Added a test for nComponents < number of elements

This commit is contained in:
Harry Moffat 2007-01-02 00:31:55 +00:00
parent d978389e98
commit 2550449514
6 changed files with 1640 additions and 0 deletions

View file

@ -0,0 +1,5 @@
basopt_red1
Makefile
output.txt
csvCode.txt
diff_test.out

View file

@ -0,0 +1,110 @@
#!/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 = basopt_red1
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = basopt_red1.o
# Location of the current build. Will assume that tests are run
# in the source directory tree location
src_dir_tree = 0
# 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
else
CANTERA_INCDIR=@ctroot@/build/include/cantera
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 $< -I$(CANTERA_INCDIR) $(CXX_FLAGS)
# How to compile the dependency file
.cpp.d:
@CXX_DEPENDS@ -I$(CANTERA_INCDIR) $(CXX_FLAGS) $*.cpp > $*.d
# List of dependency files to be created
DEPENDS=$(OBJS:.o=.d)
# Program Name
PROGRAM = $(PROG_NAME)$(EXE_EXT)
all: $(PROGRAM)
$(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@ -s $(PROGRAM)
endif
@ ./runtest
clean:
$(RM) $(OBJS) $(PROGRAM) $(DEPENDS) .depends
../../bin/rm_cvsignore
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )

View file

@ -0,0 +1,70 @@
/*
* $Author$
* $Date$
* $Revision$
*
*/
#ifdef SRCDIRTREE
#include "ct_defs.h"
#include "ThermoPhase.h"
#include "IdealGasMix.h"
#include "equil.h"
#else
#include "Cantera.h"
#include "IdealGasMix.h"
#include "equilibrium.h"
#endif
using namespace std;
using namespace Cantera;
#ifdef DEBUG_HKM
extern int debug_print_lvl;
extern int debug_prnt_lvl;
#endif
int main(int argc, char **argv) {
try {
IdealGasMix g("red1.xml", "gri30_mix");
#ifdef DEBUG_HKM
debug_print_lvl = 0;
debug_prnt_lvl = 0;
#endif
double pres = 1.0E5;
g.setState_TPX(2000.0, pres, "C2H2:0.9, CH:0.1");
MultiPhase mphase;
mphase.addPhase(&g, 10.0);
mphase.init();
int usedZeroedSpecies = 0;
vector_int orderVectorSpecies;
vector_int orderVectorElements;
bool doFormMatrix = true;
vector_fp formRxnMatrix;
int nc = BasisOptimize(&usedZeroedSpecies, doFormMatrix,
&mphase, orderVectorSpecies,
orderVectorElements,
formRxnMatrix);
cout << "number of components = " << nc << endl;
/*
* The ChemEquil solver throws an error for this case.
* The MultiPhaseEquil solver just gets the wrong result.
*/
equilibrate(g, "TP", -1);
cout << g;
return 0;
}
catch (CanteraError) {
showErrors(cerr);
cerr << "program terminating." << endl;
return -1;
}
}

View file

@ -0,0 +1,22 @@
number of components = 1
gri30_mix:
temperature 2000 K
pressure 100000 Pa
density 0.156582 kg/m^3
mean mol. weight 26.0379 amu
1 kg 1 kmol
----------- ------------
enthalpy 1.32407e+07 3.448e+08 J
internal energy 1.26021e+07 3.281e+08 J
entropy 12321.9 3.208e+05 J/K
Gibbs function -1.1403e+07 -2.969e+08 J
heat capacity c_p 3110.34 8.099e+04 J/K
heat capacity c_v 2791.01 7.267e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
CH 5.94369e-09 2.97184e-09 -8.9275
C2H2 1 1 -17.855

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
#!/bin/sh
#
#
temp_success="1"
/bin/rm -f output.txt outputa.txt
testName="baseopt_red1"
#################################################################
#
#################################################################
CANTERA_DATA=${CANTERA_DATA:=../../data/inputs}; export CANTERA_DATA
CANTERA_BIN=${CANTERA_BIN:=../../bin}
./basopt_red1 > output.txt
retnStat=$?
if [ $retnStat != "0" ]
then
temp_success="0"
echo "$testName returned with bad status, $retnStat, check output"
fi
diff -w output.txt output_blessed.txt > diff_test.out
retnStat=$?
if [ $retnStat = "0" ]
then
echo "successful diff comparison on $testName test"
else
echo "unsuccessful diff comparison on $testName test"
echo "FAILED" > csvCode.txt
temp_success="0"
fi