https://mooseframework.inl.gov
FlowModelGasMixUtilsTest.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 
13 #include "THMIndicesGasMix.h"
14 #include "FlowModelGasMixUtils.h"
15 #include "THMTestUtils.h"
16 
17 #include "gtest/gtest.h"
18 
20 {
22 }
23 
24 void
26 {
27  const std::string fp_steam_name = "fp_steam";
28  const std::string fp_nitrogen_name = "fp_nitrogen";
29  const std::string fp_mix_name = "fp_mix";
30 
31  // steam fluid properties; parameters correspond to T in range 298 K to 473 K
32  {
33  const std::string class_name = "IdealGasFluidProperties";
34  InputParameters params = _factory.getValidParams(class_name);
35  params.set<Real>("gamma") = 1.43;
36  params.set<Real>("molar_mass") = 0.01801488;
37  params.set<Real>("mu") = 0.000013277592; // at 400 K and 1.e5 Pa
38  params.set<Real>("k") = 0.026824977826; // at 400 K and 1.e5 Pa
39  _fe_problem->addUserObject(class_name, fp_steam_name, params);
40  }
41 
42  // nitrogen fluid properties
43  {
44  const std::string class_name = "IdealGasFluidProperties";
45  InputParameters params = _factory.getValidParams(class_name);
46  params.set<Real>("gamma") = 1.4;
47  params.set<Real>("molar_mass") = 0.028012734746133888;
48  params.set<Real>("mu") = 0.0000222084; // at 400 K and 1.e5 Pa
49  params.set<Real>("k") = 0.032806168; // at 400 K and 1.e5 Pa
50  _fe_problem->addUserObject(class_name, fp_nitrogen_name, params);
51  }
52 
53  // mixture fluid properties
54  {
55  const std::string class_name = "IdealGasMixtureFluidProperties";
56  InputParameters params = _factory.getValidParams(class_name);
57  params.set<std::vector<UserObjectName>>("component_fluid_properties") = {fp_steam_name,
58  fp_nitrogen_name};
59  _fe_problem->addUserObject(class_name, fp_mix_name, params);
60  _fp_mix = &_fe_problem->getUserObject<IdealGasMixtureFluidProperties>(fp_mix_name);
61  }
62 }
63 
64 TEST_F(FlowModelGasMixUtilsTest, testConservativePrimitiveConversionConsistency)
65 {
66  std::vector<ADReal> W(THMGasMix1D::N_PRIM_VARS);
68  W[THMGasMix1D::PRESSURE] = 1e5;
69  W[THMGasMix1D::TEMPERATURE] = 300;
70  W[THMGasMix1D::VELOCITY] = 1.5;
71 
72  const ADReal A = 2.0;
73 
74  const auto U = FlowModelGasMixUtils::computeConservativeSolution<true>(W, A, *_fp_mix);
75  const auto W_new = FlowModelGasMixUtils::computePrimitiveSolution<true>(U, *_fp_mix);
76 
77  for (unsigned int i = 0; i < W_new.size(); ++i)
78  REL_TEST(W_new[i], W[i], REL_TOL_CONSISTENCY);
79 }
std::shared_ptr< FEProblem > _fe_problem
static const unsigned int N_PRIM_VARS
T & set(const std::string &name, bool quiet_mode=false)
const IdealGasMixtureFluidProperties * _fp_mix
Fluid properties user object.
InputParameters getValidParams(const std::string &name) const
DualNumber< Real, DNDerivativeType, true > ADReal
TEST_F(FlowModelGasMixUtilsTest, testConservativePrimitiveConversionConsistency)
void addFluidProperties()
Adds fluid properties objects needed for testing.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Class for fluid properties of an ideal gas mixture.
Tests FlowModelGasMixUtils.