8000 refactor ModelChain inverter methods to use PVSystem.get_ac by wholmgren · Pull Request #1150 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

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
Prev Previous commit
remove _infer_ac_model_multi
  • Loading branch information
wholmgren committed Jan 28, 2021
commit 7b8bb4ebc337b475f41a21a37db3c238e3f99d32
20 changes: 6 additions & 14 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,30 +783,22 @@ def ac_model(self, model):
def infer_ac_model(self):
"""Infer AC power model from system attributes."""
inverter_params = set(self.system.inverter_parameters.keys())
if self.system.num_arrays > 1:
return self._infer_ac_model_multi(inverter_params)
if _snl_params(inverter_params):
return self.sandia_inverter
if _adr_params(inverter_params):
return self.adr_inverter
if self.system.num_arrays > 1:
raise ValueError(
'The adr inverter function cannot be used for an inverter',
' with multiple MPPT inputs')
else:
return self.adr_inverter
if _pvwatts_params(inverter_params):
return self.pvwatts_inverter
raise ValueError('could not infer AC model from '
'system.inverter_parameters. Check '
'system.inverter_parameters or explicitly '
'set the model with the ac_model kwarg.')

def _infer_ac_model_multi(self, inverter_params):
if _snl_params(inverter_params):
return self.sandia_inverter
elif _pvwatts_params(inverter_params):
return self.pvwatts_inverter
raise ValueError('could not infer multi-array AC model from '
'system.inverter_parameters. Only sandia and pvwatts '
'inverter models support multiple '
'Arrays. Check system.inverter_parameters or '
'explicitly set the model with the ac_model kwarg.')

def sandia_inverter(self):
self.results.ac = self.system.get_ac(
'sandia',
Expand Down
2 changes: 1 addition & 1 deletion pvlib/tests/test_modelchain.py
685D
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def test_ModelChain_invalid_inverter_params_arrays(
sapm_dc_snl_ac_system_same_arrays.inverter_parameters = \
inverter_params[inverter]
with pytest.raises(ValueError,
match=r'Only sandia and pvwatts inverter models'):
match=r'adr inverter function cannot'):
ModelChain(sapm_dc_snl_ac_system_same_arrays, location)


Expand Down
0