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 "MassDiffusionEnergyGasMixDGKernel.h"
11 : #include "VaporMixtureFluidProperties.h"
12 : #include "IdealGasFluidProperties.h"
13 : #include "FlowModelGasMixUtils.h"
14 : #include "MooseUtils.h"
15 :
16 : registerMooseObject("ThermalHydraulicsApp", MassDiffusionEnergyGasMixDGKernel);
17 :
18 : InputParameters
19 41 : MassDiffusionEnergyGasMixDGKernel::validParams()
20 : {
21 41 : InputParameters params = MassDiffusionBaseGasMixDGKernel::validParams();
22 :
23 82 : params.addRequiredParam<MaterialPropertyName>("pressure", "Mixture pressure material property");
24 82 : params.addRequiredParam<MaterialPropertyName>("temperature",
25 : "Mixture temperature material property");
26 82 : params.addRequiredParam<MaterialPropertyName>("velocity", "Mixture velocity material property");
27 :
28 82 : params.addRequiredParam<UserObjectName>("fluid_properties",
29 : "The VaporMixtureFluidProperties object");
30 :
31 41 : params.addClassDescription("Adds mass diffusion to the energy equation for FlowChannelGasMix.");
32 :
33 41 : return params;
34 0 : }
35 :
36 22 : MassDiffusionEnergyGasMixDGKernel::MassDiffusionEnergyGasMixDGKernel(
37 22 : const InputParameters & parameters)
38 : : MassDiffusionBaseGasMixDGKernel(parameters),
39 :
40 22 : _p_elem(getADMaterialProperty<Real>("pressure")),
41 44 : _p_neig(getNeighborADMaterialProperty<Real>("pressure")),
42 44 : _T_elem(getADMaterialProperty<Real>("temperature")),
43 44 : _T_neig(getNeighborADMaterialProperty<Real>("temperature")),
44 44 : _vel_elem(getADMaterialProperty<Real>("velocity")),
45 44 : _vel_neig(getNeighborADMaterialProperty<Real>("velocity")),
46 :
47 22 : _fp(getUserObject<VaporMixtureFluidProperties>("fluid_properties")),
48 22 : _fp_primary(_fp.getPrimaryFluidProperties()),
49 44 : _fp_secondary(_fp.getSecondaryFluidProperties())
50 : {
51 22 : if (!dynamic_cast<const IdealGasFluidProperties *>(&_fp_primary) ||
52 22 : !dynamic_cast<const IdealGasFluidProperties *>(&_fp_secondary))
53 0 : mooseError("This class requires gases to use IdealGasFluidProperties.");
54 22 : }
55 :
56 : ADReal
57 22540 : MassDiffusionEnergyGasMixDGKernel::computeQpFlux() const
58 : {
59 : Real dx, dx_side;
60 22540 : computePositionChanges(dx, dx_side);
61 :
62 22540 : const ADReal rho = linearlyInterpolate(_rho_elem[_qp], _rho_neig[_qp], dx, dx_side);
63 22540 : const ADReal D = linearlyInterpolate(_D_elem[_qp], _D_neig[_qp], dx, dx_side);
64 22540 : const ADReal dxi_dx = computeGradient(_mass_fraction_elem[_qp], _mass_fraction_neig[_qp], dx);
65 :
66 22540 : const ADReal mass_flux_secondary = -rho * D * dxi_dx;
67 22540 : const ADReal mass_flux_primary = -mass_flux_secondary;
68 :
69 : const ADReal xi_secondary =
70 22540 : linearlyInterpolate(_mass_fraction_elem[_qp], _mass_fraction_neig[_qp], dx, dx_side);
71 22540 : const ADReal xi_primary = 1 - xi_secondary;
72 :
73 : const ADReal phi_secondary =
74 22540 : FlowModelGasMixUtils::computeSecondaryMoleFraction<true>(xi_secondary, _fp);
75 22540 : const ADReal phi_primary = 1 - phi_secondary;
76 :
77 22540 : 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 22540 : const ADReal T = linearlyInterpolate(_T_elem[_qp], _T_neig[_qp], dx, dx_side);
82 :
83 22540 : const ADReal vel_mix = linearlyInterpolate(_vel_elem[_qp], _vel_neig[_qp], dx, dx_side);
84 22540 : const ADReal diffvel_primary = MooseUtils::absoluteFuzzyEqual(xi_primary, 0.0)
85 22540 : ? 0.0
86 22540 : : mass_flux_primary / (rho * xi_primary);
87 45080 : const ADReal diffvel_secondary = MooseUtils::absoluteFuzzyEqual(xi_secondary, 0.0)
88 22540 : ? 0.0
89 22540 : : 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 22540 : const ADReal H_primary = computeComponentTotalEnthalpy(p_primary, T, vel_primary, _fp_primary);
94 : const ADReal H_secondary =
95 22540 : computeComponentTotalEnthalpy(p_secondary, T, vel_secondary, _fp_secondary);
96 :
97 22540 : return mass_flux_primary * H_primary + mass_flux_secondary * H_secondary;
98 : }
99 :
100 : ADReal
101 45080 : MassDiffusionEnergyGasMixDGKernel::computeComponentTotalEnthalpy(
102 : const ADReal & p,
103 : const ADReal & T,
104 : const ADReal & vel,
105 : const SinglePhaseFluidProperties & fp) const
106 : {
107 45080 : const ADReal e = fp.e_from_p_T(p, T);
108 45080 : 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 45080 : const ADReal h = e + FluidProperties::_R * T / fp.molarMass();
113 :
114 45080 : return h + 0.5 * vel * vel;
115 : }
|