-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add consistency tests to ModelChain.dc_model #548
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
Changes from 1 commit
d3c1ae3
6884555
1c4ac04
a04e111
3e1116b
1fa1be3
121a8b1
10a5f7d
c0f58c3
ae3d572
e11d1c5
743c621
669d4bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,16 +365,56 @@ def dc_model(self, model): | |
elif isinstance(model, str): | ||
model = model.lower() | ||
if model == 'sapm': | ||
self._dc_model = self.sapm | ||
# validate module parameters | ||
missing_params = self._sapm_param_set() - \ | ||
set(self.system.module.keys()) | ||
if missing_params: # some parameters are not in module.keys() | ||
raise ValueError('SAPM selected for the DC model but ' + \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can get by without the |
||
'the module is missing one or more ' + \ | ||
'required parameters: ' + \ | ||
str(missing_params)) | ||
else: | ||
self._dc_model = self.sapm | ||
elif model == 'singlediode': | ||
self._dc_model = self.singlediode | ||
# validate module parameters | ||
missing_params = self._singlediode_param_set() - \ | ||
set(self.system.module.keys()) | ||
if missing_params: # some parameters are not in module.keys() | ||
raise ValueError('singlediode selected for the DC ' + \ | ||
'model but the module is missing one ' + \ | ||
'or more required parameters: ' + \ | ||
str(missing_params)) | ||
else: | ||
self._dc_model = self.singlediode | ||
elif model == 'pvwatts': | ||
self._dc_model = self.pvwatts_dc | ||
# validate module parameters | ||
missing_params = self._pvwatts_dc_param_set() - \ | ||
set(self.system.module.keys()) | ||
if missing_params: # some parameters are not in module.keys() | ||
raise ValueError('pvwatts_dc selected for the DC ' + \ | ||
'model but the module is missing one ' + \ | ||
'or more required parameters: ' + \ | ||
str(missing_params)) | ||
else: | ||
self._dc_model = self.pvwatts_dc | ||
else: | ||
raise ValueError(model + ' is not a valid DC power model') | ||
else: | ||
self._dc_model = partial(model, self) | ||
|
||
def _sapm_param_set(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok with using a function for each of these but it seems a bit overkill and harder to extend in the future. One alternative would be defining a class or module level dictionary like this: dc_model_parameters = {'sapm': set([....]), 'singlediode': set([...]), 'pvwatts': set([...])} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One could argue that this parameter dictionary should live in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At what point in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably at the top with the rest of the imports. |
||
return set(['A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3', 'B4', | ||
'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'Isco', | ||
'Impo', 'Aisc', 'Aimp', 'Bvoco', 'Mbvoc', 'Bvmpo', 'Mbvmp', | ||
'N', 'Cells_in_Series', 'IX0', 'IXX0', 'FD']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you want to use this whole set in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
|
||
def _singlediode_param_set(): | ||
return set(['alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref', | ||
'R_s']) | ||
|
||
def _pvwatts_dc_param_set(): | ||
return set(['pdc0', 'gamma_pdc']) | ||
|
||
def infer_dc_model(self): | ||
params = set(self.system.module_parameters.keys()) | ||
if set(['A0', 'A1', 'C7']) <= params: | ||
|
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.
self.system.module_parameters.keys()