Skip to content

limit pvwatts_ac results to greater than equal to 0 #542

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 1 commit into from
Aug 23, 2018
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
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Bug fixes
Hay-Davies diffuse sky algorithms. (:issue:`432`)
* Fix argument order of longitude and latitude when querying weather forecasts
by lonlat bounding box (:issue:`521`)
* Limit pvwatts_ac results to be greater than or equal to 0. (:issue:`541`)


Documentation
Expand Down
2 changes: 2 additions & 0 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2693,9 +2693,11 @@ def pvwatts_ac(pdc, pdc0, eta_inv_nom=0.96, eta_inv_ref=0.9637):
pac0 = eta_inv_nom * pdc0
zeta = pdc / pdc0

# eta < 0 if zeta < 0.006. pac is forced to be >= 0 below. GH 541
eta = eta_inv_nom / eta_inv_ref * (-0.0162*zeta - 0.0059/zeta + 0.9858)

pac = eta * pdc
pac = np.minimum(pac0, pac)
pac = np.maximum(0, pac) # GH 541

return pac
8 changes: 8 additions & 0 deletions pvlib/test/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,14 @@ def test_pvwatts_ac_scalars():
assert_allclose(out, expected)


def test_pvwatts_ac_possible_negative():
# pvwatts_ac could return a negative value for (pdc / pdc0) < 0.006
# unless it is clipped. see GH 541 for more
expected = 0
out = pvsystem.pvwatts_ac(0.001, 1)
assert_allclose(out, expected)


@needs_numpy_1_10
def test_pvwatts_ac_arrays():
pdc = np.array([[np.nan], [50], [100]])
Expand Down