Skip to content

Commit

Permalink
option to add initial ice fraction (initial_cap) of ice storage
Browse files Browse the repository at this point in the history
  • Loading branch information
nehadimri1991 committed Nov 22, 2024
1 parent 74afbbc commit e4bb76e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions optihood/buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,14 @@ def addStorage(self, data, storageParams, ambientTemperature, opt, mergeLinkBuse
self.__nodesList.append(storage.getStorageLevel(i))
self.__nodesList.extend(storage.getDummyComponents(i))
elif "iceStorage" in s["label"]:
if not np.isnan(s["initial capacity"]):
initial_ice_frac = float(s["initial capacity"])
else:
initial_ice_frac = 0
self.__nodesList.append(IceStorage(label=storageLabel,input=self.__busDict[inputBusLabel],
output=self.__busDict[outputBusLabel],
tStorInit=float(storageParams["ice_storage"].at[s["label"],"intitial_temp"]),
fIceInit = initial_ice_frac,
fMax=float(storageParams["ice_storage"].at[s["label"],"max_ice_fraction"]),
rho=float(storageParams["ice_storage"].at[s["label"],"rho_fluid"]),
V=float(s["capacity max"])/1000, # conversion from L to m3
Expand Down
11 changes: 7 additions & 4 deletions optihood/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,13 @@ class IceStorage(on.Node):
inflow_conversion_factor: efficiency of heat exchanger at the inlet of the ice storage
outflow_conversion_factor: efficiency of heat exchanger at the outlet of the ice storage
"""
def __init__(self, label, input, output, tStorInit, fMax, rho, V, hfluid, cp, Tamb, UAtank, inflow_conversion_factor, outflow_conversion_factor):
if tStorInit <= 0:
raise ValueError("The initial temperature of ice storage should be greater than 0°C, i.e. without any ice formation.")
def __init__(self, label, input, output, tStorInit, fIceInit, fMax, rho, V, hfluid, cp, Tamb, UAtank, inflow_conversion_factor, outflow_conversion_factor):
if tStorInit < 0:
raise ValueError("The initial temperature of ice storage should be greater than or equal to 0°C.")
self.tStorInit = tStorInit
if fIceInit < 0 or fIceInit > 1:
raise ValueError("The initial ice fraction in ice storage should be in [0,1]")
self.fIceInit = fIceInit
if fMax < 0.5 or fMax > 0.8:
raise ValueError("Maximum ice fraction should be defined within the range 0.5-0.8")
self.fMax = fMax
Expand Down Expand Up @@ -409,7 +412,7 @@ def _initial_ice_state_rule(block):
"""
for g in group:
lhs = self.mIceStor_prev[g,0]
rhs = 0
rhs = g.fIceInit*g.rho*g.V
block.initial_ice_state.add((g, 0), (lhs == rhs))

self.initial_ice_state = Constraint(group, m.TIMESTEPS, noruleinit= True)
Expand Down

0 comments on commit e4bb76e

Please sign in to comment.