Added a test problem for ideal solid solutions.
This commit is contained in:
parent
b3e610fa20
commit
6f6cfb2ec7
6 changed files with 451 additions and 0 deletions
8
test_problems/cathermo/issp/.cvsignore
Normal file
8
test_problems/cathermo/issp/.cvsignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.depends
|
||||
ISSPTester
|
||||
ISSPTester.d
|
||||
Makefile
|
||||
csvCode.txt
|
||||
diff_test.out
|
||||
output.txt
|
||||
outputa.txt
|
||||
160
test_problems/cathermo/issp/ISSPTester.cpp
Normal file
160
test_problems/cathermo/issp/ISSPTester.cpp
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
/**
|
||||
* @file ISSPTester.cpp
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
/*
|
||||
* Copywrite 2004 Sandia Corporation. Under the terms of Contract
|
||||
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
|
||||
* retains certain rights in this software.
|
||||
* See file License.txt for licensing information.
|
||||
*/
|
||||
|
||||
// Example
|
||||
//
|
||||
// Read a mechanism and a thermodynamics file for the
|
||||
// class IdealSolidSolnPhase in order to test that it's
|
||||
// working correctly
|
||||
//
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef SRCDIRTREE
|
||||
#include "ct_defs.h"
|
||||
#include "IdealSolidSolnPhase.h"
|
||||
#else
|
||||
#include "Cantera.h"
|
||||
#include "kernel/thermo/IdealSolidSolnPhase.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef DEBUG_HKM
|
||||
int iDebug_HKM = 0;
|
||||
#endif
|
||||
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
/*****************************************************************/
|
||||
static void printUsage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
using namespace Cantera;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
string infile;
|
||||
// look for command-line options
|
||||
if (argc > 1) {
|
||||
string tok;
|
||||
for (int j = 1; j < argc; j++) {
|
||||
tok = string(argv[j]);
|
||||
if (tok[0] == '-') {
|
||||
int nopt = tok.size();
|
||||
for (int n = 1; n < nopt; n++) {
|
||||
if (tok[n] == 'h') {
|
||||
printUsage();
|
||||
exit(0);
|
||||
} else {
|
||||
printUsage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else if (infile == "") {
|
||||
infile = tok;
|
||||
}
|
||||
else {
|
||||
printUsage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
double Tkelvin = 1200.;
|
||||
IdealSolidSolnPhase issp("IdealSolidSolnPhaseExample.xml");
|
||||
issp.setState_TPX(Tkelvin, OneAtm,
|
||||
"C2H2-graph:0.3, C-graph:0.6, H2-solute:0.1");
|
||||
double hm = issp.enthalpy_mole();
|
||||
printf("molar enthalpy = %13.5g J kg-1\n", hm);
|
||||
|
||||
double um = issp.intEnergy_mole();
|
||||
printf("molar intEnergy = %13.5g J kg-1\n", um);
|
||||
|
||||
|
||||
double sm = issp.entropy_mole();
|
||||
printf("molar entropy = %13.5g J kg-1 K-1\n", sm);
|
||||
|
||||
double gm = issp.gibbs_mole();
|
||||
printf("molar gibbs = %13.5g J kg-1\n", gm);
|
||||
|
||||
double cpm = issp.cp_mole();
|
||||
printf("molar Cp = %13.5g J kg-1 K-1\n", cpm);
|
||||
|
||||
double dens = issp.density();
|
||||
printf("mixture density = %13.5g kg m-3\n", dens);
|
||||
|
||||
double mdens = issp.molarDensity();
|
||||
printf("molar density = %13.5g kmol m-3\n", mdens);
|
||||
|
||||
double mmw = issp.meanMolecularWeight();
|
||||
printf("mean molecular weight = %13.5g kg kmol-1\n", mmw);
|
||||
|
||||
int n = issp.nSpecies();
|
||||
|
||||
double HiSS[20], muiSS[20],SiSS[20], CpiSS[20], VoliSS[20];
|
||||
double RT = GasConstant * Tkelvin;
|
||||
issp.getStandardChemPotentials(muiSS);
|
||||
issp.getEnthalpy_RT(HiSS);
|
||||
issp.getEntropy_R (SiSS);
|
||||
issp.getCp_R(CpiSS);
|
||||
issp.getStandardVolumes(VoliSS);
|
||||
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
HiSS[i] *= RT;
|
||||
SiSS[i] *= RT;
|
||||
CpiSS[i] *= GasConstant;
|
||||
}
|
||||
|
||||
printf(" Printout of standard state properties\n");
|
||||
printf(" Name mu_i H_i_SS "
|
||||
" S_i_SS Cp_i_SS Vol_i_SS\n");
|
||||
for (int i = 0; i < n; i++) {
|
||||
string sn = issp.speciesName(i);
|
||||
printf(" %15s %12.5g %12.5g %12.5g %12.5g %12.5g\n", sn.c_str(), muiSS[i],
|
||||
HiSS[i], SiSS[i], CpiSS[i], VoliSS[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
double HiPM[20], mui[20],SiPM[20], CpiPM[20], VoliPM[20];
|
||||
|
||||
issp.getChemPotentials(mui);
|
||||
issp.getPartialMolarEnthalpies(HiPM);
|
||||
issp.getPartialMolarEntropies(SiPM);
|
||||
issp.getPartialMolarCp(CpiPM);
|
||||
issp.getPartialMolarVolumes(VoliPM);
|
||||
printf(" Printout of Partial molar properties\n");
|
||||
printf(" Name mu_i H_i_PM "
|
||||
" S_i_PM Cp_i_PM Vol_i_PM\n");
|
||||
for (int i = 0; i < n; i++) {
|
||||
string sn = issp.speciesName(i);
|
||||
printf(" %15s %12.5g %12.5g %12.5g %12.5g %12.5g\n", sn.c_str(), mui[i],
|
||||
HiPM[i], SiPM[i], CpiPM[i], VoliPM[i]);
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/***********************************************************/
|
||||
121
test_problems/cathermo/issp/IdealSolidSolnPhaseExample.xml
Normal file
121
test_problems/cathermo/issp/IdealSolidSolnPhaseExample.xml
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0"?>
|
||||
<ctml>
|
||||
|
||||
<phase id="solidSolutionExample" dim="3">
|
||||
<state>
|
||||
<temperature units="K">500</temperature>
|
||||
</state>
|
||||
<!-- thermo model identifies the inherited class
|
||||
from ThermoPhase that will handle the thermodynamics.
|
||||
-->
|
||||
<thermo model="IdealSolidSolution" />
|
||||
<elementArray datasrc="elements.xml"> H C</elementArray>
|
||||
<speciesArray datasrc="#species_solidSolution">
|
||||
C2H2-graph C-graph H2-solute
|
||||
</speciesArray>
|
||||
<reactionArray datasrc="#reactions_solidSolution">
|
||||
</reactionArray>
|
||||
<kinetics model="SolidKinetics" />
|
||||
<standardConc model="unity" />
|
||||
</phase>
|
||||
|
||||
<!-- species data
|
||||
Note that these entries are for demonstration only, and the thermo
|
||||
is made up.
|
||||
-->
|
||||
|
||||
<speciesData id="species_solidSolution">
|
||||
|
||||
<species name="C2H2-graph">
|
||||
<note>This corresponds to new soot</note>
|
||||
<atomArray>C:2 H:2 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 1.5 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
<species name="C-graph">
|
||||
<note>This corresponds to old soot</note>
|
||||
<atomArray> C:1 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 1.3 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
<species name="H2-solute">
|
||||
<note>This species diffuses back into the gas phase</note>
|
||||
<atomArray> H:2 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 0.1 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
</speciesData>
|
||||
|
||||
<!-- reaction data -->
|
||||
<reactionData id="reactions_solidSolution" model="SolidKinetics" submodel="SolidKinetics_0">
|
||||
<standardConc model="unity" />
|
||||
|
||||
<!-- reaction 1 -->
|
||||
<reaction id="bulk_rxn_1" reversible="yes">
|
||||
<equation>C2H2-graph [=] H2-solute + 2 C-graph</equation>
|
||||
<reactants> C2H2-graph:1 </reactants>
|
||||
<products>H2-solute:1 C-graph:2 </products>
|
||||
<rateCoeff>
|
||||
<Arrhenius order="1">
|
||||
<A> 1.0E10 </A>
|
||||
<b> 0.0 </b>
|
||||
<E units="cal/mol"> 10000. </E>
|
||||
</Arrhenius>
|
||||
</rateCoeff>
|
||||
</reaction>
|
||||
|
||||
</reactionData>
|
||||
</ctml>
|
||||
112
test_problems/cathermo/issp/Makefile.in
Normal file
112
test_problems/cathermo/issp/Makefile.in
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#!/bin/sh
|
||||
|
||||
############################################################################
|
||||
#
|
||||
# Makefile to compile and link a C++ application to
|
||||
# Cantera.
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
# addition to suffixes
|
||||
.SUFFIXES : .d
|
||||
|
||||
# the name of the executable program to be created
|
||||
PROG_NAME = ISSPTester
|
||||
|
||||
# the object files to be linked together. List those generated from Fortran
|
||||
# and from C/C++ separately
|
||||
OBJS = ISSPTester.o
|
||||
|
||||
# Location of the current build. Will assume that tests are run
|
||||
# in the source directory tree location
|
||||
src_dir_tree = 1
|
||||
|
||||
# additional flags to be passed to the linker. If your program
|
||||
# requires other external libraries, put them here
|
||||
LINK_OPTIONS = @EXTRA_LINK@
|
||||
|
||||
#############################################################################
|
||||
|
||||
# Check to see whether we are in the msvc++ environment
|
||||
os_is_win = @OS_IS_WIN@
|
||||
|
||||
# Fortran libraries
|
||||
FORT_LIBS = @FLIBS@
|
||||
|
||||
# the C++ compiler
|
||||
CXX = @CXX@
|
||||
|
||||
# C++ compile flags
|
||||
ifeq ($(src_dir_tree), 1)
|
||||
CXX_FLAGS = -DSRCDIRTREE @CXXFLAGS@
|
||||
else
|
||||
CXX_FLAGS = @CXXFLAGS@
|
||||
endif
|
||||
|
||||
# Ending C++ linking libraries
|
||||
LCXX_END_LIBS = @LCXX_END_LIBS@
|
||||
|
||||
# the directory where the Cantera libraries are located
|
||||
CANTERA_LIBDIR=@buildlib@
|
||||
|
||||
# required Cantera libraries
|
||||
CANTERA_LIBS = @LOCAL_LIBS@ -lctcxx
|
||||
|
||||
# the directory where Cantera include files may be found.
|
||||
ifeq ($(src_dir_tree), 1)
|
||||
CANTERA_INCDIR=../../../Cantera/src
|
||||
INCLUDES=-I$(CANTERA_INCDIR) -I$(CANTERA_INCDIR)/thermo
|
||||
else
|
||||
CANTERA_INCDIR=@ctroot@/build/include/cantera
|
||||
INCLUDES=-I$(CANTERA_INCDIR) -I$(CANTERA_INCDIR)/kernel
|
||||
endif
|
||||
|
||||
# flags passed to the C++ compiler/linker for the linking step
|
||||
LCXX_FLAGS = -L$(CANTERA_LIBDIR) @LOCAL_LIB_DIRS@ @CXXFLAGS@
|
||||
|
||||
# How to compile C++ source files to object files
|
||||
.@CXX_EXT@.@OBJ_EXT@:
|
||||
$(CXX) -c $< $(INCLUDES) $(CXX_FLAGS)
|
||||
|
||||
# How to compile the dependency file
|
||||
.cpp.d:
|
||||
g++ -MM $(INCLUDES) $(CXX_FLAGS) $*.cpp > $*.d
|
||||
|
||||
# List of dependency files to be created
|
||||
DEPENDS=$(OBJS:.o=.d)
|
||||
|
||||
# Program Name
|
||||
PROGRAM = $(PROG_NAME)$(EXE_EXT)
|
||||
|
||||
all: $(PROGRAM) .depends
|
||||
|
||||
$(PROGRAM): $(OBJS) $(CANTERA_LIBDIR)/libcantera.a
|
||||
$(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \
|
||||
$(CANTERA_LIBS) @LIBS@ $(FORT_LIBS) \
|
||||
$(LCXX_END_LIBS)
|
||||
|
||||
# depends target -> forces recalculation of dependencies
|
||||
depends:
|
||||
$(RM) *.d .depends
|
||||
@MAKE@ .depends
|
||||
|
||||
.depends: $(DEPENDS)
|
||||
cat *.d > .depends
|
||||
|
||||
# Do the test -> For the windows vc++ environment, we have to skip checking on
|
||||
# whether the program is uptodate, because we don't utilize make
|
||||
# in that environment to build programs.
|
||||
test:
|
||||
ifeq ($(os_is_win), 1)
|
||||
else
|
||||
@MAKE@ $(PROGRAM)
|
||||
endif
|
||||
./runtest
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) $(PROGRAM) $(DEPENDS) .depends
|
||||
../../../bin/rm_cvsignore
|
||||
(if test -d SunWS_cache ; then \
|
||||
$(RM) -rf SunWS_cache ; \
|
||||
fi )
|
||||
|
||||
18
test_problems/cathermo/issp/output_blessed.txt
Normal file
18
test_problems/cathermo/issp/output_blessed.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
molar enthalpy = 2.6802e+07 J kg-1
|
||||
molar intEnergy = 2.6677e+07 J kg-1
|
||||
molar entropy = 1.7927e+05 J kg-1 K-1
|
||||
molar gibbs = -1.8833e+08 J kg-1
|
||||
molar Cp = 31000 J kg-1 K-1
|
||||
mixture density = 12.274 kg m-3
|
||||
molar density = 0.80645 kmol m-3
|
||||
mean molecular weight = 15.22 kg kmol-1
|
||||
Printout of standard state properties
|
||||
Name mu_i H_i_SS S_i_SS Cp_i_SS Vol_i_SS
|
||||
C2H2-graph -1.7937e+08 2.6802e+07 2.0617e+08 31000 1.5
|
||||
C-graph -1.7937e+08 2.6802e+07 2.0617e+08 31000 1.3
|
||||
H2-solute -1.7937e+08 2.6802e+07 2.0617e+08 31000 0.1
|
||||
Printout of Partial molar properties
|
||||
Name mu_i H_i_PM S_i_PM Cp_i_PM Vol_i_PM
|
||||
C2H2-graph -1.9138e+08 2.6802e+07 1.8182e+05 31000 1.5
|
||||
C-graph -1.8446e+08 2.6802e+07 1.7606e+05 31000 1.3
|
||||
H2-solute -2.0234e+08 2.6802e+07 1.9095e+05 31000 0.1
|
||||
32
test_problems/cathermo/issp/runtest
Executable file
32
test_problems/cathermo/issp/runtest
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
temp_success="1"
|
||||
/bin/rm -f output.txt outputa.txt
|
||||
|
||||
#################################################################
|
||||
#
|
||||
#################################################################
|
||||
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
|
||||
|
||||
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
|
||||
./ISSPTester > output.txt
|
||||
retnStat=$?
|
||||
if [ $retnStat != "0" ]
|
||||
then
|
||||
temp_success="0"
|
||||
echo "ISSPTester returned with bad status, $retnStat, check output"
|
||||
fi
|
||||
|
||||
$CANTERA_BIN/exp3to2.sh output.txt > outputa.txt
|
||||
diff -w outputa.txt output_blessed.txt > diff_test.out
|
||||
retnStat=$?
|
||||
if [ $retnStat = "0" ]
|
||||
then
|
||||
echo "successful diff comparison on ISSPTester test"
|
||||
else
|
||||
echo "unsuccessful diff comparison on ISSPTester test"
|
||||
echo "FAILED" > csvCode.txt
|
||||
temp_success="0"
|
||||
fi
|
||||
|
||||
Loading…
Add table
Reference in a new issue