-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Create inverter.py #886
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
Create inverter.py #886
Conversation
I fully support the new module, but I wonder about the naming. Perhaps 'efficiency' or 'power' should be part of it, since that's what the current functions model? I can imagine inverter-related functions that model other aspects. |
Ready for review |
pvlib/tests/test_modelchain.py
Outdated
@@ -447,22 +447,29 @@ def acdc(mc): | |||
mc.ac = mc.dc | |||
|
|||
|
|||
# TODO in v0.9: remove 'snlinverter', 'adrinverter', 'pvwatts' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about 'pvwatts' being removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've edited the TODO comment to drop the 'snlinverter' and 'adrinverter' values for ModelChain.ac_model
.
There's a loose thread outside of this PR, in that PVSystem.snlinverter
, PVSystem.adrinverter
and PVSystem.pvwatts_ac
methods aren't renamed. I couldn't come up with a naming scheme for the PVSystem
methods that I liked, when the methods wrap functions in a different module. The method name needs to package both the method purpose (inverter model) and the model (snl, adr, pvwatts).
Test failures are unrelated (NREL server not responding), otherwise I think I've addressed the review comments (thanks @kanderso-nrel ) |
@kanderso-nrel can you see if the NSRDB PSM3 data service is offline? Looks that way to me. Test are passing except |
I'm getting tests passing except for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments. I wish github would allow comments on code that wasn't changed in the PR, but absent that here is a list:
- lines 2444, 2446 in pvsystem.py still reference
pvsystem.pvwatts_ac
. git grep -n snlinverter
shows a handful of docs files still referencing pvsystem.snlinverter. I checked the other two and didn't see any offenders.
docs/sphinx/source/introtutorial.rst:99: ac = pvlib.pvsystem.snlinverter(dc['v_mp'], dc['p_mp'], inverter)
docs/sphinx/source/introtutorial.rst:245: ac = localized_system.snlinverter(dc['v_mp'], dc['p_mp'])
docs/tutorials/forecast.ipynb:8162: " ac_model: snlinverter\n",
docs/tutorials/forecast_to_power.ipynb:879: "p_ac = pvsystem.snlinverter(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
docs/tutorials/pvsystem.ipynb:576: "### snlinverter"
docs/tutorials/pvsystem.ipynb:1359: "pacs = pvsystem.snlinverter(vdcs, pdcs, inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'])\n",
docs/tutorials/tmy_to_power.ipynb:1187: "p_acs['sapm'] = pvlib.pvsystem.snlinverter(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
docs/tutorials/tmy_to_power.ipynb:1188: "p_acs['sd'] = pvlib.pvsystem.snlinverter(single_diode_out.v_mp, single_diode_out.p_mp, sapm_inverter)\n",
pvlib/inverter.py
Outdated
Pnt AC power consumed by inverter at night (night tare) to | ||
maintain circuitry required to sense PV array voltage. [W] | ||
|
||
======= ============================================================ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sphinx still doesn't like this. I'm not if all of these steps are necessary, but I got it working locally for me by:
- Adding spacing between terms and definitions so that there is no overlap between columns (the ADRCoefficients term sticks out pretty far)
- Extending the left
====
strings so that they completely cover the column width - Removing the empty line between Pnt and the trailing line.
Here's the text that works for me (with some text reflows to stay under 80 chars):
=============== ========================================================
Column Description
=============== ========================================================
Pnom Nominal DC power, typically the DC power needed to
produce maximum AC power output. [W]
Vnom Nominal DC input voltage. Typically the level at which
the highest efficiency is achieved. [V]
Vmax Maximum DC input voltage. [V]
Vmin Minimum DC input voltage. [V]
Vdcmax . [V]
MPPTHi Maximum DC voltage for MPPT range. [V]
MPPTLow Minimum DC voltage for MPPT range. [V]
Pacmax Maximum AC output power, used to clip the output power
if needed. [W]
ADRCoefficients A list of 9 coefficients that capture the influence
of input voltage and power on inverter losses, and
thereby efficiency. Corresponds to terms from [1]_
(in order): :math:`b_{0,0}, b_{1,0}, b_{2,0}, b_{0,1},
b_{1,1}, b_{2,1}, b_{0,2}, b_{1,2}, b_{1,2}`. See [1]_
for the use of each coefficient and the associated unit.
Pnt AC power consumed by inverter at night (night tare) to
maintain circuitry required to sense PV array voltage.
[W]
=============== ========================================================
pvlib/inverter.py
Outdated
Pnt AC power consumed by inverter at night (night tare) to | ||
maintain circuitry required to sense PV array voltage. [W] | ||
|
||
======= ============================================================ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more notes: Vdcmax is still undefined and b_{1,2}
is repeated in ADRCoefficients
, presumably should be b_{2,2}
?
Many thanks for checking this. I've made these corrections where the function is referenced; other instances are references to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that most of the output of git grep -n snlinverter
is from ModelChain or the PVSystem method, but I think this subset is still the pvsystem function:
docs/tutorials/forecast_to_power.ipynb:879: "p_ac = pvsystem.snlinverter(sapm_out.v_mp, sapm_out.p_mp, sapm_inverter)\n",
docs/tutorials/pvsystem.ipynb:576: "### snlinverter"
docs/tutorials/pvsystem.ipynb:1359: "pacs = pvsystem.snlinverter(vdcs, pdcs, inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'])\n",
Otherwise LGTM!
What does the ### formatting do? I assumed this was just an internal label or link. |
@wholmgren ok to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay @cwhanse. A handful of minor things but looks very close.
Thanks @kanderso-nrel for the detailed review.
- :py:func:`pvlib.pvsystem.snlinverter` is now :py:func:`pvlib.inverter.sandia` | ||
- :py:func:`pvlib.pvsystem.pvwatts_ac` is now :py:func:`pvlib.inverter.pvwatts` | ||
- :py:func:`pvlib.pvsystem.adrinverter` is now :py:func:`pvlib.inverter.adr` | ||
* ModelChain.ac_model now accepts `'sandia'`, `'pvwatts'` and `'adr'` for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this line render as you intend it to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'sandia'
is intended to display as a string value. Should it be marked differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pvlib/modelchain.py
Outdated
@@ -56,7 +56,7 @@ def basic_chain(times, latitude, longitude, | |||
See temperature.sapm_cell for details. | |||
|
|||
inverter_parameters : None, dict or Series | |||
Inverter parameters as defined by the CEC. See pvsystem.snlinverter for | |||
Inverter parameters as defined by the CEC. See inverter.sandia for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noting the open comment that may have been buried
'sandia': 'snlinverter', | ||
'adrinverter': 'adrinverter', | ||
'adr': 'adrinverter', | ||
'pvwatts': 'pvwatts_ac'} | ||
system = ac_systems[ac_model] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would test that the deprecation warning is raised if the ac method name is snlinverter or adrinverter. Ok with me to skip it though since the code looks correct and is not too complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a test for the deprecation warning if ModelChain.ac_model is assigned 'snlinverter' or 'adrinverter'
The ModelChain and PVSystem methods are still snlinverter and adrinverter. Do we want to rename those as well? I favor doing that, but in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we should rename the methods in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor doc comments then ready to merge
@@ -3,15 +3,25 @@ | |||
v0.8.0 (Month day, year) | |||
------------------------- | |||
|
|||
API Changes with Deprecations | |||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |||
* Moved functions related to inverters from `pvsystem.py` to `inverter.py`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Moved functions related to inverters from `pvsystem.py` to `inverter.py`. | |
* Moved functions related to inverters from ``pvsystem.py`` to ``inverter.py``. |
* Attribute :py:attribute:`modelchain.ModelChain.ac_model` now accepts ``sandia``, | ||
``pvwatts`` and ``adr`` for the inverter models. (:pull:`886`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the vast majority of people set this through the ac_model
kwarg rather than the attribute. So I would link to :py:class:`pvlib.modelchain.ModelChain`
instead. Also suggest adding '
within the code blocks.
@@ -23,6 +33,8 @@ Testing | |||
~~~~~~~ | |||
* Decorator :py:func:`pvlib.conftest.fail_on_pvlib_version` can now be | |||
applied to functions that require args or kwargs. (:pull:`973`) | |||
* Test added for :py:meth:`ModelChain` to confirm ValueError when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use same link code as commented above
pvlib/inverter.py
Outdated
def adr(v_dc, p_dc, inverter, vtol=0.10): | ||
r''' | ||
Converts DC power and voltage to AC power using Anton Driesse's | ||
Grid-Connected PV Inverter efficiency model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grid-Connected PV Inverter efficiency model | |
Grid-Connected PV Inverter efficiency model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grid-connected inverter?
docs/sphinx/source/api.rst
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).Creates
inverter.py
pvsystem.snlinverter
toinverter.sandia
pvsystem.adrinverter
toinverter.adr
pvsystem.pvwatts_ac
toinverter.pvwatts