-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Consider replacing inverter methods in PVSystem with a single method with a kwarg #998
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
Comments
I’m all for this. The other wrapper methods for multiple models use a get_ prefix so might want to consider that for consistency. |
|
@cwhanse we've added a couple more inverter models (the multi variants) to As for name, I think |
Agree. I'm partial to I can work on this. |
How should we account for the lack of voltage data with pvwatts? I guess we can use a kwarg that's required for the non-pvwatts methods. Alternatively we could require the user to pass an argument that would be ignored for the pvwatts method. Neither sounds great. |
For |
Reaction to this def get_ac(self, p_dc, v_dc=None, model=None):
r"""Calculates AC power from p_dc using the inverter model indicated
by model and self.inverter_parameters.
Parameter model must be one of 'sandia', 'adr', or 'pvwatts'.
Parameter v_dc is required for model='sandia' or model='adr'.
"""
model = model.lower()
if model not in ['sandia', 'pvwatts', 'adr']:
raise ValueError(
model + ' is not a valid AC power model.',
' model must be one of "sandia", "adr" or "pvwatts"')
if model == 'pvwatts':
kwargs = _build_kwargs(['eta_inv_nom', 'eta_inv_ref'],
self.inverter_parameters)
if self.num_arrays > 1:
if model not in ['sandia', 'pvwatts']:
raise ValueError(
model + ' is not a valid AC power model.',
' model must be one of "sandia", "adr" or "pvwatts"')
p_dc = self._validate_per_array(p_dc)
if v_dc is not None:
v_dc = self._validate_per_array(v_dc)
if model == 'sandia':
return inverter.sandia_multi(v_dc, p_dc,
self.inverter_parameters)
elif model == 'pvwatts':
return inverter.pvwatts_multi(
p_dc, self.inverter_parameters['pdc0'], **kwargs)
else: # single array
if model == 'sandia':
return inverter.sandia(v_dc, p_dc, self.inverter_parameters)
elif model == 'pvwatts':
return inverter.pvwatts(p_dc, self.inverter_parameters['pdc0'],
**kwargs)
elif model == 'adr':
return self.adrinverter(v_dc, p_dc) |
I think the laddered if/else is clear but not elegant. It could be more compact (and probably less clear) if we accepted 'sandia_mult' and 'pvwatts_multi' as model values, but, I think it's easier on the user to build the multi-array inverter model selection into this method. |
What is expected from
|
Method generally looks good to me. A few suggestions:
I'm ok with that. Would you apply the same logic to the modelchain layer? That would be my preference.
We don't necessarily need to do that at the same time. Those As for actual implementation, one way might be to set the attribute equal to a |
#886 moved inverter-related functions from
pvsystem.py
toinverter.py
. MethodsPVSystem.snlinverter
andPVsystem.adrinverter
currently wrapinverter.sandia
andinverter.adr
, respectively, which previously werepvsystem.snlinverter
andpvsystem.adrinverter
.Perhaps renaming the functions creates potential for confusion.
It may be an improved API to replace
PVSystem.snlinverter
,PVSystem.adrinverter
andPVSystem.pvwatts_ac
with a single methodPVSystem.dc_to_ac
or similar, with a kwargmodel='sandia'
for example.Opening for discussion.
The text was updated successfully, but these errors were encountered: