Skip to content

Commit 0e7ee1b

Browse files
committed
update sde, sdm tests to use pvsystem.i_from_v
1 parent 54457f4 commit 0e7ee1b

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

pvlib/tests/ivtools/test_sde.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ def get_test_iv_params():
1212

1313
def test_fit_sandia_simple(get_test_iv_params, get_bad_iv_curves):
1414
test_params = get_test_iv_params
15-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
16-
testcurve = pvsystem.singlediode(photocurrent=test_params['IL'],
17-
saturation_current=test_params['I0'],
18-
resistance_shunt=test_params['Rsh'],
19-
resistance_series=test_params['Rs'],
20-
nNsVth=test_params['nNsVth'],
21-
ivcurve_pnts=300)
22-
expected = tuple(test_params[k] for k in ['IL', 'I0', 'Rs', 'Rsh',
23-
'nNsVth'])
24-
result = sde.fit_sandia_simple(voltage=testcurve['v'],
25-
current=testcurve['i'])
15+
test_params = dict(photocurrent=test_params['IL'],
16+
saturation_current=test_params['I0'],
17+
resistance_series=test_params['Rs'],
18+
resistance_shunt=test_params['Rsh'],
19+
nNsVth=test_params['nNsVth'])
20+
testcurve = pvsystem.singlediode(**test_params)
21+
v = np.linspace(0., testcurve['v_oc'], 300)
22+
i = pvsystem.i_from_v(voltage=v, **test_params)
23+
expected = tuple(test_params.values())
24+
25+
result = sde.fit_sandia_simple(voltage=v, current=i)
2626
assert np.allclose(result, expected, rtol=5e-5)
27-
result = sde.fit_sandia_simple(voltage=testcurve['v'],
28-
current=testcurve['i'],
27+
28+
result = sde.fit_sandia_simple(voltage=v, current=i,
2929
v_oc=testcurve['v_oc'],
3030
i_sc=testcurve['i_sc'])
3131
assert np.allclose(result, expected, rtol=5e-5)
32-
result = sde.fit_sandia_simple(voltage=testcurve['v'],
33-
current=testcurve['i'],
32+
33+
result = sde.fit_sandia_simple(voltage=v, current=i,
3434
v_oc=testcurve['v_oc'],
3535
i_sc=testcurve['i_sc'],
3636
v_mp_i_mp=(testcurve['v_mp'],
37-
testcurve['i_mp']))
37+
testcurve['i_mp']))
3838
assert np.allclose(result, expected, rtol=5e-5)
39-
result = sde.fit_sandia_simple(voltage=testcurve['v'],
40-
current=testcurve['i'], vlim=0.1)
39+
40+
result = sde.fit_sandia_simple(voltage=v, current=i, vlim=0.1)
4141
assert np.allclose(result, expected, rtol=5e-5)
4242

4343

pvlib/tests/ivtools/test_sdm.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ def test_fit_desoto_sandia(cec_params_cansol_cs5p_220p):
101101
temp_cell = np.array([15., 25., 35., 45.])
102102
ee = np.tile(effective_irradiance, len(temp_cell))
103103
tc = np.repeat(temp_cell, len(effective_irradiance))
104-
iph, io, rs, rsh, nnsvth = pvsystem.calcparams_desoto(
104+
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
105105
ee, tc, alpha_sc=specs['alpha_sc'], **params)
106-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
107-
sim_ivcurves = pvsystem.singlediode(iph, io, rs, rsh, nnsvth,
108-
ivcurve_pnts=300)
109-
sim_ivcurves['ee'] = ee
110-
sim_ivcurves['tc'] = tc
106+
ivcurve_params = dict(photocurrent=IL, saturation_current=I0,
107+
resistance_series=Rs, resistance_shunt=Rsh,
108+
nNsVth=nNsVth)
109+
sim_ivcurves = pvsystem.singlediode(**ivcurve_params).to_dict('series')
110+
v = np.linspace(0., sim_ivcurves['v_oc'], 300)
111+
i = pvsystem.i_from_v(voltage=v, **ivcurve_params)
112+
sim_ivcurves.update(v=v.T, i=i.T, ee=ee, tc=tc)
111113

112114
result = sdm.fit_desoto_sandia(sim_ivcurves, specs)
113115
modeled = pd.Series(index=params.keys(), data=np.nan)

0 commit comments

Comments
 (0)