https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSFV2PInterfaceAreaSourceSink.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
11#include "NS.h"
12#include "NonlinearSystemBase.h"
13#include "NavierStokesMethods.h"
14
16
19{
22 "Source and sink of interfacial area for two-phase flow mixture model.");
23 params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
24 params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
25 params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
26
27 params.addParam<MooseFunctorName>("L", 1.0, "The characteristic dissipation length.");
28 params.addRequiredParam<MooseFunctorName>(NS::density, "Continuous phase density.");
29 params.addRequiredParam<MooseFunctorName>(NS::density + std::string("_d"),
30 "Dispersed phase density.");
31 params.addRequiredParam<MooseFunctorName>(NS::pressure, "Continuous phase density.");
32 params.addParam<MooseFunctorName>(
33 "k_c", 0.0, "Mass exchange coefficients from continous to dispersed phases.");
34 params.addParam<MooseFunctorName>("fd", 0.0, "Fraction dispersed phase.");
35 params.addParam<Real>("fd_max", 1.0, "Maximum dispersed phase fraction.");
36
37 params.addParam<MooseFunctorName>("sigma", 1.0, "Surface tension between phases.");
38 params.addParam<MooseFunctorName>("particle_diameter", 1.0, "Maximum particle diameter.");
39
40 params.addParam<Real>("cutoff_fraction",
41 0.1,
42 "Void fraction at which the interface area density mass transfer model is "
43 "activated. Below this fraction, spherical bubbles are assumed.");
44
45 params.set<unsigned short>("ghost_layers") = 2;
46
47 return params;
48}
49
51 : FVElementalKernel(params),
52 _dim(_subproblem.mesh().dimension()),
53 _u_var(getFunctor<ADReal>("u")),
54 _v_var(params.isParamValid("v") ? &(getFunctor<ADReal>("v")) : nullptr),
55 _w_var(params.isParamValid("w") ? &(getFunctor<ADReal>("w")) : nullptr),
56 _characheristic_length(getFunctor<ADReal>("L")),
57 _rho_mixture(getFunctor<ADReal>(NS::density)),
58 _rho_d(getFunctor<ADReal>(NS::density + std::string("_d"))),
59 _pressure(getFunctor<ADReal>(NS::pressure)),
60 _mass_exchange_coefficient(getFunctor<ADReal>("k_c")),
61 _f_d(getFunctor<ADReal>("fd")),
62 _f_d_max(getParam<Real>("fd_max")),
63 _sigma(getFunctor<ADReal>("sigma")),
64 _particle_diameter(getFunctor<ADReal>("particle_diameter")),
65 _cutoff_fraction(getParam<Real>("cutoff_fraction"))
66{
67 if (_dim >= 2 && !_v_var)
68 paramError("v", "In two or more dimensions, the v velocity must be supplied!");
69
70 if (_dim >= 3 && !_w_var)
71 paramError("w", "In three or more dimensions, the w velocity must be supplied!");
72}
73
76{
77 using std::max, std::pow, std::exp, std::sqrt;
78
79 // Useful Arguments
80 const auto state = determineState();
81 const auto elem_arg = makeElemArg(_current_elem);
82 const bool is_transient = _subproblem.isTransient();
83
84 // Current Variables
85 const auto u = _u_var(elem_arg, state);
86 const auto rho_d = _rho_d(elem_arg, state);
87 const auto rho_d_grad = _rho_d.gradient(elem_arg, state);
88 const auto xi = _var(elem_arg, state);
89 const auto rho_m = _rho_mixture(elem_arg, state);
90 const auto f_d = _f_d(elem_arg, state);
91 const auto sigma = _sigma(elem_arg, state);
92 const auto rho_l = (rho_m - f_d * rho_d) / (1.0 - f_d + libMesh::TOLERANCE);
93 const auto complement_fd = max(_f_d_max - f_d, libMesh::TOLERANCE);
94 const auto f_d_o_xi = f_d / (_var(elem_arg, state) + libMesh::TOLERANCE) + libMesh::TOLERANCE;
95 const auto f_d_o_xi_old =
96 f_d / (raw_value(_var(elem_arg, state)) + libMesh::TOLERANCE) + libMesh::TOLERANCE;
97
98 // Adding bubble compressibility term
99 ADReal material_time_derivative_rho_d = u * rho_d_grad(0);
100 if (_dim > 1)
101 {
102 material_time_derivative_rho_d += (*_v_var)(elem_arg, state) * rho_d_grad(1);
103 if (_dim > 2)
104 {
105 material_time_derivative_rho_d += (*_w_var)(elem_arg, state) * rho_d_grad(2);
106 }
107 }
108 if (is_transient)
109 material_time_derivative_rho_d +=
110 raw_value(_rho_d(elem_arg, state) - _rho_d(elem_arg, Moose::oldState())) / _dt;
111 const auto bubble_compressibility = material_time_derivative_rho_d * xi / 3.0;
112
113 // Adding area growth due to added mass
114 ADReal bubble_added_mass;
115 if (f_d < _cutoff_fraction)
116 bubble_added_mass = raw_value(_rho_d(elem_arg, state)) *
117 (f_d * 6.0 / _particle_diameter(elem_arg, state) - _var(elem_arg, state));
118 else
119 bubble_added_mass = 2. / 3. * _mass_exchange_coefficient(elem_arg, state) *
120 (1.0 / (f_d + libMesh::TOLERANCE) - 2.0);
121
122 // Model parameters
123 const auto db = _shape_factor * f_d_o_xi_old + libMesh::TOLERANCE;
124
125 ADRealVectorValue velocity(u);
126 if (_v_var)
127 velocity(1) = (*_v_var)(elem_arg, state);
128 if (_w_var)
129 velocity(2) = (*_w_var)(elem_arg, state);
130
131 const ADReal velocity_norm = NS::computeSpeed<ADReal>(velocity);
132 const auto pressure_gradient = raw_value(_pressure.gradient(elem_arg, state));
133 const Real pressure_grad_norm =
134 MooseUtils::isZero(pressure_gradient) ? 1e-42 : pressure_gradient.norm();
135
136 const auto u_eps =
137 pow(velocity_norm * _characheristic_length(elem_arg, state) * pressure_grad_norm / rho_m,
138 1. / 3.);
139
140 const auto interaction_prefactor =
141 Utility::pow<2>(f_d_o_xi) * u_eps / (pow(db, 11. / 3.) / complement_fd);
142
143 // Adding coalescence term
144 const auto f_c = interaction_prefactor * _gamma_c * Utility::pow<2>(f_d);
145 const auto exp_c = exp(-_Kc * pow(db, 5. / 6.) * sqrt(rho_l / sigma) * u_eps);
146 const auto s_rc = f_c * exp_c;
147
148 // Adding breakage term
149 const auto f_b = interaction_prefactor * _gamma_b * f_d * (1. - f_d);
150 const auto exp_b = exp(-_Kb * sigma / (rho_l * pow(db, 5. / 3.) * Utility::pow<2>(u_eps)));
151 const auto s_rb = f_b * exp_b;
152
153 return -bubble_added_mass + bubble_compressibility + s_rc - s_rb;
154}
DualNumber< Real, DNDerivativeType, true > ADReal
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const GeochemicalDatabaseReader db("database/moose_testdb.json", true, true, false)
Point xi
registerMooseObject("NavierStokesApp", WCNSFV2PInterfaceAreaSourceSink)
static InputParameters validParams()
MooseVariableFV< Real > & _var
const Elem *const & _current_elem
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void paramError(const std::string &param, Args... args) const
SubProblem & _subproblem
virtual bool isTransient() const=0
Moose::StateArg determineState() const
Computes source the sink terms for the interface area in the mixture model of two-phase flows.
const Moose::Functor< ADReal > & _rho_d
Dispersed Phase Density.
const unsigned int _dim
The dimension of the domain.
static constexpr Real _gamma_c
Internal closure coefficients.
const Moose::Functor< ADReal > & _mass_exchange_coefficient
Interface Mass Exchange Coeefficient.
const Moose::Functor< ADReal > & _characheristic_length
Characterisitc Length.
const Moose::Functor< ADReal > & _pressure
Pressure field.
const Real _f_d_max
Maximum Void Fraction.
const Moose::Functor< ADReal > & _f_d
Void Fraction.
const Real _cutoff_fraction
Cutoff fraction at which the full mass transfer model is activated.
WCNSFV2PInterfaceAreaSourceSink(const InputParameters &parameters)
const Moose::Functor< ADReal > * _v_var
y-velocity
const Moose::Functor< ADReal > & _u_var
x-velocity
const Moose::Functor< ADReal > * _w_var
z-velocity
const Moose::Functor< ADReal > & _sigma
Surface Tension.
const Moose::Functor< ADReal > & _rho_mixture
Mixture Density.
const Moose::Functor< ADReal > & _particle_diameter
Particle Diameter.
MeshBase & mesh
StateArg oldState()
static const std::string density
Definition NS.h:34
template ADReal computeSpeed< ADReal >(const libMesh::VectorValue< ADReal > &velocity)
static const std::string pressure
Definition NS.h:57
static constexpr Real TOLERANCE