Skip to content

Conversation

williamhobbs
Copy link
Contributor

@williamhobbs williamhobbs commented Oct 7, 2025

  • Closes Nonlinear adjustment to pvwattsv5 dc model #2566
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries in docs/sphinx/source/reference 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 (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

Still some work to do . Replaces #2568.

@williamhobbs williamhobbs mentioned this pull request Oct 7, 2025
8 tasks
Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

I like this better than a separate function.

For example, a 500 W module that produces 95 W at 200 W/m^2 (a 5% relative
reduction in efficiency) would have a value of `k` = 0.01.
Copy link
Member

Choose a reason for hiding this comment

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

Please include Equation from above with k, I'd place it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my latest change. Is that what you had in mind?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that comment was not clear. I was thinking we should copy the equation for P_DC here, and show how k modifies the power. But the equation for the adjustment is not simple (the piecewise part), so I retract that thought. If someone wants to know how the adjustment works, we've provided code and the reference.

williamhobbs and others added 6 commits October 7, 2025 16:56
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Copy link
Member

@RDaxini RDaxini left a comment

Choose a reason for hiding this comment

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

Nice work @williamhobbs. Just a few simple comments/suggestions on the docs from me. Only had a quick look at the python implementation, LGTM at a glance but I could have a deeper look later if required

williamhobbs and others added 4 commits October 8, 2025 11:41
doi sphinx

Co-authored-by: RDaxini <143435106+RDaxini@users.noreply.github.com>
Co-authored-by: RDaxini <143435106+RDaxini@users.noreply.github.com>
Co-authored-by: RDaxini <143435106+RDaxini@users.noreply.github.com>
@kandersolar kandersolar added this to the v0.13.2 milestone Oct 8, 2025
Comment on lines 2960 to 2977
# apply Marion's correction if k is anything but zero
if k is not None:
err_1 = (k * (1 - (1 - effective_irradiance / 200)**4) /
(effective_irradiance / 1000))
err_2 = (k * (1000 - effective_irradiance) / (1000 - 200))

pdc_marion = np.where(effective_irradiance <= 200,
pdc * (1 - err_1),
pdc * (1 - err_2))

# "cap" Marion's correction at 1000 W/m^2
if cap_adjustment is True:
pdc_marion = np.where(effective_irradiance >= 1000,
pdc,
pdc_marion)

pdc = pdc_marion

Copy link
Member

Choose a reason for hiding this comment

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

@williamhobbs have you started / do you intend to write tests? The codecov check fails since this section is not covered by tests. Happy to help with that if you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haven't started, but figured I would need to. Do you have suggestions on tests to add? I have pretty limited experience with the pvlib testing structure/best practices.

Copy link
Member

Choose a reason for hiding this comment

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

I'd hand-calculate half a dozen points, using k. Test for correct output with input of three types: float, array, Series. Then test with cap_adjustment=True.

Copy link
Member

Choose a reason for hiding this comment

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

Be creative, test whatever comes to mind! Generally speaking, test a range of intended and extreme conditions.

Intended:
For the if statements, check whether the indented block is executed if the condition is met (for example, if k is not None, use some example values to check whether the correction is applied).
Whether the block is executed correctly should also be checked--- if k is not None, then check example irradiance values >200 and <=200 (is the intended behaviour executed correctly in these cases?)

Extreme:
What if the user enters non-physical values, how should these be handled and are they handled in this way? e.g. negative or NaN irradiance values

Someone else might be able to offer a clearer/more succinct explanation 😅

Copy link
Member

@RDaxini RDaxini Oct 8, 2025

Choose a reason for hiding this comment

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

I'd hand-calculate half a dozen points, using k. Test for correct output with input of three types: float, array, Series. Then test with cap_adjustment=True.

Good point, check whether different data types are handled appropriately too

Copy link
Member

Choose a reason for hiding this comment

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

@williamhobbs you do not have to test with k=None, that is covered by existing tests. Any new tests would be better in their own function, e.g., test_pvwatts_dc_with_k.

Copy link
Member

Choose a reason for hiding this comment

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

@williamhobbs you do not have to test with k=None, that is covered by existing tests.

Correct, my bad. I was trying to make a general point but overlooked that in the example.
See the codecov report

Any new tests would be better in their own function, e.g., test_pvwatts_dc_with_k.

Add to test_pvsystem.py (examples also visible there)

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

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

Thanks @williamhobbs good stuff! Happy to see this added to pvlib, less sure about the API right now.

We've been talking about changing this function name to pvwatts_dc_v5 in #1350. I think these new parameters will look quite out of place if we do go through with that. Which makes me think a separate function might be preferable.

This adjustment increases relative efficiency for irradiance above 1000
Wm⁻², which may not be desired. An optional input, `capped_adjustment`,
modifies the adjustment from [2]_ to only apply below 1000 Wm⁻².
Copy link
Member

Choose a reason for hiding this comment

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

any concerns about deviating from a reference here? I'm ok with it but imagine it could be a point of contention. perhaps some more documentation clarity would help

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also wondered about deviating from the reference. It just gives the option to apply the Marion 2008 correction up to 1000 Wm-2, and stay with standard pvwatts above that, so seems like a minor deviation.

And I can definitely add more documentation. I tend to get to long-winded and was trying to fight that. I’m open to suggestions, but will also work on some additions.

(effective_irradiance / 1000))
err_2 = (k * (1000 - effective_irradiance) / (1000 - 200))

pdc_marion = np.where(effective_irradiance <= 200,
Copy link
Member

Choose a reason for hiding this comment

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

np.where will break the paradigm of "return the same object type that was input" since it always returns an array. Options:

  1. keep np.where, cast output to match input
  2. switch to slicing, assume array input
  3. switch to slicing, promote scalars to arrays for compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean. I tried a few things, but can’t seem to figure out how to get your proposed solutions to work. Any pointers or examples?

(1 + gamma_pdc * (temp_cell - temp_ref)))

# apply Marion's correction if k is anything but zero
if k is not None:
Copy link
Member

Choose a reason for hiding this comment

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

needing to use the is not None paradigm is a small reason to prefer a separate function

@cwhanse
Copy link
Member

cwhanse commented Oct 8, 2025

We've been talking about changing this function name to pvwatts_dc_v5 in #1350. I think these new parameters will look quite out of place if we do go through with that. Which makes me think a separate function might be preferable.

I'm not dismissing your point. But to reply, PVWatts v8 (or whatever it is called now) is a moving target that does not have much documentation. I think, if we do anything with the newer PVWatts in pvlib (once it stablizes and is documented somehow), we could name that new function "pvwatts_v8" and leave the existing functions names without the version suffix.

Comment on lines +2936 to +2941
For positive `k` values, and `k` is typically positive, this adjustment
increases relative efficiency when irradiance is above 1000 Wm⁻². This may
not be desired, as modules with nonlinear irradiance response often have
peak efficiency near 1000 Wm⁻², and it is either flat or declining at
higher irradiance. An optional parameter, `cap_adjustment`, can address
this by modifying the adjustment from [2]_ to only apply below 1000 Wm⁻².
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wholmgren, does this help with clarifying the deviation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nonlinear adjustment to pvwattsv5 dc model

5 participants