Line data Source code
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 : 10 : #include "PorousFlowSingleComponentFluid.h" 11 : #include "SinglePhaseFluidProperties.h" 12 : 13 : registerMooseObject("PorousFlowApp", PorousFlowSingleComponentFluid); 14 : registerMooseObject("PorousFlowApp", ADPorousFlowSingleComponentFluid); 15 : 16 : template <bool is_ad> 17 : InputParameters 18 26429 : PorousFlowSingleComponentFluidTempl<is_ad>::validParams() 19 : { 20 26429 : InputParameters params = PorousFlowFluidPropertiesBaseTempl<is_ad>::validParams(); 21 52858 : params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties"); 22 26429 : params.addClassDescription("This Material calculates fluid properties at the quadpoints or nodes " 23 : "for a single component fluid"); 24 26429 : return params; 25 0 : } 26 : 27 : template <bool is_ad> 28 20493 : PorousFlowSingleComponentFluidTempl<is_ad>::PorousFlowSingleComponentFluidTempl( 29 : const InputParameters & parameters) 30 : : PorousFlowFluidPropertiesBaseTempl<is_ad>(parameters), 31 20493 : _fp(this->template getUserObject<SinglePhaseFluidProperties>("fp")) 32 : { 33 20493 : } 34 : 35 : template <bool is_ad> 36 : void 37 2892459 : PorousFlowSingleComponentFluidTempl<is_ad>::initQpStatefulProperties() 38 : { 39 2892459 : if (_compute_rho_mu) 40 : { 41 2892359 : (*_density)[_qp] = _fp.rho_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, 42 2888507 : _temperature[_qp] + _t_c2k); 43 : 44 5780866 : (*_viscosity)[_qp] = _fp.mu_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, 45 2888507 : _temperature[_qp] + _t_c2k) / 46 2888507 : _pressure_to_Pascals / _time_to_seconds; 47 : } 48 : 49 2892459 : if (_compute_internal_energy) 50 804413 : (*_internal_energy)[_qp] = _fp.e_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, 51 800561 : _temperature[_qp] + _t_c2k); 52 : 53 2892459 : if (_compute_enthalpy) 54 957797 : (*_enthalpy)[_qp] = _fp.h_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, 55 953945 : _temperature[_qp] + _t_c2k); 56 2892459 : } 57 : 58 : template <bool is_ad> 59 : void 60 63211441 : PorousFlowSingleComponentFluidTempl<is_ad>::computeQpProperties() 61 : { 62 63211441 : if (_compute_rho_mu) 63 : { 64 : if (is_ad) 65 : { 66 : GenericReal<is_ad> rho, mu; 67 788508 : _fp.rho_mu_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, 68 394254 : _temperature[_qp] + _t_c2k, 69 : rho, 70 : mu); 71 : 72 394254 : (*_density)[_qp] = rho; 73 788508 : (*_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 62714947 : _fp.rho_mu_from_p_T(MetaPhysicL::raw_value(_porepressure[_qp][_phase_num]) * 80 62714947 : _pressure_to_Pascals, 81 62714947 : MetaPhysicL::raw_value(_temperature[_qp]) + _t_c2k, 82 : rho, 83 : drho_dp, 84 : drho_dT, 85 : mu, 86 : dmu_dp, 87 : dmu_dT); 88 62714947 : (*_density)[_qp] = rho; 89 62714947 : (*_ddensity_dp)[_qp] = drho_dp * _pressure_to_Pascals; 90 62714947 : (*_ddensity_dT)[_qp] = drho_dT; 91 62714947 : (*_viscosity)[_qp] = mu / _pressure_to_Pascals / _time_to_seconds; 92 62714947 : (*_dviscosity_dp)[_qp] = dmu_dp / _time_to_seconds; 93 62714947 : (*_dviscosity_dT)[_qp] = dmu_dT / _pressure_to_Pascals / _time_to_seconds; 94 : } 95 : } 96 : 97 63211441 : if (_compute_internal_energy) 98 : { 99 : if (is_ad) 100 394254 : (*_internal_energy)[_qp] = _fp.e_from_p_T( 101 394254 : _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 33056057 : _fp.e_from_p_T(MetaPhysicL::raw_value(_porepressure[_qp][_phase_num]) * _pressure_to_Pascals, 107 33056057 : MetaPhysicL::raw_value(_temperature[_qp]) + _t_c2k, 108 : e, 109 : de_dp, 110 : de_dT); 111 33056057 : (*_internal_energy)[_qp] = e; 112 33056057 : (*_dinternal_energy_dp)[_qp] = de_dp * _pressure_to_Pascals; 113 33056057 : (*_dinternal_energy_dT)[_qp] = de_dT; 114 : } 115 : } 116 : 117 63211441 : if (_compute_enthalpy) 118 : { 119 : if (is_ad) 120 788508 : (*_enthalpy)[_qp] = _fp.h_from_p_T(_porepressure[_qp][_phase_num] * _pressure_to_Pascals, 121 394254 : _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 34723429 : _fp.h_from_p_T(MetaPhysicL::raw_value(_porepressure[_qp][_phase_num]) * _pressure_to_Pascals, 127 34723429 : MetaPhysicL::raw_value(_temperature[_qp]) + _t_c2k, 128 : h, 129 : dh_dp, 130 : dh_dT); 131 34723429 : (*_enthalpy)[_qp] = h; 132 34723429 : (*_denthalpy_dp)[_qp] = dh_dp * _pressure_to_Pascals; 133 34723429 : (*_denthalpy_dT)[_qp] = dh_dT; 134 : } 135 : } 136 63211441 : } 137 : 138 : template class PorousFlowSingleComponentFluidTempl<false>; 139 : template class PorousFlowSingleComponentFluidTempl<true>;