-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor ModelChain inverter methods to use PVSystem.get_ac #1150
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
Conversation
pvlib/modelchain.py
Outdated
@@ -790,9 +786,9 @@ def infer_ac_model(self): | |||
if self.system.num_arrays > 1: |
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.
Do we still need both infer_ac_model
and infer_ac_model_multi
? Maybe not.
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.
The alternative is something like the nested if statements of PVSystem.get_ac
. We need some way of raising a ValueError
if num_arrays > 1
and the parameters are not consistent with pvwatts or sandia (essentially what we have now in ModelChain
). Equivalently, for now, we could raise a ValueError
if num_arrays > 1
and the parameters are consistent with adr (essentially what we have now in PVSystem.get_ac
). This behavior is tested in test_ModelChain_invalid_inverter_params_arrays
. I have a slight preference to leave it alone, but I'll change it if you prefer it more like PVSystem.get_ac
.
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.
We need some way of raising a ValueError if num_arrays > 1 and the parameters are not consistent with pvwatts or sandia (essentially what we have now in ModelChain).
Agree. It might make more sense to do the validation in PVSystem.get_ac
so that it catches both ModelChain and PVSystem users.
The _infer
methods are only used when the inverter model isn't named, and the parameters for either _multi
inverter model are the same as for the single MPPT version. That's why I don't see a need to keep both _infer
methods since the ModelChain methods are aligned with the three model names rather than with the five inverter
functions.
Assuming you agree with either of these points, I'm OK deferring to later work.
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.
One more trade off here... The validation in the infer method helps avoid errors in PVSystem.get_ac during run_model. Traditionally ModelChain.run_model is nearly guaranteed to run if ModelChain can infer all methods at construction. Of course, as you point out, it only works if the user does not pass ac_model.
I'm generally -1 on input validation within pvlib so I'm ok with changing this in the long run.
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.
Raise ValueError in _infer_ac_model
when parameters indicate 'adr' and num_arrays > 1. Otherwise get_ac
should be fine.
Every time I see this I think it says |
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`
).One could argue there should be a deprecation period for the
ModelChain.snlinverter
andModelChain.adrinverter
methods, but I'd be shocked if anyone is directly calling them.