adding statmech testing suite
This commit is contained in:
parent
d9381b55da
commit
2d2c16ec38
12 changed files with 572 additions and 1 deletions
|
|
@ -151,6 +151,7 @@ AC_OUTPUT(Makefile \
|
|||
test_problems/cathermo/VPissp/Makefile \
|
||||
test_problems/cathermo/wtWater/Makefile \
|
||||
test_problems/PecosTransport/Makefile \
|
||||
test_problems/statmech/Makefile \
|
||||
doc/Makefile \
|
||||
doc/doxygen/Makefile \
|
||||
src/Makefile \
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ SUBDIRS += ChemEquil_ionizedGas ChemEquil_red1 CpJump cxx_ex diamondSurf
|
|||
SUBDIRS += diamondSurf_dupl fracCoeff multiGasTransport NASA9poly_test
|
||||
SUBDIRS += negATest printUtilUnitTest pureFluidTest silane_equil
|
||||
SUBDIRS += spectroscopy surfkin surfSolverTest VPsilane_test
|
||||
SUBDIRS += VCSnonideal PecosTransport
|
||||
SUBDIRS += VCSnonideal PecosTransport statmech
|
||||
|
||||
#f77test
|
||||
|
||||
|
|
|
|||
30
test_problems/statmech/Makefile.am
Normal file
30
test_problems/statmech/Makefile.am
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
INC = -I. -I$(top_builddir)/build/include/ -g
|
||||
AM_CPPFLAGS = $(INC)
|
||||
AM_CXXFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
LINK = -lctcxx -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo
|
||||
LINK += -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lcvode
|
||||
LINK += -lctlapack -lctblas -lctf2c -lm -lstdc++
|
||||
AM_LDFLAGS = -L$(top_builddir)/build/lib/
|
||||
LIBS = $(LINK)
|
||||
|
||||
check_PROGRAMS = statmech_test \
|
||||
statmech_test_poly \
|
||||
statmech_test_Fe
|
||||
|
||||
library_includedir = $(INC)
|
||||
|
||||
#-----------------------
|
||||
# Cantera DH graph test
|
||||
#-----------------------
|
||||
|
||||
statmech_test_SOURCES = statmech_test.cpp
|
||||
statmech_test_poly_SOURCES = statmech_test_poly.cpp
|
||||
statmech_test_Fe_SOURCES = statmech_test_Fe.cpp
|
||||
|
||||
TESTS_ENVIRONMENT =
|
||||
TESTS = statmech_test \
|
||||
statmech_test_poly \
|
||||
statmech_test_Fe
|
||||
|
||||
EXTRA_DIST = runtest_stat
|
||||
15
test_problems/statmech/runtest_stat
Executable file
15
test_problems/statmech/runtest_stat
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
temp_success="1"
|
||||
/bin/rm -f output.txt outputa.txt
|
||||
tname="mixGasTransport"
|
||||
#################################################################
|
||||
#
|
||||
#################################################################
|
||||
CANTERA_DATA=${CANTERA_DATA:=../../data/inputs}; export CANTERA_DATA
|
||||
|
||||
CANTERA_BIN=${CANTERA_BIN:=../../bin}
|
||||
./statmech_test > output.txt
|
||||
|
||||
exit $?
|
||||
64
test_problems/statmech/statmech_properties.cpp
Normal file
64
test_problems/statmech/statmech_properties.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* @file statmech
|
||||
* test problem for statistical mechanics in cantera
|
||||
*/
|
||||
|
||||
// Example
|
||||
//
|
||||
// Test case for the statistical mechanics in cantera
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
|
||||
#include "Cantera.h"
|
||||
#include "transport.h"
|
||||
#include "IdealGasMix.h"
|
||||
#include "equil.h"
|
||||
|
||||
#include "TransportFactory.h"
|
||||
|
||||
using namespace Cantera;
|
||||
using namespace Cantera_CXX;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
int k;
|
||||
IdealGasMix g("test_stat.xml");
|
||||
int nsp = g.nSpecies();
|
||||
double pres = 1.0E5;
|
||||
|
||||
vector_fp Xset(nsp, 0.0);
|
||||
Xset[0] = 0.5 ;
|
||||
Xset[1] = 0.5;
|
||||
|
||||
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
|
||||
equilibrate(g, "TP", -1);
|
||||
|
||||
vector_fp cp_R(nsp, 0.0);
|
||||
g.getCp_R(DATA_PTR(cp_R));
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (CanteraError)
|
||||
{
|
||||
showErrors(cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Mark it zero!
|
||||
return 0;
|
||||
|
||||
}
|
||||
115
test_problems/statmech/statmech_test.cpp
Normal file
115
test_problems/statmech/statmech_test.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
* @file statmech
|
||||
* test problem for statistical mechanics in cantera
|
||||
*/
|
||||
|
||||
// Example
|
||||
//
|
||||
// Test case for the statistical mechanics in cantera
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
|
||||
#include "Cantera.h"
|
||||
#include "transport.h"
|
||||
#include "IdealGasMix.h"
|
||||
#include "equil.h"
|
||||
|
||||
#include "TransportFactory.h"
|
||||
|
||||
using namespace Cantera;
|
||||
using namespace Cantera_CXX;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
int k;
|
||||
IdealGasMix g("test_stat.xml");
|
||||
int nsp = g.nSpecies();
|
||||
double pres = 1.0E5;
|
||||
|
||||
vector_fp Xset(nsp, 0.0);
|
||||
Xset[0] = 0.5 ;
|
||||
Xset[1] = 0.5;
|
||||
|
||||
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
|
||||
equilibrate(g, "TP", -1);
|
||||
|
||||
vector_fp cp_R(nsp, 0.0);
|
||||
g.getCp_R(DATA_PTR(cp_R));
|
||||
|
||||
//for(int i=0;i<nsp;i++)
|
||||
//{
|
||||
// std::cout.precision(10);
|
||||
// std::cout << cp_R[i] << std::endl;
|
||||
// }
|
||||
|
||||
// error check-- exactly 2.5 for atoms
|
||||
if(cp_R[0] != 2.5)
|
||||
{
|
||||
std::cout << "Error for monotomic Species!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// error check: analytical result is more complicated for
|
||||
// molecules. One species should suffice, lets try NO2, with
|
||||
// three vibrational modes:
|
||||
/// theta[0]: 1.07900e3
|
||||
/// theta[1]: 1.90000e3
|
||||
/// theta[2]: 2.32700e3
|
||||
// at T = 1500
|
||||
//
|
||||
// This is precisely: 6.655804161 (e.g. 5/2 + 2 + 3.1558..)
|
||||
//
|
||||
double theta[3];
|
||||
theta[0] = 1.07900e3;
|
||||
theta[1] = 1.90000e3;
|
||||
theta[2] = 2.32700e3;
|
||||
|
||||
double T;
|
||||
T = 1500.0;
|
||||
|
||||
double denom;
|
||||
double ctr = 0.0;
|
||||
double GasConstant = 1.0;
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
denom = exp(2*theta[i]/T) - 2* exp(theta[i]/T) + 1;
|
||||
ctr += GasConstant * theta[i] * (theta[i] * exp(theta[i]/T)/(T*T))/ (denom);
|
||||
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
|
||||
}
|
||||
//std::cout << "survey says: " << ctr << " and denom is: " << denom << std::endl;
|
||||
double sol = ctr + 5/2 + 2;
|
||||
double tol = 1e-9;
|
||||
|
||||
if(abs(cp_R[3] - sol) >= tol )
|
||||
{
|
||||
double diff = cp_R[3]-sol;
|
||||
std::cout << "Error for Species NO2!\n";
|
||||
std::cout << "Diff was: " << diff << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch (CanteraError)
|
||||
{
|
||||
showErrors(cout);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Mark it zero!
|
||||
return 0;
|
||||
|
||||
}
|
||||
75
test_problems/statmech/statmech_test_Fe.cpp
Normal file
75
test_problems/statmech/statmech_test_Fe.cpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* @file statmech
|
||||
* test problem for statistical mechanics in cantera
|
||||
*/
|
||||
|
||||
// Example
|
||||
//
|
||||
// Test case to check error thrown if using Fe (not supported species)
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
|
||||
#include "Cantera.h"
|
||||
#include "transport.h"
|
||||
#include "IdealGasMix.h"
|
||||
#include "equil.h"
|
||||
|
||||
#include "TransportFactory.h"
|
||||
|
||||
using namespace Cantera;
|
||||
using namespace Cantera_CXX;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
int k;
|
||||
IdealGasMix g("test_stat_Fe.xml");
|
||||
int nsp = g.nSpecies();
|
||||
double pres = 1.0E5;
|
||||
|
||||
vector_fp Xset(nsp, 0.0);
|
||||
Xset[0] = 0.5 ;
|
||||
Xset[1] = 0.5;
|
||||
|
||||
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
|
||||
equilibrate(g, "TP", -1);
|
||||
|
||||
vector_fp cp_R(nsp, 0.0);
|
||||
g.getCp_R(DATA_PTR(cp_R));
|
||||
|
||||
for(int i=0;i<nsp;i++)
|
||||
{
|
||||
std::cout << cp_R[i] << std::endl;
|
||||
}
|
||||
|
||||
// error check
|
||||
if(cp_R[0] != 0)
|
||||
{
|
||||
std::cout << "Error for monotomic Species!\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (CanteraError)
|
||||
{
|
||||
// need to get error here because of loading Fe in input file, when
|
||||
// no Fe exists in the species information table, in statmech.cpp
|
||||
//showErrors(cout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Mark it zero!
|
||||
return 1;
|
||||
|
||||
}
|
||||
77
test_problems/statmech/statmech_test_poly.cpp
Normal file
77
test_problems/statmech/statmech_test_poly.cpp
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* @file statmech
|
||||
* test problem for statistical mechanics in cantera
|
||||
*/
|
||||
|
||||
// Example
|
||||
//
|
||||
// Test case for the statistical mechanics in cantera
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
|
||||
#include "Cantera.h"
|
||||
#include "transport.h"
|
||||
#include "IdealGasMix.h"
|
||||
#include "equil.h"
|
||||
|
||||
#include "TransportFactory.h"
|
||||
|
||||
using namespace Cantera;
|
||||
using namespace Cantera_CXX;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
int k;
|
||||
IdealGasMix g("test_stat_err.xml");
|
||||
int nsp = g.nSpecies();
|
||||
double pres = 1.0E5;
|
||||
|
||||
vector_fp Xset(nsp, 0.0);
|
||||
Xset[0] = 0.5 ;
|
||||
Xset[1] = 0.5;
|
||||
|
||||
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
|
||||
equilibrate(g, "TP", -1);
|
||||
|
||||
vector_fp cp_R(nsp, 0.0);
|
||||
g.getCp_R(DATA_PTR(cp_R));
|
||||
|
||||
for(int i=0;i<nsp;i++)
|
||||
{
|
||||
std::cout << cp_R[i] << std::endl;
|
||||
}
|
||||
|
||||
// error check
|
||||
if(cp_R[0] != 0)
|
||||
{
|
||||
std::cout << "Error for monotomic Species!\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (CanteraError)
|
||||
{
|
||||
// we wanted to catch an error here for incorrectly trying to use poly methods
|
||||
// for the statmech species data, so exit successfully
|
||||
//showErrors(cout);
|
||||
|
||||
// Mark it zero!
|
||||
return 0;
|
||||
}
|
||||
|
||||
// something is wrong: we were suppose to catch an error here: paradox!
|
||||
return 1;
|
||||
|
||||
}
|
||||
37
test_problems/statmech/test.xml
Normal file
37
test_problems/statmech/test.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
<?xml version="1.0"?>
|
||||
<ctml>
|
||||
<validate reactions="yes" species="yes"/>
|
||||
|
||||
<!-- phase Na -->
|
||||
<phase dim="3" id="H">
|
||||
<elementArray datasrc="elements.xml">
|
||||
O H C Fe Ca N Na Cl
|
||||
</elementArray>
|
||||
<speciesArray datasrc="#species_test"> H </speciesArray>
|
||||
<thermo model="IdealGas">
|
||||
<density units="g/cm3">2.165</density>
|
||||
</thermo>
|
||||
<transport model="None"/>
|
||||
<kinetics model="none"/>
|
||||
</phase>
|
||||
|
||||
<!-- species definitions -->
|
||||
<speciesData id="species_test">
|
||||
|
||||
<!-- species H -->
|
||||
<species name="H">
|
||||
<atomArray> H:1 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="10.0">
|
||||
<floatArray name="coeffs" size="7">
|
||||
2.344331120E+00, 7.980520750E-03, -1.947815100E-05, 2.015720940E-08,
|
||||
-7.376117610E-12, -9.179351730E+02, 6.830102380E-01</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
</speciesData>
|
||||
|
||||
</ctml>
|
||||
66
test_problems/statmech/test_stat.xml
Normal file
66
test_problems/statmech/test_stat.xml
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
<?xml version="1.0"?>
|
||||
<ctml>
|
||||
<validate reactions="yes" species="yes"/>
|
||||
|
||||
<!-- phase H -->
|
||||
<phase dim="3" id="H">
|
||||
<elementArray datasrc="elements.xml">
|
||||
O H C N Na
|
||||
</elementArray>
|
||||
<speciesArray datasrc="#species_test"> H O N NO2</speciesArray>
|
||||
<thermo model="IdealGas">
|
||||
<density units="g/cm3">2.165</density>
|
||||
</thermo>
|
||||
<transport model="None"/>
|
||||
<kinetics model="none"/>
|
||||
</phase>
|
||||
|
||||
<!-- species definitions -->
|
||||
<speciesData id="species_test">
|
||||
|
||||
<!-- species H -->
|
||||
<species name="H">
|
||||
<atomArray> H:1 </atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="3000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
<!-- species O -->
|
||||
<species name="O">
|
||||
<atomArray>O:1</atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="3000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
<!-- species N -->
|
||||
<species name="N">
|
||||
<atomArray>N:1</atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="3000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
<!-- species NO2 -->
|
||||
<species name="NO2">
|
||||
<atomArray>O:2 N:1</atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="3000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
<StatMech P0="100000.0" Tmax="3000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
</speciesData>
|
||||
|
||||
</ctml>
|
||||
44
test_problems/statmech/test_stat_Fe.xml
Normal file
44
test_problems/statmech/test_stat_Fe.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
<?xml version="1.0"?>
|
||||
<ctml>
|
||||
<validate reactions="yes" species="yes"/>
|
||||
|
||||
<!-- phase H -->
|
||||
<phase dim="3" id="H">
|
||||
<elementArray datasrc="elements.xml">
|
||||
O H C N Na Cl Fe
|
||||
</elementArray>
|
||||
<speciesArray datasrc="#species_test"> H Fe</speciesArray>
|
||||
<thermo model="IdealGas">
|
||||
<density units="g/cm3">2.165</density>
|
||||
</thermo>
|
||||
<transport model="None"/>
|
||||
<kinetics model="none"/>
|
||||
</phase>
|
||||
|
||||
<!-- species definitions -->
|
||||
<speciesData id="species_test">
|
||||
|
||||
<!-- species H -->
|
||||
<species name="H">
|
||||
<atomArray> H:1 </atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="2000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
<!-- species Fe -->
|
||||
<species name="Fe">
|
||||
<atomArray> Fe:1 </atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="2000.0" Tmin="1.0">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
</speciesData>
|
||||
|
||||
</ctml>
|
||||
47
test_problems/statmech/test_stat_err.xml
Normal file
47
test_problems/statmech/test_stat_err.xml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
<?xml version="1.0"?>
|
||||
<ctml>
|
||||
<validate reactions="yes" species="yes"/>
|
||||
|
||||
<!-- phase H -->
|
||||
<phase dim="3" id="H">
|
||||
<elementArray datasrc="elements.xml">
|
||||
O H C N Na Cl
|
||||
</elementArray>
|
||||
<speciesArray datasrc="#species_test"> H O</speciesArray>
|
||||
<thermo model="IdealGas">
|
||||
<density units="g/cm3">2.165</density>
|
||||
</thermo>
|
||||
<transport model="None"/>
|
||||
<kinetics model="none"/>
|
||||
</phase>
|
||||
|
||||
<!-- species definitions -->
|
||||
<speciesData id="species_test">
|
||||
|
||||
<!-- species H -->
|
||||
<species name="H">
|
||||
<atomArray> H:1 </atomArray>
|
||||
<thermo>
|
||||
<StatMech P0="100000.0" Tmax="1000.0" Tmin="0.1">
|
||||
</StatMech>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
<!-- species O -->
|
||||
<species name="O">
|
||||
<atomArray> O:1 </atomArray>
|
||||
<thermo>
|
||||
<NASA9 P0="100000.0" Tmax="1000.0" Tmin="0.1">
|
||||
<floatArray name="coeffs" size="7">
|
||||
2.344331120E+00, 7.980520750E-03, -1.947815100E-05, 2.015720940E-08,
|
||||
-7.376117610E-12, -9.179351730E+02, 6.830102380E-01</floatArray>
|
||||
</NASA9>
|
||||
</thermo>
|
||||
<density units="g/cm3">2.165</density>
|
||||
</species>
|
||||
|
||||
</speciesData>
|
||||
|
||||
</ctml>
|
||||
Loading…
Add table
Reference in a new issue