OGS
BHECommonCoaxial.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 "BHECommonCoaxial.h"
5
8
9namespace ProcessLib
10{
11namespace HeatTransportBHE
12{
13namespace BHE
14{
16 BoreholeGeometry const& borehole,
20 PipeConfigurationCoaxial const& pipes,
21 bool const use_python_bcs)
24 _pipes(pipes)
25{
26 cross_section_area_inner_pipe = _pipes.inner_pipe.area();
28 _pipes.outer_pipe.area() - _pipes.inner_pipe.outsideArea();
29}
30
31std::array<double, BHECommonCoaxial::number_of_unknowns>
33{
34 double const rho_r = refrigerant.density;
35 double const specific_heat_capacity = refrigerant.specific_heat_capacity;
36 double const rho_g = grout.rho_g;
37 double const porosity_g = grout.porosity_g;
38 double const heat_cap_g = grout.heat_cap_g;
39
40 return {{/*i*/ rho_r * specific_heat_capacity,
41 /*o*/ rho_r * specific_heat_capacity,
42 /*g*/ (1.0 - porosity_g) * rho_g * heat_cap_g}};
43}
44
46 double const current_time)
47{
48 auto values =
49 visit([&](auto const& control) { return control(T_out, current_time); },
51 updateHeatTransferCoefficients(values.flow_rate);
52 return values.temperature;
53}
54std::array<double, BHECommonCoaxial::number_of_unknowns>
55BHECommonCoaxial::pipeHeatConductions(int /*section_index*/) const
56{
57 // Pipe dimensions are constant; velocity does not vary by section.
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 = _pipes.longitudinal_dispersion_length;
62 double const porosity_g = grout.porosity_g;
63 double const lambda_g = grout.lambda_g;
64
65 auto v = velocities();
66 // Here we calculate the laplace coefficients in the governing
67 // equations of BHE. These governing equations can be found in
68 // 1) Diersch (2013) FEFLOW book on page 952, M.120-122, or
69 // 2) Diersch (2011) Comp & Geosci 37:1122-1135, Eq. 26-28, 23-25
70 return {{// pipe i, Eq. 26 and Eq. 23
71 (lambda_r + rho_r * Cp_r * alpha_L * std::abs(v[0])),
72 // pipe o, Eq. 27 and Eq. 24
73 (lambda_r + rho_r * Cp_r * alpha_L * std::abs(v[1])),
74 // pipe g, Eq. 28 and Eq. 25
75 (1.0 - porosity_g) * lambda_g}};
76}
77
78std::array<Eigen::Vector3d, BHECommonCoaxial::number_of_unknowns>
79BHECommonCoaxial::pipeAdvectionVectors(Eigen::Vector3d const& elem_direction,
80 int /*section_index*/) const
81{
82 // Pipe dimensions are constant; velocity does not vary by section.
83 double const rho_r = refrigerant.density;
84 double const Cp_r = refrigerant.specific_heat_capacity;
85 auto const v = velocities();
86
87 return {// pipe i, Eq. 26 and Eq. 23
88 rho_r * Cp_r * std::abs(v[0]) * elem_direction,
89 // pipe o, Eq. 27 and Eq. 24
90 -rho_r * Cp_r * std::abs(v[1]) * elem_direction,
91 // grout g, Eq. 28 and Eq. 25
92 {0, 0, 0}};
93}
94
96 double const Nu_inner_pipe, double const Nu_annulus_pipe,
97 int const section_index) const
98{
99 // thermal resistances due to advective flow of refrigerant in the pipes
100 auto const R_advective = calculateAdvectiveThermalResistance(
101 _pipes.inner_pipe, _pipes.outer_pipe, refrigerant, Nu_inner_pipe,
102 Nu_annulus_pipe);
103
104 // thermal resistance due to thermal conductivity of the pipe wall material
105 auto const R_conductive = calculatePipeWallThermalResistance(
106 _pipes.inner_pipe, _pipes.outer_pipe);
107
108 // thermal resistance due to the grout transition and grout-soil exchange.
110 _pipes.outer_pipe, grout,
111 borehole_geometry.sections.diameterAtSection(section_index));
112
113 // thermal resistance due to grout-soil exchange
114 double const R_gs = R.grout_soil;
115
116 // Eq. 56 and 57
117 double const R_ff = R_advective.inner_pipe_coaxial + R_advective.a_annulus +
118 R_conductive.inner_pipe_coaxial;
119 double const R_fg =
120 R_advective.b_annulus + R_conductive.annulus + R.conductive_b;
121
122 return getThermalResistances(R_gs, R_ff, R_fg);
123}
124
125std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
127 std::size_t const top_node_id,
128 std::size_t const /*bottom_node_id*/,
129 int const in_component_id)
130{
131 return {std::make_pair(top_node_id, in_component_id),
132 std::make_pair(top_node_id, in_component_id + 1)};
133}
134
135std::optional<
136 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
138 std::size_t const bottom_node_id, int const in_component_id,
139 int const out_component_id)
140{
141 return {{std::make_pair(bottom_node_id, in_component_id),
142 std::make_pair(bottom_node_id, out_component_id)}};
143}
144
146{
147 auto const tm_flow_inner = calculateThermoMechanicalFlowPropertiesPipe(
148 _pipes.inner_pipe, borehole_geometry.length, refrigerant, flow_rate);
149
150 auto const tm_flow_annulus = calculateThermoMechanicalFlowPropertiesAnnulus(
151 _pipes.inner_pipe, _pipes.outer_pipe, borehole_geometry.length,
152 refrigerant, flow_rate);
153
154 assignVelocities(tm_flow_inner.velocity, tm_flow_annulus.velocity);
155
157 [&](int i)
158 {
159 return calcThermalResistances(tm_flow_inner.nusselt_number,
160 tm_flow_annulus.nusselt_number, i);
161 });
162}
163} // namespace BHE
164} // namespace HeatTransportBHE
165} // namespace ProcessLib
std::vector< double > calcThermalResistances(double const Nu_inner_pipe, double const Nu_annulus_pipe, int const section_index=0) const
double updateFlowRateAndTemperature(double T_out, double current_time)
BHECommonCoaxial(BoreholeGeometry const &borehole, RefrigerantProperties const &refrigerant, GroutParameters const &grout, FlowAndTemperatureControl const &flowAndTemperatureControl, PipeConfigurationCoaxial const &pipes, bool const use_python_bcs)
std::array< double, number_of_unknowns > pipeHeatCapacities() const
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors(Eigen::Vector3d const &, int const section_index=0) const
virtual void assignVelocities(double inner_vel, double annulus_vel)=0
std::array< double, number_of_unknowns > pipeHeatConductions(int const section_index=0) const
static std::optional< std::array< std::pair< std::size_t, int >, 2 > > getBHEBottomDirichletBCNodesAndComponents(std::size_t const bottom_node_id, int const in_component_id, int const out_component_id)
static std::array< std::pair< std::size_t, int >, 2 > getBHEInflowDirichletBCNodesAndComponents(std::size_t const top_node_id, std::size_t const, int const in_component_id)
virtual std::vector< double > getThermalResistances(double const &R_gs, double const &R_ff, double const &R_fg) const =0
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
PipeWallThermalResistanceCoaxial calculatePipeWallThermalResistance(Pipe const &inner_pipe, Pipe const &outer_pipe)
ThermoMechanicalFlowProperties calculateThermoMechanicalFlowPropertiesAnnulus(Pipe const &inner_pipe, Pipe const &outer_pipe, double const length, RefrigerantProperties const &fluid, double const flow_rate)
AdvectiveThermalResistanceCoaxial calculateAdvectiveThermalResistance(Pipe const &inner_pipe, Pipe const &outer_pipe, RefrigerantProperties const &fluid, double const Nu_inner_pipe, double const Nu_annulus)
GroutAndGroutSoilExchangeThermalResistanceCoaxial calculateGroutAndGroutSoilExchangeThermalResistance(Pipe const &outer_pipe, GroutParameters const &grout_parameters, double const borehole_diameter)
std::variant< InflowTemperature, Power, BuildingPower, BuildingPowerHotWaterActiveCooling, BuildingPowerHotWaterPassiveCooling, BuildingPowerHotWater, BuildingPowerActiveCooling, BuildingPowerPassiveCooling, ActiveCooling > FlowAndTemperatureControl
ThermoMechanicalFlowProperties calculateThermoMechanicalFlowPropertiesPipe(Pipe const &pipe, double const length, RefrigerantProperties const &fluid, double const flow_rate)