Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add methods and tests for a explicit IV curve calculation of single-diode model #409

Merged
merged 76 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
22d2e5c
add methods and tests for a faster way to calculate single-diode model
mikofski Jan 27, 2018
bb7c49a
log estimate of speedup in test
mikofski Jan 27, 2018
36d4f78
use ordered dict for output, match inputs and outputs, add iv-curve
mikofski Jan 27, 2018
817a303
add "slow" but reliable ways to calculate i_from_v and vv
mikofski Jan 28, 2018
b17a8cd
add check for numerical errors
mikofski Jan 30, 2018
0666d29
use float64, output symbols for fun, make executable
mikofski Jan 30, 2018
595e254
add tests for slower_way using fminbound
mikofski Jan 30, 2018
5ade588
change voc to v_oc
mikofski Jan 30, 2018
7179096
add numeric type to args in docstrings
mikofski Jan 30, 2018
4b66f87
replace custom newton method with scipy.optimize.newton
mikofski Jan 31, 2018
664d7d8
get lambdas working in fast_i_from_v
mikofski Jan 31, 2018
09a9e14
add fast_v_from_i using newton
mikofski Jan 31, 2018
06be522
add fast_mppt
mikofski Jan 31, 2018
1aba56a
calculate i_x and i_xx too for both fast and slow
mikofski Jan 31, 2018
f09be91
test i_x and i_xx too
mikofski Jan 31, 2018
4905363
use brentq instead of fminbound
mikofski Jan 31, 2018
a3d2bb4
change test for numerical errors to use data file
mikofski Jan 31, 2018
8ee1b94
working on #410
mikofski Jan 31, 2018
c9a893a
helping test_singlediode pass tests
mikofski Jan 31, 2018
c5248bb
add the requires scipy decorator
mikofski Jan 31, 2018
68c65c3
fixes #410
mikofski Jan 31, 2018
41e0c83
add i, v, and p to out
mikofski Jan 31, 2018
d7b6e62
need to calculate i-v curve points to compare
mikofski Jan 31, 2018
aa3d29a
add mppt method, update docs
mikofski Jan 31, 2018
9fc350d
fix latex and other sphinx formatting issue sand typos
mikofski Jan 31, 2018
54e8d18
fix circular import issues?
mikofski Feb 1, 2018
16ad9b4
try something remove redundant package imports
mikofski Feb 1, 2018
7aca302
don't raise import error at module level if no scipy
mikofski Feb 1, 2018
086e73f
okay I think I fixed it, now return pvlib module objects
mikofski Feb 1, 2018
9f2b157
try to modify i_from_v
mikofski Feb 1, 2018
555e946
implement v_from_i wrapper
mikofski Feb 1, 2018
52a8e88
respond to @thunderfish24 review items:
mikofski Feb 1, 2018
c0e18a5
change default argument for method to "gold"
mikofski Feb 1, 2018
09c6a75
update test_singlediode_methods to use lambertw in comparison
mikofski Feb 1, 2018
ff8cc0b
change name from mppt -> mpp
mikofski Feb 1, 2018
446fa9e
add test to check for verbose yet graceful failure of v_from_i
mikofski Feb 1, 2018
f976f61
fix pytest.raise context, add test_v_from_i
mikofski Feb 1, 2018
db88022
change mppt->mpp in api.rst docs
mikofski Feb 1, 2018
a509dd3
fix what's new to point to mpp in docs, also add links to bishop88 an…
mikofski Feb 1, 2018
62010c2
Merge branch 'master' into faster_way
mikofski Jun 20, 2018
5c939b8
TST: fix precision test to use new calcparams* API
mikofski Jun 20, 2018
66a801d
TST: update singlediode test for updated atol in #415
mikofski Jun 20, 2018
df1423b
DOC: update what's new for 0.6 with proposed explicit SDM solution
mikofski Jun 20, 2018
eb20cf4
DOC: update docstring to conform to numpydoc style in sdm methods
mikofski Jun 20, 2018
e3805ef
Merge branch 'master' into faster_way
mikofski Jun 26, 2018
5f89578
ENH: refactor est_voc -> estimate_voc
mikofski Jun 26, 2018
ba84fcf
ENH refactor pvsystem.estimate_voc too, also update docs to numpy style
mikofski Jun 26, 2018
0f3893c
ENH refactor vd->diode_voltage in bishop88
mikofski Jun 26, 2018
d6023b1
ENH: TST: refactor reshaping conditions for _array_newton
mikofski Jun 27, 2018
80b3352
ENH: TST: make brentq vectorized always
mikofski Jun 27, 2018
ef20676
ENH: TST: can't vectorize brentq because it treats args as array
mikofski Jun 27, 2018
98d1c01
BUG: TST: use "brentq" instead of "gold"
mikofski Jun 27, 2018
4ecd913
TST: change test fixtures with nonsensical values in quadrant four
mikofski Jun 27, 2018
bf05d2d
TST: fix mpp tests
mikofski Jun 28, 2018
edc445d
ENH: clean up last little bit
mikofski Jun 28, 2018
f542d15
ENH: BUG: TST: DOC: remove all traces for "fast" or "slow"
mikofski Jun 28, 2018
cc6c976
TST: BUG: fix the boolean mask numpy<1.14 bug in tests
mikofski Jun 28, 2018
22c53fc
ENH: TST: ignore .pytest_cache/ folder
mikofski Jun 29, 2018
442a3d4
DOC: MAINT: respond to review by @cwhanse , clean up docstrings
mikofski Jun 29, 2018
6bcffe8
MAINT: update comment about mpp search algorithm
mikofski Jun 29, 2018
e6b60c6
MAINT: update what's new for v0.6
mikofski Jun 29, 2018
0fc9c83
DOC: make sure docs render well
mikofski Jun 29, 2018
fc6cee1
DOC: MAINT: rewording what's new with @cwhanse comments to make it clear
mikofski Jun 29, 2018
28c8ffb
API: change bishop88 and estimate_voc to be used from singlediode_met…
mikofski Jun 29, 2018
58361c1
DOC: link to new singlediode_methods subfunctions in what's new
mikofski Jun 29, 2018
5f9ed41
API: DOC: ENH: change pvsystem.mpp() -> max_power_point()
mikofski Jun 29, 2018
43475cc
MAINT: address comments by @wholmgren
mikofski Jun 30, 2018
c79ab97
Merge branch 'master' into faster_way
mikofski Jul 10, 2018
1ad6031
MAINT: add comment to explain why we import brentq in try-except
mikofski Jul 10, 2018
f14ba04
MAINT: move lambertw methods to singlediode_methods.py
mikofski Jul 10, 2018
8d86560
MAINT: add docstring elaborating the numerical precision test
mikofski Jul 10, 2018
337d7b4
MAINT: use np.expm1(x) for exp(x) - 1 in bishop88 single diode method
mikofski Jul 10, 2018
ce5b0f5
MAINT: replace boilerplate code for broadcasting newton array args
mikofski Jul 10, 2018
3e009f8
MAINT: TEST: parametrize i_from_v and v_from_i for methods, atol
mikofski Jul 10, 2018
082dfd5
MAINT: remove import of functools.partial in pvsystem.py
mikofski Jul 10, 2018
ceb69cd
MAINT: wrap lines longer than 79 characters
mikofski Jul 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Byte-compiled / optimized / DLL files
.pytest_cache/
__pycache__/
*.py[cod]

Expand Down
15 changes: 13 additions & 2 deletions docs/sphinx/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ algorithm.

spa


Correlations and analytical expressions for low precision solar position
calculations.

Expand All @@ -80,6 +79,7 @@ calculations.
solarposition.equation_of_time_pvcdrom
solarposition.hour_angle


Clear sky
=========

Expand Down Expand Up @@ -206,6 +206,18 @@ Functions relevant for the single diode model.
pvsystem.i_from_v
pvsystem.singlediode
pvsystem.v_from_i
pvsystem.max_power_point

Low-level functions for solving the single diode equation.

.. autosummary::
:toctree: generated/

singlediode_methods.estimate_voc
singlediode_methods.bishop88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cwhanse you once asked for a more specific function name. Does encapsulating the function within a singlediode module address that concern?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with bishop88 here as a member of singlediode_methods. It's siblings will be lambertw and perhaps others.

singlediode_methods.bishop88_i_from_v
singlediode_methods.bishop88_v_from_i
singlediode_methods.bishop88_mpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"methods" makes me think of methods vs. functions but maybe that's just me. probably best to go with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my thought, also, but in this case I think it's OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change this to "how" I think that's what Pandas often uses. Is there any precedent for PVLIB?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean singlediode_how.py? A little odd to me but not opposed. singlediode_algorithms? I'd stay away from singlediode_models here. I am ok with singlediode_methods if others are. I think the context is clear enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with singlediode_methods

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL! I meant the keyword, but I'm fine with everything as it is if you are.


SAPM model
----------
Expand All @@ -232,7 +244,6 @@ PVWatts model
pvsystem.pvwatts_ac
pvsystem.pvwatts_losses


Other
-----

Expand Down
42 changes: 38 additions & 4 deletions docs/sphinx/source/whatsnew/v0.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,43 @@ API Changes

Enhancements
~~~~~~~~~~~~
* Add sea surface albedo in irradiance.py (:issue:`458`)
* Implement first_solar_spectral_loss in modelchain.py (:issue:`359`)
* Clarify arguments Egref and dEgdT for calcparams_desoto (:issue:`462`)
* Add pvsystem.calcparams_pvsyst to compute values for the single diode equation using the PVsyst v6 model (:issue:'470')
* Add sea surface albedo in ``irradiance.py`` (:issue:`458`)
* Implement :meth:`~pvlib.modelchain.ModelChain.first_solar_spectral_loss`
in ``modelchain.py`` (:issue:`359`)
* Clarify arguments ``Egref`` and ``dEgdT`` for
:func:`~pvlib.pvsystem.calcparams_desoto` (:issue:`462`)
* Add pvsystem.calcparams_pvsyst to compute values for the single diode equation
using the PVsyst v6 model (:issue:'470')
* Extend :func:`~pvlib.pvsystem.singlediode` with an additional keyword argument
``method`` in ``('lambertw', 'newton', 'brentq')``, default is ``'lambertw'``,
to select a method to solve the single diode equation for points on the IV
curve. Selecting either ``'brentq'`` or ``'newton'`` as the method uses
:func:`~pvlib.singlediode_methods.bishop88` with the corresponding method.
(:issue:`410`)
* Implement new methods ``'brentq'`` and ``'newton'`` for solving the single
diode equation for points on the IV curve. ``'brentq'`` uses a bisection
method (Brent, 1973) that may be slow but guarantees a solution. ``'newton'``
uses the Newton-Raphson method and may be faster but is not guaranteed to
converge. However, ``'newton'`` should be safe for well-behaved IV curves.
(:issue:`408`)
* Implement :func:`~pvlib.singlediode_methods.bishop88` for explicit calculation
of arbitrary IV curve points using diode voltage instead of cell voltage. If
``method`` is either ``'newton'`` or ``'brentq'`` and ``ivcurve_pnts`` in
:func:`~pvlib.pvsystem.singlediode` is provided, the IV curve points will be
log spaced instead of linear.
* Implement :func:`~pvlib.singlediode_methods.estimate_voc` to estimate open
circuit voltage by assuming :math:`R_{sh} \to \infty` and :math:`R_s=0` as an
upper bound in bisection method for :func:`~pvlib.pvsystem.singlediode` when
method is either ``'newton'`` or ``'brentq'``.
* Add :func:`~pvlib.pvsystem.max_power_point` method to compute the max power
point using the new ``'brentq'`` method.
* Add new module ``pvlib.singlediode_methods`` with low-level functions for
solving the single diode equation such as:
:func:`~pvlib.singlediode_methods.bishop88`,
:func:`~pvlib.singlediode_methods.estimate_voc`,
:func:`~pvlib.singlediode_methods.bishop88_i_from_v`,
:func:`~pvlib.singlediode_methods.bishop88_v_from_i`, and
:func:`~pvlib.singlediode_methods.bishop88_mpp`.


Bug fixes
Expand Down Expand Up @@ -50,5 +83,6 @@ Contributors
* Will Holmgren
* Yu Cao
* Cliff Hansen
* Mark Mikofski
* Alan Mathew

1 change: 1 addition & 0 deletions pvlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from pvlib import pvsystem
from pvlib import spa
from pvlib import modelchain
from pvlib import singlediode_methods
101 changes: 101 additions & 0 deletions pvlib/data/bishop88_numerical_precision.csv

Large diffs are not rendered by default.

Loading