Skip to content

Remove unnecessary SAPM keys in pvsystem._DC_MODEL_PARAMS #2393

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 8 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions docs/sphinx/source/whatsnew/v0.11.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
v0.11.3 (Anticipated March, 2025)
---------------------------------

Bug fixes
~~~~~~~~~
* Fix a bug in :py:func:`pvlib.bifacial.get_irradiance_poa` which may have yielded non-zero
ground irradiance when the sun was below the horizon. (:issue:`2245`, :pull:`2359`)
* Fix a bug where :py:func:`pvlib.transformer.simple_efficiency` could only be imported
using the `from pvlib.transformer` syntax (:pull:`2388`)
* :py:class:`~pvlib.modelchain.ModelChain` now requires only a minimal set of
parameters to run the SAPM electrical model. (:issue:`2369`, :pull:`2393`)
* Correct keys for First Solar modules in `~pvlib.spectrum.spectral_factor_pvspec` (:issue:`2398`, :pull:`2400`)


Deprecations
~~~~~~~~~~~~

Expand All @@ -12,15 +23,10 @@ Enhancements
~~~~~~~~~~~~
* :py:func:`~pvlib.irradiance.gti_dirint` now raises an informative message
when input data don't include values with AOI<90 (:issue:`1342`, :pull:`2347`)
* Fix a bug in :py:func:`pvlib.bifacial.get_irradiance_poa` which may have yielded non-zero
ground irradiance when the sun was below the horizon. (:issue:`2245`, :pull:`2359`)
* Fix a bug where :py:func:`pvlib.transformer.simple_efficiency` could only be imported
using the `from pvlib.transformer` syntax (:pull:`2388`)
* Reduced space requirements by excluding tests and test files from wheel.
Zipped wheel is now 66% of the previous size, and installed size is 50% of
the previous size.
(:issue:`2271`, :pull:`2277`)
* Correct keys for First Solar modules in `~pvlib.spectrum.spectral_factor_pvspec` (:issue:`2398`, :pull:`2400`)

Documentation
~~~~~~~~~~~~~
Expand Down Expand Up @@ -57,4 +63,5 @@ Contributors
* Manoj K S (:ghuser:`manojks1999`)
* Kurt Rhee (:ghuser:`kurt-rhee`)
* Ayush jariyal (:ghuser:`ayushjariyal`)
* Kevin Anderson (:ghuser:`kandersolar`)
* Echedey Luis (:ghuser:`echedey-ls`)
7 changes: 3 additions & 4 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
# a dict of required parameter names for each DC power model
_DC_MODEL_PARAMS = {
'sapm': {
'A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3',
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6',
'C7', 'Isco', 'Impo', 'Voco', 'Vmpo', 'Aisc', 'Aimp', 'Bvoco',
'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7',
'Isco', 'Impo', 'Voco', 'Vmpo', 'Aisc', 'Aimp', 'Bvoco',
'Mbvoc', 'Bvmpo', 'Mbvmp', 'N', 'Cells_in_Series',
'IXO', 'IXXO', 'FD'},
'IXO', 'IXXO'},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've long wanted to move 'IX0' and 'IX00' into some kind of optional category, to allow the SAPM electrical model to run without them. That would be scope expansion in this PR; the thought resurfaces when I read "unnecessary SAPM keys" and "minimal set of parameters".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. #2402

'desoto': {
'alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
'R_sh_ref', 'R_s'},
Expand Down
18 changes: 17 additions & 1 deletion tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,22 @@ def test_infer_dc_model(sapm_dc_snl_ac_system, cec_dc_snl_ac_system,
assert isinstance(mc.results.dc, (pd.Series, pd.DataFrame))


def test_infer_dc_model_sapm_minimal(location):
# GH 2369 -- Omit A*, B*, FD parameters; specify only DC electrical keys
dc_keys = ['C0', 'C1', 'C2', 'C3', 'Isco', 'Impo', 'Voco', 'Vmpo',
'Aisc', 'Aimp', 'Bvoco', 'Bvmpo', 'Mbvoc', 'Mbvmp', 'N',
'Cells_in_Series', 'IXO', 'IXXO', 'C4', 'C5', 'C6', 'C7']
sapm_parameters = {key: 0 for key in dc_keys}

system = pvsystem.PVSystem(module_parameters=sapm_parameters,
temperature_model_parameters={'u0': 0, 'u1': 0},
inverter_parameters={'pdc0': 0})

mc = ModelChain(system, location, dc_model='sapm',
spectral_model='no_loss', aoi_model='no_loss')
assert isinstance(mc, ModelChain)


def test_infer_dc_model_incomplete(multi_array_sapm_dc_snl_ac_system,
location):
match = 'Could not infer DC model from the module_parameters attributes '
Expand Down Expand Up @@ -1730,7 +1746,7 @@ def test_invalid_dc_model_params(sapm_dc_snl_ac_system, cec_dc_snl_ac_system,
'aoi_model': 'no_loss', 'spectral_model': 'no_loss',
'temperature_model': 'sapm', 'losses_model': 'no_loss'}
for array in sapm_dc_snl_ac_system.arrays:
array.module_parameters.pop('A0') # remove a parameter
array.module_parameters.pop('C0') # remove a parameter
with pytest.raises(ValueError):
ModelChain(sapm_dc_snl_ac_system, location, **kwargs)

Expand Down