22 "Variable that is the porepressure of the liquid phase");
24 params.
addRequiredParam<UserObjectName>(
"fluid_state",
"Name of the FluidState UserObject");
26 "Class for single component multiphase fluid state calculations using pressure and enthalpy");
34 _liquid_porepressure(_nodal_material
35 ? this->template coupledGenericDofValue<is_ad>(
"porepressure")
36 : this->template coupledGenericValue<is_ad>(
"porepressure")),
37 _liquid_gradp_qp(this->template coupledGenericGradient<is_ad>(
"porepressure")),
38 _liquid_porepressure_varnum(coupled(
"porepressure")),
39 _pvar(_dictator.isPorousFlowVariable(_liquid_porepressure_varnum)
40 ? _dictator.porousFlowVariableNum(_liquid_porepressure_varnum)
42 _enthalpy(_nodal_material ? this->template coupledGenericDofValue<is_ad>(
"enthalpy")
43 : this->template coupledGenericValue<is_ad>(
"enthalpy")),
44 _gradh_qp(this->template coupledGenericGradient<is_ad>(
"enthalpy")),
45 _enthalpy_varnum(coupled(
"enthalpy")),
46 _hvar(_dictator.isPorousFlowVariable(_enthalpy_varnum)
47 ? _dictator.porousFlowVariableNum(_enthalpy_varnum)
50 _aqueous_phase_number(_fs.aqueousPhaseIndex()),
51 _gas_phase_number(_fs.gasPhaseIndex()),
53 this->template declareGenericProperty<
Real, is_ad>(
"PorousFlow_temperature" + _sfx)),
54 _grad_temperature_qp(_nodal_material
56 : &this->template declareGenericProperty<
RealGradient, is_ad>(
57 "PorousFlow_grad_temperature_qp")),
58 _dtemperature_dvar(is_ad ? nullptr
59 : &this->template declareProperty<
std::vector<
Real>>(
60 "dPorousFlow_temperature" + _sfx +
"_dvar")),
61 _dgrad_temperature_dgradv(is_ad || _nodal_material
63 : &this->template declareProperty<
std::vector<
Real>>(
64 "dPorousFlow_grad_temperature_qp_dgradvar")),
65 _dgrad_temperature_dv(is_ad ? nullptr
69 "dPorousFlow_grad_temperature_qp_dvar")),
70 _pidx(_fs.getPressureIndex()),
71 _hidx(_fs.getEnthalpyIndex())
78 " phases are allowed. Please check the number of phases entered in the dictator is " 86 _fs.clearFluidStateProperties(_fsp);
87 _fs.thermophysicalProperties(_liquid_porepressure[_qp], _enthalpy[_qp], _qp, _fsp);
103 _temperature[_qp] = genericValue(_fsp[_aqueous_phase_number].
temperature) - _T_c2k;
107 template <
bool is_ad>
115 _temperature[_qp] = genericValue(_fsp[_aqueous_phase_number].
temperature) - _T_c2k;
119 (*_dtemperature_dvar)[_qp][_pvar] =
120 _fsp[_aqueous_phase_number].temperature.derivatives()[_pidx];
121 (*_dtemperature_dvar)[_qp][_hvar] =
122 _fsp[_aqueous_phase_number].temperature.derivatives()[_hidx];
127 for (
unsigned int ph = 0; ph < _num_phases; ++ph)
129 (*_dporepressure_dvar)[_qp][ph][_pvar] = _fsp[ph].pressure.derivatives()[_pidx];
130 (*_dporepressure_dvar)[_qp][ph][_hvar] = _fsp[ph].pressure.derivatives()[_hidx];
132 (*_dsaturation_dvar)[_qp][ph][_pvar] = _fsp[ph].saturation.derivatives()[_pidx];
133 (*_dsaturation_dvar)[_qp][ph][_hvar] = _fsp[ph].saturation.derivatives()[_hidx];
135 (*_dfluid_density_dvar)[_qp][ph][_pvar] = _fsp[ph].density.derivatives()[_pidx];
136 (*_dfluid_density_dvar)[_qp][ph][_hvar] = _fsp[ph].density.derivatives()[_hidx];
138 (*_dfluid_viscosity_dvar)[_qp][ph][_pvar] = _fsp[ph].viscosity.derivatives()[_pidx];
139 (*_dfluid_viscosity_dvar)[_qp][ph][_hvar] = _fsp[ph].viscosity.derivatives()[_hidx];
141 (*_dfluid_enthalpy_dvar)[_qp][ph][_pvar] = _fsp[ph].enthalpy.derivatives()[_pidx];
142 (*_dfluid_enthalpy_dvar)[_qp][ph][_hvar] = _fsp[ph].enthalpy.derivatives()[_hidx];
144 (*_dfluid_internal_energy_dvar)[_qp][ph][_pvar] =
145 _fsp[ph].internal_energy.derivatives()[_pidx];
146 (*_dfluid_internal_energy_dvar)[_qp][ph][_hvar] =
147 _fsp[ph].internal_energy.derivatives()[_hidx];
154 if (!_nodal_material)
155 if constexpr (!is_ad)
159 const Real dp = 1.0e-5 * _liquid_porepressure[_qp];
160 const Real dh = 1.0e-5 * _enthalpy[_qp];
163 _fs.thermophysicalProperties(_liquid_porepressure[_qp] + dp, _enthalpy[_qp], _qp, fsp_dp);
166 _fs.thermophysicalProperties(_liquid_porepressure[_qp], _enthalpy[_qp] + dh, _qp, fsp_dh);
169 (*_grad_temperature_qp)[_qp] = (*_dtemperature_dvar)[_qp][_pvar] * _liquid_gradp_qp[_qp] +
170 (*_dtemperature_dvar)[_qp][_hvar] * _gradh_qp[_qp];
171 (*_dgrad_temperature_dgradv)[_qp][_pvar] = (*_dtemperature_dvar)[_qp][_pvar];
172 (*_dgrad_temperature_dgradv)[_qp][_hvar] = (*_dtemperature_dvar)[_qp][_hvar];
174 const auto d2T_dp2 = (fsp_dp[_aqueous_phase_number].temperature.derivatives()[_pidx] -
175 _fsp[_aqueous_phase_number].temperature.derivatives()[_pidx]) /
178 const auto d2T_dh2 = (fsp_dh[_aqueous_phase_number].temperature.derivatives()[_hidx] -
179 _fsp[_aqueous_phase_number].temperature.derivatives()[_hidx]) /
182 const auto d2T_dph = (fsp_dp[_aqueous_phase_number].temperature.derivatives()[_hidx] -
183 _fsp[_aqueous_phase_number].temperature.derivatives()[_hidx]) /
185 (fsp_dh[_aqueous_phase_number].
temperature.derivatives()[_pidx] -
186 _fsp[_aqueous_phase_number].temperature.derivatives()[_pidx]) /
189 (*_dgrad_temperature_dv)[_qp][_pvar] =
190 d2T_dp2 * _liquid_gradp_qp[_qp] + d2T_dph * _gradh_qp[_qp];
191 (*_dgrad_temperature_dv)[_qp][_hvar] =
192 d2T_dph * _liquid_gradp_qp[_qp] + d2T_dh2 * _gradh_qp[_qp];
195 (*_grads_qp)[_qp][_gas_phase_number] =
196 (*_dsaturation_dvar)[_qp][_gas_phase_number][_pvar] * _liquid_gradp_qp[_qp] +
197 (*_dsaturation_dvar)[_qp][_gas_phase_number][_hvar] * _gradh_qp[_qp];
198 (*_grads_qp)[_qp][_aqueous_phase_number] = -(*_grads_qp)[_qp][_gas_phase_number];
200 (*_dgrads_qp_dgradv)[_qp][_gas_phase_number][_pvar] =
201 (*_dsaturation_dvar)[_qp][_gas_phase_number][_pvar];
202 (*_dgrads_qp_dgradv)[_qp][_aqueous_phase_number][_pvar] =
203 -(*_dgrads_qp_dgradv)[_qp][_gas_phase_number][_pvar];
205 (*_dgrads_qp_dgradv)[_qp][_gas_phase_number][_hvar] =
206 (*_dsaturation_dvar)[_qp][_gas_phase_number][_hvar];
207 (*_dgrads_qp_dgradv)[_qp][_aqueous_phase_number][_hvar] =
208 -(*_dgrads_qp_dgradv)[_qp][_gas_phase_number][_hvar];
210 const Real d2s_dp2 = (fsp_dp[_gas_phase_number].saturation.derivatives()[_pidx] -
211 _fsp[_gas_phase_number].saturation.derivatives()[_pidx]) /
214 const Real d2s_dh2 = (fsp_dh[_gas_phase_number].saturation.derivatives()[_hidx] -
215 _fsp[_gas_phase_number].saturation.derivatives()[_hidx]) /
218 const Real d2s_dph = (fsp_dp[_gas_phase_number].saturation.derivatives()[_hidx] -
219 _fsp[_gas_phase_number].saturation.derivatives()[_hidx]) /
221 (fsp_dh[_gas_phase_number].saturation.derivatives()[_pidx] -
222 _fsp[_gas_phase_number].saturation.derivatives()[_pidx]) /
225 (*_dgrads_qp_dv)[_qp][_gas_phase_number][_pvar] =
226 d2s_dp2 * _liquid_gradp_qp[_qp] + d2s_dph * _gradh_qp[_qp];
227 (*_dgrads_qp_dv)[_qp][_aqueous_phase_number][_pvar] =
228 -(*_dgrads_qp_dv)[_qp][_gas_phase_number][_pvar];
230 (*_dgrads_qp_dv)[_qp][_gas_phase_number][_hvar] =
231 d2s_dh2 * _gradh_qp[_qp] + d2s_dph * _liquid_gradp_qp[_qp];
232 (*_dgrads_qp_dv)[_qp][_aqueous_phase_number][_hvar] =
233 -(*_dgrads_qp_dv)[_qp][_gas_phase_number][_hvar];
237 const Real dpc = _pc.dCapillaryPressure(_fsp[_aqueous_phase_number].saturation.value());
238 const Real d2pc = _pc.d2CapillaryPressure(_fsp[_aqueous_phase_number].saturation.value());
240 (*_gradp_qp)[_qp][_aqueous_phase_number] = _liquid_gradp_qp[_qp];
241 (*_gradp_qp)[_qp][_gas_phase_number] =
242 _liquid_gradp_qp[_qp] + dpc * (*_grads_qp)[_qp][_aqueous_phase_number];
244 for (
unsigned int ph = 0; ph < _num_phases; ++ph)
245 (*_dgradp_qp_dgradv)[_qp][ph][_pvar] = 1.0;
247 (*_dgradp_qp_dgradv)[_qp][_gas_phase_number][_pvar] +=
248 dpc * (*_dgrads_qp_dgradv)[_qp][_aqueous_phase_number][_pvar];
249 (*_dgradp_qp_dgradv)[_qp][_gas_phase_number][_hvar] =
250 dpc * (*_dgrads_qp_dgradv)[_qp][_aqueous_phase_number][_hvar];
252 (*_dgradp_qp_dv)[_qp][_gas_phase_number][_pvar] =
253 d2pc * (*_grads_qp)[_qp][_aqueous_phase_number] *
254 (*_dsaturation_dvar)[_qp][_aqueous_phase_number][_pvar] +
255 dpc * (*_dgrads_qp_dv)[_qp][_aqueous_phase_number][_pvar];
257 (*_dgradp_qp_dv)[_qp][_gas_phase_number][_hvar] =
258 d2pc * (*_grads_qp)[_qp][_aqueous_phase_number] *
259 (*_dsaturation_dvar)[_qp][_aqueous_phase_number][_hvar] +
260 dpc * (*_dgrads_qp_dv)[_qp][_aqueous_phase_number][_hvar];
264 template <
bool is_ad>
274 (*_dtemperature_dvar)[_qp].assign(_num_pf_vars, 0.0);
277 if (!_nodal_material || is_ad)
282 if (!_nodal_material)
284 (*_dgrad_temperature_dgradv)[_qp].assign(_num_pf_vars, 0.0);
285 (*_dgrad_temperature_dv)[_qp].assign(_num_pf_vars,
RealGradient());
const PorousFlowFluidStateSingleComponentBase & _fs
FluidState UserObject.
virtual void setMaterialVectorSize() const override
Size material property vectors and initialise with zeros.
virtual void initQpStatefulProperties() override
void mooseError(Args &&... args)
static const std::string temperature
virtual void thermophysicalProperties() override
Calculates all required thermophysical properties and derivatives for each phase and fluid component...
static InputParameters validParams()
virtual void initQpStatefulProperties() override
virtual void setMaterialVectorSize() const
Size material property vectors and initialise with zeros.
static InputParameters validParams()
virtual void computeQpProperties() override
registerMooseObject("PorousFlowApp", PorousFlowFluidStateSingleComponent)
AD data structure to pass calculated thermophysical properties.
virtual void computeQpProperties() override
Fluid state base class using a persistent set of primary variables for multiphase, single and multicomponent cases.
const unsigned int _num_phases
Number of phases.
PorousFlowFluidStateSingleComponentTempl(const InputParameters ¶meters)
Fluid state class using a persistent set of primary variables for the mutliphase, single component ca...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int numPhases() const
The maximum number of phases in this model.
Base class for miscible multiphase flow classes with a single fluid component using a pressure and en...