|
15 | 15 |
|
16 | 16 | def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
|
17 | 17 | EgRef=1.121, dEgdT=-0.0002677, temp_ref=25, irrad_ref=1000,
|
18 |
| - root_kwargs={}): |
| 18 | + init_guess={}, root_kwargs={}): |
19 | 19 | """
|
20 | 20 | Calculates the parameters for the De Soto single diode model.
|
21 | 21 |
|
22 |
| - This procedure (described in [1]_) has the advantage of |
23 |
| - using common specifications given by manufacturers in the |
| 22 | + This procedure (described in [1]_) fits the De Soto model [2]_ using |
| 23 | + common specifications given by manufacturers in the |
24 | 24 | datasheets of PV modules.
|
25 | 25 |
|
26 |
| - The solution is found using the scipy.optimize.root() function, |
27 |
| - with the corresponding default solver method 'hybr'. |
28 |
| - No restriction is put on the fit variables, i.e. series |
| 26 | + The solution is found using :py:func:`scipy.optimize.root`, |
| 27 | + with the default solver method 'hybr'. |
| 28 | + No restriction is put on the fit variables, e.g. series |
29 | 29 | or shunt resistance could go negative. Nevertheless, if it happens,
|
30 |
| - check carefully the inputs and their units; alpha_sc and beta_voc are |
31 |
| - often given in %/K in manufacturers datasheets and should be given |
32 |
| - in A/K and V/K here. |
| 30 | + check carefully the inputs and their units. For example, ``alpha_sc`` and |
| 31 | + ``beta_voc`` are often given in %/K in manufacturers datasheets but should |
| 32 | + be given in A/K and V/K here. |
33 | 33 |
|
34 | 34 | The parameters returned by this function can be used by
|
35 |
| - :py:func:`pvlib.pvsystem.calcparams_desoto` to calculate the values at |
36 |
| - different irradiance and cell temperature. |
| 35 | + :py:func:`pvlib.pvsystem.calcparams_desoto` to calculate single diode |
| 36 | + equation parameters at different irradiance and cell temperature. |
37 | 37 |
|
38 | 38 | Parameters
|
39 | 39 | ----------
|
40 | 40 | v_mp: float
|
41 |
| - Module voltage at the maximum-power point at reference conditions [V]. |
| 41 | + Module voltage at the maximum-power point at reference conditions. [V] |
42 | 42 | i_mp: float
|
43 |
| - Module current at the maximum-power point at reference conditions [A]. |
| 43 | + Module current at the maximum-power point at reference conditions. [A] |
44 | 44 | v_oc: float
|
45 |
| - Open-circuit voltage at reference conditions [V]. |
| 45 | + Open-circuit voltage at reference conditions. [V] |
46 | 46 | i_sc: float
|
47 |
| - Short-circuit current at reference conditions [A]. |
| 47 | + Short-circuit current at reference conditions. [A] |
48 | 48 | alpha_sc: float
|
49 | 49 | The short-circuit current (i_sc) temperature coefficient of the
|
50 |
| - module [A/K]. |
| 50 | + module. [A/K] |
51 | 51 | beta_voc: float
|
52 | 52 | The open-circuit voltage (v_oc) temperature coefficient of the
|
53 |
| - module [V/K]. |
| 53 | + module. [V/K] |
54 | 54 | cells_in_series: integer
|
55 | 55 | Number of cell in the module.
|
56 | 56 | EgRef: float, default 1.121 eV - value for silicon
|
57 |
| - Energy of bandgap of semi-conductor used [eV] |
| 57 | + Energy of bandgap of semi-conductor used. [eV] |
58 | 58 | dEgdT: float, default -0.0002677 - value for silicon
|
59 |
| - Variation of bandgap according to temperature [eV/K] |
| 59 | + Variation of bandgap according to temperature. [eV/K] |
60 | 60 | temp_ref: float, default 25
|
61 |
| - Reference temperature condition [C] |
| 61 | + Reference temperature condition. [C] |
62 | 62 | irrad_ref: float, default 1000
|
63 |
| - Reference irradiance condition [W/m2] |
| 63 | + Reference irradiance condition. [Wm⁻²] |
| 64 | + init_guess: dict, optional |
| 65 | + Initial values for optimization. Keys can be `'Rsh_0'`, `'a_0'`, |
| 66 | + `'IL_0'`, `'Io_0'`, `'Rs_0'`. |
64 | 67 | root_kwargs : dictionary, optional
|
65 | 68 | Dictionary of arguments to pass onto scipy.optimize.root()
|
66 | 69 |
|
67 | 70 | Returns
|
68 | 71 | -------
|
69 | 72 | dict with the following elements:
|
70 | 73 | I_L_ref: float
|
71 |
| - Light-generated current at reference conditions [A] |
| 74 | + Light-generated current at reference conditions. [A] |
72 | 75 | I_o_ref: float
|
73 |
| - Diode saturation current at reference conditions [A] |
| 76 | + Diode saturation current at reference conditions. [A] |
74 | 77 | R_s: float
|
75 |
| - Series resistance [ohm] |
| 78 | + Series resistance. [ohm] |
76 | 79 | R_sh_ref: float
|
77 |
| - Shunt resistance at reference conditions [ohm]. |
| 80 | + Shunt resistance at reference conditions. [ohm]. |
78 | 81 | a_ref: float
|
79 | 82 | Modified ideality factor at reference conditions.
|
80 | 83 | The product of the usual diode ideality factor (n, unitless),
|
81 | 84 | number of cells in series (Ns), and cell thermal voltage at
|
82 | 85 | specified effective irradiance and cell temperature.
|
83 | 86 | alpha_sc: float
|
84 | 87 | The short-circuit current (i_sc) temperature coefficient of the
|
85 |
| - module [A/K]. |
| 88 | + module. [A/K] |
86 | 89 | EgRef: float
|
87 |
| - Energy of bandgap of semi-conductor used [eV] |
| 90 | + Energy of bandgap of semi-conductor used. [eV] |
88 | 91 | dEgdT: float
|
89 |
| - Variation of bandgap according to temperature [eV/K] |
| 92 | + Variation of bandgap according to temperature. [eV/K] |
90 | 93 | irrad_ref: float
|
91 |
| - Reference irradiance condition [W/m2] |
| 94 | + Reference irradiance condition. [Wm⁻²] |
92 | 95 | temp_ref: float
|
93 |
| - Reference temperature condition [C] |
| 96 | + Reference temperature condition. [C] |
94 | 97 |
|
95 | 98 | scipy.optimize.OptimizeResult
|
96 | 99 | Optimization result of scipy.optimize.root().
|
97 | 100 | See scipy.optimize.OptimizeResult for more details.
|
98 | 101 |
|
99 | 102 | References
|
100 | 103 | ----------
|
101 |
| - .. [1] W. De Soto et al., "Improvement and validation of a model for |
| 104 | + .. [1] J. A Duffie, W. A Beckman, "Solar Engineering of Thermal Processes", |
| 105 | + 4th ed., Wiley, 2013. :doi:`10.1002/9781118671603` |
| 106 | + .. [2] W. De Soto et al., "Improvement and validation of a model for |
102 | 107 | photovoltaic array performance", Solar Energy, vol 80, pp. 78-88,
|
103 | 108 | 2006. :doi:`10.1016/j.solener.2005.06.010`
|
| 109 | +
|
104 | 110 | """
|
105 | 111 |
|
106 | 112 | # Constants
|
107 | 113 | k = constants.value('Boltzmann constant in eV/K') # in eV/K
|
108 | 114 | Tref = temp_ref + 273.15 # [K]
|
109 | 115 |
|
110 | 116 | # initial guesses of variables for computing convergence:
|
111 |
| - # Values are taken from [2], p753 |
112 |
| - Rsh_0 = 100.0 |
113 |
| - a_0 = 1.5*k*Tref*cells_in_series |
114 |
| - IL_0 = i_sc |
115 |
| - Io_0 = i_sc * np.exp(-v_oc/a_0) |
116 |
| - Rs_0 = (a_0*np.log1p((IL_0-i_mp)/Io_0) - v_mp)/i_mp |
| 117 | + # Default values are taken from [1], p753 |
| 118 | + init_guess_keys = ['IL_0', 'Io_0', 'Rs_0', 'Rsh_0', 'a_0'] # order matters |
| 119 | + init = {key: None for key in init_guess_keys} |
| 120 | + init['IL_0'] = i_sc |
| 121 | + init['a_0'] = 1.5*k*Tref*cells_in_series |
| 122 | + init['Io_0'] = i_sc * np.exp(-v_oc/init['a_0']) |
| 123 | + init['Rs_0'] = (init['a_0']*np.log1p((init['IL_0'] - i_mp)/init['Io_0']) |
| 124 | + - v_mp) / i_mp |
| 125 | + init['Rsh_0'] = 100.0 |
| 126 | + # overwrite if optional init_guess is provided |
| 127 | + for key in init_guess: |
| 128 | + if key in init_guess_keys: |
| 129 | + init[key] = init_guess[key] |
| 130 | + else: |
| 131 | + raise ValueError(f"'{key}' is not a valid name;" |
| 132 | + f" allowed values are {init_guess_keys}") |
117 | 133 | # params_i : initial values vector
|
118 |
| - params_i = np.array([IL_0, Io_0, Rs_0, Rsh_0, a_0]) |
| 134 | + params_i = np.array([init[k] for k in init_guess_keys]) |
119 | 135 |
|
120 | 136 | # specs of module
|
121 | 137 | specs = (i_sc, v_oc, i_mp, v_mp, beta_voc, alpha_sc, EgRef, dEgdT,
|
|
0 commit comments