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