1919CONSTANTS = {'E0' : 1000.0 , 'T0' : 25.0 , 'k' : constants .k , 'q' : constants .e }
2020
2121
22- IEC61853 = pd .DataFrame (
22+ IEC61853_plus = pd .DataFrame (
2323 columns = ['effective_irradiance' , 'temp_cell' ],
2424 data = np .array (
2525 [[100 , 100 , 100 , 100 , 200 , 200 , 200 , 200 , 400 , 400 , 400 , 400 ,
3030 dtype = np .float64 )
3131
3232
33- def _pvsyst_objfun (pvs_mod , cec_ivs , ee , tc , cs ):
33+ IEC61853 = pd .DataFrame (
34+ columns = ['effective_irradiance' , 'temp_cell' ],
35+ data = np .array (
36+ [[100 , 100 , 200 , 200 , 400 , 400 , 400 ,
37+ 600 , 600 , 600 , 600 , 800 , 800 , 800 , 800 , 1000 , 1000 , 1000 , 1000 ,
38+ 1100 , 1100 , 1100 ],
39+ [15 , 25 , 15 , 25 , 15 , 25 , 50 ,
40+ 15 , 25 , 50 , 75 , 15 , 25 , 50 , 75 , 15 , 25 , 50 , 75 ,
41+ 25 , 50 , 75 ]]).T ,
42+ dtype = np .float64 )
43+
3444
45+ def _pvsyst_objfun (pvs_mod , cec_ivs , ee , tc , cs ):
46+ # objective function for converting CEC to PVsyst model
3547 # translate the guess into named args that are used in the functions
36- # order : [alpha_sc, gamma_ref, mu_gamma, I_L_ref, I_o_ref,
37- # R_sh_mult, R_sh_ref, R_s]
48+ # order of variables in pvs_mod:
49+ # [alpha_sc, gamma_ref, mu_gamma, I_L_ref, I_o_ref,
50+ # R_sh_mult, R_sh_ref, R_s]
3851 # cec_ivs : DataFrame with columns i_sc, v_oc, i_mp, v_mp, p_mp
3952 # ee : effective irradiance
4053 # tc : cell temperature
@@ -56,6 +69,9 @@ def _pvsyst_objfun(pvs_mod, cec_ivs, ee, tc, cs):
5669
5770 pvsyst_ivs = singlediode (* pvs_params )
5871
72+
73+ # calculate error metric, mean absolute relative error for PVsyst model as
74+ # the target
5975 isc_diff = np .abs ((pvsyst_ivs ['i_sc' ] - cec_ivs ['i_sc' ]) /
6076 cec_ivs ['i_sc' ]).mean ()
6177 imp_diff = np .abs ((pvsyst_ivs ['i_mp' ] - cec_ivs ['i_mp' ]) /
@@ -194,8 +210,10 @@ def convert_cec_pvsyst(cec_model, cells_in_series, method='Nelder-Mead',
194210
195211
196212def _cec_objfun (cec_mod , pvs_ivs , ee , tc , alpha_sc ):
213+ # objective function for converting PVsyst to CEC model
197214 # translate the guess into named args that are used in the functions
198- # order : [I_L_ref, I_o_ref, a_ref, R_sh_ref, R_s, alpha_sc, Adjust]
215+ # order of variables in cec_mod:
216+ # [I_L_ref, I_o_ref, a_ref, R_sh_ref, R_s, alpha_sc, Adjust]
199217 # pvs_ivs : DataFrame with columns i_sc, v_oc, i_mp, v_mp, p_mp
200218 # ee : effective irradiance
201219 # tc : cell temperature
@@ -212,6 +230,7 @@ def _cec_objfun(cec_mod, pvs_ivs, ee, tc, alpha_sc):
212230 ee , tc , alpha_sc , a_ref , I_L_ref , I_o_ref , R_sh_ref , R_s , Adjust )
213231 cec_ivs = singlediode (* cec_params )
214232
233+ # calculate error metric, root sum of squares for CEC model as the target
215234 isc_rss = np .sqrt (sum ((cec_ivs ['i_sc' ] - pvs_ivs ['i_sc' ])** 2 ))
216235 imp_rss = np .sqrt (sum ((cec_ivs ['i_mp' ] - pvs_ivs ['i_mp' ])** 2 ))
217236 voc_rss = np .sqrt (sum ((cec_ivs ['v_oc' ] - pvs_ivs ['v_oc' ])** 2 ))
0 commit comments