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"
11
12namespace ProcessLib
13{
15{
16namespace BHE
17{
22 PipeConfiguration1PType const& pipes,
23 bool const use_python_bcs)
26 _pipe(pipes)
27{
28 _thermal_resistances.fill(std::numeric_limits<double>::quiet_NaN());
29
30 // Initialize thermal resistances.
31 auto values = visit(
32 [&](auto const& control) {
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 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 // Here we calculate the laplace coefficients in the governing
66 // equations of the BHE.
67 return {{
68 // pipe, Eq. 19
69 (lambda_r + rho_r * Cp_r * alpha_L * _flow_velocity),
70 // grout, Eq. 21
71 (1.0 - porosity_g) * lambda_g,
72 }};
73}
74
75std::array<Eigen::Vector3d, BHE_1P::number_of_unknowns>
76BHE_1P::pipeAdvectionVectors(Eigen::Vector3d const& elem_direction) const
77{
78 double const& rho_r = refrigerant.density;
79 double const& Cp_r = refrigerant.specific_heat_capacity;
80 Eigen::Vector3d adv_vector = rho_r * Cp_r * _flow_velocity * elem_direction;
81
82 return {// pipe, Eq. 19
83 adv_vector,
84 // grout, Eq. 21
85 {0, 0, 0}};
86}
87
88double BHE_1P::compute_R_gs(double const chi, double const R_g)
89{
90 return (1 - chi) * R_g;
91}
92
93void BHE_1P::updateHeatTransferCoefficients(double const flow_rate)
94
95{
96 auto const tm_flow_properties = calculateThermoMechanicalFlowPropertiesPipe(
97 _pipe.single_pipe, borehole_geometry.length, refrigerant, flow_rate);
98
99 _flow_velocity = tm_flow_properties.velocity;
101 calcThermalResistances(tm_flow_properties.nusselt_number);
102}
103
104// Nu is the Nusselt number.
105std::array<double, BHE_1P::number_of_unknowns> BHE_1P::calcThermalResistances(
106 double const Nu)
107{
108 constexpr double pi = std::numbers::pi;
109
110 double const lambda_r = refrigerant.thermal_conductivity;
111 double const lambda_g = grout.lambda_g;
112 double const lambda_p = _pipe.single_pipe.wall_thermal_conductivity;
113
114 // thermal resistances due to advective flow of refrigerant in the pipe
115 double const R_adv_i1 = 1.0 / (Nu * lambda_r * pi);
116
117 // thermal resistance due to thermal conductivity of the pipe wall material
118 double const R_con_a = std::log(_pipe.single_pipe.outsideDiameter() /
119 _pipe.single_pipe.diameter) /
120 (2.0 * pi * lambda_p);
121
122 // thermal resistances of the grout
123 double const D = borehole_geometry.diameter;
124 double const pipe_outside_diameter = _pipe.single_pipe.outsideDiameter();
125
126 double const chi = std::log(std::sqrt(D * D + pipe_outside_diameter *
127 pipe_outside_diameter) /
128 std::sqrt(2) / pipe_outside_diameter) /
129 std::log(D / pipe_outside_diameter);
130 double const R_g =
131 std::log(D / pipe_outside_diameter) / 2 / (pi * lambda_g);
132
133 double const R_con_b = chi * R_g;
134
135 // thermal resistances due to grout-soil exchange
136 double const R_gs = compute_R_gs(chi, R_g);
137
138 // Eq. 29 and 30
139 double const R_fg = R_adv_i1 + R_con_a + R_con_b;
140
141 return {{R_fg, R_gs}};
142}
143
144std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
146 std::size_t const top_node_id,
147 std::size_t const bottom_node_id,
148 int const in_component_id)
149{
150 return {std::make_pair(top_node_id, in_component_id),
151 std::make_pair(bottom_node_id, in_component_id)};
152}
153
154std::optional<
155 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
157 std::size_t const /*bottom_node_id*/,
158 int const /*in_component_id*/,
159 int const /*out_component_id*/)
160{
161 return {};
162}
163
164std::array<double, BHE_1P::number_of_unknowns> BHE_1P::crossSectionAreas() const
165{
166 return {{_pipe.single_pipe.area(),
167 borehole_geometry.area() - _pipe.single_pipe.outsideArea()}};
168}
169
170double BHE_1P::updateFlowRateAndTemperature(double const T_out,
171 double const current_time)
172{
173 auto values =
174 visit([&](auto const& control) { return control(T_out, current_time); },
176 updateHeatTransferCoefficients(values.flow_rate);
177 return values.temperature;
178}
179} // namespace BHE
180} // namespace HeatTransportBHE
181} // namespace ProcessLib
void updateHeatTransferCoefficients(double const flow_rate)
Definition BHE_1P.cpp:93
double _flow_velocity
Flow velocity inside the pipes. Depends on the flow_rate.
Definition BHE_1P.h:128
std::array< double, number_of_unknowns > _thermal_resistances
Definition BHE_1P.h:140
static double compute_R_gs(double const chi, double const R_g)
Definition BHE_1P.cpp:88
std::array< double, number_of_unknowns > calcThermalResistances(double const Nu)
Definition BHE_1P.cpp:105
std::array< double, number_of_unknowns > pipeHeatConductions() 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:156
PipeConfiguration1PType const _pipe
Definition BHE_1P.h:125
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:18
std::array< double, number_of_unknowns > crossSectionAreas() const
Definition BHE_1P.cpp:164
double updateFlowRateAndTemperature(double T_out, double current_time)
Return the inflow temperature for the boundary condition.
Definition BHE_1P.cpp:170
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors(Eigen::Vector3d const &elem_direction) const
Definition BHE_1P.cpp:76
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:145
std::variant< TemperatureCurveConstantFlow, TemperatureCurveFlowCurve, FixedPowerConstantFlow, FixedPowerFlowCurve, PowerCurveConstantFlow, PowerCurveFlowCurve, BuildingPowerCurveConstantFlow, BuildingPowerCurveHotWaterCurveActiveCoolingCurveFlowCurve, BuildingPowerCurveHotWaterCurvePassiveCoolingCurveFlowCurve, BuildingPowerCurveHotWaterCurveFlowCurve, BuildingPowerCurveActiveCoolingCurveFlowCurve, BuildingPowerCurvePassiveCoolingCurveFlowCurve, BuildingPowerCurveFlowCurve, ActiveCoolingCurveFlowCurve > FlowAndTemperatureControl
ThermoMechanicalFlowProperties calculateThermoMechanicalFlowPropertiesPipe(Pipe const &pipe, double const length, RefrigerantProperties const &fluid, double const flow_rate)
RefrigerantProperties const refrigerant
Definition BHECommon.h:36
FlowAndTemperatureControl const flowAndTemperatureControl
Definition BHECommon.h:38