Skip to content

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

Merged
merged 13 commits into from
Jan 28, 2021

Conversation

wholmgren
Copy link
Member

@wholmgren wholmgren commented Jan 27, 2021

  • follow up to Implement PVSystem.get_ac #1147
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries to docs/sphinx/source/api.rst for API changes.
  • Adds description and name entries in the appropriate "what's new" file in 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`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels and Milestone are assigned to the Pull Request and linked Issue.

One could argue there should be a deprecation period for the ModelChain.snlinverter and ModelChain.adrinverter methods, but I'd be shocked if anyone is directly calling them.

@wholmgren wholmgren added the api label Jan 27, 2021
@wholmgren wholmgren added this to the 0.9.0 milestone Jan 27, 2021
@wholmgren wholmgren mentioned this pull request Jan 27, 2021
8 tasks
@wholmgren wholmgren requested a review from cwhanse January 27, 2021 22:54
@@ -790,9 +786,9 @@ def infer_ac_model(self):
if self.system.num_arrays > 1:
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@cwhanse cwhanse Jan 28, 2021

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.

Copy link
Member Author

@wholmgren wholmgren Jan 28, 2021

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.

Copy link
Member

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.

@mikofski
Copy link
Member

Every time I see this I think it says PVsyst.get_ac 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants