OGS 6.2.0-97-g4a610c866
BHE_1U.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <Eigen/Eigen>
13 
14 #include "BaseLib/Error.h"
15 
16 #include "BHECommon.h"
18 #include "PipeConfiguration1U.h"
19 
20 namespace ProcessLib
21 {
22 namespace HeatTransportBHE
23 {
24 namespace BHE
25 {
39 class BHE_1U final : public BHECommon
40 {
41 public:
42  BHE_1U(BoreholeGeometry const& borehole,
44  GroutParameters const& grout,
46  PipeConfiguration1U const& pipes);
47 
48  static constexpr int number_of_unknowns = 4;
49  static constexpr int number_of_grout_zones = 2;
50 
51  std::array<double, number_of_unknowns> pipeHeatCapacities() const;
52 
53  std::array<double, number_of_unknowns> pipeHeatConductions() const;
54 
55  std::array<Eigen::Vector3d, number_of_unknowns> pipeAdvectionVectors()
56  const;
57 
58  template <int NPoints,
59  typename SingleUnknownMatrixType,
60  typename RMatrixType,
61  typename RPiSMatrixType,
62  typename RSMatrixType>
64  int const idx_bhe_unknowns,
65  Eigen::MatrixBase<SingleUnknownMatrixType> const& matBHE_loc_R,
66  Eigen::MatrixBase<RMatrixType>& R_matrix,
67  Eigen::MatrixBase<RPiSMatrixType>& R_pi_s_matrix,
68  Eigen::MatrixBase<RSMatrixType>& R_s_matrix) const
69  {
70  switch (idx_bhe_unknowns)
71  {
72  case 0: // PHI_fig
73  R_matrix.block(0, 2 * NPoints, NPoints, NPoints) +=
74  -1.0 * matBHE_loc_R;
75  R_matrix.block(2 * NPoints, 0, NPoints, NPoints) +=
76  -1.0 * matBHE_loc_R;
77 
78  R_matrix.block(0, 0, NPoints, NPoints) +=
79  1.0 * matBHE_loc_R; // K_i1
80  R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
81  1.0 * matBHE_loc_R; // K_ig
82  return;
83  case 1: // PHI_fog
84  R_matrix.block(NPoints, 3 * NPoints, NPoints, NPoints) +=
85  -1.0 * matBHE_loc_R;
86  R_matrix.block(3 * NPoints, NPoints, NPoints, NPoints) +=
87  -1.0 * matBHE_loc_R;
88 
89  R_matrix.block(NPoints, NPoints, NPoints, NPoints) +=
90  1.0 * matBHE_loc_R; // K_o1
91  R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
92  1.0 * matBHE_loc_R; // K_og
93  return;
94  case 2: // PHI_gg
95  R_matrix.block(2 * NPoints, 3 * NPoints, NPoints, NPoints) +=
96  -1.0 * matBHE_loc_R;
97  R_matrix.block(3 * NPoints, 2 * NPoints, NPoints, NPoints) +=
98  -1.0 * matBHE_loc_R;
99 
100  R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
101  1.0 * matBHE_loc_R; // K_ig // notice we only have
102  // 1 PHI_gg term here.
103  R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
104  1.0 * matBHE_loc_R; // K_og // see Diersch 2013 FEFLOW
105  // book page 954 Table M.2
106  return;
107  case 3: // PHI_gs
108  R_s_matrix.template block<NPoints, NPoints>(0, 0).noalias() +=
109  1.0 * matBHE_loc_R;
110 
111  R_pi_s_matrix.block(2 * NPoints, 0, NPoints, NPoints) +=
112  -1.0 * matBHE_loc_R;
113  R_pi_s_matrix.block(3 * NPoints, 0, NPoints, NPoints) +=
114  -1.0 * matBHE_loc_R;
115  R_matrix.block(2 * NPoints, 2 * NPoints, NPoints, NPoints) +=
116  1.0 * matBHE_loc_R; // K_ig
117  R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
118  1.0 * matBHE_loc_R; // K_og
119  return;
120  default:
121  OGS_FATAL(
122  "Error!!! In the function BHE_1U::assembleRMatrices, "
123  "the index of bhe unknowns is out of range! ");
124  }
125  }
126 
128  double updateFlowRateAndTemperature(double T_out, double current_time);
129 
130  double thermalResistance(int const unknown_index) const
131  {
132  return _thermal_resistances[unknown_index];
133  }
134 
135  static constexpr std::pair<int, int> inflow_outflow_bc_component_ids[] = {
136  {0, 1}};
137 
138 private:
139  // Placing it here before using it in the cross_section_areas.
141 
142 public:
143  std::array<double, number_of_unknowns> crossSectionAreas() const
144  {
145  return {{_pipes.inlet.area(), _pipes.outlet.area(),
146  borehole_geometry.area() / 2 - _pipes.inlet.area(),
147  borehole_geometry.area() / 2 - _pipes.outlet.area()}};
148  }
149 
150 private:
151  void updateHeatTransferCoefficients(double const flow_rate);
152 
153  std::array<double, number_of_unknowns> calcThermalResistances(
154  double const Nu);
155 
156 private:
163  std::array<double, number_of_unknowns> _thermal_resistances;
164 
167 };
168 } // namespace BHE
169 } // namespace HeatTransportBHE
170 } // namespace ProcessLib
BHE_1U(BoreholeGeometry const &borehole, RefrigerantProperties const &refrigerant, GroutParameters const &grout, FlowAndTemperatureControl const &flowAndTemperatureControl, PipeConfiguration1U const &pipes)
Definition: BHE_1U.cpp:25
std::array< double, number_of_unknowns > crossSectionAreas() const
Definition: BHE_1U.h:143
PipeConfiguration1U const _pipes
Definition: BHE_1U.h:140
std::array< double, number_of_unknowns > pipeHeatConductions() const
Definition: BHE_1U.cpp:58
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) const
Definition: BHE_1U.h:63
std::array< double, number_of_unknowns > calcThermalResistances(double const Nu)
Nu is the Nusselt number.
Definition: BHE_1U.cpp:182
double updateFlowRateAndTemperature(double T_out, double current_time)
Return the inflow temperature for the boundary condition.
Definition: BHE_1U.cpp:242
BoreholeGeometry const borehole_geometry
Definition: BHECommon.h:41
static constexpr std::pair< int, int > inflow_outflow_bc_component_ids[]
Definition: BHE_1U.h:135
static constexpr int number_of_unknowns
Definition: BHE_1U.h:48
void updateHeatTransferCoefficients(double const flow_rate)
Definition: BHE_1U.cpp:170
static constexpr int number_of_grout_zones
Definition: BHE_1U.h:49
boost::variant< TemperatureCurveConstantFlow, FixedPowerConstantFlow, FixedPowerFlowCurve, PowerCurveConstantFlow > FlowAndTemperatureControl
double thermalResistance(int const unknown_index) const
Definition: BHE_1U.h:130
FlowAndTemperatureControl const flowAndTemperatureControl
Definition: BHECommon.h:44
std::array< double, number_of_unknowns > _thermal_resistances
Definition: BHE_1U.h:163
std::array< double, number_of_unknowns > pipeHeatCapacities() const
Definition: BHE_1U.cpp:43
std::array< Eigen::Vector3d, number_of_unknowns > pipeAdvectionVectors() const
Definition: BHE_1U.cpp:85
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
double _flow_velocity
Flow velocity inside the pipes. Depends on the flow_rate.
Definition: BHE_1U.h:166
RefrigerantProperties const refrigerant
Definition: BHECommon.h:42
double area() const
Area of the pipe&#39;s inside without the wall.
Definition: Pipe.h:33