OGS
BHE_1P.h
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#pragma once
5
6#include <Eigen/Core>
7#include <optional>
8
9#include "BHECommon.h"
10#include "BaseLib/Error.h"
13
14namespace ProcessLib
15{
16namespace HeatTransportBHE
17{
18namespace BHE
19{
32class BHE_1P final : public BHECommon
33{
34public:
35 BHE_1P(BoreholeGeometry const& borehole,
39 PipeConfiguration1PType const& pipes,
40 bool const use_python_bcs);
41
42 static constexpr int number_of_unknowns = 2;
43 static constexpr int number_of_grout_zones = 1;
44
45 std::array<double, number_of_unknowns> pipeHeatCapacities() const;
46
47 std::array<double, number_of_unknowns> pipeHeatConductions() const;
48
49 std::array<Eigen::Vector3d, number_of_unknowns> pipeAdvectionVectors(
50 Eigen::Vector3d const& elem_direction) const;
51
52 template <int NPoints,
53 typename SingleUnknownMatrixType,
54 typename RMatrixType,
55 typename RPiSMatrixType,
56 typename RSMatrixType>
57 static void assembleRMatrices(
58 int const idx_bhe_unknowns,
59 Eigen::MatrixBase<SingleUnknownMatrixType> const& matBHE_loc_R,
60 Eigen::MatrixBase<RMatrixType>& R_matrix,
61 Eigen::MatrixBase<RPiSMatrixType>& R_pi_s_matrix,
62 Eigen::MatrixBase<RSMatrixType>& R_s_matrix)
63 {
64 // Here we are looping over two resistance terms
65 // First PHI_fg is the resistance between pipe and grout
66 // Second PHI_gs is the resistance between grout and soil
67 switch (idx_bhe_unknowns)
68 {
69 case 0: // PHI_fg
70 R_matrix.block(0, NPoints, NPoints, NPoints) +=
71 -1.0 * matBHE_loc_R;
72 R_matrix.block(NPoints, 0, NPoints, NPoints) +=
73 -1.0 * matBHE_loc_R;
74
75 R_matrix.block(0, 0, NPoints, NPoints) +=
76 matBHE_loc_R; // K_i/o
77 R_matrix.block(NPoints, NPoints, NPoints, NPoints) +=
78 matBHE_loc_R; // K_fg
79 return;
80 case 1: // PHI_gs
81 R_s_matrix += matBHE_loc_R;
82
83 R_pi_s_matrix.block(NPoints, 0, NPoints, NPoints) +=
84 -1.0 * matBHE_loc_R;
85
86 R_matrix.block(NPoints, NPoints, NPoints, NPoints) +=
87 matBHE_loc_R; // K_fg
88 return;
89 default:
91 "Error!!! In the function BHE_1P::assembleRMatrices, "
92 "the index of bhe resistance term is out of range! ");
93 }
94 }
95
97 double updateFlowRateAndTemperature(double T_out, double current_time);
98
99 double thermalResistance(int const unknown_index) const
100 {
101 return _thermal_resistances[unknown_index];
102 }
103
104 static constexpr std::pair<int, int> inflow_outflow_bc_component_ids[] = {
105 {0, 1}};
106
107 static std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
108 getBHEInflowDirichletBCNodesAndComponents(std::size_t const top_node_id,
109 std::size_t const bottom_node_id,
110 int const in_component_id);
111
112 static std::optional<
113 std::array<std::pair<std::size_t /*node_id*/, int /*component*/>, 2>>
115 std::size_t const /*bottom_node_id*/,
116 int const /*in_component_id*/,
117 int const /*out_component_id*/);
118
119public:
120 std::array<double, number_of_unknowns> crossSectionAreas() const;
121
122 void updateHeatTransferCoefficients(double const flow_rate);
123
124protected:
126
128 double _flow_velocity = std::numeric_limits<double>::quiet_NaN();
129
130private:
131 std::array<double, number_of_unknowns> calcThermalResistances(
132 double const Nu);
133
134 static double compute_R_gs(double const chi, double const R_g);
135
136private:
140 std::array<double, number_of_unknowns> _thermal_resistances;
141};
142} // namespace BHE
143} // namespace HeatTransportBHE
144} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
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
double thermalResistance(int const unknown_index) const
Definition BHE_1P.h:99
PipeConfiguration1PType const _pipe
Definition BHE_1P.h:125
static constexpr std::pair< int, int > inflow_outflow_bc_component_ids[]
Definition BHE_1P.h:104
static constexpr int number_of_unknowns
Definition BHE_1P.h:42
static constexpr int number_of_grout_zones
Definition BHE_1P.h:43
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
static void assembleRMatrices(int const idx_bhe_unknowns, Eigen::MatrixBase< SingleUnknownMatrixType > const &matBHE_loc_R, Eigen::MatrixBase< RMatrixType > &R_matrix, Eigen::MatrixBase< RPiSMatrixType > &R_pi_s_matrix, Eigen::MatrixBase< RSMatrixType > &R_s_matrix)
Definition BHE_1P.h:57
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
RefrigerantProperties const refrigerant
Definition BHECommon.h:36
FlowAndTemperatureControl const flowAndTemperatureControl
Definition BHECommon.h:38