14
14
15
15
from pvlib .pvsystem import singlediode , v_from_i
16
16
17
- from pvlib .ivtools .utility import constants , rectify_iv_curve , _numdiff
17
+ from pvlib .ivtools .utils import rectify_iv_curve , _numdiff
18
18
from pvlib .ivtools .sde import _fit_sandia_cocontent
19
19
20
20
@@ -299,7 +299,7 @@ def _system_of_equations_desoto(params, specs):
299
299
return y
300
300
301
301
302
- def fit_pvsyst_sandia (ivcurves , specs , const = constants , maxiter = 5 , eps1 = 1.e-3 ):
302
+ def fit_pvsyst_sandia (ivcurves , specs , const = None , maxiter = 5 , eps1 = 1.e-3 ):
303
303
"""
304
304
Estimate parameters for the PVsyst module performance model.
305
305
@@ -414,6 +414,9 @@ def fit_pvsyst_sandia(ivcurves, specs, const=constants, maxiter=5, eps1=1.e-3):
414
414
.. [7] PVLib MATLAB https://github.com/sandialabs/MATLAB_PV_LIB
415
415
"""
416
416
417
+ if const is None :
418
+ const = {'E0' : 1000.0 , 'T0' : 25.0 , 'k' : 1.38066e-23 , 'q' : 1.60218e-19 }
419
+
417
420
ee = ivcurves ['ee' ]
418
421
tc = ivcurves ['tc' ]
419
422
tck = tc + 273.15
@@ -474,7 +477,7 @@ def fit_pvsyst_sandia(ivcurves, specs, const=constants, maxiter=5, eps1=1.e-3):
474
477
return pvsyst
475
478
476
479
477
- def fit_desoto_sandia (ivcurves , specs , const = constants , maxiter = 5 , eps1 = 1.e-3 ):
480
+ def fit_desoto_sandia (ivcurves , specs , const = None , maxiter = 5 , eps1 = 1.e-3 ):
478
481
"""
479
482
Estimate parameters for the De Soto module performance model.
480
483
@@ -573,6 +576,9 @@ def fit_desoto_sandia(ivcurves, specs, const=constants, maxiter=5, eps1=1.e-3):
573
576
.. [4] PVLib MATLAB https://github.com/sandialabs/MATLAB_PV_LIB
574
577
"""
575
578
579
+ if const is None :
580
+ const = {'E0' : 1000.0 , 'T0' : 25.0 , 'k' : 1.38066e-23 , 'q' : 1.60218e-19 }
581
+
576
582
ee = ivcurves ['ee' ]
577
583
tc = ivcurves ['tc' ]
578
584
tck = tc + 273.15
@@ -936,10 +942,11 @@ def _update_io(voc, iph, io, rs, rsh, nnsvth):
936
942
dvoc = pvoc - voc
937
943
938
944
# Update Io
939
- new_io = tio * (1. + (2. * dvoc ) / (2. * nnsvth - dvoc ))
945
+ with np .errstate (invalid = "ignore" , divide = "ignore" ):
946
+ new_io = tio * (1. + (2. * dvoc ) / (2. * nnsvth - dvoc ))
947
+ # Calculate Maximum Percent Difference
948
+ maxerr = np .max (np .abs (new_io - tio ) / tio ) * 100.
940
949
941
- # Calculate Maximum Percent Difference
942
- maxerr = np .max (np .abs (new_io - tio ) / tio ) * 100.
943
950
tio = new_io
944
951
k += 1.
945
952
@@ -1128,8 +1135,9 @@ def _update_rsh_fixed_pt(vmp, imp, iph, io, rs, rsh, nnsvth):
1128
1135
1129
1136
for i in range (niter ):
1130
1137
_ , z = _calc_theta_phi_exact (vmp , imp , iph , io , rs , x1 , nnsvth )
1131
- next_x1 = (1 + z ) / z * ((iph + io ) * x1 / imp - nnsvth * z / imp - 2 *
1132
- vmp / imp )
1138
+ with np .errstate (divide = "ignore" ):
1139
+ next_x1 = (1 + z ) / z * ((iph + io ) * x1 / imp - nnsvth * z / imp
1140
+ - 2 * vmp / imp )
1133
1141
x1 = next_x1
1134
1142
1135
1143
return x1
@@ -1191,12 +1199,12 @@ def _calc_theta_phi_exact(vmp, imp, iph, io, rs, rsh, nnsvth):
1191
1199
1192
1200
# Argument for Lambert W function involved in V = V(I) [2] Eq. 12; [3]
1193
1201
# Eq. 3
1194
- with np .errstate (over = "ignore" ):
1202
+ with np .errstate (over = "ignore" , divide = "ignore" , invalid = "ignore" ):
1195
1203
argw = np .where (
1196
1204
nnsvth == 0 ,
1197
1205
np .nan ,
1198
1206
rsh * io / nnsvth * np .exp (rsh * (iph + io - imp ) / nnsvth ))
1199
- phi = np .where (argw > 0 , lambertw (argw ).real , np .nan )
1207
+ phi = np .where (argw > 0 , lambertw (argw ).real , np .nan )
1200
1208
1201
1209
# NaN where argw overflows. Switch to log space to evaluate
1202
1210
u = np .isinf (argw )
@@ -1216,21 +1224,23 @@ def _calc_theta_phi_exact(vmp, imp, iph, io, rs, rsh, nnsvth):
1216
1224
1217
1225
# Argument for Lambert W function involved in I = I(V) [2] Eq. 11; [3]
1218
1226
# E1. 2
1219
- with np .errstate (over = "ignore" ):
1227
+ with np .errstate (over = "ignore" , divide = "ignore" , invalid = "ignore" ):
1220
1228
argw = np .where (
1221
1229
nnsvth == 0 ,
1222
1230
np .nan ,
1223
1231
rsh / (rsh + rs ) * rs * io / nnsvth * np .exp (
1224
1232
rsh / (rsh + rs ) * (rs * (iph + io ) + vmp ) / nnsvth ))
1225
- theta = np .where (argw > 0 , lambertw (argw ).real , np .nan )
1233
+ theta = np .where (argw > 0 , lambertw (argw ).real , np .nan )
1226
1234
1227
1235
# NaN where argw overflows. Switch to log space to evaluate
1228
1236
u = np .isinf (argw )
1229
1237
if np .any (u ):
1230
- logargw = (
1231
- np .log (rsh [u ]) / (rsh [u ] + rs [u ]) + np .log (rs [u ]) + np .log (io [u ])
1232
- - np .log (nnsvth [u ]) + (rsh [u ] / (rsh [u ] + rs [u ]))
1233
- * (rs [u ] * (iph [u ] + io [u ]) + vmp [u ]) / nnsvth [u ])
1238
+ with np .errstate (divide = "ignore" ):
1239
+ logargw = (
1240
+ np .log (rsh [u ]) - np .log (rsh [u ] + rs [u ]) + np .log (rs [u ])
1241
+ + np .log (io [u ]) - np .log (nnsvth [u ])
1242
+ + (rsh [u ] / (rsh [u ] + rs [u ]))
1243
+ * (rs [u ] * (iph [u ] + io [u ]) + vmp [u ]) / nnsvth [u ])
1234
1244
# Three iterations of Newton-Raphson method to solve w+log(w)=logargW.
1235
1245
# The initial guess is w=logargW. Where direct evaluation (above)
1236
1246
# results in NaN from overflow, 3 iterations of Newton's method gives
0 commit comments