www.mooseframework.org
MollifiedLangmuirMaterial.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<Material>();
14 
15  params.addRequiredCoupledVar(
16  "one_over_desorption_time_const",
17  "Time constant for Langmuir desorption (gas moving from matrix to porespace). Units [s]");
18  params.addRequiredCoupledVar(
19  "one_over_adsorption_time_const",
20  "Time constant for Langmuir adsorption (gas moving from porespace to matrix). Units [s].");
21  params.addRequiredParam<Real>("langmuir_density",
22  "This is (Langmuir volume)*(density of gas at standard temp and "
23  "pressure). Langmuir volume is measured in (gas volume)/(matrix "
24  "volume). (Methane density(101kPa, 20degC) = 0.655kg/m^3. "
25  "Methane density(101kPa, 0degC) = 0.715kg/m^3.) Units [kg/m^3]");
26  params.addRequiredParam<Real>("langmuir_pressure", "Langmuir pressure. Units Pa");
27  params.addRequiredCoupledVar("conc_var", "The concentration of gas variable");
28  params.addRequiredCoupledVar("pressure_var", "The gas porepressure variable");
29  params.addRangeCheckedParam<Real>("mollifier",
30  0.1,
31  "mollifier > 0",
32  "The reciprocal of time constants will be "
33  "one_over_time_const*tanh( |conc_var - "
34  "equilib_conc|/(mollifier*langmuir_density)). So for "
35  "mollifier very small you will get a stepchange between "
36  "desorption and adsorption, but for mollifier bigger you "
37  "will be a gradual change");
38  params.addClassDescription("Material type that holds info regarding MollifiedLangmuir desorption "
39  "from matrix to porespace and viceversa");
40  return params;
41 }
42 
43 MollifiedLangmuirMaterial::MollifiedLangmuirMaterial(const InputParameters & parameters)
44  : Material(parameters),
45  // coupledValue returns a reference (an alias) to a VariableValue, and the & turns it into a
46  // pointer
47  _one_over_de_time_const(&coupledValue("one_over_desorption_time_const")),
48  _one_over_ad_time_const(&coupledValue("one_over_adsorption_time_const")),
49 
50  _langmuir_dens(getParam<Real>("langmuir_density")),
51  _langmuir_p(getParam<Real>("langmuir_pressure")),
52 
53  _conc(&coupledValue("conc_var")),
54  _pressure(&coupledValue("pressure_var")),
55 
56  _mollifier(getParam<Real>("mollifier")),
57 
58  _mass_rate_from_matrix(declareProperty<Real>("mass_rate_from_matrix")),
59  _dmass_rate_from_matrix_dC(declareProperty<Real>("dmass_rate_from_matrix_dC")),
60  _dmass_rate_from_matrix_dp(declareProperty<Real>("dmass_rate_from_matrix_dp"))
61 {
62 }
63 
64 void
66 {
67  Real equilib_conc = _langmuir_dens * ((*_pressure)[_qp]) / (_langmuir_p + (*_pressure)[_qp]);
68  Real dequilib_conc_dp =
69  _langmuir_dens / (_langmuir_p + (*_pressure)[_qp]) -
70  _langmuir_dens * ((*_pressure)[_qp]) / std::pow(_langmuir_p + (*_pressure)[_qp], 2);
71 
72  Real mol = std::tanh(std::abs((*_conc)[_qp] - equilib_conc) / (_mollifier * _langmuir_dens));
73  Real deriv_tanh =
74  1 - std::pow(std::tanh(((*_conc)[_qp] - equilib_conc) / (_mollifier * _langmuir_dens)), 2);
75  if ((*_conc)[_qp] < equilib_conc)
76  deriv_tanh *= -1;
77  Real dmol_dC = deriv_tanh / (_mollifier * _langmuir_dens);
78  Real dmol_dp = -dmol_dC * dequilib_conc_dp;
79 
80  /*
81  Real de_plus_ad = (*_one_over_de_time_const)[_qp] + (*_one_over_ad_time_const)[_qp];
82  Real de_minus_ad = (*_one_over_de_time_const)[_qp] - (*_one_over_ad_time_const)[_qp];
83 
84  Real one_over_tau = 0.5*de_plus_ad + 0.5*de_minus_ad*std::tanh( ((*_conc)[_qp] -
85  equilib_conc)/(_mollifier*_langmuir_dens));
86  Real deriv_tanh = 1 - std::pow(std::tanh(((*_conc)[_qp] -
87  equilib_conc)/(_mollifier*_langmuir_dens)), 2);
88  Real d_one_over_tau_dC = 0.5*de_minus_ad*deriv_tanh/(_mollifier*_langmuir_dens);
89  Real d_one_over_tau_dp = -0.5*de_minus_ad*dequilib_conc_dp*deriv_tanh/(_mollifier*_langmuir_dens);
90  */
91 
92  // form the base rate and derivs without the appropriate time const
93  _mass_rate_from_matrix[_qp] = ((*_conc)[_qp] - equilib_conc) * mol;
94  _dmass_rate_from_matrix_dC[_qp] = mol + ((*_conc)[_qp] - equilib_conc) * dmol_dC;
96  -dequilib_conc_dp * mol + ((*_conc)[_qp] - equilib_conc) * dmol_dp;
97 
98  // multiply by the appropriate time const
99  if ((*_conc)[_qp] > equilib_conc)
100  {
101  _mass_rate_from_matrix[_qp] *= (*_one_over_de_time_const)[_qp];
102  _dmass_rate_from_matrix_dC[_qp] *= (*_one_over_de_time_const)[_qp];
103  _dmass_rate_from_matrix_dp[_qp] *= (*_one_over_de_time_const)[_qp];
104  }
105  else
106  {
107  _mass_rate_from_matrix[_qp] *= (*_one_over_ad_time_const)[_qp];
108  _dmass_rate_from_matrix_dC[_qp] *= (*_one_over_ad_time_const)[_qp];
109  _dmass_rate_from_matrix_dp[_qp] *= (*_one_over_ad_time_const)[_qp];
110  }
111 }
const VariableValue * _conc
concentration of adsorbed fluid in matrix
MaterialProperty< Real > & _dmass_rate_from_matrix_dC
derivative of mass flow rate wrt concentration
const Real _mollifier
mollifying parameter.
MaterialProperty< Real > & _dmass_rate_from_matrix_dp
derivative of mass flow rate wrt pressure
InputParameters validParams< MollifiedLangmuirMaterial >()
MollifiedLangmuirMaterial(const InputParameters &parameters)
virtual void computeQpProperties() override
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _langmuir_p
langmuir pressure
const Real _langmuir_dens
langmuir density
MaterialProperty< Real > & _mass_rate_from_matrix
mass flow rate from the matrix = mass flow rate to the porespace
const VariableValue * _pressure
porespace pressure (or partial pressure if multiphase flow scenario)