GRINS-0.8.0
antioch_mixture_builder_test.C
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 //
3 // GRINS - General Reacting Incompressible Navier-Stokes
4 //
5 // Copyright (C) 2014-2016 Paul T. Bauman, Roy H. Stogner
6 // Copyright (C) 2010-2013 The PECOS Development Team
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the Version 2.1 GNU Lesser General
10 // Public License as published by the Free Software Foundation.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
20 // Boston, MA 02110-1301 USA
21 //
22 //-----------------------------------------------------------------------el-
23 
24 #include "grins_config.h"
25 
26 #ifdef GRINS_HAVE_CPPUNIT
27 #ifdef GRINS_HAVE_ANTIOCH
28 
29 #include <cppunit/extensions/HelperMacros.h>
30 #include <cppunit/TestCase.h>
31 
32 // Testing
33 #include "grins_test_paths.h"
34 
35 //GRINS
39 
40 namespace GRINSTesting
41 {
42  class AntiochMixtureBuilderBaseTest : public CppUnit::TestCase
43  {
44  public:
46 
52 
54 
55  public:
56 
57  void setUp()
58  {
59  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/antioch.in";
60  _input.reset( new GetPot(input_file) );
61  }
62 
64  {
66 
67  libMesh::UniquePtr<Antioch::ChemicalMixture<libMesh::Real> > chem_mix
68  = builder.build_chem_mix(*_input, "TestMaterial");
69 
70  // Just a couple of basic tests for the parsed ChemicalMixture
71  CPPUNIT_ASSERT_EQUAL( 5, (int)chem_mix->n_species() );
72 
73  const std::vector<Antioch::ChemicalSpecies<libMesh::Real>*> & all_species =
74  chem_mix->chemical_species();
75 
76  CPPUNIT_ASSERT_EQUAL( 5, (int)all_species.size() );
77  }
78 
80  {
82 
83  libMesh::UniquePtr<Antioch::ChemicalMixture<libMesh::Real> > chem_mix
84  = builder.build_chem_mix(*_input, "TestMaterial");
85 
86  libMesh::UniquePtr<Antioch::ReactionSet<libMesh::Real> > reaction_set
87  = builder.build_reaction_set(*_input, "TestMaterial", *chem_mix);
88 
89  CPPUNIT_ASSERT_EQUAL( 5, (int)reaction_set->n_species() );
90  CPPUNIT_ASSERT_EQUAL( 5, (int)reaction_set->n_reactions() );
91  }
92 
94  {
96 
97  libMesh::UniquePtr<Antioch::ChemicalMixture<libMesh::Real> > chem_mix
98  = builder.build_chem_mix(*_input, "TestMaterial");
99 
100  libMesh::UniquePtr<Antioch::NASAThermoMixture<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> > >
101  nasa_mix =
102  builder.build_nasa_thermo_mix<Antioch::CEACurveFit<libMesh::Real> >(*_input, "TestMaterial", *chem_mix);
103 
104  CPPUNIT_ASSERT(nasa_mix->check());
105  }
106 
108  {
110 
111  libMesh::Real min_T_exact = 114.15;
112  libMesh::Real min_T = builder.parse_min_T( *_input, "TestMaterial" );
113 
114  CPPUNIT_ASSERT_DOUBLES_EQUAL( min_T_exact, min_T, std::numeric_limits<libMesh::Real>::epsilon() );
115  }
116 
118  {
120 
121  bool clip_negative_rho_exact = true;
122  bool clip_negative_rho = builder.parse_clip_negative_rho( *_input, "TestMaterial" );
123 
124  CPPUNIT_ASSERT_EQUAL( clip_negative_rho_exact, clip_negative_rho );
125  }
126 
127  private:
128 
129  libMesh::UniquePtr<GetPot> _input;
130  };
131 
132 
133  class AntiochConstantTransportMixtureBuilderTest : public CppUnit::TestCase
134  {
135  public:
137 
144 
146 
147  public:
148 
149  void setUp()
150  {
151  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/antioch.in";
152  _input.reset( new GetPot(input_file) );
153  }
154 
156  {
158 
159  libMesh::UniquePtr<GRINS::ConstantViscosity> visc =
160  builder.build_constant_viscosity( *_input, "TestMaterial" );
161 
162  libMesh::Real mu = (*visc)();
163 
164  CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, mu, std::numeric_limits<libMesh::Real>::epsilon() );
165  }
166 
168  {
170 
171  libMesh::UniquePtr<GRINS::ConstantConductivity> conductivity =
173 
174  libMesh::Real k = (*conductivity)();
175 
176  CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.71, k, std::numeric_limits<libMesh::Real>::epsilon() );
177  }
178 
180  {
182 
183  libMesh::UniquePtr<GRINS::ConstantPrandtlConductivity> conductivity =
185 
186  libMesh::Real mu = 1.2;
187  libMesh::Real cp = 2.3;
188  libMesh::Real Pr = 0.7;
189  libMesh::Real k = (*conductivity)( mu, cp );
190  libMesh::Real k_exact = mu*cp/Pr;
191 
192  CPPUNIT_ASSERT_DOUBLES_EQUAL( k_exact, k, std::numeric_limits<libMesh::Real>::epsilon() );
193  }
194 
196  {
198 
199  libMesh::UniquePtr<Antioch::ConstantLewisDiffusivity<libMesh::Real> > diff =
200  builder.build_constant_lewis_diff( *_input, "TestMaterial" );
201 
202  libMesh::Real rho = 1.2;
203  libMesh::Real cp = 2.3;
204  libMesh::Real k = 3.4;
205  libMesh::Real Le = 1.4;
206 
207  libMesh::Real D = diff->D(rho,cp,k);
208 
209  libMesh::Real D_exact = k/rho/cp/Le;
210 
211  CPPUNIT_ASSERT_DOUBLES_EQUAL( D_exact, D, std::numeric_limits<libMesh::Real>::epsilon() );
212  }
213 
215  {
217 
218  libMesh::UniquePtr<GRINS::AntiochConstantTransportMixture<Antioch::CEACurveFit<libMesh::Real>,
220  mixture = builder.build_mixture<Antioch::CEACurveFit<libMesh::Real>,GRINS::ConstantConductivity>
221  (*_input, "TestMaterial");
222 
223  libMesh::Real mu = mixture->mu();
224  libMesh::Real k = (mixture->conductivity())();
225 
226  libMesh::Real rho = 1.2;
227  libMesh::Real cp = 2.3;
228 
229  libMesh::Real Le = 1.4;
230 
231  libMesh::Real D = mixture->diffusivity().D(rho,cp,k);
232 
233  libMesh::Real D_exact = k/rho/cp/Le;
234 
235  CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, mu, std::numeric_limits<libMesh::Real>::epsilon() );
236  CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.71, k, std::numeric_limits<libMesh::Real>::epsilon() );
237  CPPUNIT_ASSERT_DOUBLES_EQUAL( D_exact, D, std::numeric_limits<libMesh::Real>::epsilon() );
238  }
239 
241  {
243 
244  libMesh::UniquePtr<GRINS::AntiochConstantTransportMixture<Antioch::CEACurveFit<libMesh::Real>,
246  mixture = builder.build_mixture<Antioch::CEACurveFit<libMesh::Real>,GRINS::ConstantPrandtlConductivity>
247  (*_input, "TestMaterial");
248 
249  libMesh::Real mu = mixture->mu();
250  libMesh::Real cp = 2.3;
251  libMesh::Real Pr = 0.7;
252  libMesh::Real k = (mixture->conductivity())(mu, cp);
253  libMesh::Real k_exact = mu*cp/Pr;
254 
255  libMesh::Real rho = 1.2;
256 
257  libMesh::Real Le = 1.4;
258 
259  libMesh::Real D = mixture->diffusivity().D(rho,cp,k);
260 
261  libMesh::Real D_exact = k/rho/cp/Le;
262 
263  CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, mu, std::numeric_limits<libMesh::Real>::epsilon() );
264  CPPUNIT_ASSERT_DOUBLES_EQUAL( k_exact, k, std::numeric_limits<libMesh::Real>::epsilon() );
265  CPPUNIT_ASSERT_DOUBLES_EQUAL( D_exact, D, std::numeric_limits<libMesh::Real>::epsilon() );
266  }
267 
268  private:
269 
270  libMesh::UniquePtr<GetPot> _input;
271  };
272 
273 
274 
275 
276  class AntiochMixtureAveragedTransportMixtureBuilderTest : public CppUnit::TestCase
277  {
278  public:
280 
283 
284 #ifdef ANTIOCH_HAVE_GSL
285  CPPUNIT_TEST( test_build_cea_kinetic_theory_mix );
286 #endif // ANTIOCH_HAVE_GSL
287 
289 
290  public:
291 
292  void setUp()
293  {
294  std::string input_file = std::string(GRINS_TEST_SRCDIR)+"/input_files/antioch.in";
295  _input.reset( new GetPot(input_file) );
296  }
297 
299  {
301 
302  libMesh::UniquePtr<GRINS::AntiochMixtureAveragedTransportMixture<Antioch::CEACurveFit<libMesh::Real>,
303  Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real>,
304  Antioch::SutherlandViscosity<libMesh::Real>,
305  Antioch::EuckenThermalConductivity<Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real> > ,
306  Antioch::ConstantLewisDiffusivity<libMesh::Real> > >
307  mixture = builder.build_mixture<Antioch::CEACurveFit<libMesh::Real>,
308  Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real>,
309  Antioch::SutherlandViscosity<libMesh::Real>,
310  Antioch::EuckenThermalConductivity<Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real> >,
311  Antioch::ConstantLewisDiffusivity<libMesh::Real> >( *_input, "TestMaterial" );
312 
313  CPPUNIT_ASSERT(mixture);
314  }
315 
317  {
319 
320  libMesh::UniquePtr<GRINS::AntiochMixtureAveragedTransportMixture<Antioch::CEACurveFit<libMesh::Real>,
321  Antioch::StatMechThermodynamics<libMesh::Real>,
322  Antioch::SutherlandViscosity<libMesh::Real>,
323  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> >,
324  Antioch::ConstantLewisDiffusivity<libMesh::Real> > >
325  mixture = builder.build_mixture<Antioch::CEACurveFit<libMesh::Real>,
326  Antioch::StatMechThermodynamics<libMesh::Real>,
327  Antioch::SutherlandViscosity<libMesh::Real>,
328  Antioch::EuckenThermalConductivity<Antioch::StatMechThermodynamics<libMesh::Real> >,
329  Antioch::ConstantLewisDiffusivity<libMesh::Real> >( *_input, "TestMaterial" );
330 
331  CPPUNIT_ASSERT(mixture);
332  }
333 
334 #ifdef ANTIOCH_HAVE_GSL
335  void test_build_cea_kinetic_theory_mix()
336  {
338 
339  libMesh::UniquePtr<GRINS::AntiochMixtureAveragedTransportMixture<Antioch::CEACurveFit<libMesh::Real>,
340  Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real>,
341  Antioch::KineticsTheoryViscosity<libMesh::Real,Antioch::GSLSpliner>,
342  Antioch::KineticsTheoryThermalConductivity<Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real>,libMesh::Real>,
343  Antioch::MolecularBinaryDiffusion<libMesh::Real,Antioch::GSLSpliner> > >
344  mixture = builder.build_mixture<Antioch::CEACurveFit<libMesh::Real>,
345  Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real>,
346  Antioch::KineticsTheoryViscosity<libMesh::Real,Antioch::GSLSpliner>,
347  Antioch::KineticsTheoryThermalConductivity<Antioch::IdealGasMicroThermo<Antioch::NASAEvaluator<libMesh::Real,Antioch::CEACurveFit<libMesh::Real> >, libMesh::Real>,libMesh::Real>,
348  Antioch::MolecularBinaryDiffusion<libMesh::Real,Antioch::GSLSpliner> >( *_input, "TestMaterial" );
349 
350  CPPUNIT_ASSERT(mixture);
351  }
352 #endif // ANTIOCH_HAVE_GSL
353 
354  private:
355 
356  libMesh::UniquePtr<GetPot> _input;
357  };
358 
359 
363 
364 } // end namespace GRINSTesting
365 
366 #endif // GRINS_HAVE_ANTIOCH
367 #endif // GRINS_HAVE_CPPUNIT
bool parse_clip_negative_rho(const GetPot &input, const std::string &material)
CPPUNIT_TEST_SUITE_REGISTRATION(AntiochAirNASA9ThermoTest)
libMesh::UniquePtr< AntiochConstantTransportMixture< KineticsThermoCurveFit, Conductivity > > build_mixture(const GetPot &input, const std::string &material)
CPPUNIT_TEST(test_build_cea_sutherland_eucken_constlewis_mix)
libMesh::UniquePtr< Antioch::ReactionSet< libMesh::Real > > build_reaction_set(const GetPot &input, const std::string &material, const Antioch::ChemicalMixture< libMesh::Real > &chem_mix)
CPPUNIT_TEST_SUITE(AntiochMixtureBuilderBaseTest)
Base class building Antioch mixture wrappers.
libMesh::UniquePtr< Antioch::NASAThermoMixture< libMesh::Real, KineticsThermoCurveFit > > build_nasa_thermo_mix(const GetPot &input, const std::string &material, const Antioch::ChemicalMixture< libMesh::Real > &chem_mix)
libMesh::UniquePtr< Antioch::ConstantLewisDiffusivity< libMesh::Real > > build_constant_lewis_diff(const GetPot &input, const std::string &material)
libMesh::UniquePtr< ConstantViscosity > build_constant_viscosity(const GetPot &input, const std::string &material)
CPPUNIT_TEST_SUITE(AntiochMixtureAveragedTransportMixtureBuilderTest)
libMesh::UniquePtr< Conductivity > build_constant_conductivity(const GetPot &input, const std::string &material)
libMesh::Real parse_min_T(const GetPot &input, const std::string &material)
CPPUNIT_TEST_SUITE(AntiochConstantTransportMixtureBuilderTest)
libMesh::UniquePtr< Antioch::ChemicalMixture< libMesh::Real > > build_chem_mix(const GetPot &input, const std::string &material)
libMesh::UniquePtr< AntiochMixtureAveragedTransportMixture< KineticsThermoCurveFit, Thermo, Viscosity, Conductivity, Diffusivity > > build_mixture(const GetPot &input, const std::string &material)

Generated on Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1