switch_model/balancing/load_zones.py
def define_components(mod):
    """
    Augments a Pyomo abstract model object with sets and parameters that
    describe load zones and associated power balance equations. Unless
    otherwise stated, each set and parameter is mandatory.

    LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a
    single bus connected to the inter-zonal transmission network (assuming
    transmission is enabled). If local_td is included, the central zonal bus,
    is connected to a "distributed bus" via local transmission and
    distribution that incurs efficiency losses and must be upgraded over time
    to always meet peak demand. Load zones are abbreviated as zone in
    parameter names and as z for indexes.

    zone_demand_mw[z,t] describes the power demand from the high voltage
    transmission grid each load zone z and timepoint t. This will either go
    into the Zone_Power_Withdrawals or the Distributed_Power_Withdrawals power
    balance equations, depending on whether the local_td module is included
    and has defined a distributed node for power balancing. If the local_td
    module is excluded, this value should be the total withdrawals from the
    central grid and should include any distribution losses. If the local_td
    module is included, this should be set to total end-use demand (aka sales)
    and should not include distribution losses. zone_demand_mw must be
    non-negative.

    zone_dbid[z] stores an external database id for each load zone. This
    is optional and defaults to the name of the load zone. It will be
    printed out when results are exported.

    zone_ccs_distance_km[z] describes the length of a pipeline in
    kilometers that would need to be built to transport CO2 from a load
    zones central bus to the nearest viable CCS reservoir. This
    parameter is optional and defaults to 0.

    EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS is a set of load zones and
    periods (z,p) that have zone_expected_coincident_peak_demand specified.

    zone_expected_coincident_peak_demand[z,p] is an optional parameter than can
    be used to externally specify peak load planning requirements in MW.
    Currently local_td and planning_reserves determine capacity requirements
    use zone_expected_coincident_peak_demand as well as load timeseries. Do not
    specify this parameter if you wish for the model to endogenously determine
    capacity requirements after accounting for both load and Distributed
    Energy Resources (DER).

    Derived parameters:

    zone_total_demand_in_period_mwh[z,p] describes the total energy demand
    of each load zone in each period in Megawatt hours.

    """

    mod.LOAD_ZONES = Set(dimen=1, input_file='load_zones.csv')
    mod.ZONE_TIMEPOINTS = Set(dimen=2,
        initialize=lambda m: m.LOAD_ZONES * m.TIMEPOINTS,
        doc="The cross product of load zones and timepoints, used for indexing.")
    mod.zone_demand_mw = Param(
        mod.ZONE_TIMEPOINTS,
        input_file="loads.csv",
        within=NonNegativeReals)
    mod.zone_ccs_distance_km = Param(
        mod.LOAD_ZONES,
        within=NonNegativeReals,
        input_file="load_zones.csv",
        default=0.0)
    mod.zone_dbid = Param(
        mod.LOAD_ZONES,
        input_file="load_zones.csv",
        default=lambda m, z: z)
    mod.min_data_check('LOAD_ZONES', 'zone_demand_mw')
    try:
        mod.Distributed_Power_Withdrawals.append('zone_demand_mw')
    except AttributeError:
        mod.Zone_Power_Withdrawals.append('zone_demand_mw')

    mod.EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS = Set(
        dimen=2, within=mod.LOAD_ZONES * mod.PERIODS,
        input_file="zone_coincident_peak_demand.csv",
        input_optional=True,
        doc="Zone-Period combinations with zone_expected_coincident_peak_demand data.")
    mod.zone_expected_coincident_peak_demand = Param(
        mod.EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS,
        input_file="zone_coincident_peak_demand.csv",
        within=NonNegativeReals)
    mod.zone_total_demand_in_period_mwh = Param(
        mod.LOAD_ZONES, mod.PERIODS,
        within=NonNegativeReals,
        initialize=lambda m, z, p: (
            sum(m.zone_demand_mw[z, t] * m.tp_weight[t]
                for t in m.TPS_IN_PERIOD[p])))

    # Make sure the model has duals enabled since we use the duals in post_solve()
    mod.enable_duals()

    Augments a Pyomo abstract model object with sets and parameters that
    describe load zones and associated power balance equations. Unless
    otherwise stated, each set and parameter is mandatory.

    LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a
    single bus connected to the inter-zonal transmission network (assuming
    transmission is enabled). If local_td is included, the central zonal bus,
    is connected to a "distributed bus" via local transmission and
    distribution that incurs efficiency losses and must be upgraded over time
    to always meet peak demand. Load zones are abbreviated as zone in
    parameter names and as z for indexes.

    zone_demand_mw[z,t] describes the power demand from the high voltage
    transmission grid each load zone z and timepoint t. This will either go
    into the Zone_Power_Withdrawals or the Distributed_Power_Withdrawals power
    balance equations, depending on whether the local_td module is included
    and has defined a distributed node for power balancing. If the local_td
    module is excluded, this value should be the total withdrawals from the
    central grid and should include any distribution losses. If the local_td
    module is included, this should be set to total end-use demand (aka sales)
    and should not include distribution losses. zone_demand_mw must be
    non-negative.

    zone_dbid[z] stores an external database id for each load zone. This
    is optional and defaults to the name of the load zone. It will be
    printed out when results are exported.

    zone_ccs_distance_km[z] describes the length of a pipeline in
    kilometers that would need to be built to transport CO2 from a load
    zones central bus to the nearest viable CCS reservoir. This
    parameter is optional and defaults to 0.

    EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS is a set of load zones and
    periods (z,p) that have zone_expected_coincident_peak_demand specified.

    zone_expected_coincident_peak_demand[z,p] is an optional parameter than can
    be used to externally specify peak load planning requirements in MW.
    Currently local_td and planning_reserves determine capacity requirements
    use zone_expected_coincident_peak_demand as well as load timeseries. Do not
    specify this parameter if you wish for the model to endogenously determine
    capacity requirements after accounting for both load and Distributed
    Energy Resources (DER).

    Derived parameters:

    zone_total_demand_in_period_mwh[z,p] describes the total energy demand
    of each load zone in each period in Megawatt hours.

    
Augments a Pyomo abstract model object with sets and parameters that
describe load zones and associated power balance equations. Unless
otherwise stated, each set and parameter is mandatory.

LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a
single bus connected to the inter-zonal transmission network (assuming
transmission is enabled). If local_td is included, the central zonal bus,
is connected to a "distributed bus" via local transmission and
distribution that incurs efficiency losses and must be upgraded over time
to always meet peak demand. Load zones are abbreviated as zone in
parameter names and as z for indexes.

zone_demand_mw[z,t] describes the power demand from the high voltage
transmission grid each load zone z and timepoint t. This will either go
into the Zone_Power_Withdrawals or the Distributed_Power_Withdrawals power
balance equations, depending on whether the local_td module is included
and has defined a distributed node for power balancing. If the local_td
module is excluded, this value should be the total withdrawals from the
central grid and should include any distribution losses. If the local_td
module is included, this should be set to total end-use demand (aka sales)
and should not include distribution losses. zone_demand_mw must be
non-negative.

zone_dbid[z] stores an external database id for each load zone. This
is optional and defaults to the name of the load zone. It will be
printed out when results are exported.

zone_ccs_distance_km[z] describes the length of a pipeline in
kilometers that would need to be built to transport CO2 from a load
zones central bus to the nearest viable CCS reservoir. This
parameter is optional and defaults to 0.

EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS is a set of load zones and
periods (z,p) that have zone_expected_coincident_peak_demand specified.

zone_expected_coincident_peak_demand[z,p] is an optional parameter than can
be used to externally specify peak load planning requirements in MW.
Currently local_td and planning_reserves determine capacity requirements
use zone_expected_coincident_peak_demand as well as load timeseries. Do not
specify this parameter if you wish for the model to endogenously determine
capacity requirements after accounting for both load and Distributed
Energy Resources (DER).

Derived parameters.

zone_total_demand_in_period_mwh[z,p] describes the total energy demand
of each load zone in each period in Megawatt hours.
Augments a Pyomo abstract model object with sets and parameters that describe load zones and associated power balance equations . Unless otherwise stated each set and parameter is mandatory . LOAD_ZONES is the set of load zones . Each zone is effectively modeled as a single bus connected to the inter - zonal transmission network ( assuming transmission is enabled ) . If local_td is included the central zonal bus is connected to a " distributed bus " via local transmission and distribution that incurs efficiency losses and must be upgraded over time to always meet peak demand . Load zones are abbreviated as zone in parameter names and as z for indexes . zone_demand_mw [ z t ] describes the power demand from the high voltage transmission grid each load zone z and timepoint t . This will either go into the Zone_Power_Withdrawals or the Distributed_Power_Withdrawals power balance equations depending on whether the local_td module is included and has defined a distributed node for power balancing . If the local_td module is excluded this value should be the total withdrawals from the central grid and should include any distribution losses . If the local_td module is included this should be set to total end - use demand ( aka sales ) and should not include distribution losses . zone_demand_mw must be non - negative . zone_dbid [ z ] stores an external database id for each load zone . This is optional and defaults to the name of the load zone . It will be printed out when results are exported . zone_ccs_distance_km [ z ] describes the length of a pipeline in kilometers that would need to be built to transport CO2 from a load zones central bus to the nearest viable CCS reservoir . This parameter is optional and defaults to 0 . EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS is a set of load zones and periods ( z p ) that have zone_expected_coincident_peak_demand specified . zone_expected_coincident_peak_demand [ z p ] is an optional parameter than can be used to externally specify peak load planning requirements in MW . Currently local_td and planning_reserves determine capacity requirements use zone_expected_coincident_peak_demand as well as load timeseries . Do not specify this parameter if you wish for the model to endogenously determine capacity requirements after accounting for both load and Distributed Energy Resources ( DER ) . Derived parameters . zone_total_demand_in_period_mwh [ z p ] describes the total energy demand of each load zone in each period in Megawatt hours .
def define_components(mod):
    mod.LOAD_ZONES = Set(dimen=1, input_file='load_zones.csv')
    mod.ZONE_TIMEPOINTS = Set(dimen=2,
        initialize=lambda m: m.LOAD_ZONES * m.TIMEPOINTS,
        doc="The cross product of load zones and timepoints, used for indexing.")
    mod.zone_demand_mw = Param(
        mod.ZONE_TIMEPOINTS,
        input_file="loads.csv",
        within=NonNegativeReals)
    mod.zone_ccs_distance_km = Param(
        mod.LOAD_ZONES,
        within=NonNegativeReals,
        input_file="load_zones.csv",
        default=0.0)
    mod.zone_dbid = Param(
        mod.LOAD_ZONES,
        input_file="load_zones.csv",
        default=lambda m, z: z)
    mod.min_data_check('LOAD_ZONES', 'zone_demand_mw')
    try:
        mod.Distributed_Power_Withdrawals.append('zone_demand_mw')
    except AttributeError:
        mod.Zone_Power_Withdrawals.append('zone_demand_mw')
    mod.EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS = Set(
        dimen=2, within=mod.LOAD_ZONES * mod.PERIODS,
        input_file="zone_coincident_peak_demand.csv",
        input_optional=True,
        doc="Zone-Period combinations with zone_expected_coincident_peak_demand data.")
    mod.zone_expected_coincident_peak_demand = Param(
        mod.EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS,
        input_file="zone_coincident_peak_demand.csv",
        within=NonNegativeReals)
    mod.zone_total_demand_in_period_mwh = Param(
        mod.LOAD_ZONES, mod.PERIODS,
        within=NonNegativeReals,
        initialize=lambda m, z, p: (
            sum(m.zone_demand_mw[z, t] * m.tp_weight[t]
                for t in m.TPS_IN_PERIOD[p])))
    mod.enable_duals()
def define_components ( mod ) : mod . LOAD_ZONES = Set ( dimen = 1 , input_file = 'load_zones.csv' ) mod . ZONE_TIMEPOINTS = Set ( dimen = 2 , initialize = lambda m : m . LOAD_ZONES * m . TIMEPOINTS , doc = "The cross product of load zones and timepoints, used for indexing." ) mod . zone_demand_mw = Param ( mod . ZONE_TIMEPOINTS , input_file = "loads.csv" , within = NonNegativeReals ) mod . zone_ccs_distance_km = Param ( mod . LOAD_ZONES , within = NonNegativeReals , input_file = "load_zones.csv" , default = 0.0 ) mod . zone_dbid = Param ( mod . LOAD_ZONES , input_file = "load_zones.csv" , default = lambda m , z : z ) mod . min_data_check ( 'LOAD_ZONES' , 'zone_demand_mw' ) try : mod . Distributed_Power_Withdrawals . append ( 'zone_demand_mw' ) except AttributeError : mod . Zone_Power_Withdrawals . append ( 'zone_demand_mw' ) mod . EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS = Set ( dimen = 2 , within = mod . LOAD_ZONES * mod . PERIODS , input_file = "zone_coincident_peak_demand.csv" , input_optional = True , doc = "Zone-Period combinations with zone_expected_coincident_peak_demand data." ) mod . zone_expected_coincident_peak_demand = Param ( mod . EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS , input_file = "zone_coincident_peak_demand.csv" , within = NonNegativeReals ) mod . zone_total_demand_in_period_mwh = Param ( mod . LOAD_ZONES , mod . PERIODS , within = NonNegativeReals , initialize = lambda m , z , p : ( sum ( m . zone_demand_mw [ z , t ] * m . tp_weight [ t ] for t in m . TPS_IN_PERIOD [ p ] ) ) ) mod . enable_duals ( )
Augments a Pyomo abstract model object with sets and parameters that
describe load zones and associated power balance equations.
Augments a Pyomo abstract model object with sets and parameters that describe load zones and associated power balance equations .
"""
    Augments a Pyomo abstract model object with sets and parameters that
    describe load zones and associated power balance equations. Unless
    otherwise stated, each set and parameter is mandatory.

    LOAD_ZONES is the set of load zones. Each zone is effectively modeled as a
    single bus connected to the inter-zonal transmission network (assuming
    transmission is enabled). If local_td is included, the central zonal bus,
    is connected to a "distributed bus" via local transmission and
    distribution that incurs efficiency losses and must be upgraded over time
    to always meet peak demand. Load zones are abbreviated as zone in
    parameter names and as z for indexes.

    zone_demand_mw[z,t] describes the power demand from the high voltage
    transmission grid each load zone z and timepoint t. This will either go
    into the Zone_Power_Withdrawals or the Distributed_Power_Withdrawals power
    balance equations, depending on whether the local_td module is included
    and has defined a distributed node for power balancing. If the local_td
    module is excluded, this value should be the total withdrawals from the
    central grid and should include any distribution losses. If the local_td
    module is included, this should be set to total end-use demand (aka sales)
    and should not include distribution losses. zone_demand_mw must be
    non-negative.

    zone_dbid[z] stores an external database id for each load zone. This
    is optional and defaults to the name of the load zone. It will be
    printed out when results are exported.

    zone_ccs_distance_km[z] describes the length of a pipeline in
    kilometers that would need to be built to transport CO2 from a load
    zones central bus to the nearest viable CCS reservoir. This
    parameter is optional and defaults to 0.

    EXTERNAL_COINCIDENT_PEAK_DEMAND_ZONE_PERIODS is a set of load zones and
    periods (z,p) that have zone_expected_coincident_peak_demand specified.

    zone_expected_coincident_peak_demand[z,p] is an optional parameter than can
    be used to externally specify peak load planning requirements in MW.
    Currently local_td and planning_reserves determine capacity requirements
    use zone_expected_coincident_peak_demand as well as load timeseries. Do not
    specify this parameter if you wish for the model to endogenously determine
    capacity requirements after accounting for both load and Distributed
    Energy Resources (DER).

    Derived parameters:

    zone_total_demand_in_period_mwh[z,p] describes the total energy demand
    of each load zone in each period in Megawatt hours.

    """ # Make sure the model has duals enabled since we use the duals in post_solve()
mod