eris-echo 2.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. echo/__init__.py +1 -0
  2. echo/configuration.py +178 -0
  3. echo/constants.py +8 -0
  4. echo/exceptions.py +16 -0
  5. echo/functional.py +83 -0
  6. echo/models/__init__.py +0 -0
  7. echo/models/agnostic/__init__.py +50 -0
  8. echo/models/agnostic/aggregation.py +64 -0
  9. echo/models/agnostic/base.py +84 -0
  10. echo/models/agnostic/bounded.py +43 -0
  11. echo/models/agnostic/controlled.py +97 -0
  12. echo/models/agnostic/flex.py +61 -0
  13. echo/models/agnostic/input_output.py +30 -0
  14. echo/models/agnostic/storage.py +307 -0
  15. echo/models/agnostic/tellegen/__init__.py +6 -0
  16. echo/models/agnostic/tellegen/base.py +62 -0
  17. echo/models/agnostic/tellegen/multi_commodity.py +50 -0
  18. echo/models/agnostic/tellegen/partitioned_multi_commodity.py +88 -0
  19. echo/models/agnostic/tellegen/three_way_valve.py +122 -0
  20. echo/models/agnostic/time_delay.py +34 -0
  21. echo/models/agnostic/time_varying.py +134 -0
  22. echo/models/base/__init__.py +21 -0
  23. echo/models/base/edge.py +128 -0
  24. echo/models/base/node.py +160 -0
  25. echo/models/base/optimisation_graph.py +546 -0
  26. echo/models/base/path.py +66 -0
  27. echo/models/base/port.py +564 -0
  28. echo/models/base/transform.py +186 -0
  29. echo/models/base/types.py +7 -0
  30. echo/models/carbon/__init__.py +4 -0
  31. echo/models/carbon/aggregation.py +33 -0
  32. echo/models/carbon/base.py +25 -0
  33. echo/models/electrical/__init__.py +35 -0
  34. echo/models/electrical/base.py +37 -0
  35. echo/models/electrical/ev/__init__.py +14 -0
  36. echo/models/electrical/ev/base.py +340 -0
  37. echo/models/electrical/ev/deprecated.py +273 -0
  38. echo/models/electrical/ev/ev_with_profile.py +137 -0
  39. echo/models/electrical/ev/v0g.py +264 -0
  40. echo/models/electrical/ev/v1g.py +85 -0
  41. echo/models/electrical/ev/v2g.py +84 -0
  42. echo/models/electrical/generation.py +49 -0
  43. echo/models/electrical/inverter.py +97 -0
  44. echo/models/gas/__init__.py +5 -0
  45. echo/models/gas/base.py +18 -0
  46. echo/models/gas/boiler_fixedcop.py +65 -0
  47. echo/models/gas/boiler_tempcontrolled.py +96 -0
  48. echo/models/prebuilt/__init__.py +17 -0
  49. echo/models/prebuilt/battery.py +36 -0
  50. echo/models/prebuilt/diesel_generator.py +57 -0
  51. echo/models/prebuilt/flex.py +36 -0
  52. echo/models/prebuilt/load.py +14 -0
  53. echo/models/prebuilt/scaled_solar.py +19 -0
  54. echo/models/prebuilt/solar.py +13 -0
  55. echo/models/scenario.py +63 -0
  56. echo/models/thermal/__init__.py +15 -0
  57. echo/models/thermal/base.py +117 -0
  58. echo/models/thermal/parameterised_chiller.py +228 -0
  59. echo/models/thermal/parameterised_heatpump.py +496 -0
  60. echo/models/thermal/simple_chiller.py +139 -0
  61. echo/models/thermal/simple_heatpump.py +291 -0
  62. echo/models/thermal/simple_heatpump_dualoutput.py +195 -0
  63. echo/models/thermal/storage.py +307 -0
  64. echo/objectives/__init__.py +0 -0
  65. echo/objectives/base.py +99 -0
  66. echo/objectives/contingency.py +158 -0
  67. echo/objectives/power.py +132 -0
  68. echo/objectives/tariff.py +694 -0
  69. echo/optimiser.py +460 -0
  70. echo/py.typed +0 -0
  71. echo/tracker.py +74 -0
  72. echo/utils.py +506 -0
  73. echo/validators.py +290 -0
  74. echo/visualization.py +229 -0
  75. eris_echo-2.3.0.dist-info/METADATA +127 -0
  76. eris_echo-2.3.0.dist-info/RECORD +79 -0
  77. eris_echo-2.3.0.dist-info/WHEEL +5 -0
  78. eris_echo-2.3.0.dist-info/licenses/LICENSE.txt +22 -0
  79. eris_echo-2.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,19 @@
1
+ from echo.models.base.node import Node
2
+ from echo.models.electrical import ElectricalGeneration
3
+
4
+
5
+ class ScaledSolar(Node):
6
+ """Solar Node using size of solar system for scaling of initial value ref"""
7
+
8
+ def __init__(
9
+ self,
10
+ port_name: str,
11
+ solar_size: float,
12
+ initial_value_ref: str,
13
+ curtailable: bool = False,
14
+ **data,
15
+ ) -> None:
16
+ super().__init__(**data)
17
+ self.ports[port_name] = ElectricalGeneration(
18
+ curtailable=curtailable, initial_value_ref=initial_value_ref, initial_value_scaling=solar_size
19
+ )
@@ -0,0 +1,13 @@
1
+ from echo.models.base import Node
2
+ from echo.models.electrical import ElectricalGeneration
3
+ from echo.validators import ArrayType
4
+
5
+
6
+ class Solar(Node):
7
+ def __init__(self, port_name: str, profile: ArrayType | dict, curtailable: bool = False, **data) -> None:
8
+ super().__init__(**data)
9
+ self.ports[port_name] = ElectricalGeneration(curtailable=curtailable)
10
+ if type(profile) is dict:
11
+ self.ports[port_name].set_initial_value(profile)
12
+ else:
13
+ self.ports[port_name].set_initial_value_from_array(profile)
@@ -0,0 +1,63 @@
1
+ import os
2
+ from dataclasses import dataclass
3
+
4
+ from pyomo.core.base.set import FiniteScalarRangeSet
5
+ from pyomo.environ import ConcreteModel, Param
6
+
7
+
8
+ @dataclass
9
+ class ScenarioSettings:
10
+ """Settings specific to describing an Echo scenario"""
11
+
12
+ interval_duration: int # Duration of each interval, in minutes
13
+ number_of_intervals: int # Total number of intervals
14
+ number_of_expansion_intervals: int # Number of expansion intervals
15
+ discount_rate: int = 0
16
+
17
+
18
+ @dataclass
19
+ class EngineSettings:
20
+ """High level settings for the underlying optimisation engine
21
+
22
+ Args:
23
+ engine: the name (str) of the optimiser e.g. "cplex"
24
+ engine_executable: the path to the executable (str). An empty string causes echo
25
+ to try to determine the path to the solver.
26
+ small_m: small bias value (float). A small fudge factor for reducing the size
27
+ of the solution set and achieving a unique optimisation solution.
28
+ big_m: big bias value (int). A big_m value for integer optimisation
29
+ """
30
+
31
+ engine: str
32
+ engine_executable: str
33
+ small_m: float
34
+ big_m: int
35
+
36
+
37
+ class EchoConcreteModel(ConcreteModel):
38
+ """Extension to pyomo's ConcreteModel that documents all the echo specific variables that
39
+ decorate the underlying ConcreteModel"""
40
+
41
+ small_m: Param # A small fudge factor for reducing the size of the solution set and achieving a unique solution
42
+ big_m: Param # A big_m value for integer optimisation
43
+ Time: FiniteScalarRangeSet # index for time
44
+ Expansion: FiniteScalarRangeSet # index for expansion periods
45
+ discount_rates: Param
46
+
47
+ scenario_settings: ScenarioSettings
48
+
49
+
50
+ def engine_settings_from_environment(optimiser_engine: str | None = None) -> EngineSettings:
51
+ """Configure the optimiser through setting appropriate environmental variables."""
52
+
53
+ if not optimiser_engine:
54
+ optimiser_engine = os.environ.get(
55
+ "OPTIMISER_ENGINE", "cplex"
56
+ ) # Default to cplex, as we seem to want quadratic costs
57
+
58
+ return EngineSettings(
59
+ engine=optimiser_engine,
60
+ engine_executable=os.environ.get("OPTIMISER_ENGINE_EXECUTABLE", ""),
61
+ big_m=5000000, # This value has been arbitrarily chosen
62
+ small_m=0.0001, # This value has been arbitrarily chosen
63
+ )
@@ -0,0 +1,15 @@
1
+ from echo.models.thermal.parameterised_chiller import ParameterisedChiller
2
+ from echo.models.thermal.parameterised_heatpump import ParameterisedHeatPump
3
+ from echo.models.thermal.simple_chiller import SimpleChiller
4
+ from echo.models.thermal.simple_heatpump import SimpleHeatPump
5
+ from echo.models.thermal.simple_heatpump_dualoutput import SimpleHeatPumpDualOutput
6
+ from echo.models.thermal.storage import ThermalStorage
7
+
8
+ __all__ = [
9
+ "ParameterisedChiller",
10
+ "ParameterisedHeatPump",
11
+ "SimpleChiller",
12
+ "SimpleHeatPump",
13
+ "SimpleHeatPumpDualOutput",
14
+ "ThermalStorage",
15
+ ]
@@ -0,0 +1,117 @@
1
+ import pandas as pd
2
+ import pyomo.environ as en
3
+ from attrs import define, field, validators
4
+ from pyomo.core.expr import EqualityExpression, InequalityExpression
5
+
6
+ from echo.models.base import Node
7
+ from echo.models.scenario import EchoConcreteModel
8
+ from echo.utils import set_var_bounds_from_dict
9
+
10
+
11
+ @define
12
+ class ThermalNode(Node):
13
+ """
14
+ A thermal node has an internal temperature variable, which can be bounded.
15
+ It can have any number of ports for heating (importing) or cooling (export).
16
+ All the ports are related to temp by an energy balance constraint.
17
+ """
18
+
19
+ temp_ub: dict = field(
20
+ kw_only=True
21
+ ) # Upper bound of acceptable temperature for each time interval: dict with expansion-time keys
22
+ temp_lb: dict = field(
23
+ kw_only=True
24
+ ) # Lower bound of acceptable temperature for each time interval: dict with expansion-time keys
25
+ external_temp: dict = field(kw_only=True) # External (ambient) temp, formatted as dict with expansion-time keys
26
+ loss_factor: float = field(
27
+ default=0, validator=validators.ge(0)
28
+ ) # Losses due to ambient temp being lower than internal temp
29
+ gain_factor: float = field(
30
+ default=0, validator=validators.ge(0)
31
+ ) # Free gains due to ambient temp being higher than internal temp
32
+ temp_to_energy_coef: float = field(
33
+ default=1, validator=validators.gt(0)
34
+ ) # Conversion factor * temp change = added energy
35
+ initial_internal_temp: float = 0 # initial internal temperature
36
+
37
+ # Pyomo vars/params
38
+ internal_temp: str = ""
39
+ is_gain: str = ""
40
+ losses: str = ""
41
+ gains: str = ""
42
+
43
+ def __attrs_post_init__(self) -> None:
44
+ self.internal_temp = "internal_temp_" + self.node_name
45
+ self.is_gain = "is_gain_" + self.node_name
46
+ self.losses = "losses_" + self.node_name
47
+ self.gains = "gains_" + self.node_name
48
+
49
+ def add_node_to_model(self, model: EchoConcreteModel, profile: pd.DataFrame) -> None:
50
+ super().add_node_to_model(model, profile)
51
+ self.create_and_bound_temp_vars(model)
52
+ self.loss_and_gain_constraints_and_variables(model)
53
+ self.apply_energy_balance_constraint(model)
54
+
55
+ def create_and_bound_temp_vars(self, model: EchoConcreteModel) -> None:
56
+ # Create temperature variable
57
+ setattr(model, self.internal_temp, en.Var(model.Expansion, model.Time, domain=en.NonNegativeReals))
58
+ # Bound temp variable to be within range
59
+ set_var_bounds_from_dict(model=model, var_name=self.internal_temp, ub=self.temp_ub, lb=self.temp_lb)
60
+
61
+ def loss_and_gain_constraints_and_variables(self, model: EchoConcreteModel) -> None:
62
+ # Create variable for losses and gains
63
+ setattr(model, self.losses, en.Var(model.Expansion, model.Time, domain=en.NonPositiveReals))
64
+ setattr(model, self.gains, en.Var(model.Expansion, model.Time, domain=en.NonNegativeReals))
65
+ setattr(model, self.is_gain, en.Var(model.Expansion, model.Time, domain=en.Binary))
66
+
67
+ # Apply constraints on loss and gain variables
68
+ def loss_gain_sum_constraint(model: EchoConcreteModel, p: int, t: int) -> EqualityExpression:
69
+ """Losses + gains must equal the temperature difference between ambient and internal"""
70
+ return (
71
+ getattr(model, self.losses)[p, t] + getattr(model, self.gains)[p, t]
72
+ == self.external_temp[p, t] - getattr(model, self.internal_temp)[p, t]
73
+ )
74
+
75
+ setattr(
76
+ model,
77
+ "loss_gain_con1_" + self.node_name,
78
+ en.Constraint(model.Expansion, model.Time, rule=loss_gain_sum_constraint),
79
+ )
80
+
81
+ def loss_or_gain1(model: EchoConcreteModel, p: int, t: int) -> InequalityExpression:
82
+ """Gains can only be non-zero if is_gain = 1"""
83
+ return getattr(model, self.gains)[p, t] <= getattr(model, self.is_gain)[p, t] * model.big_m
84
+
85
+ setattr(
86
+ model, "loss_gain_con2_" + self.node_name, en.Constraint(model.Expansion, model.Time, rule=loss_or_gain1)
87
+ )
88
+
89
+ def loss_or_gain2(model: EchoConcreteModel, p: int, t: int) -> InequalityExpression:
90
+ """Losses can only be non-zero if is_gain = 0"""
91
+ return getattr(model, self.losses)[p, t] >= (getattr(model, self.is_gain)[p, t] - 1) * model.big_m
92
+
93
+ setattr(
94
+ model, "loss_gain_con3_" + self.node_name, en.Constraint(model.Expansion, model.Time, rule=loss_or_gain2)
95
+ )
96
+
97
+ def apply_energy_balance_constraint(self, model: EchoConcreteModel) -> None:
98
+ # Constraint relating internal, ambient temp, heat in, heat out, losses, and gains
99
+ def rule1(model: EchoConcreteModel, p: int, t: int) -> EqualityExpression:
100
+ thermal_kw = 0
101
+ for v in self.ports.values():
102
+ thermal_kw += getattr(model, v.port_name)[p, t] # sum together our thermal ports
103
+
104
+ internal_temp = getattr(model, self.internal_temp)
105
+ loss = getattr(model, self.losses)[p, t] * self.loss_factor
106
+ gain = getattr(model, self.gains)[p, t] * self.gain_factor
107
+
108
+ if p == 0 and t == 0:
109
+ return (
110
+ thermal_kw + loss + gain
111
+ == (internal_temp[p, t] - self.initial_internal_temp) * self.temp_to_energy_coef
112
+ )
113
+ else:
114
+ temp_diff = internal_temp[p, t] - internal_temp[p, t - 1]
115
+ return thermal_kw + loss + gain == temp_diff * self.temp_to_energy_coef
116
+
117
+ setattr(model, "internal_temp_con_" + self.node_name, en.Constraint(model.Expansion, model.Time, rule=rule1))
@@ -0,0 +1,228 @@
1
+ import pandas as pd
2
+ import pyomo.environ as en
3
+ from attrs import define, field, validators
4
+ from pyomo.core.expr import EqualityExpression
5
+ from scipy import interpolate
6
+
7
+ from echo.configuration import Units
8
+ from echo.models.agnostic import FlexPort, FlexSink, FlexSource, TimeVaryingPiecewiseIONode
9
+ from echo.models.scenario import EchoConcreteModel
10
+ from echo.utils import (
11
+ TimeSeriesData,
12
+ clamp,
13
+ expand_as_dict,
14
+ to_initial_values,
15
+ )
16
+ from echo.validators import (
17
+ partial_load_cop_validator,
18
+ temperature_dependent_cop_validator,
19
+ )
20
+
21
+
22
+ @define
23
+ class ParameterisedChiller(TimeVaryingPiecewiseIONode):
24
+ """A chiller has one electrical input port and one cooling output (thermal sink) port.
25
+
26
+ ParameterisedChiller is an input/output piecewise node, with a single set of input/output breakpoints representing
27
+ chiller COP (Coefficient Of Performance = Output/Input=Cooling_delivered/Electricity_consumed) used
28
+ for all time periods.
29
+ """
30
+
31
+ nominal_cop: float = field(
32
+ kw_only=True, validator=validators.gt(0)
33
+ ) # Nominal coefficient of performance COP = output/input
34
+
35
+ max_cooling_capacity: float = field(
36
+ kw_only=True, validator=validators.gt(0)
37
+ ) # Maximum cooling output in KWT (1RT ~ 3.5KWT)
38
+ partial_load_cop: dict = field(
39
+ default={
40
+ 0: 0,
41
+ 0.25: 0.8,
42
+ 0.5: 0.9,
43
+ 0.75: 1,
44
+ 1: 0.85,
45
+ },
46
+ validator=partial_load_cop_validator,
47
+ ) # Scaling factor for the nominal COP (coefficient of performance) depending on the partial load value
48
+ temperature_dependent_cop: dict = field(
49
+ default={
50
+ 0: 0.7,
51
+ 10: 1,
52
+ 20: 0.5,
53
+ 30: 0.35,
54
+ 45: 0.2,
55
+ },
56
+ validator=temperature_dependent_cop_validator,
57
+ ) # Scaling factor for the nominal COP (coefficient of performance) depending on \
58
+ # the ambient/condenser temperature value
59
+ ambient_temperature_dict: dict = field(
60
+ factory=dict
61
+ ) # Condenser side temperature ambient air temperature or condenser \
62
+ # water temperature for water cooled chiller
63
+ ambient_temperature_ref: str | None = None # Ambient temperature array passed by string reference
64
+ constant_ambient_temperature: float = 10 # Constant value for ambient temperature in degrees C,
65
+ # when no array data is provided
66
+ input_port_unit: Units = Units.KW # Input port units
67
+ output_port_unit: Units = Units.KWT # Output port units TODO: implementation for output units JPS
68
+ heat_rejection_port: bool = False # If True, add heat rejection port
69
+ heat_rejection_coefficient: float = field(
70
+ default=1, validator=validators.gt(0)
71
+ ) # Heat rejection coefficient cooling_delivered/heat_rejected
72
+
73
+ # The input_port_ref and output_port_ref are defined on the parent class (TimeVaryingPiecewiseIONode)
74
+ heat_rejection_port_ref: str = "heat_rejection"
75
+
76
+ def __attrs_post_init__(self) -> None:
77
+ super().__attrs_post_init__()
78
+
79
+ # A chiller has one electrical input port and one cooling output (thermal sink) port
80
+ self.ports[self.input_port_ref] = FlexSink(units=self.input_port_unit)
81
+ self.ports[self.output_port_ref] = FlexSink(units=self.output_port_unit)
82
+ if self.heat_rejection_port:
83
+ self.ports[self.heat_rejection_port_ref] = FlexSource(units=self.output_port_unit)
84
+
85
+ @property
86
+ def temperature_cop_param(self) -> str:
87
+ return f"temperature_cop_factor_{self.node_name}"
88
+
89
+ @property
90
+ def electrical_input_port_ref(self) -> str:
91
+ return self.input_port_ref
92
+
93
+ @property
94
+ def thermal_output_port_ref(self) -> str:
95
+ return self.output_port_ref
96
+
97
+ def update(self, ambient_temperature_dict: dict[float, float]) -> None:
98
+ self.ambient_temperature_dict = ambient_temperature_dict
99
+
100
+ def add_node_to_model(self, model: EchoConcreteModel, profile: pd.DataFrame) -> None:
101
+ self._load_temperature_values_from_profile(model, profile)
102
+ self._define_temperature_dependent_cop_coefficient(model)
103
+ self._set_input_points(model)
104
+ self._set_output_points(model)
105
+ super().add_node_to_model(model, profile)
106
+ if self.heat_rejection_port_ref in self.ports:
107
+ self._add_heat_rejection_constraint(model)
108
+
109
+ def set_ports(
110
+ self,
111
+ electrical_input_port: FlexSink,
112
+ cooling_output_port: FlexPort,
113
+ heat_rejection_port: FlexPort | None = None,
114
+ ) -> None:
115
+ # Discard existing ports
116
+ self.ports.clear()
117
+
118
+ # Update port references
119
+ self.input_port_ref = electrical_input_port.port_name
120
+ self.output_port_ref = cooling_output_port.port_name
121
+
122
+ # Add the new ports
123
+ self.ports[self.input_port_ref] = electrical_input_port
124
+ self.ports[self.output_port_ref] = cooling_output_port
125
+
126
+ # Handle heat intake rejection
127
+ self.heat_rejection_port = False # clear if already set
128
+ if heat_rejection_port:
129
+ self.heat_rejection_port = True
130
+ self.heat_rejection_port_ref = heat_rejection_port.port_name
131
+ self.ports[self.heat_rejection_port_ref] = heat_rejection_port
132
+
133
+ def _define_temperature_dependent_cop_coefficient(self, model: EchoConcreteModel) -> None:
134
+ """Get COP (coefficient of performance) scaling factor for each interval.
135
+
136
+ Calculate value of the temperature_cop_factor parameter using numpy linear interpolation function.
137
+ """
138
+
139
+ temperature_points = list(self.temperature_dependent_cop.keys())
140
+ cop_points = list(self.temperature_dependent_cop.values())
141
+
142
+ if self.ambient_temperature_dict:
143
+ temperature_dict = self.ambient_temperature_dict
144
+ else:
145
+ # Set default amb temp value to 10 >> no change to nominal COP
146
+ temperature_dict = expand_as_dict(
147
+ TimeSeriesData(
148
+ value=self.constant_ambient_temperature,
149
+ num_time_intervals=len(model.Time),
150
+ num_expansion_intervals=len(model.Expansion),
151
+ )
152
+ )
153
+
154
+ # Use numpy linear interpolation function to get temperature related cop (coefficient of performance)
155
+ # scaling factor based on the temperature values in the temperature dictionary
156
+ min_temp = min(self.temperature_dependent_cop.keys())
157
+ max_temp = max(self.temperature_dependent_cop.keys())
158
+ clamped_temp_values = [clamp(v, min_temp, max_temp) for v in temperature_dict.values()]
159
+
160
+ cop_scaling_interpolated = interpolate.interp1d(temperature_points, cop_points, assume_sorted=False)(
161
+ list(clamped_temp_values)
162
+ ).round(2)
163
+ temperature_cop_dict = {k: v for k, v in zip(temperature_dict.keys(), cop_scaling_interpolated, strict=True)}
164
+ # Create a parameter holding ambient/condenser temperature dictionary
165
+ # (defaulting to self.constant_ambient_temperature)
166
+ setattr(
167
+ model,
168
+ self.temperature_cop_param,
169
+ en.Param(model.Expansion, model.Time, initialize=temperature_cop_dict, domain=en.Reals),
170
+ )
171
+
172
+ def _set_input_points(self, model: EchoConcreteModel) -> None:
173
+ """Input breakpoints are input electrical power values calculated as
174
+ cooling_output/(COP_nominal*partial_load_correction) and scaled by 1/temperature_cop_param value"""
175
+
176
+ # get parameter holding temperature dependent COP (coefficient of performance) factor
177
+ temperature_cop_param = getattr(model, self.temperature_cop_param)
178
+
179
+ def input_point(k: float, v: float) -> float:
180
+ if v == 0:
181
+ return 0
182
+ else:
183
+ return k * self.max_cooling_capacity / (v * self.nominal_cop)
184
+
185
+ self.input_points = {
186
+ (p, t): [input_point(k, v) / temperature_cop_param[p, t] for k, v in self.partial_load_cop.items()]
187
+ for p in range(len(model.Expansion))
188
+ for t in range(len(model.Time))
189
+ }
190
+
191
+ def _set_output_points(self, model: EchoConcreteModel) -> None:
192
+ """Output breakpoints are partial cooling load values (% of max capacity)"""
193
+ self.output_points = {
194
+ (p, t): [k * self.max_cooling_capacity for k in self.partial_load_cop.keys()]
195
+ for p in range(len(model.Expansion))
196
+ for t in range(len(model.Time))
197
+ }
198
+
199
+ def _add_heat_rejection_constraint(self, model: EchoConcreteModel) -> None:
200
+ """Get variables representing port flow values for cooling output (heat in) and
201
+ rejected heat flow, set the constraint."""
202
+ heat_in = getattr(model, self.ports[self.output_port_ref].port_name)
203
+ heat_reject = getattr(model, self.ports[self.heat_rejection_port_ref].port_name)
204
+
205
+ def heat_reject_constraint(model: EchoConcreteModel, p: None, t: None) -> EqualityExpression:
206
+ """Amount of rejected heat at each interval equals amount of cooling delivered (heat in) multiplied by
207
+ heat rejection coefficient
208
+ """
209
+ return heat_reject[p, t] == -heat_in[p, t] * self.heat_rejection_coefficient
210
+
211
+ setattr(
212
+ model,
213
+ "heat_rejection_constraint_" + self.node_name,
214
+ en.Constraint(model.Expansion, model.Time, rule=heat_reject_constraint),
215
+ )
216
+
217
+ def _load_temperature_values_from_profile(self, model: EchoConcreteModel, profile_df: pd.DataFrame) -> None:
218
+ """When ambient temperature is set by str reference, load values from profile."""
219
+ if self.ambient_temperature_ref:
220
+ if self.ambient_temperature_ref and self.ambient_temperature_ref not in profile_df.columns:
221
+ raise ValueError(f"Could not find reference column name {self.ambient_temperature_ref} in the profile.")
222
+ else:
223
+ self.ambient_temperature_dict = to_initial_values(
224
+ profile_df,
225
+ key=self.ambient_temperature_ref,
226
+ time_periods=len(model.Time),
227
+ expansion_periods=len(model.Expansion),
228
+ )