Skip to content

Commit ca2d908

Browse files
committed
fixup! Implement initial storage support
1 parent 2d738d0 commit ca2d908

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

docs/sphinx/source/user_guide/storage.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ In order to work with time series pvlib relies on pandas and pytz to handle
6060
time and time zones. See "Time and time zones" section for a brief
6161
introduction.
6262

63-
Also, when dealing with storage systems and energy flow, you need to take into
63+
Also, when dealing with storage systems and power flow, you need to take into
6464
account the following conventions:
6565

66-
- Timestamps are associated to the beginning of the interval
66+
- Timestamps are associated to the beginning of the interval, as opposed to
67+
other pvlib series where timestamps are instantaneous
6768

6869
- The time series frequency needs to be well defined in the time series
6970

70-
- Values represent power throughout the interval, in W
71+
- Values represent a constant power throughout the interval, in W (power flow
72+
simplifies calculations if you want to be able to model different time step
73+
lengths)
7174

7275
- Positive values represent power provided by the storage system (i.e.:
7376
discharging), hence negative values represent power into the storage system
@@ -232,6 +235,9 @@ cycles:
232235
@suppress
233236
plt.close()
234237
238+
239+
.. ipython:: python
240+
235241
@savefig sam_soc.png
236242
results["SOC"].plot(ylabel="SOC (%)")
237243
@suppress
@@ -241,10 +247,7 @@ cycles:
241247
Power flow
242248
----------
243249

244-
TODO: We are assuming power flow instead of energy flow in this module. Should we change that? It seems SAM works with power flow, maybe for a good reason? Or maybe it is more common? It seems to me like energy flow is more intuitive, but... :shrug: Or maybe we could rename it to "Power balance" instead of "Power flow" (and leave the flow for "Energy flow")
245-
246-
With pvlib you can simulate power/energy flow for different scenarios and use
247-
cases.
250+
With pvlib you can simulate power flow for different scenarios and use cases.
248251

249252
Self consumption
250253
****************
@@ -302,7 +305,7 @@ self-consumption use case:
302305

303306
.. ipython:: python
304307
305-
from pvlib.flow import self_consumption
308+
from pvlib.powerflow import self_consumption
306309
307310
power_flow = self_consumption(generation, load)
308311
power_flow.head()
@@ -313,7 +316,7 @@ from grid to load/system:
313316

314317
.. ipython:: python
315318
316-
from pvlib.flow import self_consumption
319+
from pvlib.powerflow import self_consumption
317320
318321
@savefig power_flow_self_consumption_load.png
319322
power_flow.groupby(power_flow.index.hour).mean()[["System to load", "Grid to load"]].plot.bar(stacked=True, xlabel="Hour", ylabel="Power (W)", title="Average power flow to load")
@@ -367,7 +370,7 @@ function:
367370

368371
.. ipython:: python
369372
370-
from pvlib.flow import self_consumption_ac_battery
373+
from pvlib.powerflow import self_consumption_ac_battery
371374
372375
battery = fit_sam(parameters)
373376
state, flow = self_consumption_ac_battery(generation, load, battery, sam)

pvlib/flow.py renamed to pvlib/powerflow.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This module contains functions for simulating power/energy flow.
2+
This module contains functions for simulating power flow.
33
"""
44
from pandas import DataFrame
55

@@ -66,19 +66,19 @@ def self_consumption_ac_battery(
6666
The resulting power flow provided by the system, the grid and the
6767
battery into the system, grid, battery and load. [W]
6868
"""
69-
ac_dc_loss = 1 - ac_dc_loss / 100
70-
dc_ac_loss = 1 - dc_ac_loss / 100
69+
ac_dc_efficiency = 1 - ac_dc_loss / 100
70+
dc_ac_efficiency = 1 - dc_ac_loss / 100
7171
df = self_consumption(generation, load)
72-
charging = df["System to grid"] * ac_dc_loss
73-
discharging = df["Grid to load"] / dc_ac_loss
72+
charging = df["System to grid"] * ac_dc_efficiency
73+
discharging = df["Grid to load"] / dc_ac_efficiency
7474
dispatch = discharging - charging
7575
final_state, results = model(battery, dispatch)
7676
df["System to battery"] = -results["Power"].loc[results["Power"] < 0]
77-
df["System to battery"] /= ac_dc_loss
77+
df["System to battery"] /= ac_dc_efficiency
7878
df["System to battery"] = df["System to battery"].fillna(0.0)
7979
df["System to grid"] -= df["System to battery"]
8080
df["Battery to load"] = results["Power"].loc[results["Power"] > 0]
81-
df["Battery to load"] *= dc_ac_loss
81+
df["Battery to load"] *= dc_ac_efficiency
8282
df["Battery to load"] = df["Battery to load"].fillna(0.0)
8383
df["Grid to load"] -= df["Battery to load"]
8484
df["Grid"] = df[["Grid to system", "Grid to load"]].sum(

pvlib/tests/test_flow.py renamed to pvlib/tests/test_powerflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from pvlib.battery import boc
99
from pvlib.battery import fit_boc
10-
from pvlib.flow import self_consumption
11-
from pvlib.flow import self_consumption_ac_battery
10+
from pvlib.powerflow import self_consumption
11+
from pvlib.powerflow import self_consumption_ac_battery
1212

1313

1414
@mark.parametrize(

0 commit comments

Comments
 (0)