OGS
CreateBHEUType.cpp
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#include "CreateBHEUType.h"
5
6#include <cmath>
7
8#include "BHE_1U.h"
9#include "BHE_2U.h"
10#include "BaseLib/ConfigTree.h"
11#include "BaseLib/Error.h"
13namespace ProcessLib
14{
15namespace HeatTransportBHE
16{
17namespace BHE
18{
22 BaseLib::ConfigTree const& config,
23 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
24 std::map<std::string,
25 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
26 curves)
27{
28 // if the BHE is using python boundary condition
29 auto const bhe_if_use_python_bc_conf =
31 config.getConfigParameter<bool>("use_bhe_pipe_network", false);
32 DBUG("If using python boundary condition : {:s}",
33 (bhe_if_use_python_bc_conf) ? "true" : "false");
34
35 auto const borehole_geometry =
37 createBoreholeGeometry(config.getConfigSubtree("borehole"), parameters);
38
40 auto const& pipes_config = config.getConfigSubtree("pipes");
41 Pipe const inlet_pipe =
43 createPipe(pipes_config.getConfigSubtree("inlet"), parameters);
44 Pipe const outlet_pipe =
46 createPipe(pipes_config.getConfigSubtree("outlet"), parameters);
47 const auto pipe_distance =
49 pipes_config.getConfigParameter<double>("distance_between_pipes");
50 const auto pipe_longitudinal_dispersion_length =
52 pipes_config.getConfigParameter<double>(
53 "longitudinal_dispersion_length");
54 PipeConfigurationUType const pipes{inlet_pipe, outlet_pipe, pipe_distance,
55 pipe_longitudinal_dispersion_length};
56
57 if (pipe_distance <= 0)
58 {
60 "distance_between_pipes must be positive for U-type BHEs, got "
61 "{:g}.",
62 pipe_distance);
63 }
64
65 // The resistance formulas use a single pipe outside diameter; the BHE_1U /
66 // BHE_2U constructor enforces that inlet and outlet share it, so the inlet
67 // value is representative here.
68 double const d0 = pipes.inlet.outsideDiameter();
69 if (pipe_distance <= d0)
70 {
72 "distance_between_pipes ({:g}) must be > pipe outside diameter "
73 "({:g}) for valid U-type thermal resistance formulas. A distance "
74 "equal to the pipe outside diameter makes the inter-grout acosh "
75 "argument exactly 1, i.e. a zero resistance and an infinite "
76 "assembly coefficient.",
77 pipe_distance, d0);
78 }
79
81 auto const grout = createGroutParameters(config.getConfigSubtree("grout"));
82
83 auto const refrigerant =
85 createRefrigerantProperties(config.getConfigSubtree("refrigerant"));
86
87 auto const flowAndTemperatureControl = createFlowAndTemperatureControl(
89 config.getConfigSubtree("flow_and_temperature_control"),
90 parameters,
91 curves,
92 refrigerant);
93
94 return {borehole_geometry, refrigerant, grout,
95 flowAndTemperatureControl, pipes, bhe_if_use_python_bc_conf};
96}
97
98template <typename T_BHE>
100 BaseLib::ConfigTree const& config,
101 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
102 std::map<std::string,
103 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
104 curves)
105{
106 auto UType = parseBHEUTypeConfig(config, parameters, curves);
107 return {std::get<0>(UType), std::get<1>(UType), std::get<2>(UType),
108 std::get<3>(UType), std::get<4>(UType), std::get<5>(UType)};
109}
110
112 BaseLib::ConfigTree const& config,
113 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
114 std::map<std::string,
115 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
116 curves);
117
119 BaseLib::ConfigTree const& config,
120 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters,
121 std::map<std::string,
122 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
123 curves);
124} // namespace BHE
125} // namespace HeatTransportBHE
126} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:10
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
RefrigerantProperties createRefrigerantProperties(BaseLib::ConfigTree const &config)
T_BHE createBHEUType(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
FlowAndTemperatureControl createFlowAndTemperatureControl(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves, RefrigerantProperties const &refrigerant)
static std::tuple< BoreholeGeometry, RefrigerantProperties, GroutParameters, FlowAndTemperatureControl, PipeConfigurationUType, bool > parseBHEUTypeConfig(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
BoreholeGeometry createBoreholeGeometry(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters)
template BHE_1U createBHEUType< BHE_1U >(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
template BHE_2U createBHEUType< BHE_2U >(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
Pipe createPipe(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters)
Definition Pipe.cpp:17
std::variant< InflowTemperature, Power, BuildingPower, BuildingPowerHotWaterActiveCooling, BuildingPowerHotWaterPassiveCooling, BuildingPowerHotWater, BuildingPowerActiveCooling, BuildingPowerPassiveCooling, ActiveCooling > FlowAndTemperatureControl
GroutParameters createGroutParameters(BaseLib::ConfigTree const &config)