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
15#include "MooseUtils.h"
16
18
21{
23
24 params.addRequiredParam<MaterialPropertyName>("pressure", "Mixture pressure material property");
25 params.addRequiredParam<MaterialPropertyName>("temperature",
26 "Mixture temperature material property");
27 params.addRequiredParam<MaterialPropertyName>("velocity", "Mixture velocity material property");
28
29 params.addRequiredParam<UserObjectName>("fluid_properties",
30 "The VaporMixtureFluidProperties object");
31
32 params.addClassDescription("Adds mass diffusion to the energy equation for FlowChannelGasMix.");
33
34 return params;
35}
36
38 const InputParameters & parameters)
40
41 _p_elem(getADMaterialProperty<Real>("pressure")),
42 _p_neig(getNeighborADMaterialProperty<Real>("pressure")),
43 _T_elem(getADMaterialProperty<Real>("temperature")),
44 _T_neig(getNeighborADMaterialProperty<Real>("temperature")),
45 _vel_elem(getADMaterialProperty<Real>("velocity")),
46 _vel_neig(getNeighborADMaterialProperty<Real>("velocity")),
47
48 _fp(getUserObject<VaporMixtureFluidProperties>("fluid_properties")),
49 _fp_primary(_fp.getPrimaryFluidProperties()),
50 _fp_secondary(_fp.getSecondaryFluidProperties())
51{
52 // The component enthalpies are computed with the ideal gas law
53 if (!dynamic_cast<const IdealGasMixtureInterface *>(&_fp_primary) ||
54 !dynamic_cast<const IdealGasMixtureInterface *>(&_fp_secondary))
55 mooseError("This class requires ideal gases that implement IdealGasMixtureInterface, such as "
56 "IdealGasFluidProperties or NASA7IdealGasFluidProperties.");
57}
58
61{
62 Real dx, dx_side;
63 computePositionChanges(dx, dx_side);
64
65 const ADReal rho = linearlyInterpolate(_rho_elem[_qp], _rho_neig[_qp], dx, dx_side);
66 const ADReal D = linearlyInterpolate(_D_elem[_qp], _D_neig[_qp], dx, dx_side);
68
69 const ADReal mass_flux_secondary = -rho * D * dxi_dx;
70 const ADReal mass_flux_primary = -mass_flux_secondary;
71
72 const ADReal xi_secondary =
74 const ADReal xi_primary = 1 - xi_secondary;
75
76 const ADReal phi_secondary =
77 FlowModelGasMixUtils::computeSecondaryMoleFraction<true>(xi_secondary, _fp);
78 const ADReal phi_primary = 1 - phi_secondary;
79
80 const ADReal p_mix = linearlyInterpolate(_p_elem[_qp], _p_neig[_qp], dx, dx_side);
81 const ADReal p_primary = phi_primary * p_mix;
82 const ADReal p_secondary = phi_secondary * p_mix;
83
84 const ADReal T = linearlyInterpolate(_T_elem[_qp], _T_neig[_qp], dx, dx_side);
85
86 const ADReal vel_mix = linearlyInterpolate(_vel_elem[_qp], _vel_neig[_qp], dx, dx_side);
87 const ADReal diffvel_primary = MooseUtils::absoluteFuzzyEqual(xi_primary, 0.0)
88 ? 0.0
89 : mass_flux_primary / (rho * xi_primary);
90 const ADReal diffvel_secondary = MooseUtils::absoluteFuzzyEqual(xi_secondary, 0.0)
91 ? 0.0
92 : mass_flux_secondary / (rho * xi_secondary);
93 const ADReal vel_primary = vel_mix + diffvel_primary;
94 const ADReal vel_secondary = vel_mix + diffvel_secondary;
95
96 const ADReal H_primary = computeComponentTotalEnthalpy(p_primary, T, vel_primary, _fp_primary);
97 const ADReal H_secondary =
98 computeComponentTotalEnthalpy(p_secondary, T, vel_secondary, _fp_secondary);
99
100 return mass_flux_primary * H_primary + mass_flux_secondary * H_secondary;
101}
102
103ADReal
105 const ADReal & p,
106 const ADReal & T,
107 const ADReal & vel,
108 const SinglePhaseFluidProperties & fp) const
109{
110 const ADReal e = fp.e_from_p_T(p, T);
111 const ADReal rho = fp.rho_from_p_T(p, T);
112
113 // Ideal gas assumption is used here to eliminate pressure in numerator and denominator,
114 // which when zero, would cause NaN
115 const ADReal h = e + FluidProperties::_R * T / fp.molarMass();
116
117 return h + 0.5 * vel * vel;
118}
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)
Interface of the fluid properties of ideal gases that can be components of IdealGasMixtureFluidProper...
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.