Skip to content

Commit 7179096

Browse files
committed
add numeric type to args in docstrings
* so that pycharm will stop complaining * add a bunch of todo's for pvlib#408 and pvlib#410 * use DELTA instead of recalculating each time * fix typo/bug in docstring for nNsVth arg, missing trailing colon (:) had quotes (") instead
1 parent 5ade588 commit 7179096

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

pvlib/way_faster.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from collections import OrderedDict
88
import numpy as np
9-
from scipy.optimize import fminbound, newton
9+
from scipy.optimize import fminbound
1010

1111
logging.basicConfig()
1212
LOGGER = logging.getLogger(__name__)
@@ -16,16 +16,24 @@
1616
DAMP = 1.5
1717
DELTA = EPS**0.33
1818

19+
# TODO: make fast_i_from_v, fast_v_from_i, fast_mppt using newton
20+
# TODO: remove grad calcs from bishop88
21+
# TODO: add new residual and f_prime calcs for fast_ methods to use newton
22+
# TODO: refactor singlediode to be a wrapper with a method argument
23+
# TODO: update pvsystem.singlediode to use slow_ methods by default
24+
# TODO: ditto for i_from_v and v_from_i
25+
# TODO: add new mppt function to pvsystem
26+
1927

2028
def est_voc(photocurrent, saturation_current, nNsVth):
2129
"""
2230
Rough estimate of open circuit voltage useful for bounding searches for
2331
``i`` of ``v`` when using :func:`~pvlib.way_faster`.
2432
25-
:param photocurrent: photo-generated current [A]
26-
:param saturation_current: diode one reverse saturation current [A]
27-
:param nNsVth: product of thermal voltage ``Vth`` [V], diode ideality
28-
factor ``n``, and number of series cells ``Ns``
33+
:param numeric photocurrent: photo-generated current [A]
34+
:param numeric saturation_current: diode one reverse saturation current [A]
35+
:param numeric nNsVth: product of thermal voltage ``Vth`` [V], diode
36+
ideality factor ``n``, and number of series cells ``Ns``
2937
:returns: rough estimate of open circuit voltage [V]
3038
"""
3139
# http://www.pveducation.org/pvcdrom/open-circuit-voltage
@@ -42,13 +50,13 @@ def bishop88(vd, photocurrent, saturation_current, resistance_series,
4250
photovoltaic cell interconnection circuits" JW Bishop, Solar Cell (1988)
4351
https://doi.org/10.1016/0379-6787(88)90059-2
4452
45-
:param vd: diode voltages [V}]
46-
:param photocurrent: photo-generated current [A]
47-
:param saturation_current: diode one reverse saturation current [A]
48-
:param resistance_series: series resitance [ohms]
49-
:param resistance_shunt: shunt resitance [ohms]
50-
:param nNsVth" product of thermal voltage ``Vth`` [V], diode ideality
51-
factor ``n``, and number of series cells ``Ns``
53+
:param numeric vd: diode voltages [V]
54+
:param numeric photocurrent: photo-generated current [A]
55+
:param numeric saturation_current: diode one reverse saturation current [A]
56+
:param numeric resistance_series: series resitance [ohms]
57+
:param numeric resistance_shunt: shunt resitance [ohms]
58+
:param numeric nNsVth: product of thermal voltage ``Vth`` [V], diode
59+
ideality factor ``n``, and number of series cells ``Ns``
5260
:returns: tuple containing currents [A], voltages [V], gradient ``di/dvd``,
5361
gradient ``dv/dvd``, power [W], gradient ``dp/dv``, and gradient
5462
``d2p/dv/dvd``
@@ -169,9 +177,8 @@ def faster_way(photocurrent, saturation_current, resistance_series,
169177
voc_est, newton_step, i_test, v_test, resnorm
170178
)
171179
if test:
172-
delta = EPS**0.3
173-
i_test2, _, _, _, _, _, _ = bishop88(voc_est * (1.0 + delta), *args)
174-
LOGGER.debug('test_grad=%g', (i_test2 - i_test) / voc_est / delta)
180+
i_test2, _, _, _, _, _, _ = bishop88(voc_est * (1.0 + DELTA), *args)
181+
LOGGER.debug('test_grad=%g', (i_test2 - i_test) / voc_est / DELTA)
175182
LOGGER.debug('grad=%g', grad)
176183
# find isc too
177184
isc_est = 0.0
@@ -191,9 +198,8 @@ def faster_way(photocurrent, saturation_current, resistance_series,
191198
vd_sc, newton_step, isc_est, v_test, resnorm
192199
)
193200
if test:
194-
delta = EPS**0.3
195-
_, v_test2, _, _, _, _, _ = bishop88(vd_sc * (1.0 + delta), *args)
196-
LOGGER.debug('test_grad=%g', (v_test2 - v_test) / vd_sc / delta)
201+
_, v_test2, _, _, _, _, _ = bishop88(vd_sc * (1.0 + DELTA), *args)
202+
LOGGER.debug('test_grad=%g', (v_test2 - v_test) / vd_sc / DELTA)
197203
LOGGER.debug('grad=%g', grad)
198204
# find the mpp
199205
imp_est, vmp_est, pmp_est = 0.0, 0.0, 0.0
@@ -213,9 +219,8 @@ def faster_way(photocurrent, saturation_current, resistance_series,
213219
vd_mp, newton_step, pmp_est, resnorm
214220
)
215221
if test:
216-
delta = EPS**0.3
217-
_, _, _, _, _, grad_p2, _ = bishop88(vd_mp * (1.0 + delta), *args)
218-
LOGGER.debug('test_grad=%g', (grad_p2 - grad_p) / vd_mp / delta)
222+
_, _, _, _, _, grad_p2, _ = bishop88(vd_mp * (1.0 + DELTA), *args)
223+
LOGGER.debug('test_grad=%g', (grad_p2 - grad_p) / vd_mp / DELTA)
219224
LOGGER.debug('grad=%g', grad2p)
220225
out = OrderedDict()
221226
out['i_sc'] = isc_est

0 commit comments

Comments
 (0)