https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MassDiffusionEnergyGasMixDGKernel.C
Go to the documentation of this file.
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
14#include "MooseUtils.h"
15
17
20{
22
23 params.addRequiredParam<MaterialPropertyName>("pressure", "Mixture pressure material property");
24 params.addRequiredParam<MaterialPropertyName>("temperature",
25 "Mixture temperature material property");
26 params.addRequiredParam<MaterialPropertyName>("velocity", "Mixture velocity material property");
27
28 params.addRequiredParam<UserObjectName>("fluid_properties",
29 "The VaporMixtureFluidProperties object");
30
31 params.addClassDescription("Adds mass diffusion to the energy equation for FlowChannelGasMix.");
32
33 return params;
34}
35
37 const InputParameters & parameters)
39
40 _p_elem(getADMaterialProperty<Real>("pressure")),
41 _p_neig(getNeighborADMaterialProperty<Real>("pressure")),
42 _T_elem(getADMaterialProperty<Real>("temperature")),
43 _T_neig(getNeighborADMaterialProperty<Real>("temperature")),
44 _vel_elem(getADMaterialProperty<Real>("velocity")),
45 _vel_neig(getNeighborADMaterialProperty<Real>("velocity")),
46
47 _fp(getUserObject<VaporMixtureFluidProperties>("fluid_properties")),
48 _fp_primary(_fp.getPrimaryFluidProperties()),
49 _fp_secondary(_fp.getSecondaryFluidProperties())
50{
51 if (!dynamic_cast<const IdealGasFluidProperties *>(&_fp_primary) ||
52 !dynamic_cast<const IdealGasFluidProperties *>(&_fp_secondary))
53 mooseError("This class requires gases to use IdealGasFluidProperties.");
54}
55
58{
59 Real dx, dx_side;
60 computePositionChanges(dx, dx_side);
61
62 const ADReal rho = linearlyInterpolate(_rho_elem[_qp], _rho_neig[_qp], dx, dx_side);
63 const ADReal D = linearlyInterpolate(_D_elem[_qp], _D_neig[_qp], dx, dx_side);
65
66 const ADReal mass_flux_secondary = -rho * D * dxi_dx;
67 const ADReal mass_flux_primary = -mass_flux_secondary;
68
69 const ADReal xi_secondary =
71 const ADReal xi_primary = 1 - xi_secondary;
72
73 const ADReal phi_secondary =
74 FlowModelGasMixUtils::computeSecondaryMoleFraction<true>(xi_secondary, _fp);
75 const ADReal phi_primary = 1 - phi_secondary;
76
77 const ADReal p_mix = linearlyInterpolate(_p_elem[_qp], _p_neig[_qp], dx, dx_side);
78 const ADReal p_primary = phi_primary * p_mix;
79 const ADReal p_secondary = phi_secondary * p_mix;
80
81 const ADReal T = linearlyInterpolate(_T_elem[_qp], _T_neig[_qp], dx, dx_side);
82
83 const ADReal vel_mix = linearlyInterpolate(_vel_elem[_qp], _vel_neig[_qp], dx, dx_side);
84 const ADReal diffvel_primary = MooseUtils::absoluteFuzzyEqual(xi_primary, 0.0)
85 ? 0.0
86 : mass_flux_primary / (rho * xi_primary);
87 const ADReal diffvel_secondary = MooseUtils::absoluteFuzzyEqual(xi_secondary, 0.0)
88 ? 0.0
89 : mass_flux_secondary / (rho * xi_secondary);
90 const ADReal vel_primary = vel_mix + diffvel_primary;
91 const ADReal vel_secondary = vel_mix + diffvel_secondary;
92
93 const ADReal H_primary = computeComponentTotalEnthalpy(p_primary, T, vel_primary, _fp_primary);
94 const ADReal H_secondary =
95 computeComponentTotalEnthalpy(p_secondary, T, vel_secondary, _fp_secondary);
96
97 return mass_flux_primary * H_primary + mass_flux_secondary * H_secondary;
98}
99
100ADReal
102 const ADReal & p,
103 const ADReal & T,
104 const ADReal & vel,
105 const SinglePhaseFluidProperties & fp) const
106{
107 const ADReal e = fp.e_from_p_T(p, T);
108 const ADReal rho = fp.rho_from_p_T(p, T);
109
110 // Ideal gas assumption is used here to eliminate pressure in numerator and denominator,
111 // which when zero, would cause NaN
112 const ADReal h = e + FluidProperties::_R * T / fp.molarMass();
113
114 return h + 0.5 * vel * vel;
115}
DualNumber< Real, DNDerivativeType, true > ADReal
const Real p
const double rho
const double T
registerMooseObject("ThermalHydraulicsApp", MassDiffusionEnergyGasMixDGKernel)
unsigned int _qp
static const Real _R
Universal gas constant (J/mol/K)
Ideal gas fluid properties Default parameters are for air at atmospheric pressure and temperature.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Adds mass diffusion for FlowChannelGasMix.
ADReal computeGradient(const ADReal &y_elem, const ADReal &y_neig, Real dx) const
Computes the gradient of a quantity in the channel direction.
ADReal linearlyInterpolate(const ADReal &y_elem, const ADReal &y_neig, Real dx, Real dx_side) const
Linearly interpolates a quantity to the side position.
const ADMaterialProperty< Real > & _rho_neig
Density for neighbor element.
const ADMaterialProperty< Real > & _D_elem
Diffusion coefficient for current element.
const ADMaterialProperty< Real > & _D_neig
Diffusion coefficient for neighbor element.
const ADMaterialProperty< Real > & _rho_elem
Density for current element.
const ADMaterialProperty< Real > & _mass_fraction_elem
Mass fraction for current element.
void computePositionChanges(Real &dx, Real &dx_side) const
Computes the changes in position between elements and side.
const ADMaterialProperty< Real > & _mass_fraction_neig
Mass fraction for neighbor element.
Adds mass diffusion to the energy equation for FlowChannelGasMix.
const ADMaterialProperty< Real > & _T_neig
Temperature for neighbor element.
ADReal computeComponentTotalEnthalpy(const ADReal &p, const ADReal &T, const ADReal &vel, const SinglePhaseFluidProperties &fp) const
Components the total enthalpy for a mixture component.
const ADMaterialProperty< Real > & _vel_elem
Mixture velocity for current element.
const VaporMixtureFluidProperties & _fp
Fluid properties.
const ADMaterialProperty< Real > & _vel_neig
Mixture velocity for neighbor element.
const SinglePhaseFluidProperties & _fp_primary
const ADMaterialProperty< Real > & _p_elem
Mixture pressure for current element.
virtual ADReal computeQpFlux() const override
Computes the flux that will be applied to both sides for a q-point.
const ADMaterialProperty< Real > & _p_neig
Mixture pressure for neighbor element.
const ADMaterialProperty< Real > & _T_elem
Temperature for current element.
const SinglePhaseFluidProperties & _fp_secondary
MassDiffusionEnergyGasMixDGKernel(const InputParameters &parameters)
void mooseError(Args &&... args) const
Common class for single phase fluid properties.
Base class for fluid properties of vapor mixtures.