echo.models.agnostic.tellegen.three_way_valve module
- class echo.models.agnostic.tellegen.three_way_valve.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