-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemand_response_simple.py
25 lines (19 loc) · 1.05 KB
/
demand_response_simple.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from pyomo.environ import *
from switch_mod.financials import capital_recovery_factor as crf
def define_components(m):
# maximum share of hourly load that can be rescheduled
# this is mutable so various values can be tested
m.demand_response_max_share = Param(default=0.30, mutable=True)
# adjustment to demand during each hour (positive = higher demand)
m.DemandResponse = Var(m.LOAD_ZONES, m.TIMEPOINTS, within=Reals)
# don't reduce demand by more than 30% in any hour
m.Demand_Response_Max_Reduction = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t:
m.DemandResponse[z, t] >= (-1.0) * m.demand_response_max_share * m.lz_demand_mw[z, t]
)
# all changes to demand must balance out over the course of the day
m.Demand_Response_Net_Zero = Constraint(m.LOAD_ZONES, m.TIMESERIES, rule=lambda m, z, ts:
sum(m.DemandResponse[z, tp] for tp in m.TS_TPS[ts]) == 0.0
)
# add the demand response to the model's energy balance
m.LZ_Energy_Components_Consume.append('DemandResponse')