Skip to content

Commit

Permalink
1) move function bodies from .h to .cpp file; 2) add documentation of…
Browse files Browse the repository at this point in the history
… the BHE_1U class; 3) add the default case for the switch.
  • Loading branch information
HBShaoUFZ committed Nov 5, 2018
1 parent e2dd8a4 commit 750b56a
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 68 deletions.
85 changes: 82 additions & 3 deletions ProcessLib/HeatTransportBHE/BHE/BHE_1U.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,87 @@
#include "FlowAndTemperatureControl.h"
#include "Physics.h"

using namespace ProcessLib::HeatTransportBHE::BHE;
namespace ProcessLib
{
namespace HeatTransportBHE
{
namespace BHE
{
BHE_1U::BHE_1U(BoreholeGeometry const& borehole,
RefrigerantProperties const& refrigerant,
GroutParameters const& grout,
FlowAndTemperatureControl const& flowAndTemperatureControl,
PipeConfiguration1U const& pipes)
: BHECommon{borehole, refrigerant, grout, flowAndTemperatureControl},
_pipes(pipes)
{
// Initialize thermal resistances.
auto values = apply_visitor(
[&](auto const& control) {
return control(refrigerant.reference_temperature,
0. /* initial time */);
},
flowAndTemperatureControl);
updateHeatTransferCoefficients(values.flow_rate);
}

std::array<double, BHE_1U::number_of_unknowns> BHE_1U::pipeHeatCapacities()
const
{
double const& rho_r = refrigerant.density;
double const& specific_heat_capacity = refrigerant.specific_heat_capacity;
double const& rho_g = grout.rho_g;
double const& porosity_g = grout.porosity_g;
double const& heat_cap_g = grout.heat_cap_g;

return {{/*i1*/ rho_r * specific_heat_capacity,
/*o1*/ rho_r * specific_heat_capacity,
/*g1*/ (1.0 - porosity_g) * rho_g * heat_cap_g,
/*g2*/ (1.0 - porosity_g) * rho_g * heat_cap_g}};
}

namespace
std::array<double, BHE_1U::number_of_unknowns> BHE_1U::pipeHeatConductions()
const
{
double const& lambda_r = refrigerant.thermal_conductivity;
double const& rho_r = refrigerant.density;
double const& Cp_r = refrigerant.specific_heat_capacity;
double const& alpha_L = _pipes.longitudinal_despersion_length;
double const& porosity_g = grout.porosity_g;
double const& lambda_g = grout.lambda_g;

double const velocity_norm = std::abs(_flow_velocity) * std::sqrt(2);

// Here we calculate the laplace coefficients in the governing
// equations of BHE. These governing equations can be found in
// 1) Diersch (2013) FEFLOW book on page 952, M.120-122, or
// 2) Diersch (2011) Comp & Geosci 37:1122-1135, Eq. 19-22.
return {{// pipe i1, Eq. 19
(lambda_r + rho_r * Cp_r * alpha_L * velocity_norm),
// pipe o1, Eq. 20
(lambda_r + rho_r * Cp_r * alpha_L * velocity_norm),
// pipe g1, Eq. 21
(1.0 - porosity_g) * lambda_g,
// pipe g2, Eq. 22
(1.0 - porosity_g) * lambda_g}};
}

std::array<Eigen::Vector3d, BHE_1U::number_of_unknowns>
BHE_1U::pipeAdvectionVectors() const
{
double const& rho_r = refrigerant.density;
double const& Cp_r = refrigerant.specific_heat_capacity;

return {{// pipe i1, Eq. 19
{0, 0, -rho_r * Cp_r * _flow_velocity},
// pipe o1, Eq. 20
{0, 0, rho_r * Cp_r * _flow_velocity},
// grout g1, Eq. 21
{0, 0, 0},
// grout g2, Eq. 22
{0, 0, 0}}};
}

double compute_R_gs(double const chi, double const R_g)
{
return (1 - chi) * R_g;
Expand Down Expand Up @@ -84,7 +161,6 @@ std::pair<double, double> thermalResistancesGroutSoil(double chi,
}
return {R_gg, R_gs};
}
} // namespace

constexpr std::pair<int, int> BHE_1U::inflow_outflow_bc_component_ids[];

Expand Down Expand Up @@ -176,3 +252,6 @@ double BHE_1U::getTinByTout(double const T_out, double const current_time)
updateHeatTransferCoefficients(values.flow_rate);
return values.temperature;
}
} // namespace BHE
} // namespace HeatTransportBHE
} // namespace ProcessLib
88 changes: 23 additions & 65 deletions ProcessLib/HeatTransportBHE/BHE/BHE_1U.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,83 +23,36 @@ namespace HeatTransportBHE
{
namespace BHE
{
/**
* The BHE_1U class is the realization of 1U type of Borehole Heate Exchanger.
* In this class, the pipe heat capacity, pipe heat conductiion, pie advection
* vectors are intialized according to the geometry of 1U type of BHE.
* For 1U type of BHE, 4 primary unknowns are assigned on the 1D BHE elements.
* They are the temperature in inflow pipe T_in, temperature in outflow pipe
* T_out temperature of the two grout zones sorrounding the inflow and outflow
* pipe T_g1 and T_g2. These primary varaibles are solved according to heat
* convection and conduction equations on the pipes and also in the grout zones.
* The interaction of the 1U type of BHE and the sorrounding soil is regulated
* through the thermal resistance values, which are calculated specifically
* during the initialization of the class.
*/
class BHE_1U final : public BHECommon
{
public:
BHE_1U(BoreholeGeometry const& borehole,
RefrigerantProperties const& refrigerant,
GroutParameters const& grout,
FlowAndTemperatureControl const& flowAndTemperatureControl,
PipeConfiguration1U const& pipes)
: BHECommon{borehole, refrigerant, grout, flowAndTemperatureControl},
_pipes(pipes)
{
// Initialize thermal resistances.
auto values = apply_visitor(
[&](auto const& control) {
return control(refrigerant.reference_temperature,
0. /* initial time */);
},
flowAndTemperatureControl);
updateHeatTransferCoefficients(values.flow_rate);
}
PipeConfiguration1U const& pipes);

static constexpr int number_of_unknowns = 4;

std::array<double, number_of_unknowns> pipeHeatCapacities() const
{
double const& rho_r = refrigerant.density;
double const& specific_heat_capacity =
refrigerant.specific_heat_capacity;
double const& rho_g = grout.rho_g;
double const& porosity_g = grout.porosity_g;
double const& heat_cap_g = grout.heat_cap_g;

return {{/*i1*/ rho_r * specific_heat_capacity,
/*o1*/ rho_r * specific_heat_capacity,
/*g1*/ (1.0 - porosity_g) * rho_g * heat_cap_g,
/*g2*/ (1.0 - porosity_g) * rho_g * heat_cap_g}};
}
std::array<double, number_of_unknowns> pipeHeatCapacities() const;

std::array<double, number_of_unknowns> pipeHeatConductions() const
{
double const& lambda_r = refrigerant.thermal_conductivity;
double const& rho_r = refrigerant.density;
double const& Cp_r = refrigerant.specific_heat_capacity;
double const& alpha_L = _pipes.longitudinal_despersion_length;
double const& porosity_g = grout.porosity_g;
double const& lambda_g = grout.lambda_g;

double const velocity_norm = std::abs(_flow_velocity) * std::sqrt(2);

// Here we calculate the laplace coefficients in the governing
// equations of BHE. These governing equations can be found in
// 1) Diersch (2013) FEFLOW book on page 952, M.120-122, or
// 2) Diersch (2011) Comp & Geosci 37:1122-1135, Eq. 19-22.
return {{// pipe i1, Eq. 19
(lambda_r + rho_r * Cp_r * alpha_L * velocity_norm),
// pipe o1, Eq. 20
(lambda_r + rho_r * Cp_r * alpha_L * velocity_norm),
// pipe g1, Eq. 21
(1.0 - porosity_g) * lambda_g,
// pipe g2, Eq. 22
(1.0 - porosity_g) * lambda_g}};
}
std::array<double, number_of_unknowns> pipeHeatConductions() const;

std::array<Eigen::Vector3d, number_of_unknowns> pipeAdvectionVectors() const
{
double const& rho_r = refrigerant.density;
double const& Cp_r = refrigerant.specific_heat_capacity;

return {{// pipe i1, Eq. 19
{0, 0, -rho_r * Cp_r * _flow_velocity},
// pipe o1, Eq. 20
{0, 0, rho_r * Cp_r * _flow_velocity},
// grout g1, Eq. 21
{0, 0, 0},
// grout g2, Eq. 22
{0, 0, 0}}};
}
std::array<Eigen::Vector3d, number_of_unknowns> pipeAdvectionVectors()
const;

template <int NPoints,
typename SingleUnknownMatrixType,
Expand Down Expand Up @@ -163,6 +116,11 @@ class BHE_1U final : public BHECommon
R_matrix.block(3 * NPoints, 3 * NPoints, NPoints, NPoints) +=
1.0 * matBHE_loc_R; // K_og
break;
default:
OGS_FATAL(
"Error!!! In the function BHE_1U::assembleRMatrices, "
"the index of bhe unknowns is out of range! ");
break;
}
}

Expand Down

0 comments on commit 750b56a

Please sign in to comment.