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