OGS
BHE_1P.cpp
Go to the documentation of this file.
1
11#include "BHE_1P.h"
12
13#include <boost/math/constants/constants.hpp>
14
16#include "Physics.h"
18
19namespace ProcessLib
20{
21namespace HeatTransportBHE
22{
23namespace BHE
24{
26 RefrigerantProperties const& refrigerant,
27 GroutParameters const& grout,
28 FlowAndTemperatureControl const& flowAndTemperatureControl,
29 PipeConfiguration1PType const& pipes,
30 bool const use_python_bcs)
31 : BHECommon{borehole, refrigerant, grout, flowAndTemperatureControl,
32 use_python_bcs},
33 _pipe(pipes)
34{
35 _thermal_resistances.fill(std::numeric_limits<double>::quiet_NaN());
36
37 // Initialize thermal resistances.
38 auto values = visit(
39 [&](auto const& control) {
41 0. /* initial time */);
42 },
44 updateHeatTransferCoefficients(values.flow_rate);
45}
46
47std::array<double, BHE_1P::number_of_unknowns> BHE_1P::pipeHeatCapacities()
48 const
49{
50 double const rho_r = refrigerant.density;
51 double const specific_heat_capacity = refrigerant.specific_heat_capacity;
52 double const rho_g = grout.rho_g;
53 double const porosity_g = grout.porosity_g;
54 double const heat_cap_g = grout.heat_cap_g;
55
56 return {{
57 /*pipe*/ rho_r * specific_heat_capacity,
58 /*grout*/ (1.0 - porosity_g) * rho_g * heat_cap_g,
59 }};
60}
61
62std::array<double, BHE_1P::number_of_unknowns> BHE_1P::pipeHeatConductions()
63 const
64{
65 double const lambda_r = refrigerant.thermal_conductivity;
66 double const rho_r = refrigerant.density;
67 double const Cp_r = refrigerant.specific_heat_capacity;
68 double const alpha_L = _pipe.longitudinal_dispersion_length;
69 double const porosity_g = grout.porosity_g;
70 double const lambda_g = grout.lambda_g;
71
72 // Here we calculate the laplace coefficients in the governing
73 // equations of the BHE.
74 return {{
75 // pipe, Eq. 19
76 (lambda_r + rho_r * Cp_r * alpha_L * _flow_velocity),
77 // grout, Eq. 21
78 (1.0 - porosity_g) * lambda_g,
79 }};
80}
81
82std::array<Eigen::Vector3d, BHE_1P::number_of_unknowns>
83BHE_1P::pipeAdvectionVectors(Eigen::Vector3d const& elem_direction) const
84{
85 double const& rho_r = refrigerant.density;
86 double const& Cp_r = refrigerant.specific_heat_capacity;
87 Eigen::Vector3d adv_vector = rho_r * Cp_r * _flow_velocity * elem_direction;
88
89 return {// pipe, Eq. 19
90 adv_vector,
91 // grout, Eq. 21
92 {0, 0, 0}};
93}
94
95double BHE_1P::compute_R_gs(double const chi, double const R_g)
96{
97 return (1 - chi) * R_g;
98}
99
100void BHE_1P::updateHeatTransferCoefficients(double const flow_rate)
101
102{
103 auto const tm_flow_properties = calculateThermoMechanicalFlowPropertiesPipe(
105
106 _flow_velocity = tm_flow_properties.velocity;
108 calcThermalResistances(tm_flow_properties.nusselt_number);
109}
110
111// Nu is the Nusselt number.
112std::array<double, BHE_1P::number_of_unknowns> BHE_1P::calcThermalResistances(
113 double const Nu)
114{
115 constexpr double pi = boost::math::constants::pi<double>();
116
117 double const lambda_r = refrigerant.thermal_conductivity;
118 double const lambda_g = grout.lambda_g;
119 double const lambda_p = _pipe.single_pipe.wall_thermal_conductivity;
120
121 // thermal resistances due to advective flow of refrigerant in the pipe
122 double const R_adv_i1 = 1.0 / (Nu * lambda_r * pi);
123
124 // thermal resistance due to thermal conductivity of the pipe wall material
125 double const R_con_a = std::log(_pipe.single_pipe.outsideDiameter() /
127 (2.0 * pi * lambda_p);
128
129 // thermal resistances of the grout
130 double const D = borehole_geometry.diameter;
131 double const pipe_outside_diameter = _pipe.single_pipe.outsideDiameter();
132
133 double const chi = std::log(std::sqrt(D * D + pipe_outside_diameter *
134 pipe_outside_diameter) /
135 std::sqrt(2) / pipe_outside_diameter) /
136 std::log(D / pipe_outside_diameter);
137 double const R_g =
138 std::log(D / pipe_outside_diameter) / 2 / (pi * lambda_g);
139
140 double const R_con_b = chi * R_g;
141
142 // thermal resistances due to grout-soil exchange
143 double const R_gs = compute_R_gs(chi, R_g);
144
145 // Eq. 29 and 30
146 double const R_fg = R_adv_i1 + R_con_a + R_con_b;
147
148 return {{R_fg, R_gs}};
149}
150
151std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
153 std::size_t const top_node_id,
154 std::size_t const bottom_node_id,
155 int const in_component_id)
156{
157 return {std::make_pair(top_node_id, in_component_id),
158 std::make_pair(bottom_node_id, in_component_id)};
159}
160
161std::optional<
162 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
164 std::size_t const /*bottom_node_id*/,
165 int const /*in_component_id*/,
166 int const /*out_component_id*/)
167{
168 return {};
169}
170
171std::array<double, BHE_1P::number_of_unknowns> BHE_1P::crossSectionAreas() const
172{
173 return {{_pipe.single_pipe.area(),
175}
176
177double BHE_1P::updateFlowRateAndTemperature(double const T_out,
178 double const current_time)
179{
180 auto values =
181 visit([&](auto const& control) { return control(T_out, current_time); },
183 updateHeatTransferCoefficients(values.flow_rate);
184 return values.temperature;
185}
186} // namespace BHE
187} // namespace HeatTransportBHE
188} // namespace ProcessLib
void updateHeatTransferCoefficients(double const flow_rate)
Definition BHE_1P.cpp:100
double _flow_velocity
Flow velocity inside the pipes. Depends on the flow_rate.
Definition BHE_1P.h:135
std::array< double, number_of_unknowns > _thermal_resistances
Definition BHE_1P.h:147
static double compute_R_gs(double const chi, double const R_g)
Definition BHE_1P.cpp:95
std::array< double, number_of_unknowns > calcThermalResistances(double const Nu)
Definition BHE_1P.cpp:112
std::array< double, number_of_unknowns > pipeHeatConductions() const
Definition BHE_1P.cpp:62
static std::optional< std::array< std::pair< std::size_t, int >, 2 > > getBHEBottomDirichletBCNodesAndComponents(std::size_t const, int const, int const)
Definition BHE_1P.cpp:163
PipeConfiguration1PType const _pipe
Definition BHE_1P.h:132
std::array< double, number_of_unknowns > pipeHeatCapacities() const
Definition BHE_1P.cpp:47
BHE_1P(BoreholeGeometry const &borehole, RefrigerantProperties const &refrigerant, GroutParameters const &grout, FlowAndTemperatureControl const &flowAndTemperatureControl, PipeConfiguration1PType const &pipes, bool const use_python_bcs)
Definition BHE_1P.cpp:25
std::array< double, number_of_unknowns > crossSectionAreas() const
Definition BHE_1P.cpp:171
double updateFlowRateAndTemperature(double T_out, double current_time)
Return the inflow temperature for the boundary condition.
Definition BHE_1P.cpp:177
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors(Eigen::Vector3d const &elem_direction) const
Definition BHE_1P.cpp:83
static std::array< std::pair< std::size_t, int >, 2 > getBHEInflowDirichletBCNodesAndComponents(std::size_t const top_node_id, std::size_t const bottom_node_id, int const in_component_id)
Definition BHE_1P.cpp:152
std::variant< TemperatureCurveConstantFlow, TemperatureCurveFlowCurve, FixedPowerConstantFlow, FixedPowerFlowCurve, PowerCurveConstantFlow, PowerCurveFlowCurve, BuildingPowerCurveConstantFlow > FlowAndTemperatureControl
ThermoMechanicalFlowProperties calculateThermoMechanicalFlowPropertiesPipe(Pipe const &pipe, double const length, RefrigerantProperties const &fluid, double const flow_rate)
RefrigerantProperties const refrigerant
Definition BHECommon.h:42
FlowAndTemperatureControl const flowAndTemperatureControl
Definition BHECommon.h:44
double outsideArea() const
Area of the pipe's outside including the wall thickness.
Definition Pipe.h:35
double area() const
Area of the pipe's inside without the wall.
Definition Pipe.h:32