Source and Sink classes

Sources and sink transfer commodities into and out of the energy system.

Source class description:

class sourceSink.Source(esM, name, commodity, hasCapacityVariable, capacityVariableDomain='continuous', capacityPerPlantUnit=1, hasIsBuiltBinaryVariable=False, bigM=None, operationRateMin=None, operationRateMax=None, operationRateFix=None, tsaWeight=1, commodityLimitID=None, yearlyLimit=None, locationalEligibility=None, capacityMin=None, capacityMax=None, partLoadMin=None, sharedPotentialID=None, linkedQuantityID=None, capacityFix=None, commissioningMin=None, commissioningMax=None, commissioningFix=None, isBuiltFix=None, investPerCapacity=0, investIfBuilt=0, opexPerOperation=0, commodityCost=0, commodityRevenue=0, commodityCostTimeSeries=None, commodityRevenueTimeSeries=None, opexPerCapacity=0, opexIfBuilt=0, QPcostScale=0, interestRate=0.08, economicLifetime=10, technicalLifetime=None, yearlyFullLoadHoursMin=None, yearlyFullLoadHoursMax=None, balanceLimitID=None, pathwayBalanceLimitID=None, stockCommissioning=None, floorTechnicalLifetime=True)[source]

A Source component can transfer a commodity over the energy system boundary into the system.

__init__(esM, name, commodity, hasCapacityVariable, capacityVariableDomain='continuous', capacityPerPlantUnit=1, hasIsBuiltBinaryVariable=False, bigM=None, operationRateMin=None, operationRateMax=None, operationRateFix=None, tsaWeight=1, commodityLimitID=None, yearlyLimit=None, locationalEligibility=None, capacityMin=None, capacityMax=None, partLoadMin=None, sharedPotentialID=None, linkedQuantityID=None, capacityFix=None, commissioningMin=None, commissioningMax=None, commissioningFix=None, isBuiltFix=None, investPerCapacity=0, investIfBuilt=0, opexPerOperation=0, commodityCost=0, commodityRevenue=0, commodityCostTimeSeries=None, commodityRevenueTimeSeries=None, opexPerCapacity=0, opexIfBuilt=0, QPcostScale=0, interestRate=0.08, economicLifetime=10, technicalLifetime=None, yearlyFullLoadHoursMin=None, yearlyFullLoadHoursMax=None, balanceLimitID=None, pathwayBalanceLimitID=None, stockCommissioning=None, floorTechnicalLifetime=True)[source]

Constructor for creating an Source class instance. The Source component specific input arguments are described below. The general component input arguments are described in the Component class.

Note

The Sink class inherits from the Source class and is initialized with the same parameter set.

Required arguments:

Parameters:
  • commodity (string) – to the component related commodity.

  • hasCapacityVariable (boolean) –

    specifies if the component should be modeled with a capacity or not. Examples:

    • A wind turbine has a capacity given in GW_electric -> hasCapacityVariable is True.

    • Emitting CO2 into the environment is not per se limited by a capacity -> hasCapacityVariable is False.

Default arguments: :param operationRateMin: if specified, indicates a minimum operation rate for each location and each time, if required also for each investment period, if

step by a positive float. If hasCapacityVariable is set to True, the values are given relative to the installed capacities (i.e. a value of 1 indicates a utilization of 100% of the capacity). If hasCapacityVariable is set to False, the values are given as absolute values in form of the commodityUnit for each time step.
* the default value is None

Parameters:
  • operationRateMax – if specified, indicates a maximum operation rate for each location and each time, if required also for each investment period, if step by a positive float. If hasCapacityVariable is set to True, the values are given relative to the installed capacities (i.e. a value of 1 indicates a utilization of 100% of the capacity). If hasCapacityVariable is set to False, the values are given as absolute values in form of the commodityUnit for each time step.
    * the default value is None

  • operationRateFix – if specified, indicates a fixed operation rate for each location and each time, if required also for each investment period, step by a positive float. If hasCapacityVariable is set to True, the values are given relative to the installed capacities (i.e. a value of 1 indicates a utilization of 100% of the capacity). If hasCapacityVariable is set to False, the values are given as absolute values in form of the commodityUnit for each time step.
    * the default value is None

  • commodityCostTimeSeries – if specified, indicates commodity cost rates for each location and each time step, if required also for each investment period, by a positive float. The values are given as specific values relative to the commodityUnit for each time step.
    * the default value is None

  • commodityRevenueTimeSeries – if specified, indicates commodity revenue rate for each location and each time step, if required also for each investment period, by a positive float. The values are given as specific values relative to the commodityUnit for each time step.
    * the default value is None

  • tsaWeight (positive (>= 0) float) – weight with which the time series of the component should be considered when applying time series aggregation.
    * the default value is 1

  • commodityLimitID (string) – can be specified to limit an annual commodity import/export over the energySystemModel’s boundaries for one or multiple Source/Sink components. If the same ID is used in multiple components, the sum of all imports and exports is considered. If a commodityLimitID is specified, the yearlyLimit parameters has to be set as well.
    * the default value is None

  • yearlyLimit

    if specified, indicates a yearly import/export commodity limit per investment period for all components with the same commodityLimitID. If positive, the commodity flow leaving the energySystemModel is limited. If negative, the commodity flow entering the energySystemModel is limited. If a yearlyLimit is specified, the commodityLimitID parameters has to be set as well. The yearlyLimit can also be specified for every investment period year individually. Examples:

    • CO2 can be emitted in power plants by burning natural gas or coal. The CO2 which goes into the atmosphere over the energy system’s boundaries is modelled as a Sink. CO2 can also be a Source taken directly from the atmosphere (over the energy system’s boundaries) for a methanation process. The commodityUnit for CO2 is tonnes_CO2. Overall, +XY tonnes_CO2 are allowed to be emitted during the year. All Sources/Sinks producing or consuming CO2 over the energy system’s boundaries have the same commodityLimitID and the same yearlyLimit of +XY.

    • The maximum annual import of a certain chemical (commodityUnit tonnes_chem) is limited to XY tonnes_chem. The Source component modeling this import has a commodityLimitID “chemicalComponentLimitID” and a yearlyLimit of -XY.


    * the default value is None

  • opexPerOperation – describes the cost for one unit of the operation. The cost which is directly proportional to the operation of the component is obtained by multiplying the opexPerOperation parameter with the annual sum of the operational time series of the components. The opexPerOperation can either be given as a float or a Pandas Series with location specific values or a dictionary per investment period with one of the previous options. The cost unit in which the parameter is given has to match the one specified in the energy system model (e.g. Euro, Dollar, 1e6 Euro).
    * the default value is 0

  • commodityCost

    describes the cost value of one operation´s unit of the component. The cost which is directly proportional to the operation of the component is obtained by multiplying the commodityCost parameter with the annual sum of the time series of the components. The commodityCost can either be given as a float or a Pandas Series with location specific values or a dictionary per investment period with one of the two previous options. The cost unit in which the parameter is given has to match the one specified in the energy system model (e.g. Euro, Dollar, 1e6 Euro). Example:

    • In a national energy system, natural gas could be purchased from another country with a certain cost.


    * the default value is 0

  • commodityRevenue

    describes the revenue of one operation´s unit of the component. The revenue which is directly proportional to the operation of the component is obtained by multiplying the commodityRevenue parameter with the annual sum of the time series of the components. The commodityRevenue can either be given as a float or a Pandas Series with location specific values or a dictionary per investment period with one of the two previous options. The cost unit in which the parameter is given has to match the one specified in the energy system model (e.g. Euro, Dollar, 1e6 Euro). Example:

    • Modeling a PV electricity feed-in tariff for a household


    * the default value is 0

  • balanceLimitID (string) – ID for the respective balance limit (out of the balance limits introduced in the esM). Should be specified if the respective component of the SourceSinkModel is supposed to be included in the balance analysis. If the commodity is transported out of the region, it is counted as a negative, if it is imported into the region it is considered positive.
    * the default value is None

  • pathwayBalanceLimitID (string) – similar to balanceLimitID just as restriction over the entire pathway.
    * the default value is None

setTimeSeriesData(hasTSA)[source]

Function for setting the maximum operation rate, fixed operation rate and cost or revenue time series depending on whether a time series analysis is requested or not.

Parameters:

hasTSA (boolean) – states whether a time series aggregation is requested (True) or not (False).

getDataForTimeSeriesAggregation(ip)[source]

Function for getting the required data if a time series aggregation is requested.

Parameters:

ip (int) – investment period of transformation path analysis.

setAggregatedTimeSeriesData(data, ip)[source]

Function for determining the aggregated maximum rate and the aggregated fixed operation rate.

Parameters:
  • data (Pandas DataFrame) – Pandas DataFrame with the clustered time series data of the source component

  • ip (int) – investment period of transformation path analysis.

checkProcessedDataSets()[source]

Check processed time series data after applying time series aggregation. If all entries of dictionary are None the parameter itself is set to None.

Inheritance diagram:

Inheritance diagram of Source

Sink class description:

class sourceSink.Sink(esM, name, commodity, hasCapacityVariable, capacityVariableDomain='continuous', capacityPerPlantUnit=1, hasIsBuiltBinaryVariable=False, bigM=None, operationRateMin=None, operationRateMax=None, operationRateFix=None, tsaWeight=1, commodityLimitID=None, yearlyLimit=None, locationalEligibility=None, capacityMin=None, capacityMax=None, partLoadMin=None, sharedPotentialID=None, linkedQuantityID=None, capacityFix=None, commissioningMin=None, commissioningMax=None, commissioningFix=None, isBuiltFix=None, investPerCapacity=0, investIfBuilt=0, opexPerOperation=0, commodityCost=0, commodityRevenue=0, commodityCostTimeSeries=None, commodityRevenueTimeSeries=None, opexPerCapacity=0, opexIfBuilt=0, QPcostScale=0, interestRate=0.08, economicLifetime=10, technicalLifetime=None, balanceLimitID=None, pathwayBalanceLimitID=None, stockCommissioning=None, floorTechnicalLifetime=True)[source]

A Sink component can transfer a commodity over the energy system boundary out of the system.

__init__(esM, name, commodity, hasCapacityVariable, capacityVariableDomain='continuous', capacityPerPlantUnit=1, hasIsBuiltBinaryVariable=False, bigM=None, operationRateMin=None, operationRateMax=None, operationRateFix=None, tsaWeight=1, commodityLimitID=None, yearlyLimit=None, locationalEligibility=None, capacityMin=None, capacityMax=None, partLoadMin=None, sharedPotentialID=None, linkedQuantityID=None, capacityFix=None, commissioningMin=None, commissioningMax=None, commissioningFix=None, isBuiltFix=None, investPerCapacity=0, investIfBuilt=0, opexPerOperation=0, commodityCost=0, commodityRevenue=0, commodityCostTimeSeries=None, commodityRevenueTimeSeries=None, opexPerCapacity=0, opexIfBuilt=0, QPcostScale=0, interestRate=0.08, economicLifetime=10, technicalLifetime=None, balanceLimitID=None, pathwayBalanceLimitID=None, stockCommissioning=None, floorTechnicalLifetime=True)[source]

Constructor for creating a Sink class instance.

The Sink class inherits from the Source class. They coincide with the input parameters (see Source class for the parameter description) and differ in the sign parameter, which is equal to -1 for Sink objects and +1 for Source objects.

Inheritance diagram:

Inheritance diagram of Sink

ComponentModel class description:

class sourceSink.SourceSinkModel[source]

A SourceSinkModel class instance will be instantly created if a Source class instance or a Sink class instance is initialized. It is used for the declaration of the sets, variables and constraints which are valid for the Source/Sink class instance. These declarations are necessary for the modeling and optimization of the energy system model. The SourceSinkModel class inherits from the ComponentModel class.

declareYearlyCommodityLimitationDict(pyM, esM)[source]

Declare source/sink components with linked commodity limits and check if the linked components have the same yearly upper limit.

Parameters:

pyM (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

declareSets(esM, pyM)[source]

Declare sets and dictionaries: design variable sets, operation variable set, operation mode sets and linked commodity limitation dictionary.

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • pyM (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

declareVariables(esM, pyM, relaxIsBuiltBinary, relevanceThreshold)[source]

Declare design and operation variables.

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • pyM (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

  • relaxIsBuiltBinary – states if the optimization problem should be solved as a relaxed LP to get the lower bound of the problem.
    * the default value is False

  • relevanceThreshold (float (>=0) or None) – Force operation parameters to be 0 if values are below the relevance threshold.
    * the default value is None

yearlyLimitationConstraint(pyM, esM)[source]

Limit annual commodity imports/exports over the energySystemModel’s boundaries for one or multiple Source/Sink components.

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • pyM (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

declareComponentConstraints(esM, pyM)[source]

Declare time independent and dependent constraints.

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • pyM (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

hasOpVariablesForLocationCommodity(esM, loc, commod)[source]

Check if operation variables exist in the modeling class at a location which are connected to a commodity.

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • loc (string) – Name of the regarded location (locations are defined in the EnergySystemModel instance)

  • commod – Name of the regarded commodity (commodities are defined in the EnergySystemModel instance)

  • commod – string

getBalanceLimitContribution(esM, pyM, ID, ip, timeSeriesAggregation, loc, componentNames)[source]

Get contribution to balanceLimitConstraint (Further read in EnergySystemModel). Sum of the operation time series of a SourceSink component is used as the balanceLimit contribution:

  • If component is a Source it contributes with a positive sign to the limit. Example: Electricity Purchase

  • A Sink contributes with a negative sign. Example: Sale of electricity

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • pym (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

  • ip (int) – investment period of transformation path analysis.

  • ID – ID of the regarded balanceLimitConstraint

  • ID – string

  • timeSeriesAggregation (boolean) –

    states if the optimization of the energy system model should be done with

    1. the full time series (False) or

    2. clustered time series data (True).

  • loc (string) – Name of the regarded location (locations are defined in the EnergySystemModel instance)

  • componentNames (list) – Names of components which contribute to the balance limit

getCommodityBalanceContribution(pyM, commod, loc, ip, p, t)[source]
Get contribution to a commodity balance.

text{C}^{comp,comm}_{loc,ip,p,t} = - op_{loc,ip,p,t}^{comp,op} text{Sink}

\text{C}^{comp,comm}_{loc,ip,p,t} = op_{loc,ip,p,t}^{comp,op} \text{Source}

getObjectiveFunctionContribution(esM, pyM)[source]
Get contribution to the objective function.
param esM:

EnergySystemModel instance representing the energy system in which the component should be modeled.

type esM:

esM - EnergySystemModel class instance

param pym:

pyomo ConcreteModel which stores the mathematical formulation of the model.

type pym:

pyomo ConcreteModel

setOptimalValues(esM, pyM)[source]

Set the optimal values of the components.

Parameters:
  • esM (esM - EnergySystemModel class instance) – EnergySystemModel instance representing the energy system in which the component should be modeled.

  • pym (pyomo ConcreteModel) – pyomo ConcreteModel which stores the mathematical formulation of the model.

  • ip (int) – investment period of transformation path analysis.

getOptimalValues(name='all', ip=0)[source]

Return optimal values of the components.

Parameters:

name

name of the variables of which the optimal values should be returned:

  • ’capacityVariables’,

  • ’isBuiltVariables’,

  • ’_operationVariablesOptimum’,

  • ’all’ or another input: all variables are returned.


* the default value is ‘all’ :type name: string

Parameters:

ip (int) – investment period
* the default value is 0

Returns:

a dictionary with the optimal values of the components

Return type:

dict

Inheritance diagram:

Inheritance diagram of SourceSinkModel