OGS
FlowAndTemperatureControl.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <variant>
7
8#include "BaseLib/Error.h"
10#include "PowerWithCOP.h"
11
12namespace ProcessLib
13{
14namespace HeatTransportBHE
15{
16namespace BHE
17{
19{
20 double const flow_rate;
21 double const temperature;
22};
23
25 double power,
26 double const heat_capacity,
27 double const density,
28 double const T_out,
29 double const flow_rate_min,
30 double const power_min)
31{
32 flow_rate = (std::abs(flow_rate) < flow_rate_min) ? 0.0 : flow_rate;
33
34 if (std::abs(power) < power_min)
35 {
36 return {flow_rate, T_out};
37 }
38
39 if (flow_rate == 0)
40 {
42 "BHE power {:0.2f} W with flow rate of 0 m3/s requested, "
43 "calculation not possible!",
44 power);
45 }
46 return {flow_rate, power / flow_rate / heat_capacity / density + T_out};
47};
48
50{
51 FlowAndTemperature operator()(double const /*T_out*/,
52 double const time) const
53 {
55 double const flow_rate = flow_rate_param(time, x)[0];
56 double const temperature = temperature_param(time, x)[0];
57 return {(std::abs(flow_rate) < flow_rate_min) ? 0.0 : flow_rate,
58 temperature};
59 }
62 double const flow_rate_min;
63 static constexpr bool is_power_bc = false;
64};
65
66struct Power
67{
68 FlowAndTemperature operator()(double const T_out, double const time) const
69 {
71 double const flow_rate = flow_rate_param(time, x)[0];
72 double const power = power_param(time, x)[0];
73 return check_power_and_flow_rate(flow_rate,
74 power,
76 density,
77 T_out,
79 power_min);
80 }
81
82 // Value is expected to be in Watt.
85 double const heat_capacity;
86 double const density;
87 double const flow_rate_min;
88 double const power_min;
89 static constexpr bool is_power_bc = true;
90};
91
93{
94 FlowAndTemperature operator()(double const T_out, double const time) const
95 {
97 double const flow_rate = flow_rate_param(time, x)[0];
98 double const power_building = building_power.power_param(time, x)[0];
99 double const cop = building_power.cop_curve.getValue(T_out);
100
101 double const power = power_building - power_building / cop;
102
103 return check_power_and_flow_rate(flow_rate,
104 power,
106 density,
107 T_out,
109 power_min);
110 }
111
114 double const heat_capacity;
115 double const density;
116 double const flow_rate_min;
117 double const power_min;
118 static constexpr bool is_power_bc = true;
119};
120
122{
123 FlowAndTemperature operator()(double const T_out, double const time) const
124 {
126 double const flow_rate = flow_rate_param(time, x)[0];
127 double const power_heating = building_heating.power_param(time, x)[0];
128 double const cop_heating = building_heating.cop_curve.getValue(T_out);
129
130 double const power_hot_water =
131 building_hot_water.power_param(time, x)[0];
132 double const cop_hot_water =
133 building_hot_water.cop_curve.getValue(T_out);
134
135 double const power_cooling =
136 building_active_cooling.power_param(time, x)[0];
137 double const cop_cooling =
138 building_active_cooling.cop_curve.getValue(T_out);
139
140 double const power = power_heating - power_heating / cop_heating +
141 power_hot_water - power_hot_water / cop_hot_water +
142 power_cooling - power_cooling / cop_cooling;
143
144 return check_power_and_flow_rate(flow_rate,
145 power,
147 density,
148 T_out,
150 power_min);
151 }
152
157
158 double const heat_capacity;
159 double const density;
160 double const flow_rate_min;
161 double const power_min;
162 static constexpr bool is_power_bc = true;
163};
164
166{
167 FlowAndTemperature operator()(double const T_out, double const time) const
168 {
170 double const flow_rate = flow_rate_param(time, x)[0];
171 double const power_heating = building_heating.power_param(time, x)[0];
172 double const cop_heating = building_heating.cop_curve.getValue(T_out);
173
174 double const power_hot_water =
175 building_hot_water.power_param(time, x)[0];
176 double const cop_hot_water =
177 building_hot_water.cop_curve.getValue(T_out);
178
179 double const power_cooling = cooling_power_param(time, x)[0];
180
181 double const power = power_heating - power_heating / cop_heating +
182 power_hot_water - power_hot_water / cop_hot_water +
183 power_cooling;
184
185 return check_power_and_flow_rate(flow_rate,
186 power,
188 density,
189 T_out,
191 power_min);
192 }
193
198
199 double const heat_capacity;
200 double const density;
201 double const flow_rate_min;
202 double const power_min;
203 static constexpr bool is_power_bc = true;
204};
205
207{
208 FlowAndTemperature operator()(double const T_out, double const time) const
209 {
211 double const flow_rate = flow_rate_param(time, x)[0];
212 double const power_heating = building_heating.power_param(time, x)[0];
213 double const cop_heating = building_heating.cop_curve.getValue(T_out);
214
215 double const power_hot_water =
216 building_hot_water.power_param(time, x)[0];
217 double const cop_hot_water =
218 building_hot_water.cop_curve.getValue(T_out);
219
220 double const power = power_heating - power_heating / cop_heating +
221 power_hot_water - power_hot_water / cop_hot_water;
222
223 return check_power_and_flow_rate(flow_rate,
224 power,
226 density,
227 T_out,
229 power_min);
230 }
231
235
236 double const heat_capacity;
237 double const density;
238 double const flow_rate_min;
239 double const power_min;
240 static constexpr bool is_power_bc = true;
241};
242
244{
245 FlowAndTemperature operator()(double const T_out, double const time) const
246 {
248 double const flow_rate = flow_rate_param(time, x)[0];
249 double const power_heating = building_heating.power_param(time, x)[0];
250 double const cop_heating = building_heating.cop_curve.getValue(T_out);
251
252 double const power_cooling =
253 building_active_cooling.power_param(time, x)[0];
254 double const cop_cooling =
255 building_active_cooling.cop_curve.getValue(T_out);
256
257 double const power = power_heating - power_heating / cop_heating +
258 power_cooling - power_cooling / cop_cooling;
259
260 return check_power_and_flow_rate(flow_rate,
261 power,
263 density,
264 T_out,
266 power_min);
267 }
268
272
273 double const heat_capacity;
274 double const density;
275 double const flow_rate_min;
276 double const power_min;
277 static constexpr bool is_power_bc = true;
278};
279
281{
282 FlowAndTemperature operator()(double const T_out, double const time) const
283 {
285 double const flow_rate = flow_rate_param(time, x)[0];
286 double const power_heating = building_heating.power_param(time, x)[0];
287 double const cop_heating = building_heating.cop_curve.getValue(T_out);
288
289 double const power_cooling = cooling_power_param(time, x)[0];
290
291 double const power =
292 power_heating - power_heating / cop_heating + power_cooling;
293
294 return check_power_and_flow_rate(flow_rate,
295 power,
297 density,
298 T_out,
300 power_min);
301 }
302
306
307 double const heat_capacity;
308 double const density;
309 double const flow_rate_min;
310 double const power_min;
311 static constexpr bool is_power_bc = true;
312};
313
315{
316 FlowAndTemperature operator()(double const T_out, double const time) const
317 {
319 double const flow_rate = flow_rate_param(time, x)[0];
320
321 double const power_cooling =
322 building_active_cooling.power_param(time, x)[0];
323 double const cop_cooling =
324 building_active_cooling.cop_curve.getValue(T_out);
325
326 double const power = power_cooling - power_cooling / cop_cooling;
327
328 return check_power_and_flow_rate(flow_rate,
329 power,
331 density,
332 T_out,
334 power_min);
335 }
336
339
340 double const heat_capacity;
341 double const density;
342 double const flow_rate_min;
343 double const power_min;
344 static constexpr bool is_power_bc = true;
345};
346
348 std::variant<InflowTemperature,
349 Power,
357} // namespace BHE
358} // namespace HeatTransportBHE
359} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
FlowAndTemperature check_power_and_flow_rate(double flow_rate, double power, double const heat_capacity, double const density, double const T_out, double const flow_rate_min, double const power_min)
std::variant< InflowTemperature, Power, BuildingPower, BuildingPowerHotWaterActiveCooling, BuildingPowerHotWaterPassiveCooling, BuildingPowerHotWater, BuildingPowerActiveCooling, BuildingPowerPassiveCooling, ActiveCooling > FlowAndTemperatureControl
FlowAndTemperature operator()(double const T_out, double const time) const
ParameterLib::Parameter< double > const & flow_rate_param
FlowAndTemperature operator()(double const T_out, double const time) const
FlowAndTemperature operator()(double const T_out, double const time) const
FlowAndTemperature operator()(double const T_out, double const time) const
FlowAndTemperature operator()(double const T_out, double const time) const
FlowAndTemperature operator()(double const T_out, double const time) const
FlowAndTemperature operator()(double const T_out, double const time) const
ParameterLib::Parameter< double > const & flow_rate_param
FlowAndTemperature operator()(double const, double const time) const
ParameterLib::Parameter< double > const & temperature_param
ParameterLib::Parameter< double > const & flow_rate_param
ParameterLib::Parameter< double > const & flow_rate_param
ParameterLib::Parameter< double > const & power_param
FlowAndTemperature operator()(double const T_out, double const time) const