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