echo.models.agnostic package
- class echo.models.agnostic.AggregationNode(uid: str = NOTHING, node_name: str = NOTHING, objective: NumericExpression | float = 0, ports: dict[str, Port] = NOTHING, *, port_units: Units)
Bases:
NodeArbitrary commodity aggregation node.
This node has an additional variable, ‘total’, which equals the sum of all ports defined on the node. port_units attribute is used for validation, all ports must be the same commodity.
- add_node_to_model(model: EchoConcreteModel, profile: DataFrame) None
Add this node to a concrete model.
- Parameters:
model – The concrete model to add the node to.
profile – The data associated with this node.
- apply_node_constraints(model: EchoConcreteModel) None
Apply constraints associated with this node to a concrete model.
Intended to be overridden in subclasses.
Define constraints as functions that returns a Constraint, EqualityExpression or InequalityExpression.
Define a subfunction of the form detailed in the example below, then apply with setattr. For example:
- def apply_node_constraints(self, model: EchoConcreteModel) -> None:
- def tellegen_node_rule(model: EchoConcreteModel, p: int, t:int) -> EqualityExpression:
a = 0 for port in node_ports.values():
a += getattr(model, port.port_name)[p, t]
return a == 0
node_ports = self.ports con_name = “reliability_con_” + self.node_name setattr(model, con_name, en.Constraint(model.Expansion, model.Time, rule=tellegen_node_rule))
- Parameters:
model – The model to add the constraints to.
- Returns:
None
- property total: None
- verify_node() None
Checks there is at least one port associated with this node.
- Raises:
ConfigurationError – If there are no ports present on this node.
- class echo.models.agnostic.BoundedLoad(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, *, upper_bound: ndarray | float, lower_bound: ndarray | float)
Bases:
BoundedPortA port where the load has to be within a max and min value which is specified at each timestep.
- add_port_to_model(model: EchoConcreteModel, profile: DataFrame) None
Creates pyomo vars, params, and constraints for the port.
- import_constraint: FlowConstraint
- lower_bound: ndarray | float
- upper_bound: ndarray | float
- class echo.models.agnostic.BoundedPort(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, *, upper_bound: ndarray | float, lower_bound: ndarray | float)
Bases:
FlexPortA flex port with an upper and lower bound
- add_port_to_model(model: EchoConcreteModel, profile: DataFrame) None
Creates pyomo vars, params, and constraints for the port.
- lower_bound: ndarray | float
- upper_bound: ndarray | float
- class echo.models.agnostic.ControlledGen(uid: str = NOTHING, port_name: str = NOTHING, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, min_utilisation: float | None = None, max_utilisation: float | None = None, units: Units = Units.KW, *, max_power: float, min_power: float)
Bases:
ControlledLoadOrGen- max_power: float
- min_power: float
- class echo.models.agnostic.ControlledLoad(uid: str = NOTHING, port_name: str = NOTHING, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, min_utilisation: float | None = None, max_utilisation: float | None = None, units: Units = Units.KW, *, max_power: float, min_power: float)
Bases:
ControlledLoadOrGen- max_power: float
- min_power: float
- class echo.models.agnostic.ControlledLoadOrGen(uid: str = NOTHING, port_name: str = NOTHING, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, min_utilisation: float | None = None, max_utilisation: float | None = None, max_power: float | None = None, min_power: float | None = None, units: Units = Units.KW)
Bases:
FlexPortA controlled load or generation has a max/min power, as well as a max/min utilisation. Min utilisation is the ratio between the minimum energy consumed/generated, and the maximum energy that could be consumed/generated if the load operated at max power. Max utilisation is the ratio between the maximum energy consumed/generated, and the maximum energy that could be consumed/generated if the load operated at max power.
- add_port_to_model(model: EchoConcreteModel, profile: DataFrame) None
Creates pyomo vars, params, and constraints for the port.
- max_power: float | None
- max_utilisation: float | None
- min_power: float | None
- min_utilisation: float | None
- class echo.models.agnostic.Demand(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint: FlowConstraint = FlowConstraint.NA, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Import, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Parameter, initial_value: dict[tuple[int, int], float] | float = 0)
Bases:
Sink- add_demand_profile(demand: dict) None
- add_demand_profile_from_array(demand: float | list[float] | list[list[float]] | ndarray, expansion_periods: int = 1, time_periods: int | None = None) None
- class echo.models.agnostic.FixedPort(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Parameter)
Bases:
PortFixed port (parameter), can either import or export.
- export_constraint: FlowConstraint
- flow_type: OptimisationType
- import_constraint: FlowConstraint
- class echo.models.agnostic.FlexPort(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable)
Bases:
PortFlexible variable port, which can import and export without constraints.
- export_constraint: FlowConstraint
- flow_type: OptimisationType
- import_constraint: FlowConstraint
- class echo.models.agnostic.FlexSink(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, flows: Flows = Flows.Import)
Bases:
FlexPortFlexible port, imports only
- class echo.models.agnostic.FlexSource(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, flows: Flows = Flows.Export)
Bases:
FlexPortFlexible ports, exports only
- class echo.models.agnostic.InputOutputNode(uid: str = NOTHING, node_name: str = NOTHING, ports: dict[str, Port] = NOTHING, objective: en.numeric_expr.NumericExpression | float = 0, max_output: float | None = None, min_output: float | None = None, max_input: float | None = None, min_input: float | None = None, input_port_ref: str = 'input', output_port_ref: str = 'output', *, input_port_unit: Units, output_port_unit: Units)
Bases:
NodeAn input-output node has one input port and one output port. A custom transformation can be defined between input and output.
- input_port_ref: str
- max_input: float | None
- max_output: float | None
- min_input: float | None
- min_output: float | None
- output_port_ref: str
- class echo.models.agnostic.MobileStorage(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, flow_type: OptimisationType = OptimisationType.Variable, import_constraint: FlowConstraint = FlowConstraint.Fixed, export_constraint: FlowConstraint = FlowConstraint.Fixed, depth_of_discharge_limit: float = 0, min_soc: float = 0, charging_efficiency: float = 1, discharging_efficiency: float = 1, fixed_storage_capacity: bool = True, storage_capacity_cost: float | None = None, regularise: bool = False, enable_trip_slack: bool = False, soc_conserv: float | list[float] | list[list[float]] | ndarray | None = None, soc_conserv_cost: float | None = None, available: ndarray | list | None = None, *, max_capacity: float, charging_power_limit: float, discharging_power_limit: float, initial_state_of_charge: float | None = None)
Bases:
StorageNew Storage + EV attributes
- add_objective(model: EchoConcreteModel) None
Populates the port attribute ‘objectives’ with any pyomo expressions that are needed :param model: pyomo concrete model
- add_port_to_model(model: EchoConcreteModel, profile: DataFrame) None
Creates pyomo vars, params, and constraints for the port.
- apply_conserv_soc_constraints(model: EchoConcreteModel) None
- apply_modified_soc_constraints(model: EchoConcreteModel) None
Get some variables to make constraints easier to write
- available: ndarray | list | None
- property cons_slack: str
- enable_trip_slack: bool
- soc_conserv: float | list[float] | list[list[float]] | ndarray | None
- soc_conserv_cost: float | None
- property trip_slack: str
- class echo.models.agnostic.MultiCommodityTellegenNode(uid: str = NOTHING, node_name: str = NOTHING, ports: dict[str, Port] = NOTHING, objective: NumericExpression | float = 0)
Bases:
NodeA node with ports that have multiple commodities. A tellegen constraint is applied per commodity.
- apply_node_constraints(model: EchoConcreteModel) None
Apply Tellegen constraint for same commodity ports.
- class echo.models.agnostic.OffOrConstrainedPort(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Variable, *, lower_bound: float, upper_bound: float)
Bases:
FlexPortA port that is either off (0) or on, and when it is on it is constrained between a min and max value.
- property active: str
- add_port_to_model(model: EchoConcreteModel, profile: DataFrame) None
Creates pyomo vars, params, and constraints for the port.
- lower_bound: float
- upper_bound: float
- class echo.models.agnostic.PartitionedMultiCommodityTellegenNode(uid: str = NOTHING, node_name: str = NOTHING, ports: dict[str, Port] = NOTHING, objective: NumericExpression | float = 0, partitions: dict[str, list[Port]] = NOTHING, default_partition: str = 'default_partition')
Bases:
NodeA node with partitions of ports, ports in each partition may have multiple commodities. A tellegen constraint is applied per partition per commodity.
- add_port(name: str, port: Port, partition: str | None = None) None
Override base add_port method, add addition argument which is partition name to which add the port.
If partition is not specified, adds to the default partition.
- apply_node_constraints(model: EchoConcreteModel) None
Apply Tellegen constraint for same commodity ports within each partition.
- default_partition: str
- class echo.models.agnostic.Sink(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint: FlowConstraint = FlowConstraint.NA, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Import, import_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Parameter, initial_value: dict[tuple[int, int], float] | float = 0)
Bases:
PortA fixed sink for a commodity.
- add_sink_profile(sink_values: dict[tuple[int, int], float]) None
- add_sink_profile_from_array(sink_values: list[float] | ndarray, expansion_periods: int = 1, time_periods: int | None = None) None
- flow_type: OptimisationType
- import_constraint: FlowConstraint
- initial_value: dict[tuple[int, int], float] | float
- class echo.models.agnostic.Source(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint: FlowConstraint = FlowConstraint.NA, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Export, export_constraint: FlowConstraint = FlowConstraint.NoConstraint, flow_type: OptimisationType = OptimisationType.Parameter, initial_value: dict[tuple[int, int], float] | float = 0)
Bases:
PortA fixed source of a commodity.
- add_source_profile(source_values: dict) None
- add_source_profile_from_array(source_values: list[float] | ndarray, expansion_periods: int = 1, time_periods: int | None = None) None
- export_constraint: FlowConstraint
- flow_type: OptimisationType
- initial_value: dict[tuple[int, int], float] | float
- class echo.models.agnostic.Storage(uid: str = NOTHING, port_name: str = NOTHING, units: Units = Units.NA, initial_value: dict[tuple[int, int], float] | float = 0, initial_value_ref: str | None = None, initial_value_scaling: int | None = None, import_constraint_value: ConstraintValueType | None = None, export_constraint_value: ConstraintValueType | None = None, active_periods: dict[tuple[int, int], Any] | None = None, slack: bool = False, objective: en.numeric_expr.NumericExpression | float = 0, allow_dangling_port: bool = False, flows: Flows = Flows.Both, flow_type: OptimisationType = OptimisationType.Variable, import_constraint: FlowConstraint = FlowConstraint.Fixed, export_constraint: FlowConstraint = FlowConstraint.Fixed, depth_of_discharge_limit: float = 0, min_soc: float = 0, charging_efficiency: float = 1, discharging_efficiency: float = 1, fixed_storage_capacity: bool = True, storage_capacity_cost: float | None = None, regularise: bool = False, *, max_capacity: float, charging_power_limit: float, discharging_power_limit: float, initial_state_of_charge: float | None = None)
Bases:
PortSame as old storage but without all the EV attributes
- add_objective(model: EchoConcreteModel) None
Populates the port attribute ‘objectives’ with any pyomo expressions that are needed :param model: pyomo concrete model
- add_port_to_model(model: EchoConcreteModel, profile: DataFrame) None
Creates pyomo vars, params, and constraints for the port.
- apply_soc_constraints(model: EchoConcreteModel) None
Extract some variables to make constraints easier to write
- charging_efficiency: float
- charging_power_limit: float
- create_storage_variables(model: EchoConcreteModel) None
- depth_of_discharge_limit: float
- discharging_efficiency: float
- discharging_power_limit: float
- export_constraint: FlowConstraint
- fixed_storage_capacity: bool
- flow_type: OptimisationType
- import_constraint: FlowConstraint
- initial_state_of_charge: float | None
- max_capacity: float
- min_soc: float
- property optimised_capacity: str
- regularise: bool
- property soc_constraint: str
- property soc_value: str
- storage_capacity_cost: float | None
- class echo.models.agnostic.TellegenNode(uid: str = NOTHING, node_name: str = NOTHING, objective: NumericExpression | float = 0, ports: dict[str, Port] = NOTHING)
Bases:
NodeA node that implements a Tellegen constraint requiring that port values sum to zero.
- apply_node_constraints(model: EchoConcreteModel) None
Apply constraints associated with this node to a concrete model.
Intended to be overridden in subclasses.
Define constraints as functions that returns a Constraint, EqualityExpression or InequalityExpression.
Define a subfunction of the form detailed in the example below, then apply with setattr. For example:
- def apply_node_constraints(self, model: EchoConcreteModel) -> None:
- def tellegen_node_rule(model: EchoConcreteModel, p: int, t:int) -> EqualityExpression:
a = 0 for port in node_ports.values():
a += getattr(model, port.port_name)[p, t]
return a == 0
node_ports = self.ports con_name = “reliability_con_” + self.node_name setattr(model, con_name, en.Constraint(model.Expansion, model.Time, rule=tellegen_node_rule))
- Parameters:
model – The model to add the constraints to.
- Returns:
None
- verify_node() None
Checks there is at least one port associated with this node.
- Raises:
ConfigurationError – If there are no ports present on this node.
- class echo.models.agnostic.ThreeWayValveNode(uid: str = NOTHING, node_name: str = NOTHING, objective: NumericExpression | float = 0, ports: dict[str, Port] = NOTHING, input_port_name: str = 'input_port', output_port_name_1: str = 'output_port_1', output_port_name_2: str = 'output_port_2', mutually_exclusive_port_flows: tuple[str, str] = None, *, units: Units)
Bases:
TellegenNodeA node that implements a Tellegen constraint requiring that port values sum to zero.
ThreeWayValveNode node implements additional constraints between ports, there is one input (import) port and two output (export) ports. At each time the flow is allowed through only one output port.
- add_node_to_model(model: EchoConcreteModel, profile: DataFrame) None
Add this node to a concrete model.
- Parameters:
model – The concrete model to add the node to.
profile – The data associated with this node.
- apply_node_constraints(model: EchoConcreteModel) None
Apply constraints associated with this node to a concrete model.
Intended to be overridden in subclasses.
Define constraints as functions that returns a Constraint, EqualityExpression or InequalityExpression.
Define a subfunction of the form detailed in the example below, then apply with setattr. For example:
- def apply_node_constraints(self, model: EchoConcreteModel) -> None:
- def tellegen_node_rule(model: EchoConcreteModel, p: int, t:int) -> EqualityExpression:
a = 0 for port in node_ports.values():
a += getattr(model, port.port_name)[p, t]
return a == 0
node_ports = self.ports con_name = “reliability_con_” + self.node_name setattr(model, con_name, en.Constraint(model.Expansion, model.Time, rule=tellegen_node_rule))
- Parameters:
model – The model to add the constraints to.
- Returns:
None
- property binary_variable_flow_through_mutually_exclusive_port_1: str
- property constraint_neg_flow_mutually_exclusive_port_1: str
- property constraint_neg_flow_mutually_exclusive_port_2: str
- property constraint_pos_flow_mutually_exclusive_port_1: str
- property constraint_pos_flow_mutually_exclusive_port_2: str
- create_ports() None
- input_port_name: str
- mutually_exclusive_port_flows: tuple[str, str]
- output_port_name_1: str
- output_port_name_2: str
- set_ports(input_port: FlexSink, output_port_1: FlexSource, output_port_2: FlexSource) None
- class echo.models.agnostic.TimeDelayNode(uid: str = NOTHING, node_name: str = NOTHING, ports: dict[str, Port] = NOTHING, objective: en.numeric_expr.NumericExpression | float = 0, max_output: float | None = None, min_output: float | None = None, max_input: float | None = None, min_input: float | None = None, input_port_ref: str = 'input', output_port_ref: str = 'output', *, input_port_unit: Units, output_port_unit: Units, time_delay: int)
Bases:
InputOutputNodeA time delay node is an input-output node that implements a fixed delay between input and output.
- apply_node_constraints(model: EchoConcreteModel) None
Apply constraints associated with this node to a concrete model.
Intended to be overridden in subclasses.
Define constraints as functions that returns a Constraint, EqualityExpression or InequalityExpression.
Define a subfunction of the form detailed in the example below, then apply with setattr. For example:
- def apply_node_constraints(self, model: EchoConcreteModel) -> None:
- def tellegen_node_rule(model: EchoConcreteModel, p: int, t:int) -> EqualityExpression:
a = 0 for port in node_ports.values():
a += getattr(model, port.port_name)[p, t]
return a == 0
node_ports = self.ports con_name = “reliability_con_” + self.node_name setattr(model, con_name, en.Constraint(model.Expansion, model.Time, rule=tellegen_node_rule))
- Parameters:
model – The model to add the constraints to.
- Returns:
None
- time_delay: int
- class echo.models.agnostic.TimeVaryingPiecewiseIONode(uid: str = NOTHING, node_name: str = NOTHING, ports: dict[str, Port] = NOTHING, objective: en.numeric_expr.NumericExpression | float = 0, max_output: float | None = None, min_output: float | None = None, max_input: float | None = None, min_input: float | None = None, input_port_ref: str = 'input', output_port_ref: str = 'output', input_points: dict | None = None, output_points: dict | None = None, input_points_ref: str | None = None, output_points_ref: str | None = None, *, input_port_unit: Units, output_port_unit: Units)
Bases:
InputOutputNodeA Node with an input and output and time varying piecewise relationship between input and output.
The relationship between input and output is defined at each time interval by an array of input–>output point pairs, which are used to construct a piecewise constraint. Attributes input_port_unit and output_port_unit define node’s commodity.
- add_constant_input_points(input_points: float | int | list, time_periods: int, expansion_periods: int = 1) None
Tiles constant input points array across time and expansion periods
- add_constant_output_points(output_points: float | int | list, time_periods: int, expansion_periods: int = 1) None
Tiles constant output points array across time and expansion periods.
- add_node_to_model(model: EchoConcreteModel, profile: DataFrame) None
Add this node to a concrete model.
- Parameters:
model – The concrete model to add the node to.
profile – The data associated with this node.
- apply_node_constraints(model: EchoConcreteModel) None
Apply constraints associated with this node to a concrete model.
Intended to be overridden in subclasses.
Define constraints as functions that returns a Constraint, EqualityExpression or InequalityExpression.
Define a subfunction of the form detailed in the example below, then apply with setattr. For example:
- def apply_node_constraints(self, model: EchoConcreteModel) -> None:
- def tellegen_node_rule(model: EchoConcreteModel, p: int, t:int) -> EqualityExpression:
a = 0 for port in node_ports.values():
a += getattr(model, port.port_name)[p, t]
return a == 0
node_ports = self.ports con_name = “reliability_con_” + self.node_name setattr(model, con_name, en.Constraint(model.Expansion, model.Time, rule=tellegen_node_rule))
- Parameters:
model – The model to add the constraints to.
- Returns:
None
- input_points: dict | None
- input_points_ref: str | None
- load_input_output_values_from_profile(model: EchoConcreteModel, profile_df: DataFrame) None
If input/output point string references are provided, load values from profile.
input_points_ref/output_points_ref will override input_points/output_points values provided in the instance’s attributes (if any) with values from profile dataframe.
- output_points: dict | None
- output_points_ref: str | None
- verify_points_values() None
Subpackages
- echo.models.agnostic.tellegen package
MultiCommodityTellegenNodePartitionedMultiCommodityTellegenNodeTellegenNodeThreeWayValveNodeThreeWayValveNode.add_node_to_model()ThreeWayValveNode.apply_node_constraints()ThreeWayValveNode.binary_variable_flow_through_mutually_exclusive_port_1ThreeWayValveNode.constraint_neg_flow_mutually_exclusive_port_1ThreeWayValveNode.constraint_neg_flow_mutually_exclusive_port_2ThreeWayValveNode.constraint_pos_flow_mutually_exclusive_port_1ThreeWayValveNode.constraint_pos_flow_mutually_exclusive_port_2ThreeWayValveNode.create_ports()ThreeWayValveNode.input_port_nameThreeWayValveNode.mutually_exclusive_port_flowsThreeWayValveNode.output_port_name_1ThreeWayValveNode.output_port_name_2ThreeWayValveNode.set_ports()ThreeWayValveNode.units
- Submodules
Submodules
- echo.models.agnostic.aggregation module
- echo.models.agnostic.base module
- echo.models.agnostic.bounded module
- echo.models.agnostic.controlled module
- echo.models.agnostic.flex module
- echo.models.agnostic.input_output module
- echo.models.agnostic.storage module
MobileStorageMobileStorage.add_objective()MobileStorage.add_port_to_model()MobileStorage.apply_conserv_soc_constraints()MobileStorage.apply_modified_soc_constraints()MobileStorage.availableMobileStorage.cons_slackMobileStorage.enable_trip_slackMobileStorage.soc_conservMobileStorage.soc_conserv_costMobileStorage.trip_slack
StorageStorage.add_objective()Storage.add_port_to_model()Storage.apply_soc_constraints()Storage.charging_efficiencyStorage.charging_power_limitStorage.create_storage_variables()Storage.depth_of_discharge_limitStorage.discharging_efficiencyStorage.discharging_power_limitStorage.export_constraintStorage.fixed_storage_capacityStorage.flow_typeStorage.flowsStorage.import_constraintStorage.initial_state_of_chargeStorage.max_capacityStorage.min_socStorage.optimised_capacityStorage.regulariseStorage.soc_constraintStorage.soc_valueStorage.storage_capacity_cost
- echo.models.agnostic.time_delay module
- echo.models.agnostic.time_varying module
TimeVaryingPiecewiseIONodeTimeVaryingPiecewiseIONode.add_constant_input_points()TimeVaryingPiecewiseIONode.add_constant_output_points()TimeVaryingPiecewiseIONode.add_node_to_model()TimeVaryingPiecewiseIONode.apply_node_constraints()TimeVaryingPiecewiseIONode.input_pointsTimeVaryingPiecewiseIONode.input_points_refTimeVaryingPiecewiseIONode.load_input_output_values_from_profile()TimeVaryingPiecewiseIONode.output_pointsTimeVaryingPiecewiseIONode.output_points_refTimeVaryingPiecewiseIONode.verify_points_values()