diff --git a/Cantera/clib/src/ct.cpp b/Cantera/clib/src/ct.cpp index e6c33cbe8..9a5fa36d0 100755 --- a/Cantera/clib/src/ct.cpp +++ b/Cantera/clib/src/ct.cpp @@ -1,1282 +1,1283 @@ -/** - * @file ct.cpp - * Cantera interface library. This library of functions is designed - * to encapsulate Cantera functionality and make it available for - * use in languages and applications other than C++. A set of - * library functions is provided that are declared "extern C". All - * Cantera objects are stored and referenced by integers - no - * pointers are passed to or from the calling application. - */ - -/* $Id$ */ - -// turn off warnings under Windows -#ifdef WIN32 -#pragma warning(disable:4786) -#pragma warning(disable:4503) -#endif - -#define CANTERA_USE_INTERNAL -#include "ct.h" - -// Cantera includes -#include "equil.h" -#include "KineticsFactory.h" -#include "TransportFactory.h" -#include "ctml.h" -#include "importKinetics.h" -#include "ThermoFactory.h" -#include "ck2ct.h" -#include "Storage.h" -#include "Cabinet.h" -#include "InterfaceKinetics.h" -#include "PureFluidPhase.h" - - -using namespace std; -using namespace Cantera; - -#ifdef WIN32 -#include "windows.h" -#endif - - -inline XML_Node* _xml(int i) { - return Cabinet::cabinet(false)->item(i); -} - - -#ifdef WITH_PURE_FLUIDS -static PureFluidPhase* purefluid(int n) { - try { - ThermoPhase* tp = th(n); - if (tp->eosType() == cPureFluid) { - return (PureFluidPhase*)tp; - } - else { - throw CanteraError("purefluid","object is not a PureFluidPhase object"); - } - } - catch (CanteraError) { - return 0; - } -} - -static double pfprop(int n, int i, double v=0.0, double x=0.0) { - PureFluidPhase* p = purefluid(n); - if (p) { - switch(i) { - case 0: return p->critTemperature(); - case 1: return p->critPressure(); - case 2: return p->critDensity(); - case 3: return p->vaporFraction(); - case 4: return p->satTemperature(v); - case 5: return p->satPressure(v); - case 6: p->setState_Psat(v, x); return 0.0; - case 7: p->setState_Tsat(v, x); return 0.0; - } - } - return DERR; -} - - -#else - -static ThermoPhase* purefluid(int n) { - return th(n); -} -static double pfprop(int n, int i, double v=0.0, double x=0.0) { - return DERR; -} -#endif - - -inline int nThermo() { - return Storage::storage()->nThermo(); -} - -namespace Cantera { - void writephase(const ThermoPhase& th, bool show_thermo); -} - -/** - * Exported functions. - */ -extern "C" { - -#ifdef WIN32 -#ifndef NO_DLL_BUILD - /* - * The microsoft docs says we may need this in some - * cases when building dll's - */ - /* - bool WINAPI DllMain(HINSTANCE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) { - switch(ul_reason_for_call ) { - case DLL_PROCESS_ATTACH: - break; - case DLL_THREAD_ATTACH: - break; - case DLL_THREAD_DETACH: - break; - case DLL_PROCESS_DETACH: - break; - } - return TRUE; - } - */ -#endif -#endif - - int DLL_EXPORT ct_appdelete() { - appdelete(); - return 0; - } - - //--------------- Phase ---------------------// - - int DLL_EXPORT phase_nElements(int n) { - return ph(n)->nElements(); - } - - int DLL_EXPORT phase_nSpecies(int n) { - return ph(n)->nSpecies(); - } - - doublereal DLL_EXPORT phase_temperature(int n) { - return ph(n)->temperature(); - } - - int DLL_EXPORT phase_setTemperature(int n, double t) { - try { - ph(n)->setTemperature(t); - } - catch(CanteraError) {return -1;} - return 0; - } - - doublereal DLL_EXPORT phase_density(int n) { - return ph(n)->density(); - } - - int DLL_EXPORT phase_setDensity(int n, double rho) { - if (rho < 0.0) return -1; - ph(n)->setDensity(rho); - return 0; - } - - doublereal DLL_EXPORT phase_molarDensity(int n) { - return ph(n)->molarDensity(); - } - - int DLL_EXPORT phase_setMolarDensity(int n, double ndens) { - if (ndens < 0.0) return -1; - ph(n)->setMolarDensity(ndens); - return 0; - } - - doublereal DLL_EXPORT phase_meanMolecularWeight(int n) { - return ph(n)->meanMolecularWeight(); - } - - int DLL_EXPORT phase_elementIndex(int n, char* nm) { - string elnm = string(nm); - return ph(n)->elementIndex(elnm); - } - - int DLL_EXPORT phase_speciesIndex(int n, char* nm) { - string spnm = string(nm); - return ph(n)->speciesIndex(spnm); - } - - int DLL_EXPORT phase_getMoleFractions(int n, int lenx, double* x) { - ThermoPhase* p = ph(n); - if (lenx >= p->nSpecies()) { - p->getMoleFractions(x); - return 0; - } - else - return -1; - } - - doublereal DLL_EXPORT phase_moleFraction(int n, int k) { - ThermoPhase* p = ph(n); - return p->moleFraction(k); - } - - int DLL_EXPORT phase_getMassFractions(int n, int leny, double* y) { - ThermoPhase* p = ph(n); - if (leny >= p->nSpecies()) { - p->getMassFractions(y); - return 0; - } - else - return -1; - } - - doublereal DLL_EXPORT phase_massFraction(int n, int k) { - ThermoPhase* p = ph(n); - return p->massFraction(k); - } - - int DLL_EXPORT phase_setMoleFractions(int n, int lenx, double* x, int norm) { - ThermoPhase* p = ph(n); - if (lenx >= p->nSpecies()) { - if (norm) p->setMoleFractions(x); - else p->setMoleFractions_NoNorm(x); - return 0; - } - else - return -1; - } - - int DLL_EXPORT phase_setMoleFractionsByName(int n, char* x) { - try { - ThermoPhase* p = ph(n); - compositionMap xx; - int nsp = p->nSpecies(); - for (int n = 0; n < nsp; n++) { - xx[p->speciesName(n)] = -1; - } - parseCompString(string(x), xx); - p->setMoleFractionsByName(xx); - return 0; - } - catch (CanteraError) {return -1;} - //catch (...) {return ERR;} - } - - int DLL_EXPORT phase_setMassFractions(int n, int leny, - double* y, int norm) { - ThermoPhase* p = ph(n); - if (leny >= p->nSpecies()) { - if (norm) p->setMassFractions(y); - else p->setMassFractions_NoNorm(y); - return 0; - } - else - return -10; - } - - int DLL_EXPORT phase_setMassFractionsByName(int n, char* y) { - try { - ThermoPhase* p = ph(n); - compositionMap yy; - int nsp = p->nSpecies(); - for (int n = 0; n < nsp; n++) { - yy[p->speciesName(n)] = -1; - } - parseCompString(string(y), yy); - p->setMassFractionsByName(yy); - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT phase_getAtomicWeights(int n, - int lenm, double* atw) { - ThermoPhase* p = ph(n); - if (lenm >= p->nElements()) { - const vector_fp& wt = p->atomicWeights(); - copy(wt.begin(), wt.end(), atw); - return 0; - } - else - return -10; - } - - int DLL_EXPORT phase_getMolecularWeights(int n, - int lenm, double* mw) { - ThermoPhase* p = ph(n); - if (lenm >= p->nSpecies()) { - const vector_fp& wt = p->molecularWeights(); - copy(wt.begin(), wt.end(), mw); - return 0; - } - else - return -10; - } - - int DLL_EXPORT phase_getName(int n, int lennm, char* nm) { - string name = ph(n)->name(); - int lout = (int) min(lennm, (int) name.size()); - copy(name.c_str(), name.c_str() + lout, nm); - nm[lout] = '\0'; - return 0; - } - - int DLL_EXPORT phase_setName(int n, const char* nm) { - string name = string(nm); - ph(n)->setName(name); - return 0; - } - - int DLL_EXPORT phase_getSpeciesName(int n, int k, int lennm, char* nm) { - try { - string spnm = ph(n)->speciesName(k); - int lout = min(lennm, (int) spnm.size()); - copy(spnm.c_str(), spnm.c_str() + lout, nm); - nm[lout] = '\0'; - return 0; - } - catch (CanteraError) { return -1; } - //catch (...) {return ERR;} - } - - int DLL_EXPORT phase_getElementName(int n, int m, int lennm, char* nm) { - try { - string elnm = ph(n)->elementName(m); - int lout = min(lennm, (int) elnm.size()); - copy(elnm.c_str(), elnm.c_str() + lout, nm); - nm[lout] = '\0'; - return 0; - } - catch (CanteraError) { return -1; } - } - - - doublereal DLL_EXPORT phase_nAtoms(int n, int k, int m) { - try { - return ph(n)->nAtoms(k,m); - } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT phase_addElement(int n, char* name, doublereal weight) { - try { - ph(n)->addElement(string(name),weight); - return 0; - } - catch (CanteraError) { return -1; } - } - -// int DLL_EXPORT phase_addSpecies(int n, char* name, int phase, -// int ncomp, doublereal* comp, int thermoType, int ncoeffs, -// double* coeffs, double minTemp, double maxTemp, double refPressure, -// doublereal charge, doublereal weight) { -// try { -// vector_fp cmp(ncomp); -// copy(comp, comp + ncomp, cmp.begin()); -// vector_fp c(ncoeffs); -// copy(coeffs, coeffs + ncoeffs, c.begin()); -// ph(n)->addSpecies(string(name), phase, cmp, -// thermoType, c, minTemp, maxTemp, refPressure, -// charge, weight); -// return 0; -// } -// catch (CanteraError) { return -1; } -// catch (...) {return ERR;} -// } - - - - //-------------- Thermo --------------------// - - // int DLL_EXPORT newThermo(int eos, int ph, int sptherm) { - // return Storage::storage()->addNewThermo(eos, ph, sptherm); - // } - - int DLL_EXPORT th_thermoIndex(char* id) { - return thermo_index(id); - } - -// int DLL_EXPORT newThermo(char* model) { -// try { -// string m = string(model); -// thermo_t* th = newThermoPhase(m); -// return Storage::storage()->addThermo(th); -// } -// catch (CanteraError) { return -1; } -// } - - int DLL_EXPORT newThermoFromXML(int mxml) { - try { - XML_Node* x = _xml(mxml); - thermo_t* th = newPhase(*x); - return Storage::storage()->addThermo(th); - } - catch (CanteraError) { return -1; } - } - - //int DLL_EXPORT th_phase(int n) { - // return th(n)->phase().index(); - // } - - int DLL_EXPORT th_nSpecies(int n) { - return th(n)->nSpecies(); - } - - int DLL_EXPORT th_eosType(int n) { - return th(n)->eosType(); - } - - double DLL_EXPORT th_enthalpy_mole(int n) { - try {return th(n)->enthalpy_mole();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_intEnergy_mole(int n) { - try {return th(n)->intEnergy_mole();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_entropy_mole(int n) { - try {return th(n)->entropy_mole();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_gibbs_mole(int n) { - try {return th(n)->gibbs_mole();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_cp_mole(int n) { - try {return th(n)->cp_mole();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_cv_mole(int n) { - try {return th(n)->cv_mole();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_pressure(int n) { - try {return th(n)->pressure();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_enthalpy_mass(int n) { - try {return th(n)->enthalpy_mass();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_intEnergy_mass(int n) { - try {return th(n)->intEnergy_mass();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_entropy_mass(int n) { - try {return th(n)->entropy_mass();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_gibbs_mass(int n) { - try {return th(n)->gibbs_mass();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_cp_mass(int n) { - try {return th(n)->cp_mass();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_cv_mass(int n) { - try {return th(n)->cv_mass();} - catch (CanteraError) {return DERR;} - } - - double DLL_EXPORT th_electricPotential(int n) { - try {return th(n)->electricPotential();} - catch (CanteraError) {return DERR;} - } - - int DLL_EXPORT th_chemPotentials(int n, int lenm, double* murt) { - thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); - if (lenm >= nsp) { - thrm->getChemPotentials(murt); - return 0; - } - else - return -10; - } - - int DLL_EXPORT th_elementPotentials(int n, int lenm, double* lambda) { - thermo_t* thrm = th(n); - int nel = thrm->nElements(); - if (lenm >= nel) { - equilibrate(*thrm, "TP", 0); - thrm->getElementPotentials(lambda); - return 0; - } - else - return -10; - } - - int DLL_EXPORT th_setPressure(int n, double p) { - try { - if (p < 0.0) throw CanteraError("th_setPressure", - "pressure cannot be negative"); - th(n)->setPressure(p); - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_set_HP(int n, double* vals) { - try { - if (vals[1] < 0.0) - throw CanteraError("th_set_HP", - "pressure cannot be negative"); - th(n)->setState_HP(vals[0],vals[1]); - if (th(n)->temperature() < 0.0) - throw CanteraError("th_set_HP", - "temperature cannot be negative"); - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_set_UV(int n, double* vals) { - try { - if (vals[1] < 0.0) - throw CanteraError("th_set_UV", - "specific volume cannot be negative"); - th(n)->setState_UV(vals[0],vals[1]); - if (th(n)->temperature() < 0.0) - throw CanteraError("th_set_UV", - "temperature cannot be negative"); - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_set_SV(int n, double* vals) { - try { - th(n)->setState_SV(vals[0],vals[1]); - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_set_SP(int n, double* vals) { - try { - th(n)->setState_SP(vals[0],vals[1]); - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_equil(int n, char* XY, int solver, - double rtol, int maxsteps, int maxiter, int loglevel) { - try { - equilibrate(*th(n), XY, solver, rtol, maxsteps, - maxiter, loglevel); return 0; - } - catch (CanteraError) { - return -1; - } - } - - doublereal DLL_EXPORT th_refPressure(int n) { - return th(n)->refPressure(); - } - - doublereal DLL_EXPORT th_minTemp(int n, int k) { - return th(n)->minTemp(k); - } - - doublereal DLL_EXPORT th_maxTemp(int n, int k) { - return th(n)->maxTemp(k); - } - - - int DLL_EXPORT th_getEnthalpies_RT(int n, int lenm, double* h_rt) { - try { - thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); - if (lenm >= nsp) { - thrm->getEnthalpy_RT_ref(h_rt); - return 0; - } - else - return -10; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_getEntropies_R(int n, int lenm, double* s_r) { - try { - thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); - if (lenm >= nsp) { - thrm->getEntropy_R_ref(s_r); - return 0; - } - else - return -10; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_getCp_R(int n, int lenm, double* cp_r) { - try { - thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); - if (lenm >= nsp) { - thrm->getCp_R_ref(cp_r); - return 0; - } - else - return -10; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT th_setElectricPotential(int n, double v) { - th(n)->setElectricPotential(v); - return 0; - } - - //-------------- pure fluids ---------------// -#ifdef WITH_PURE_FLUIDS - - double DLL_EXPORT th_critTemperature(int n) { - return pfprop(n,0); - } - - double DLL_EXPORT th_critPressure(int n) { - return purefluid(n)->critPressure(); - } - - double DLL_EXPORT th_critDensity(int n) { - return purefluid(n)->critDensity(); - } - - double DLL_EXPORT th_vaporFraction(int n) { - return purefluid(n)->vaporFraction(); - } - - double DLL_EXPORT th_satTemperature(int n, double p) { - try { - return purefluid(n)->satTemperature(p); - } - catch (CanteraError) { return DERR; } - } - - double DLL_EXPORT th_satPressure(int n, double t) { - try { - return purefluid(n)->satPressure(t); - } - catch (CanteraError) { return DERR; } - } - - int DLL_EXPORT th_setState_Psat(int n, double p, double x) { - try { - purefluid(n)->setState_Psat(p, x); - return 0; - } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT th_setState_Tsat(int n, double t, double x) { - try { - purefluid(n)->setState_Tsat(t, x); - return 0; - } - catch (CanteraError) { return -1; } - } -#else - - double DLL_EXPORT th_critTemperature(int n) { - return DERR; - } - - double DLL_EXPORT th_critPressure(int n) { - return DERR; - } - - double DLL_EXPORT th_critDensity(int n) { - return DERR; - } - - double DLL_EXPORT th_vaporFraction(int n) { - return DERR; - } - - double DLL_EXPORT th_satTemperature(int n, double p) { - return DERR; - } - - double DLL_EXPORT th_satPressure(int n, double t) { - return DERR; - } - - int DLL_EXPORT th_setState_Psat(int n, double p, double x) { - return DERR; - } - - int DLL_EXPORT th_setState_Tsat(int n, double t, double x) { - return DERR; - } -#endif - - - - //-------------- Kinetics ------------------// - - int DLL_EXPORT newKineticsFromXML(int mxml, int iphase, - int neighbor1, int neighbor2, int neighbor3, - int neighbor4) { - try { - XML_Node* x = _xml(mxml); - vector phases; - phases.push_back(th(iphase)); - if (neighbor1 >= 0) { - phases.push_back(th(neighbor1)); - if (neighbor2 >= 0) { - phases.push_back(th(neighbor2)); - if (neighbor3 >= 0) { - phases.push_back(th(neighbor3)); - if (neighbor4 >= 0) { - phases.push_back(th(neighbor4)); - } - } - } - } - Kinetics* kin = newKineticsMgr(*x, phases); - if (kin) - return Storage::storage()->addKinetics(kin); - else - return 0; - } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT installRxnArrays(int pxml, int ikin, - char* default_phase) { - try { - XML_Node* p = _xml(pxml); - kinetics_t* k = kin(ikin); - string defphase = string(default_phase); - installReactionArrays(*p, *k, defphase); - return 0; - } - catch (CanteraError) { return -1; } - } - - //------------------------------------- - int DLL_EXPORT kin_type(int n) { - return kin(n)->type(); - } - - int DLL_EXPORT kin_start(int n, int p) { - return kin(n)->kineticsSpeciesIndex(0,p); - } - - int DLL_EXPORT kin_speciesIndex(int n, const char* nm, const char* ph) { - return kin(n)->kineticsSpeciesIndex(string(nm), string(ph)); - } - - //--------------------------------------- - - int DLL_EXPORT kin_nSpecies(int n) { - return kin(n)->nTotalSpecies(); - } - - int DLL_EXPORT kin_nReactions(int n) { - return kin(n)->nReactions(); - } - - int DLL_EXPORT kin_nPhases(int n) { - return kin(n)->nPhases(); - } - - int DLL_EXPORT kin_phaseIndex(int n, char* ph) { - return kin(n)->phaseIndex(string(ph)); - } - - int DLL_EXPORT kin_reactionPhaseIndex(int n) { - return kin(n)->reactionPhaseIndex(); - } - - double DLL_EXPORT kin_reactantStoichCoeff(int n, int k, int i) { - return kin(n)->reactantStoichCoeff(k,i); - } - - double DLL_EXPORT kin_productStoichCoeff(int n, int k, int i) { - return kin(n)->productStoichCoeff(k,i); - } - - int DLL_EXPORT kin_reactionType(int n, int i) { - return kin(n)->reactionType(i); - } - - int DLL_EXPORT kin_getFwdRatesOfProgress(int n, int len, double* fwdROP) { - Kinetics* k = kin(n); - try { - if (len >= k->nReactions()) { - k->getFwdRatesOfProgress(fwdROP); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_getRevRatesOfProgress(int n, int len, double* revROP) { - Kinetics* k = kin(n); - try { - if (len >= k->nReactions()) { - k->getRevRatesOfProgress(revROP); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_isReversible(int n, int i) { - return (int)kin(n)->isReversible(i); - } - - int DLL_EXPORT kin_getNetRatesOfProgress(int n, int len, double* netROP) { - try { - Kinetics* k = kin(n); - if (len >= k->nReactions()) { - k->getNetRatesOfProgress(netROP); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_getFwdRateConstants(int n, int len, double* kfwd) { - try { - Kinetics* k = kin(n); - if (len >= k->nReactions()) { - k->getFwdRateConstants(kfwd); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_getRevRateConstants(int n, int doIrreversible, int len, double* krev) { - try { - Kinetics* k = kin(n); - bool doirrev = false; - if (doIrreversible != 0) doirrev = true; - if (len >= k->nReactions()) { - k->getRevRateConstants(krev, doirrev); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - - int DLL_EXPORT kin_getActivationEnergies(int n, int len, double* E) { - try { - Kinetics* k = kin(n); - if (len >= k->nReactions()) { - k->getActivationEnergies(E); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - - int DLL_EXPORT kin_getDelta(int n, int job, int len, double* delta) { - try { - Kinetics* k = kin(n); - if (len < k->nReactions()) return ERR; - switch (job) { - case 0: - k->getDeltaEnthalpy(delta); break; - case 1: - k->getDeltaGibbs(delta); break; - case 2: - k->getDeltaEntropy(delta); break; - case 3: - k->getDeltaSSEnthalpy(delta); break; - case 4: - k->getDeltaSSGibbs(delta); break; - case 5: - k->getDeltaSSEntropy(delta); break; - default: - return ERR; - } - return 0; - } - catch (CanteraError) {return -1;} - } - - - int DLL_EXPORT kin_getDeltaEntropy(int n, int len, double* deltaS) { - try { - Kinetics* k = kin(n); - if (len >= k->nReactions()) { - k->getDeltaEntropy(deltaS); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - - int DLL_EXPORT kin_getCreationRates(int n, int len, double* cdot) { - try { - Kinetics* k = kin(n); - if (len >= k->nTotalSpecies()) { - k->getCreationRates(cdot); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_getDestructionRates(int n, int len, double* ddot) { - try { - Kinetics* k = kin(n); - if (len >= k->nTotalSpecies()) { - k->getDestructionRates(ddot); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - //catch (...) {return ERR;} - } - - int DLL_EXPORT kin_getNetProductionRates(int n, int len, double* wdot) { - try { - Kinetics* k = kin(n); - if (len >= k->nTotalSpecies()) { - k->getNetProductionRates(wdot); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_getSourceTerms(int n, int len, double* ydot) { - try { - Kinetics* k = kin(n); - ThermoPhase* p = &k->thermo(); - const vector_fp& mw = p->molecularWeights(); - int nsp = static_cast(mw.size()); - double rrho = 1.0/p->density(); - if (len >= nsp) { - k->getNetProductionRates(ydot); - multiply_each(ydot, ydot + nsp, mw.begin()); - scale(ydot, ydot + nsp, ydot, rrho); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - double DLL_EXPORT kin_multiplier(int n, int i) { - return kin(n)->multiplier(i); - } - - int DLL_EXPORT kin_phase(int n, int i) { - return kin(n)->thermo(i).index(); - // return thermo_index(kin(n)->thermo(i).id()); - } - - int DLL_EXPORT kin_getEquilibriumConstants(int n, int len, double* kc) { - try { - Kinetics* k = kin(n); - if (len >= k->nReactions()) { - k->getEquilibriumConstants(kc); - return 0; - } - else - return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_getReactionString(int n, int i, int len, char* buf) { - try { - Kinetics* k = kin(n); - string r = k->reactionString(i); - int lout = min(len, (int)r.size()); - copy(r.c_str(), r.c_str() + lout, buf); - buf[lout] = '\0'; - return 0; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_setMultiplier(int n, int i, double v) { - try { - if (v >= 0.0) { - kin(n)->setMultiplier(i,v); - return 0; - } - else return ERR; - } - catch (CanteraError) {return -1;} - } - - int DLL_EXPORT kin_advanceCoverages(int n, double tstep) { - try { - Kinetics* k = kin(n); - if (k->type() == cInterfaceKinetics) { - ((InterfaceKinetics*)k)->advanceCoverages(tstep); - } - else { - throw CanteraError("kin_advanceCoverages", - "wrong kinetics manager type"); - } - return 0; - } - catch (CanteraError) {return -1;} - } - - //------------------- Transport --------------------------- - - int DLL_EXPORT newTransport(char* model, - int ith, int loglevel) { - string mstr = string(model); - thermo_t* t = th(ith); - try { - Transport* tr = newTransportMgr(mstr,t, loglevel); - return Storage::storage()->addTransport(tr); - } - catch (CanteraError) { return -1; } - } - - double DLL_EXPORT trans_viscosity(int n) { - try {return trans(n)->viscosity();} - catch (CanteraError) { return -1.0; } - } - - double DLL_EXPORT trans_thermalConductivity(int n) { - try {return trans(n)->thermalConductivity();} - catch (CanteraError) { return -1.0; } - } - - int DLL_EXPORT trans_getThermalDiffCoeffs(int n, int ldt, double* dt) { - try { trans(n)->getThermalDiffCoeffs(dt); return 0; } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT trans_getMixDiffCoeffs(int n, int ld, double* d) { - try { trans(n)->getMixDiffCoeffs(d); return 0;} - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT trans_getBinDiffCoeffs(int n, int ld, double* d) { - try { trans(n)->getBinaryDiffCoeffs(ld,d); return 0;} - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT trans_getMultiDiffCoeffs(int n, int ld, double* d) { - try { trans(n)->getMultiDiffCoeffs(ld,d); return 0;} - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT trans_setParameters(int n, int type, int k, double* d) { - try { trans(n)->setParameters(type, k, d); return 0;} - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT trans_getMolarFluxes(int n, const double* state1, - const double* state2, double delta, double* fluxes) { - try { - trans(n)->getMolarFluxes(state1, state2, delta, fluxes); - return 0; - } - catch (CanteraError) { return -1; } - } - - //-------------------- Functions --------------------------- - - int DLL_EXPORT import_phase(int nth, int nxml, char* id) { - thermo_t* thrm = th(nth); - XML_Node* node = _xml(nxml); - string idstr = string(id); - try { - importPhase(*node, thrm); - return 0; - } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT import_kinetics(int nxml, char* id, - int nphases, integer* ith, int nkin) { - vector phases; - for (int i = 0; i < nphases; i++) { - phases.push_back(th(ith[i])); - } - XML_Node* node = _xml(nxml); - Kinetics* k = kin(nkin); - string idstr = string(id); - try { - importKinetics(*node, phases, k); - return 0; - } - catch (CanteraError) { return -1; } - } - - - int DLL_EXPORT phase_report(int nth, - int ibuf, char* buf, int show_thermo) { - try { - bool stherm = (show_thermo != 0); - string s = report(*th(nth), stherm); - if (int(s.size()) > ibuf - 1) { - return -(static_cast(s.size()) + 1); - } - copy(s.begin(), s.end(), buf); - buf[s.size() - 1] = '\0'; - return 0; - - } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT write_phase(int nth, int show_thermo) { - try { - bool stherm = (show_thermo != 0); - writephase(*th(nth), stherm); - return 0; - } - catch (CanteraError) { return -1; } - } - - int DLL_EXPORT write_HTML_log(char* file) { - write_logfile(string(file)); - return 0; - } - - int DLL_EXPORT getCanteraError(int buflen, char* buf) { - string e; - e = lastErrorMessage(); - if (buflen > 0) { - int n = min(static_cast(e.size()), buflen-1); - copy(e.begin(), e.begin() + n, buf); - buf[min(n, buflen-1)] = '\0'; - } - return int(e.size()); - } - - int DLL_EXPORT showCanteraErrors() { - showErrors(); - return 0; - } - - int DLL_EXPORT addCanteraDirectory(int buflen, char* buf) { - addDirectory(string(buf)); - return 0; - } - - int DLL_EXPORT setLogWriter(void* logger) { - Logger* logwriter = (Logger*)logger; - setLogger(logwriter); - return 0; - } - - int DLL_EXPORT readlog(int n, char* buf) { - string s; - writelog("function readlog is deprecated!"); - //getlog(s); - int nlog = static_cast(s.size()); - if (n < 0) return nlog; - int nn = min(n-1, nlog); - copy(s.begin(), s.begin() + nn, - buf); - buf[min(nlog, n-1)] = '\0'; - //clearlog(); - return 0; - - } - int DLL_EXPORT clearStorage() { - try { - Storage::storage()->clear(); - return 0; - } - catch (CanteraError) { - return -1; - } - } - - int DLL_EXPORT delThermo(int n) { - try { - Storage::storage()->deleteThermo(n); - return 0; - } - catch (CanteraError) { - return -1; - } - } - - int DLL_EXPORT delKinetics(int n) { - Storage::storage()->deleteKinetics(n); - return 0; - } - - int DLL_EXPORT delTransport(int n) { - Storage::storage()->deleteTransport(n); - return 0; - } - - int DLL_EXPORT buildSolutionFromXML(char* src, int ixml, char* id, - int ith, int ikin) { - - XML_Node* root = 0; - if (ixml > 0) root = _xml(ixml); - - thermo_t* t = th(ith); - kinetics_t* k = kin(ikin); - - Kinetics& kin = *k; - XML_Node *x, *r=0; - if (root) r = &root->root(); - x = get_XML_Node(string(src), r); - //x = find_XML(string(src), r, string(id), "", "phase"); - if (!x) return false; - importPhase(*x, t); - kin.addPhase(*t); - kin.init(); - installReactionArrays(*x, kin, x->id()); - t->setState_TP(300.0, OneAtm); - if (r) { - if (&x->root() != &r->root()) delete &x->root(); - } - else delete &x->root(); - return 0; - } - - - int DLL_EXPORT ck_to_cti(char* in_file, char* db_file, - char* tr_file, char* id_tag, int debug, int validate) { - bool dbg = (debug != 0); - bool val = (validate != 0); - return pip::convert_ck(in_file, db_file, tr_file, id_tag, dbg, val); - } - - - int DLL_EXPORT writelogfile(char* logfile) { - write_logfile(string(logfile)); - return 0; - } - - -} +/** + * @file ct.cpp + * Cantera interface library. This library of functions is designed + * to encapsulate Cantera functionality and make it available for + * use in languages and applications other than C++. A set of + * library functions is provided that are declared "extern C". All + * Cantera objects are stored and referenced by integers - no + * pointers are passed to or from the calling application. + */ + +/* $Id$ */ + +// turn off warnings under Windows +#ifdef WIN32 +#pragma warning(disable:4786) +#pragma warning(disable:4503) +#endif + +#define CANTERA_USE_INTERNAL +#include "ct.h" + +// Cantera includes +#include "equil.h" +#include "KineticsFactory.h" +#include "TransportFactory.h" +#include "ctml.h" +#include "importKinetics.h" +#include "ThermoFactory.h" +#include "ck2ct.h" +#include "Storage.h" +#include "Cabinet.h" +#include "InterfaceKinetics.h" +#include "PureFluidPhase.h" + + +using namespace std; +using namespace Cantera; + +#ifdef WIN32 +#include "windows.h" +#endif + + +inline XML_Node* _xml(int i) { + return Cabinet::cabinet(false)->item(i); +} + + +#ifdef WITH_PURE_FLUIDS +static PureFluidPhase* purefluid(int n) { + try { + ThermoPhase* tp = th(n); + if (tp->eosType() == cPureFluid) { + return (PureFluidPhase*)tp; + } + else { + throw CanteraError("purefluid","object is not a PureFluidPhase object"); + } + } + catch (CanteraError) { + return 0; + } + return 0; +} + +static double pfprop(int n, int i, double v=0.0, double x=0.0) { + PureFluidPhase* p = purefluid(n); + if (p) { + switch(i) { + case 0: return p->critTemperature(); + case 1: return p->critPressure(); + case 2: return p->critDensity(); + case 3: return p->vaporFraction(); + case 4: return p->satTemperature(v); + case 5: return p->satPressure(v); + case 6: p->setState_Psat(v, x); return 0.0; + case 7: p->setState_Tsat(v, x); return 0.0; + } + } + return DERR; +} + + +#else + +static ThermoPhase* purefluid(int n) { + return th(n); +} +static double pfprop(int n, int i, double v=0.0, double x=0.0) { + return DERR; +} +#endif + + +inline int nThermo() { + return Storage::storage()->nThermo(); +} + +namespace Cantera { + void writephase(const ThermoPhase& th, bool show_thermo); +} + +/** + * Exported functions. + */ +extern "C" { + +#ifdef WIN32 +#ifndef NO_DLL_BUILD + /* + * The microsoft docs says we may need this in some + * cases when building dll's + */ + /* + bool WINAPI DllMain(HINSTANCE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved) { + switch(ul_reason_for_call ) { + case DLL_PROCESS_ATTACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + break; + } + return TRUE; + } + */ +#endif +#endif + + int DLL_EXPORT ct_appdelete() { + appdelete(); + return 0; + } + + //--------------- Phase ---------------------// + + int DLL_EXPORT phase_nElements(int n) { + return ph(n)->nElements(); + } + + int DLL_EXPORT phase_nSpecies(int n) { + return ph(n)->nSpecies(); + } + + doublereal DLL_EXPORT phase_temperature(int n) { + return ph(n)->temperature(); + } + + int DLL_EXPORT phase_setTemperature(int n, double t) { + try { + ph(n)->setTemperature(t); + } + catch(CanteraError) {return -1;} + return 0; + } + + doublereal DLL_EXPORT phase_density(int n) { + return ph(n)->density(); + } + + int DLL_EXPORT phase_setDensity(int n, double rho) { + if (rho < 0.0) return -1; + ph(n)->setDensity(rho); + return 0; + } + + doublereal DLL_EXPORT phase_molarDensity(int n) { + return ph(n)->molarDensity(); + } + + int DLL_EXPORT phase_setMolarDensity(int n, double ndens) { + if (ndens < 0.0) return -1; + ph(n)->setMolarDensity(ndens); + return 0; + } + + doublereal DLL_EXPORT phase_meanMolecularWeight(int n) { + return ph(n)->meanMolecularWeight(); + } + + int DLL_EXPORT phase_elementIndex(int n, char* nm) { + string elnm = string(nm); + return ph(n)->elementIndex(elnm); + } + + int DLL_EXPORT phase_speciesIndex(int n, char* nm) { + string spnm = string(nm); + return ph(n)->speciesIndex(spnm); + } + + int DLL_EXPORT phase_getMoleFractions(int n, int lenx, double* x) { + ThermoPhase* p = ph(n); + if (lenx >= p->nSpecies()) { + p->getMoleFractions(x); + return 0; + } + else + return -1; + } + + doublereal DLL_EXPORT phase_moleFraction(int n, int k) { + ThermoPhase* p = ph(n); + return p->moleFraction(k); + } + + int DLL_EXPORT phase_getMassFractions(int n, int leny, double* y) { + ThermoPhase* p = ph(n); + if (leny >= p->nSpecies()) { + p->getMassFractions(y); + return 0; + } + else + return -1; + } + + doublereal DLL_EXPORT phase_massFraction(int n, int k) { + ThermoPhase* p = ph(n); + return p->massFraction(k); + } + + int DLL_EXPORT phase_setMoleFractions(int n, int lenx, double* x, int norm) { + ThermoPhase* p = ph(n); + if (lenx >= p->nSpecies()) { + if (norm) p->setMoleFractions(x); + else p->setMoleFractions_NoNorm(x); + return 0; + } + else + return -1; + } + + int DLL_EXPORT phase_setMoleFractionsByName(int n, char* x) { + try { + ThermoPhase* p = ph(n); + compositionMap xx; + int nsp = p->nSpecies(); + for (int n = 0; n < nsp; n++) { + xx[p->speciesName(n)] = -1; + } + parseCompString(string(x), xx); + p->setMoleFractionsByName(xx); + return 0; + } + catch (CanteraError) {return -1;} + //catch (...) {return ERR;} + } + + int DLL_EXPORT phase_setMassFractions(int n, int leny, + double* y, int norm) { + ThermoPhase* p = ph(n); + if (leny >= p->nSpecies()) { + if (norm) p->setMassFractions(y); + else p->setMassFractions_NoNorm(y); + return 0; + } + else + return -10; + } + + int DLL_EXPORT phase_setMassFractionsByName(int n, char* y) { + try { + ThermoPhase* p = ph(n); + compositionMap yy; + int nsp = p->nSpecies(); + for (int n = 0; n < nsp; n++) { + yy[p->speciesName(n)] = -1; + } + parseCompString(string(y), yy); + p->setMassFractionsByName(yy); + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT phase_getAtomicWeights(int n, + int lenm, double* atw) { + ThermoPhase* p = ph(n); + if (lenm >= p->nElements()) { + const vector_fp& wt = p->atomicWeights(); + copy(wt.begin(), wt.end(), atw); + return 0; + } + else + return -10; + } + + int DLL_EXPORT phase_getMolecularWeights(int n, + int lenm, double* mw) { + ThermoPhase* p = ph(n); + if (lenm >= p->nSpecies()) { + const vector_fp& wt = p->molecularWeights(); + copy(wt.begin(), wt.end(), mw); + return 0; + } + else + return -10; + } + + int DLL_EXPORT phase_getName(int n, int lennm, char* nm) { + string name = ph(n)->name(); + int lout = (int) min(lennm, (int) name.size()); + copy(name.c_str(), name.c_str() + lout, nm); + nm[lout] = '\0'; + return 0; + } + + int DLL_EXPORT phase_setName(int n, const char* nm) { + string name = string(nm); + ph(n)->setName(name); + return 0; + } + + int DLL_EXPORT phase_getSpeciesName(int n, int k, int lennm, char* nm) { + try { + string spnm = ph(n)->speciesName(k); + int lout = min(lennm, (int) spnm.size()); + copy(spnm.c_str(), spnm.c_str() + lout, nm); + nm[lout] = '\0'; + return 0; + } + catch (CanteraError) { return -1; } + //catch (...) {return ERR;} + } + + int DLL_EXPORT phase_getElementName(int n, int m, int lennm, char* nm) { + try { + string elnm = ph(n)->elementName(m); + int lout = min(lennm, (int) elnm.size()); + copy(elnm.c_str(), elnm.c_str() + lout, nm); + nm[lout] = '\0'; + return 0; + } + catch (CanteraError) { return -1; } + } + + + doublereal DLL_EXPORT phase_nAtoms(int n, int k, int m) { + try { + return ph(n)->nAtoms(k,m); + } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT phase_addElement(int n, char* name, doublereal weight) { + try { + ph(n)->addElement(string(name),weight); + return 0; + } + catch (CanteraError) { return -1; } + } + +// int DLL_EXPORT phase_addSpecies(int n, char* name, int phase, +// int ncomp, doublereal* comp, int thermoType, int ncoeffs, +// double* coeffs, double minTemp, double maxTemp, double refPressure, +// doublereal charge, doublereal weight) { +// try { +// vector_fp cmp(ncomp); +// copy(comp, comp + ncomp, cmp.begin()); +// vector_fp c(ncoeffs); +// copy(coeffs, coeffs + ncoeffs, c.begin()); +// ph(n)->addSpecies(string(name), phase, cmp, +// thermoType, c, minTemp, maxTemp, refPressure, +// charge, weight); +// return 0; +// } +// catch (CanteraError) { return -1; } +// catch (...) {return ERR;} +// } + + + + //-------------- Thermo --------------------// + + // int DLL_EXPORT newThermo(int eos, int ph, int sptherm) { + // return Storage::storage()->addNewThermo(eos, ph, sptherm); + // } + + int DLL_EXPORT th_thermoIndex(char* id) { + return thermo_index(id); + } + +// int DLL_EXPORT newThermo(char* model) { +// try { +// string m = string(model); +// thermo_t* th = newThermoPhase(m); +// return Storage::storage()->addThermo(th); +// } +// catch (CanteraError) { return -1; } +// } + + int DLL_EXPORT newThermoFromXML(int mxml) { + try { + XML_Node* x = _xml(mxml); + thermo_t* th = newPhase(*x); + return Storage::storage()->addThermo(th); + } + catch (CanteraError) { return -1; } + } + + //int DLL_EXPORT th_phase(int n) { + // return th(n)->phase().index(); + // } + + int DLL_EXPORT th_nSpecies(int n) { + return th(n)->nSpecies(); + } + + int DLL_EXPORT th_eosType(int n) { + return th(n)->eosType(); + } + + double DLL_EXPORT th_enthalpy_mole(int n) { + try {return th(n)->enthalpy_mole();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_intEnergy_mole(int n) { + try {return th(n)->intEnergy_mole();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_entropy_mole(int n) { + try {return th(n)->entropy_mole();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_gibbs_mole(int n) { + try {return th(n)->gibbs_mole();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_cp_mole(int n) { + try {return th(n)->cp_mole();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_cv_mole(int n) { + try {return th(n)->cv_mole();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_pressure(int n) { + try {return th(n)->pressure();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_enthalpy_mass(int n) { + try {return th(n)->enthalpy_mass();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_intEnergy_mass(int n) { + try {return th(n)->intEnergy_mass();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_entropy_mass(int n) { + try {return th(n)->entropy_mass();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_gibbs_mass(int n) { + try {return th(n)->gibbs_mass();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_cp_mass(int n) { + try {return th(n)->cp_mass();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_cv_mass(int n) { + try {return th(n)->cv_mass();} + catch (CanteraError) {return DERR;} + } + + double DLL_EXPORT th_electricPotential(int n) { + try {return th(n)->electricPotential();} + catch (CanteraError) {return DERR;} + } + + int DLL_EXPORT th_chemPotentials(int n, int lenm, double* murt) { + thermo_t* thrm = th(n); + int nsp = thrm->nSpecies(); + if (lenm >= nsp) { + thrm->getChemPotentials(murt); + return 0; + } + else + return -10; + } + + int DLL_EXPORT th_elementPotentials(int n, int lenm, double* lambda) { + thermo_t* thrm = th(n); + int nel = thrm->nElements(); + if (lenm >= nel) { + equilibrate(*thrm, "TP", 0); + thrm->getElementPotentials(lambda); + return 0; + } + else + return -10; + } + + int DLL_EXPORT th_setPressure(int n, double p) { + try { + if (p < 0.0) throw CanteraError("th_setPressure", + "pressure cannot be negative"); + th(n)->setPressure(p); + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_set_HP(int n, double* vals) { + try { + if (vals[1] < 0.0) + throw CanteraError("th_set_HP", + "pressure cannot be negative"); + th(n)->setState_HP(vals[0],vals[1]); + if (th(n)->temperature() < 0.0) + throw CanteraError("th_set_HP", + "temperature cannot be negative"); + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_set_UV(int n, double* vals) { + try { + if (vals[1] < 0.0) + throw CanteraError("th_set_UV", + "specific volume cannot be negative"); + th(n)->setState_UV(vals[0],vals[1]); + if (th(n)->temperature() < 0.0) + throw CanteraError("th_set_UV", + "temperature cannot be negative"); + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_set_SV(int n, double* vals) { + try { + th(n)->setState_SV(vals[0],vals[1]); + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_set_SP(int n, double* vals) { + try { + th(n)->setState_SP(vals[0],vals[1]); + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_equil(int n, char* XY, int solver, + double rtol, int maxsteps, int maxiter, int loglevel) { + try { + equilibrate(*th(n), XY, solver, rtol, maxsteps, + maxiter, loglevel); return 0; + } + catch (CanteraError) { + return -1; + } + } + + doublereal DLL_EXPORT th_refPressure(int n) { + return th(n)->refPressure(); + } + + doublereal DLL_EXPORT th_minTemp(int n, int k) { + return th(n)->minTemp(k); + } + + doublereal DLL_EXPORT th_maxTemp(int n, int k) { + return th(n)->maxTemp(k); + } + + + int DLL_EXPORT th_getEnthalpies_RT(int n, int lenm, double* h_rt) { + try { + thermo_t* thrm = th(n); + int nsp = thrm->nSpecies(); + if (lenm >= nsp) { + thrm->getEnthalpy_RT_ref(h_rt); + return 0; + } + else + return -10; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_getEntropies_R(int n, int lenm, double* s_r) { + try { + thermo_t* thrm = th(n); + int nsp = thrm->nSpecies(); + if (lenm >= nsp) { + thrm->getEntropy_R_ref(s_r); + return 0; + } + else + return -10; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_getCp_R(int n, int lenm, double* cp_r) { + try { + thermo_t* thrm = th(n); + int nsp = thrm->nSpecies(); + if (lenm >= nsp) { + thrm->getCp_R_ref(cp_r); + return 0; + } + else + return -10; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT th_setElectricPotential(int n, double v) { + th(n)->setElectricPotential(v); + return 0; + } + + //-------------- pure fluids ---------------// +#ifdef WITH_PURE_FLUIDS + + double DLL_EXPORT th_critTemperature(int n) { + return pfprop(n,0); + } + + double DLL_EXPORT th_critPressure(int n) { + return purefluid(n)->critPressure(); + } + + double DLL_EXPORT th_critDensity(int n) { + return purefluid(n)->critDensity(); + } + + double DLL_EXPORT th_vaporFraction(int n) { + return purefluid(n)->vaporFraction(); + } + + double DLL_EXPORT th_satTemperature(int n, double p) { + try { + return purefluid(n)->satTemperature(p); + } + catch (CanteraError) { return DERR; } + } + + double DLL_EXPORT th_satPressure(int n, double t) { + try { + return purefluid(n)->satPressure(t); + } + catch (CanteraError) { return DERR; } + } + + int DLL_EXPORT th_setState_Psat(int n, double p, double x) { + try { + purefluid(n)->setState_Psat(p, x); + return 0; + } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT th_setState_Tsat(int n, double t, double x) { + try { + purefluid(n)->setState_Tsat(t, x); + return 0; + } + catch (CanteraError) { return -1; } + } +#else + + double DLL_EXPORT th_critTemperature(int n) { + return DERR; + } + + double DLL_EXPORT th_critPressure(int n) { + return DERR; + } + + double DLL_EXPORT th_critDensity(int n) { + return DERR; + } + + double DLL_EXPORT th_vaporFraction(int n) { + return DERR; + } + + double DLL_EXPORT th_satTemperature(int n, double p) { + return DERR; + } + + double DLL_EXPORT th_satPressure(int n, double t) { + return DERR; + } + + int DLL_EXPORT th_setState_Psat(int n, double p, double x) { + return DERR; + } + + int DLL_EXPORT th_setState_Tsat(int n, double t, double x) { + return DERR; + } +#endif + + + + //-------------- Kinetics ------------------// + + int DLL_EXPORT newKineticsFromXML(int mxml, int iphase, + int neighbor1, int neighbor2, int neighbor3, + int neighbor4) { + try { + XML_Node* x = _xml(mxml); + vector phases; + phases.push_back(th(iphase)); + if (neighbor1 >= 0) { + phases.push_back(th(neighbor1)); + if (neighbor2 >= 0) { + phases.push_back(th(neighbor2)); + if (neighbor3 >= 0) { + phases.push_back(th(neighbor3)); + if (neighbor4 >= 0) { + phases.push_back(th(neighbor4)); + } + } + } + } + Kinetics* kin = newKineticsMgr(*x, phases); + if (kin) + return Storage::storage()->addKinetics(kin); + else + return 0; + } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT installRxnArrays(int pxml, int ikin, + char* default_phase) { + try { + XML_Node* p = _xml(pxml); + kinetics_t* k = kin(ikin); + string defphase = string(default_phase); + installReactionArrays(*p, *k, defphase); + return 0; + } + catch (CanteraError) { return -1; } + } + + //------------------------------------- + int DLL_EXPORT kin_type(int n) { + return kin(n)->type(); + } + + int DLL_EXPORT kin_start(int n, int p) { + return kin(n)->kineticsSpeciesIndex(0,p); + } + + int DLL_EXPORT kin_speciesIndex(int n, const char* nm, const char* ph) { + return kin(n)->kineticsSpeciesIndex(string(nm), string(ph)); + } + + //--------------------------------------- + + int DLL_EXPORT kin_nSpecies(int n) { + return kin(n)->nTotalSpecies(); + } + + int DLL_EXPORT kin_nReactions(int n) { + return kin(n)->nReactions(); + } + + int DLL_EXPORT kin_nPhases(int n) { + return kin(n)->nPhases(); + } + + int DLL_EXPORT kin_phaseIndex(int n, char* ph) { + return kin(n)->phaseIndex(string(ph)); + } + + int DLL_EXPORT kin_reactionPhaseIndex(int n) { + return kin(n)->reactionPhaseIndex(); + } + + double DLL_EXPORT kin_reactantStoichCoeff(int n, int k, int i) { + return kin(n)->reactantStoichCoeff(k,i); + } + + double DLL_EXPORT kin_productStoichCoeff(int n, int k, int i) { + return kin(n)->productStoichCoeff(k,i); + } + + int DLL_EXPORT kin_reactionType(int n, int i) { + return kin(n)->reactionType(i); + } + + int DLL_EXPORT kin_getFwdRatesOfProgress(int n, int len, double* fwdROP) { + Kinetics* k = kin(n); + try { + if (len >= k->nReactions()) { + k->getFwdRatesOfProgress(fwdROP); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_getRevRatesOfProgress(int n, int len, double* revROP) { + Kinetics* k = kin(n); + try { + if (len >= k->nReactions()) { + k->getRevRatesOfProgress(revROP); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_isReversible(int n, int i) { + return (int)kin(n)->isReversible(i); + } + + int DLL_EXPORT kin_getNetRatesOfProgress(int n, int len, double* netROP) { + try { + Kinetics* k = kin(n); + if (len >= k->nReactions()) { + k->getNetRatesOfProgress(netROP); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_getFwdRateConstants(int n, int len, double* kfwd) { + try { + Kinetics* k = kin(n); + if (len >= k->nReactions()) { + k->getFwdRateConstants(kfwd); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_getRevRateConstants(int n, int doIrreversible, int len, double* krev) { + try { + Kinetics* k = kin(n); + bool doirrev = false; + if (doIrreversible != 0) doirrev = true; + if (len >= k->nReactions()) { + k->getRevRateConstants(krev, doirrev); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + + int DLL_EXPORT kin_getActivationEnergies(int n, int len, double* E) { + try { + Kinetics* k = kin(n); + if (len >= k->nReactions()) { + k->getActivationEnergies(E); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + + int DLL_EXPORT kin_getDelta(int n, int job, int len, double* delta) { + try { + Kinetics* k = kin(n); + if (len < k->nReactions()) return ERR; + switch (job) { + case 0: + k->getDeltaEnthalpy(delta); break; + case 1: + k->getDeltaGibbs(delta); break; + case 2: + k->getDeltaEntropy(delta); break; + case 3: + k->getDeltaSSEnthalpy(delta); break; + case 4: + k->getDeltaSSGibbs(delta); break; + case 5: + k->getDeltaSSEntropy(delta); break; + default: + return ERR; + } + return 0; + } + catch (CanteraError) {return -1;} + } + + + int DLL_EXPORT kin_getDeltaEntropy(int n, int len, double* deltaS) { + try { + Kinetics* k = kin(n); + if (len >= k->nReactions()) { + k->getDeltaEntropy(deltaS); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + + int DLL_EXPORT kin_getCreationRates(int n, int len, double* cdot) { + try { + Kinetics* k = kin(n); + if (len >= k->nTotalSpecies()) { + k->getCreationRates(cdot); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_getDestructionRates(int n, int len, double* ddot) { + try { + Kinetics* k = kin(n); + if (len >= k->nTotalSpecies()) { + k->getDestructionRates(ddot); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + //catch (...) {return ERR;} + } + + int DLL_EXPORT kin_getNetProductionRates(int n, int len, double* wdot) { + try { + Kinetics* k = kin(n); + if (len >= k->nTotalSpecies()) { + k->getNetProductionRates(wdot); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_getSourceTerms(int n, int len, double* ydot) { + try { + Kinetics* k = kin(n); + ThermoPhase* p = &k->thermo(); + const vector_fp& mw = p->molecularWeights(); + int nsp = static_cast(mw.size()); + double rrho = 1.0/p->density(); + if (len >= nsp) { + k->getNetProductionRates(ydot); + multiply_each(ydot, ydot + nsp, mw.begin()); + scale(ydot, ydot + nsp, ydot, rrho); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + double DLL_EXPORT kin_multiplier(int n, int i) { + return kin(n)->multiplier(i); + } + + int DLL_EXPORT kin_phase(int n, int i) { + return kin(n)->thermo(i).index(); + // return thermo_index(kin(n)->thermo(i).id()); + } + + int DLL_EXPORT kin_getEquilibriumConstants(int n, int len, double* kc) { + try { + Kinetics* k = kin(n); + if (len >= k->nReactions()) { + k->getEquilibriumConstants(kc); + return 0; + } + else + return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_getReactionString(int n, int i, int len, char* buf) { + try { + Kinetics* k = kin(n); + string r = k->reactionString(i); + int lout = min(len, (int)r.size()); + copy(r.c_str(), r.c_str() + lout, buf); + buf[lout] = '\0'; + return 0; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_setMultiplier(int n, int i, double v) { + try { + if (v >= 0.0) { + kin(n)->setMultiplier(i,v); + return 0; + } + else return ERR; + } + catch (CanteraError) {return -1;} + } + + int DLL_EXPORT kin_advanceCoverages(int n, double tstep) { + try { + Kinetics* k = kin(n); + if (k->type() == cInterfaceKinetics) { + ((InterfaceKinetics*)k)->advanceCoverages(tstep); + } + else { + throw CanteraError("kin_advanceCoverages", + "wrong kinetics manager type"); + } + return 0; + } + catch (CanteraError) {return -1;} + } + + //------------------- Transport --------------------------- + + int DLL_EXPORT newTransport(char* model, + int ith, int loglevel) { + string mstr = string(model); + thermo_t* t = th(ith); + try { + Transport* tr = newTransportMgr(mstr,t, loglevel); + return Storage::storage()->addTransport(tr); + } + catch (CanteraError) { return -1; } + } + + double DLL_EXPORT trans_viscosity(int n) { + try {return trans(n)->viscosity();} + catch (CanteraError) { return -1.0; } + } + + double DLL_EXPORT trans_thermalConductivity(int n) { + try {return trans(n)->thermalConductivity();} + catch (CanteraError) { return -1.0; } + } + + int DLL_EXPORT trans_getThermalDiffCoeffs(int n, int ldt, double* dt) { + try { trans(n)->getThermalDiffCoeffs(dt); return 0; } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT trans_getMixDiffCoeffs(int n, int ld, double* d) { + try { trans(n)->getMixDiffCoeffs(d); return 0;} + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT trans_getBinDiffCoeffs(int n, int ld, double* d) { + try { trans(n)->getBinaryDiffCoeffs(ld,d); return 0;} + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT trans_getMultiDiffCoeffs(int n, int ld, double* d) { + try { trans(n)->getMultiDiffCoeffs(ld,d); return 0;} + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT trans_setParameters(int n, int type, int k, double* d) { + try { trans(n)->setParameters(type, k, d); return 0;} + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT trans_getMolarFluxes(int n, const double* state1, + const double* state2, double delta, double* fluxes) { + try { + trans(n)->getMolarFluxes(state1, state2, delta, fluxes); + return 0; + } + catch (CanteraError) { return -1; } + } + + //-------------------- Functions --------------------------- + + int DLL_EXPORT import_phase(int nth, int nxml, char* id) { + thermo_t* thrm = th(nth); + XML_Node* node = _xml(nxml); + string idstr = string(id); + try { + importPhase(*node, thrm); + return 0; + } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT import_kinetics(int nxml, char* id, + int nphases, integer* ith, int nkin) { + vector phases; + for (int i = 0; i < nphases; i++) { + phases.push_back(th(ith[i])); + } + XML_Node* node = _xml(nxml); + Kinetics* k = kin(nkin); + string idstr = string(id); + try { + importKinetics(*node, phases, k); + return 0; + } + catch (CanteraError) { return -1; } + } + + + int DLL_EXPORT phase_report(int nth, + int ibuf, char* buf, int show_thermo) { + try { + bool stherm = (show_thermo != 0); + string s = report(*th(nth), stherm); + if (int(s.size()) > ibuf - 1) { + return -(static_cast(s.size()) + 1); + } + copy(s.begin(), s.end(), buf); + buf[s.size() - 1] = '\0'; + return 0; + + } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT write_phase(int nth, int show_thermo) { + try { + bool stherm = (show_thermo != 0); + writephase(*th(nth), stherm); + return 0; + } + catch (CanteraError) { return -1; } + } + + int DLL_EXPORT write_HTML_log(char* file) { + write_logfile(string(file)); + return 0; + } + + int DLL_EXPORT getCanteraError(int buflen, char* buf) { + string e; + e = lastErrorMessage(); + if (buflen > 0) { + int n = min(static_cast(e.size()), buflen-1); + copy(e.begin(), e.begin() + n, buf); + buf[min(n, buflen-1)] = '\0'; + } + return int(e.size()); + } + + int DLL_EXPORT showCanteraErrors() { + showErrors(); + return 0; + } + + int DLL_EXPORT addCanteraDirectory(int buflen, char* buf) { + addDirectory(string(buf)); + return 0; + } + + int DLL_EXPORT setLogWriter(void* logger) { + Logger* logwriter = (Logger*)logger; + setLogger(logwriter); + return 0; + } + + int DLL_EXPORT readlog(int n, char* buf) { + string s; + writelog("function readlog is deprecated!"); + //getlog(s); + int nlog = static_cast(s.size()); + if (n < 0) return nlog; + int nn = min(n-1, nlog); + copy(s.begin(), s.begin() + nn, + buf); + buf[min(nlog, n-1)] = '\0'; + //clearlog(); + return 0; + + } + int DLL_EXPORT clearStorage() { + try { + Storage::storage()->clear(); + return 0; + } + catch (CanteraError) { + return -1; + } + } + + int DLL_EXPORT delThermo(int n) { + try { + Storage::storage()->deleteThermo(n); + return 0; + } + catch (CanteraError) { + return -1; + } + } + + int DLL_EXPORT delKinetics(int n) { + Storage::storage()->deleteKinetics(n); + return 0; + } + + int DLL_EXPORT delTransport(int n) { + Storage::storage()->deleteTransport(n); + return 0; + } + + int DLL_EXPORT buildSolutionFromXML(char* src, int ixml, char* id, + int ith, int ikin) { + + XML_Node* root = 0; + if (ixml > 0) root = _xml(ixml); + + thermo_t* t = th(ith); + kinetics_t* k = kin(ikin); + + Kinetics& kin = *k; + XML_Node *x, *r=0; + if (root) r = &root->root(); + x = get_XML_Node(string(src), r); + //x = find_XML(string(src), r, string(id), "", "phase"); + if (!x) return false; + importPhase(*x, t); + kin.addPhase(*t); + kin.init(); + installReactionArrays(*x, kin, x->id()); + t->setState_TP(300.0, OneAtm); + if (r) { + if (&x->root() != &r->root()) delete &x->root(); + } + else delete &x->root(); + return 0; + } + + + int DLL_EXPORT ck_to_cti(char* in_file, char* db_file, + char* tr_file, char* id_tag, int debug, int validate) { + bool dbg = (debug != 0); + bool val = (validate != 0); + return pip::convert_ck(in_file, db_file, tr_file, id_tag, dbg, val); + } + + + int DLL_EXPORT writelogfile(char* logfile) { + write_logfile(string(logfile)); + return 0; + } + + +} diff --git a/Cantera/clib/src/ctonedim.cpp b/Cantera/clib/src/ctonedim.cpp index e1da6fa52..9295c2ed5 100644 --- a/Cantera/clib/src/ctonedim.cpp +++ b/Cantera/clib/src/ctonedim.cpp @@ -47,16 +47,18 @@ inline Domain1D* _domain(int i) { static StFlow* _stflow(int i) { Domain1D* d = _domain(i); if (d->domainType() == cFlowType) return (StFlow*)d; - else + else { throw CanteraError("_stflow","wrong domain type"); + } + return 0; } static Bdry1D* _bdry(int i) { Domain1D* d = _domain(i); - if (d->isConnector()) return (Bdry1D*)d; - else - throw CanteraError("_bdry","wrong domain type: " - +int2str(d->domainType())); + if (! d->isConnector()) { + throw CanteraError("_bdry","wrong domain type: " +int2str(d->domainType())); + } + return (Bdry1D*)d; } inline ThermoPhase* _phase(int n) { diff --git a/Cantera/cxx/include/Cantera.mak.in b/Cantera/cxx/include/Cantera.mak.in index 23c5114bd..c59840454 100644 --- a/Cantera/cxx/include/Cantera.mak.in +++ b/Cantera/cxx/include/Cantera.mak.in @@ -25,6 +25,10 @@ in_CanteraBuildTree = 0 # CANTERA_VERSION=@ctversion@ # +CANTERA_VERSION=@ctversion@ + +CANTERA_VERSION=@ctversion@ + ############################################################################### # CANTERA CORE ############################################################################### diff --git a/Cantera/cxx/include/Cantera_bt.mak.in b/Cantera/cxx/include/Cantera_bt.mak.in index f6aa0aee6..00839668c 100644 --- a/Cantera/cxx/include/Cantera_bt.mak.in +++ b/Cantera/cxx/include/Cantera_bt.mak.in @@ -25,6 +25,10 @@ in_CanteraBuildTree = 0 # CANTERA_VERSION=@ctversion@ # +CANTERA_VERSION=@ctversion@ + +CANTERA_VERSION=@ctversion@ + ############################################################################### # CANTERA CORE ############################################################################### diff --git a/Cantera/fortran/src/fct.cpp b/Cantera/fortran/src/fct.cpp index 7b746d9d6..cbfb0c84d 100644 --- a/Cantera/fortran/src/fct.cpp +++ b/Cantera/fortran/src/fct.cpp @@ -33,7 +33,7 @@ // Assert that there is storage // for the templated classes' static member // (needed to compile on solaris) -template<> Cabinet * Cabinet::__storage; +//template<> Cabinet * Cabinet::__storage; inline XML_Node* _xml(const integer* n) { return Cabinet::cabinet()->item(*n); @@ -93,6 +93,7 @@ extern "C" { catch (CanteraError) { handleError(); return -1; } + return -1; } //--------------- Phase ---------------------// diff --git a/Cantera/src/base/checkFinite.cpp b/Cantera/src/base/checkFinite.cpp index b20096b99..be4fa224d 100644 --- a/Cantera/src/base/checkFinite.cpp +++ b/Cantera/src/base/checkFinite.cpp @@ -14,6 +14,8 @@ * See file License.txt for licensing information. */ +#include "ct_defs.h" + #include #include diff --git a/Cantera/src/base/ctml.cpp b/Cantera/src/base/ctml.cpp index 45172dd54..ec6c4983d 100644 --- a/Cantera/src/base/ctml.cpp +++ b/Cantera/src/base/ctml.cpp @@ -370,7 +370,9 @@ namespace ctml { const std::string typeString) { XML_Node& f = node.addChild("string", valueString); f.addAttribute("title", titleString); - if (typeString != "") f.addAttribute("type", typeString); + if (typeString != "") { + f.addAttribute("type", typeString); + } } XML_Node* getByTitle(const Cantera::XML_Node& node, const std::string &title) { diff --git a/Cantera/src/base/misc.cpp b/Cantera/src/base/misc.cpp index 5a6e48d0e..b8acb15a8 100644 --- a/Cantera/src/base/misc.cpp +++ b/Cantera/src/base/misc.cpp @@ -1489,28 +1489,34 @@ protected: doublereal toSI(std::string unit) { doublereal f = Unit::units()->toSI(unit); - if (f) return f; - else throw CanteraError("toSI","unknown unit string: "+unit); - //return 1.0; + if (f) { + return f; + } else { + throw CanteraError("toSI","unknown unit string: "+unit); + } + return 1.0; } doublereal actEnergyToSI(std::string unit) { doublereal f = Unit::units()->actEnergyToSI(unit); - if (f) return f; - else return 1.0; + if (f) { + return f; + } + return 1.0; } string canteraRoot() { char* ctroot = 0; ctroot = getenv("CANTERA_ROOT"); - if (ctroot != 0) { return string(ctroot); } - else { + if (ctroot != 0) { + return string(ctroot); + } #ifdef CANTERA_ROOT - return string(CANTERA_ROOT); + return string(CANTERA_ROOT); #else - return ""; + return ""; #endif - } + } // exceptions diff --git a/Cantera/src/base/units.h b/Cantera/src/base/units.h index 25009ea12..bf81f8820 100644 --- a/Cantera/src/base/units.h +++ b/Cantera/src/base/units.h @@ -173,10 +173,9 @@ namespace Cantera { static boost::mutex units_mutex; #endif - /*! - * Units class constructor, containing the default mappings between - * strings and units. - */ + + //! Units class constructor, containing the default mappings between + //! strings and units. Unit() : m_u(), m_act_u() @@ -234,13 +233,16 @@ namespace Cantera { m_u["hr"] = 3600.0; m_u["ms"] = 0.001; - /*// frequency + + /* + // frequency - Took frequency out to reevaluate it. Inverse cm is probably the wrong default unit m_u["hZ"] = 0.01/(lightSpeed); m_u["cm^-1"] = 1.0; m_u["m^-1"] = 0.1; m_u["cm-1"] = m_u["cm^-1"]; m_u["m-1"] = m_u["m^-1"]; - m_u["wavenumbers"] = m_u["cm^-1"];*/ + m_u["wavenumbers"] = m_u["cm^-1"]; + */ // viscosity m_u["Pa-s"] = 1; @@ -258,7 +260,6 @@ namespace Cantera { m_u["ml"] = 1.0e-6; m_u["cc"] = 1.0e-6; - m_act_u["eV"] = m_u["eV"]; // /m_u["molec"]; m_act_u["K"] = GasConstant; m_act_u["Kelvin"] = GasConstant; diff --git a/Cantera/src/base/utilities.h b/Cantera/src/base/utilities.h index 7090bacae..3628c5317 100644 --- a/Cantera/src/base/utilities.h +++ b/Cantera/src/base/utilities.h @@ -687,7 +687,6 @@ namespace Cantera { } - //@} } diff --git a/Cantera/src/equil/ChemEquil.cpp b/Cantera/src/equil/ChemEquil.cpp index d78714575..f1af6a8a5 100755 --- a/Cantera/src/equil/ChemEquil.cpp +++ b/Cantera/src/equil/ChemEquil.cpp @@ -59,7 +59,10 @@ namespace Cantera { else if (flag == "SP") return SP; else if (flag == "SV") return SV; else if (flag == "UP") return UP; - else throw CanteraError("_equilflag","unknown property pair "+flag); + else { + throw CanteraError("_equilflag","unknown property pair "+flag); + } + return -1; } diff --git a/Cantera/src/equil/equilibrate.cpp b/Cantera/src/equil/equilibrate.cpp index 548df4f68..2efdb336f 100644 --- a/Cantera/src/equil/equilibrate.cpp +++ b/Cantera/src/equil/equilibrate.cpp @@ -27,7 +27,7 @@ namespace Cantera { doublereal equilibrate(MultiPhase& s, const char* XY, doublereal tol, int maxsteps, int maxiter, int loglevel) { - + if (loglevel > 0) { beginLogGroup("equilibrate",loglevel); addLogEntry("multiphase equilibrate function"); @@ -65,9 +65,9 @@ namespace Cantera { endLogGroup("equilibrate"); } throw CanteraError("equilibrate","unsupported option"); - //return -1.0; + return -1.0; } - + return 0.0; } /* diff --git a/Cantera/src/kinetics/Kinetics.cpp b/Cantera/src/kinetics/Kinetics.cpp index e935c0410..989f3d2b7 100644 --- a/Cantera/src/kinetics/Kinetics.cpp +++ b/Cantera/src/kinetics/Kinetics.cpp @@ -260,6 +260,7 @@ namespace Cantera { if (k >= 0) return thermo(n); } throw CanteraError("speciesPhase", "unknown species "+nm); + return thermo(0); } //============================================================================================== @@ -276,8 +277,8 @@ namespace Cantera { return n; } } - throw CanteraError("speciesPhaseIndex", - "illegal species index: "+int2str(k)); + throw CanteraError("speciesPhaseIndex", "illegal species index: "+int2str(k)); + return -1; } /* @@ -338,7 +339,6 @@ namespace Cantera { } } - // Private function of the class Kinetics, indicating that a function // inherited from the base class hasn't had a definition assigned to it /* diff --git a/Cantera/src/kinetics/RxnRates.h b/Cantera/src/kinetics/RxnRates.h index bb9ba6937..ce2cf2fc3 100644 --- a/Cantera/src/kinetics/RxnRates.h +++ b/Cantera/src/kinetics/RxnRates.h @@ -29,7 +29,6 @@ namespace Cantera { * */ class Arrhenius { - public: //! return the rate coefficient type. @@ -128,10 +127,10 @@ namespace Cantera { class ArrheniusSum { public: + static int type() { return ARRHENIUS_SUM_REACTION_RATECOEFF_TYPE; } - ArrheniusSum() : m_nterms(0) {} void addArrheniusTerm(doublereal A, doublereal b, doublereal E) { @@ -350,6 +349,7 @@ namespace Cantera { + //! Arrhenius reaction rate type depends only on temperature /** * A reaction rate coefficient of the following form. @@ -360,9 +360,8 @@ namespace Cantera { * */ class ExchangeCurrent { - public: - + //! return the rate coefficient type. static int type() { return EXCHANGE_CURRENT_REACTION_RATECOEFF_TYPE; @@ -436,7 +435,6 @@ namespace Cantera { doublereal updateRC(doublereal logT, doublereal recipT) const { return m_A * exp(m_b*logT - m_E*recipT); } - void writeUpdateRHS(std::ostream& s) const { s << " exp(" << m_logA; @@ -483,7 +481,6 @@ namespace Cantera { // }; //} - } #endif diff --git a/Cantera/src/numerics/ODE_integrators.cpp b/Cantera/src/numerics/ODE_integrators.cpp index e0c613b09..6f344530a 100644 --- a/Cantera/src/numerics/ODE_integrators.cpp +++ b/Cantera/src/numerics/ODE_integrators.cpp @@ -22,6 +22,7 @@ namespace Cantera { throw CanteraError("newIntegrator", "unknown ODE integrator: "+itype); } + return 0; } void deleteIntegrator(Integrator *cv) { diff --git a/Cantera/src/oneD/Domain1D.cpp b/Cantera/src/oneD/Domain1D.cpp index f9f19d92f..c0c87ef96 100644 --- a/Cantera/src/oneD/Domain1D.cpp +++ b/Cantera/src/oneD/Domain1D.cpp @@ -190,7 +190,8 @@ namespace Cantera { doublereal Domain1D::initialValue(int n, int j) { throw CanteraError("Domain1D::initialValue", - "base class method called!"); + "base class method called!"); + return 0.0; } diff --git a/Cantera/src/oneD/OneDim.cpp b/Cantera/src/oneD/OneDim.cpp index eabebdf28..a54602ce2 100644 --- a/Cantera/src/oneD/OneDim.cpp +++ b/Cantera/src/oneD/OneDim.cpp @@ -64,6 +64,7 @@ namespace Cantera { if (domain(n).id() == name) return n; } throw CanteraError("OneDim::domainIndex","no domain named >>"+name+"<<"); + return -1; } diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index d788cf99d..cfe591a33 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -117,10 +117,14 @@ namespace Cantera { string Inlet1D:: componentName(int n) const { switch (n) { - case 0: return "mdot"; break; - case 1: return "temperature"; break; - default: return "unknown"; + case 0: + return "mdot"; + case 1: + return "temperature"; + default: + break; } + return "unknown"; } void Inlet1D:: @@ -271,9 +275,12 @@ namespace Cantera { string Empty1D::componentName(int n) const { switch (n) { - case 0: return "dummy"; break; - default: return ""; + case 0: + return "dummy"; + default: + break; } + return ""; } void Empty1D:: @@ -326,9 +333,12 @@ namespace Cantera { string Symm1D::componentName(int n) const { switch (n) { - case 0: return "dummy"; break; - default: return ""; + case 0: + return "dummy"; + default: + break; } + return ""; } void Symm1D:: @@ -405,9 +415,12 @@ namespace Cantera { string Outlet1D::componentName(int n) const { switch (n) { - case 0: return "outlet dummy"; break; - default: return ""; + case 0: + return "outlet dummy"; + default: + break; } + return ""; } void Outlet1D:: @@ -522,9 +535,12 @@ namespace Cantera { string OutletRes1D::componentName(int n) const { switch (n) { - case 0: return "dummy"; break; - default: return ""; + case 0: + return "dummy"; + default: + break; } + return ""; } void OutletRes1D:: @@ -641,9 +657,12 @@ namespace Cantera { string Surf1D::componentName(int n) const { switch (n) { - case 0: return "temperature"; break; - default: return ""; + case 0: + return "temperature"; + default: + break; } + return ""; } void Surf1D:: diff --git a/Cantera/src/thermo/Elements.cpp b/Cantera/src/thermo/Elements.cpp index 5e5943361..2c9e61bdc 100644 --- a/Cantera/src/thermo/Elements.cpp +++ b/Cantera/src/thermo/Elements.cpp @@ -321,14 +321,13 @@ namespace Cantera { * index. If m < 0 or m >= nElements() an exception is thrown. */ string Elements::elementName(int m) const { - if (m >= 0 && m < nElements()) - return m_elementNames[m]; - else + if (m < 0 || m >= nElements()) { throw ElementRangeError("Elements::elementName", m, nElements()); + } + return m_elementNames[m]; } - doublereal Elements::entropyElement298(int m) const { AssertThrowMsg(m_entropy298[m] != ENTROPY298_UNKNOWN, "Elements::entropy298", diff --git a/Cantera/src/thermo/GibbsExcessVPSSTP.h b/Cantera/src/thermo/GibbsExcessVPSSTP.h index d98b95241..68a4f3ad5 100644 --- a/Cantera/src/thermo/GibbsExcessVPSSTP.h +++ b/Cantera/src/thermo/GibbsExcessVPSSTP.h @@ -326,6 +326,28 @@ namespace Cantera { virtual void getdlnActCoeffdlnN(const int ld, doublereal * const dlnActCoeffdlnN) const { err(" getdlnActCoeffdlnN: nonzero and nonimplemented"); } + + //! Get the array of log concentration-like derivatives of the + //! log activity coefficients + /*! + * This function is a virtual method. For ideal mixtures + * (unity activity coefficients), this can return zero. + * Implementations should take the derivative of the + * logarithm of the activity coefficient with respect to the + * logarithm of the concentration-like variable (i.e. number of moles in + * in a unit volume. ) that represents the standard state. + * This quantity is to be used in conjunction with derivatives of + * that concentration-like variable when the derivative of the chemical + * potential is taken. + * + * units = dimensionless + * + * @param dlnActCoeffdlnX Output vector of derivatives of the + * log Activity Coefficients. length = m_kk + */ + virtual void getdlnActCoeffdlnX(doublereal *dlnActCoeffdlnX) const { + err("getdlnActCoeffdlnX"); + } //@} diff --git a/Cantera/src/thermo/HMWSoln.cpp b/Cantera/src/thermo/HMWSoln.cpp index a250de5f0..5147b705d 100644 --- a/Cantera/src/thermo/HMWSoln.cpp +++ b/Cantera/src/thermo/HMWSoln.cpp @@ -792,7 +792,7 @@ namespace Cantera { doublereal HMWSoln::isothermalCompressibility() const { throw CanteraError("HMWSoln::isothermalCompressibility", "unimplemented"); - //return 0.0; + return 0.0; } /* diff --git a/Cantera/src/thermo/IdealSolidSolnPhase.cpp b/Cantera/src/thermo/IdealSolidSolnPhase.cpp index d297ca6f4..6fd4107e6 100644 --- a/Cantera/src/thermo/IdealSolidSolnPhase.cpp +++ b/Cantera/src/thermo/IdealSolidSolnPhase.cpp @@ -494,13 +494,10 @@ namespace Cantera { switch (m_formGC) { case 0: return 1.0; - break; case 1: return 1.0 / m_speciesMolarVolume[k]; - break; case 2: return 1.0/m_speciesMolarVolume[m_kk-1]; - break; } return 0.0; } @@ -509,13 +506,10 @@ namespace Cantera { switch (m_formGC) { case 0: return 1.0; - break; case 1: return 1.0 / m_speciesMolarVolume[k]; - break; case 2: return 1.0 / m_speciesMolarVolume[m_kk-1]; - break; } return 0.0; } diff --git a/Cantera/src/thermo/MargulesVPSSTP.cpp b/Cantera/src/thermo/MargulesVPSSTP.cpp index f2923c44d..f039c561d 100644 --- a/Cantera/src/thermo/MargulesVPSSTP.cpp +++ b/Cantera/src/thermo/MargulesVPSSTP.cpp @@ -746,6 +746,7 @@ namespace Cantera { } //=================================================================================================================== + // Update the activity coefficients /* * This function will be called to update the internally storred diff --git a/Cantera/src/thermo/MargulesVPSSTP.h b/Cantera/src/thermo/MargulesVPSSTP.h index af2edca83..8913c53c2 100644 --- a/Cantera/src/thermo/MargulesVPSSTP.h +++ b/Cantera/src/thermo/MargulesVPSSTP.h @@ -85,15 +85,16 @@ namespace Cantera { * that has more than 2 species. * * \f[ - * G^E = \sum_i \left( H_{Ei} - T S_{Ei} \right) + * G^E = \sum_i \left( H_{Ei} - T S_{Ei} \right) * \f] * \f[ - * H^E_i = X_{Ai} X_{Bi} \left( h_{o,i} + h_{1,i} X_{Bi} \right) + * H^E_i = n X_{Ai} X_{Bi} \left( h_{o,i} + h_{1,i} X_{Bi} \right) * \f] * \f[ - * S^E_i = X_{Ai} X_{Bi} \left( s_{o,i} + s_{1,i} X_{Bi} \right) + * S^E_i = n X_{Ai} X_{Bi} \left( s_{o,i} + s_{1,i} X_{Bi} \right) * \f] * + * where n is the total moles in the solution. * * The activity of a species defined in the phase is given by an excess * Gibbs free energy formulation. diff --git a/Cantera/src/thermo/PureFluidPhase.cpp b/Cantera/src/thermo/PureFluidPhase.cpp index f753bc8cd..70336dbd7 100644 --- a/Cantera/src/thermo/PureFluidPhase.cpp +++ b/Cantera/src/thermo/PureFluidPhase.cpp @@ -743,9 +743,7 @@ namespace Cantera { catch (CanteraError) { ; } - } - - + } } #endif // WITH_PURE_FLUIDS diff --git a/Cantera/src/thermo/State.cpp b/Cantera/src/thermo/State.cpp index f8b3dbee9..a25d53701 100644 --- a/Cantera/src/thermo/State.cpp +++ b/Cantera/src/thermo/State.cpp @@ -96,6 +96,7 @@ namespace Cantera { throw CanteraError("State:moleFraction", "illegal species index number"); } + return 0.0; } void State::setMoleFractions(const doublereal* const x) { @@ -126,20 +127,16 @@ namespace Cantera { if (k >= 0 && k < m_kk) { return m_y[k]; } - else { - throw CanteraError("State:massFraction", - "illegal species index number"); - } + throw CanteraError("State:massFraction", "illegal species index number"); + return 0.0; } doublereal State::concentration(const int k) const { if (k >= 0 && k < m_kk) { return m_y[k] * m_dens * m_rmolwts[k] ; } - else { - throw CanteraError("State:massFraction", - "illegal species index number"); - } + throw CanteraError("State:massFraction", "illegal species index number"); + return 0.0; } void State::setMassFractions(const doublereal* const y) { diff --git a/Cantera/src/thermo/VPSSMgrFactory.cpp b/Cantera/src/thermo/VPSSMgrFactory.cpp index 3e2265e0d..d3ab29edc 100644 --- a/Cantera/src/thermo/VPSSMgrFactory.cpp +++ b/Cantera/src/thermo/VPSSMgrFactory.cpp @@ -361,22 +361,17 @@ namespace Cantera { switch (type) { case cVPSSMGR_IDEALGAS: return new VPSSMgr_IdealGas(vp_ptr, &spthermoRef); - break; case cVPSSMGR_CONSTVOL: return new VPSSMgr_ConstVol(vp_ptr, &spthermoRef); - break; case cVPSSMGR_PUREFLUID: throw CanteraError("VPSSMgrFactory::newVPSSMgr", "unimplemented"); case cVPSSMGR_WATER_CONSTVOL: return new VPSSMgr_Water_ConstVol(vp_ptr, &spthermoRef); - break; case cVPSSMGR_WATER_HKFT: return new VPSSMgr_Water_HKFT(vp_ptr, &spthermoRef); - break; case cVPSSMGR_GENERAL: return new VPSSMgr_General(vp_ptr, &spthermoRef); - break; case cVPSSMGR_UNDEF: default: throw UnknownVPSSMgrModel("VPSSMgrFactory::newVPSSMgr", int2str(type)); diff --git a/Cantera/src/thermo/WaterPropsIAPWS.cpp b/Cantera/src/thermo/WaterPropsIAPWS.cpp index 4853e2d09..57225efb0 100644 --- a/Cantera/src/thermo/WaterPropsIAPWS.cpp +++ b/Cantera/src/thermo/WaterPropsIAPWS.cpp @@ -875,4 +875,4 @@ doublereal WaterPropsIAPWS::molarVolume() const { return (M_water / rho); } -}; +} diff --git a/Cantera/src/zeroD/ReactorFactory.cpp b/Cantera/src/zeroD/ReactorFactory.cpp index ee07a21f3..3a07c12fa 100644 --- a/Cantera/src/zeroD/ReactorFactory.cpp +++ b/Cantera/src/zeroD/ReactorFactory.cpp @@ -67,6 +67,7 @@ namespace CanteraZeroD { throw CanteraError("ReactorFactory::newReactor", "unknown reactor type!"); } + return 0; } } diff --git a/config.h.in b/config.h.in index 9f4d1b1d7..c7a867245 100755 --- a/config.h.in +++ b/config.h.in @@ -4,6 +4,11 @@ #ifndef CT_CONFIG_H #define CT_CONFIG_H +//---------------------------- Version Flags ------------------// +// Cantera version -> this will be a double-quoted string value +// refering to branch number within svn +#undef CANTERA_VERSION + //---------------------------- Version Flags ------------------// // // Cantera version -> this will be a double-quoted string value @@ -19,6 +24,7 @@ // Flag indictaing that its part of 1.8_LiquidTransportDevelop branch #define CANTERA_VERSION_18_LTD 1 // + //------------------------ Development flags ------------------// // // Compile in additional debug printing where available. diff --git a/test_problems/ChemEquil_gri_matrix/Makefile.in b/test_problems/ChemEquil_gri_matrix/Makefile.in index decf4e6c2..2054185f3 100644 --- a/test_problems/ChemEquil_gri_matrix/Makefile.in +++ b/test_problems/ChemEquil_gri_matrix/Makefile.in @@ -52,7 +52,7 @@ CANTERA_INCLUDES=-I$(CANTERA_INCROOTDIR) -I$(CANTERA_INCROOTDIR)/cantera # LOCAL_DEFS = -DEBUG_BASISOPTIMIZE # # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) +CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/ChemEquil_gri_pairs/Makefile.in b/test_problems/ChemEquil_gri_pairs/Makefile.in index 960309deb..6e4d84b7f 100644 --- a/test_problems/ChemEquil_gri_pairs/Makefile.in +++ b/test_problems/ChemEquil_gri_pairs/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/ChemEquil_ionizedGas/Makefile.in b/test_problems/ChemEquil_ionizedGas/Makefile.in index a36be6324..d77d9ee7a 100644 --- a/test_problems/ChemEquil_ionizedGas/Makefile.in +++ b/test_problems/ChemEquil_ionizedGas/Makefile.in @@ -43,7 +43,7 @@ CXX = @CXX@ # LOCAL_DEFS=-DDEBUG_CHEMEQUIL # # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ $(LOCAL_DEFS) +CXX_FLAGS = @CXXFLAGS@ $(LOCAL_DEFS) @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/ChemEquil_ionizedGas/output_blessed.txt b/test_problems/ChemEquil_ionizedGas/output_blessed.txt index e26422df6..efe6c770a 100644 --- a/test_problems/ChemEquil_ionizedGas/output_blessed.txt +++ b/test_problems/ChemEquil_ionizedGas/output_blessed.txt @@ -322,7 +322,7 @@ Initial T = 414.143, pres = 1.17767e-06 atm NO 5.58575e-12 5.80828e-12 -38.5785 NO+ 4.52092e-104 4.70095e-104 12.1169 Electron 4.52092e-104 8.53846e-109 -254.253 - N+ 8.08849e-210 3.92595e-210 32.1429 + N+ 8.0885e-210 3.92595e-210 32.1429 O+ 3.41902e-171 1.8956e-171 30.6695 N2+ 6.99476e-169 6.79029e-169 13.5903 O2+ 3.64494e-127 4.04179e-127 10.6435 @@ -355,7 +355,7 @@ Initial T = 414.143, pres = 1.17767e-05 atm NO 5.58575e-12 5.80828e-12 -36.2759 NO+ 2.7933e-104 2.90453e-104 13.938 Electron 2.7933e-104 5.27558e-109 -252.432 - N+ 1.58037e-210 7.67069e-211 32.8127 + N+ 1.58037e-210 7.6707e-211 32.8127 O+ 6.68024e-172 3.70371e-172 31.3393 N2+ 4.32179e-169 4.19545e-169 15.4114 O2+ 2.25207e-127 2.49726e-127 12.4646 @@ -424,7 +424,7 @@ Initial T = 414.143, pres = 0.00117767 atm N+ 6.03308e-212 2.9283e-212 34.1523 O+ 2.55019e-173 1.4139e-173 32.6789 N2+ 1.64985e-169 1.60162e-169 19.0536 - O2+ 8.5973e-128 9.53333e-128 16.1068 + O2+ 8.5973e-128 9.53334e-128 16.1068 Final T = 414.143, pres = 0.00117767 atm Initial T = 414.143, pres = 0.0117767 atm @@ -457,7 +457,7 @@ Initial T = 414.143, pres = 0.0117767 atm N+ 1.17877e-212 5.72145e-213 34.8221 O+ 4.98269e-174 2.76254e-174 33.3487 N2+ 1.01938e-169 9.89578e-170 20.8747 - O2+ 5.31193e-128 5.89027e-128 17.9279 + O2+ 5.31194e-128 5.89027e-128 17.9279 Final T = 414.143, pres = 0.0117767 atm Initial T = 1153.16, pres = 3.27918e-08 atm @@ -485,10 +485,10 @@ Initial T = 1153.16, pres = 3.27918e-08 atm N 2.86312e-15 1.38975e-15 -21.3563 O 2.23425e-05 1.23879e-05 -22.8775 NO 0.000134494 0.000139854 -44.2338 - NO+ 9.19995e-24 9.56641e-24 7.08807 - Electron 9.19995e-24 1.73757e-28 -74.3227 - N+ 1.62751e-56 7.89959e-57 29.9656 - O+ 3.109e-43 1.72373e-43 28.4444 + NO+ 9.19996e-24 9.56642e-24 7.08807 + Electron 9.19996e-24 1.73757e-28 -74.3227 + N+ 1.62751e-56 7.8996e-57 29.9656 + O+ 3.109e-43 1.72374e-43 28.4444 N2+ 1.23423e-46 1.19817e-46 8.60924 O2+ 3.28303e-32 3.64051e-32 5.5669 @@ -523,7 +523,7 @@ Initial T = 1152.46, pres = 3.27723e-07 atm N+ 1.39651e-56 6.7783e-57 32.0898 O+ 2.65657e-43 1.47288e-43 30.5686 N2+ 3.33238e-46 3.23497e-46 11.8846 - O2+ 8.8243e-32 9.78508e-32 8.8423 + O2+ 8.8243e-32 9.78509e-32 8.8423 Final T = 1152.61, pres = 3.27763e-07 atm Initial T = 1152.61, pres = 3.27763e-06 atm @@ -551,11 +551,11 @@ Initial T = 1152.61, pres = 3.27763e-06 atm N 2.88709e-16 1.40138e-16 -19.0539 O 2.24413e-06 1.24425e-06 -20.575 NO 0.000134716 0.000140083 -39.6289 - NO+ 6.55508e-23 6.81612e-23 13.6391 - Electron 6.55508e-23 1.23803e-27 -67.7541 + NO+ 6.55509e-23 6.81613e-23 13.6391 + Electron 6.55509e-23 1.23803e-27 -67.7541 N+ 1.17797e-56 5.71759e-57 34.2141 O+ 2.23788e-43 1.24075e-43 32.693 - N2+ 8.87483e-46 8.6154e-46 15.1603 + N2+ 8.87483e-46 8.61541e-46 15.1603 O2+ 2.34675e-31 2.60226e-31 12.1179 Final T = 1152.66, pres = 3.27775e-06 atm @@ -617,11 +617,11 @@ Initial T = 1152.67, pres = 0.000327779 atm N 2.88951e-17 1.40255e-17 -16.7513 O 2.24513e-07 1.24481e-07 -18.2725 NO 0.000134738 0.000140106 -35.0238 - NO+ 4.59472e-22 4.77768e-22 20.1897 + NO+ 4.59472e-22 4.77769e-22 20.1897 Electron 4.59472e-22 8.67784e-27 -61.2017 - N+ 8.26992e-57 4.014e-57 38.4622 - O+ 1.57022e-43 8.70576e-44 36.941 - N2+ 6.22643e-45 6.04441e-45 21.7109 + N+ 8.26992e-57 4.01401e-57 38.4622 + O+ 1.57022e-43 8.70577e-44 36.941 + N2+ 6.22643e-45 6.04442e-45 21.7109 O2+ 1.64546e-30 1.82461e-30 18.6686 Final T = 1152.68, pres = 0.00032778 atm diff --git a/test_problems/ChemEquil_red1/Makefile.in b/test_problems/ChemEquil_red1/Makefile.in index 551ee19f1..6da68eafd 100644 --- a/test_problems/ChemEquil_red1/Makefile.in +++ b/test_problems/ChemEquil_red1/Makefile.in @@ -52,7 +52,7 @@ CANTERA_INCLUDES=-I$(CANTERA_INCROOTDIR) -I$(CANTERA_INCROOTDIR)/cantera # LOCAL_DEFS = -DEBUG_BASISOPTIMIZE # # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) +CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/CpJump/Makefile.in b/test_problems/CpJump/Makefile.in index 2eaf597fc..80d82350d 100644 --- a/test_problems/CpJump/Makefile.in +++ b/test_problems/CpJump/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/VCSnonideal/NaCl_equil/Makefile.in b/test_problems/VCSnonideal/NaCl_equil/Makefile.in index 4f5a8fd0c..9b24dbd03 100644 --- a/test_problems/VCSnonideal/NaCl_equil/Makefile.in +++ b/test_problems/VCSnonideal/NaCl_equil/Makefile.in @@ -45,7 +45,7 @@ CANTERA_INCDIR=@ctroot@/build/include/cantera INCLUDE_DIRS = -I$(CANTERA_INCDIR) # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ $(INCLUDE_DIRS) +CXX_FLAGS = @CXXFLAGS@ $(INCLUDE_DIRS) @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/DH_graph_1/Makefile.in b/test_problems/cathermo/DH_graph_1/Makefile.in index 0cfc4d76a..757519488 100644 --- a/test_problems/cathermo/DH_graph_1/Makefile.in +++ b/test_problems/cathermo/DH_graph_1/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/DH_graph_NM/Makefile.in b/test_problems/cathermo/DH_graph_NM/Makefile.in index 0029fed70..c58bbb03a 100644 --- a/test_problems/cathermo/DH_graph_NM/Makefile.in +++ b/test_problems/cathermo/DH_graph_NM/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/DH_graph_acommon/Makefile.in b/test_problems/cathermo/DH_graph_acommon/Makefile.in index 2f5f6264e..de638c902 100644 --- a/test_problems/cathermo/DH_graph_acommon/Makefile.in +++ b/test_problems/cathermo/DH_graph_acommon/Makefile.in @@ -38,7 +38,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/HMW_dupl_test/Makefile.in b/test_problems/cathermo/HMW_dupl_test/Makefile.in index e210ad1b9..95f410f8c 100644 --- a/test_problems/cathermo/HMW_dupl_test/Makefile.in +++ b/test_problems/cathermo/HMW_dupl_test/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/HMW_graph_CpvT/Makefile.in b/test_problems/cathermo/HMW_graph_CpvT/Makefile.in index 39ae2000a..445a524ff 100644 --- a/test_problems/cathermo/HMW_graph_CpvT/Makefile.in +++ b/test_problems/cathermo/HMW_graph_CpvT/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/HMW_graph_GvI/Makefile.in b/test_problems/cathermo/HMW_graph_GvI/Makefile.in index 505d6ad40..cc2d1cbe2 100644 --- a/test_problems/cathermo/HMW_graph_GvI/Makefile.in +++ b/test_problems/cathermo/HMW_graph_GvI/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = -DSRCDIRTREE @CXXFLAGS@ +CXX_FLAGS = -DSRCDIRTREE @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/HMW_graph_GvT/Makefile.in b/test_problems/cathermo/HMW_graph_GvT/Makefile.in index 0127086c1..c65d4916f 100644 --- a/test_problems/cathermo/HMW_graph_GvT/Makefile.in +++ b/test_problems/cathermo/HMW_graph_GvT/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/HMW_graph_HvT/Makefile.in b/test_problems/cathermo/HMW_graph_HvT/Makefile.in index f23503d3a..b0ecf6a2b 100644 --- a/test_problems/cathermo/HMW_graph_HvT/Makefile.in +++ b/test_problems/cathermo/HMW_graph_HvT/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/HMW_graph_VvT/Makefile.in b/test_problems/cathermo/HMW_graph_VvT/Makefile.in index 8325e574c..cd5437328 100644 --- a/test_problems/cathermo/HMW_graph_VvT/Makefile.in +++ b/test_problems/cathermo/HMW_graph_VvT/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/VPissp/Makefile.in b/test_problems/cathermo/VPissp/Makefile.in index ae869c571..59082ea8c 100644 --- a/test_problems/cathermo/VPissp/Makefile.in +++ b/test_problems/cathermo/VPissp/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/issp/Makefile.in b/test_problems/cathermo/issp/Makefile.in index f4cd8710e..366a13061 100644 --- a/test_problems/cathermo/issp/Makefile.in +++ b/test_problems/cathermo/issp/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/stoichSubSSTP/Makefile.in b/test_problems/cathermo/stoichSubSSTP/Makefile.in index 7b733c665..71498b17f 100644 --- a/test_problems/cathermo/stoichSubSSTP/Makefile.in +++ b/test_problems/cathermo/stoichSubSSTP/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/testWaterTP/Makefile.in b/test_problems/cathermo/testWaterTP/Makefile.in index 685de3f4b..1dd7c0eb6 100644 --- a/test_problems/cathermo/testWaterTP/Makefile.in +++ b/test_problems/cathermo/testWaterTP/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/cathermo/wtWater/Makefile.in b/test_problems/cathermo/wtWater/Makefile.in index a34cc1ce2..3aaaec32d 100755 --- a/test_problems/cathermo/wtWater/Makefile.in +++ b/test_problems/cathermo/wtWater/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ @@ -101,7 +101,6 @@ endif clean: $(RM) $(OBJS) $(PROGRAM) $(DEPENDS) .depends - ../../../bin/rm_cvsignore (if test -d SunWS_cache ; then \ $(RM) -rf SunWS_cache ; \ fi ) diff --git a/test_problems/cxx_ex/Makefile.in b/test_problems/cxx_ex/Makefile.in index cff1beeef..e5e889844 100644 --- a/test_problems/cxx_ex/Makefile.in +++ b/test_problems/cxx_ex/Makefile.in @@ -11,7 +11,6 @@ test: clean: (cd ../../examples/cxx ; @MAKE@ clean ) - ../../bin/rm_cvsignore depends: diff --git a/test_problems/fracCoeff/Makefile.in b/test_problems/fracCoeff/Makefile.in index 275ee94ad..a4b2bd09c 100644 --- a/test_problems/fracCoeff/Makefile.in +++ b/test_problems/fracCoeff/Makefile.in @@ -39,7 +39,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/negATest/Makefile.in b/test_problems/negATest/Makefile.in index ef159696a..bd11bd1b4 100644 --- a/test_problems/negATest/Makefile.in +++ b/test_problems/negATest/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/python/flame1/runtest b/test_problems/python/flame1/runtest index 2b9e597c1..6dbc682f7 100755 --- a/test_problems/python/flame1/runtest +++ b/test_problems/python/flame1/runtest @@ -76,7 +76,7 @@ then fi else echo " Unsuccessful test comparison on "`pwd` " test" - if test $retnStat_csv != "1" + if test $retnStat_csv != "0" then echo " csv files are different - see diff_csv.txt" fi diff --git a/test_problems/python/runtest b/test_problems/python/runtest index c74c618b6..0551c28f6 100755 --- a/test_problems/python/runtest +++ b/test_problems/python/runtest @@ -68,7 +68,7 @@ then echo "diamond.py returned with bad status, $retnStat, check output" fi -$CANTERA_BIN/csvdiff diamond.csv diamond_blessed.csv > diamond_test.out +$CANTERA_BIN/csvdiff diamond.csv diamond_blessed.csv > diamond_test_csv.out retnStat=$? if [ $retnStat = "0" ] then diff --git a/test_problems/rankine_democxx/Makefile.in b/test_problems/rankine_democxx/Makefile.in index 781edc60e..19a4a97af 100644 --- a/test_problems/rankine_democxx/Makefile.in +++ b/test_problems/rankine_democxx/Makefile.in @@ -51,7 +51,7 @@ CANTERA_INCLUDES=-I$(CANTERA_INCROOTDIR) -I$(CANTERA_INCROOTDIR)/cantera # LOCAL_DEFS = -DEBUG_BASISOPTIMIZE # # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) +CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/test_problems/surfSolverTest/Makefile.in b/test_problems/surfSolverTest/Makefile.in index 887eddc3e..c3e454b9b 100644 --- a/test_problems/surfSolverTest/Makefile.in +++ b/test_problems/surfSolverTest/Makefile.in @@ -37,7 +37,7 @@ endif CXX = @CXX@ # C++ compile flags -CXX_FLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@ # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ diff --git a/winconfig.h b/winconfig.h index 94984e233..321ac035f 100644 --- a/winconfig.h +++ b/winconfig.h @@ -8,7 +8,6 @@ // Cantera version -> this will be a double-quoted string value // refering to branch number within svn #define CANTERA_VERSION "1.8_liquidTransportDevelop" - // Integer for major number of Cantera #define CANTERA_VERSION_MAJORNUMBER 18 // Flag indicating it's part of major version 18 @@ -18,6 +17,19 @@ // Flag indictaing that its part of 1.8_LiquidTransportDevelop branch #define CANTERA_VERSION_18_LTD 1 +//---------------------------- Version Flags ------------------// +// Cantera version -> this will be a double-quoted string value +// refering to branch number within svn +#define CANTERA_VERSION "1.8.x" + +// Integer for major number of Cantera +#define CANTERA_VERSION_MAJORNUMBER 18 +// Flag indicating it's part of major version 18 +#define CANTERA_VERSION_18 1 +// Flag indicating it's a development version +#define CANTERA_VERSION_18_XXX 1 + + //------------------------ Development flags ------------------// // // Compile in additional debug printing where available. @@ -76,6 +88,7 @@ typedef int ftnlen; // Fortran hidden string length type /* #undef DARWIN */ #define HAS_SSTREAM 1 + // Identify whether the operating system is cygwin's overlay of // windows, with gcc being used as the compiler. /* #undef CYGWIN */