https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowSingleComponentFluid.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
12
15
16template <bool is_ad>
19{
21 params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
22 params.addClassDescription("This Material calculates fluid properties at the quadpoints or nodes "
23 "for a single component fluid");
24 return params;
25}
26
27template <bool is_ad>
29 const InputParameters & parameters)
30 : PorousFlowFluidPropertiesBaseTempl<is_ad>(parameters),
31 _fp(this->template getUserObject<SinglePhaseFluidProperties>("fp"))
32{
33}
34
35template <bool is_ad>
36void
38{
39 if (_compute_rho_mu)
40 {
41 (*_density)[_qp] = _fp.rho_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
42 _temperature[_qp] + _t_c2k);
43
44 (*_viscosity)[_qp] = _fp.mu_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
45 _temperature[_qp] + _t_c2k) /
46 _pressure_to_Pascals / _time_to_seconds;
47 }
48
49 if (_compute_internal_energy)
50 (*_internal_energy)[_qp] = _fp.e_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
51 _temperature[_qp] + _t_c2k);
52
53 if (_compute_enthalpy)
54 (*_enthalpy)[_qp] = _fp.h_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
55 _temperature[_qp] + _t_c2k);
56}
57
58template <bool is_ad>
59void
61{
62 if (_compute_rho_mu)
63 {
64 if (is_ad)
65 {
67 _fp.rho_mu_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
68 _temperature[_qp] + _t_c2k,
69 rho,
70 mu);
71
72 (*_density)[_qp] = rho;
73 (*_viscosity)[_qp] = mu / _pressure_to_Pascals / _time_to_seconds;
74 }
75 else
76 {
77 // Density and viscosity, and derivatives wrt pressure and temperature
78 Real rho, drho_dp, drho_dT, mu, dmu_dp, dmu_dT;
79 _fp.rho_mu_from_p_T(MetaPhysicL::raw_value(_porepressure[_qp][_phase_num]) *
80 _pressure_to_Pascals,
81 MetaPhysicL::raw_value(_temperature[_qp]) + _t_c2k,
82 rho,
83 drho_dp,
84 drho_dT,
85 mu,
86 dmu_dp,
87 dmu_dT);
88 (*_density)[_qp] = rho;
89 (*_ddensity_dp)[_qp] = drho_dp * _pressure_to_Pascals;
90 (*_ddensity_dT)[_qp] = drho_dT;
91 (*_viscosity)[_qp] = mu / _pressure_to_Pascals / _time_to_seconds;
92 (*_dviscosity_dp)[_qp] = dmu_dp / _time_to_seconds;
93 (*_dviscosity_dT)[_qp] = dmu_dT / _pressure_to_Pascals / _time_to_seconds;
94 }
95 }
96
97 if (_compute_internal_energy)
98 {
99 if (is_ad)
100 (*_internal_energy)[_qp] = _fp.e_from_p_T(
101 _porepressure[_qp][_phase_num] * _pressure_to_Pascals, _temperature[_qp] + _t_c2k);
102 else
103 {
104 // Internal energy and derivatives wrt pressure and temperature at the qps
105 Real e, de_dp, de_dT;
106 _fp.e_from_p_T(MetaPhysicL::raw_value(_porepressure[_qp][_phase_num]) * _pressure_to_Pascals,
107 MetaPhysicL::raw_value(_temperature[_qp]) + _t_c2k,
108 e,
109 de_dp,
110 de_dT);
111 (*_internal_energy)[_qp] = e;
112 (*_dinternal_energy_dp)[_qp] = de_dp * _pressure_to_Pascals;
113 (*_dinternal_energy_dT)[_qp] = de_dT;
114 }
115 }
116
117 if (_compute_enthalpy)
118 {
119 if (is_ad)
120 (*_enthalpy)[_qp] = _fp.h_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
121 _temperature[_qp] + _t_c2k);
122 else
123 {
124 // Enthalpy and derivatives wrt pressure and temperature at the qps
125 Real h, dh_dp, dh_dT;
126 _fp.h_from_p_T(MetaPhysicL::raw_value(_porepressure[_qp][_phase_num]) * _pressure_to_Pascals,
127 MetaPhysicL::raw_value(_temperature[_qp]) + _t_c2k,
128 h,
129 dh_dp,
130 dh_dT);
131 (*_enthalpy)[_qp] = h;
132 (*_denthalpy_dp)[_qp] = dh_dp * _pressure_to_Pascals;
133 (*_denthalpy_dT)[_qp] = dh_dT;
134 }
135 }
136}
137
const double mu
const double rho
Moose::GenericType< Real, is_ad > GenericReal
registerMooseObject("PorousFlowApp", PorousFlowSingleComponentFluid)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Base class for fluid properties materials.
General single component fluid material.
PorousFlowSingleComponentFluidTempl(const InputParameters &parameters)
Common class for single phase fluid properties.
auto raw_value(const Eigen::Map< T > &in)