Skip to content

Commit 0abc6ce

Browse files
wholmgrencwhanse
authored andcommitted
limit pvwatts_ac to gte 0 (#542)
Closes #541
1 parent 5728d11 commit 0abc6ce

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/sphinx/source/whatsnew/v0.6.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Bug fixes
118118
Hay-Davies diffuse sky algorithms. (:issue:`432`)
119119
* Fix argument order of longitude and latitude when querying weather forecasts
120120
by lonlat bounding box (:issue:`521`)
121+
* Limit pvwatts_ac results to be greater than or equal to 0. (:issue:`541`)
121122

122123

123124
Documentation

pvlib/pvsystem.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,9 +2693,11 @@ def pvwatts_ac(pdc, pdc0, eta_inv_nom=0.96, eta_inv_ref=0.9637):
26932693
pac0 = eta_inv_nom * pdc0
26942694
zeta = pdc / pdc0
26952695

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

26982699
pac = eta * pdc
26992700
pac = np.minimum(pac0, pac)
2701+
pac = np.maximum(0, pac) # GH 541
27002702

27012703
return pac

pvlib/test/test_pvsystem.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,14 @@ def test_pvwatts_ac_scalars():
12751275
assert_allclose(out, expected)
12761276

12771277

1278+
def test_pvwatts_ac_possible_negative():
1279+
# pvwatts_ac could return a negative value for (pdc / pdc0) < 0.006
1280+
# unless it is clipped. see GH 541 for more
1281+
expected = 0
1282+
out = pvsystem.pvwatts_ac(0.001, 1)
1283+
assert_allclose(out, expected)
1284+
1285+
12781286
@needs_numpy_1_10
12791287
def test_pvwatts_ac_arrays():
12801288
pdc = np.array([[np.nan], [50], [100]])

0 commit comments

Comments
 (0)