Spaces:
Sleeping
Sleeping
Daniel Varga commited on
Commit ·
97b4bca
1
Parent(s): fcbe190
bess params are used
Browse files- v2/app.py +20 -4
- v2/bess.py +18 -10
v2/app.py
CHANGED
|
@@ -12,7 +12,7 @@ from visualization import *
|
|
| 12 |
from supplier import Supplier, precalculate_supplier
|
| 13 |
from architecture import simulator, add_dummy_predictions
|
| 14 |
from decider import Decider, RandomDecider
|
| 15 |
-
from bess import BatteryModel
|
| 16 |
|
| 17 |
#@title ### Downloading the data
|
| 18 |
# !wget "https://static.renyi.hu/ai-shared/daniel/pq/PL_44527.19-21.csv.gz"
|
|
@@ -40,7 +40,23 @@ def recalculate(ui):
|
|
| 40 |
time_interval_min = all_data.index.freq.n
|
| 41 |
time_interval_h = time_interval_min / 60
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# for faster testing:
|
| 46 |
DATASET_TRUNCATED_SIZE = None
|
|
@@ -144,8 +160,8 @@ with gr.Blocks() as ui:
|
|
| 144 |
with gr.Row():
|
| 145 |
# LEFT: Input controls
|
| 146 |
with gr.Column(scale=1): # narrower column
|
| 147 |
-
solar_cell_num = gr.Slider(0, 3000, 1140, label="
|
| 148 |
-
solar_cell_nominal_capacity = gr.Slider(0, 1000, 280, label="
|
| 149 |
|
| 150 |
bess_capacity_Ah = gr.Slider(0, 2000, 330, label="BESS nominal capacity [Ah]")
|
| 151 |
|
|
|
|
| 12 |
from supplier import Supplier, precalculate_supplier
|
| 13 |
from architecture import simulator, add_dummy_predictions
|
| 14 |
from decider import Decider, RandomDecider
|
| 15 |
+
from bess import BatteryParameters, BatteryModel
|
| 16 |
|
| 17 |
#@title ### Downloading the data
|
| 18 |
# !wget "https://static.renyi.hu/ai-shared/daniel/pq/PL_44527.19-21.csv.gz"
|
|
|
|
| 40 |
time_interval_min = all_data.index.freq.n
|
| 41 |
time_interval_h = time_interval_min / 60
|
| 42 |
|
| 43 |
+
'''
|
| 44 |
+
def __init__(self, capacity_Ah, time_interval_h):
|
| 45 |
+
self.capacity_Ah = capacity_Ah
|
| 46 |
+
self.efficiency = 0.9 # [dimensionless]
|
| 47 |
+
self.voltage_V = 600
|
| 48 |
+
self.charge_kW = 50
|
| 49 |
+
self.discharge_kW = 60
|
| 50 |
+
self.time_interval_h = time_interval_h
|
| 51 |
+
'''
|
| 52 |
+
|
| 53 |
+
battery_parameters = BatteryParameters()
|
| 54 |
+
battery_parameters.capacity_Ah = ui.bess_capacity_Ah
|
| 55 |
+
battery_parameters.voltage_V = ui.bess_voltage_V
|
| 56 |
+
battery_parameters.bess_charge_kW = ui.bess_charge_kW
|
| 57 |
+
battery_parameters.bess_discharge_kW = ui.bess_discharge_kW
|
| 58 |
+
|
| 59 |
+
battery_model = BatteryModel(battery_parameters, time_interval_h=time_interval_h)
|
| 60 |
|
| 61 |
# for faster testing:
|
| 62 |
DATASET_TRUNCATED_SIZE = None
|
|
|
|
| 160 |
with gr.Row():
|
| 161 |
# LEFT: Input controls
|
| 162 |
with gr.Column(scale=1): # narrower column
|
| 163 |
+
solar_cell_num = gr.Slider(0, 3000, 1140, label="Number of installed solar cells")
|
| 164 |
+
solar_cell_nominal_capacity = gr.Slider(0, 1000, 280, label="Solar cell nominal capacity at NOCT [W]")
|
| 165 |
|
| 166 |
bess_capacity_Ah = gr.Slider(0, 2000, 330, label="BESS nominal capacity [Ah]")
|
| 167 |
|
v2/bess.py
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# SOC is normalized so that minimal_depth_of_discharge = 0 and maximal_depth_of_discharge = 1.
|
| 2 |
# please set capacity_Ah = nominal_capacity_Ah * (max_dod - min_dod)
|
| 3 |
#
|
| 4 |
# TODO efficiency multiplier is not currently used, where best to put it?
|
| 5 |
class BatteryModel:
|
| 6 |
-
def __init__(self,
|
| 7 |
-
self.
|
| 8 |
-
self.efficiency = 0.9 # [dimensionless]
|
| 9 |
-
self.voltage_V = 600
|
| 10 |
-
self.charge_kW = 50
|
| 11 |
-
self.discharge_kW = 60
|
| 12 |
self.time_interval_h = time_interval_h
|
| 13 |
|
| 14 |
# the only non-constant member variable!
|
| 15 |
# ratio of self.current_capacity_kWh and self.maximal_capacity_kWh
|
| 16 |
-
self.soc = 0.0
|
| 17 |
|
| 18 |
@property
|
| 19 |
def maximal_capacity_kWh(self):
|
| 20 |
-
return self.capacity_Ah * self.voltage_V / 1000
|
| 21 |
|
| 22 |
@property
|
| 23 |
def current_capacity_kWh(self):
|
|
@@ -27,7 +35,7 @@ class BatteryModel:
|
|
| 27 |
assert 0 <= self.soc <= 1
|
| 28 |
assert demand_kW >= 0
|
| 29 |
# rate limited:
|
| 30 |
-
possible_discharge_in_timestep_kWh = self.discharge_kW * self.time_interval_h
|
| 31 |
# limited by current capacity:
|
| 32 |
possible_discharge_in_timestep_kWh = min((possible_discharge_in_timestep_kWh, self.current_capacity_kWh))
|
| 33 |
# limited by need:
|
|
@@ -44,7 +52,7 @@ class BatteryModel:
|
|
| 44 |
assert 0 <= self.soc <= 1
|
| 45 |
assert charge_kW >= 0
|
| 46 |
# rate limited:
|
| 47 |
-
possible_charge_in_timestep_kWh = self.charge_kW * self.time_interval_h
|
| 48 |
# limited by current capacity:
|
| 49 |
possible_charge_in_timestep_kWh = min((possible_charge_in_timestep_kWh, self.maximal_capacity_kWh - self.current_capacity_kWh))
|
| 50 |
# limited by supply:
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
@dataclass
|
| 5 |
+
class BatteryParameters:
|
| 6 |
+
capacity_Ah = 330
|
| 7 |
+
efficiency = 0.9 # [dimensionless]
|
| 8 |
+
voltage_V = 600
|
| 9 |
+
charge_kW = 50
|
| 10 |
+
discharge_kW = 60
|
| 11 |
+
|
| 12 |
+
|
| 13 |
# SOC is normalized so that minimal_depth_of_discharge = 0 and maximal_depth_of_discharge = 1.
|
| 14 |
# please set capacity_Ah = nominal_capacity_Ah * (max_dod - min_dod)
|
| 15 |
#
|
| 16 |
# TODO efficiency multiplier is not currently used, where best to put it?
|
| 17 |
class BatteryModel:
|
| 18 |
+
def __init__(self, battery_parameters, time_interval_h):
|
| 19 |
+
self.p = battery_parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
self.time_interval_h = time_interval_h
|
| 21 |
|
| 22 |
# the only non-constant member variable!
|
| 23 |
# ratio of self.current_capacity_kWh and self.maximal_capacity_kWh
|
| 24 |
+
self.soc = 0.0
|
| 25 |
|
| 26 |
@property
|
| 27 |
def maximal_capacity_kWh(self):
|
| 28 |
+
return self.p.capacity_Ah * self.p.voltage_V / 1000
|
| 29 |
|
| 30 |
@property
|
| 31 |
def current_capacity_kWh(self):
|
|
|
|
| 35 |
assert 0 <= self.soc <= 1
|
| 36 |
assert demand_kW >= 0
|
| 37 |
# rate limited:
|
| 38 |
+
possible_discharge_in_timestep_kWh = self.p.discharge_kW * self.time_interval_h
|
| 39 |
# limited by current capacity:
|
| 40 |
possible_discharge_in_timestep_kWh = min((possible_discharge_in_timestep_kWh, self.current_capacity_kWh))
|
| 41 |
# limited by need:
|
|
|
|
| 52 |
assert 0 <= self.soc <= 1
|
| 53 |
assert charge_kW >= 0
|
| 54 |
# rate limited:
|
| 55 |
+
possible_charge_in_timestep_kWh = self.p.charge_kW * self.time_interval_h
|
| 56 |
# limited by current capacity:
|
| 57 |
possible_charge_in_timestep_kWh = min((possible_charge_in_timestep_kWh, self.maximal_capacity_kWh - self.current_capacity_kWh))
|
| 58 |
# limited by supply:
|