cantera/test_problems/ChemEquil_red1/basopt_red1.cpp
Ray Speth b88846e5e0 Fixed C++ tests that were failing under Windows
Visual Studio defaults to 3-digit exponents when printing in scientific
notation. The tests now use a MSVC-specific function to change this
behavior when necessary.
2012-01-09 17:35:28 +00:00

57 lines
1.3 KiB
C++

#include "cantera/Cantera.h"
#include "cantera/IdealGasMix.h"
#include "cantera/equilibrium.h"
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {
IdealGasMix g("red1.xml", "gri30_mix");
#ifdef DEBUG_BASISOPTIMIZE
Cantera::BasisOptimize_print_lvl = 0;
#endif
#ifdef DEBUG_CHEMEQUIL
Cantera::ChemEquil_print_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;
}
}