www.mooseframework.org
PorousFlowSingleComponentFluid.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<PorousFlowFluidPropertiesBase>();
15  params.addParam<bool>(
16  "compute_density_and_viscosity", true, "Compute the fluid density and viscosity");
17  params.addParam<bool>("compute_internal_energy", true, "Compute the fluid internal energy");
18  params.addParam<bool>("compute_enthalpy", true, "Compute the fluid enthalpy");
19  params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
20  params.addClassDescription(
21  "This Material calculates fluid properties at the quadpoints for a single component fluid");
22  return params;
23 }
24 
26  : PorousFlowFluidPropertiesBase(parameters),
27  _compute_rho_mu(getParam<bool>("compute_density_and_viscosity")),
28  _compute_internal_energy(getParam<bool>("compute_internal_energy")),
29  _compute_enthalpy(getParam<bool>("compute_enthalpy")),
30  _density(_compute_rho_mu
31  ? (_nodal_material
32  ? &declareProperty<Real>("PorousFlow_fluid_phase_density_nodal" + _phase)
33  : &declareProperty<Real>("PorousFlow_fluid_phase_density_qp" + _phase))
34  : nullptr),
35  _ddensity_dp(
36  _compute_rho_mu
37  ? (_nodal_material
38  ? &declarePropertyDerivative<Real>(
39  "PorousFlow_fluid_phase_density_nodal" + _phase, _pressure_variable_name)
40  : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_qp" + _phase,
41  _pressure_variable_name))
42  : nullptr),
43  _ddensity_dT(
44  _compute_rho_mu
45  ? (_nodal_material
46  ? &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_nodal" +
47  _phase,
48  _temperature_variable_name)
49  : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_qp" + _phase,
50  _temperature_variable_name))
51  : nullptr),
52 
53  _viscosity(_compute_rho_mu
54  ? (_nodal_material
55  ? &declareProperty<Real>("PorousFlow_viscosity_nodal" + _phase)
56  : &declareProperty<Real>("PorousFlow_viscosity_qp" + _phase))
57  : nullptr),
58  _dviscosity_dp(_compute_rho_mu
59  ? (_nodal_material
60  ? &declarePropertyDerivative<Real>(
61  "PorousFlow_viscosity_nodal" + _phase, _pressure_variable_name)
62  : &declarePropertyDerivative<Real>("PorousFlow_viscosity_qp" + _phase,
63  _pressure_variable_name))
64  : nullptr),
65  _dviscosity_dT(
66  _compute_rho_mu
67  ? (_nodal_material
68  ? &declarePropertyDerivative<Real>("PorousFlow_viscosity_nodal" + _phase,
69  _temperature_variable_name)
70  : &declarePropertyDerivative<Real>("PorousFlow_viscosity_qp" + _phase,
71  _temperature_variable_name))
72  : nullptr),
73 
74  _internal_energy(
75  _compute_internal_energy
76  ? (_nodal_material
77  ? &declareProperty<Real>("PorousFlow_fluid_phase_internal_energy_nodal" + _phase)
78  : &declareProperty<Real>("PorousFlow_fluid_phase_internal_energy_qp" + _phase))
79  : nullptr),
80  _dinternal_energy_dp(_compute_internal_energy
81  ? (_nodal_material
82  ? &declarePropertyDerivative<Real>(
83  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
84  _pressure_variable_name)
85  : &declarePropertyDerivative<Real>(
86  "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
87  _pressure_variable_name))
88  : nullptr),
89  _dinternal_energy_dT(_compute_internal_energy
90  ? (_nodal_material
91  ? &declarePropertyDerivative<Real>(
92  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
93  _temperature_variable_name)
94  : &declarePropertyDerivative<Real>(
95  "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
96  _temperature_variable_name))
97  : nullptr),
98 
99  _enthalpy(_compute_enthalpy
100  ? (_nodal_material
101  ? &declareProperty<Real>("PorousFlow_fluid_phase_enthalpy_nodal" + _phase)
102  : &declareProperty<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase))
103  : nullptr),
104  _denthalpy_dp(
105  _compute_enthalpy
106  ? (_nodal_material
107  ? &declarePropertyDerivative<Real>(
108  "PorousFlow_fluid_phase_enthalpy_nodal" + _phase, _pressure_variable_name)
109  : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase,
110  _pressure_variable_name))
111  : nullptr),
112  _denthalpy_dT(
113  _compute_enthalpy
114  ? (_nodal_material
115  ? &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_nodal" +
116  _phase,
117  _temperature_variable_name)
118  : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase,
119  _temperature_variable_name))
120  : nullptr),
121 
122  _fp(getUserObject<SinglePhaseFluidPropertiesPT>("fp"))
123 {
124 }
125 
126 void
128 {
129  if (_compute_rho_mu)
130  (*_density)[_qp] = _fp.rho(_porepressure[_qp][_phase_num], _temperature[_qp] + _t_c2k);
132  (*_internal_energy)[_qp] = _fp.e(_porepressure[_qp][_phase_num], _temperature[_qp] + _t_c2k);
133  if (_compute_enthalpy)
134  (*_enthalpy)[_qp] = _fp.h(_porepressure[_qp][_phase_num], _temperature[_qp] + _t_c2k);
135 }
136 
137 void
139 {
140  const Real Tk = _temperature[_qp] + _t_c2k;
141 
142  if (_compute_rho_mu)
143  {
144  // Density and derivatives wrt pressure and temperature at the qps
145  Real rho, drho_dp, drho_dT;
146  _fp.rho_dpT(_porepressure[_qp][_phase_num], Tk, rho, drho_dp, drho_dT);
147  (*_density)[_qp] = rho;
148  (*_ddensity_dp)[_qp] = drho_dp;
149  (*_ddensity_dT)[_qp] = drho_dT;
150 
151  // Viscosity and derivatives wrt pressure and temperature at the nodes.
152  // Note that dmu_dp = dmu_drho * drho_dp
153  Real mu, dmu_drho, dmu_dT;
154  _fp.mu_drhoT_from_rho_T(rho, Tk, drho_dT, mu, dmu_drho, dmu_dT);
155  (*_viscosity)[_qp] = mu;
156  (*_dviscosity_dp)[_qp] = dmu_drho * drho_dp;
157  (*_dviscosity_dT)[_qp] = dmu_dT;
158  }
159 
160  // Internal energy and derivatives wrt pressure and temperature at the qps
162  {
163  Real e, de_dp, de_dT;
164  _fp.e_dpT(_porepressure[_qp][_phase_num], Tk, e, de_dp, de_dT);
165  (*_internal_energy)[_qp] = e;
166  (*_dinternal_energy_dp)[_qp] = de_dp;
167  (*_dinternal_energy_dT)[_qp] = de_dT;
168  }
169 
170  // Enthalpy and derivatives wrt pressure and temperature at the qps
171  if (_compute_enthalpy)
172  {
173  Real h, dh_dp, dh_dT;
174  _fp.h_dpT(_porepressure[_qp][_phase_num], Tk, h, dh_dp, dh_dT);
175  (*_enthalpy)[_qp] = h;
176  (*_denthalpy_dp)[_qp] = dh_dp;
177  (*_denthalpy_dT)[_qp] = dh_dT;
178  }
179 }
virtual void e_dpT(Real pressure, Real temperature, Real &e, Real &de_dp, Real &de_dT) const =0
Internal energy and its derivatives wrt pressure and temperature.
virtual void rho_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT) const =0
Density and its derivatives wrt pressure and temperature.
InputParameters validParams< PorousFlowFluidPropertiesBase >()
virtual void h_dpT(Real pressure, Real temperature, Real &h, Real &dh_dp, Real &dh_dT) const =0
Enthalpy and its derivatives wrt pressure and temperature.
const SinglePhaseFluidPropertiesPT & _fp
Fluid properties UserObject.
InputParameters validParams< PorousFlowSingleComponentFluid >()
PorousFlowSingleComponentFluid(const InputParameters &parameters)
Common class for single phase fluid properties using a pressure and temperature formulation.
const unsigned int _phase_num
Phase number of fluid.
const bool _compute_rho_mu
If true, this Material will compute density and viscosity, and their derivatives. ...
virtual void mu_drhoT_from_rho_T(Real density, Real temperature, Real ddensity_dT, Real &mu, Real &dmu_drho, Real &dmu_dT) const =0
Dynamic viscosity and its derivatives wrt density and temperature.
virtual Real e(Real pressure, Real temperature) const =0
Internal energy.
Base class for fluid properties materials.
virtual Real h(Real p, Real T) const =0
Specific enthalpy.
const bool _compute_internal_energy
If true, this Material will compute internal energy and its derivatives.
virtual Real rho(Real pressure, Real temperature) const =0
Density.
const bool _compute_enthalpy
If true, this Material will compute enthalpy and its derivatives.
const MaterialProperty< Real > & _temperature
Fluid temperature at the nodes or quadpoints.
const Real _t_c2k
Conversion from degrees Celsius to degrees Kelvin.
const MaterialProperty< std::vector< Real > > & _porepressure
Pore pressure at the nodes or quadpoints.