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 : // Methane density - a quadratic fit to expressions in: 11 : // "Results of (pressure, density, temperature) measurements on methane and on nitrogen in the 12 : // temperature range from 273.15K to 323.15K at pressures up to 12MPa using new apparatus for 13 : // accurate gas-density" 14 : // 15 : // This is only valid for p>=0, which is the physical region. I extend to the p>0 domain with an 16 : // exponential, which will probably be sampled as the newton interative process converges towards 17 : // the solution. 18 : #include "RichardsDensityMethane20degC.h" 19 : 20 : registerMooseObject("RichardsApp", RichardsDensityMethane20degC); 21 : 22 : InputParameters 23 6 : RichardsDensityMethane20degC::validParams() 24 : { 25 6 : InputParameters params = RichardsDensity::validParams(); 26 12 : params.addParam<Real>( 27 : "p_unit", 28 12 : 1, 29 : "Set to 1 for pressure measured in Pascals. Set to 1E6 for pressure measured in MPa. Etc."); 30 6 : params.addClassDescription("Methane density (kg/m^3) at 20degC. Pressure is assumed to be " 31 : "measured in Pascals. NOTE: this expression is only valid to about " 32 : "P=20MPa. Use van der Waals (RichardsDensityVDW) for higher " 33 : "pressures."); 34 6 : return params; 35 0 : } 36 : 37 3 : RichardsDensityMethane20degC::RichardsDensityMethane20degC(const InputParameters & parameters) 38 6 : : RichardsDensity(parameters), _p_unit(getParam<Real>("p_unit")) 39 : { 40 3 : } 41 : 42 : Real 43 606 : RichardsDensityMethane20degC::density(Real p) const 44 : { 45 606 : if (p >= 0) 46 306 : return 0.00654576947608E-3 * p * _p_unit + 1.04357716547E-13 * std::pow(p * _p_unit, 2); 47 : else 48 300 : return 0.1 * (std::exp(6.54576947608E-5 * p * _p_unit) - 1); 49 : } 50 : 51 : Real 52 606 : RichardsDensityMethane20degC::ddensity(Real p) const 53 : { 54 606 : if (p >= 0) 55 306 : return (0.00654576947608E-3 + 2.08715433094E-13 * p * _p_unit) * _p_unit; 56 : else 57 300 : return 0.1 * 6.54576947608E-5 * _p_unit * std::exp(6.54576947608E-5 * p * _p_unit); 58 : } 59 : 60 : Real 61 606 : RichardsDensityMethane20degC::d2density(Real p) const 62 : { 63 606 : if (p >= 0) 64 306 : return 2.08715433094E-13 * std::pow(_p_unit, 2); 65 : else 66 300 : return 0.1 * std::pow(6.54576947608E-5 * _p_unit, 2) * std::exp(6.54576947608E-5 * p * _p_unit); 67 : }