www.mooseframework.org
PorousFlowSingleComponentFluid.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<PorousFlowFluidPropertiesBase>();
19  params.addParam<bool>(
20  "compute_density_and_viscosity", true, "Compute the fluid density and viscosity");
21  params.addParam<bool>("compute_internal_energy", true, "Compute the fluid internal energy");
22  params.addParam<bool>("compute_enthalpy", true, "Compute the fluid enthalpy");
23  params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
24  MooseEnum p_unit_choice("Pa MPa", "Pa");
25  params.addParam<MooseEnum>("pressure_unit",
26  p_unit_choice,
27  "The unit of the pressure variable used everywhere in the input file "
28  "except for in the FluidProperties-module objects");
29  MooseEnum time_unit_choice("seconds hours days years", "seconds");
30  params.addParam<MooseEnum>("time_unit",
31  time_unit_choice,
32  "The unit of time used everywhere in the input file except for in the "
33  "FluidProperties-module objects");
34  params.addClassDescription("This Material calculates fluid properties at the quadpoints or nodes "
35  "for a single component fluid");
36  return params;
37 }
38 
40  : PorousFlowFluidPropertiesBase(parameters),
41  _p_unit(getParam<MooseEnum>("pressure_unit").getEnum<PressureUnitEnum>()),
42  _pressure_to_Pascals(_p_unit == PressureUnitEnum::Pa ? 1.0 : 1.0E6),
43  _time_unit(getParam<MooseEnum>("time_unit").getEnum<TimeUnitEnum>()),
44  _time_to_seconds(_time_unit == TimeUnitEnum::seconds
45  ? 1.0
46  : _time_unit == TimeUnitEnum::hours
47  ? 3600.0
48  : _time_unit == TimeUnitEnum::days ? 3600.0 * 24
49  : 3600 * 24 * 365.25),
50  _compute_rho_mu(getParam<bool>("compute_density_and_viscosity")),
51  _compute_internal_energy(getParam<bool>("compute_internal_energy")),
52  _compute_enthalpy(getParam<bool>("compute_enthalpy")),
53  _density(_compute_rho_mu
54  ? (_nodal_material
55  ? &declareProperty<Real>("PorousFlow_fluid_phase_density_nodal" + _phase)
56  : &declareProperty<Real>("PorousFlow_fluid_phase_density_qp" + _phase))
57  : nullptr),
58  _ddensity_dp(
59  _compute_rho_mu
60  ? (_nodal_material
61  ? &declarePropertyDerivative<Real>(
62  "PorousFlow_fluid_phase_density_nodal" + _phase, _pressure_variable_name)
63  : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_qp" + _phase,
64  _pressure_variable_name))
65  : nullptr),
66  _ddensity_dT(_compute_rho_mu
67  ? (_nodal_material ? &declarePropertyDerivative<Real>(
68  "PorousFlow_fluid_phase_density_nodal" + _phase,
69  _temperature_variable_name)
70  : &declarePropertyDerivative<Real>(
71  "PorousFlow_fluid_phase_density_qp" + _phase,
72  _temperature_variable_name))
73  : nullptr),
74 
75  _viscosity(_compute_rho_mu
76  ? (_nodal_material
77  ? &declareProperty<Real>("PorousFlow_viscosity_nodal" + _phase)
78  : &declareProperty<Real>("PorousFlow_viscosity_qp" + _phase))
79  : nullptr),
80  _dviscosity_dp(_compute_rho_mu
81  ? (_nodal_material
82  ? &declarePropertyDerivative<Real>(
83  "PorousFlow_viscosity_nodal" + _phase, _pressure_variable_name)
84  : &declarePropertyDerivative<Real>("PorousFlow_viscosity_qp" + _phase,
85  _pressure_variable_name))
86  : nullptr),
87  _dviscosity_dT(
88  _compute_rho_mu
89  ? (_nodal_material
90  ? &declarePropertyDerivative<Real>("PorousFlow_viscosity_nodal" + _phase,
91  _temperature_variable_name)
92  : &declarePropertyDerivative<Real>("PorousFlow_viscosity_qp" + _phase,
93  _temperature_variable_name))
94  : nullptr),
95 
96  _internal_energy(
97  _compute_internal_energy
98  ? (_nodal_material
99  ? &declareProperty<Real>("PorousFlow_fluid_phase_internal_energy_nodal" + _phase)
100  : &declareProperty<Real>("PorousFlow_fluid_phase_internal_energy_qp" + _phase))
101  : nullptr),
102  _dinternal_energy_dp(_compute_internal_energy
103  ? (_nodal_material
104  ? &declarePropertyDerivative<Real>(
105  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
106  _pressure_variable_name)
107  : &declarePropertyDerivative<Real>(
108  "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
109  _pressure_variable_name))
110  : nullptr),
111  _dinternal_energy_dT(_compute_internal_energy
112  ? (_nodal_material
113  ? &declarePropertyDerivative<Real>(
114  "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
115  _temperature_variable_name)
116  : &declarePropertyDerivative<Real>(
117  "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
118  _temperature_variable_name))
119  : nullptr),
120 
121  _enthalpy(_compute_enthalpy
122  ? (_nodal_material
123  ? &declareProperty<Real>("PorousFlow_fluid_phase_enthalpy_nodal" + _phase)
124  : &declareProperty<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase))
125  : nullptr),
126  _denthalpy_dp(
127  _compute_enthalpy
128  ? (_nodal_material
129  ? &declarePropertyDerivative<Real>(
130  "PorousFlow_fluid_phase_enthalpy_nodal" + _phase, _pressure_variable_name)
131  : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase,
132  _pressure_variable_name))
133  : nullptr),
134  _denthalpy_dT(_compute_enthalpy
135  ? (_nodal_material ? &declarePropertyDerivative<Real>(
136  "PorousFlow_fluid_phase_enthalpy_nodal" + _phase,
137  _temperature_variable_name)
138  : &declarePropertyDerivative<Real>(
139  "PorousFlow_fluid_phase_enthalpy_qp" + _phase,
140  _temperature_variable_name))
141  : nullptr),
142 
143  _fp(getUserObject<SinglePhaseFluidProperties>("fp"))
144 {
145 }
146 
147 void
149 {
150  if (_compute_rho_mu)
151  (*_density)[_qp] = _fp.rho_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
152  _temperature[_qp] + _t_c2k);
154  (*_internal_energy)[_qp] = _fp.e_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
155  _temperature[_qp] + _t_c2k);
156  if (_compute_enthalpy)
157  (*_enthalpy)[_qp] = _fp.h_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals,
158  _temperature[_qp] + _t_c2k);
159 }
160 
161 void
163 {
164  const Real Tk = _temperature[_qp] + _t_c2k;
165 
166  if (_compute_rho_mu)
167  {
168  // Density and viscosity, and derivatives wrt pressure and temperature
169  Real rho, drho_dp, drho_dT, mu, dmu_dp, dmu_dT;
171  Tk,
172  rho,
173  drho_dp,
174  drho_dT,
175  mu,
176  dmu_dp,
177  dmu_dT);
178  (*_density)[_qp] = rho;
179  (*_ddensity_dp)[_qp] = drho_dp * _pressure_to_Pascals;
180  (*_ddensity_dT)[_qp] = drho_dT;
181  (*_viscosity)[_qp] = mu / _pressure_to_Pascals / _time_to_seconds;
182  (*_dviscosity_dp)[_qp] = dmu_dp / _time_to_seconds;
183  (*_dviscosity_dT)[_qp] = dmu_dT / _pressure_to_Pascals / _time_to_seconds;
184  }
185 
186  // Internal energy and derivatives wrt pressure and temperature at the qps
188  {
189  Real e, de_dp, de_dT;
190  _fp.e_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, Tk, e, de_dp, de_dT);
191  (*_internal_energy)[_qp] = e;
192  (*_dinternal_energy_dp)[_qp] = de_dp * _pressure_to_Pascals;
193  (*_dinternal_energy_dT)[_qp] = de_dT;
194  }
195 
196  // Enthalpy and derivatives wrt pressure and temperature at the qps
197  if (_compute_enthalpy)
198  {
199  Real h, dh_dp, dh_dT;
200  _fp.h_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, Tk, h, dh_dp, dh_dT);
201  (*_enthalpy)[_qp] = h;
202  (*_denthalpy_dp)[_qp] = dh_dp * _pressure_to_Pascals;
203  (*_denthalpy_dT)[_qp] = dh_dT;
204  }
205 }
SinglePhaseFluidProperties::rho_mu_from_p_T
virtual void rho_mu_from_p_T(Real p, Real T, Real &rho, Real &mu) const
Combined methods.
Definition: SinglePhaseFluidProperties.C:256
validParams< PorousFlowFluidPropertiesBase >
InputParameters validParams< PorousFlowFluidPropertiesBase >()
Definition: PorousFlowFluidPropertiesBase.C:14
SinglePhaseFluidProperties
Common class for single phase fluid properties.
Definition: SinglePhaseFluidProperties.h:89
PorousFlowFluidPropertiesBase::_t_c2k
const Real _t_c2k
Conversion from degrees Celsius to degrees Kelvin.
Definition: PorousFlowFluidPropertiesBase.h:39
PorousFlowFluidPropertiesBase::_porepressure
const MaterialProperty< std::vector< Real > > & _porepressure
Pore pressure at the nodes or quadpoints.
Definition: PorousFlowFluidPropertiesBase.h:33
PorousFlowSingleComponentFluid::_time_to_seconds
const Real _time_to_seconds
convert time to seconds by multiplying by this quantity
Definition: PorousFlowSingleComponentFluid.h:44
PorousFlowSingleComponentFluid::_compute_internal_energy
const bool _compute_internal_energy
If true, this Material will compute internal energy and its derivatives.
Definition: PorousFlowSingleComponentFluid.h:50
PorousFlowSingleComponentFluid::PressureUnitEnum
PressureUnitEnum
Unit used for porepressure.
Definition: PorousFlowSingleComponentFluid.h:35
PorousFlowFluidPropertiesBase
Base class for fluid properties materials.
Definition: PorousFlowFluidPropertiesBase.h:24
PorousFlowSingleComponentFluid.h
PorousFlowSingleComponentFluid
General single component fluid material.
Definition: PorousFlowSingleComponentFluid.h:25
PorousFlowSingleComponentFluid::computeQpProperties
virtual void computeQpProperties() override
Definition: PorousFlowSingleComponentFluid.C:162
validParams< PorousFlowSingleComponentFluid >
InputParameters validParams< PorousFlowSingleComponentFluid >()
Definition: PorousFlowSingleComponentFluid.C:16
PorousFlowSingleComponentFluid::initQpStatefulProperties
virtual void initQpStatefulProperties() override
Definition: PorousFlowSingleComponentFluid.C:148
PorousFlowSingleComponentFluid::_compute_enthalpy
const bool _compute_enthalpy
If true, this Material will compute enthalpy and its derivatives.
Definition: PorousFlowSingleComponentFluid.h:53
PorousFlowSingleComponentFluid::_pressure_to_Pascals
const Real _pressure_to_Pascals
convert porepressure to Pascals by multiplying by this quantity
Definition: PorousFlowSingleComponentFluid.h:38
PorousFlowSingleComponentFluid::TimeUnitEnum
TimeUnitEnum
Unit used for time.
Definition: PorousFlowSingleComponentFluid.h:41
PorousFlowSingleComponentFluid::PorousFlowSingleComponentFluid
PorousFlowSingleComponentFluid(const InputParameters &parameters)
Definition: PorousFlowSingleComponentFluid.C:39
PorousFlowSingleComponentFluid::_fp
const SinglePhaseFluidProperties & _fp
Fluid properties UserObject.
Definition: PorousFlowSingleComponentFluid.h:92
PorousFlowFluidPropertiesBase::_temperature
const MaterialProperty< Real > & _temperature
Fluid temperature at the nodes or quadpoints.
Definition: PorousFlowFluidPropertiesBase.h:36
PorousFlowMaterialBase::_phase_num
const unsigned int _phase_num
Phase number of fluid.
Definition: PorousFlowMaterialBase.h:34
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlowSingleComponentFluid)
PorousFlowSingleComponentFluid::_compute_rho_mu
const bool _compute_rho_mu
If true, this Material will compute density and viscosity, and their derivatives.
Definition: PorousFlowSingleComponentFluid.h:47