Skip to content

Commit

Permalink
addition of district heating link, ice storage example update, debugg…
Browse files Browse the repository at this point in the history
…ubg, etc.
  • Loading branch information
nehadimri1991 committed Nov 5, 2024
1 parent 647cc03 commit 5f5fd27
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
10 changes: 2 additions & 8 deletions data/examples/solar_ice_hp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
from optihood.energy_network import EnergyNetworkGroup as EnergyNetwork

if __name__ == '__main__':
"""
This example is currently under development (use with caution) !
"""

# set a time period for the optimization problem
timePeriod = pd.date_range("2018-06-01 00:00:00", "2018-12-31 23:00:00", freq="60min")

Expand All @@ -29,8 +23,8 @@
# initialize parameters
numberOfBuildings = 4
optimizationType = "costs" # set as "env" for environmental optimization and "costs" for cost optimization
mergeLinkBuses = True
mergeBuses = ["electricity", "heatPumpInputBus"] # "heat_buses"
mergeLinkBuses = False
mergeBuses = [] # "electricity", "heatPumpInputBus"
dispatchMode = True # Set to True to run the optimization in dispatch mode

# solver specific command line options
Expand Down
Binary file modified data/excels/solar_ice_hp/scenario.xls
Binary file not shown.
22 changes: 11 additions & 11 deletions optihood/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,29 @@ def connectInvestmentRule(om):
dhwLinkOutputFlows = [(i, o) for (i, o) in om.flows if i.label == "dhwLink"]

if elLinkOutputFlows:
first = om.InvestmentFlow.invest[next(iter(elLinkOutputFlows))]
first = om.InvestmentFlowBlock.invest[next(iter(elLinkOutputFlows))]
for (i, o) in elLinkOutputFlows:
expr = (first == om.InvestmentFlow.invest[i, o])
expr = (first == om.InvestmentFlowBlock.invest[i, o])
setattr(
om,
"elLinkConstr_" + o.label,
pyo.Constraint(expr=expr),
)

if shLinkOutputFlows:
first = om.InvestmentFlow.invest[next(iter(shLinkOutputFlows))]
first = om.InvestmentFlowBlock.invest[next(iter(shLinkOutputFlows))]
for (i, o) in shLinkOutputFlows:
expr = (first == om.InvestmentFlow.invest[i, o])
expr = (first == om.InvestmentFlowBlock.invest[i, o])
setattr(
om,
"shLinkConstr_" + o.label,
pyo.Constraint(expr=expr),
)

if dhwLinkOutputFlows:
first = om.InvestmentFlow.invest[next(iter(dhwLinkOutputFlows))]
first = om.InvestmentFlowBlock.invest[next(iter(dhwLinkOutputFlows))]
for (i, o) in dhwLinkOutputFlows:
expr = (first == om.InvestmentFlow.invest[i, o])
expr = (first == om.InvestmentFlowBlock.invest[i, o])
setattr(
om,
"dhwLinkConstr_" + o.label,
Expand Down Expand Up @@ -228,12 +228,12 @@ def electricRodCapacityConstaint(om, numBuildings):
groundHeatPumpCapacityTotal = 0

for b in range(1,numBuildings+1):
elRodCapacity = [om.InvestmentFlow.invest[i, o] for (i, o) in electricRodInputFlows if ((f'__Building{b}') in o.label)]
airHeatPumpCapacity = [om.InvestmentFlow.invest[i, o] for (i, o) in airHeatPumpInputFlows if ((f'__Building{b}') in o.label)]
elRodCapacity = [om.InvestmentFlowBlock.invest[i, o] for (i, o) in electricRodInputFlows if ((f'__Building{b}') in o.label)]
airHeatPumpCapacity = [om.InvestmentFlowBlock.invest[i, o] for (i, o) in airHeatPumpInputFlows if ((f'__Building{b}') in o.label)]
if groundHeatPumpInputFlows:
groundHeatPumpCapacity = [om.InvestmentFlow.invest[i, o] for (i, o) in groundHeatPumpInputFlows if ((f'__Building{b}') in o.label)]
groundHeatPumpCapacity = [om.InvestmentFlowBlock.invest[i, o] for (i, o) in groundHeatPumpInputFlows if ((f'__Building{b}') in o.label)]
else:
groundHeatPumpCapacity = [om.InvestmentFlow.invest[i, o] for (i, o) in groundHeatPumpOutFlows if ((f'__Building{b}') in i.label)]
groundHeatPumpCapacity = [om.InvestmentFlowBlock.invest[i, o] for (i, o) in groundHeatPumpOutFlows if ((f'__Building{b}') in i.label)]
if elRodCapacity:
elRodCapacity = elRodCapacity[0]
airHeatPumpCapacity = airHeatPumpCapacity[0] if airHeatPumpCapacity else 0
Expand All @@ -257,7 +257,7 @@ def totalPVCapacityConstraint(om, numBuildings):
pvOutFlows = [(i, o) for (i, o) in om.flows if ("pv" in i.label)]
pvCapacityTotal = 0
for b in range(1,numBuildings+1):
pvCapacity = [om.InvestmentFlow.invest[i, o] for (i, o) in pvOutFlows if ((f'__Building{b}') in o.label)]
pvCapacity = [om.InvestmentFlowBlock.invest[i, o] for (i, o) in pvOutFlows if ((f'__Building{b}') in o.label)]
if pvCapacity:
pvCapacity = pvCapacity[0]
pvCapacityTotal = pvCapacityTotal + pvCapacity
Expand Down
6 changes: 5 additions & 1 deletion optihood/energy_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,9 +1404,13 @@ def _addLinks(self, data, numberOfBuildings, mergeLinkBuses): # connects buses
elif "heat" in l["label"]:
busesOut.append(self._busDict["heatBus" + l["label"][-1] + '__Building' + str(b + 1)])
busesIn.append(self._busDict["heatDemandBus" + l["label"][-1] + '__Building' + str(b + 1)])
else:
elif "electricity" in l["label"]:
busesOut.append(self._busDict["electricityBus" + '__Building' + str(b + 1)])
busesIn.append(self._busDict["electricityInBus" + '__Building' + str(b + 1)])
elif "dhLink" in l["label"]:
if "districtHeatingInputBus" + '__Building' + str(b + 1) in self._busDict:
busesOut.append(self._busDict["districtHeatingInputBus" + '__Building' + str(b + 1)])
busesIn.append(self._busDict["districtHeatingBus" + '__Building' + str(b + 1)])

self._nodesList.append(Link(
label=l["label"],
Expand Down

0 comments on commit 5f5fd27

Please sign in to comment.