8000 update snlinverter variable names · sschiffel/pvlib-python@e8a71bf · GitHub
[go: up one dir, main page]

Skip to content

Commit e8a71bf

Browse files
committed
update snlinverter variable names
1 parent bc763a5 commit e8a71bf

File tree

2 files changed

+40
-21
lines changed

2 files changed

+40
-21
lines changed

pvlib/pvsystem.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,17 +1115,17 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
11151115
return I.real
11161116

11171117

1118-
def snlinverter(inverter, Vmp, Pmp):
1118+
def snlinverter(inverter, v_dc, p_dc):
11191119
'''
11201120
Converts DC power and voltage to AC power using
11211121
Sandia's Grid-Connected PV Inverter model.
11221122
1123-
Determine the AC power output of an inverter given the DC voltage, DC
1123+
Determines the AC power output of an inverter given the DC voltage, DC
11241124
power, and appropriate Sandia Grid-Connected Photovoltaic Inverter
1125-
Model parameters. The output, ACPower, is clipped at the maximum power
1125+
Model parameters. The output, ac_power, is clipped at the maximum power
11261126
output, and gives a negative power during low-input power conditions,
11271127
but does NOT account for maximum power point tracking voltage windows
1128-
nor maximum current or voltage limits on the inverter.
1128+
nor maximum current or voltage limits on the inverter.
11291129
11301130
Parameters
11311131
----------
@@ -1165,22 +1165,22 @@ def snlinverter(inverter, Vmp, Pmp):
11651165
maintain circuitry required to sense PV array voltage (W)
11661166
====== ============================================================
11671167
1168-
Vdc : float or DataFrame
1168+
v_dc : float or Series
11691169
DC voltages, in volts, which are provided as input to the inverter.
11701170
Vdc must be >= 0.
1171-
Pdc : float or DataFrame
1171+
p_dc : float or Series
11721172
A scalar or DataFrame of DC powers, in watts, which are provided
11731173
as input to the inverter. Pdc must be >= 0.
11741174
11751175
Returns
11761176
-------
1177-
ACPower : float or DataFrame
1177+
ac_power : float or Series
11781178
Modeled AC power output given the input
1179-
DC voltage, Vdc, and input DC power, Pdc. When ACPower would be
1179+
DC voltage, Vdc, and input DC power, Pdc. When ac_power would be
11801180
greater than Pac0, it is set to Pac0 to represent inverter
1181-
"clipping". When ACPower would be less 8000 than Ps0 (startup power
1182-
required), then ACPower is set to -1*abs(Pnt) to represent nightly
1183-
power losses. ACPower is not adjusted for maximum power point
1181+
"clipping". When ac_power would be less than Ps0 (startup power
1182+
required), then ac_power is set to -1*abs(Pnt) to represent nightly
1183+
power losses. ac_power is not adjusted for maximum power point
11841184
tracking (MPPT) voltage windows or maximum current limits of the
11851185
inverter.
11861186
@@ -1207,11 +1207,18 @@ def snlinverter(inverter, Vmp, Pmp):
12071207
C3 = inverter['C3']
12081208
Pnt = inverter['Pnt']
12091209

1210-
A = Pdco*((1 + C1*((Vmp - Vdco))))
1211-
B = Pso*((1 + C2*((Vmp - Vdco))))
1212-
C = C0*((1 + C3*((Vmp - Vdco))))
1213-
ACPower = ((Paco / (A - B)) - C*((A - B)))*((Pmp - B)) + C*((Pmp - B) ** 2)
1214-
ACPower[ACPower > Paco] = Paco
1215-
ACPower[ACPower < Pso] = - 1.0 * abs(Pnt)
1210+
A = Pdco * (1 + C1*(v_dc - Vdco))
1211+
B = Pso * (1 + C2*(v_dc - Vdco))
1212+
C = C0 * (1 + C3*(v_dc - Vdco))
1213+
1214+
# ensures that function works with scalar or Series input
1215+
p_dc = pd.Series(p_dc)
1216+
1217+
ac_power = ( Paco/(A-B) - C*(A-B) ) * (p_dc-B) + C*((p_dc-B)**2)
1218+
ac_power[ac_power > Paco] = Paco
1219+
ac_power[ac_power < Pso] = - 1.0 * abs(Pnt)
1220+
1221+
if len(ac_power) == 1:
1222+
ac_power = ac_power.ix[0]
12161223

1217-
return ACPower
1224+
return ac_power

pvlib/test/test_pvsystem.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pandas as pd
1010

1111
from nose.tools import assert_equals, assert_almost_equals
12-
from pandas.util.testing import assert_frame_equal
12+
from pandas.util.testing import assert_series_equal, assert_frame_equal
1313

1414
from pvlib import tmy
1515
from pvlib import pvsystem
@@ -180,9 +180,21 @@ def test_sapm_celltemp_with_index():
180180
def test_snlinverter():
181181
inverters = sam_data['sandiainverter']
182182
testinv = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'
183-
vdcs = pd.Series(np.linspace(0,50,51))
184-
idcs = pd.Series(np.linspace(0,11,110))
183+
vdcs = pd.Series(np.linspace(0,50,3))
184+
idcs = pd.Series(np.linspace(0,11,3))
185185
pdcs = idcs * vdcs
186186

187187
pacs = pvsystem.snlinverter(inverters[testinv], vdcs, pdcs)
188+
assert_series_equal(pacs, pd.Series([-0.020000, 132.004308, 250.000000]))
189+
190+
191+
def test_snlinverter_float():
192+
inverters = sam_data['sandiainverter']
193+
testinv = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'
194+
vdcs = 25.
195+
idcs = 5.5
196+
pdcs = idcs * vdcs
197+
198+
pacs = pvsystem.snlinverter(inverters[testinv], vdcs, pdcs)
199+
assert_almost_equals(pacs, 132.004308, 5)
188200

0 commit comments

Comments
 (0)
0