Skip to content

Commit a6ecb75

Browse files
authored
remove unnecessary module argument from singlediode function (#202)
* remove module from singlediode * update whatsnew * remove unused partial * consolidate line
1 parent 1c02806 commit a6ecb75

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

docs/sphinx/source/whatsnew/v0.4.0.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ the API changes.
1111
API Changes
1212
~~~~~~~~~~~
1313

14-
* In ``pvlib.irradiance.perez``, renamed argument ``modelt`` to ``model`` (:issue:`196`)
14+
* Remove unneeded module argument from singlediode function. (:issue:`200`)
15+
* In ``pvlib.irradiance.perez``, renamed argument ``modelt`` to ``model``.
16+
(:issue:`196`)
17+
1518

1619
Enhancements
1720
~~~~~~~~~~~~

pvlib/pvsystem.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ def singlediode(self, photocurrent, saturation_current,
350350
-------
351351
See pvsystem.singlediode for details
352352
"""
353-
return singlediode(self.module_parameters, photocurrent,
354-
saturation_current,
353+
return singlediode(photocurrent, saturation_current,
355354
resistance_series, resistance_shunt, nNsVth)
356355

357356
def i_from_v(self, resistance_shunt, resistance_series, nNsVth, voltage,
@@ -1334,9 +1333,9 @@ def sapm_celltemp(poa_global, wind_speed, temp_air,
13341333
return pd.DataFrame({'temp_cell': temp_cell, 'temp_module': temp_module})
13351334

13361335

1337-
def singlediode(module, photocurrent, saturation_current,
1338-
resistance_series, resistance_shunt, nNsVth):
1339-
'''
1336+
def singlediode(photocurrent, saturation_current, resistance_series,
1337+
resistance_shunt, nNsVth):
1338+
r'''
13401339
Solve the single-diode model to obtain a photovoltaic IV curve.
13411340
13421341
Singlediode solves the single diode equation [1]
@@ -1357,9 +1356,6 @@ def singlediode(module, photocurrent, saturation_current,
13571356
13581357
Parameters
13591358
----------
1360-
module : dict or Series
1361-
A dict-like object defining the SAPM performance parameters.
1362-
13631359
photocurrent : float or Series
13641360
Light-generated current (photocurrent) in amperes under desired
13651361
IV curve conditions. Often abbreviated ``I_L``.
@@ -1439,8 +1435,7 @@ def singlediode(module, photocurrent, saturation_current,
14391435
'i_0': saturation_current,
14401436
'i_l': photocurrent}
14411437

1442-
p_mp, v_mp = _golden_sect_DataFrame(params, 0, module['V_oc_ref']*1.14,
1443-
_pwr_optfcn)
1438+
p_mp, v_mp = _golden_sect_DataFrame(params, 0, v_oc*1.14, _pwr_optfcn)
14441439

14451440
# Invert the Power-Current curve. Find the current where the inverted power
14461441
# is minimized. This is i_mp. Start the optimization at v_oc/2

pvlib/test/test_pvsystem.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pandas as pd
88

99
from nose.tools import assert_equals, assert_almost_equals
10+
from numpy.testing import assert_allclose
1011
from pandas.util.testing import assert_series_equal, assert_frame_equal
1112
from numpy.testing import assert_allclose
1213

@@ -268,14 +269,19 @@ def test_singlediode_series():
268269
module_parameters=module_parameters,
269270
EgRef=1.121,
270271
dEgdT=-0.0002677)
271-
out = pvsystem.singlediode(module_parameters, IL, I0, Rs, Rsh, nNsVth)
272+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth)
272273
assert isinstance(out, pd.DataFrame)
273274

274275

276+
# nose didn't like it when I tried to use partial (wholmgren)
277+
def assert_allclose_atol_01(*args):
278+
return assert_allclose(*args, atol=0.02)
279+
280+
275281
def test_singlediode_floats():
276282
module = 'Example_Module'
277283
module_parameters = sam_data['cecmod'][module]
278-
out = pvsystem.singlediode(module_parameters, 7, 6e-7, .1, 20, .5)
284+
out = pvsystem.singlediode(7, 6e-7, .1, 20, .5)
279285
expected = {'i_xx': 4.2685798754011426,
280286
'i_mp': 6.1390251797935704,
281287
'v_oc': 8.1063001465863085,
@@ -285,7 +291,7 @@ def test_singlediode_floats():
285291
'v_mp': 6.221535886625464}
286292
assert isinstance(out, dict)
287293
for k, v in out.items():
288-
yield assert_almost_equals, expected[k], v, 3
294+
yield assert_allclose_atol_01, expected[k], v
289295

290296

291297
def test_PVSystem_singlediode_floats():
@@ -303,7 +309,7 @@ def test_PVSystem_singlediode_floats():
303309
'v_mp': 6.221535886625464}
304310
assert isinstance(out, dict)
305311
for k, v in out.items():
306-
yield assert_almost_equals, expected[k], v, 3
312+
yield assert_allclose_atol_01, expected[k], v
307313

308314

309315
def test_scale_voltage_current_power():

0 commit comments

Comments
 (0)