OGS
BHE_1P.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 "BHE_1P.h"
5
6#include <numbers>
7
9#include "Physics.h"
12
13namespace ProcessLib
14{
16{
17namespace BHE
18{
23 PipeConfiguration1PType const& pipes,
24 bool const use_python_bcs)
27 _pipe(pipes)
28{
29 // Initialize thermal resistances.
30 auto values = visit(
31 [&](auto const& control)
32 {
33 return control(refrigerant.reference_temperature,
34 0. /* initial time */);
35 },
37 updateHeatTransferCoefficients(values.flow_rate);
38}
39
40std::array<double, BHE_1P::number_of_unknowns> BHE_1P::pipeHeatCapacities()
41 const
42{
43 double const rho_r = refrigerant.density;
44 double const specific_heat_capacity = refrigerant.specific_heat_capacity;
45 double const rho_g = grout.rho_g;
46 double const porosity_g = grout.porosity_g;
47 double const heat_cap_g = grout.heat_cap_g;
48
49 return {{
50 /*pipe*/ rho_r * specific_heat_capacity,
51 /*grout*/ (1.0 - porosity_g) * rho_g * heat_cap_g,
52 }};
53}
54
55std::array<double, BHE_1P::number_of_unknowns> BHE_1P::pipeHeatConductions(
56 int const section_index) const
57{
58 double const lambda_r = refrigerant.thermal_conductivity;
59 double const rho_r = refrigerant.density;
60 double const Cp_r = refrigerant.specific_heat_capacity;
61 double const alpha_L = _pipe.longitudinal_dispersion_length;
62 double const porosity_g = grout.porosity_g;
63 double const lambda_g = grout.lambda_g;
64
65 double const velocity_norm =
66 std::abs(getClampedFlowVelocity(section_index));
67
68 // Here we calculate the laplace coefficients in the governing
69 // equations of the BHE.
70 return {{
71 // pipe, Eq. 19
72 (lambda_r + rho_r * Cp_r * alpha_L * velocity_norm),
73 // grout, Eq. 21
74 (1.0 - porosity_g) * lambda_g,
75 }};
76}
77
78std::array<Eigen::Vector3d, BHE_1P::number_of_unknowns>
79BHE_1P::pipeAdvectionVectors(Eigen::Vector3d const& elem_direction,
80 int const section_index) const
81{
82 double const& rho_r = refrigerant.density;
83 double const& Cp_r = refrigerant.specific_heat_capacity;
84
85 double const velocity = getClampedFlowVelocity(section_index);
86 Eigen::Vector3d adv_vector = rho_r * Cp_r * velocity * elem_direction;
87
88 return {// pipe, Eq. 19
89 adv_vector,
90 // grout, Eq. 21
91 {0, 0, 0}};
92}
93
94void BHE_1P::updateHeatTransferCoefficients(double const flow_rate)
95{
97 _pipe.single_pipe, borehole_geometry.length, refrigerant, flow_rate);
98
99 _flow_velocities = {tm_flow.velocity};
100
102 [&](int i)
103 { return calcThermalResistances(tm_flow.nusselt_number, i); });
104}
105
106// Nu is the Nusselt number.
107// section_index is the borehole section index for depth-varying borehole
108// diameter (default: 0).
110 double const Nu, int const section_index) const
111{
112 constexpr double pi = std::numbers::pi;
113
114 double const lambda_r = refrigerant.thermal_conductivity;
115 double const lambda_g = grout.lambda_g;
116 double const lambda_p = _pipe.single_pipe.wall_thermal_conductivity;
117
118 // thermal resistances due to advective flow of refrigerant in the pipe
119 double const R_adv_i1 = 1.0 / (Nu * lambda_r * pi);
120
121 // thermal resistance due to thermal conductivity of the pipe wall material
122 double const pipe_diameter = _pipe.single_pipe.diameter;
123 double const pipe_outside_diameter = _pipe.single_pipe.outsideDiameter();
124 double const R_con_a =
125 std::log(pipe_outside_diameter / pipe_diameter) / (2.0 * pi * lambda_p);
126
127 // thermal resistances of the grout
128 double const D =
129 borehole_geometry.sections.diameterAtSection(section_index);
130
131 double const chi = std::log(std::sqrt(D * D + pipe_outside_diameter *
132 pipe_outside_diameter) /
133 std::sqrt(2) / pipe_outside_diameter) /
134 std::log(D / pipe_outside_diameter);
135 double const R_g =
136 std::log(D / pipe_outside_diameter) / 2 / (pi * lambda_g);
137
138 double const R_con_b = chi * R_g;
139
140 // thermal resistances due to grout-soil exchange
141 double const R_gs = computeRgs(chi, R_g);
142
143 // Eq. 29 and 30
144 double const R_fg = R_adv_i1 + R_con_a + R_con_b;
145
146 return {R_fg, R_gs};
147}
148
149std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
151 std::size_t const top_node_id,
152 std::size_t const bottom_node_id,
153 int const in_component_id)
154{
155 return {std::make_pair(top_node_id, in_component_id),
156 std::make_pair(bottom_node_id, in_component_id)};
157}
158
159std::optional<
160 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
162 std::size_t const /*bottom_node_id*/,
163 int const /*in_component_id*/,
164 int const /*out_component_id*/)
165{
166 return {};
167}
168
169std::array<double, BHE_1P::number_of_unknowns> BHE_1P::crossSectionAreas(
170 int const section_index) const
171{
172 return {{_pipe.single_pipe.area(),
174 borehole_geometry.sections.areaAtSection(section_index),
175 _pipe.single_pipe.outsideArea(), section_index)}};
176}
177
178double BHE_1P::updateFlowRateAndTemperature(double const T_out,
179 double const current_time)
180{
181 auto values =
182 visit([&](auto const& control) { return control(T_out, current_time); },
184 updateHeatTransferCoefficients(values.flow_rate);
185 return values.temperature;
186}
187} // namespace BHE
188} // namespace HeatTransportBHE
189} // namespace ProcessLib
RefrigerantProperties const refrigerant
Definition BHECommon.h:72
void recomputeSectionalResistances(Fn &&calcForSection)
Recompute _sectional_thermal_resistances for all sections.
Definition BHECommon.h:117
BHECommon(BoreholeGeometry const &borehole_geometry_, RefrigerantProperties const &refrigerant_, GroutParameters const &grout_, FlowAndTemperatureControl const &flowAndTemperatureControl_, bool const use_python_bcs_)
Definition BHECommon.h:58
FlowAndTemperatureControl const flowAndTemperatureControl
Definition BHECommon.h:74
double getClampedFlowVelocity(int const section_index) const
Get velocity for a section, clamping to last section if index exceeds the number of velocity entries....
Definition BHECommon.h:133
void updateHeatTransferCoefficients(double const flow_rate)
Definition BHE_1P.cpp:94
std::vector< double > calcThermalResistances(double const Nu, int const section_index=0) const
Definition BHE_1P.cpp:109
std::array< double, number_of_unknowns > crossSectionAreas(int const section_index=0) const
Definition BHE_1P.cpp:169
std::array< double, number_of_unknowns > pipeHeatConductions(int const section_index=0) const
Definition BHE_1P.cpp:55
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:161
PipeConfiguration1PType const _pipe
Definition BHE_1P.h:134
std::array< double, number_of_unknowns > pipeHeatCapacities() const
Definition BHE_1P.cpp:40
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:19
double updateFlowRateAndTemperature(double T_out, double current_time)
Return the inflow temperature for the boundary condition.
Definition BHE_1P.cpp:178
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors(Eigen::Vector3d const &elem_direction, int const section_index=0) const
Definition BHE_1P.cpp:79
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:150
double checkedGroutArea(double const borehole_area_fraction, double const pipe_outside_area, int const section_index)
Definition BHECommon.h:40
std::variant< InflowTemperature, Power, BuildingPower, BuildingPowerHotWaterActiveCooling, BuildingPowerHotWaterPassiveCooling, BuildingPowerHotWater, BuildingPowerActiveCooling, BuildingPowerPassiveCooling, ActiveCooling > FlowAndTemperatureControl
double computeRgs(double const chi, double const R_g)
Grout-soil thermal resistance: R_gs = (1 - chi) * R_g.
ThermoMechanicalFlowProperties calculateThermoMechanicalFlowPropertiesPipe(Pipe const &pipe, double const length, RefrigerantProperties const &fluid, double const flow_rate)