mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Applied consistent formatting to all C++ code
Done using astyle: astyle --style=kr --add-brackets --indent=spaces=4 --indent-col1-comments --unpad-paren --pad-header --align-pointer=type --lineend=linux
This commit is contained in:
70
Cantera/clib/src/Cabinet.h
Executable file → Normal file
70
Cantera/clib/src/Cabinet.h
Executable file → Normal file
@@ -58,13 +58,16 @@
|
||||
*/
|
||||
|
||||
template<class M>
|
||||
class Cabinet {
|
||||
class Cabinet
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor. Delete all objects in the list.
|
||||
*/
|
||||
virtual ~Cabinet() {clear();}
|
||||
virtual ~Cabinet() {
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function that returns a pointer to the one Cabinet<M>
|
||||
@@ -79,8 +82,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new object. The index of the object is returned.
|
||||
/**
|
||||
* Add a new object. The index of the object is returned.
|
||||
*/
|
||||
int add(M* ptr) {
|
||||
//try {
|
||||
@@ -92,7 +95,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Make a new copy of an existing object. The index of the new
|
||||
* object is returned.
|
||||
*/
|
||||
@@ -101,13 +104,15 @@ public:
|
||||
M* old = __table[i];
|
||||
__table.push_back(new M(*old));
|
||||
return static_cast<int>(__table.size()) - 1;
|
||||
} catch (Cantera::CanteraError) {
|
||||
return -1;
|
||||
} catch (...) {
|
||||
return -999;
|
||||
}
|
||||
catch (Cantera::CanteraError) {return -1;}
|
||||
catch (...) {return -999;}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Assign one object (index j) to another (index i). This method
|
||||
* is not used currently, and may be removed from the class in the
|
||||
* future.
|
||||
@@ -118,20 +123,26 @@ public:
|
||||
M* dest = __table[i];
|
||||
*dest = *src;
|
||||
return 0;
|
||||
} catch (Cantera::CanteraError) {
|
||||
return -1;
|
||||
} catch (...) {
|
||||
return -999;
|
||||
}
|
||||
catch (Cantera::CanteraError) {return -1;}
|
||||
catch (...) {return -999;}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Delete all objects but the first.
|
||||
*/
|
||||
int clear() {
|
||||
int i, n;
|
||||
n = static_cast<int>(__table.size());
|
||||
for (i = 1; i < n; i++) {del(i);}
|
||||
if (_can_delete) delete __table[0];
|
||||
for (i = 1; i < n; i++) {
|
||||
del(i);
|
||||
}
|
||||
if (_can_delete) {
|
||||
delete __table[0];
|
||||
}
|
||||
__table.clear();
|
||||
add(new M);
|
||||
return 0;
|
||||
@@ -144,39 +155,44 @@ public:
|
||||
* in the list.
|
||||
*/
|
||||
void del(int n) {
|
||||
if (n == 0) return;
|
||||
if (__table[n] != __table[0]) {
|
||||
if (_can_delete) delete __table[n];
|
||||
__table[n] = __table[0];
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
if (__table[n] != __table[0]) {
|
||||
if (_can_delete) {
|
||||
delete __table[n];
|
||||
}
|
||||
__table[n] = __table[0];
|
||||
} else {
|
||||
throw Cantera::CanteraError("Cabinet<M>::del",
|
||||
"Attempt made to delete an already-deleted object.");
|
||||
}
|
||||
else {
|
||||
throw Cantera::CanteraError("Cabinet<M>::del",
|
||||
"Attempt made to delete an already-deleted object.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return a pointer to object n.
|
||||
*/
|
||||
M* item(size_t n) {
|
||||
if (n < __table.size())
|
||||
if (n < __table.size()) {
|
||||
return __table[n];
|
||||
else {
|
||||
} else {
|
||||
throw Cantera::CanteraError("item","index out of range"+Cantera::int2str(int(n)));
|
||||
//return __table[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor.
|
||||
*/
|
||||
Cabinet(bool canDelete = true) : _can_delete(canDelete) { add(new M); }
|
||||
Cabinet(bool canDelete = true) : _can_delete(canDelete) {
|
||||
add(new M);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor.
|
||||
*/
|
||||
// Cabinet(bool canDelete = true) : _can_delete(canDelete) { add(new M); }
|
||||
|
||||
|
||||
68
Cantera/clib/src/Storage.cpp
Executable file → Normal file
68
Cantera/clib/src/Storage.cpp
Executable file → Normal file
@@ -11,17 +11,23 @@ using namespace std;
|
||||
using namespace Cantera;
|
||||
|
||||
|
||||
Storage::Storage() {
|
||||
Storage::Storage()
|
||||
{
|
||||
addThermo(new ThermoPhase);
|
||||
addKinetics(new Kinetics);
|
||||
addTransport(newTransportMgr());
|
||||
}
|
||||
|
||||
Storage::~Storage() { clear(); }
|
||||
Storage::~Storage()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
size_t Storage::addThermo(thermo_t* th) {
|
||||
if (th->index() != npos)
|
||||
size_t Storage::addThermo(thermo_t* th)
|
||||
{
|
||||
if (th->index() != npos) {
|
||||
return th->index();
|
||||
}
|
||||
__thtable.push_back(th);
|
||||
size_t n = __thtable.size() - 1;
|
||||
th->setIndex(n);
|
||||
@@ -37,33 +43,38 @@ size_t Storage::addThermo(thermo_t* th) {
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t Storage::nThermo() {
|
||||
return __thtable.size();
|
||||
size_t Storage::nThermo()
|
||||
{
|
||||
return __thtable.size();
|
||||
}
|
||||
|
||||
size_t Storage::addKinetics(Kinetics* kin) {
|
||||
if (kin->index() != npos)
|
||||
size_t Storage::addKinetics(Kinetics* kin)
|
||||
{
|
||||
if (kin->index() != npos) {
|
||||
return kin->index();
|
||||
}
|
||||
__ktable.push_back(kin);
|
||||
size_t n = __ktable.size() - 1;
|
||||
kin->setIndex(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t Storage::addTransport(Transport* tr) {
|
||||
if (tr->index() != npos)
|
||||
size_t Storage::addTransport(Transport* tr)
|
||||
{
|
||||
if (tr->index() != npos) {
|
||||
return tr->index();
|
||||
}
|
||||
__trtable.push_back(tr);
|
||||
size_t n = __trtable.size() - 1;
|
||||
tr->setIndex(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
// int Storage::addNewTransport(int model, char* dbase, int th,
|
||||
// int Storage::addNewTransport(int model, char* dbase, int th,
|
||||
// int loglevel) {
|
||||
// try {
|
||||
// ThermoPhase* thrm = __thtable[th];
|
||||
// Transport* tr = newTransportMgr(model,
|
||||
// Transport* tr = newTransportMgr(model,
|
||||
// string(dbase), thrm, loglevel);
|
||||
// __trtable.push_back(tr);
|
||||
// return __trtable.size() - 1;
|
||||
@@ -72,7 +83,8 @@ size_t Storage::addTransport(Transport* tr) {
|
||||
// catch (...) {return ERR;}
|
||||
// }
|
||||
|
||||
int Storage::clear() {
|
||||
int Storage::clear()
|
||||
{
|
||||
size_t i, n;
|
||||
n = __thtable.size();
|
||||
for (i = 1; i < n; i++) {
|
||||
@@ -98,24 +110,36 @@ int Storage::clear() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Storage::deleteKinetics(int n) {
|
||||
if (n == 0) return;
|
||||
if (__ktable[n] != __ktable[0])
|
||||
void Storage::deleteKinetics(int n)
|
||||
{
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
if (__ktable[n] != __ktable[0]) {
|
||||
delete __ktable[n];
|
||||
}
|
||||
__ktable[n] = __ktable[0];
|
||||
}
|
||||
|
||||
void Storage::deleteThermo(int n) {
|
||||
if (n == 0) return;
|
||||
if (n < 0 || n >= (int) __thtable.size())
|
||||
void Storage::deleteThermo(int n)
|
||||
{
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
if (n < 0 || n >= (int) __thtable.size()) {
|
||||
throw CanteraError("deleteThermo","illegal index");
|
||||
}
|
||||
__thtable[n] = __thtable[0];
|
||||
}
|
||||
|
||||
void Storage::deleteTransport(int n) {
|
||||
if (n == 0) return;
|
||||
if (__trtable[n] != __trtable[0])
|
||||
void Storage::deleteTransport(int n)
|
||||
{
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
if (__trtable[n] != __trtable[0]) {
|
||||
delete __trtable[n];
|
||||
}
|
||||
__trtable[n] = __trtable[0];
|
||||
}
|
||||
|
||||
|
||||
18
Cantera/clib/src/Storage.h
Executable file → Normal file
18
Cantera/clib/src/Storage.h
Executable file → Normal file
@@ -16,7 +16,8 @@
|
||||
* Class to hold pointers to Cantera objects. Only one instance of
|
||||
* this class is needed.
|
||||
*/
|
||||
class Storage {
|
||||
class Storage
|
||||
{
|
||||
public:
|
||||
Storage();
|
||||
virtual ~Storage();
|
||||
@@ -48,23 +49,28 @@ public:
|
||||
static Storage* __storage;
|
||||
};
|
||||
|
||||
inline Cantera::ThermoPhase* ph(int n) {
|
||||
inline Cantera::ThermoPhase* ph(int n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline Cantera::Kinetics* kin(int n) {
|
||||
inline Cantera::Kinetics* kin(int n)
|
||||
{
|
||||
return Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
inline Cantera::ThermoPhase* th(size_t n) {
|
||||
inline Cantera::ThermoPhase* th(size_t n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline int thermo_index(std::string id) {
|
||||
inline int thermo_index(std::string id)
|
||||
{
|
||||
return Storage::__storage->__thmap[id];
|
||||
}
|
||||
|
||||
inline Cantera::Transport* trans(int n) {
|
||||
inline Cantera::Transport* trans(int n)
|
||||
{
|
||||
return Storage::__storage->__trtable[n];
|
||||
}
|
||||
|
||||
|
||||
6
Cantera/clib/src/clib_defs.h
Executable file → Normal file
6
Cantera/clib/src/clib_defs.h
Executable file → Normal file
@@ -7,8 +7,8 @@
|
||||
#include "kernel/ct_defs.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
// Either build as a DLL under Windows or not.
|
||||
// the decision relies upon whether the NO_DLL_BUILD define is
|
||||
// Either build as a DLL under Windows or not.
|
||||
// the decision relies upon whether the NO_DLL_BUILD define is
|
||||
// set or not.
|
||||
#ifdef NO_DLL_BUILD
|
||||
#define DLL_EXPORT
|
||||
@@ -28,7 +28,7 @@
|
||||
#define EEXXTT extern
|
||||
#else
|
||||
#define DLL_CPREFIX DLL_IMPORT
|
||||
#define EEXXTT
|
||||
#define EEXXTT
|
||||
#endif
|
||||
|
||||
// Values returned for error conditions
|
||||
|
||||
1136
Cantera/clib/src/ct.cpp
Executable file → Normal file
1136
Cantera/clib/src/ct.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
48
Cantera/clib/src/ct.h
Executable file → Normal file
48
Cantera/clib/src/ct.h
Executable file → Normal file
@@ -30,9 +30,9 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX phase_getMoleFractions(int n, size_t lenx, double* x);
|
||||
EEXXTT int DLL_CPREFIX phase_getMassFractions(int n, size_t leny, double* y);
|
||||
EEXXTT int DLL_CPREFIX phase_setMoleFractions(int n, size_t lenx,
|
||||
double* x, int norm);
|
||||
double* x, int norm);
|
||||
EEXXTT int DLL_CPREFIX phase_setMassFractions(int n, size_t leny,
|
||||
double* y, int norm);
|
||||
double* y, int norm);
|
||||
EEXXTT int DLL_CPREFIX phase_setMoleFractionsByName(int n, char* x);
|
||||
EEXXTT int DLL_CPREFIX phase_setMassFractionsByName(int n, char* y);
|
||||
EEXXTT int DLL_CPREFIX phase_getAtomicWeights(int n, size_t lenm, double* atw);
|
||||
@@ -43,19 +43,19 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX phase_setName(int n, const char* nm);
|
||||
EEXXTT size_t DLL_CPREFIX phase_elementIndex(int n, char* nm);
|
||||
EEXXTT size_t DLL_CPREFIX phase_speciesIndex(int n, char* nm);
|
||||
EEXXTT int DLL_CPREFIX phase_report(int nth,
|
||||
int ibuf, char* buf, int show_thermo);
|
||||
EEXXTT int DLL_CPREFIX phase_report(int nth,
|
||||
int ibuf, char* buf, int show_thermo);
|
||||
EEXXTT int DLL_EXPORT write_phase(int nth, int show_thermo);
|
||||
|
||||
EEXXTT double DLL_CPREFIX phase_nAtoms(int n, size_t k, size_t m);
|
||||
|
||||
EEXXTT int DLL_CPREFIX phase_addElement(int n, char* name, double weight);
|
||||
EEXXTT int DLL_CPREFIX phase_addSpecies(int n, char* name, int phase,
|
||||
int ncomp, double* comp, int thermoType, int ncoeffs,
|
||||
double* coeffs, double minTemp, double maxTemp, double refPressure,
|
||||
double charge, double weight);
|
||||
int ncomp, double* comp, int thermoType, int ncoeffs,
|
||||
double* coeffs, double minTemp, double maxTemp, double refPressure,
|
||||
double charge, double weight);
|
||||
|
||||
//int DLL_CPREFIX newThermo(char* model);
|
||||
//int DLL_CPREFIX newThermo(char* model);
|
||||
EEXXTT size_t DLL_CPREFIX newThermoFromXML(int mxml);
|
||||
EEXXTT int DLL_CPREFIX th_thermoIndex(char* id);
|
||||
EEXXTT int DLL_CPREFIX th_phase(int n);
|
||||
@@ -92,8 +92,8 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX th_set_SV(int n, double* vals);
|
||||
EEXXTT int DLL_CPREFIX th_set_SP(int n, double* vals);
|
||||
EEXXTT int DLL_CPREFIX th_equil(int n, char* XY, int solver,
|
||||
double rtol, int maxsteps, int maxiter, int loglevel);
|
||||
|
||||
double rtol, int maxsteps, int maxiter, int loglevel);
|
||||
|
||||
EEXXTT double DLL_CPREFIX th_critTemperature(int n);
|
||||
EEXXTT double DLL_CPREFIX th_critPressure(int n);
|
||||
EEXXTT double DLL_CPREFIX th_critDensity(int n);
|
||||
@@ -104,10 +104,10 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX th_setState_Tsat(int n, double t, double x);
|
||||
|
||||
EEXXTT size_t DLL_CPREFIX newKineticsFromXML(int mxml, int iphase,
|
||||
int neighbor1=-1, int neighbor2=-1, int neighbor3=-1,
|
||||
int neighbor4=-1);
|
||||
EEXXTT int DLL_CPREFIX installRxnArrays(int pxml, int ikin,
|
||||
char* default_phase);
|
||||
int neighbor1=-1, int neighbor2=-1, int neighbor3=-1,
|
||||
int neighbor4=-1);
|
||||
EEXXTT int DLL_CPREFIX installRxnArrays(int pxml, int ikin,
|
||||
char* default_phase);
|
||||
EEXXTT size_t DLL_CPREFIX kin_nSpecies(int n);
|
||||
EEXXTT size_t DLL_CPREFIX kin_nReactions(int n);
|
||||
EEXXTT size_t DLL_CPREFIX kin_nPhases(int n);
|
||||
@@ -141,7 +141,7 @@ extern "C" {
|
||||
EEXXTT size_t DLL_CPREFIX kin_phase(int n, size_t i);
|
||||
|
||||
EEXXTT size_t DLL_CPREFIX newTransport(char* model,
|
||||
int th, int loglevel);
|
||||
int th, int loglevel);
|
||||
EEXXTT double DLL_CPREFIX trans_viscosity(int n);
|
||||
EEXXTT double DLL_CPREFIX trans_thermalConductivity(int n);
|
||||
EEXXTT int DLL_CPREFIX trans_getThermalDiffCoeffs(int n, int ldt, double* dt);
|
||||
@@ -150,15 +150,15 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX trans_getMultiDiffCoeffs(int n, int ld, double* d);
|
||||
EEXXTT int DLL_CPREFIX trans_setParameters(int n, int type, int k, double* d);
|
||||
EEXXTT int DLL_CPREFIX trans_getMolarFluxes(int n, const double* state1,
|
||||
const double* state2, double delta, double* fluxes);
|
||||
const double* state2, double delta, double* fluxes);
|
||||
EEXXTT int DLL_CPREFIX trans_getMassFluxes(int n, const double* state1,
|
||||
const double* state2, double delta, double* fluxes);
|
||||
const double* state2, double delta, double* fluxes);
|
||||
|
||||
EEXXTT int DLL_CPREFIX import_phase(int nth, int nxml, char* id);
|
||||
EEXXTT int DLL_CPREFIX import_kinetics(int nxml, char* id,
|
||||
int nphases, int* ith, int nkin);
|
||||
EEXXTT int DLL_CPREFIX import_from_file(int nth, int nkin, char* fname, char* db,
|
||||
char* id, int validate, double threshold);
|
||||
EEXXTT int DLL_CPREFIX import_kinetics(int nxml, char* id,
|
||||
int nphases, int* ith, int nkin);
|
||||
EEXXTT int DLL_CPREFIX import_from_file(int nth, int nkin, char* fname, char* db,
|
||||
char* id, int validate, double threshold);
|
||||
EEXXTT int DLL_CPREFIX getCanteraError(int buflen, char* buf);
|
||||
EEXXTT int DLL_CPREFIX showCanteraErrors();
|
||||
EEXXTT int DLL_CPREFIX write_HTML_log(char* file);
|
||||
@@ -170,11 +170,11 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX delKinetics(int n);
|
||||
EEXXTT int DLL_CPREFIX delTransport(int n);
|
||||
EEXXTT int DLL_CPREFIX readlog(int n, char* buf);
|
||||
EEXXTT int DLL_CPREFIX buildSolutionFromXML(char* src, int ixml, char* id,
|
||||
int ith, int ikin);
|
||||
EEXXTT int DLL_CPREFIX buildSolutionFromXML(char* src, int ixml, char* id,
|
||||
int ith, int ikin);
|
||||
|
||||
EEXXTT int DLL_CPREFIX ck_to_cti(char* in_file, char* db_file,
|
||||
char* tr_file, char* id_tag, int debug, int validate);
|
||||
char* tr_file, char* id_tag, int debug, int validate);
|
||||
EEXXTT int DLL_CPREFIX writelogfile(char* logfile);
|
||||
}
|
||||
|
||||
|
||||
79
Cantera/clib/src/ctbdry.cpp
Executable file → Normal file
79
Cantera/clib/src/ctbdry.cpp
Executable file → Normal file
@@ -17,7 +17,8 @@ using namespace Cantera;
|
||||
|
||||
template<> Cabinet<Bdry1D>* Cabinet<Bdry1D>::__storage = 0;
|
||||
|
||||
inline Bdry1D* _bndry(int i) {
|
||||
inline Bdry1D* _bndry(int i)
|
||||
{
|
||||
return Cabinet<Bdry1D>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
@@ -25,27 +26,34 @@ inline Bdry1D* _bndry(int i) {
|
||||
// return Storage::__storage->__phasetable[n];
|
||||
//}
|
||||
|
||||
inline ThermoPhase* _thermo(int n) {
|
||||
inline ThermoPhase* _thermo(int n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline Kinetics* _kin(int n) {
|
||||
inline Kinetics* _kin(int n)
|
||||
{
|
||||
return Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT bndry_new(int itype) {
|
||||
int DLL_EXPORT bndry_new(int itype)
|
||||
{
|
||||
Bdry1D* s;
|
||||
switch (itype) {
|
||||
case 1:
|
||||
s = new Inlet1D(); break;
|
||||
case 2:
|
||||
s = new Symm1D(); break;
|
||||
s = new Inlet1D();
|
||||
break;
|
||||
case 2:
|
||||
s = new Symm1D();
|
||||
break;
|
||||
case 3:
|
||||
s = new Surf1D(); break;
|
||||
s = new Surf1D();
|
||||
break;
|
||||
case 4:
|
||||
s = new ReactingSurf1D(); break;
|
||||
s = new ReactingSurf1D();
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
@@ -53,76 +61,93 @@ extern "C" {
|
||||
return i;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bndry_del(int i) {
|
||||
int DLL_EXPORT bndry_del(int i)
|
||||
{
|
||||
Cabinet<Bdry1D>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT bndry_temperature(int i) {
|
||||
double DLL_EXPORT bndry_temperature(int i)
|
||||
{
|
||||
return _bndry(i)->temperature();
|
||||
}
|
||||
|
||||
int DLL_EXPORT bndry_settemperature(int i, double t) {
|
||||
int DLL_EXPORT bndry_settemperature(int i, double t)
|
||||
{
|
||||
try {
|
||||
_bndry(i)->setTemperature(t);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT bndry_spreadrate(int i) {
|
||||
double DLL_EXPORT bndry_spreadrate(int i)
|
||||
{
|
||||
try {
|
||||
return ((Inlet1D*)_bndry(i))->spreadRate();
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bndry_setSpreadRate(int i, double v) {
|
||||
int DLL_EXPORT bndry_setSpreadRate(int i, double v)
|
||||
{
|
||||
try {
|
||||
((Inlet1D*)_bndry(i))->setSpreadRate(v);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bndry_setmdot(int i, double mdot) {
|
||||
int DLL_EXPORT bndry_setmdot(int i, double mdot)
|
||||
{
|
||||
try {
|
||||
_bndry(i)->setMdot(mdot);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
double DLL_EXPORT bndry_mdot(int i) {
|
||||
double DLL_EXPORT bndry_mdot(int i)
|
||||
{
|
||||
return _bndry(i)->mdot();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bndry_setxin(int i, double* xin) {
|
||||
int DLL_EXPORT bndry_setxin(int i, double* xin)
|
||||
{
|
||||
try {
|
||||
_bndry(i)->setMoleFractions(xin);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bndry_setxinbyname(int i, char* xin) {
|
||||
int DLL_EXPORT bndry_setxinbyname(int i, char* xin)
|
||||
{
|
||||
try {
|
||||
_bndry(i)->setMoleFractions(string(xin));
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_setkinetics(int i, int j) {
|
||||
int DLL_EXPORT surf_setkinetics(int i, int j)
|
||||
{
|
||||
try {
|
||||
ReactingSurf1D* srf = (ReactingSurf1D*)_bndry(i);
|
||||
InterfaceKinetics* k = (InterfaceKinetics*)_kin(j);
|
||||
srf->setKineticsMgr(k);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
140
Cantera/clib/src/ctfunc.cpp
Executable file → Normal file
140
Cantera/clib/src/ctfunc.cpp
Executable file → Normal file
@@ -18,140 +18,134 @@ typedef Func1 func_t;
|
||||
// Assign storage to the Cabinet<Func1> static member
|
||||
template<> Cabinet<func_t>* Cabinet<func_t>::__storage = 0;
|
||||
|
||||
inline func_t* _func(size_t i) {
|
||||
inline func_t* _func(size_t i)
|
||||
{
|
||||
return Cabinet<func_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
// functions
|
||||
|
||||
int DLL_EXPORT func_new(int type, size_t n, size_t lenp, double* params) {
|
||||
int DLL_EXPORT func_new(int type, size_t n, size_t lenp, double* params)
|
||||
{
|
||||
func_t* r=0;
|
||||
size_t m = lenp;
|
||||
try {
|
||||
if (type == SinFuncType) {
|
||||
r = new Sin1(params[0]);
|
||||
}
|
||||
else if (type == CosFuncType) {
|
||||
} else if (type == CosFuncType) {
|
||||
r = new Cos1(params[0]);
|
||||
}
|
||||
else if (type == ExpFuncType) {
|
||||
} else if (type == ExpFuncType) {
|
||||
r = new Exp1(params[0]);
|
||||
}
|
||||
else if (type == PowFuncType) {
|
||||
if (lenp < 1)
|
||||
throw CanteraError("func_new",
|
||||
"exponent for pow must be supplied");
|
||||
} else if (type == PowFuncType) {
|
||||
if (lenp < 1)
|
||||
throw CanteraError("func_new",
|
||||
"exponent for pow must be supplied");
|
||||
r = new Pow1(params[0]);
|
||||
}
|
||||
else if (type == ConstFuncType) {
|
||||
} else if (type == ConstFuncType) {
|
||||
r = new Const1(params[0]);
|
||||
}
|
||||
else if (type == FourierFuncType) {
|
||||
if (lenp < 2*n + 2)
|
||||
throw CanteraError("func_new",
|
||||
"not enough Fourier coefficients");
|
||||
r = new Fourier1(n, params[n+1], params[0], params + 1,
|
||||
params + n + 2);
|
||||
}
|
||||
else if (type == GaussianFuncType) {
|
||||
if (lenp < 3)
|
||||
throw CanteraError("func_new",
|
||||
"not enough Gaussian coefficients");
|
||||
} else if (type == FourierFuncType) {
|
||||
if (lenp < 2*n + 2)
|
||||
throw CanteraError("func_new",
|
||||
"not enough Fourier coefficients");
|
||||
r = new Fourier1(n, params[n+1], params[0], params + 1,
|
||||
params + n + 2);
|
||||
} else if (type == GaussianFuncType) {
|
||||
if (lenp < 3)
|
||||
throw CanteraError("func_new",
|
||||
"not enough Gaussian coefficients");
|
||||
r = new Gaussian(params[0], params[1], params[2]);
|
||||
}
|
||||
else if (type == PolyFuncType) {
|
||||
if (lenp < n + 1)
|
||||
throw CanteraError("func_new",
|
||||
"not enough polynomial coefficients");
|
||||
} else if (type == PolyFuncType) {
|
||||
if (lenp < n + 1)
|
||||
throw CanteraError("func_new",
|
||||
"not enough polynomial coefficients");
|
||||
r = new Poly1(n, params);
|
||||
}
|
||||
else if (type == ArrheniusFuncType) {
|
||||
if (lenp < 3*n)
|
||||
throw CanteraError("func_new",
|
||||
"not enough Arrhenius coefficients");
|
||||
} else if (type == ArrheniusFuncType) {
|
||||
if (lenp < 3*n)
|
||||
throw CanteraError("func_new",
|
||||
"not enough Arrhenius coefficients");
|
||||
r = new Arrhenius1(n, params);
|
||||
}
|
||||
else if (type == PeriodicFuncType) {
|
||||
} else if (type == PeriodicFuncType) {
|
||||
r = new Periodic1(*_func(n), params[0]);
|
||||
}
|
||||
else if (type == SumFuncType) {
|
||||
} else if (type == SumFuncType) {
|
||||
r = &newSumFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
}
|
||||
else if (type == DiffFuncType) {
|
||||
r = &newDiffFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
}
|
||||
else if (type == ProdFuncType) {
|
||||
r = &newProdFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
}
|
||||
else if (type == RatioFuncType) {
|
||||
r = &newRatioFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
}
|
||||
else if (type == CompositeFuncType) {
|
||||
r = &newCompositeFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
}
|
||||
else if (type == TimesConstantFuncType) {
|
||||
_func(m)->duplicate());
|
||||
} else if (type == DiffFuncType) {
|
||||
r = &newDiffFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
} else if (type == ProdFuncType) {
|
||||
r = &newProdFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
} else if (type == RatioFuncType) {
|
||||
r = &newRatioFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
} else if (type == CompositeFuncType) {
|
||||
r = &newCompositeFunction(_func(n)->duplicate(),
|
||||
_func(m)->duplicate());
|
||||
} else if (type == TimesConstantFuncType) {
|
||||
r = &newTimesConstFunction(_func(n)->duplicate(), params[0]);
|
||||
}
|
||||
else if (type == PlusConstantFuncType) {
|
||||
} else if (type == PlusConstantFuncType) {
|
||||
r = &newPlusConstFunction(_func(n)->duplicate(), params[0]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw CanteraError("func_new","unknown function type");
|
||||
r = new Func1();
|
||||
}
|
||||
return Cabinet<func_t>::cabinet()->add(r);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT func_del(int i) {
|
||||
int DLL_EXPORT func_del(int i)
|
||||
{
|
||||
Cabinet<func_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT func_copy(int i) {
|
||||
int DLL_EXPORT func_copy(int i)
|
||||
{
|
||||
return Cabinet<func_t>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT func_assign(int i, int j) {
|
||||
int DLL_EXPORT func_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<func_t>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
double DLL_EXPORT func_value(int i, double t) {
|
||||
double DLL_EXPORT func_value(int i, double t)
|
||||
{
|
||||
return _func(i)->eval(t);
|
||||
}
|
||||
|
||||
int DLL_EXPORT func_derivative(int i) {
|
||||
int DLL_EXPORT func_derivative(int i)
|
||||
{
|
||||
func_t* r = 0;
|
||||
r = &_func(i)->derivative();
|
||||
return Cabinet<func_t>::cabinet()->add(r);
|
||||
}
|
||||
|
||||
int DLL_EXPORT func_duplicate(int i) {
|
||||
int DLL_EXPORT func_duplicate(int i)
|
||||
{
|
||||
func_t* r = 0;
|
||||
r = &_func(i)->duplicate();
|
||||
return Cabinet<func_t>::cabinet()->add(r);
|
||||
}
|
||||
|
||||
int DLL_EXPORT func_write(int i, size_t lennm, const char* arg, char* nm) {
|
||||
int DLL_EXPORT func_write(int i, size_t lennm, const char* arg, char* nm)
|
||||
{
|
||||
try {
|
||||
std::string a = std::string(arg);
|
||||
std::string w = _func(i)->write(a);
|
||||
size_t ws = w.size();
|
||||
size_t lout = (lennm > ws ? ws : lennm);
|
||||
std::copy(w.c_str(), w.c_str() + lout, nm);
|
||||
std::copy(w.c_str(), w.c_str() + lout, nm);
|
||||
nm[lout] = '\0';
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,279 +20,335 @@ typedef MultiPhase mix_t;
|
||||
|
||||
template<> Cabinet<mix_t>* Cabinet<mix_t>::__storage = 0;
|
||||
|
||||
inline mix_t* _mix(int i) {
|
||||
inline mix_t* _mix(int i)
|
||||
{
|
||||
return Cabinet<mix_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline ThermoPhase* _th(int n) {
|
||||
inline ThermoPhase* _th(int n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
static bool checkSpecies(int i, size_t k) {
|
||||
static bool checkSpecies(int i, size_t k)
|
||||
{
|
||||
try {
|
||||
if (k >= _mix(i)->nSpecies())
|
||||
throw CanteraError("checkSpecies",
|
||||
"illegal species index ("+int2str(int(k))+") ");
|
||||
"illegal species index ("+int2str(int(k))+") ");
|
||||
return true;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool checkElement(int i, size_t m) {
|
||||
static bool checkElement(int i, size_t m)
|
||||
{
|
||||
try {
|
||||
if (m >= _mix(i)->nElements())
|
||||
throw CanteraError("checkElement",
|
||||
"illegal element index ("+int2str(int(m))+") ");
|
||||
"illegal element index ("+int2str(int(m))+") ");
|
||||
return true;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool checkPhase(int i, int n) {
|
||||
static bool checkPhase(int i, int n)
|
||||
{
|
||||
try {
|
||||
if (n < 0 || n >= int(_mix(i)->nPhases()))
|
||||
if (n < 0 || n >= int(_mix(i)->nPhases()))
|
||||
throw CanteraError("checkPhase",
|
||||
"illegal phase index ("+int2str(n)+") ");
|
||||
"illegal phase index ("+int2str(n)+") ");
|
||||
return true;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Cantera {
|
||||
int _equilflag(const char* xy);
|
||||
namespace Cantera
|
||||
{
|
||||
int _equilflag(const char* xy);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT mix_new() {
|
||||
int DLL_EXPORT mix_new()
|
||||
{
|
||||
mix_t* m = new MultiPhase;
|
||||
return Cabinet<mix_t>::cabinet()->add(m);
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_del(int i) {
|
||||
int DLL_EXPORT mix_del(int i)
|
||||
{
|
||||
Cabinet<mix_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_copy(int i) {
|
||||
int DLL_EXPORT mix_copy(int i)
|
||||
{
|
||||
return Cabinet<mix_t>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_assign(int i, int j) {
|
||||
int DLL_EXPORT mix_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<mix_t>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_addPhase(int i, int j, double moles) {
|
||||
int DLL_EXPORT mix_addPhase(int i, int j, double moles)
|
||||
{
|
||||
_mix(i)->addPhase(_th(j), moles);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_init(int i) {
|
||||
int DLL_EXPORT mix_init(int i)
|
||||
{
|
||||
_mix(i)->init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT mix_nElements(int i) {
|
||||
size_t DLL_EXPORT mix_nElements(int i)
|
||||
{
|
||||
return _mix(i)->nElements();
|
||||
}
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT mix_elementIndex(int i, char* name) {
|
||||
size_t DLL_EXPORT mix_elementIndex(int i, char* name)
|
||||
{
|
||||
return _mix(i)->elementIndex(string(name));
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT mix_nSpecies(int i) {
|
||||
size_t DLL_EXPORT mix_nSpecies(int i)
|
||||
{
|
||||
return _mix(i)->nSpecies();
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT mix_speciesIndex(int i, int k, int p) {
|
||||
size_t DLL_EXPORT mix_speciesIndex(int i, int k, int p)
|
||||
{
|
||||
return _mix(i)->speciesIndex(k, p);
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_nAtoms(int i, int k, int m) {
|
||||
doublereal DLL_EXPORT mix_nAtoms(int i, int k, int m)
|
||||
{
|
||||
bool ok = (checkSpecies(i,k) && checkElement(i,m));
|
||||
if (ok)
|
||||
if (ok) {
|
||||
return _mix(i)->nAtoms(k,m);
|
||||
else
|
||||
} else {
|
||||
return DERR;
|
||||
}
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT mix_nPhases(int i) {
|
||||
size_t DLL_EXPORT mix_nPhases(int i)
|
||||
{
|
||||
return _mix(i)->nPhases();
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_phaseMoles(int i, int n) {
|
||||
if (!checkPhase(i, n)) return DERR;
|
||||
doublereal DLL_EXPORT mix_phaseMoles(int i, int n)
|
||||
{
|
||||
if (!checkPhase(i, n)) {
|
||||
return DERR;
|
||||
}
|
||||
return _mix(i)->phaseMoles(n);
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_setPhaseMoles(int i, int n, double v) {
|
||||
if (!checkPhase(i, n)) return ERR;
|
||||
if (v < 0.0) return -1;
|
||||
int DLL_EXPORT mix_setPhaseMoles(int i, int n, double v)
|
||||
{
|
||||
if (!checkPhase(i, n)) {
|
||||
return ERR;
|
||||
}
|
||||
if (v < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
_mix(i)->setPhaseMoles(n, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_setMoles(int i, size_t nlen, double* n) {
|
||||
int DLL_EXPORT mix_setMoles(int i, size_t nlen, double* n)
|
||||
{
|
||||
try {
|
||||
if (nlen < _mix(i)->nSpecies())
|
||||
if (nlen < _mix(i)->nSpecies()) {
|
||||
throw CanteraError("setMoles","array size too small.");
|
||||
}
|
||||
_mix(i)->setMoles(n);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT mix_setMolesByName(int i, char* n) {
|
||||
int DLL_EXPORT mix_setMolesByName(int i, char* n)
|
||||
{
|
||||
try {
|
||||
_mix(i)->setMolesByName(string(n));
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_setTemperature(int i, double t) {
|
||||
if (t < 0.0) return -1;
|
||||
int DLL_EXPORT mix_setTemperature(int i, double t)
|
||||
{
|
||||
if (t < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
_mix(i)->setTemperature(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_temperature(int i) {
|
||||
doublereal DLL_EXPORT mix_temperature(int i)
|
||||
{
|
||||
return _mix(i)->temperature();
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_minTemp(int i) {
|
||||
doublereal DLL_EXPORT mix_minTemp(int i)
|
||||
{
|
||||
return _mix(i)->minTemp();
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_maxTemp(int i) {
|
||||
doublereal DLL_EXPORT mix_maxTemp(int i)
|
||||
{
|
||||
return _mix(i)->maxTemp();
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_charge(int i) {
|
||||
doublereal DLL_EXPORT mix_charge(int i)
|
||||
{
|
||||
return _mix(i)->charge();
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_phaseCharge(int i, int p) {
|
||||
if (!checkPhase(i,p)) return DERR;
|
||||
doublereal DLL_EXPORT mix_phaseCharge(int i, int p)
|
||||
{
|
||||
if (!checkPhase(i,p)) {
|
||||
return DERR;
|
||||
}
|
||||
return _mix(i)->phaseCharge(p);
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_setPressure(int i, double p) {
|
||||
if (p < 0.0) return -1;
|
||||
int DLL_EXPORT mix_setPressure(int i, double p)
|
||||
{
|
||||
if (p < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
_mix(i)->setPressure(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_pressure(int i) {
|
||||
doublereal DLL_EXPORT mix_pressure(int i)
|
||||
{
|
||||
return _mix(i)->pressure();
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_speciesMoles(int i, int k) {
|
||||
if (!checkSpecies(i,k)) return DERR;
|
||||
doublereal DLL_EXPORT mix_speciesMoles(int i, int k)
|
||||
{
|
||||
if (!checkSpecies(i,k)) {
|
||||
return DERR;
|
||||
}
|
||||
return _mix(i)->speciesMoles(k);
|
||||
}
|
||||
|
||||
doublereal DLL_EXPORT mix_elementMoles(int i, int m) {
|
||||
if (!checkElement(i,m)) return DERR;
|
||||
doublereal DLL_EXPORT mix_elementMoles(int i, int m)
|
||||
{
|
||||
if (!checkElement(i,m)) {
|
||||
return DERR;
|
||||
}
|
||||
return _mix(i)->elementMoles(m);
|
||||
}
|
||||
|
||||
|
||||
doublereal DLL_EXPORT mix_equilibrate(int i, char* XY,
|
||||
doublereal rtol, int maxsteps,
|
||||
int maxiter, int loglevel) {
|
||||
try {
|
||||
return equilibrate(*_mix(i), XY,
|
||||
rtol, maxsteps, maxiter, loglevel);
|
||||
}
|
||||
catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doublereal DLL_EXPORT mix_vcs_equilibrate(int i, char* XY, int estimateEquil,
|
||||
int printLvl, int solver,
|
||||
doublereal rtol, int maxsteps,
|
||||
int maxiter, int loglevel) {
|
||||
try {
|
||||
#ifdef WITH_VCSNONIDEAL
|
||||
int retn = vcs_equilibrate(*_mix(i), XY, estimateEquil, printLvl, solver,
|
||||
rtol, maxsteps, maxiter, loglevel);
|
||||
#else
|
||||
int retn = -1;
|
||||
throw CanteraError("mix_vcs_equilibrate",
|
||||
"The VCS NonIdeal equilibrium solver isn't compiled in\n"
|
||||
" To use this feature add export WITH_VCS_NONIDEAL='y' to the preconfig file");
|
||||
#endif
|
||||
return (double) retn;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_getChemPotentials(int i, size_t lenmu, double* mu) {
|
||||
doublereal DLL_EXPORT mix_equilibrate(int i, char* XY,
|
||||
doublereal rtol, int maxsteps,
|
||||
int maxiter, int loglevel)
|
||||
{
|
||||
try {
|
||||
if (lenmu < _mix(i)->nSpecies())
|
||||
return equilibrate(*_mix(i), XY,
|
||||
rtol, maxsteps, maxiter, loglevel);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doublereal DLL_EXPORT mix_vcs_equilibrate(int i, char* XY, int estimateEquil,
|
||||
int printLvl, int solver,
|
||||
doublereal rtol, int maxsteps,
|
||||
int maxiter, int loglevel)
|
||||
{
|
||||
try {
|
||||
#ifdef WITH_VCSNONIDEAL
|
||||
int retn = vcs_equilibrate(*_mix(i), XY, estimateEquil, printLvl, solver,
|
||||
rtol, maxsteps, maxiter, loglevel);
|
||||
#else
|
||||
int retn = -1;
|
||||
throw CanteraError("mix_vcs_equilibrate",
|
||||
"The VCS NonIdeal equilibrium solver isn't compiled in\n"
|
||||
" To use this feature add export WITH_VCS_NONIDEAL='y' to the preconfig file");
|
||||
#endif
|
||||
return (double) retn;
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_getChemPotentials(int i, size_t lenmu, double* mu)
|
||||
{
|
||||
try {
|
||||
if (lenmu < _mix(i)->nSpecies()) {
|
||||
throw CanteraError("getChemPotentials","array too small");
|
||||
}
|
||||
_mix(i)->getChemPotentials(mu);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT mix_getValidChemPotentials(int i, double bad_mu,
|
||||
int standard, size_t lenmu, double* mu) {
|
||||
int DLL_EXPORT mix_getValidChemPotentials(int i, double bad_mu,
|
||||
int standard, size_t lenmu, double* mu)
|
||||
{
|
||||
bool st = (standard == 1);
|
||||
try {
|
||||
if (lenmu < _mix(i)->nSpecies())
|
||||
if (lenmu < _mix(i)->nSpecies()) {
|
||||
throw CanteraError("getChemPotentials","array too small");
|
||||
}
|
||||
_mix(i)->getValidChemPotentials(bad_mu, mu, st);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
double DLL_EXPORT mix_enthalpy(int i) {
|
||||
double DLL_EXPORT mix_enthalpy(int i)
|
||||
{
|
||||
return _mix(i)->enthalpy();
|
||||
}
|
||||
|
||||
double DLL_EXPORT mix_entropy(int i) {
|
||||
double DLL_EXPORT mix_entropy(int i)
|
||||
{
|
||||
return _mix(i)->entropy();
|
||||
}
|
||||
|
||||
|
||||
double DLL_EXPORT mix_gibbs(int i) {
|
||||
|
||||
double DLL_EXPORT mix_gibbs(int i)
|
||||
{
|
||||
return _mix(i)->gibbs();
|
||||
}
|
||||
|
||||
double DLL_EXPORT mix_cp(int i) {
|
||||
double DLL_EXPORT mix_cp(int i)
|
||||
{
|
||||
return _mix(i)->cp();
|
||||
}
|
||||
|
||||
double DLL_EXPORT mix_volume(int i) {
|
||||
double DLL_EXPORT mix_volume(int i)
|
||||
{
|
||||
return _mix(i)->volume();
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT mix_speciesPhaseIndex(int i, int k) {
|
||||
size_t DLL_EXPORT mix_speciesPhaseIndex(int i, int k)
|
||||
{
|
||||
return _mix(i)->speciesPhaseIndex(k);
|
||||
}
|
||||
|
||||
double DLL_EXPORT mix_moleFraction(int i, int k) {
|
||||
double DLL_EXPORT mix_moleFraction(int i, int k)
|
||||
{
|
||||
return _mix(i)->moleFraction(k);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,50 +8,50 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
EEXXTT int DLL_CPREFIX mix_new();
|
||||
EEXXTT int DLL_CPREFIX mix_del(int i);
|
||||
EEXXTT int DLL_CPREFIX mix_copy(int i);
|
||||
EEXXTT int DLL_CPREFIX mix_assign(int i, int j);
|
||||
EEXXTT int DLL_CPREFIX mix_addPhase(int i, int j, double moles);
|
||||
EEXXTT int DLL_CPREFIX mix_init(int i);
|
||||
EEXXTT size_t DLL_CPREFIX mix_nElements(int i);
|
||||
EEXXTT size_t DLL_CPREFIX mix_elementIndex(int i, char* name);
|
||||
EEXXTT size_t DLL_CPREFIX mix_speciesIndex(int i, int k, int p);
|
||||
EEXXTT size_t DLL_CPREFIX mix_nSpecies(int i);
|
||||
EEXXTT int DLL_CPREFIX mix_setTemperature(int i, double t);
|
||||
EEXXTT double DLL_CPREFIX mix_temperature(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_minTemp(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_maxTemp(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_charge(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_phaseCharge(int i, int p);
|
||||
EEXXTT int DLL_CPREFIX mix_setPressure(int i, double p);
|
||||
EEXXTT double DLL_CPREFIX mix_pressure(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_nAtoms(int i, int k, int m);
|
||||
EEXXTT size_t DLL_CPREFIX mix_nPhases(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_phaseMoles(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX mix_setPhaseMoles(int i, int n, double v);
|
||||
EEXXTT int DLL_CPREFIX mix_setMoles(int i, size_t nlen, double* n);
|
||||
EEXXTT int DLL_CPREFIX mix_setMolesByName(int i, char* n);
|
||||
EEXXTT double DLL_CPREFIX mix_speciesMoles(int i, int k);
|
||||
EEXXTT double DLL_CPREFIX mix_elementMoles(int i, int m);
|
||||
EEXXTT double DLL_CPREFIX mix_equilibrate(int i, char* XY,
|
||||
double err, int maxsteps, int maxiter, int loglevel);
|
||||
EEXXTT double DLL_EXPORT mix_vcs_equilibrate(int i, char* XY, int estimateEquil,
|
||||
int printLvl, int solver,
|
||||
double rtol, int maxsteps,
|
||||
int maxiter, int loglevel);
|
||||
EEXXTT int DLL_CPREFIX mix_getChemPotentials(int i, size_t lenmu, double* mu);
|
||||
EEXXTT int DLL_CPREFIX mix_getValidChemPotentials(int i, double bad_mu,
|
||||
int standard, size_t lenmu, double* mu);
|
||||
EEXXTT int DLL_CPREFIX mix_new();
|
||||
EEXXTT int DLL_CPREFIX mix_del(int i);
|
||||
EEXXTT int DLL_CPREFIX mix_copy(int i);
|
||||
EEXXTT int DLL_CPREFIX mix_assign(int i, int j);
|
||||
EEXXTT int DLL_CPREFIX mix_addPhase(int i, int j, double moles);
|
||||
EEXXTT int DLL_CPREFIX mix_init(int i);
|
||||
EEXXTT size_t DLL_CPREFIX mix_nElements(int i);
|
||||
EEXXTT size_t DLL_CPREFIX mix_elementIndex(int i, char* name);
|
||||
EEXXTT size_t DLL_CPREFIX mix_speciesIndex(int i, int k, int p);
|
||||
EEXXTT size_t DLL_CPREFIX mix_nSpecies(int i);
|
||||
EEXXTT int DLL_CPREFIX mix_setTemperature(int i, double t);
|
||||
EEXXTT double DLL_CPREFIX mix_temperature(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_minTemp(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_maxTemp(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_charge(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_phaseCharge(int i, int p);
|
||||
EEXXTT int DLL_CPREFIX mix_setPressure(int i, double p);
|
||||
EEXXTT double DLL_CPREFIX mix_pressure(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_nAtoms(int i, int k, int m);
|
||||
EEXXTT size_t DLL_CPREFIX mix_nPhases(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_phaseMoles(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX mix_setPhaseMoles(int i, int n, double v);
|
||||
EEXXTT int DLL_CPREFIX mix_setMoles(int i, size_t nlen, double* n);
|
||||
EEXXTT int DLL_CPREFIX mix_setMolesByName(int i, char* n);
|
||||
EEXXTT double DLL_CPREFIX mix_speciesMoles(int i, int k);
|
||||
EEXXTT double DLL_CPREFIX mix_elementMoles(int i, int m);
|
||||
EEXXTT double DLL_CPREFIX mix_equilibrate(int i, char* XY,
|
||||
double err, int maxsteps, int maxiter, int loglevel);
|
||||
EEXXTT double DLL_EXPORT mix_vcs_equilibrate(int i, char* XY, int estimateEquil,
|
||||
int printLvl, int solver,
|
||||
double rtol, int maxsteps,
|
||||
int maxiter, int loglevel);
|
||||
EEXXTT int DLL_CPREFIX mix_getChemPotentials(int i, size_t lenmu, double* mu);
|
||||
EEXXTT int DLL_CPREFIX mix_getValidChemPotentials(int i, double bad_mu,
|
||||
int standard, size_t lenmu, double* mu);
|
||||
|
||||
EEXXTT double DLL_CPREFIX mix_enthalpy(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_entropy(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_gibbs(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_cp(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_volume(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_enthalpy(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_entropy(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_gibbs(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_cp(int i);
|
||||
EEXXTT double DLL_CPREFIX mix_volume(int i);
|
||||
|
||||
EEXXTT size_t DLL_CPREFIX mix_speciesPhaseIndex(int i, int k);
|
||||
EEXXTT double DLL_CPREFIX mix_moleFraction(int i, int k);
|
||||
EEXXTT size_t DLL_CPREFIX mix_speciesPhaseIndex(int i, int k);
|
||||
EEXXTT double DLL_CPREFIX mix_moleFraction(int i, int k);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,306 +23,380 @@ template<> Cabinet<Sim1D>* Cabinet<Sim1D>::__storage = 0;
|
||||
template<> Cabinet<Domain1D>* Cabinet<Domain1D>::__storage = 0;
|
||||
|
||||
|
||||
inline Sim1D* _sim1D(int i) {
|
||||
inline Sim1D* _sim1D(int i)
|
||||
{
|
||||
return Cabinet<Sim1D>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline Domain1D* _domain(int i) {
|
||||
inline Domain1D* _domain(int i)
|
||||
{
|
||||
return Cabinet<Domain1D>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
static StFlow* _stflow(int i) {
|
||||
static StFlow* _stflow(int i)
|
||||
{
|
||||
Domain1D* d = _domain(i);
|
||||
if (d->domainType() == cFlowType) return (StFlow*)d;
|
||||
else {
|
||||
if (d->domainType() == cFlowType) {
|
||||
return (StFlow*)d;
|
||||
} else {
|
||||
throw CanteraError("_stflow","wrong domain type");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Bdry1D* _bdry(int i) {
|
||||
static Bdry1D* _bdry(int i)
|
||||
{
|
||||
Domain1D* d = _domain(i);
|
||||
if (! d->isConnector()) {
|
||||
throw CanteraError("_bdry","wrong domain type: " +int2str(d->domainType()));
|
||||
throw CanteraError("_bdry","wrong domain type: " +int2str(d->domainType()));
|
||||
}
|
||||
return (Bdry1D*)d;
|
||||
}
|
||||
|
||||
inline ThermoPhase* _phase(int n) {
|
||||
inline ThermoPhase* _phase(int n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline Kinetics* _kinetics(int n) {
|
||||
inline Kinetics* _kinetics(int n)
|
||||
{
|
||||
return Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
inline ThermoPhase* _thermo(int n) {
|
||||
inline ThermoPhase* _thermo(int n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline Transport* _transport(int n) {
|
||||
inline Transport* _transport(int n)
|
||||
{
|
||||
return Storage::__storage->__trtable[n];
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT domain_clear() {
|
||||
int DLL_EXPORT domain_clear()
|
||||
{
|
||||
try {
|
||||
Cabinet<Domain1D>::cabinet()->clear();
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT domain_del(int i) {
|
||||
int DLL_EXPORT domain_del(int i)
|
||||
{
|
||||
Cabinet<Domain1D>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT domain_type(int i) {
|
||||
int DLL_EXPORT domain_type(int i)
|
||||
{
|
||||
return _domain(i)->domainType();
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT domain_index(int i) {
|
||||
size_t DLL_EXPORT domain_index(int i)
|
||||
{
|
||||
return _domain(i)->domainIndex();
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT domain_nComponents(int i) {
|
||||
size_t DLL_EXPORT domain_nComponents(int i)
|
||||
{
|
||||
return _domain(i)->nComponents();
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT domain_nPoints(int i) {
|
||||
size_t DLL_EXPORT domain_nPoints(int i)
|
||||
{
|
||||
return _domain(i)->nPoints();
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT domain_componentName(int i, int n, int sz, char* buf) {
|
||||
int DLL_EXPORT domain_componentName(int i, int n, int sz, char* buf)
|
||||
{
|
||||
try {
|
||||
string nm = _domain(i)->componentName(n);
|
||||
int lout = min(sz, nm.size());
|
||||
copy(nm.c_str(), nm.c_str() + lout, buf);
|
||||
buf[lout] = '\0';
|
||||
return static_cast<int>(nm.size());
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT domain_componentIndex(int i, char* name) {
|
||||
size_t DLL_EXPORT domain_componentIndex(int i, char* name)
|
||||
{
|
||||
try {
|
||||
size_t n = _domain(i)->componentIndex(string(name));
|
||||
size_t n = _domain(i)->componentIndex(string(name));
|
||||
return n;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT domain_grid(int i, int n) {
|
||||
double DLL_EXPORT domain_grid(int i, int n)
|
||||
{
|
||||
try {
|
||||
return _domain(i)->grid(n);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT domain_setBounds(int i, int n, double lower, double upper) {
|
||||
int DLL_EXPORT domain_setBounds(int i, int n, double lower, double upper)
|
||||
{
|
||||
try {
|
||||
_domain(i)->setBounds(n, lower, upper);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT domain_upperBound(int i, int n) {
|
||||
double DLL_EXPORT domain_upperBound(int i, int n)
|
||||
{
|
||||
try {
|
||||
return _domain(i)->upperBound(n);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT domain_lowerBound(int i, int n) {
|
||||
double DLL_EXPORT domain_lowerBound(int i, int n)
|
||||
{
|
||||
try {
|
||||
return _domain(i)->lowerBound(n);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT domain_setTolerances(int i, int n, double rtol,
|
||||
double atol, int itime) {
|
||||
int DLL_EXPORT domain_setTolerances(int i, int n, double rtol,
|
||||
double atol, int itime)
|
||||
{
|
||||
try {
|
||||
_domain(i)->setTolerances(n, rtol, atol, itime);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT domain_rtol(int i, int n) {
|
||||
double DLL_EXPORT domain_rtol(int i, int n)
|
||||
{
|
||||
try {
|
||||
return _domain(i)->rtol(n);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT domain_atol(int i, int n) {
|
||||
double DLL_EXPORT domain_atol(int i, int n)
|
||||
{
|
||||
try {
|
||||
return _domain(i)->atol(n);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT domain_setupGrid(int i, size_t npts, double* grid) {
|
||||
int DLL_EXPORT domain_setupGrid(int i, size_t npts, double* grid)
|
||||
{
|
||||
try {
|
||||
_domain(i)->setupGrid(npts, grid);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT domain_setID(int i, char* id) {
|
||||
int DLL_EXPORT domain_setID(int i, char* id)
|
||||
{
|
||||
try {
|
||||
string s = string(id);
|
||||
_domain(i)->setID(s);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT domain_setDesc(int i, char* desc) {
|
||||
int DLL_EXPORT domain_setDesc(int i, char* desc)
|
||||
{
|
||||
try {
|
||||
string s = string(desc);
|
||||
_domain(i)->setDesc(s);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT inlet_new() {
|
||||
int DLL_EXPORT inlet_new()
|
||||
{
|
||||
try {
|
||||
Inlet1D* i = new Inlet1D();
|
||||
return Cabinet<Domain1D>::cabinet()->add(i);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_new() {
|
||||
int DLL_EXPORT surf_new()
|
||||
{
|
||||
try {
|
||||
Surf1D* i = new Surf1D();
|
||||
return Cabinet<Domain1D>::cabinet()->add(i);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactingsurf_new() {
|
||||
int DLL_EXPORT reactingsurf_new()
|
||||
{
|
||||
try {
|
||||
//writelog("in reactingsurf_new\n");
|
||||
//writelog("in reactingsurf_new\n");
|
||||
Domain1D* i = new ReactingSurf1D();
|
||||
return Cabinet<Domain1D>::cabinet()->add(i);
|
||||
} catch (CanteraError) {
|
||||
writelog("error");
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { writelog("error"); return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT symm_new() {
|
||||
int DLL_EXPORT symm_new()
|
||||
{
|
||||
try {
|
||||
Symm1D* i = new Symm1D();
|
||||
return Cabinet<Domain1D>::cabinet()->add(i);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT outlet_new() {
|
||||
int DLL_EXPORT outlet_new()
|
||||
{
|
||||
try {
|
||||
Outlet1D* i = new Outlet1D();
|
||||
return Cabinet<Domain1D>::cabinet()->add(i);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT outletres_new() {
|
||||
int DLL_EXPORT outletres_new()
|
||||
{
|
||||
try {
|
||||
OutletRes1D* i = new OutletRes1D();
|
||||
return Cabinet<Domain1D>::cabinet()->add(i);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT bdry_setMdot(int i, double mdot) {
|
||||
int DLL_EXPORT bdry_setMdot(int i, double mdot)
|
||||
{
|
||||
try {
|
||||
_bdry(i)->setMdot(mdot);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT bdry_setTemperature(int i, double t) {
|
||||
int DLL_EXPORT bdry_setTemperature(int i, double t)
|
||||
{
|
||||
try {
|
||||
_bdry(i)->setTemperature(t);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT bdry_setMoleFractions(int i, char* x) {
|
||||
int DLL_EXPORT bdry_setMoleFractions(int i, char* x)
|
||||
{
|
||||
try {
|
||||
_bdry(i)->setMoleFractions(string(x));
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT bdry_temperature(int i) {
|
||||
double DLL_EXPORT bdry_temperature(int i)
|
||||
{
|
||||
try {
|
||||
return _bdry(i)->temperature();
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT bdry_massFraction(int i, int k) {
|
||||
double DLL_EXPORT bdry_massFraction(int i, int k)
|
||||
{
|
||||
try {
|
||||
return _bdry(i)->massFraction(k);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT bdry_mdot(int i) {
|
||||
double DLL_EXPORT bdry_mdot(int i)
|
||||
{
|
||||
try {
|
||||
return _bdry(i)->mdot();
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactingsurf_setkineticsmgr(int i, int j) {
|
||||
int DLL_EXPORT reactingsurf_setkineticsmgr(int i, int j)
|
||||
{
|
||||
try {
|
||||
ReactingSurf1D* srf = (ReactingSurf1D*)_bdry(i);
|
||||
InterfaceKinetics* k = (InterfaceKinetics*)_kinetics(j);
|
||||
srf->setKineticsMgr(k);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactingsurf_enableCoverageEqs(int i, int onoff) {
|
||||
int DLL_EXPORT reactingsurf_enableCoverageEqs(int i, int onoff)
|
||||
{
|
||||
try {
|
||||
ReactingSurf1D* srf = (ReactingSurf1D*)_bdry(i);
|
||||
srf->enableCoverageEquations(onoff != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT inlet_setSpreadRate(int i, double v) {
|
||||
int DLL_EXPORT inlet_setSpreadRate(int i, double v)
|
||||
{
|
||||
try {
|
||||
Inlet1D* inlt = (Inlet1D*)_bdry(i);
|
||||
inlt->setSpreadRate(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------ stagnation flow domains --------------------
|
||||
|
||||
int DLL_EXPORT stflow_new(int iph, int ikin, int itr, int itype) {
|
||||
int DLL_EXPORT stflow_new(int iph, int ikin, int itr, int itype)
|
||||
{
|
||||
try {
|
||||
IdealGasPhase* ph = (IdealGasPhase*)_thermo(iph);
|
||||
if (itype == 1) {
|
||||
@@ -330,131 +404,156 @@ extern "C" {
|
||||
x->setKinetics(*_kinetics(ikin));
|
||||
x->setTransport(*_transport(itr));
|
||||
return Cabinet<Domain1D>::cabinet()->add(x);
|
||||
}
|
||||
else if (itype == 2) {
|
||||
} else if (itype == 2) {
|
||||
FreeFlame* x = new FreeFlame(ph, ph->nSpecies(), 2);
|
||||
x->setKinetics(*_kinetics(ikin));
|
||||
x->setTransport(*_transport(itr));
|
||||
return Cabinet<Domain1D>::cabinet()->add(x);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT stflow_setTransport(int i, int itr, int iSoret) {
|
||||
int DLL_EXPORT stflow_setTransport(int i, int itr, int iSoret)
|
||||
{
|
||||
bool withSoret = false;
|
||||
if (iSoret > 0) withSoret = true;
|
||||
if (iSoret > 0) {
|
||||
withSoret = true;
|
||||
}
|
||||
try {
|
||||
_stflow(i)->setTransport(*_transport(itr), withSoret);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT stflow_enableSoret(int i, int iSoret) {
|
||||
int DLL_EXPORT stflow_enableSoret(int i, int iSoret)
|
||||
{
|
||||
bool withSoret = false;
|
||||
if (iSoret > 0) withSoret = true;
|
||||
if (iSoret > 0) {
|
||||
withSoret = true;
|
||||
}
|
||||
try {
|
||||
_stflow(i)->enableSoret(withSoret);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT stflow_setPressure(int i, double p) {
|
||||
int DLL_EXPORT stflow_setPressure(int i, double p)
|
||||
{
|
||||
try {
|
||||
_stflow(i)->setPressure(p);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT stflow_setFixedTempProfile(int i, size_t n, double* pos,
|
||||
size_t m, double* temp) {
|
||||
size_t m, double* temp)
|
||||
{
|
||||
try {
|
||||
vector_fp vpos(n), vtemp(n);
|
||||
for (size_t j = 0; j < n; j++) {
|
||||
vpos[j] = pos[j];
|
||||
vpos[j] = pos[j];
|
||||
vtemp[j] = temp[j];
|
||||
}
|
||||
_stflow(i)->setFixedTempProfile(vpos, vtemp);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT stflow_solveSpeciesEqs(int i, int flag) {
|
||||
int DLL_EXPORT stflow_solveSpeciesEqs(int i, int flag)
|
||||
{
|
||||
try {
|
||||
if (flag > 0)
|
||||
if (flag > 0) {
|
||||
_stflow(i)->solveSpecies(-1);
|
||||
else
|
||||
} else {
|
||||
_stflow(i)->fixSpecies(-1);
|
||||
}
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT stflow_solveEnergyEqn(int i, int flag) {
|
||||
int DLL_EXPORT stflow_solveEnergyEqn(int i, int flag)
|
||||
{
|
||||
try {
|
||||
if (flag > 0)
|
||||
if (flag > 0) {
|
||||
_stflow(i)->solveEnergyEqn(-1);
|
||||
else
|
||||
} else {
|
||||
_stflow(i)->fixTemperature(-1);
|
||||
}
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
//------------------- Sim1D --------------------------------------
|
||||
|
||||
int DLL_EXPORT sim1D_new(size_t nd, int* domains) {
|
||||
int DLL_EXPORT sim1D_new(size_t nd, int* domains)
|
||||
{
|
||||
vector<Domain1D*> d;
|
||||
try {
|
||||
// cout << "nd = " << nd << endl;
|
||||
// cout << "nd = " << nd << endl;
|
||||
for (size_t n = 0; n < nd; n++) {
|
||||
//writelog("n = "+int2str(n)+"\n");
|
||||
//writelog("dom = "+int2str(domains[n])+"\n");
|
||||
//writelog("n = "+int2str(n)+"\n");
|
||||
//writelog("dom = "+int2str(domains[n])+"\n");
|
||||
d.push_back(_domain(domains[n]));
|
||||
}
|
||||
//writelog("in sim1D_new, calling new Sim1D\n");
|
||||
Sim1D* s = new Sim1D(d);
|
||||
//writelog("in sim1D_new, ret Sim1D\n");
|
||||
return Cabinet<Sim1D>::cabinet()->add(s);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_clear() {
|
||||
int DLL_EXPORT sim1D_clear()
|
||||
{
|
||||
try {
|
||||
Cabinet<Sim1D>::cabinet()->clear();
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_del(int i) {
|
||||
int DLL_EXPORT sim1D_del(int i)
|
||||
{
|
||||
Cabinet<Sim1D>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setValue(int i, int dom, int comp,
|
||||
int localPoint, double value) {
|
||||
int DLL_EXPORT sim1D_setValue(int i, int dom, int comp,
|
||||
int localPoint, double value)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setValue(dom, comp, localPoint, value);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setProfile(int i, int dom, int comp,
|
||||
size_t np, double* pos, size_t nv, double* v) {
|
||||
int DLL_EXPORT sim1D_setProfile(int i, int dom, int comp,
|
||||
size_t np, double* pos, size_t nv, double* v)
|
||||
{
|
||||
try {
|
||||
vector_fp vv, pv;
|
||||
for (size_t n = 0; n < np; n++) {
|
||||
@@ -463,23 +562,27 @@ extern "C" {
|
||||
}
|
||||
_sim1D(i)->setProfile(dom, comp, pv, vv);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setFlatProfile(int i, int dom, int comp, double v) {
|
||||
int DLL_EXPORT sim1D_setFlatProfile(int i, int dom, int comp, double v)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setFlatProfile(dom, comp, v);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_showSolution(int i, char* fname) {
|
||||
int DLL_EXPORT sim1D_showSolution(int i, char* fname)
|
||||
{
|
||||
string fn = string(fname);
|
||||
if (fn == "-")
|
||||
if (fn == "-") {
|
||||
_sim1D(i)->showSolution();
|
||||
else {
|
||||
} else {
|
||||
ofstream fout(fname);
|
||||
_sim1D(i)->showSolution(fout);
|
||||
fout.close();
|
||||
@@ -487,163 +590,202 @@ extern "C" {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps) {
|
||||
int DLL_EXPORT sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setTimeStep(stepsize, ns, nsteps);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_getInitialSoln(int i) {
|
||||
int DLL_EXPORT sim1D_getInitialSoln(int i)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->getInitialSoln();
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_solve(int i, int loglevel, int refine_grid) {
|
||||
int DLL_EXPORT sim1D_solve(int i, int loglevel, int refine_grid)
|
||||
{
|
||||
try {
|
||||
bool r = (refine_grid == 0 ? false : true);
|
||||
_sim1D(i)->solve(loglevel, r);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_refine(int i, int loglevel) {
|
||||
int DLL_EXPORT sim1D_refine(int i, int loglevel)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->refine(loglevel);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setRefineCriteria(int i, int dom, double ratio,
|
||||
double slope, double curve, double prune) {
|
||||
double slope, double curve, double prune)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setRefineCriteria(dom, ratio, slope, curve, prune);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_save(int i, char* fname, char* id,
|
||||
char* desc) {
|
||||
int DLL_EXPORT sim1D_save(int i, char* fname, char* id,
|
||||
char* desc)
|
||||
{
|
||||
try {
|
||||
string sname = string(fname);
|
||||
string sid = string(id);
|
||||
string sdesc = string(desc);
|
||||
_sim1D(i)->save(sname, sid, sdesc);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_restore(int i, char* fname, char* id) {
|
||||
int DLL_EXPORT sim1D_restore(int i, char* fname, char* id)
|
||||
{
|
||||
try {
|
||||
string sname = string(fname);
|
||||
string sid = string(id);
|
||||
_sim1D(i)->restore(sname, sid);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_writeStats(int i, int printTime) {
|
||||
int DLL_EXPORT sim1D_writeStats(int i, int printTime)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->writeStats(printTime);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_domainIndex(int i, char* name) {
|
||||
int DLL_EXPORT sim1D_domainIndex(int i, char* name)
|
||||
{
|
||||
try {
|
||||
return (int) _sim1D(i)->domainIndex(string(name));
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT sim1D_value(int i, int idom, int icomp, int localPoint) {
|
||||
double DLL_EXPORT sim1D_value(int i, int idom, int icomp, int localPoint)
|
||||
{
|
||||
try {
|
||||
return _sim1D(i)->value(idom, icomp, localPoint);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT sim1D_workValue(int i, int idom, int icomp, int localPoint) {
|
||||
double DLL_EXPORT sim1D_workValue(int i, int idom, int icomp, int localPoint)
|
||||
{
|
||||
try {
|
||||
return _sim1D(i)->workValue(idom, icomp, localPoint);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_eval(int i, double rdt, int count) {
|
||||
int DLL_EXPORT sim1D_eval(int i, double rdt, int count)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->eval(rdt, count);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setMaxJacAge(int i, int ss_age, int ts_age) {
|
||||
int DLL_EXPORT sim1D_setMaxJacAge(int i, int ss_age, int ts_age)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setJacAge(ss_age, ts_age);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_timeStepFactor(int i, double tfactor) {
|
||||
int DLL_EXPORT sim1D_timeStepFactor(int i, double tfactor)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setTimeStepFactor(tfactor);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setTimeStepLimits(int i, double tsmin, double tsmax) {
|
||||
int DLL_EXPORT sim1D_setTimeStepLimits(int i, double tsmin, double tsmax)
|
||||
{
|
||||
try {
|
||||
if (tsmin > 0.0)
|
||||
if (tsmin > 0.0) {
|
||||
_sim1D(i)->setMinTimeStep(tsmin);
|
||||
if (tsmax > 0.0)
|
||||
}
|
||||
if (tsmax > 0.0) {
|
||||
_sim1D(i)->setMaxTimeStep(tsmax);
|
||||
}
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_setFixedTemperature(int i, double temp) {
|
||||
int DLL_EXPORT sim1D_setFixedTemperature(int i, double temp)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->setFixedTemperature(temp);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT sim1D_evalSSJacobian(int i) {
|
||||
int DLL_EXPORT sim1D_evalSSJacobian(int i)
|
||||
{
|
||||
try {
|
||||
_sim1D(i)->evalSSJacobian();
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT sim1D_jacobian(int i, int m, int n) {
|
||||
double DLL_EXPORT sim1D_jacobian(int i, int m, int n)
|
||||
{
|
||||
try {
|
||||
return _sim1D(i)->jacobian(m,n);
|
||||
} catch (CanteraError) {
|
||||
return DERR;
|
||||
}
|
||||
catch (CanteraError) { return DERR; }
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT sim1D_size(int i) {
|
||||
size_t DLL_EXPORT sim1D_size(int i)
|
||||
{
|
||||
try {
|
||||
return _sim1D(i)->size();
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ extern "C" {
|
||||
EEXXTT size_t DLL_CPREFIX domain_nPoints(int i);
|
||||
EEXXTT int DLL_CPREFIX domain_componentName(int i, int n, int sz, char* nameout);
|
||||
EEXXTT size_t DLL_CPREFIX domain_componentIndex(int i, char* name);
|
||||
EEXXTT int DLL_CPREFIX domain_setBounds(int i, int n, double lower,
|
||||
double upper);
|
||||
EEXXTT int DLL_CPREFIX domain_setBounds(int i, int n, double lower,
|
||||
double upper);
|
||||
EEXXTT double DLL_EXPORT domain_lowerBound(int i, int n);
|
||||
EEXXTT double DLL_EXPORT domain_upperBound(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX domain_setTolerances(int i, int n, double rtol,
|
||||
double atol, int itime);
|
||||
EEXXTT int DLL_CPREFIX domain_setTolerances(int i, int n, double rtol,
|
||||
double atol, int itime);
|
||||
EEXXTT double DLL_CPREFIX domain_rtol(int i, int n);
|
||||
EEXXTT double DLL_CPREFIX domain_atol(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX domain_setupGrid(int i, size_t npts, double* grid);
|
||||
@@ -59,7 +59,7 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX stflow_enableSoret(int i, int iSoret);
|
||||
EEXXTT int DLL_CPREFIX stflow_setPressure(int i, double p);
|
||||
EEXXTT int DLL_CPREFIX stflow_setFixedTempProfile(int i, size_t n, double* pos,
|
||||
size_t m, double* temp);
|
||||
size_t m, double* temp);
|
||||
EEXXTT int DLL_CPREFIX stflow_solveSpeciesEqs(int i, int flag);
|
||||
EEXXTT int DLL_CPREFIX stflow_solveEnergyEqn(int i, int flag);
|
||||
|
||||
@@ -67,7 +67,7 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX sim1D_new(size_t nd, int* domains);
|
||||
EEXXTT int DLL_CPREFIX sim1D_del(int i);
|
||||
EEXXTT int DLL_CPREFIX sim1D_setValue(int i, int dom, int comp, int localPoint, double value);
|
||||
EEXXTT int DLL_CPREFIX sim1D_setProfile(int i, int dom, int comp,
|
||||
EEXXTT int DLL_CPREFIX sim1D_setProfile(int i, int dom, int comp,
|
||||
size_t np, double* pos, size_t nv, double* v);
|
||||
EEXXTT int DLL_CPREFIX sim1D_setFlatProfile(int i, int dom, int comp, double v);
|
||||
EEXXTT int DLL_CPREFIX sim1D_showSolution(int i, char* fname);
|
||||
@@ -76,15 +76,15 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX sim1D_solve(int i, int loglevel, int refine_grid);
|
||||
EEXXTT int DLL_CPREFIX sim1D_refine(int i, int loglevel);
|
||||
EEXXTT int DLL_CPREFIX sim1D_setRefineCriteria(int i, int dom, double ratio,
|
||||
double slope, double curve, double prune);
|
||||
EEXXTT int DLL_CPREFIX sim1D_save(int i, char* fname, char* id,
|
||||
char* desc);
|
||||
double slope, double curve, double prune);
|
||||
EEXXTT int DLL_CPREFIX sim1D_save(int i, char* fname, char* id,
|
||||
char* desc);
|
||||
EEXXTT int DLL_CPREFIX sim1D_restore(int i, char* fname, char* id);
|
||||
EEXXTT int DLL_CPREFIX sim1D_writeStats(int i, int printTime = 1);
|
||||
EEXXTT int DLL_CPREFIX sim1D_domainIndex(int i, char* name);
|
||||
EEXXTT double DLL_CPREFIX sim1D_value(int i, int idom, int icomp, int localPoint);
|
||||
EEXXTT double DLL_CPREFIX sim1D_workValue(int i, int idom,
|
||||
int icomp, int localPoint);
|
||||
EEXXTT double DLL_CPREFIX sim1D_workValue(int i, int idom,
|
||||
int icomp, int localPoint);
|
||||
EEXXTT int DLL_CPREFIX sim1D_eval(int i, double rdt, int count);
|
||||
EEXXTT int DLL_CPREFIX sim1D_setMaxJacAge(int i, int ss_age, int ts_age);
|
||||
EEXXTT int DLL_CPREFIX sim1D_timeStepFactor(int i, double tfactor);
|
||||
|
||||
320
Cantera/clib/src/ctreactor.cpp
Executable file → Normal file
320
Cantera/clib/src/ctreactor.cpp
Executable file → Normal file
@@ -29,161 +29,198 @@ template<> Cabinet<reactornet_t>* Cabinet<reactornet_t>::__storage = 0;
|
||||
template<> Cabinet<flowdev_t>* Cabinet<flowdev_t>::__storage = 0;
|
||||
template<> Cabinet<wall_t>* Cabinet<wall_t>::__storage = 0;
|
||||
|
||||
inline reactor_t* _reactor(int i) {
|
||||
inline reactor_t* _reactor(int i)
|
||||
{
|
||||
return Cabinet<reactor_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline reactornet_t* _reactornet(int i) {
|
||||
inline reactornet_t* _reactornet(int i)
|
||||
{
|
||||
return Cabinet<reactornet_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline flowdev_t* _flowdev(int i) {
|
||||
inline flowdev_t* _flowdev(int i)
|
||||
{
|
||||
return Cabinet<flowdev_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline wall_t* _wall(int i) {
|
||||
inline wall_t* _wall(int i)
|
||||
{
|
||||
return Cabinet<wall_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline Kinetics* _kin(int n) {
|
||||
inline Kinetics* _kin(int n)
|
||||
{
|
||||
return Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
inline ThermoPhase* _th(int n) {
|
||||
inline ThermoPhase* _th(int n)
|
||||
{
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
|
||||
inline Func1* _func(int i) {
|
||||
inline Func1* _func(int i)
|
||||
{
|
||||
return Cabinet<Func1>::cabinet()->item(i);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
|
||||
// reactor
|
||||
|
||||
int DLL_EXPORT reactor_new(int type) {
|
||||
int DLL_EXPORT reactor_new(int type)
|
||||
{
|
||||
reactor_t* r=0;
|
||||
if (type == ReactorType)
|
||||
if (type == ReactorType) {
|
||||
r = new Reactor();
|
||||
else if (type == FlowReactorType)
|
||||
} else if (type == FlowReactorType) {
|
||||
r = new FlowReactor();
|
||||
else if (type == ConstPressureReactorType)
|
||||
} else if (type == ConstPressureReactorType) {
|
||||
r = new ConstPressureReactor();
|
||||
else if (type == ReservoirType)
|
||||
} else if (type == ReservoirType) {
|
||||
r = new Reservoir();
|
||||
else
|
||||
} else {
|
||||
r = new ReactorBase();
|
||||
}
|
||||
return Cabinet<reactor_t>::cabinet()->add(r);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_del(int i) {
|
||||
int DLL_EXPORT reactor_del(int i)
|
||||
{
|
||||
Cabinet<reactor_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_copy(int i) {
|
||||
int DLL_EXPORT reactor_copy(int i)
|
||||
{
|
||||
return Cabinet<reactor_t>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_assign(int i, int j) {
|
||||
int DLL_EXPORT reactor_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<reactor_t>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_setInitialVolume(int i, double v) {
|
||||
int DLL_EXPORT reactor_setInitialVolume(int i, double v)
|
||||
{
|
||||
_reactor(i)->setInitialVolume(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_setInitialTime(int i, double t) {
|
||||
_reactor(i)->setInitialTime(t);
|
||||
return 0;
|
||||
int DLL_EXPORT reactor_setInitialTime(int i, double t)
|
||||
{
|
||||
_reactor(i)->setInitialTime(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_setThermoMgr(int i, int n) {
|
||||
int DLL_EXPORT reactor_setThermoMgr(int i, int n)
|
||||
{
|
||||
_reactor(i)->setThermoMgr(*_th(n));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_setKineticsMgr(int i, int n) {
|
||||
int DLL_EXPORT reactor_setKineticsMgr(int i, int n)
|
||||
{
|
||||
reactor_t* r = _reactor(i);
|
||||
if (r->type() >= ReactorType)
|
||||
if (r->type() >= ReactorType) {
|
||||
((Reactor*)r)->setKineticsMgr(*_kin(n));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_advance(int i, double t) {
|
||||
try {
|
||||
_reactor(i)->advance(t);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {return -1;}
|
||||
int DLL_EXPORT reactor_advance(int i, double t)
|
||||
{
|
||||
try {
|
||||
_reactor(i)->advance(t);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_step(int i, double t) {
|
||||
return _reactor(i)->step(t);
|
||||
double DLL_EXPORT reactor_step(int i, double t)
|
||||
{
|
||||
return _reactor(i)->step(t);
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_time(int i) {
|
||||
double DLL_EXPORT reactor_time(int i)
|
||||
{
|
||||
return _reactor(i)->time();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_mass(int i) {
|
||||
double DLL_EXPORT reactor_mass(int i)
|
||||
{
|
||||
return _reactor(i)->mass();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_volume(int i) {
|
||||
double DLL_EXPORT reactor_volume(int i)
|
||||
{
|
||||
return _reactor(i)->volume();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_density(int i) {
|
||||
double DLL_EXPORT reactor_density(int i)
|
||||
{
|
||||
return _reactor(i)->density();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_temperature(int i) {
|
||||
double DLL_EXPORT reactor_temperature(int i)
|
||||
{
|
||||
return _reactor(i)->temperature();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_enthalpy_mass(int i) {
|
||||
double DLL_EXPORT reactor_enthalpy_mass(int i)
|
||||
{
|
||||
return _reactor(i)->enthalpy_mass();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_intEnergy_mass(int i) {
|
||||
double DLL_EXPORT reactor_intEnergy_mass(int i)
|
||||
{
|
||||
return _reactor(i)->intEnergy_mass();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_pressure(int i) {
|
||||
double DLL_EXPORT reactor_pressure(int i)
|
||||
{
|
||||
return _reactor(i)->pressure();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactor_massFraction(int i, int k) {
|
||||
double DLL_EXPORT reactor_massFraction(int i, int k)
|
||||
{
|
||||
return _reactor(i)->massFraction(k);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_setEnergy(int i, int eflag) {
|
||||
int DLL_EXPORT reactor_setEnergy(int i, int eflag)
|
||||
{
|
||||
reactor_t* r = _reactor(i);
|
||||
if (r->type() >= ReactorType) ((Reactor*)r)->setEnergy(eflag);
|
||||
if (r->type() >= ReactorType) {
|
||||
((Reactor*)r)->setEnergy(eflag);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowReactor_setMassFlowRate(int i, double mdot) {
|
||||
int DLL_EXPORT flowReactor_setMassFlowRate(int i, double mdot)
|
||||
{
|
||||
reactor_t* r = _reactor(i);
|
||||
if (r->type() >= ReactorType) ((FlowReactor*)r)->setMassFlowRate(mdot);
|
||||
if (r->type() >= ReactorType) {
|
||||
((FlowReactor*)r)->setMassFlowRate(mdot);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t DLL_EXPORT reactor_nSensParams(int i) {
|
||||
size_t DLL_EXPORT reactor_nSensParams(int i)
|
||||
{
|
||||
reactor_t* r = _reactor(i);
|
||||
if (r->type() >= ReactorType)
|
||||
if (r->type() >= ReactorType) {
|
||||
return ((Reactor*)r)->nSensParams();
|
||||
else {
|
||||
} else {
|
||||
std::cout << "type problem..." << r->type() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactor_addSensitivityReaction(int i, int rxn) {
|
||||
|
||||
int DLL_EXPORT reactor_addSensitivityReaction(int i, int rxn)
|
||||
{
|
||||
reactor_t* r = _reactor(i);
|
||||
((Reactor*)r)->addSensitivityReaction(rxn);
|
||||
return 0;
|
||||
@@ -192,155 +229,183 @@ extern "C" {
|
||||
|
||||
// reactor networks
|
||||
|
||||
int DLL_EXPORT reactornet_new() {
|
||||
int DLL_EXPORT reactornet_new()
|
||||
{
|
||||
ReactorNet* r = new ReactorNet();
|
||||
return Cabinet<reactornet_t>::cabinet()->add(r);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_del(int i) {
|
||||
int DLL_EXPORT reactornet_del(int i)
|
||||
{
|
||||
try {
|
||||
Cabinet<reactornet_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_copy(int i) {
|
||||
int DLL_EXPORT reactornet_copy(int i)
|
||||
{
|
||||
return Cabinet<reactornet_t>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_assign(int i, int j) {
|
||||
int DLL_EXPORT reactornet_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<reactornet_t>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_setInitialTime(int i, double t) {
|
||||
int DLL_EXPORT reactornet_setInitialTime(int i, double t)
|
||||
{
|
||||
_reactornet(i)->setInitialTime(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_setMaxTimeStep(int i, double maxstep) {
|
||||
int DLL_EXPORT reactornet_setMaxTimeStep(int i, double maxstep)
|
||||
{
|
||||
_reactornet(i)->setMaxTimeStep(maxstep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_setTolerances(int i, double rtol, double atol) {
|
||||
int DLL_EXPORT reactornet_setTolerances(int i, double rtol, double atol)
|
||||
{
|
||||
_reactornet(i)->setTolerances(rtol, atol);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_setSensitivityTolerances(int i, double rtol, double atol) {
|
||||
int DLL_EXPORT reactornet_setSensitivityTolerances(int i, double rtol, double atol)
|
||||
{
|
||||
_reactornet(i)->setSensitivityTolerances(rtol, atol);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_addreactor(int i, int n) {
|
||||
int DLL_EXPORT reactornet_addreactor(int i, int n)
|
||||
{
|
||||
try {
|
||||
_reactornet(i)->addReactor(_reactor(n));
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT reactornet_advance(int i, double t) {
|
||||
int DLL_EXPORT reactornet_advance(int i, double t)
|
||||
{
|
||||
try {
|
||||
_reactornet(i)->advance(t);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return -1;
|
||||
}
|
||||
catch (...) {return -1;}
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactornet_step(int i, double t) {
|
||||
double DLL_EXPORT reactornet_step(int i, double t)
|
||||
{
|
||||
try {
|
||||
return _reactornet(i)->step(t);
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
return DERR;
|
||||
}
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactornet_time(int i) {
|
||||
double DLL_EXPORT reactornet_time(int i)
|
||||
{
|
||||
return _reactornet(i)->time();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactornet_rtol(int i) {
|
||||
double DLL_EXPORT reactornet_rtol(int i)
|
||||
{
|
||||
return _reactornet(i)->rtol();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactornet_atol(int i) {
|
||||
double DLL_EXPORT reactornet_atol(int i)
|
||||
{
|
||||
return _reactornet(i)->atol();
|
||||
}
|
||||
|
||||
double DLL_EXPORT reactornet_sensitivity(int i, char* v, int p, int r) {
|
||||
double DLL_EXPORT reactornet_sensitivity(int i, char* v, int p, int r)
|
||||
{
|
||||
return _reactornet(i)->sensitivity(v, p, r);
|
||||
}
|
||||
|
||||
|
||||
// flow devices
|
||||
|
||||
int DLL_EXPORT flowdev_new(int type) {
|
||||
int DLL_EXPORT flowdev_new(int type)
|
||||
{
|
||||
flowdev_t* r;
|
||||
switch (type) {
|
||||
case MFC_Type:
|
||||
r = new MassFlowController(); break;
|
||||
r = new MassFlowController();
|
||||
break;
|
||||
case PressureController_Type:
|
||||
r = new PressureController(); break;
|
||||
r = new PressureController();
|
||||
break;
|
||||
case Valve_Type:
|
||||
r = new Valve(); break;
|
||||
r = new Valve();
|
||||
break;
|
||||
default:
|
||||
r = new FlowDevice();
|
||||
}
|
||||
return Cabinet<flowdev_t>::cabinet()->add(r);
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_del(int i) {
|
||||
int DLL_EXPORT flowdev_del(int i)
|
||||
{
|
||||
Cabinet<flowdev_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_install(int i, int n, int m) {
|
||||
int DLL_EXPORT flowdev_install(int i, int n, int m)
|
||||
{
|
||||
try {
|
||||
bool ok = _flowdev(i)->install(*_reactor(n), *_reactor(m) );
|
||||
if (!ok) throw CanteraError("install","Could not install flow device.");
|
||||
bool ok = _flowdev(i)->install(*_reactor(n), *_reactor(m));
|
||||
if (!ok) {
|
||||
throw CanteraError("install","Could not install flow device.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_setMaster(int i, int n) {
|
||||
int DLL_EXPORT flowdev_setMaster(int i, int n)
|
||||
{
|
||||
if (_flowdev(i)->type() == PressureController_Type) {
|
||||
((PressureController*)_flowdev(i))->setMaster(_flowdev(n));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT flowdev_massFlowRate(int i, double time) {
|
||||
double DLL_EXPORT flowdev_massFlowRate(int i, double time)
|
||||
{
|
||||
return _flowdev(i)->massFlowRate(time);
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_setMassFlowRate(int i, double mdot) {
|
||||
int DLL_EXPORT flowdev_setMassFlowRate(int i, double mdot)
|
||||
{
|
||||
_flowdev(i)->setMassFlowRate(mdot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_setParameters(int i, int n, double* v) {
|
||||
int DLL_EXPORT flowdev_setParameters(int i, int n, double* v)
|
||||
{
|
||||
_flowdev(i)->setParameters(n, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_setFunction(int i, int n) {
|
||||
int DLL_EXPORT flowdev_setFunction(int i, int n)
|
||||
{
|
||||
_flowdev(i)->setFunction(_func(n));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flowdev_ready(int i) {
|
||||
int DLL_EXPORT flowdev_ready(int i)
|
||||
{
|
||||
bool ok = _flowdev(i)->ready();
|
||||
if (ok) return 1;
|
||||
if (ok) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -348,95 +413,118 @@ extern "C" {
|
||||
///////////// Walls ///////////////////////
|
||||
|
||||
|
||||
int DLL_EXPORT wall_new(int type) {
|
||||
int DLL_EXPORT wall_new(int type)
|
||||
{
|
||||
wall_t* r;
|
||||
r = new Wall();
|
||||
return Cabinet<wall_t>::cabinet()->add(r);
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_del(int i) {
|
||||
int DLL_EXPORT wall_del(int i)
|
||||
{
|
||||
Cabinet<wall_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_copy(int i) {
|
||||
int DLL_EXPORT wall_copy(int i)
|
||||
{
|
||||
return Cabinet<wall_t>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_assign(int i, int j) {
|
||||
int DLL_EXPORT wall_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<wall_t>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_install(int i, int n, int m) {
|
||||
_wall(i)->install(*_reactor(n), *_reactor(m) );
|
||||
int DLL_EXPORT wall_install(int i, int n, int m)
|
||||
{
|
||||
_wall(i)->install(*_reactor(n), *_reactor(m));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setkinetics(int i, int n, int m) {
|
||||
Kinetics *left=0, *right=0;
|
||||
if (n > 0)
|
||||
if (_kin(n)->type() == cInterfaceKinetics)
|
||||
int DLL_EXPORT wall_setkinetics(int i, int n, int m)
|
||||
{
|
||||
Kinetics* left=0, *right=0;
|
||||
if (n > 0)
|
||||
if (_kin(n)->type() == cInterfaceKinetics) {
|
||||
left = _kin(n);
|
||||
if (m > 0)
|
||||
if (_kin(m)->type() == cInterfaceKinetics)
|
||||
}
|
||||
if (m > 0)
|
||||
if (_kin(m)->type() == cInterfaceKinetics) {
|
||||
right = _kin(m);
|
||||
}
|
||||
_wall(i)->setKinetics(left, right);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT wall_vdot(int i, double t) {
|
||||
double DLL_EXPORT wall_vdot(int i, double t)
|
||||
{
|
||||
return _wall(i)->vdot(t);
|
||||
}
|
||||
|
||||
double DLL_EXPORT wall_Q(int i, double t) {
|
||||
double DLL_EXPORT wall_Q(int i, double t)
|
||||
{
|
||||
return _wall(i)->Q(t);
|
||||
}
|
||||
|
||||
double DLL_EXPORT wall_area(int i) {
|
||||
double DLL_EXPORT wall_area(int i)
|
||||
{
|
||||
return _wall(i)->area();
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setArea(int i, double v) {
|
||||
int DLL_EXPORT wall_setArea(int i, double v)
|
||||
{
|
||||
_wall(i)->setArea(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setThermalResistance(int i, double rth) {
|
||||
int DLL_EXPORT wall_setThermalResistance(int i, double rth)
|
||||
{
|
||||
_wall(i)->setThermalResistance(rth);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setHeatTransferCoeff(int i, double u) {
|
||||
int DLL_EXPORT wall_setHeatTransferCoeff(int i, double u)
|
||||
{
|
||||
_wall(i)->setHeatTransferCoeff(u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setHeatFlux(int i, int n) {
|
||||
int DLL_EXPORT wall_setHeatFlux(int i, int n)
|
||||
{
|
||||
_wall(i)->setHeatFlux(_func(n));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setExpansionRateCoeff(int i, double k) {
|
||||
int DLL_EXPORT wall_setExpansionRateCoeff(int i, double k)
|
||||
{
|
||||
_wall(i)->setExpansionRateCoeff(k);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setVelocity(int i, int n) {
|
||||
int DLL_EXPORT wall_setVelocity(int i, int n)
|
||||
{
|
||||
_wall(i)->setVelocity(_func(n));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_setEmissivity(int i, double epsilon) {
|
||||
int DLL_EXPORT wall_setEmissivity(int i, double epsilon)
|
||||
{
|
||||
_wall(i)->setEmissivity(epsilon);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_ready(int i) {
|
||||
if (_wall(i)->ready()) return 1;
|
||||
else return 0;
|
||||
int DLL_EXPORT wall_ready(int i)
|
||||
{
|
||||
if (_wall(i)->ready()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int DLL_EXPORT wall_addSensitivityReaction(int i, int lr, int rxn) {
|
||||
int DLL_EXPORT wall_addSensitivityReaction(int i, int lr, int rxn)
|
||||
{
|
||||
_wall(i)->addSensitivityReaction(lr, rxn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
38
Cantera/clib/src/ctreactor.h
Executable file → Normal file
38
Cantera/clib/src/ctreactor.h
Executable file → Normal file
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "clib_defs.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
EEXXTT int DLL_CPREFIX reactor_new(int type);
|
||||
EEXXTT int DLL_CPREFIX reactor_del(int i);
|
||||
@@ -58,24 +58,24 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX flowdev_setFunction(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX flowdev_ready(int i);
|
||||
|
||||
EEXXTT int DLL_CPREFIX wall_new(int type);
|
||||
EEXXTT int DLL_CPREFIX wall_del(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_copy(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_assign(int i, int j);
|
||||
EEXXTT int DLL_CPREFIX wall_install(int i, int n, int m);
|
||||
EEXXTT int DLL_CPREFIX wall_setkinetics(int i, int n, int m);
|
||||
EEXXTT double DLL_CPREFIX wall_vdot(int i, double t);
|
||||
EEXXTT double DLL_CPREFIX wall_Q(int i, double t);
|
||||
EEXXTT double DLL_CPREFIX wall_area(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_setArea(int i, double v);
|
||||
EEXXTT int DLL_CPREFIX wall_setThermalResistance(int i, double rth);
|
||||
EEXXTT int DLL_CPREFIX wall_setHeatTransferCoeff(int i, double u);
|
||||
EEXXTT int DLL_CPREFIX wall_setHeatFlux(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX wall_setExpansionRateCoeff(int i, double k);
|
||||
EEXXTT int DLL_CPREFIX wall_setVelocity(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX wall_setEmissivity(int i, double epsilon);
|
||||
EEXXTT int DLL_CPREFIX wall_ready(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_addSensitivityReaction(int i, int lr, int rxn);
|
||||
EEXXTT int DLL_CPREFIX wall_new(int type);
|
||||
EEXXTT int DLL_CPREFIX wall_del(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_copy(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_assign(int i, int j);
|
||||
EEXXTT int DLL_CPREFIX wall_install(int i, int n, int m);
|
||||
EEXXTT int DLL_CPREFIX wall_setkinetics(int i, int n, int m);
|
||||
EEXXTT double DLL_CPREFIX wall_vdot(int i, double t);
|
||||
EEXXTT double DLL_CPREFIX wall_Q(int i, double t);
|
||||
EEXXTT double DLL_CPREFIX wall_area(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_setArea(int i, double v);
|
||||
EEXXTT int DLL_CPREFIX wall_setThermalResistance(int i, double rth);
|
||||
EEXXTT int DLL_CPREFIX wall_setHeatTransferCoeff(int i, double u);
|
||||
EEXXTT int DLL_CPREFIX wall_setHeatFlux(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX wall_setExpansionRateCoeff(int i, double k);
|
||||
EEXXTT int DLL_CPREFIX wall_setVelocity(int i, int n);
|
||||
EEXXTT int DLL_CPREFIX wall_setEmissivity(int i, double epsilon);
|
||||
EEXXTT int DLL_CPREFIX wall_ready(int i);
|
||||
EEXXTT int DLL_CPREFIX wall_addSensitivityReaction(int i, int lr, int rxn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
112
Cantera/clib/src/ctrpath.cpp
Executable file → Normal file
112
Cantera/clib/src/ctrpath.cpp
Executable file → Normal file
@@ -22,163 +22,197 @@ template<> Cabinet<ReactionPathDiagram>* Cabinet<ReactionPathDiagram>::__stora
|
||||
|
||||
template<> Cabinet<builder_t>* Cabinet<builder_t>::__storage = 0;
|
||||
|
||||
inline ReactionPathDiagram* _diag(int i) {
|
||||
inline ReactionPathDiagram* _diag(int i)
|
||||
{
|
||||
return Cabinet<ReactionPathDiagram>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline builder_t* _builder(int i) {
|
||||
inline builder_t* _builder(int i)
|
||||
{
|
||||
return Cabinet<builder_t>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline Kinetics* _kin(int n) {
|
||||
inline Kinetics* _kin(int n)
|
||||
{
|
||||
return Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT rdiag_new() {
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT rdiag_new()
|
||||
{
|
||||
diag_t* d = new ReactionPathDiagram();
|
||||
return Cabinet<diag_t>::cabinet()->add(d);
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_del(int i) {
|
||||
int DLL_EXPORT rdiag_del(int i)
|
||||
{
|
||||
Cabinet<diag_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_copy(int i) {
|
||||
int DLL_EXPORT rdiag_copy(int i)
|
||||
{
|
||||
return Cabinet<diag_t>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_assign(int i, int j) {
|
||||
int DLL_EXPORT rdiag_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<diag_t>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_detailed(int i) {
|
||||
int DLL_EXPORT rdiag_detailed(int i)
|
||||
{
|
||||
_diag(i)->show_details = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_brief(int i) {
|
||||
int DLL_EXPORT rdiag_brief(int i)
|
||||
{
|
||||
_diag(i)->show_details = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setThreshold(int i, double v) {
|
||||
int DLL_EXPORT rdiag_setThreshold(int i, double v)
|
||||
{
|
||||
_diag(i)->threshold = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setBoldColor(int i, char* color) {
|
||||
int DLL_EXPORT rdiag_setBoldColor(int i, char* color)
|
||||
{
|
||||
_diag(i)->bold_color = string(color);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setNormalColor(int i, char* color) {
|
||||
int DLL_EXPORT rdiag_setNormalColor(int i, char* color)
|
||||
{
|
||||
_diag(i)->normal_color = string(color);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setDashedColor(int i, char* color) {
|
||||
int DLL_EXPORT rdiag_setDashedColor(int i, char* color)
|
||||
{
|
||||
_diag(i)->dashed_color = string(color);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setDotOptions(int i, char* opt) {
|
||||
int DLL_EXPORT rdiag_setDotOptions(int i, char* opt)
|
||||
{
|
||||
_diag(i)->dot_options = string(opt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setFont(int i, char* font) {
|
||||
int DLL_EXPORT rdiag_setFont(int i, char* font)
|
||||
{
|
||||
_diag(i)->setFont(string(font));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setBoldThreshold(int i, double v) {
|
||||
int DLL_EXPORT rdiag_setBoldThreshold(int i, double v)
|
||||
{
|
||||
_diag(i)->bold_min = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setNormalThreshold(int i, double v) {
|
||||
int DLL_EXPORT rdiag_setNormalThreshold(int i, double v)
|
||||
{
|
||||
_diag(i)->dashed_max = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setLabelThreshold(int i, double v) {
|
||||
int DLL_EXPORT rdiag_setLabelThreshold(int i, double v)
|
||||
{
|
||||
_diag(i)->label_min = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setScale(int i, double v) {
|
||||
int DLL_EXPORT rdiag_setScale(int i, double v)
|
||||
{
|
||||
_diag(i)->scale = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setFlowType(int i, int iflow) {
|
||||
if (iflow == 0)
|
||||
int DLL_EXPORT rdiag_setFlowType(int i, int iflow)
|
||||
{
|
||||
if (iflow == 0) {
|
||||
_diag(i)->flow_type = OneWayFlow;
|
||||
else
|
||||
} else {
|
||||
_diag(i)->flow_type = NetFlow;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setArrowWidth(int i, double v) {
|
||||
int DLL_EXPORT rdiag_setArrowWidth(int i, double v)
|
||||
{
|
||||
_diag(i)->arrow_width = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_setTitle(int i, char* title) {
|
||||
int DLL_EXPORT rdiag_setTitle(int i, char* title)
|
||||
{
|
||||
_diag(i)->title = string(title);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_add(int i, int n) {
|
||||
int DLL_EXPORT rdiag_add(int i, int n)
|
||||
{
|
||||
_diag(i)->add(*_diag(n));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_findMajor(int i, double threshold,
|
||||
size_t lda, double* a) {
|
||||
int DLL_EXPORT rdiag_findMajor(int i, double threshold,
|
||||
size_t lda, double* a)
|
||||
{
|
||||
_diag(i)->findMajorPaths(threshold, lda, a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_write(int i, int fmt, char* fname) {
|
||||
int DLL_EXPORT rdiag_write(int i, int fmt, char* fname)
|
||||
{
|
||||
ofstream f(fname);
|
||||
if (fmt == 0)
|
||||
if (fmt == 0) {
|
||||
_diag(i)->exportToDot(f);
|
||||
else
|
||||
} else {
|
||||
_diag(i)->writeData(f);
|
||||
}
|
||||
f.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rdiag_displayOnly(int i, int k) {
|
||||
int DLL_EXPORT rdiag_displayOnly(int i, int k)
|
||||
{
|
||||
_diag(i)->displayOnly(k);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rbuild_new() {
|
||||
int DLL_EXPORT rbuild_new()
|
||||
{
|
||||
builder_t* d = new ReactionPathBuilder();
|
||||
return Cabinet<builder_t>::cabinet()->add(d);
|
||||
}
|
||||
|
||||
int DLL_EXPORT rbuild_del(int i) {
|
||||
int DLL_EXPORT rbuild_del(int i)
|
||||
{
|
||||
Cabinet<builder_t>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rbuild_init(int i, char* logfile, int k) {
|
||||
int DLL_EXPORT rbuild_init(int i, char* logfile, int k)
|
||||
{
|
||||
ofstream flog(logfile);
|
||||
_builder(i)->init(flog, *_kin(k));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT rbuild_build(int i, int k, char* el, char* dotfile,
|
||||
int idiag, int iquiet) {
|
||||
int DLL_EXPORT rbuild_build(int i, int k, char* el, char* dotfile,
|
||||
int idiag, int iquiet)
|
||||
{
|
||||
ofstream fdot(dotfile);
|
||||
bool quiet = false;
|
||||
if (iquiet > 0) quiet = true;
|
||||
if (iquiet > 0) {
|
||||
quiet = true;
|
||||
}
|
||||
_builder(i)->build(*_kin(k), string(el), fdot, *_diag(idiag), quiet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
6
Cantera/clib/src/ctrpath.h
Executable file → Normal file
6
Cantera/clib/src/ctrpath.h
Executable file → Normal file
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "clib_defs.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
EEXXTT int DLL_CPREFIX rdiag_new();
|
||||
EEXXTT int DLL_CPREFIX rdiag_del(int i);
|
||||
@@ -33,8 +33,8 @@ extern "C" {
|
||||
EEXXTT int DLL_CPREFIX rbuild_new();
|
||||
EEXXTT int DLL_CPREFIX rbuild_del(int i);
|
||||
EEXXTT int DLL_CPREFIX rbuild_init(int i, char* logfile, int k);
|
||||
EEXXTT int DLL_CPREFIX rbuild_build(int i, int k, char* el, char* dotfile,
|
||||
int idiag, int iquiet);
|
||||
EEXXTT int DLL_CPREFIX rbuild_build(int i, int k, char* el, char* dotfile,
|
||||
int idiag, int iquiet);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
57
Cantera/clib/src/ctsurf.cpp
Executable file → Normal file
57
Cantera/clib/src/ctsurf.cpp
Executable file → Normal file
@@ -22,66 +22,75 @@ using namespace Cantera;
|
||||
// return Cabinet<Surf1D>::cabinet()->item(i);
|
||||
//}
|
||||
|
||||
inline SurfPhase* _surfphase(int n) {
|
||||
inline SurfPhase* _surfphase(int n)
|
||||
{
|
||||
return (SurfPhase*)Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline InterfaceKinetics* _surfkin(int n) {
|
||||
inline InterfaceKinetics* _surfkin(int n)
|
||||
{
|
||||
return (InterfaceKinetics*)Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
// int DLL_EXPORT surface_new(int ikin) {
|
||||
// InterfaceKinetics* sk = 0;
|
||||
// if (ikin > 0) sk = _surfkin(ikin);
|
||||
// Surf1D* s = new Surf1D(sk);
|
||||
// return Cabinet<Surf1D>::cabinet()->add(s);
|
||||
// }
|
||||
// int DLL_EXPORT surface_new(int ikin) {
|
||||
// InterfaceKinetics* sk = 0;
|
||||
// if (ikin > 0) sk = _surfkin(ikin);
|
||||
// Surf1D* s = new Surf1D(sk);
|
||||
// return Cabinet<Surf1D>::cabinet()->add(s);
|
||||
// }
|
||||
|
||||
// int DLL_EXPORT surface_del(int i) {
|
||||
// Cabinet<Surf1D>::cabinet()->del(i);
|
||||
// return 0;
|
||||
// }
|
||||
// int DLL_EXPORT surface_del(int i) {
|
||||
// Cabinet<Surf1D>::cabinet()->del(i);
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
int DLL_EXPORT surf_setsitedensity(int i, double s0) {
|
||||
int DLL_EXPORT surf_setsitedensity(int i, double s0)
|
||||
{
|
||||
_surfphase(i)->setSiteDensity(s0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT surf_sitedensity(int i) {
|
||||
double DLL_EXPORT surf_sitedensity(int i)
|
||||
{
|
||||
return _surfphase(i)->siteDensity();
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_setcoverages(int i, double* c) {
|
||||
int DLL_EXPORT surf_setcoverages(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->setCoverages(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_setcoveragesbyname(int i, char* c) {
|
||||
int DLL_EXPORT surf_setcoveragesbyname(int i, char* c)
|
||||
{
|
||||
_surfphase(i)->setCoveragesByName(string(c));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_getcoverages(int i, double* c) {
|
||||
int DLL_EXPORT surf_getcoverages(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->getCoverages(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_setconcentrations(int i, double* c) {
|
||||
int DLL_EXPORT surf_setconcentrations(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->setConcentrations(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT surf_getconcentrations(int i, double* c) {
|
||||
int DLL_EXPORT surf_getconcentrations(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->getConcentrations(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int DLL_EXPORT surface_setcoverages(int i, double* c) {
|
||||
// _surface(i)->setCoverages(c);
|
||||
// return 0;
|
||||
// }
|
||||
// int DLL_EXPORT surface_setcoverages(int i, double* c) {
|
||||
// _surface(i)->setCoverages(c);
|
||||
// return 0;
|
||||
// }
|
||||
}
|
||||
|
||||
10
Cantera/clib/src/ctsurf.h
Executable file → Normal file
10
Cantera/clib/src/ctsurf.h
Executable file → Normal file
@@ -35,17 +35,17 @@ extern "C" {
|
||||
|
||||
EEXXTT int DLL_CPREFIX surfkin_new(int iph, int ith1, int ith2);
|
||||
EEXXTT int DLL_CPREFIX surfkin_del(int i);
|
||||
EEXXTT int DLL_CPREFIX surfkin_addreaction(int i, int nr, int* r,
|
||||
int* rst, int* ro, int np, int* p, int* pst,
|
||||
int nrate, double* rateParams);
|
||||
EEXXTT int DLL_CPREFIX surfkin_addreaction(int i, int nr, int* r,
|
||||
int* rst, int* ro, int np, int* p, int* pst,
|
||||
int nrate, double* rateParams);
|
||||
EEXXTT int DLL_CPREFIX surfkin_nreactions(int i);
|
||||
EEXXTT int DLL_CPREFIX surfkin_getratesofprogress(int i, double* rop);
|
||||
EEXXTT int DLL_CPREFIX surfkin_getnetproductionrates(int i, double* sdot);
|
||||
EEXXTT int DLL_CPREFIX surfkin_integrate(int i, double dt);
|
||||
EEXXTT int DLL_CPREFIX surfkin_save(int i, char* fname, char* id, char* comment);
|
||||
|
||||
EEXXTT int DLL_CPREFIX surface_settolerances(int i, int nr,
|
||||
double* rtol, int na, double* atol);
|
||||
EEXXTT int DLL_CPREFIX surface_settolerances(int i, int nr,
|
||||
double* rtol, int na, double* atol);
|
||||
EEXXTT int DLL_CPREFIX surface_fixspecies(int i, int k, double c=-1.0);
|
||||
EEXXTT int DLL_CPREFIX surface_solvespecies(int i, int k);
|
||||
EEXXTT int DLL_CPREFIX surface_setmultiplier(int i, int k, double f);
|
||||
|
||||
@@ -20,254 +20,297 @@ using namespace ctml;
|
||||
// class Cabinet<XML_Node>;
|
||||
template<> Cabinet<XML_Node>* Cabinet<XML_Node>::__storage = 0;
|
||||
|
||||
inline XML_Node* _xml(int i) {
|
||||
inline XML_Node* _xml(int i)
|
||||
{
|
||||
return Cabinet<XML_Node>::cabinet(false)->item(i);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT xml_new(const char* name = 0) {
|
||||
int DLL_EXPORT xml_new(const char* name = 0)
|
||||
{
|
||||
XML_Node* x;
|
||||
if (!name)
|
||||
if (!name) {
|
||||
x = new XML_Node;
|
||||
else
|
||||
} else {
|
||||
x = new XML_Node(name);
|
||||
}
|
||||
return Cabinet<XML_Node>::cabinet(true)->add(x);
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_get_XML_File(const char* file, int debug) {
|
||||
int DLL_EXPORT xml_get_XML_File(const char* file, int debug)
|
||||
{
|
||||
try {
|
||||
XML_Node* x = get_XML_File(std::string(file), debug);
|
||||
return Cabinet<XML_Node>::cabinet(false)->add(x);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_clear() {
|
||||
int DLL_EXPORT xml_clear()
|
||||
{
|
||||
try {
|
||||
Cabinet<XML_Node>::cabinet(false)->clear();
|
||||
close_XML_File("all");
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_del(int i) {
|
||||
int DLL_EXPORT xml_del(int i)
|
||||
{
|
||||
Cabinet<XML_Node>::cabinet(false)->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_removeChild(int i, int j) {
|
||||
int DLL_EXPORT xml_removeChild(int i, int j)
|
||||
{
|
||||
_xml(i)->removeChild(_xml(j));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_copy(int i) {
|
||||
int DLL_EXPORT xml_copy(int i)
|
||||
{
|
||||
return Cabinet<XML_Node>::cabinet(false)->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_assign(int i, int j) {
|
||||
int DLL_EXPORT xml_assign(int i, int j)
|
||||
{
|
||||
return Cabinet<XML_Node>::cabinet(false)->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_build(int i, const char* file) {
|
||||
int DLL_EXPORT xml_build(int i, const char* file)
|
||||
{
|
||||
try {
|
||||
writelog("WARNING: xml_build called. Use get_XML_File instead.");
|
||||
string path = findInputFile(string(file));
|
||||
ifstream f(path.c_str());
|
||||
if (!f) {
|
||||
throw CanteraError("xml_build",
|
||||
"file "+string(file)+" not found.");
|
||||
"file "+string(file)+" not found.");
|
||||
}
|
||||
_xml(i)->build(f);
|
||||
f.close();
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_preprocess_and_build(int i, const char* file, int debug) {
|
||||
int DLL_EXPORT xml_preprocess_and_build(int i, const char* file, int debug)
|
||||
{
|
||||
try {
|
||||
get_CTML_Tree(_xml(i), string(file), debug);
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DLL_EXPORT xml_attrib(int i, const char* key, char* value) {
|
||||
int DLL_EXPORT xml_attrib(int i, const char* key, char* value)
|
||||
{
|
||||
try {
|
||||
string ky = string(key);
|
||||
XML_Node& node = *_xml(i);
|
||||
if (node.hasAttrib(ky)) {
|
||||
string v = node[ky];
|
||||
strncpy(value, v.c_str(), 80);
|
||||
}
|
||||
else
|
||||
} else
|
||||
throw CanteraError("xml_attrib","node "
|
||||
" has no attribute '"+ky+"'");
|
||||
" has no attribute '"+ky+"'");
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_addAttrib(int i, const char* key, const char* value) {
|
||||
int DLL_EXPORT xml_addAttrib(int i, const char* key, const char* value)
|
||||
{
|
||||
try {
|
||||
string ky = string(key);
|
||||
string val = string(value);
|
||||
XML_Node& node = *_xml(i);
|
||||
node.addAttribute(ky, val);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_addComment(int i, const char* comment) {
|
||||
int DLL_EXPORT xml_addComment(int i, const char* comment)
|
||||
{
|
||||
try {
|
||||
string c = string(comment);
|
||||
XML_Node& node = *_xml(i);
|
||||
node.addComment(c);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_tag(int i, char* tag) {
|
||||
int DLL_EXPORT xml_tag(int i, char* tag)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
const string v = node.name();
|
||||
strncpy(tag, v.c_str(), 80);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_value(int i, char* value) {
|
||||
int DLL_EXPORT xml_value(int i, char* value)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
const string v = node.value();
|
||||
strncpy(value, v.c_str(), 80);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_child(int i, const char* loc) {
|
||||
int DLL_EXPORT xml_child(int i, const char* loc)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.child(string(loc));
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_child_bynumber(int i, int m) {
|
||||
int DLL_EXPORT xml_child_bynumber(int i, int m)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.child(m);
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_findID(int i, const char* id) {
|
||||
int DLL_EXPORT xml_findID(int i, const char* id)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node* c = node.findID(string(id));
|
||||
if (c) {
|
||||
return Cabinet<XML_Node>::cabinet()->add(c);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
throw CanteraError("xml_find_id","id not found: "+string(id));
|
||||
}
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_findByName(int i, const char* nm) {
|
||||
int DLL_EXPORT xml_findByName(int i, const char* nm)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node* c = node.findByName(string(nm));
|
||||
if (c) {
|
||||
return Cabinet<XML_Node>::cabinet()->add(c);
|
||||
}
|
||||
else
|
||||
} else
|
||||
throw CanteraError("xml_findByName","name "+string(nm)
|
||||
+" not found");
|
||||
+" not found");
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_nChildren(int i) {
|
||||
int DLL_EXPORT xml_nChildren(int i)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
return (int) node.nChildren();
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_addChild(int i, const char* name, const char* value) {
|
||||
int DLL_EXPORT xml_addChild(int i, const char* name, const char* value)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.addChild(string(name),string(value));
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { showErrors(cout); return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_addChildNode(int i, int j) {
|
||||
int DLL_EXPORT xml_addChildNode(int i, int j)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& chld = *_xml(j);
|
||||
XML_Node& c = node.addChild(chld);
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT xml_write(int i, const char* file) {
|
||||
int DLL_EXPORT xml_write(int i, const char* file)
|
||||
{
|
||||
try {
|
||||
ofstream f(file);
|
||||
if (f) {
|
||||
XML_Node& node = *_xml(i);
|
||||
node.write(f);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw CanteraError("xml_write",
|
||||
"file "+string(file)+" not found.");
|
||||
"file "+string(file)+" not found.");
|
||||
}
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT ctml_getFloatArray(int i, size_t n, doublereal* data, int iconvert) {
|
||||
int DLL_EXPORT ctml_getFloatArray(int i, size_t n, doublereal* data, int iconvert)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
vector_fp v;
|
||||
bool conv = false;
|
||||
if (iconvert > 0) conv = true;
|
||||
if (iconvert > 0) {
|
||||
conv = true;
|
||||
}
|
||||
getFloatArray(node, v, conv);
|
||||
size_t nv = v.size();
|
||||
|
||||
// array not big enough
|
||||
if (n < nv) {
|
||||
throw CanteraError("ctml_getFloatArray",
|
||||
"array must be dimensioned at least "+int2str(int(nv)));
|
||||
"array must be dimensioned at least "+int2str(int(nv)));
|
||||
}
|
||||
|
||||
|
||||
for (size_t i = 0; i < nv; i++) {
|
||||
data[i] = v[i];
|
||||
}
|
||||
} catch (CanteraError) {
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "cantera/kernel/config.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
EEXXTT int DLL_CPREFIX xml_new(const char* name);
|
||||
EEXXTT int DLL_CPREFIX xml_get_XML_File(const char* file, int debug = 0);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace std;
|
||||
using namespace Cantera;
|
||||
using namespace Cantera_CXX;
|
||||
|
||||
@@ -18,7 +18,8 @@ using namespace Cantera_CXX;
|
||||
// The program is put into a function so that error handling code can
|
||||
// be conveniently put around the whole thing. See main() below.
|
||||
|
||||
void demoprog() {
|
||||
void demoprog()
|
||||
{
|
||||
|
||||
printf("\n\n**** Testing modifying NASA polynomial coefficients ****\n\n");
|
||||
|
||||
@@ -50,12 +51,18 @@ void demoprog() {
|
||||
|
||||
// print the unmodified NASA coefficients
|
||||
printf("\n ");
|
||||
for (j = 1; j < 8; j++) printf(" A%d ", j);
|
||||
for (j = 1; j < 8; j++) {
|
||||
printf(" A%d ", j);
|
||||
}
|
||||
printf("\n low:");
|
||||
for (j = 1; j < 8; j++) printf(" %10.4E ", c[j]);
|
||||
for (j = 1; j < 8; j++) {
|
||||
printf(" %10.4E ", c[j]);
|
||||
}
|
||||
|
||||
printf("\n high:");
|
||||
for (j = 8; j < 15; j++) printf(" %10.4E ", c[j]);
|
||||
for (j = 8; j < 15; j++) {
|
||||
printf(" %10.4E ", c[j]);
|
||||
}
|
||||
printf("\n ");
|
||||
|
||||
// modify coefficient A6 of the low-temperature polynomial
|
||||
@@ -70,24 +77,30 @@ void demoprog() {
|
||||
// print the modified NASA coefficients
|
||||
printf("\n\n %s (modified):", gas.speciesName(n).c_str());
|
||||
printf("\n ");
|
||||
for (j = 1; j < 8; j++) printf(" A%d ", j);
|
||||
for (j = 1; j < 8; j++) {
|
||||
printf(" A%d ", j);
|
||||
}
|
||||
printf("\n low:");
|
||||
for (j = 1; j < 8; j++) printf(" %10.4E ", c[j]);
|
||||
for (j = 1; j < 8; j++) {
|
||||
printf(" %10.4E ", c[j]);
|
||||
}
|
||||
|
||||
printf("\n high:");
|
||||
for (j = 8; j < 15; j++) printf(" %10.4E ", c[j]);
|
||||
for (j = 8; j < 15; j++) {
|
||||
printf(" %10.4E ", c[j]);
|
||||
}
|
||||
printf("\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
try {
|
||||
demoprog();
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
using namespace Cantera;
|
||||
|
||||
void runexample() {
|
||||
void runexample()
|
||||
{
|
||||
|
||||
// use reaction mechanism GRI-Mech 3.0
|
||||
IdealGasMix gas("gri30.cti", "gri30");
|
||||
@@ -83,7 +84,7 @@ void runexample() {
|
||||
double FWHM = 0.2;
|
||||
double t0 = 1.0;
|
||||
Gaussian igniter_mdot(A, t0, FWHM);
|
||||
|
||||
|
||||
MassFlowController m3;
|
||||
m3.install(igniter, combustor);
|
||||
m3.setFunction(&igniter_mdot);
|
||||
@@ -122,7 +123,8 @@ void runexample() {
|
||||
f.close();
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
|
||||
try {
|
||||
runexample();
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
|
||||
using namespace Cantera;
|
||||
|
||||
int flamespeed(int np, void* p) {
|
||||
int flamespeed(int np, void* p)
|
||||
{
|
||||
try {
|
||||
int i;
|
||||
IdealGasMix gas("gri30.cti","gri30_mix");
|
||||
IdealGasMix gas("gri30.cti","gri30_mix");
|
||||
|
||||
doublereal temp = 300.0; // K
|
||||
doublereal pressure = 1.0*OneAtm; //atm
|
||||
@@ -22,7 +23,9 @@ int flamespeed(int np, void* p) {
|
||||
x.resize(nsp);
|
||||
|
||||
double phi = 0.0;
|
||||
if (np > 0) phi = *(double*)(p);
|
||||
if (np > 0) {
|
||||
phi = *(double*)(p);
|
||||
}
|
||||
if (phi == 0.0) {
|
||||
cout << "Enter phi: ";
|
||||
cin >> phi;
|
||||
@@ -32,26 +35,30 @@ int flamespeed(int np, void* p) {
|
||||
doublereal H_atoms=4.0;
|
||||
doublereal ax=C_atoms+H_atoms/4.0;
|
||||
doublereal fa_stoic=1.0/(4.76*ax);
|
||||
for(int k=0;k<nsp;k++){
|
||||
if(k==gas.speciesIndex("CH4")){ x[k]=1.0; }
|
||||
else if(k==gas.speciesIndex("O2")){ x[k]=0.21/phi/fa_stoic; }
|
||||
else if(k==gas.speciesIndex("N2")){ x[k]=0.79/phi/fa_stoic; }
|
||||
else{ x[k]=0.0; }
|
||||
for (int k=0; k<nsp; k++) {
|
||||
if (k==gas.speciesIndex("CH4")) {
|
||||
x[k]=1.0;
|
||||
} else if (k==gas.speciesIndex("O2")) {
|
||||
x[k]=0.21/phi/fa_stoic;
|
||||
} else if (k==gas.speciesIndex("N2")) {
|
||||
x[k]=0.79/phi/fa_stoic;
|
||||
} else {
|
||||
x[k]=0.0;
|
||||
}
|
||||
}
|
||||
|
||||
gas.setState_TPX(temp,pressure,DATA_PTR(x));
|
||||
doublereal rho_in=gas.density();
|
||||
|
||||
double *yin=new double[nsp];
|
||||
double* yin=new double[nsp];
|
||||
gas.getMassFractions(yin);
|
||||
|
||||
try {
|
||||
equilibrate(gas,"HP");
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
}
|
||||
double *yout=new double[nsp];
|
||||
double* yout=new double[nsp];
|
||||
gas.getMassFractions(yout);
|
||||
doublereal rho_out = gas.density();
|
||||
doublereal Tad=gas.temperature();
|
||||
@@ -73,9 +80,9 @@ int flamespeed(int np, void* p) {
|
||||
// create an initial grid
|
||||
int nz=5;
|
||||
doublereal lz=0.02;
|
||||
doublereal *z=new double[nz+1];
|
||||
doublereal* z=new double[nz+1];
|
||||
doublereal dz=lz/((doublereal)(nz-1));
|
||||
for(int iz=0;iz<nz;iz++){
|
||||
for (int iz=0; iz<nz; iz++) {
|
||||
z[iz]=((doublereal)iz)*dz;
|
||||
}
|
||||
//add one node onto end of domain to help with zero gradient at outlet
|
||||
@@ -84,7 +91,7 @@ int flamespeed(int np, void* p) {
|
||||
|
||||
flow.setupGrid(nz, z);
|
||||
|
||||
// specify the objects to use to compute kinetic rates and
|
||||
// specify the objects to use to compute kinetic rates and
|
||||
// transport properties
|
||||
|
||||
Transport* trmix = newTransportMgr("Mix", &gas);
|
||||
@@ -127,22 +134,30 @@ int flamespeed(int np, void* p) {
|
||||
locs.resize(3);
|
||||
value.resize(3);
|
||||
|
||||
//ramp values from inlet to adiabatic flame conditions
|
||||
//ramp values from inlet to adiabatic flame conditions
|
||||
// over 70% of domain and then level off at equilibrium
|
||||
double z1=0.7;
|
||||
|
||||
double uout;
|
||||
uout=inlet.mdot()/rho_out;
|
||||
uin=inlet.mdot()/rho_in;
|
||||
locs[0]=0.0; locs[1]=z1; locs[2]=1.0;
|
||||
value[0]=uin; value[1]=uout; value[2]=uout;
|
||||
locs[0]=0.0;
|
||||
locs[1]=z1;
|
||||
locs[2]=1.0;
|
||||
value[0]=uin;
|
||||
value[1]=uout;
|
||||
value[2]=uout;
|
||||
flame.setInitialGuess("u",locs,value);
|
||||
|
||||
value[0]=temp; value[1]=Tad; value[2]=Tad;
|
||||
value[0]=temp;
|
||||
value[1]=Tad;
|
||||
value[2]=Tad;
|
||||
flame.setInitialGuess("T",locs,value);
|
||||
|
||||
for(i=0;i<nsp;i++){
|
||||
value[0]=yin[i]; value[1]=yout[i]; value[2]=yout[i];
|
||||
for (i=0; i<nsp; i++) {
|
||||
value[0]=yin[i];
|
||||
value[1]=yout[i];
|
||||
value[2]=yout[i];
|
||||
flame.setInitialGuess(gas.speciesName(i),locs,value);
|
||||
}
|
||||
|
||||
@@ -160,7 +175,7 @@ int flamespeed(int np, void* p) {
|
||||
|
||||
flame.setRefineCriteria(flowdomain,ratio,slope,curve,prune);
|
||||
|
||||
int loglevel=1;
|
||||
int loglevel=1;
|
||||
bool refine_grid = true;
|
||||
|
||||
/* Solve species*/
|
||||
@@ -185,27 +200,27 @@ int flamespeed(int np, void* p) {
|
||||
flame.solve(loglevel,refine_grid);
|
||||
double flameSpeed_mix = flame.value(flowdomain,flow.componentIndex("u"),0);
|
||||
cout << "Flame speed with mixture-averaged transport: " <<
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
|
||||
// now switch to multicomponent transport
|
||||
flow.setTransport(*trmulti);
|
||||
flame.solve(loglevel, refine_grid);
|
||||
double flameSpeed_multi = flame.value(flowdomain,flow.componentIndex("u"),0);
|
||||
double flameSpeed_multi = flame.value(flowdomain,flow.componentIndex("u"),0);
|
||||
cout << "Flame speed with multicomponent transport: " <<
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
|
||||
// now enable Soret diffusion
|
||||
flow.enableSoret(true);
|
||||
flame.solve(loglevel, refine_grid);
|
||||
double flameSpeed_full = flame.value(flowdomain,flow.componentIndex("u"),0);
|
||||
double flameSpeed_full = flame.value(flowdomain,flow.componentIndex("u"),0);
|
||||
cout << "Flame speed with multicomponent transport + Soret: " <<
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
|
||||
|
||||
int np=flow.nPoints();
|
||||
vector<doublereal> zvec,Tvec,COvec,CO2vec,Uvec;
|
||||
|
||||
printf("\n%9s\t%8s\t%5s\t%7s\n","z (m)", "T (K)", "U (m/s)", "Y(CO)");
|
||||
for(int n=0;n<np;n++){
|
||||
for (int n=0; n<np; n++) {
|
||||
Tvec.push_back(flame.value(flowdomain,flow.componentIndex("T"),n));
|
||||
COvec.push_back(flame.value(flowdomain,flow.componentIndex("CO"),n));
|
||||
CO2vec.push_back(flame.value(flowdomain,flow.componentIndex("CO2"),n));
|
||||
@@ -217,26 +232,25 @@ int flamespeed(int np, void* p) {
|
||||
cout << endl<<"Adiabatic flame temperature from equilibrium is: "<<Tad<<endl;
|
||||
cout << "Flame speed for phi="<<phi<<" is "<<Uvec[0]<<" m/s."<<endl;
|
||||
|
||||
string reportFile = "flamespeed.csv";
|
||||
FILE * FP = fopen(reportFile.c_str(), "w");
|
||||
if (!FP) {
|
||||
printf("Failure to open file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(FP," Flame speed (mixture-averaged ) = %11.3e m/s\n", flameSpeed_mix);
|
||||
fprintf(FP," Flame speed (multicomponent ) = %11.3e m/s\n", flameSpeed_multi);
|
||||
fprintf(FP," Flame speed (multicomponent + Soret) = %11.3e m/s\n", flameSpeed_full);
|
||||
fprintf(FP," Grid, Temperature, Uvec, CO, CO2\n");
|
||||
for (int n = 0; n < np; n++) {
|
||||
fprintf(FP," %11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
|
||||
flow.grid(n), Tvec[n], Uvec[n], COvec[n], CO2vec[n]);
|
||||
string reportFile = "flamespeed.csv";
|
||||
FILE* FP = fopen(reportFile.c_str(), "w");
|
||||
if (!FP) {
|
||||
printf("Failure to open file\n");
|
||||
exit(-1);
|
||||
}
|
||||
fclose(FP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
fprintf(FP," Flame speed (mixture-averaged ) = %11.3e m/s\n", flameSpeed_mix);
|
||||
fprintf(FP," Flame speed (multicomponent ) = %11.3e m/s\n", flameSpeed_multi);
|
||||
fprintf(FP," Flame speed (multicomponent + Soret) = %11.3e m/s\n", flameSpeed_full);
|
||||
fprintf(FP," Grid, Temperature, Uvec, CO, CO2\n");
|
||||
for (int n = 0; n < np; n++) {
|
||||
fprintf(FP," %11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
|
||||
flow.grid(n), Tvec[n], Uvec[n], COvec[n], CO2vec[n]);
|
||||
}
|
||||
fclose(FP);
|
||||
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
showErrors(cerr);
|
||||
cerr << "program terminating." << endl;
|
||||
return -1;
|
||||
@@ -244,7 +258,8 @@ int flamespeed(int np, void* p) {
|
||||
}
|
||||
|
||||
#ifndef CXX_DEMO
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return flamespeed(0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
// Save the temperature, density, pressure, and mole fractions at one
|
||||
// time
|
||||
template<class G, class A>
|
||||
void saveSoln(int i, double time, const G& gas, A& soln) {
|
||||
void saveSoln(int i, double time, const G& gas, A& soln)
|
||||
{
|
||||
soln(0,i) = time;
|
||||
soln(1,i) = gas.temperature();
|
||||
soln(2,i) = gas.density();
|
||||
@@ -16,7 +17,8 @@ void saveSoln(int i, double time, const G& gas, A& soln) {
|
||||
}
|
||||
|
||||
template<class G, class A>
|
||||
void saveSoln(double time, const G& gas, A& soln) {
|
||||
void saveSoln(double time, const G& gas, A& soln)
|
||||
{
|
||||
soln.resize(soln.nRows(), soln.nColumns() + 1);
|
||||
int back = soln.nColumns() - 1;
|
||||
soln(0,back) = time;
|
||||
@@ -24,12 +26,14 @@ void saveSoln(double time, const G& gas, A& soln) {
|
||||
soln(2,back) = gas.density();
|
||||
soln(3,back) = gas.pressure();
|
||||
int nsp = gas.nSpecies();
|
||||
for (int k = 0; k < nsp; k++)
|
||||
for (int k = 0; k < nsp; k++) {
|
||||
soln(4+k,back) = gas.moleFraction(k);
|
||||
}
|
||||
}
|
||||
|
||||
template<class G, class V>
|
||||
void makeDataLabels(const G& gas, V& names) {
|
||||
void makeDataLabels(const G& gas, V& names)
|
||||
{
|
||||
int nsp = gas.nSpecies();
|
||||
names.resize(nsp + 4);
|
||||
names[0] = "time (s)";
|
||||
@@ -37,19 +41,23 @@ void makeDataLabels(const G& gas, V& names) {
|
||||
names[2] = "Density (kg/m3)";
|
||||
names[3] = "Pressure (Pa)";
|
||||
int k;
|
||||
for (k = 0; k < nsp; k++) names[4+k] = gas.speciesName(k);
|
||||
for (k = 0; k < nsp; k++) {
|
||||
names[4+k] = gas.speciesName(k);
|
||||
}
|
||||
}
|
||||
|
||||
template<class G, class A>
|
||||
void plotSoln(std::string fname, std::string fmt, std::string title, const G& gas, const A& soln) {
|
||||
void plotSoln(std::string fname, std::string fmt, std::string title, const G& gas, const A& soln)
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
makeDataLabels(gas, names);
|
||||
writePlotFile(fname, fmt, title, names, soln);
|
||||
}
|
||||
|
||||
inline void writeCanteraHeader(std::ostream& s) {
|
||||
inline void writeCanteraHeader(std::ostream& s)
|
||||
{
|
||||
s << std::endl;
|
||||
s << " Cantera version " << "CANTERA_VERSION" << std::endl;
|
||||
s << " Cantera version " << "CANTERA_VERSION" << std::endl;
|
||||
s << " Copyright California Institute of Technology, 2002." << std::endl;
|
||||
s << " http://www.cantera.org" << std::endl;
|
||||
s << std::endl;
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
#include "example_utils.h"
|
||||
|
||||
|
||||
int kinetics1(int np, void* p) {
|
||||
int kinetics1(int np, void* p)
|
||||
{
|
||||
|
||||
cout << "Constant-pressure ignition of a "
|
||||
<< "hydrogen/oxygen/nitrogen"
|
||||
" mixture \nbeginning at T = 1001 K and P = 1 atm." << endl;
|
||||
" mixture \nbeginning at T = 1001 K and P = 1 atm." << endl;
|
||||
|
||||
// create an ideal gas mixture that corresponds to GRI-Mech
|
||||
// 3.0
|
||||
@@ -94,9 +95,9 @@ int kinetics1(int np, void* p) {
|
||||
doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC;
|
||||
cout << " Tfinal = " << r.temperature() << endl;
|
||||
cout << " time = " << tmm << endl;
|
||||
cout << " number of residual function evaluations = "
|
||||
cout << " number of residual function evaluations = "
|
||||
<< sim.integrator().nEvals() << endl;
|
||||
cout << " time per evaluation = " << tmm/sim.integrator().nEvals()
|
||||
cout << " time per evaluation = " << tmm/sim.integrator().nEvals()
|
||||
<< endl << endl;
|
||||
cout << "Output files:" << endl
|
||||
<< " kin1.csv (Excel CSV file)" << endl
|
||||
@@ -108,7 +109,8 @@ int kinetics1(int np, void* p) {
|
||||
|
||||
#ifndef CXX_DEMO
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
|
||||
try {
|
||||
int retn = kinetics1(0, 0);
|
||||
|
||||
@@ -17,7 +17,8 @@ map<string,double> x;
|
||||
vector<string> states;
|
||||
|
||||
template<class F>
|
||||
void saveState(F& fluid, string name) {
|
||||
void saveState(F& fluid, string name)
|
||||
{
|
||||
h[name] = fluid.enthalpy_mass();
|
||||
s[name] = fluid.entropy_mass();
|
||||
T[name] = fluid.temperature();
|
||||
@@ -26,18 +27,20 @@ void saveState(F& fluid, string name) {
|
||||
states.push_back(name);
|
||||
}
|
||||
|
||||
void printStates() {
|
||||
void printStates()
|
||||
{
|
||||
string name;
|
||||
int n;
|
||||
int nStates = states.size();
|
||||
for (n = 0; n < nStates; n++) {
|
||||
name = states[n];
|
||||
printf(" %5s %10.6g %10.6g %12.6g %12.6g %5.2g \n",
|
||||
name.c_str(), T[name], P[name], h[name], s[name], x[name]);
|
||||
printf(" %5s %10.6g %10.6g %12.6g %12.6g %5.2g \n",
|
||||
name.c_str(), T[name], P[name], h[name], s[name], x[name]);
|
||||
}
|
||||
}
|
||||
|
||||
int openRankine(int np, void* p) {
|
||||
int openRankine(int np, void* p)
|
||||
{
|
||||
|
||||
double etap = 0.6; // pump isentropic efficiency
|
||||
double etat = 0.8; // turbine isentropic efficiency
|
||||
@@ -79,12 +82,12 @@ int openRankine(int np, void* p) {
|
||||
|
||||
|
||||
#ifndef CXX_DEMO
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
|
||||
try {
|
||||
return openRankine(0, 0);
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -7,40 +7,48 @@
|
||||
#include "kernel/EdgeKinetics.h"
|
||||
#include "kernel/importKinetics.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class Edge :
|
||||
public EdgePhase, public EdgeKinetics
|
||||
{
|
||||
public:
|
||||
Edge(std::string infile, std::string id, std::vector<ThermoPhase*> phases)
|
||||
: m_ok(false), m_r(0) {
|
||||
class Edge :
|
||||
public EdgePhase, public EdgeKinetics
|
||||
{
|
||||
public:
|
||||
Edge(std::string infile, std::string id, std::vector<ThermoPhase*> phases)
|
||||
: m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
|
||||
XML_Node* x = get_XML_Node("#"+id, m_r);
|
||||
if (!x)
|
||||
throw CanteraError("Edge","error in get_XML_Node");
|
||||
|
||||
importPhase(*x, this);
|
||||
phases.push_back(this);
|
||||
importKinetics(*x, phases, this);
|
||||
m_ok = true;
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") {
|
||||
id = "";
|
||||
}
|
||||
|
||||
XML_Node* x = get_XML_Node("#"+id, m_r);
|
||||
if (!x) {
|
||||
throw CanteraError("Edge","error in get_XML_Node");
|
||||
}
|
||||
|
||||
virtual ~Edge() {}
|
||||
importPhase(*x, this);
|
||||
phases.push_back(this);
|
||||
importKinetics(*x, phases, this);
|
||||
m_ok = true;
|
||||
}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
bool ready() const { return m_ok; }
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
virtual ~Edge() {}
|
||||
|
||||
private:
|
||||
};
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
}
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,46 +8,51 @@
|
||||
#include "kernel/importKinetics.h"
|
||||
#include "kernel/stringUtils.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
/**
|
||||
* This class is a convenience class for use in C++ programs that
|
||||
* hard-wires the GRI 3.0 reaction mechanism. It derivees from
|
||||
* both Cantera::IdealGasPhase, which handles all composition and
|
||||
* state information, as well as thermodynamic properties, and
|
||||
* class GRI_30_Kinetics, which is the kinetics manager with
|
||||
* hard-wired replacements for some of the generic kinetics
|
||||
* methods like "getNetReactionRates."
|
||||
*/
|
||||
class GRI30 :
|
||||
public IdealGasPhase,
|
||||
public GRI_30_Kinetics
|
||||
{
|
||||
public:
|
||||
GRI30() : m_ok(false), m_r(0) {
|
||||
m_r = get_XML_File("gri30.xml");
|
||||
m_ok = buildSolutionFromXML(*m_r, "gri30",
|
||||
"phase", this, this);
|
||||
if (!m_ok) throw CanteraError("GRI30",
|
||||
"buildSolutionFromXML returned false");
|
||||
}
|
||||
/**
|
||||
* This class is a convenience class for use in C++ programs that
|
||||
* hard-wires the GRI 3.0 reaction mechanism. It derivees from
|
||||
* both Cantera::IdealGasPhase, which handles all composition and
|
||||
* state information, as well as thermodynamic properties, and
|
||||
* class GRI_30_Kinetics, which is the kinetics manager with
|
||||
* hard-wired replacements for some of the generic kinetics
|
||||
* methods like "getNetReactionRates."
|
||||
*/
|
||||
class GRI30 :
|
||||
public IdealGasPhase,
|
||||
public GRI_30_Kinetics
|
||||
{
|
||||
public:
|
||||
GRI30() : m_ok(false), m_r(0) {
|
||||
m_r = get_XML_File("gri30.xml");
|
||||
m_ok = buildSolutionFromXML(*m_r, "gri30",
|
||||
"phase", this, this);
|
||||
if (!m_ok) throw CanteraError("GRI30",
|
||||
"buildSolutionFromXML returned false");
|
||||
}
|
||||
|
||||
virtual ~GRI30() {}
|
||||
virtual ~GRI30() {}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
bool ready() const { return m_ok; }
|
||||
friend std::ostream& operator<<(std::ostream& s, GRI30& mix) {
|
||||
std::string r = mix.report(true);
|
||||
s << r;
|
||||
return s;
|
||||
}
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
}
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& s, GRI30& mix) {
|
||||
std::string r = mix.report(true);
|
||||
s << r;
|
||||
return s;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
Cantera::XML_Node* m_r;
|
||||
protected:
|
||||
bool m_ok;
|
||||
Cantera::XML_Node* m_r;
|
||||
|
||||
private:
|
||||
};
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,58 +8,65 @@
|
||||
#include "kernel/importKinetics.h"
|
||||
#include "kernel/stringUtils.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class IdealGasMix :
|
||||
public IdealGasPhase,
|
||||
public GasKinetics
|
||||
{
|
||||
public:
|
||||
class IdealGasMix :
|
||||
public IdealGasPhase,
|
||||
public GasKinetics
|
||||
{
|
||||
public:
|
||||
|
||||
IdealGasMix() : m_ok(false), m_r(0) {}
|
||||
IdealGasMix() : m_ok(false), m_r(0) {}
|
||||
|
||||
IdealGasMix(std::string infile, std::string id="") :
|
||||
m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
m_id = id;
|
||||
if (id == "-") id = "";
|
||||
m_ok = buildSolutionFromXML(*m_r,
|
||||
m_id, "phase", this, this);
|
||||
if (!m_ok) throw CanteraError("IdealGasMix",
|
||||
"Cantera::buildSolutionFromXML returned false");
|
||||
IdealGasMix(std::string infile, std::string id="") :
|
||||
m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
m_id = id;
|
||||
if (id == "-") {
|
||||
id = "";
|
||||
}
|
||||
m_ok = buildSolutionFromXML(*m_r,
|
||||
m_id, "phase", this, this);
|
||||
if (!m_ok) throw CanteraError("IdealGasMix",
|
||||
"Cantera::buildSolutionFromXML returned false");
|
||||
}
|
||||
|
||||
|
||||
IdealGasMix(XML_Node& root,
|
||||
std::string id) : m_ok(false), m_r(&root), m_id(id) {
|
||||
m_ok = buildSolutionFromXML(root, id, "phase", this, this);
|
||||
}
|
||||
IdealGasMix(XML_Node& root,
|
||||
std::string id) : m_ok(false), m_r(&root), m_id(id) {
|
||||
m_ok = buildSolutionFromXML(root, id, "phase", this, this);
|
||||
}
|
||||
|
||||
IdealGasMix(const IdealGasMix& other) : m_ok(false),
|
||||
m_r(other.m_r),
|
||||
m_id(other.m_id) {
|
||||
m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
|
||||
}
|
||||
IdealGasMix(const IdealGasMix& other) : m_ok(false),
|
||||
m_r(other.m_r),
|
||||
m_id(other.m_id) {
|
||||
m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
|
||||
}
|
||||
|
||||
virtual ~IdealGasMix() {}
|
||||
virtual ~IdealGasMix() {}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
bool ready() const { return m_ok; }
|
||||
friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
|
||||
std::string r = mix.report(true);
|
||||
s << r;
|
||||
return s;
|
||||
}
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
}
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
|
||||
std::string r = mix.report(true);
|
||||
s << r;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
std::string m_id;
|
||||
|
||||
private:
|
||||
};
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
std::string m_id;
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,37 +6,44 @@
|
||||
#include "kernel/ConstDensityThermo.h"
|
||||
#include "kernel/importKinetics.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class IncompressibleSolid : public ConstDensityThermo
|
||||
{
|
||||
public:
|
||||
IncompressibleSolid(std::string infile,
|
||||
std::string id="") : m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
|
||||
if (!m_ok) throw CanteraError("IncompressibleSolid",
|
||||
"buildSolutionFromXML returned false");
|
||||
class IncompressibleSolid : public ConstDensityThermo
|
||||
{
|
||||
public:
|
||||
IncompressibleSolid(std::string infile,
|
||||
std::string id="") : m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") {
|
||||
id = "";
|
||||
}
|
||||
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
|
||||
if (!m_ok) throw CanteraError("IncompressibleSolid",
|
||||
"buildSolutionFromXML returned false");
|
||||
}
|
||||
|
||||
virtual ~IncompressibleSolid() {}
|
||||
virtual ~IncompressibleSolid() {}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
bool ready() const { return m_ok; }
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
}
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
//friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
|
||||
// std::string r = report(mix, true);
|
||||
// s << r;
|
||||
// return s;
|
||||
//friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
|
||||
// std::string r = report(mix, true);
|
||||
// s << r;
|
||||
// return s;
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
|
||||
private:
|
||||
};
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,21 +10,22 @@
|
||||
#include "thermo.h"
|
||||
#include "kinetics.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
//! An interface between multiple bulk phases.
|
||||
/*!
|
||||
* This class isdefined mostly for convenience. It inherits both from
|
||||
* Cantera::SurfPhase and Cantera::InterfaceKinetics. It therefore
|
||||
* represents a surface phase, and also acts as the kinetics
|
||||
* manager to manage reactions occurring on the surface, possibly
|
||||
* involving species from other phases.
|
||||
*/
|
||||
class Interface :
|
||||
public SurfPhase,
|
||||
public InterfaceKinetics
|
||||
{
|
||||
public:
|
||||
//! An interface between multiple bulk phases.
|
||||
/*!
|
||||
* This class isdefined mostly for convenience. It inherits both from
|
||||
* Cantera::SurfPhase and Cantera::InterfaceKinetics. It therefore
|
||||
* represents a surface phase, and also acts as the kinetics
|
||||
* manager to manage reactions occurring on the surface, possibly
|
||||
* involving species from other phases.
|
||||
*/
|
||||
class Interface :
|
||||
public SurfPhase,
|
||||
public InterfaceKinetics
|
||||
{
|
||||
public:
|
||||
//! Constructor.
|
||||
/*!
|
||||
* Construct an Interface instance from a specification in an input file.
|
||||
@@ -44,22 +45,23 @@ namespace Cantera {
|
||||
* the ReactingSurface class. These classes will be migrated into Cantera
|
||||
* soon.
|
||||
*/
|
||||
Interface(std::string infile, std::string id,
|
||||
std::vector<Cantera::ThermoPhase*> otherPhases) :
|
||||
m_ok(false),
|
||||
m_r(0)
|
||||
{
|
||||
m_r = Cantera::get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
|
||||
Cantera::XML_Node* x = Cantera::get_XML_Node("#"+id, m_r);
|
||||
if (!x) {
|
||||
throw Cantera::CanteraError("Interface","error in get_XML_Node");
|
||||
}
|
||||
Cantera::importPhase(*x, this);
|
||||
otherPhases.push_back(this);
|
||||
Cantera::importKinetics(*x, otherPhases, this);
|
||||
m_ok = true;
|
||||
Interface(std::string infile, std::string id,
|
||||
std::vector<Cantera::ThermoPhase*> otherPhases) :
|
||||
m_ok(false),
|
||||
m_r(0) {
|
||||
m_r = Cantera::get_XML_File(infile);
|
||||
if (id == "-") {
|
||||
id = "";
|
||||
}
|
||||
|
||||
Cantera::XML_Node* x = Cantera::get_XML_Node("#"+id, m_r);
|
||||
if (!x) {
|
||||
throw Cantera::CanteraError("Interface","error in get_XML_Node");
|
||||
}
|
||||
Cantera::importPhase(*x, this);
|
||||
otherPhases.push_back(this);
|
||||
Cantera::importKinetics(*x, otherPhases, this);
|
||||
m_ok = true;
|
||||
}
|
||||
|
||||
//! Copy Constructor
|
||||
@@ -67,24 +69,25 @@ namespace Cantera {
|
||||
* @param ii Interface object to be copied.
|
||||
*/
|
||||
Interface(const Interface& ii) :
|
||||
Cantera::SurfPhase(ii),
|
||||
Cantera::InterfaceKinetics(ii),
|
||||
m_ok(ii.m_ok),
|
||||
m_r(ii.m_r)
|
||||
{
|
||||
Cantera::SurfPhase(ii),
|
||||
Cantera::InterfaceKinetics(ii),
|
||||
m_ok(ii.m_ok),
|
||||
m_r(ii.m_r) {
|
||||
}
|
||||
|
||||
//! Assignment operator
|
||||
/*!
|
||||
* @param right Interface object to be copied.
|
||||
*/
|
||||
Interface & operator=(const Interface &right) {
|
||||
if (this == &right) return *this;
|
||||
Cantera::SurfPhase::operator=(right);
|
||||
Cantera::InterfaceKinetics::operator=(right);
|
||||
m_ok = right.m_ok;
|
||||
m_r = right.m_r;
|
||||
return *this;
|
||||
Interface& operator=(const Interface& right) {
|
||||
if (this == &right) {
|
||||
return *this;
|
||||
}
|
||||
Cantera::SurfPhase::operator=(right);
|
||||
Cantera::InterfaceKinetics::operator=(right);
|
||||
m_ok = right.m_ok;
|
||||
m_r = right.m_r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Destructor. Does nothing.
|
||||
@@ -93,7 +96,7 @@ namespace Cantera {
|
||||
|
||||
//! Not operator
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
return !m_ok;
|
||||
}
|
||||
|
||||
//! return whether the object has been instantiated
|
||||
@@ -101,28 +104,29 @@ namespace Cantera {
|
||||
* @return Returns a bool.
|
||||
*/
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
//! Flag indicating that the object has been instantiated
|
||||
bool m_ok;
|
||||
|
||||
//! XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object
|
||||
//! description
|
||||
//! XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object
|
||||
//! description
|
||||
Cantera::XML_Node* m_r;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//! Import an instance of class Interface from a specification in an input file.
|
||||
/*!
|
||||
* This is the preferred method to create an Interface instance.
|
||||
*/
|
||||
Interface* importInterface(std::string infile, std::string id, std::vector<Cantera::ThermoPhase*> phases) {
|
||||
|
||||
//! Import an instance of class Interface from a specification in an input file.
|
||||
/*!
|
||||
* This is the preferred method to create an Interface instance.
|
||||
*/
|
||||
Interface* importInterface(std::string infile, std::string id, std::vector<Cantera::ThermoPhase*> phases)
|
||||
{
|
||||
return new Interface(infile, id, phases);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,31 +6,38 @@
|
||||
#include "kernel/MetalPhase.h"
|
||||
#include "kernel/importKinetics.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class Metal : public MetalPhase
|
||||
{
|
||||
public:
|
||||
Metal(std::string infile, std::string id="") : m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
|
||||
if (!m_ok) throw CanteraError("Metal",
|
||||
"buildSolutionFromXML returned false");
|
||||
class Metal : public MetalPhase
|
||||
{
|
||||
public:
|
||||
Metal(std::string infile, std::string id="") : m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") {
|
||||
id = "";
|
||||
}
|
||||
|
||||
virtual ~Metal() {}
|
||||
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
|
||||
if (!m_ok) throw CanteraError("Metal",
|
||||
"buildSolutionFromXML returned false");
|
||||
}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
bool ready() const { return m_ok; }
|
||||
virtual ~Metal() {}
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
}
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,51 +7,59 @@
|
||||
#include "kinetics.h"
|
||||
#include "kernel/stringUtils.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
class PureFluid : public PureFluidPhase
|
||||
{
|
||||
public:
|
||||
class PureFluid : public PureFluidPhase
|
||||
{
|
||||
public:
|
||||
|
||||
PureFluid() : m_ok(false), m_r(0) {}
|
||||
PureFluid() : m_ok(false), m_r(0) {}
|
||||
|
||||
PureFluid(std::string infile, std::string id="") : m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") id = "";
|
||||
PureFluid(std::string infile, std::string id="") : m_ok(false), m_r(0) {
|
||||
|
||||
m_r = get_XML_File(infile);
|
||||
if (id == "-") {
|
||||
id = "";
|
||||
}
|
||||
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
|
||||
if (!m_ok) throw CanteraError("PureFluid",
|
||||
"buildSolutionFromXML returned false");
|
||||
}
|
||||
"buildSolutionFromXML returned false");
|
||||
}
|
||||
|
||||
|
||||
PureFluid(XML_Node& root, std::string id) : m_ok(false), m_r(0) {
|
||||
m_ok = buildSolutionFromXML(root, id, "phase", this, 0);
|
||||
}
|
||||
|
||||
virtual ~PureFluid() {}
|
||||
PureFluid(XML_Node& root, std::string id) : m_ok(false), m_r(0) {
|
||||
m_ok = buildSolutionFromXML(root, id, "phase", this, 0);
|
||||
}
|
||||
|
||||
bool operator!() { return !m_ok;}
|
||||
bool ready() const { return m_ok; }
|
||||
friend std::ostream& operator<<(std::ostream& s, PureFluid& mix) {
|
||||
std::string r = mix.report(true);
|
||||
s << r;
|
||||
return s;
|
||||
}
|
||||
virtual ~PureFluid() {}
|
||||
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
bool operator!() {
|
||||
return !m_ok;
|
||||
}
|
||||
bool ready() const {
|
||||
return m_ok;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& s, PureFluid& mix) {
|
||||
std::string r = mix.report(true);
|
||||
s << r;
|
||||
return s;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
protected:
|
||||
bool m_ok;
|
||||
XML_Node* m_r;
|
||||
|
||||
class Water : public PureFluid {
|
||||
public:
|
||||
Water() : PureFluid(std::string("liquidvapor.cti"),std::string("water")) {}
|
||||
virtual ~Water() {}
|
||||
};
|
||||
private:
|
||||
};
|
||||
|
||||
class Water : public PureFluid
|
||||
{
|
||||
public:
|
||||
Water() : PureFluid(std::string("liquidvapor.cti"),std::string("water")) {}
|
||||
virtual ~Water() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
2
Cantera/cxx/include/equilibrium.h
Executable file → Normal file
2
Cantera/cxx/include/equilibrium.h
Executable file → Normal file
@@ -12,5 +12,5 @@
|
||||
#include "kernel/vcs_MultiPhaseEquil.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
2
Cantera/cxx/include/thermo.h
Executable file → Normal file
2
Cantera/cxx/include/thermo.h
Executable file → Normal file
@@ -16,7 +16,7 @@
|
||||
|
||||
#ifdef WITH_IDEAL_SOLUTIONS
|
||||
|
||||
#include "kernel/GibbsExcessVPSSTP.h"
|
||||
#include "kernel/GibbsExcessVPSSTP.h"
|
||||
#include "kernel/MargulesVPSSTP.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,7 @@ static IdealGasMix* _gas = 0;
|
||||
// provides access to the pointers for functions in other libraries
|
||||
IdealGasMix* _gasptr()
|
||||
{
|
||||
return _gas;
|
||||
return _gas;
|
||||
}
|
||||
|
||||
// comment these out to produce a smaller executable if not needed
|
||||
@@ -56,15 +56,15 @@ IdealGasMix* _gasptr()
|
||||
static Transport* _trans = 0;
|
||||
Transport* _transptr()
|
||||
{
|
||||
return _trans;
|
||||
return _trans;
|
||||
}
|
||||
#endif
|
||||
|
||||
// error handler
|
||||
void handleError()
|
||||
{
|
||||
showErrors(cout);
|
||||
exit(-1);
|
||||
showErrors(cout);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// extern "C" turns off C++ name-mangling, so that the procedure names
|
||||
@@ -72,313 +72,317 @@ void handleError()
|
||||
|
||||
extern "C" {
|
||||
|
||||
/// This is the Fortran main program. This works for g77; it may
|
||||
/// need to be modified for other Fortran compilers
|
||||
/// This is the Fortran main program. This works for g77; it may
|
||||
/// need to be modified for other Fortran compilers
|
||||
#ifdef NEED_ALT_MAIN
|
||||
extern int MAIN__();
|
||||
extern int MAIN__();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Read in a reaction mechanism file and create an IdealGasMix
|
||||
* object. The file may be in Cantera input format or in CTML. (If
|
||||
* you have a file in Chemkin-compatible format, use utility
|
||||
* program ck2cti first to convert it into Cantera format.)
|
||||
*/
|
||||
void newidealgasmix_(char* file, char* id, char* transport,
|
||||
ftnlen lenfile, ftnlen lenid, ftnlen lentr)
|
||||
{
|
||||
string trmodel = "";
|
||||
try {
|
||||
string fin = string(file, lenfile);
|
||||
string fth = string(id, lenid);
|
||||
trmodel = string(transport, lentr);
|
||||
if (_gas) delete _gas;
|
||||
_gas = new IdealGasMix(fin, fth);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
/**
|
||||
* Read in a reaction mechanism file and create an IdealGasMix
|
||||
* object. The file may be in Cantera input format or in CTML. (If
|
||||
* you have a file in Chemkin-compatible format, use utility
|
||||
* program ck2cti first to convert it into Cantera format.)
|
||||
*/
|
||||
void newidealgasmix_(char* file, char* id, char* transport,
|
||||
ftnlen lenfile, ftnlen lenid, ftnlen lentr)
|
||||
{
|
||||
string trmodel = "";
|
||||
try {
|
||||
string fin = string(file, lenfile);
|
||||
string fth = string(id, lenid);
|
||||
trmodel = string(transport, lentr);
|
||||
if (_gas) {
|
||||
delete _gas;
|
||||
}
|
||||
_gas = new IdealGasMix(fin, fth);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
#ifdef WITH_TRANSPORT
|
||||
try {
|
||||
if (_trans) delete _trans;
|
||||
_trans = newTransportMgr(trmodel,_gas,1);
|
||||
} catch (CanteraError) {
|
||||
_trans = newTransportMgr("",_gas,1);
|
||||
}
|
||||
try {
|
||||
if (_trans) {
|
||||
delete _trans;
|
||||
}
|
||||
_trans = newTransportMgr(trmodel,_gas,1);
|
||||
} catch (CanteraError) {
|
||||
_trans = newTransportMgr("",_gas,1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// integer function nElements()
|
||||
integer nelements_()
|
||||
{
|
||||
return _gas->nElements();
|
||||
}
|
||||
|
||||
/// integer function nSpecies()
|
||||
integer nspecies_()
|
||||
{
|
||||
return _gas->nSpecies();
|
||||
}
|
||||
|
||||
/// integer function nReactions()
|
||||
integer nreactions_()
|
||||
{
|
||||
return _gas->nReactions();
|
||||
}
|
||||
|
||||
void getspeciesname_(integer* k, char* name, ftnlen n)
|
||||
{
|
||||
int ik = *k - 1;
|
||||
fill(name, name + n, ' ');
|
||||
string spnm = _gas->speciesName(ik);
|
||||
int ns = spnm.size();
|
||||
unsigned int nmx = (ns > n ? n : ns);
|
||||
copy(spnm.begin(), spnm.begin()+nmx, name);
|
||||
}
|
||||
|
||||
//-------------- setting the state ----------------------------
|
||||
|
||||
/// subroutine setState_TPX(T, P, X)
|
||||
void setstate_tpx_(doublereal* T, doublereal* P, doublereal* X)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TPX(*T, *P, X);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
|
||||
/// subroutine setState_TPX_String(T, P, X)
|
||||
void setstate_tpx_string_(doublereal* T, doublereal* P,
|
||||
char* X, ftnlen lenx)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TPX(*T, *P, string(X, lenx));
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
/// integer function nElements()
|
||||
integer nelements_()
|
||||
{
|
||||
return _gas->nElements();
|
||||
}
|
||||
}
|
||||
|
||||
void setstate_try_(doublereal* T, doublereal* rho, doublereal* Y)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TRY(*T, *rho, Y);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
/// integer function nSpecies()
|
||||
integer nspecies_()
|
||||
{
|
||||
return _gas->nSpecies();
|
||||
}
|
||||
}
|
||||
|
||||
void setstate_tpy_(doublereal* T, doublereal* p, doublereal* Y)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TPY(*T, *p, Y);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
/// integer function nReactions()
|
||||
integer nreactions_()
|
||||
{
|
||||
return _gas->nReactions();
|
||||
}
|
||||
}
|
||||
|
||||
void setstate_sp_(doublereal* s, doublereal* p)
|
||||
{
|
||||
try {
|
||||
_gas->setState_SP(*s, *p);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
void getspeciesname_(integer* k, char* name, ftnlen n)
|
||||
{
|
||||
int ik = *k - 1;
|
||||
fill(name, name + n, ' ');
|
||||
string spnm = _gas->speciesName(ik);
|
||||
int ns = spnm.size();
|
||||
unsigned int nmx = (ns > n ? n : ns);
|
||||
copy(spnm.begin(), spnm.begin()+nmx, name);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------- thermodynamic properties ----------------------
|
||||
//-------------- setting the state ----------------------------
|
||||
|
||||
/// Temperature (K)
|
||||
doublereal temperature_()
|
||||
{
|
||||
return _gas->temperature();
|
||||
}
|
||||
/// subroutine setState_TPX(T, P, X)
|
||||
void setstate_tpx_(doublereal* T, doublereal* P, doublereal* X)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TPX(*T, *P, X);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
|
||||
/// Pressure (Pa)
|
||||
doublereal pressure_()
|
||||
{
|
||||
return _gas->pressure();
|
||||
}
|
||||
/// subroutine setState_TPX_String(T, P, X)
|
||||
void setstate_tpx_string_(doublereal* T, doublereal* P,
|
||||
char* X, ftnlen lenx)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TPX(*T, *P, string(X, lenx));
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
|
||||
/// Density (kg/m^3)
|
||||
doublereal density_()
|
||||
{
|
||||
return _gas->density();
|
||||
}
|
||||
void setstate_try_(doublereal* T, doublereal* rho, doublereal* Y)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TRY(*T, *rho, Y);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
|
||||
/// Mean molar mass (kg/kmol).
|
||||
doublereal meanmolarmass_()
|
||||
{
|
||||
return _gas->meanMolecularWeight();
|
||||
}
|
||||
void setstate_tpy_(doublereal* T, doublereal* p, doublereal* Y)
|
||||
{
|
||||
try {
|
||||
_gas->setState_TPY(*T, *p, Y);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
|
||||
/// Molar enthalpy (J/kmol)
|
||||
doublereal enthalpy_mole_()
|
||||
{
|
||||
return _gas->enthalpy_mole();
|
||||
}
|
||||
void setstate_sp_(doublereal* s, doublereal* p)
|
||||
{
|
||||
try {
|
||||
_gas->setState_SP(*s, *p);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
|
||||
/// Molar internal energy (J/kmol)
|
||||
doublereal intenergy_mole_()
|
||||
{
|
||||
return _gas->intEnergy_mole();
|
||||
}
|
||||
//-------------- thermodynamic properties ----------------------
|
||||
|
||||
/// Molar entropy (J/kmol-K)
|
||||
doublereal entropy_mole_()
|
||||
{
|
||||
return _gas->entropy_mole();
|
||||
}
|
||||
/// Temperature (K)
|
||||
doublereal temperature_()
|
||||
{
|
||||
return _gas->temperature();
|
||||
}
|
||||
|
||||
/// Molar heat capacity at constant P (J/kmol-K)
|
||||
doublereal cp_mole_()
|
||||
{
|
||||
return _gas->cp_mole();
|
||||
}
|
||||
/// Pressure (Pa)
|
||||
doublereal pressure_()
|
||||
{
|
||||
return _gas->pressure();
|
||||
}
|
||||
|
||||
/// Molar Gibbs function (J/kmol)
|
||||
doublereal gibbs_mole_()
|
||||
{
|
||||
return _gas->gibbs_mole();
|
||||
}
|
||||
/// Density (kg/m^3)
|
||||
doublereal density_()
|
||||
{
|
||||
return _gas->density();
|
||||
}
|
||||
|
||||
doublereal enthalpy_mass_()
|
||||
{
|
||||
return _gas->enthalpy_mass();
|
||||
}
|
||||
/// Mean molar mass (kg/kmol).
|
||||
doublereal meanmolarmass_()
|
||||
{
|
||||
return _gas->meanMolecularWeight();
|
||||
}
|
||||
|
||||
doublereal intenergy_mass_()
|
||||
{
|
||||
return _gas->intEnergy_mass();
|
||||
}
|
||||
/// Molar enthalpy (J/kmol)
|
||||
doublereal enthalpy_mole_()
|
||||
{
|
||||
return _gas->enthalpy_mole();
|
||||
}
|
||||
|
||||
doublereal entropy_mass_()
|
||||
{
|
||||
return _gas->entropy_mass();
|
||||
}
|
||||
/// Molar internal energy (J/kmol)
|
||||
doublereal intenergy_mole_()
|
||||
{
|
||||
return _gas->intEnergy_mole();
|
||||
}
|
||||
|
||||
doublereal cp_mass_()
|
||||
{
|
||||
return _gas->cp_mass();
|
||||
}
|
||||
/// Molar entropy (J/kmol-K)
|
||||
doublereal entropy_mole_()
|
||||
{
|
||||
return _gas->entropy_mole();
|
||||
}
|
||||
|
||||
doublereal cv_mass_()
|
||||
{
|
||||
return _gas->cv_mass();
|
||||
}
|
||||
/// Molar heat capacity at constant P (J/kmol-K)
|
||||
doublereal cp_mole_()
|
||||
{
|
||||
return _gas->cp_mole();
|
||||
}
|
||||
|
||||
doublereal gibbs_mass_()
|
||||
{
|
||||
return _gas->gibbs_mass();
|
||||
}
|
||||
/// Molar Gibbs function (J/kmol)
|
||||
doublereal gibbs_mole_()
|
||||
{
|
||||
return _gas->gibbs_mole();
|
||||
}
|
||||
|
||||
void gotmolefractions_(doublereal* x)
|
||||
{
|
||||
_gas->getMoleFractions(x);
|
||||
}
|
||||
doublereal enthalpy_mass_()
|
||||
{
|
||||
return _gas->enthalpy_mass();
|
||||
}
|
||||
|
||||
void gotmassfractions_(doublereal* y)
|
||||
{
|
||||
_gas->getMassFractions(y);
|
||||
}
|
||||
doublereal intenergy_mass_()
|
||||
{
|
||||
return _gas->intEnergy_mass();
|
||||
}
|
||||
|
||||
doublereal entropy_mass_()
|
||||
{
|
||||
return _gas->entropy_mass();
|
||||
}
|
||||
|
||||
doublereal cp_mass_()
|
||||
{
|
||||
return _gas->cp_mass();
|
||||
}
|
||||
|
||||
doublereal cv_mass_()
|
||||
{
|
||||
return _gas->cv_mass();
|
||||
}
|
||||
|
||||
doublereal gibbs_mass_()
|
||||
{
|
||||
return _gas->gibbs_mass();
|
||||
}
|
||||
|
||||
void gotmolefractions_(doublereal* x)
|
||||
{
|
||||
_gas->getMoleFractions(x);
|
||||
}
|
||||
|
||||
void gotmassfractions_(doublereal* y)
|
||||
{
|
||||
_gas->getMassFractions(y);
|
||||
}
|
||||
|
||||
#ifdef WITH_EQUIL
|
||||
void equilibrate_(char* opt, ftnlen lenopt)
|
||||
{
|
||||
try {
|
||||
if (lenopt != 2) {
|
||||
throw CanteraError("equilibrate",
|
||||
"two-character string required.");
|
||||
}
|
||||
string optstr = string(opt, 2);
|
||||
equilibrate(*_gas, optstr.c_str());
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
void equilibrate_(char* opt, ftnlen lenopt)
|
||||
{
|
||||
try {
|
||||
if (lenopt != 2) {
|
||||
throw CanteraError("equilibrate",
|
||||
"two-character string required.");
|
||||
}
|
||||
string optstr = string(opt, 2);
|
||||
equilibrate(*_gas, optstr.c_str());
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------- kinetics -------------------------
|
||||
//---------------- kinetics -------------------------
|
||||
|
||||
void getreactioneqn_(integer* i, char* eqn, ftnlen n)
|
||||
{
|
||||
int irxn = *i - 1;
|
||||
fill(eqn, eqn + n, ' ');
|
||||
string e = _gas->reactionString(irxn);
|
||||
int ns = e.size();
|
||||
unsigned int nmx = (ns > n ? n : ns);
|
||||
copy(e.begin(), e.begin()+nmx, eqn);
|
||||
}
|
||||
void getreactioneqn_(integer* i, char* eqn, ftnlen n)
|
||||
{
|
||||
int irxn = *i - 1;
|
||||
fill(eqn, eqn + n, ' ');
|
||||
string e = _gas->reactionString(irxn);
|
||||
int ns = e.size();
|
||||
unsigned int nmx = (ns > n ? n : ns);
|
||||
copy(e.begin(), e.begin()+nmx, eqn);
|
||||
}
|
||||
|
||||
void getnetproductionrates_(doublereal* wdot)
|
||||
{
|
||||
_gas->getNetProductionRates(wdot);
|
||||
}
|
||||
void getnetproductionrates_(doublereal* wdot)
|
||||
{
|
||||
_gas->getNetProductionRates(wdot);
|
||||
}
|
||||
|
||||
void getcreationrates_(doublereal* cdot)
|
||||
{
|
||||
_gas->getCreationRates(cdot);
|
||||
}
|
||||
void getcreationrates_(doublereal* cdot)
|
||||
{
|
||||
_gas->getCreationRates(cdot);
|
||||
}
|
||||
|
||||
void getdestructionrates_(doublereal* ddot)
|
||||
{
|
||||
_gas->getDestructionRates(ddot);
|
||||
}
|
||||
void getdestructionrates_(doublereal* ddot)
|
||||
{
|
||||
_gas->getDestructionRates(ddot);
|
||||
}
|
||||
|
||||
void getnetratesofprogress_(doublereal* q)
|
||||
{
|
||||
_gas->getNetRatesOfProgress(q);
|
||||
}
|
||||
void getnetratesofprogress_(doublereal* q)
|
||||
{
|
||||
_gas->getNetRatesOfProgress(q);
|
||||
}
|
||||
|
||||
void getfwdratesofprogress_(doublereal* q)
|
||||
{
|
||||
_gas->getFwdRatesOfProgress(q);
|
||||
}
|
||||
void getfwdratesofprogress_(doublereal* q)
|
||||
{
|
||||
_gas->getFwdRatesOfProgress(q);
|
||||
}
|
||||
|
||||
void getrevratesofprogress_(doublereal* q)
|
||||
{
|
||||
_gas->getRevRatesOfProgress(q);
|
||||
}
|
||||
void getrevratesofprogress_(doublereal* q)
|
||||
{
|
||||
_gas->getRevRatesOfProgress(q);
|
||||
}
|
||||
|
||||
//-------------------- transport properties --------------------
|
||||
//-------------------- transport properties --------------------
|
||||
|
||||
#ifdef WITH_TRANSPORT
|
||||
double viscosity_()
|
||||
{
|
||||
try {
|
||||
return _trans->viscosity();
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
return 0.0;
|
||||
double viscosity_()
|
||||
{
|
||||
try {
|
||||
return _trans->viscosity();
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double thermalconductivity_()
|
||||
{
|
||||
try {
|
||||
return _trans->thermalConductivity();
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
return 0.0;
|
||||
double thermalconductivity_()
|
||||
{
|
||||
try {
|
||||
return _trans->thermalConductivity();
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getmixdiffcoeffs_(double* diff)
|
||||
{
|
||||
try {
|
||||
_trans->getMixDiffCoeffs(diff);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
void getmixdiffcoeffs_(double* diff)
|
||||
{
|
||||
try {
|
||||
_trans->getMixDiffCoeffs(diff);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getthermaldiffcoeffs_(double* dt)
|
||||
{
|
||||
try {
|
||||
_trans->getThermalDiffCoeffs(dt);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
void getthermaldiffcoeffs_(double* dt)
|
||||
{
|
||||
try {
|
||||
_trans->getThermalDiffCoeffs(dt);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -395,14 +399,14 @@ extern "C" {
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
return MAIN__();
|
||||
} catch (CanteraError) {
|
||||
showErrors(cerr);
|
||||
exit(-1);
|
||||
} catch (...) {
|
||||
cout << "An exception was trapped. Program terminating." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
try {
|
||||
return MAIN__();
|
||||
} catch (CanteraError) {
|
||||
showErrors(cerr);
|
||||
exit(-1);
|
||||
} catch (...) {
|
||||
cout << "An exception was trapped. Program terminating." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,247 +21,285 @@ using Cantera::CanteraError;
|
||||
// Assign storage for the templated classes static member
|
||||
template<> Cabinet<XML_Node> * Cabinet<XML_Node>::__storage = 0;
|
||||
|
||||
inline XML_Node* _xml(const integer* i) {
|
||||
inline XML_Node* _xml(const integer* i)
|
||||
{
|
||||
return Cabinet<XML_Node>::cabinet(false)->item(*i);
|
||||
}
|
||||
|
||||
static void handleError() {
|
||||
static void handleError()
|
||||
{
|
||||
Cantera::error(Cantera::lastErrorMessage());
|
||||
}
|
||||
|
||||
std::string f2string(const char* s, ftnlen n);
|
||||
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
|
||||
integer DLL_EXPORT fxml_new_(const char* name, ftnlen namelen) {
|
||||
integer DLL_EXPORT fxml_new_(const char* name, ftnlen namelen)
|
||||
{
|
||||
XML_Node* x;
|
||||
if (!name)
|
||||
if (!name) {
|
||||
x = new XML_Node;
|
||||
else
|
||||
} else {
|
||||
x = new XML_Node(f2string(name, namelen), 0);
|
||||
}
|
||||
return Cabinet<XML_Node>::cabinet(true)->add(x);
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_get_xml_file_(const char* file, ftnlen filelen) {
|
||||
status_t DLL_EXPORT fxml_get_xml_file_(const char* file, ftnlen filelen)
|
||||
{
|
||||
try {
|
||||
XML_Node* x = Cantera::get_XML_File(f2string(file, filelen));
|
||||
int ix = Cabinet<XML_Node>::cabinet(false)->add(x);
|
||||
return ix;
|
||||
}
|
||||
catch (CanteraError) {
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_clear_() {
|
||||
status_t DLL_EXPORT fxml_clear_()
|
||||
{
|
||||
try {
|
||||
Cabinet<XML_Node>::cabinet(false)->clear();
|
||||
Cantera::close_XML_File("all");
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
return -1;
|
||||
}
|
||||
catch (CanteraError) { handleError(); return -1;}
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_del_(const integer* i) {
|
||||
status_t DLL_EXPORT fxml_del_(const integer* i)
|
||||
{
|
||||
Cabinet<XML_Node>::cabinet(false)->del(*i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_removechild_(const integer* i, const integer* j) {
|
||||
status_t DLL_EXPORT fxml_removechild_(const integer* i, const integer* j)
|
||||
{
|
||||
_xml(i)->removeChild(_xml(j));
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_copy_(const integer* i) {
|
||||
status_t DLL_EXPORT fxml_copy_(const integer* i)
|
||||
{
|
||||
return Cabinet<XML_Node>::cabinet(false)->newCopy(*i);
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_assign_(const integer* i, const integer* j) {
|
||||
status_t DLL_EXPORT fxml_assign_(const integer* i, const integer* j)
|
||||
{
|
||||
return Cabinet<XML_Node>::cabinet(false)->assign(*i,*j);
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_attrib_(const integer* i, const char* key,
|
||||
char* value, ftnlen keylen, ftnlen valuelen) {
|
||||
status_t DLL_EXPORT fxml_attrib_(const integer* i, const char* key,
|
||||
char* value, ftnlen keylen, ftnlen valuelen)
|
||||
{
|
||||
try {
|
||||
std::string ky = f2string(key, keylen);
|
||||
XML_Node& node = *_xml(i);
|
||||
if (node.hasAttrib(ky)) {
|
||||
std::string v = node[ky];
|
||||
strncpy(value, v.c_str(), valuelen);
|
||||
}
|
||||
else
|
||||
} else
|
||||
throw CanteraError("fxml_attrib","node "
|
||||
" has no attribute '"+ky+"'");
|
||||
" has no attribute '"+ky+"'");
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_addattrib_(const integer* i,
|
||||
const char* key, const char* value, ftnlen keylen, ftnlen valuelen) {
|
||||
status_t DLL_EXPORT fxml_addattrib_(const integer* i,
|
||||
const char* key, const char* value, ftnlen keylen, ftnlen valuelen)
|
||||
{
|
||||
try {
|
||||
std::string ky = f2string(key, keylen);
|
||||
std::string val = f2string(value, valuelen);
|
||||
XML_Node& node = *_xml(i);
|
||||
node.addAttribute(ky, val);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_addcomment_(const integer* i, const char* comment,
|
||||
ftnlen commentlen) {
|
||||
status_t DLL_EXPORT fxml_addcomment_(const integer* i, const char* comment,
|
||||
ftnlen commentlen)
|
||||
{
|
||||
try {
|
||||
std::string c = f2string(comment, commentlen);
|
||||
XML_Node& node = *_xml(i);
|
||||
node.addComment(c);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_tag_(const integer* i, char* tag, ftnlen taglen) {
|
||||
status_t DLL_EXPORT fxml_tag_(const integer* i, char* tag, ftnlen taglen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
const std::string v = node.name();
|
||||
strncpy(tag, v.c_str(), taglen);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_value_(const integer* i, char* value, ftnlen valuelen) {
|
||||
status_t DLL_EXPORT fxml_value_(const integer* i, char* value, ftnlen valuelen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
const std::string v = node.value();
|
||||
strncpy(value, v.c_str(), valuelen);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_child_(const integer* i, const char* loc, ftnlen loclen) {
|
||||
status_t DLL_EXPORT fxml_child_(const integer* i, const char* loc, ftnlen loclen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.child(f2string(loc, loclen));
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_child_bynumber_(const integer* i, const integer* m) {
|
||||
status_t DLL_EXPORT fxml_child_bynumber_(const integer* i, const integer* m)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.child(*m);
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_findid_(const integer* i, const char* id, ftnlen idlen) {
|
||||
status_t DLL_EXPORT fxml_findid_(const integer* i, const char* id, ftnlen idlen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node* c = node.findID(f2string(id, idlen));
|
||||
if (c) {
|
||||
return Cabinet<XML_Node>::cabinet()->add(c);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
throw CanteraError("fxml_find_id","id not found: "+f2string(id, idlen));
|
||||
}
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_findbyname_(const integer* i, const char* nm, ftnlen nmlen) {
|
||||
status_t DLL_EXPORT fxml_findbyname_(const integer* i, const char* nm, ftnlen nmlen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node* c = node.findByName(f2string(nm, nmlen));
|
||||
if (c) {
|
||||
return Cabinet<XML_Node>::cabinet()->add(c);
|
||||
}
|
||||
else
|
||||
} else
|
||||
throw CanteraError("fxml_findByName","name "+f2string(nm, nmlen)
|
||||
+" not found");
|
||||
+" not found");
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
integer DLL_EXPORT fxml_nchildren_(const integer* i) {
|
||||
integer DLL_EXPORT fxml_nchildren_(const integer* i)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
return node.nChildren();
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_addchild_(const integer* i, const char* name,
|
||||
const char* value, ftnlen namelen, ftnlen valuelen) {
|
||||
status_t DLL_EXPORT fxml_addchild_(const integer* i, const char* name,
|
||||
const char* value, ftnlen namelen, ftnlen valuelen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.addChild(f2string(name, namelen),
|
||||
f2string(value,valuelen));
|
||||
f2string(value,valuelen));
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_addchildnode_(const integer* i, const integer* j) {
|
||||
status_t DLL_EXPORT fxml_addchildnode_(const integer* i, const integer* j)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& chld = *_xml(j);
|
||||
XML_Node& c = node.addChild(chld);
|
||||
return Cabinet<XML_Node>::cabinet()->add(&c);
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT fxml_write_(const integer* i, const char* file, ftnlen filelen) {
|
||||
status_t DLL_EXPORT fxml_write_(const integer* i, const char* file, ftnlen filelen)
|
||||
{
|
||||
try {
|
||||
std::string ff(file, filelen);
|
||||
ofstream f(ff.c_str());
|
||||
if (f) {
|
||||
XML_Node& node = *_xml(i);
|
||||
node.write(f);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw CanteraError("fxml_write",
|
||||
"file "+f2string(file, filelen)+" not found.");
|
||||
"file "+f2string(file, filelen)+" not found.");
|
||||
}
|
||||
return 0;
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t DLL_EXPORT ctml_getfloatarray_(const integer* i, const integer* n,
|
||||
doublereal* data, const integer* iconvert) {
|
||||
status_t DLL_EXPORT ctml_getfloatarray_(const integer* i, const integer* n,
|
||||
doublereal* data, const integer* iconvert)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
Cantera::vector_fp v;
|
||||
bool conv = false;
|
||||
if (*iconvert > 0) conv = true;
|
||||
if (*iconvert > 0) {
|
||||
conv = true;
|
||||
}
|
||||
getFloatArray(node, v, conv);
|
||||
int nv = v.size();
|
||||
|
||||
// array not big enough
|
||||
if (*n < nv) {
|
||||
throw CanteraError("ctml_getfloatarray",
|
||||
"array must be dimensioned at least "+Cantera::int2str(nv));
|
||||
"array must be dimensioned at least "+Cantera::int2str(nv));
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < nv; i++) {
|
||||
data[i] = v[i];
|
||||
}
|
||||
//n = nv;
|
||||
} catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
typedef integer status_t;
|
||||
|
||||
namespace Cantera {}
|
||||
namespace std{}
|
||||
namespace std {}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void reportError() {
|
||||
void reportError()
|
||||
{
|
||||
write_HTML_log("error_log.html");
|
||||
int buflen = 0;
|
||||
char* output_buf = 0;
|
||||
@@ -21,12 +22,12 @@ void reportError() {
|
||||
mexErrMsgTxt(output_buf);
|
||||
}
|
||||
|
||||
void ctfunctions( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
void ctfunctions(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int job = getInt(prhs[1]);
|
||||
int iok, dbg, validate;
|
||||
char *infile, *dbfile, *trfile, *idtag;
|
||||
char* infile, *dbfile, *trfile, *idtag;
|
||||
int buflen;
|
||||
char* output_buf;
|
||||
|
||||
@@ -37,7 +38,7 @@ void ctfunctions( int nlhs, mxArray *plhs[],
|
||||
if (nrhs < 8) {
|
||||
mexErrMsgTxt("Wrong number of inputs.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
infile = getString(prhs[2]);
|
||||
dbfile = getString(prhs[3]);
|
||||
trfile = getString(prhs[4]);
|
||||
@@ -45,7 +46,7 @@ void ctfunctions( int nlhs, mxArray *plhs[],
|
||||
dbg = getInt(prhs[6]);
|
||||
validate = getInt(prhs[7]);
|
||||
iok = ck_to_cti(infile, dbfile, trfile, idtag, dbg, validate);
|
||||
break;
|
||||
break;
|
||||
|
||||
// get Cantera error
|
||||
case 2:
|
||||
@@ -74,7 +75,9 @@ void ctfunctions( int nlhs, mxArray *plhs[],
|
||||
mexErrMsgTxt("ctfunctions: unknown job");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
}
|
||||
|
||||
18
Cantera/matlab/src/ctmatutils.h
Executable file → Normal file
18
Cantera/matlab/src/ctmatutils.h
Executable file → Normal file
@@ -19,33 +19,35 @@ void reportError();
|
||||
void checkNArgs(const int n, const int nrhs);
|
||||
|
||||
template<class A>
|
||||
inline int getInt(A* mxhndl) {
|
||||
inline int getInt(A* mxhndl)
|
||||
{
|
||||
return int(mxGetScalar(mxhndl));
|
||||
}
|
||||
|
||||
template<class A>
|
||||
inline double getDouble(A* mxhndl) {
|
||||
inline double getDouble(A* mxhndl)
|
||||
{
|
||||
return double(mxGetScalar(mxhndl));
|
||||
}
|
||||
|
||||
inline char* getString(const mxArray* p) {
|
||||
inline char* getString(const mxArray* p)
|
||||
{
|
||||
char* input_buf = 0;
|
||||
int status;
|
||||
size_t m = mxGetM(p);
|
||||
size_t n = mxGetN(p);
|
||||
mwSize buflen = (mwSize) (m*n + 1);
|
||||
mwSize buflen = (mwSize)(m*n + 1);
|
||||
std::string msg;
|
||||
|
||||
if (m == 1) {
|
||||
input_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
status = mxGetString(p, input_buf, buflen);
|
||||
if(status != 0) {
|
||||
msg = std::string(input_buf)
|
||||
if (status != 0) {
|
||||
msg = std::string(input_buf)
|
||||
+ "\nNot enough space. String is truncated.";
|
||||
mexWarnMsgTxt(msg.c_str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mexErrMsgTxt("string must be a row vector");
|
||||
}
|
||||
return input_buf;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* The interface between the MATLAB environment and the C++ Cantera
|
||||
* kernel is through a single MEX file. This is top-level driver for
|
||||
* the MEX file.
|
||||
*
|
||||
*
|
||||
* This file handles the methods of all Cantera MATLAB classes. The
|
||||
* class is indicated by the first parameter in the call from MATLAB.
|
||||
*/
|
||||
@@ -30,55 +30,56 @@ const int SURF_CLASS = 100;
|
||||
const int FUNC_CLASS = 110;
|
||||
const int MIXTURE_CLASS = 120;
|
||||
|
||||
void ctfunctions( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void ctfunctions(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void xmlmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void xmlmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void thermomethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void thermomethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void phasemethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void phasemethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void mixturemethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void mixturemethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void surfmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void surfmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void kineticsmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void kineticsmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void transportmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void transportmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void reactormethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void reactormethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void reactornetmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void reactornetmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void wallmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void wallmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void flowdevicemethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void flowdevicemethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void onedimmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void onedimmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
void funcmethods( int nlhs, mxArray *plhs[], int nrhs,
|
||||
const mxArray *prhs[] );
|
||||
void funcmethods(int nlhs, mxArray* plhs[], int nrhs,
|
||||
const mxArray* prhs[]);
|
||||
|
||||
static Cantera::ML_Logger* _logger = 0;
|
||||
|
||||
void initLogger() {
|
||||
void initLogger()
|
||||
{
|
||||
if (!_logger) {
|
||||
_logger = new Cantera::ML_Logger;
|
||||
// Call the DLL program to set the logger
|
||||
void * vl = (void *) _logger;
|
||||
void* vl = (void*) _logger;
|
||||
int retn = setLogWriter(vl);
|
||||
}
|
||||
}
|
||||
@@ -86,14 +87,14 @@ void initLogger() {
|
||||
|
||||
extern "C" {
|
||||
|
||||
void mexFunction( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
void mexFunction(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
// mexPrintf("Number of lhs = %d\n", nlhs);
|
||||
// mexPrintf("number of rhs = %d\n", nrhs);
|
||||
// create a log writer for error messages if this is the
|
||||
// first MATLAB function call
|
||||
initLogger();
|
||||
initLogger();
|
||||
|
||||
// flag specifying the class
|
||||
int iclass = getInt(prhs[0]);
|
||||
@@ -102,33 +103,47 @@ extern "C" {
|
||||
// value of the first parameter
|
||||
switch (iclass) {
|
||||
case NO_CLASS:
|
||||
ctfunctions(nlhs, plhs, nrhs, prhs); break;
|
||||
ctfunctions(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case XML_CLASS:
|
||||
xmlmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
xmlmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case THERMO_CLASS:
|
||||
thermomethods(nlhs, plhs, nrhs, prhs); break;
|
||||
thermomethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case PHASE_CLASS:
|
||||
phasemethods(nlhs, plhs, nrhs, prhs); break;
|
||||
phasemethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case MIXTURE_CLASS:
|
||||
mixturemethods(nlhs, plhs, nrhs, prhs); break;
|
||||
mixturemethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case KINETICS_CLASS:
|
||||
kineticsmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
kineticsmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case TRANSPORT_CLASS:
|
||||
transportmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
transportmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case REACTOR_CLASS:
|
||||
reactormethods(nlhs, plhs, nrhs, prhs); break;
|
||||
reactormethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case REACTORNET_CLASS:
|
||||
reactornetmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
reactornetmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case WALL_CLASS:
|
||||
wallmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
wallmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case FLOWDEVICE_CLASS:
|
||||
flowdevicemethods(nlhs, plhs, nrhs, prhs); break;
|
||||
flowdevicemethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case ONEDIM_CLASS:
|
||||
onedimmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
onedimmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case SURF_CLASS:
|
||||
surfmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
surfmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
case FUNC_CLASS:
|
||||
funcmethods(nlhs, plhs, nrhs, prhs); break;
|
||||
funcmethods(nlhs, plhs, nrhs, prhs);
|
||||
break;
|
||||
default:
|
||||
mexPrintf("iclass = %d",iclass);
|
||||
//mexErrMsgTxt("unknown class");
|
||||
|
||||
@@ -4,79 +4,87 @@
|
||||
|
||||
//const double Undef = -999.123;
|
||||
|
||||
void flowdevicemethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
int m, iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
void flowdevicemethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int m, iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3) v = getDouble(prhs[3]);
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = flowdev_new(i);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = flowdev_del(i);
|
||||
break;
|
||||
case 2:
|
||||
m = getInt(prhs[4]);
|
||||
iok = flowdev_install(i, int(v), m);
|
||||
break;
|
||||
case 3:
|
||||
iok = flowdev_setMassFlowRate(i, v);
|
||||
break;
|
||||
case 4:
|
||||
iok = flowdev_setParameters(i, 1, &v);
|
||||
break;
|
||||
case 5:
|
||||
iok = flowdev_setFunction(i, int(v));
|
||||
break;
|
||||
case 6:
|
||||
iok = flowdev_ready(i);
|
||||
break;
|
||||
case 7:
|
||||
iok = flowdev_setMaster(i, int(v));
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = flowdev_massFlowRate(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) reportError();
|
||||
return;
|
||||
}
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3) {
|
||||
v = getDouble(prhs[3]);
|
||||
}
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = flowdev_new(i);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = flowdev_del(i);
|
||||
break;
|
||||
case 2:
|
||||
m = getInt(prhs[4]);
|
||||
iok = flowdev_install(i, int(v), m);
|
||||
break;
|
||||
case 3:
|
||||
iok = flowdev_setMassFlowRate(i, v);
|
||||
break;
|
||||
case 4:
|
||||
iok = flowdev_setParameters(i, 1, &v);
|
||||
break;
|
||||
case 5:
|
||||
iok = flowdev_setFunction(i, int(v));
|
||||
break;
|
||||
case 6:
|
||||
iok = flowdev_ready(i);
|
||||
break;
|
||||
case 7:
|
||||
iok = flowdev_setMaster(i, int(v));
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = flowdev_massFlowRate(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <cantera/clib/ctfunc.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
void funcmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
void funcmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int job = getInt(prhs[1]);
|
||||
int nn;
|
||||
@@ -19,19 +19,19 @@ void funcmethods( int nlhs, mxArray *plhs[],
|
||||
size_t nsize = mxGetN(prhs[4]);
|
||||
size_t lenp = msize*nsize;
|
||||
nn = func_new(type, n, lenp, ptr);
|
||||
}
|
||||
else if (type < 45) {
|
||||
} else if (type < 45) {
|
||||
int m = getInt(prhs[4]);
|
||||
nn = func_new(type, n, m, ptr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ptr = mxGetPr(prhs[4]);
|
||||
nn = func_new(type, n, 0, ptr);
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(nn);
|
||||
if (nn < 0) reportError();
|
||||
if (nn < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,19 +42,21 @@ void funcmethods( int nlhs, mxArray *plhs[],
|
||||
int i = getInt(prhs[2]);
|
||||
if (job == 1) {
|
||||
nn = func_del(i);
|
||||
if (nn < 0) reportError();
|
||||
if (nn < 0) {
|
||||
reportError();
|
||||
}
|
||||
v = double(nn);
|
||||
}
|
||||
else if (job == 2) {
|
||||
} else if (job == 2) {
|
||||
t = getDouble(prhs[3]);
|
||||
v = func_value(i, t);
|
||||
if (v == Undef) reportError();
|
||||
}
|
||||
else {
|
||||
if (v == Undef) {
|
||||
reportError();
|
||||
}
|
||||
} else {
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = v;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
#include "ctmatutils.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
void checkNArgs(const int n, const int nrhs) {
|
||||
void checkNArgs(const int n, const int nrhs)
|
||||
{
|
||||
if (n != nrhs) {
|
||||
mexErrMsgTxt("Wrong number of arguments.");
|
||||
}
|
||||
}
|
||||
|
||||
void kineticsmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] ) {
|
||||
void kineticsmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
double vv;
|
||||
int job = getInt(prhs[2]);
|
||||
int job = getInt(prhs[2]);
|
||||
int kin, irxn;
|
||||
|
||||
// construct a new instance
|
||||
@@ -24,7 +26,7 @@ void kineticsmethods( int nlhs, mxArray *plhs[],
|
||||
int in4 = getInt(prhs[7]);
|
||||
vv = (double) newKineticsFromXML(root, iph, in1, in2, in3, in4);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
@@ -32,8 +34,9 @@ void kineticsmethods( int nlhs, mxArray *plhs[],
|
||||
// methods
|
||||
else if (job > 0) {
|
||||
int isp = 1;
|
||||
if (job < 5 || job > 6) checkNArgs(4,nrhs);
|
||||
else {
|
||||
if (job < 5 || job > 6) {
|
||||
checkNArgs(4,nrhs);
|
||||
} else {
|
||||
checkNArgs(5,nrhs);
|
||||
isp = getInt(prhs[4]);
|
||||
}
|
||||
@@ -44,72 +47,83 @@ void kineticsmethods( int nlhs, mxArray *plhs[],
|
||||
if (job < 10) {
|
||||
|
||||
switch (job) {
|
||||
|
||||
|
||||
case 1:
|
||||
vv = (double) kin_nReactions(kin); break;
|
||||
vv = (double) kin_nReactions(kin);
|
||||
break;
|
||||
case 2:
|
||||
vv = kin_multiplier(kin, irxn-1); break;
|
||||
vv = kin_multiplier(kin, irxn-1);
|
||||
break;
|
||||
case 3:
|
||||
vv = (double) kin_nSpecies(kin); break;
|
||||
vv = (double) kin_nSpecies(kin);
|
||||
break;
|
||||
case 4:
|
||||
vv = kin_isReversible(kin,irxn-1); break;
|
||||
vv = kin_isReversible(kin,irxn-1);
|
||||
break;
|
||||
case 5:
|
||||
vv = kin_reactantStoichCoeff(kin, isp - 1, irxn-1);
|
||||
break;
|
||||
case 6:
|
||||
vv = kin_productStoichCoeff(kin, isp - 1, irxn-1);
|
||||
vv = kin_productStoichCoeff(kin, isp - 1, irxn-1);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
else if (job < 20) {
|
||||
} else if (job < 20) {
|
||||
|
||||
// get reaction array attributes
|
||||
mwSize nr = (mwSize) kin_nReactions(kin);
|
||||
plhs[0] = mxCreateNumericMatrix(nr,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
int ok = -10;
|
||||
switch (job) {
|
||||
case 11:
|
||||
ok = kin_getFwdRatesOfProgress(kin,nr,h); break;
|
||||
ok = kin_getFwdRatesOfProgress(kin,nr,h);
|
||||
break;
|
||||
case 12:
|
||||
ok = kin_getRevRatesOfProgress(kin,nr,h); break;
|
||||
ok = kin_getRevRatesOfProgress(kin,nr,h);
|
||||
break;
|
||||
case 13:
|
||||
ok = kin_getNetRatesOfProgress(kin,nr,h); break;
|
||||
ok = kin_getNetRatesOfProgress(kin,nr,h);
|
||||
break;
|
||||
case 14:
|
||||
ok = kin_getEquilibriumConstants(kin,nr,h); break;
|
||||
ok = kin_getEquilibriumConstants(kin,nr,h);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (ok < 0)
|
||||
if (ok < 0) {
|
||||
mexErrMsgTxt("error computing rates of progress");
|
||||
}
|
||||
else if (job < 30) {
|
||||
}
|
||||
} else if (job < 30) {
|
||||
mwSize nsp = (mwSize) kin_nSpecies(kin);
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
int ok = -10;
|
||||
switch (job) {
|
||||
case 21:
|
||||
ok = kin_getCreationRates(kin,nsp,h); break;
|
||||
ok = kin_getCreationRates(kin,nsp,h);
|
||||
break;
|
||||
case 22:
|
||||
ok = kin_getDestructionRates(kin,nsp,h); break;
|
||||
ok = kin_getDestructionRates(kin,nsp,h);
|
||||
break;
|
||||
case 23:
|
||||
ok = kin_getNetProductionRates(kin,nsp,h); break;
|
||||
ok = kin_getNetProductionRates(kin,nsp,h);
|
||||
break;
|
||||
case 24:
|
||||
ok = kin_getSourceTerms(kin, nsp, h); break;
|
||||
ok = kin_getSourceTerms(kin, nsp, h);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (ok < 0)
|
||||
if (ok < 0) {
|
||||
mexErrMsgTxt("error computing production rates");
|
||||
}
|
||||
else if (job < 40) {
|
||||
}
|
||||
} else if (job < 40) {
|
||||
char* buf;
|
||||
int iok = -1, buflen = 80;
|
||||
switch (job) {
|
||||
@@ -123,8 +137,9 @@ void kineticsmethods( int nlhs, mxArray *plhs[],
|
||||
if (iok >= 0) {
|
||||
plhs[0] = mxCreateString(buf);
|
||||
return;
|
||||
} else {
|
||||
reportError();
|
||||
}
|
||||
else reportError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,16 +156,21 @@ void kineticsmethods( int nlhs, mxArray *plhs[],
|
||||
double v = getDouble(prhs[4]);
|
||||
switch (job) {
|
||||
case 1:
|
||||
iok = kin_setMultiplier(kin,irxn-1,v); break;
|
||||
iok = kin_setMultiplier(kin,irxn-1,v);
|
||||
break;
|
||||
case 3:
|
||||
iok = delKinetics(kin); break;
|
||||
iok = delKinetics(kin);
|
||||
break;
|
||||
case 5:
|
||||
iok = kin_advanceCoverages(kin,v); break;
|
||||
iok = kin_advanceCoverages(kin,v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job");
|
||||
}
|
||||
}
|
||||
|
||||
if (iok < 0) reportError();
|
||||
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,166 +8,176 @@
|
||||
#include "ctmatutils.h"
|
||||
using namespace std;
|
||||
|
||||
void mixturemethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
int m, iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
void mixturemethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int m, iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3 && job != 8 && job != 22 && job != 23)
|
||||
v = getDouble(prhs[3]);
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3 && job != 8 && job != 22 && job != 23) {
|
||||
v = getDouble(prhs[3]);
|
||||
}
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = mix_new();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) reportError();
|
||||
return;
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = mix_new();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
double moles, err;
|
||||
char *nmstr, *XY, *nm;
|
||||
int maxiter, maxsteps, loglevel;
|
||||
if (job < 15) {
|
||||
switch (job) {
|
||||
// options that do not return a value
|
||||
double moles, err;
|
||||
char* nmstr, *XY, *nm;
|
||||
int maxiter, maxsteps, loglevel;
|
||||
if (job < 15) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = mix_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = mix_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = mix_assign(i, int(v));
|
||||
break;
|
||||
case 4:
|
||||
checkNArgs(5, nrhs);
|
||||
moles = getDouble(prhs[4]);
|
||||
iok = mix_addPhase(i, int(v), moles);
|
||||
break;
|
||||
case 5:
|
||||
iok = mix_setTemperature(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = mix_setPressure(i, v);
|
||||
break;
|
||||
case 7:
|
||||
checkNArgs(5, nrhs);
|
||||
moles = getDouble(prhs[4]);
|
||||
iok = mix_setPhaseMoles(i, int(v)-1, moles);
|
||||
break;
|
||||
case 8:
|
||||
checkNArgs(4, nrhs);
|
||||
nmstr = getString(prhs[3]);
|
||||
iok = mix_setMolesByName(i, nmstr);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
return;
|
||||
case 1:
|
||||
iok = mix_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = mix_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = mix_assign(i, int(v));
|
||||
break;
|
||||
case 4:
|
||||
checkNArgs(5, nrhs);
|
||||
moles = getDouble(prhs[4]);
|
||||
iok = mix_addPhase(i, int(v), moles);
|
||||
break;
|
||||
case 5:
|
||||
iok = mix_setTemperature(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = mix_setPressure(i, v);
|
||||
break;
|
||||
case 7:
|
||||
checkNArgs(5, nrhs);
|
||||
moles = getDouble(prhs[4]);
|
||||
iok = mix_setPhaseMoles(i, int(v)-1, moles);
|
||||
break;
|
||||
case 8:
|
||||
checkNArgs(4, nrhs);
|
||||
nmstr = getString(prhs[3]);
|
||||
iok = mix_setMolesByName(i, nmstr);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 19:
|
||||
r = (double) mix_nPhases(i);
|
||||
break;
|
||||
case 21:
|
||||
r = (double) mix_nElements(i);
|
||||
break;
|
||||
case 22:
|
||||
checkNArgs(4, nrhs);
|
||||
nm = getString(prhs[3]);
|
||||
r = (double) mix_elementIndex(i, nm)+1;
|
||||
break;
|
||||
case 23:
|
||||
checkNArgs(5, nrhs);
|
||||
m = getInt(prhs[3]);
|
||||
n = getInt(prhs[4]);
|
||||
r = (double) mix_speciesIndex(i, m-1, n-1)+1;
|
||||
break;
|
||||
case 24:
|
||||
r = (double) mix_nSpecies(i);
|
||||
break;
|
||||
case 25:
|
||||
r = mix_temperature(i);
|
||||
break;
|
||||
case 26:
|
||||
r = mix_pressure(i);
|
||||
break;
|
||||
case 27:
|
||||
m = getInt(prhs[4]);
|
||||
r = mix_nAtoms(i,int(v), m);
|
||||
break;
|
||||
case 28:
|
||||
r = mix_phaseMoles(i, int(v)-1);
|
||||
break;
|
||||
case 29:
|
||||
r = mix_speciesMoles(i, int(v)-1);
|
||||
break;
|
||||
case 30:
|
||||
r = mix_elementMoles(i, int(v)-1);
|
||||
break;
|
||||
case 31:
|
||||
checkNArgs(8, nrhs);
|
||||
XY = getString(prhs[3]);
|
||||
err = getDouble(prhs[4]);
|
||||
maxsteps = getInt(prhs[5]);
|
||||
maxiter = getInt(prhs[6]);
|
||||
loglevel = getInt(prhs[7]);
|
||||
r = mix_equilibrate(i, XY, err, maxsteps,
|
||||
maxiter, loglevel);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) reportError();
|
||||
return;
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// species properties
|
||||
else if (job < 60) {
|
||||
|
||||
int iok = 0;
|
||||
mwSize nsp = (mwSize) mix_nSpecies(i);
|
||||
double* x = new double[nsp];
|
||||
switch (job) {
|
||||
case 41:
|
||||
iok = mix_getChemPotentials(i,nsp,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 19:
|
||||
r = (double) mix_nPhases(i);
|
||||
break;
|
||||
case 21:
|
||||
r = (double) mix_nElements(i);
|
||||
break;
|
||||
case 22:
|
||||
checkNArgs(4, nrhs);
|
||||
nm = getString(prhs[3]);
|
||||
r = (double) mix_elementIndex(i, nm)+1;
|
||||
break;
|
||||
case 23:
|
||||
checkNArgs(5, nrhs);
|
||||
m = getInt(prhs[3]);
|
||||
n = getInt(prhs[4]);
|
||||
r = (double) mix_speciesIndex(i, m-1, n-1)+1;
|
||||
break;
|
||||
case 24:
|
||||
r = (double) mix_nSpecies(i);
|
||||
break;
|
||||
case 25:
|
||||
r = mix_temperature(i);
|
||||
break;
|
||||
case 26:
|
||||
r = mix_pressure(i);
|
||||
break;
|
||||
case 27:
|
||||
m = getInt(prhs[4]);
|
||||
r = mix_nAtoms(i,int(v), m);
|
||||
break;
|
||||
case 28:
|
||||
r = mix_phaseMoles(i, int(v)-1);
|
||||
break;
|
||||
case 29:
|
||||
r = mix_speciesMoles(i, int(v)-1);
|
||||
break;
|
||||
case 30:
|
||||
r = mix_elementMoles(i, int(v)-1);
|
||||
break;
|
||||
case 31:
|
||||
checkNArgs(8, nrhs);
|
||||
XY = getString(prhs[3]);
|
||||
err = getDouble(prhs[4]);
|
||||
maxsteps = getInt(prhs[5]);
|
||||
maxiter = getInt(prhs[6]);
|
||||
loglevel = getInt(prhs[7]);
|
||||
r = mix_equilibrate(i, XY, err, maxsteps,
|
||||
maxiter, loglevel);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// species properties
|
||||
else if (job < 60) {
|
||||
|
||||
int iok = 0;
|
||||
mwSize nsp = (mwSize) mix_nSpecies(i);
|
||||
double* x = new double[nsp];
|
||||
switch (job) {
|
||||
case 41:
|
||||
iok = mix_getChemPotentials(i,nsp,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (int i = 0; i < nsp; i++) {
|
||||
h[i] = x[i];
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (int i = 0; i < nsp; i++) h[i] = x[i];
|
||||
delete x;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < nsp; i++) h[i] = -999.99;
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
delete x;
|
||||
return;
|
||||
} else {
|
||||
for (int i = 0; i < nsp; i++) {
|
||||
h[i] = -999.99;
|
||||
}
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,47 +11,51 @@
|
||||
|
||||
static std::string ss = "disp(' ";
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class ML_Logger : public Logger {
|
||||
public:
|
||||
ML_Logger() {}
|
||||
virtual ~ML_Logger() {}
|
||||
class ML_Logger : public Logger
|
||||
{
|
||||
public:
|
||||
ML_Logger() {}
|
||||
virtual ~ML_Logger() {}
|
||||
|
||||
|
||||
virtual void write(const std::string& s) {
|
||||
char ch = s[0];
|
||||
int n = 0;
|
||||
while (ch != '\0') {
|
||||
if (ch =='\n') {
|
||||
ss += "');";
|
||||
virtual void write(const std::string& s) {
|
||||
char ch = s[0];
|
||||
int n = 0;
|
||||
while (ch != '\0') {
|
||||
if (ch =='\n') {
|
||||
ss += "');";
|
||||
|
||||
mexEvalString(ss.c_str());
|
||||
ss = "disp(' ";
|
||||
}
|
||||
else
|
||||
ss += ch;
|
||||
if (ch == '\'') ss += ch;
|
||||
n++;
|
||||
ch = s[n];
|
||||
mexEvalString(ss.c_str());
|
||||
ss = "disp(' ";
|
||||
} else {
|
||||
ss += ch;
|
||||
}
|
||||
if (ch == '\'') {
|
||||
ss += ch;
|
||||
}
|
||||
n++;
|
||||
ch = s[n];
|
||||
}
|
||||
}
|
||||
|
||||
virtual void writeendl(const std::string& msg) {
|
||||
mexPrintf("\n");
|
||||
}
|
||||
virtual void writeendl(const std::string& msg) {
|
||||
mexPrintf("\n");
|
||||
}
|
||||
|
||||
virtual void error(const std::string& msg) {
|
||||
std::string err = "error("+msg+");";
|
||||
//mexEvalString(err.c_str());
|
||||
mexErrMsgTxt(err.c_str());
|
||||
}
|
||||
virtual void error(const std::string& msg) {
|
||||
std::string err = "error("+msg+");";
|
||||
//mexEvalString(err.c_str());
|
||||
mexErrMsgTxt(err.c_str());
|
||||
}
|
||||
|
||||
virtual int env() {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
virtual int env() {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,22 +7,24 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
namespace Cantera {
|
||||
void writelog(const std::string& s);
|
||||
namespace Cantera
|
||||
{
|
||||
void writelog(const std::string& s);
|
||||
}
|
||||
using namespace Cantera;
|
||||
|
||||
void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] ) {
|
||||
void onedimmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
double vv;
|
||||
int job = getInt(prhs[2]);
|
||||
int job = getInt(prhs[2]);
|
||||
size_t n, m;
|
||||
double *dom_ids, *h;
|
||||
double* dom_ids, *h;
|
||||
int indx;
|
||||
char *nm;
|
||||
char* nm;
|
||||
|
||||
int dom;
|
||||
dom = getInt(prhs[1]);
|
||||
dom = getInt(prhs[1]);
|
||||
|
||||
int idom, icomp, localPoint;
|
||||
if (job < 10) {
|
||||
@@ -72,22 +74,23 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
reactingsurf_setkineticsmgr(indx, getInt(prhs[3]));
|
||||
break;
|
||||
|
||||
// construct a new Sim1D instance
|
||||
// construct a new Sim1D instance
|
||||
case 8:
|
||||
//writelog("case 8\n");
|
||||
//writelog("case 8\n");
|
||||
checkNArgs(5, nrhs);
|
||||
nd = getInt(prhs[3]);
|
||||
dom_ids = mxGetPr(prhs[4]);
|
||||
m = mxGetM(prhs[4]);
|
||||
n = mxGetN(prhs[4]);
|
||||
sz = (m == 1) ? n : m;
|
||||
if (sz != nd)
|
||||
if (sz != nd) {
|
||||
mexErrMsgTxt("wrong size for domain array");
|
||||
}
|
||||
|
||||
ptrs = new int[sz];
|
||||
//writelog("allocated ptrs\n");
|
||||
for (size_t k = 0; k < sz; k++) {
|
||||
// writelog("k = ...\n");
|
||||
// writelog("k = ...\n");
|
||||
ptrs[k] = int(dom_ids[k]);
|
||||
}
|
||||
//writelog("calling sim1D_new\n");
|
||||
@@ -110,7 +113,9 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
*h = double(indx);
|
||||
if (indx < 0) reportError();
|
||||
if (indx < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,42 +127,56 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
int k;
|
||||
|
||||
switch (job) {
|
||||
|
||||
|
||||
case 10:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = domain_del(dom); break;
|
||||
vv = domain_del(dom);
|
||||
break;
|
||||
case 11:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = (double) domain_nComponents(dom); break;
|
||||
vv = (double) domain_nComponents(dom);
|
||||
break;
|
||||
case 12:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = domain_type(dom); break;
|
||||
vv = domain_type(dom);
|
||||
break;
|
||||
case 13:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = (double) domain_index(dom);
|
||||
if (vv >= 0.0) vv += 1.0; break;
|
||||
if (vv >= 0.0) {
|
||||
vv += 1.0;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = (double) domain_nPoints(dom); break;
|
||||
vv = (double) domain_nPoints(dom);
|
||||
break;
|
||||
case 15:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = bdry_temperature(dom); break;
|
||||
vv = bdry_temperature(dom);
|
||||
break;
|
||||
case 16:
|
||||
checkNArgs(4, nrhs);
|
||||
k = getInt(prhs[3]);
|
||||
vv = bdry_massFraction(dom, k); break;
|
||||
vv = bdry_massFraction(dom, k);
|
||||
break;
|
||||
case 17:
|
||||
checkNArgs(3, nrhs);
|
||||
vv = bdry_mdot(dom); break;
|
||||
vv = bdry_mdot(dom);
|
||||
break;
|
||||
case 18:
|
||||
checkNArgs(4, nrhs);
|
||||
nm = getString(prhs[3]);
|
||||
vv = (double) domain_componentIndex(dom, nm) ;
|
||||
if (vv >= 0.0) vv += 1.0; break;
|
||||
if (vv >= 0.0) {
|
||||
vv += 1.0;
|
||||
}
|
||||
break;
|
||||
case 19:
|
||||
checkNArgs(4, nrhs);
|
||||
localPoint = getInt(prhs[3]) - 1;
|
||||
vv = domain_grid(dom, localPoint); break;
|
||||
vv = domain_grid(dom, localPoint);
|
||||
break;
|
||||
case 30:
|
||||
checkNArgs(6, nrhs);
|
||||
idom = getInt(prhs[3]) - 1;
|
||||
@@ -176,9 +195,11 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
mexErrMsgTxt("unknown job");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
if ((job != 30) && (vv == -1.0)) reportError();
|
||||
if ((job != 30) && (vv == -1.0)) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -199,8 +220,7 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
if (iok >= 0) {
|
||||
plhs[0] = mxCreateString(output_buf);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mexErrMsgTxt("error or unknown method.");
|
||||
return;
|
||||
}
|
||||
@@ -211,14 +231,14 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
|
||||
else {
|
||||
int iok = -1;
|
||||
double lower, upper, rtol, atol, *grid, *pos, *values,
|
||||
mdot, t, p, val, *temp, ratio, slope, curve, tstep, *dts,
|
||||
rdt, prune;
|
||||
double lower, upper, rtol, atol, *grid, *pos, *values,
|
||||
mdot, t, p, val, *temp, ratio, slope, curve, tstep, *dts,
|
||||
rdt, prune;
|
||||
size_t npts, np, nv;
|
||||
int comp, localPoint, idom,
|
||||
loglevel, refine_grid, n, flag, itime, ns, *nsteps, icount,
|
||||
onoff, ss_age, ts_age;
|
||||
char *xstr, *fname, *id, *desc, *name;
|
||||
char* xstr, *fname, *id, *desc, *name;
|
||||
switch (job) {
|
||||
case 51:
|
||||
checkNArgs(6, nrhs);
|
||||
@@ -255,8 +275,8 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
t = getDouble(prhs[3]);
|
||||
iok = bdry_setTemperature(dom, t);
|
||||
break;
|
||||
case 62:
|
||||
checkNArgs(4, nrhs);
|
||||
case 62:
|
||||
checkNArgs(4, nrhs);
|
||||
xstr = getString(prhs[3]);
|
||||
iok = bdry_setMoleFractions(dom, xstr);
|
||||
break;
|
||||
@@ -333,8 +353,8 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
slope = getDouble(prhs[5]);
|
||||
curve = getDouble(prhs[6]);
|
||||
prune = getDouble(prhs[7]);
|
||||
iok = sim1D_setRefineCriteria(dom, idom,
|
||||
ratio, slope, curve, prune);
|
||||
iok = sim1D_setRefineCriteria(dom, idom,
|
||||
ratio, slope, curve, prune);
|
||||
break;
|
||||
case 107:
|
||||
iok = 0;
|
||||
@@ -352,11 +372,13 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
checkNArgs(4, nrhs);
|
||||
name = getString(prhs[3]);
|
||||
iok = sim1D_domainIndex(dom, name);
|
||||
if (iok >= 0) iok++;
|
||||
if (iok >= 0) {
|
||||
iok++;
|
||||
}
|
||||
break;
|
||||
case 110:
|
||||
checkNArgs(3, nrhs);
|
||||
iok = sim1D_del(dom);
|
||||
iok = sim1D_del(dom);
|
||||
break;
|
||||
case 111:
|
||||
iok = 0;
|
||||
@@ -380,7 +402,7 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
checkNArgs(5, nrhs);
|
||||
rdt = getDouble(prhs[3]);
|
||||
icount = getInt(prhs[4]);
|
||||
iok = sim1D_eval(dom, rdt, icount);
|
||||
iok = sim1D_eval(dom, rdt, icount);
|
||||
break;
|
||||
case 114:
|
||||
checkNArgs(5, nrhs);
|
||||
@@ -403,9 +425,11 @@ void onedimmethods( int nlhs, mxArray *plhs[],
|
||||
mexPrintf(" job = %d ",job);
|
||||
mexErrMsgTxt("unknown parameter");
|
||||
}
|
||||
if (iok < 0) reportError();
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,260 +5,279 @@
|
||||
#include "ctmatutils.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
void phasemethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
double vv;
|
||||
int iok=0, k;
|
||||
int ph = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
|
||||
bool ok = true;
|
||||
char* input_buf;
|
||||
double* ptr = 0;
|
||||
size_t nsp, n, m;
|
||||
int mjob, show_thermo;
|
||||
void phasemethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
double vv;
|
||||
int iok=0, k;
|
||||
int ph = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
|
||||
// methods to set attributes
|
||||
if (job < 0) {
|
||||
mjob = -job;
|
||||
if (mxIsChar(prhs[3]) != 1) {
|
||||
ptr = mxGetPr(prhs[3]);
|
||||
}
|
||||
m = mxGetM(prhs[3]);
|
||||
n = mxGetN(prhs[3]);
|
||||
|
||||
nsp = phase_nSpecies(ph);
|
||||
|
||||
// set scalar attributes
|
||||
bool ok = true;
|
||||
if (mjob < 10) {
|
||||
if (m != 1 || n != 1)
|
||||
mexErrMsgTxt("value must be scalar.");
|
||||
bool ok = true;
|
||||
char* input_buf;
|
||||
double* ptr = 0;
|
||||
size_t nsp, n, m;
|
||||
int mjob, show_thermo;
|
||||
|
||||
switch (mjob) {
|
||||
case 1:
|
||||
iok = phase_setTemperature(ph,*ptr); break;
|
||||
case 2:
|
||||
iok = phase_setDensity(ph,*ptr); break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
// set array attributes
|
||||
else if (mjob < 30) {
|
||||
if ((m == nsp && n == 1) || (m == 1 && n == nsp)) {
|
||||
int norm = 1;
|
||||
switch (mjob) {
|
||||
case 20:
|
||||
iok = phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 21:
|
||||
iok = phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 22:
|
||||
norm = 0;
|
||||
iok = phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 23:
|
||||
norm = 0;
|
||||
iok = phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mexErrMsgTxt("wrong array size");
|
||||
}
|
||||
}
|
||||
|
||||
// set attributes from a string
|
||||
else {
|
||||
int status;
|
||||
mwSize buflen;
|
||||
char* input_buf;
|
||||
if (mxIsChar(prhs[3]) == 1) {
|
||||
if(mxGetM(prhs[3]) != 1)
|
||||
mexErrMsgTxt("Input must be a row vector.");
|
||||
buflen = (mwSize) (mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1;
|
||||
input_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
status = mxGetString(prhs[3], input_buf, buflen);
|
||||
if (status != 0)
|
||||
mexWarnMsgTxt("Not enough space. "
|
||||
"String is truncated.");
|
||||
|
||||
switch (mjob) {
|
||||
case 30:
|
||||
iok = phase_setMoleFractionsByName(ph, input_buf);
|
||||
break;
|
||||
case 31:
|
||||
iok = phase_setMassFractionsByName(ph, input_buf);
|
||||
break;
|
||||
case 32:
|
||||
iok = phase_setName(ph, input_buf);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("what?");
|
||||
}
|
||||
}
|
||||
else {
|
||||
mexErrMsgTxt("expected a string.");
|
||||
}
|
||||
}
|
||||
// methods to set attributes
|
||||
if (job < 0) {
|
||||
mjob = -job;
|
||||
if (mxIsChar(prhs[3]) != 1) {
|
||||
ptr = mxGetPr(prhs[3]);
|
||||
}
|
||||
m = mxGetM(prhs[3]);
|
||||
n = mxGetN(prhs[3]);
|
||||
|
||||
else if (job < 20) {
|
||||
nsp = phase_nSpecies(ph);
|
||||
|
||||
switch (job) {
|
||||
case 0:
|
||||
vv = (double) newThermoFromXML(ph); break;
|
||||
// floating-point attributes
|
||||
// set scalar attributes
|
||||
bool ok = true;
|
||||
if (mjob < 10) {
|
||||
if (m != 1 || n != 1) {
|
||||
mexErrMsgTxt("value must be scalar.");
|
||||
}
|
||||
|
||||
switch (mjob) {
|
||||
case 1:
|
||||
vv = phase_temperature(ph); break;
|
||||
iok = phase_setTemperature(ph,*ptr);
|
||||
break;
|
||||
case 2:
|
||||
vv = phase_density(ph); break;
|
||||
case 3:
|
||||
vv = phase_molarDensity(ph); break;
|
||||
case 4:
|
||||
vv = phase_meanMolecularWeight(ph); break;
|
||||
case 8:
|
||||
vv = 1.0/phase_density(ph); break;
|
||||
case 10:
|
||||
vv = (double) phase_nElements(ph); break;
|
||||
case 11:
|
||||
vv = (double) phase_nSpecies(ph); break;
|
||||
case 12:
|
||||
input_buf = getString(prhs[3]);
|
||||
vv = (double) phase_speciesIndex(ph, input_buf) + 1;
|
||||
break;
|
||||
case 13:
|
||||
input_buf = getString(prhs[3]);
|
||||
vv = (double) phase_elementIndex(ph, input_buf) + 1;
|
||||
break;
|
||||
case 14:
|
||||
k = getInt(prhs[3]);
|
||||
m = getInt(prhs[4]);
|
||||
vv = phase_nAtoms(ph,k-1,m-1); break;
|
||||
case 15:
|
||||
show_thermo = getInt(prhs[3]);
|
||||
vv = write_phase(ph,show_thermo);
|
||||
iok = phase_setDensity(ph,*ptr);
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == DERR) reportError();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//ok = true;
|
||||
|
||||
else if (job < 30) {
|
||||
|
||||
iok = 0;
|
||||
size_t nsp = phase_nSpecies(ph);
|
||||
double* x = new double[nsp];
|
||||
switch (job) {
|
||||
case 20:
|
||||
iok = phase_getMoleFractions(ph,nsp,x);
|
||||
break;
|
||||
case 21:
|
||||
iok = phase_getMassFractions(ph,nsp,x);
|
||||
break;
|
||||
case 22:
|
||||
iok = phase_getMolecularWeights(ph,nsp,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nsp; i++) h[i] = x[i];
|
||||
delete x;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < nsp; i++) h[i] = -999.99;
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
// set array attributes
|
||||
else if (mjob < 30) {
|
||||
if ((m == nsp && n == 1) || (m == 1 && n == nsp)) {
|
||||
int norm = 1;
|
||||
switch (mjob) {
|
||||
case 20:
|
||||
iok = phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 21:
|
||||
iok = phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 22:
|
||||
norm = 0;
|
||||
iok = phase_setMoleFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
case 23:
|
||||
norm = 0;
|
||||
iok = phase_setMassFractions(ph, nsp, ptr, norm);
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
mexErrMsgTxt("wrong array size");
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 40) {
|
||||
|
||||
iok = 0;
|
||||
size_t nel = phase_nElements(ph);
|
||||
double* x = new double[nel];
|
||||
switch (job) {
|
||||
case 30:
|
||||
iok = phase_getAtomicWeights(ph,nel,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nel,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nel; i++) h[i] = x[i];
|
||||
delete x;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < nel; i++) h[i] = -999.99;
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 50) {
|
||||
iok = -1;
|
||||
int ksp, mel;
|
||||
int buflen;
|
||||
char* output_buf;
|
||||
switch (job) {
|
||||
case 40:
|
||||
ksp = getInt(prhs[3]);
|
||||
buflen = 40;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = phase_getSpeciesName(ph, ksp-1, buflen, output_buf);
|
||||
break;
|
||||
case 41:
|
||||
mel = getInt(prhs[3]);
|
||||
buflen = 40;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = phase_getElementName(ph, mel-1, buflen, output_buf);
|
||||
break;
|
||||
case 42:
|
||||
buflen = 40;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = phase_getName(ph, buflen, output_buf);
|
||||
break;
|
||||
default:
|
||||
iok = -1;
|
||||
}
|
||||
if (iok >= 0) {
|
||||
plhs[0] = mxCreateString(output_buf);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
mexErrMsgTxt("error or unknown method.");
|
||||
reportError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// set attributes from a string
|
||||
else {
|
||||
mexErrMsgTxt("unimplemented method.");
|
||||
int status;
|
||||
mwSize buflen;
|
||||
char* input_buf;
|
||||
if (mxIsChar(prhs[3]) == 1) {
|
||||
if (mxGetM(prhs[3]) != 1) {
|
||||
mexErrMsgTxt("Input must be a row vector.");
|
||||
}
|
||||
buflen = (mwSize)(mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1;
|
||||
input_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
status = mxGetString(prhs[3], input_buf, buflen);
|
||||
if (status != 0)
|
||||
mexWarnMsgTxt("Not enough space. "
|
||||
"String is truncated.");
|
||||
|
||||
switch (mjob) {
|
||||
case 30:
|
||||
iok = phase_setMoleFractionsByName(ph, input_buf);
|
||||
break;
|
||||
case 31:
|
||||
iok = phase_setMassFractionsByName(ph, input_buf);
|
||||
break;
|
||||
case 32:
|
||||
iok = phase_setName(ph, input_buf);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("what?");
|
||||
}
|
||||
} else {
|
||||
mexErrMsgTxt("expected a string.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 20) {
|
||||
|
||||
switch (job) {
|
||||
case 0:
|
||||
vv = (double) newThermoFromXML(ph);
|
||||
break;
|
||||
// floating-point attributes
|
||||
case 1:
|
||||
vv = phase_temperature(ph);
|
||||
break;
|
||||
case 2:
|
||||
vv = phase_density(ph);
|
||||
break;
|
||||
case 3:
|
||||
vv = phase_molarDensity(ph);
|
||||
break;
|
||||
case 4:
|
||||
vv = phase_meanMolecularWeight(ph);
|
||||
break;
|
||||
case 8:
|
||||
vv = 1.0/phase_density(ph);
|
||||
break;
|
||||
case 10:
|
||||
vv = (double) phase_nElements(ph);
|
||||
break;
|
||||
case 11:
|
||||
vv = (double) phase_nSpecies(ph);
|
||||
break;
|
||||
case 12:
|
||||
input_buf = getString(prhs[3]);
|
||||
vv = (double) phase_speciesIndex(ph, input_buf) + 1;
|
||||
break;
|
||||
case 13:
|
||||
input_buf = getString(prhs[3]);
|
||||
vv = (double) phase_elementIndex(ph, input_buf) + 1;
|
||||
break;
|
||||
case 14:
|
||||
k = getInt(prhs[3]);
|
||||
m = getInt(prhs[4]);
|
||||
vv = phase_nAtoms(ph,k-1,m-1);
|
||||
break;
|
||||
case 15:
|
||||
show_thermo = getInt(prhs[3]);
|
||||
vv = write_phase(ph,show_thermo);
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == DERR) {
|
||||
reportError();
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
if (iok < 0) reportError();
|
||||
}
|
||||
//ok = true;
|
||||
|
||||
else if (job < 30) {
|
||||
|
||||
iok = 0;
|
||||
size_t nsp = phase_nSpecies(ph);
|
||||
double* x = new double[nsp];
|
||||
switch (job) {
|
||||
case 20:
|
||||
iok = phase_getMoleFractions(ph,nsp,x);
|
||||
break;
|
||||
case 21:
|
||||
iok = phase_getMassFractions(ph,nsp,x);
|
||||
break;
|
||||
case 22:
|
||||
iok = phase_getMolecularWeights(ph,nsp,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nsp; i++) {
|
||||
h[i] = x[i];
|
||||
}
|
||||
delete x;
|
||||
return;
|
||||
} else {
|
||||
for (size_t i = 0; i < nsp; i++) {
|
||||
h[i] = -999.99;
|
||||
}
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 40) {
|
||||
|
||||
iok = 0;
|
||||
size_t nel = phase_nElements(ph);
|
||||
double* x = new double[nel];
|
||||
switch (job) {
|
||||
case 30:
|
||||
iok = phase_getAtomicWeights(ph,nel,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nel,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nel; i++) {
|
||||
h[i] = x[i];
|
||||
}
|
||||
delete x;
|
||||
return;
|
||||
} else {
|
||||
for (size_t i = 0; i < nel; i++) {
|
||||
h[i] = -999.99;
|
||||
}
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 50) {
|
||||
iok = -1;
|
||||
int ksp, mel;
|
||||
int buflen;
|
||||
char* output_buf;
|
||||
switch (job) {
|
||||
case 40:
|
||||
ksp = getInt(prhs[3]);
|
||||
buflen = 40;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = phase_getSpeciesName(ph, ksp-1, buflen, output_buf);
|
||||
break;
|
||||
case 41:
|
||||
mel = getInt(prhs[3]);
|
||||
buflen = 40;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = phase_getElementName(ph, mel-1, buflen, output_buf);
|
||||
break;
|
||||
case 42:
|
||||
buflen = 40;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = phase_getName(ph, buflen, output_buf);
|
||||
break;
|
||||
default:
|
||||
iok = -1;
|
||||
}
|
||||
if (iok >= 0) {
|
||||
plhs[0] = mxCreateString(output_buf);
|
||||
return;
|
||||
} else {
|
||||
mexErrMsgTxt("error or unknown method.");
|
||||
reportError();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mexErrMsgTxt("unimplemented method.");
|
||||
return;
|
||||
}
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,113 +6,121 @@
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
void reactormethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
int iok, n;
|
||||
void reactormethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int iok, n;
|
||||
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3) v = getDouble(prhs[3]);
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = reactor_new(i);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = reactor_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = reactor_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = reactor_assign(i,int(v));
|
||||
break;
|
||||
case 4:
|
||||
iok = reactor_setInitialVolume(i, v);
|
||||
break;
|
||||
case 5:
|
||||
iok = reactor_setInitialTime(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = reactor_setThermoMgr(i, int(v));
|
||||
break;
|
||||
case 7:
|
||||
iok = reactor_setKineticsMgr(i, int(v));
|
||||
break;
|
||||
case 8:
|
||||
iok = reactor_advance(i, v);
|
||||
break;
|
||||
case 9:
|
||||
iok = reactor_setEnergy(i, int(v));
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = reactor_step(i, v);
|
||||
break;
|
||||
case 22:
|
||||
r = reactor_time(i);
|
||||
break;
|
||||
case 23:
|
||||
r = reactor_mass(i);
|
||||
break;
|
||||
case 24:
|
||||
r = reactor_volume(i);
|
||||
break;
|
||||
case 25:
|
||||
r = reactor_density(i);
|
||||
break;
|
||||
case 26:
|
||||
r = reactor_temperature(i);
|
||||
break;
|
||||
case 27:
|
||||
r = reactor_enthalpy_mass(i);
|
||||
break;
|
||||
case 28:
|
||||
r = reactor_intEnergy_mass(i);
|
||||
break;
|
||||
case 29:
|
||||
r = reactor_pressure(i);
|
||||
break;
|
||||
case 30:
|
||||
r = reactor_massFraction(i, int(v));
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) reportError();
|
||||
return;
|
||||
}
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3) {
|
||||
v = getDouble(prhs[3]);
|
||||
}
|
||||
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = reactor_new(i);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = reactor_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = reactor_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = reactor_assign(i,int(v));
|
||||
break;
|
||||
case 4:
|
||||
iok = reactor_setInitialVolume(i, v);
|
||||
break;
|
||||
case 5:
|
||||
iok = reactor_setInitialTime(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = reactor_setThermoMgr(i, int(v));
|
||||
break;
|
||||
case 7:
|
||||
iok = reactor_setKineticsMgr(i, int(v));
|
||||
break;
|
||||
case 8:
|
||||
iok = reactor_advance(i, v);
|
||||
break;
|
||||
case 9:
|
||||
iok = reactor_setEnergy(i, int(v));
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = reactor_step(i, v);
|
||||
break;
|
||||
case 22:
|
||||
r = reactor_time(i);
|
||||
break;
|
||||
case 23:
|
||||
r = reactor_mass(i);
|
||||
break;
|
||||
case 24:
|
||||
r = reactor_volume(i);
|
||||
break;
|
||||
case 25:
|
||||
r = reactor_density(i);
|
||||
break;
|
||||
case 26:
|
||||
r = reactor_temperature(i);
|
||||
break;
|
||||
case 27:
|
||||
r = reactor_enthalpy_mass(i);
|
||||
break;
|
||||
case 28:
|
||||
r = reactor_intEnergy_mass(i);
|
||||
break;
|
||||
case 29:
|
||||
r = reactor_pressure(i);
|
||||
break;
|
||||
case 30:
|
||||
r = reactor_massFraction(i, int(v));
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,91 +8,101 @@
|
||||
|
||||
//const double Undef = -999.123;
|
||||
|
||||
void reactornetmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
int iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
void reactornetmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
double v2 = -1.0;
|
||||
if (nrhs > 3) v = getDouble(prhs[3]);
|
||||
if (nrhs > 4) v2 = getDouble(prhs[4]);
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = reactornet_new();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = reactornet_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = reactornet_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = reactornet_assign(i,int(v));
|
||||
break;
|
||||
case 4:
|
||||
iok = reactornet_addreactor(i, int(v));
|
||||
break;
|
||||
case 5:
|
||||
iok = reactornet_setInitialTime(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = reactornet_setMaxTimeStep(i, v);
|
||||
break;
|
||||
case 7:
|
||||
iok = reactornet_setTolerances(i, v, v2);
|
||||
break;
|
||||
case 8:
|
||||
iok = reactornet_advance(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = reactornet_step(i, v);
|
||||
break;
|
||||
case 22:
|
||||
r = reactornet_time(i);
|
||||
break;
|
||||
case 23:
|
||||
r = reactornet_rtol(i);
|
||||
break;
|
||||
case 24:
|
||||
r = reactornet_atol(i);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) reportError();
|
||||
return;
|
||||
}
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
double v2 = -1.0;
|
||||
if (nrhs > 3) {
|
||||
v = getDouble(prhs[3]);
|
||||
}
|
||||
if (nrhs > 4) {
|
||||
v2 = getDouble(prhs[4]);
|
||||
}
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = reactornet_new();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = reactornet_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = reactornet_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = reactornet_assign(i,int(v));
|
||||
break;
|
||||
case 4:
|
||||
iok = reactornet_addreactor(i, int(v));
|
||||
break;
|
||||
case 5:
|
||||
iok = reactornet_setInitialTime(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = reactornet_setMaxTimeStep(i, v);
|
||||
break;
|
||||
case 7:
|
||||
iok = reactornet_setTolerances(i, v, v2);
|
||||
break;
|
||||
case 8:
|
||||
iok = reactornet_advance(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = reactornet_step(i, v);
|
||||
break;
|
||||
case 22:
|
||||
r = reactornet_time(i);
|
||||
break;
|
||||
case 23:
|
||||
r = reactornet_rtol(i);
|
||||
break;
|
||||
case 24:
|
||||
r = reactornet_atol(i);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
void writelog(const std::string& s);
|
||||
namespace Cantera
|
||||
{
|
||||
void writelog(const std::string& s);
|
||||
}
|
||||
using namespace Cantera;
|
||||
|
||||
void surfmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] ) {
|
||||
void surfmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
double vv;
|
||||
int job = getInt(prhs[2]);
|
||||
int job = getInt(prhs[2]);
|
||||
int iok;
|
||||
double* ptr;
|
||||
char* str;
|
||||
@@ -41,8 +43,7 @@ void surfmethods( int nlhs, mxArray *plhs[],
|
||||
nsp = phase_nSpecies(surf);
|
||||
if ((m == nsp && n == 1) || (m == 1 && n == nsp)) {
|
||||
iok = surf_setcoverages(surf, ptr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mexErrMsgTxt("wrong array size for coverages");
|
||||
}
|
||||
break;
|
||||
@@ -56,9 +57,11 @@ void surfmethods( int nlhs, mxArray *plhs[],
|
||||
default:
|
||||
mexErrMsgTxt("unknown job");
|
||||
}
|
||||
if (iok < 0) reportError();
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
return;
|
||||
}
|
||||
@@ -80,21 +83,23 @@ void surfmethods( int nlhs, mxArray *plhs[],
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nsp; i++) h[i] = x[i];
|
||||
for (size_t i = 0; i < nsp; i++) {
|
||||
h[i] = x[i];
|
||||
}
|
||||
delete x;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < nsp; i++) h[i] = -999.99;
|
||||
} else {
|
||||
for (size_t i = 0; i < nsp; i++) {
|
||||
h[i] = -999.99;
|
||||
}
|
||||
delete x;
|
||||
reportError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mexErrMsgTxt("unknown job");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
static void thermoset( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] ) {
|
||||
static void thermoset(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
|
||||
//if (nrhs != 4) {
|
||||
// mexErrMsgTxt("wrong number of input parameters.");
|
||||
@@ -15,8 +16,9 @@ static void thermoset( int nlhs, mxArray *plhs[],
|
||||
int th = getInt(prhs[1]);
|
||||
int job = -getInt(prhs[2]);
|
||||
double* ptr = 0;
|
||||
if (mxIsDouble(prhs[3]) == 1)
|
||||
if (mxIsDouble(prhs[3]) == 1) {
|
||||
ptr = mxGetPr(prhs[3]);
|
||||
}
|
||||
size_t m = mxGetM(prhs[3]);
|
||||
size_t n = mxGetN(prhs[3]);
|
||||
|
||||
@@ -24,15 +26,19 @@ static void thermoset( int nlhs, mxArray *plhs[],
|
||||
|
||||
// scalar attributes
|
||||
if (job < 20) {
|
||||
if (m != 1 || n != 1)
|
||||
if (m != 1 || n != 1) {
|
||||
mexErrMsgTxt("value must be scalar.");
|
||||
}
|
||||
switch (job) {
|
||||
case 10:
|
||||
ierr = delThermo(th); break;
|
||||
ierr = delThermo(th);
|
||||
break;
|
||||
case 1:
|
||||
ierr = th_setPressure(th,*ptr); break;
|
||||
ierr = th_setPressure(th,*ptr);
|
||||
break;
|
||||
case 2:
|
||||
ierr = th_setElectricPotential(th, *ptr); break;
|
||||
ierr = th_setElectricPotential(th, *ptr);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown attribute.");
|
||||
}
|
||||
@@ -43,22 +49,27 @@ static void thermoset( int nlhs, mxArray *plhs[],
|
||||
if ((m == 2 && n == 1) || (m == 1 && n == 2)) {
|
||||
switch (job) {
|
||||
case 20:
|
||||
ierr = th_set_HP(th,ptr); break;
|
||||
ierr = th_set_HP(th,ptr);
|
||||
break;
|
||||
case 21:
|
||||
ierr = th_set_UV(th,ptr); break;
|
||||
ierr = th_set_UV(th,ptr);
|
||||
break;
|
||||
case 22:
|
||||
ierr = th_set_SV(th,ptr); break;
|
||||
ierr = th_set_SV(th,ptr);
|
||||
break;
|
||||
case 23:
|
||||
ierr = th_set_SP(th,ptr); break;
|
||||
ierr = th_set_SP(th,ptr);
|
||||
break;
|
||||
case 24:
|
||||
ierr = th_setState_Psat(th,ptr[0],ptr[1]); break;
|
||||
ierr = th_setState_Psat(th,ptr[0],ptr[1]);
|
||||
break;
|
||||
case 25:
|
||||
ierr = th_setState_Tsat(th,ptr[0],ptr[1]); break;
|
||||
ierr = th_setState_Tsat(th,ptr[0],ptr[1]);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown pair attribute.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mexErrMsgTxt("wrong size");
|
||||
}
|
||||
}
|
||||
@@ -73,141 +84,172 @@ static void thermoset( int nlhs, mxArray *plhs[],
|
||||
int loglevel = getInt(prhs[8]);
|
||||
ierr = th_equil(th, xy, solver, rtol, maxsteps, maxiter, loglevel);
|
||||
}
|
||||
if (ierr < 0) reportError();
|
||||
if (ierr < 0) {
|
||||
reportError();
|
||||
}
|
||||
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = 1.0*ierr;
|
||||
return;
|
||||
}
|
||||
|
||||
static void thermoget( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
double vv, psat, tsat;
|
||||
int n = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
static void thermoget(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
double vv, psat, tsat;
|
||||
int n = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
|
||||
if (job < 30) {
|
||||
if (job < 30) {
|
||||
|
||||
bool ok = true;
|
||||
switch (job) {
|
||||
case 0:
|
||||
vv = (double) newThermoFromXML(n); break;
|
||||
case 2:
|
||||
vv = th_enthalpy_mole(n); break;
|
||||
case 3:
|
||||
vv = th_intEnergy_mole(n); break;
|
||||
case 4:
|
||||
vv = th_entropy_mole(n); break;
|
||||
case 5:
|
||||
vv = th_gibbs_mole(n); break;
|
||||
case 6:
|
||||
vv = th_cp_mole(n); break;
|
||||
case 7:
|
||||
vv = th_cv_mole(n); break;
|
||||
case 8:
|
||||
vv = th_pressure(n); break;
|
||||
case 9:
|
||||
vv = th_enthalpy_mass(n); break;
|
||||
case 10:
|
||||
vv = th_intEnergy_mass(n); break;
|
||||
case 11:
|
||||
vv = th_entropy_mass(n); break;
|
||||
case 12:
|
||||
vv = th_gibbs_mass(n); break;
|
||||
case 13:
|
||||
vv = th_cp_mass(n); break;
|
||||
case 14:
|
||||
vv = th_cv_mass(n); break;
|
||||
case 15:
|
||||
vv = th_refPressure(n); break;
|
||||
case 16:
|
||||
vv = th_minTemp(n); break;
|
||||
case 17:
|
||||
vv = th_maxTemp(n); break;
|
||||
case 18:
|
||||
vv = double(th_eosType(n)); break;
|
||||
bool ok = true;
|
||||
switch (job) {
|
||||
case 0:
|
||||
vv = (double) newThermoFromXML(n);
|
||||
break;
|
||||
case 2:
|
||||
vv = th_enthalpy_mole(n);
|
||||
break;
|
||||
case 3:
|
||||
vv = th_intEnergy_mole(n);
|
||||
break;
|
||||
case 4:
|
||||
vv = th_entropy_mole(n);
|
||||
break;
|
||||
case 5:
|
||||
vv = th_gibbs_mole(n);
|
||||
break;
|
||||
case 6:
|
||||
vv = th_cp_mole(n);
|
||||
break;
|
||||
case 7:
|
||||
vv = th_cv_mole(n);
|
||||
break;
|
||||
case 8:
|
||||
vv = th_pressure(n);
|
||||
break;
|
||||
case 9:
|
||||
vv = th_enthalpy_mass(n);
|
||||
break;
|
||||
case 10:
|
||||
vv = th_intEnergy_mass(n);
|
||||
break;
|
||||
case 11:
|
||||
vv = th_entropy_mass(n);
|
||||
break;
|
||||
case 12:
|
||||
vv = th_gibbs_mass(n);
|
||||
break;
|
||||
case 13:
|
||||
vv = th_cp_mass(n);
|
||||
break;
|
||||
case 14:
|
||||
vv = th_cv_mass(n);
|
||||
break;
|
||||
case 15:
|
||||
vv = th_refPressure(n);
|
||||
break;
|
||||
case 16:
|
||||
vv = th_minTemp(n);
|
||||
break;
|
||||
case 17:
|
||||
vv = th_maxTemp(n);
|
||||
break;
|
||||
case 18:
|
||||
vv = double(th_eosType(n));
|
||||
break;
|
||||
#ifdef WITH_PURE_FLUIDS
|
||||
case 19:
|
||||
vv = th_critTemperature(n); break;
|
||||
case 20:
|
||||
vv = th_critPressure(n); break;
|
||||
case 21:
|
||||
vv = th_critDensity(n); break;
|
||||
case 22:
|
||||
vv = th_vaporFraction(n); break;
|
||||
case 23:
|
||||
psat = getDouble(prhs[3]);
|
||||
vv = th_satTemperature(n, psat); break;
|
||||
case 24:
|
||||
tsat = getDouble(prhs[3]);
|
||||
vv = th_satPressure(n, tsat); break;
|
||||
case 19:
|
||||
vv = th_critTemperature(n);
|
||||
break;
|
||||
case 20:
|
||||
vv = th_critPressure(n);
|
||||
break;
|
||||
case 21:
|
||||
vv = th_critDensity(n);
|
||||
break;
|
||||
case 22:
|
||||
vv = th_vaporFraction(n);
|
||||
break;
|
||||
case 23:
|
||||
psat = getDouble(prhs[3]);
|
||||
vv = th_satTemperature(n, psat);
|
||||
break;
|
||||
case 24:
|
||||
tsat = getDouble(prhs[3]);
|
||||
vv = th_satPressure(n, tsat);
|
||||
break;
|
||||
#endif
|
||||
case 25:
|
||||
vv = th_electricPotential(n); break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == DERR) reportError();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
case 25:
|
||||
vv = th_electricPotential(n);
|
||||
break;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
else if (job < 50) {
|
||||
|
||||
int iok = 0;
|
||||
size_t nsp = th_nSpecies(n);
|
||||
double* x = new double[nsp];
|
||||
switch (job) {
|
||||
case 32:
|
||||
iok = th_getEnthalpies_RT(n,nsp,x);
|
||||
break;
|
||||
case 34:
|
||||
iok = th_chemPotentials(n,nsp,x);
|
||||
break;
|
||||
case 36:
|
||||
iok = th_getEntropies_R(n,nsp,x);
|
||||
break;
|
||||
case 38:
|
||||
iok = th_getCp_R(n,nsp,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nsp; i++) h[i] = x[i];
|
||||
delete x;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < nsp; i++) h[i] = -999.99;
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
if (ok) {
|
||||
if (vv == DERR) {
|
||||
reportError();
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
} else if (job < 50) {
|
||||
|
||||
else {
|
||||
int iok = 0;
|
||||
size_t nsp = th_nSpecies(n);
|
||||
double* x = new double[nsp];
|
||||
switch (job) {
|
||||
case 32:
|
||||
iok = th_getEnthalpies_RT(n,nsp,x);
|
||||
break;
|
||||
case 34:
|
||||
iok = th_chemPotentials(n,nsp,x);
|
||||
break;
|
||||
case 36:
|
||||
iok = th_getEntropies_R(n,nsp,x);
|
||||
break;
|
||||
case 38:
|
||||
iok = th_getCp_R(n,nsp,x);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix((mwSize) nsp,1,
|
||||
mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
if (iok >= 0) {
|
||||
for (size_t i = 0; i < nsp; i++) {
|
||||
h[i] = x[i];
|
||||
}
|
||||
delete x;
|
||||
return;
|
||||
} else {
|
||||
for (size_t i = 0; i < nsp; i++) {
|
||||
h[i] = -999.99;
|
||||
}
|
||||
delete x;
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
mexErrMsgTxt("unknown attribute");
|
||||
}
|
||||
}
|
||||
|
||||
void thermomethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] ) {
|
||||
|
||||
void thermomethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
|
||||
int job = getInt(prhs[2]);
|
||||
if (job < 0) {
|
||||
thermoset(nlhs, plhs, nrhs, prhs);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
thermoget(nlhs, plhs, nrhs, prhs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,104 +5,111 @@
|
||||
|
||||
void reportError();
|
||||
|
||||
void transportmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
double vv;
|
||||
int n = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
double* h;
|
||||
int iok = 0;
|
||||
int nsp;
|
||||
void transportmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
double vv;
|
||||
int n = getInt(prhs[1]);
|
||||
int job = getInt(prhs[2]);
|
||||
double* h;
|
||||
int iok = 0;
|
||||
int nsp;
|
||||
|
||||
if (job == -1) {
|
||||
char* model = getString(prhs[3]);
|
||||
int loglevel = getInt(prhs[4]);
|
||||
int m = -2;
|
||||
m = (int) newTransport(model, n, loglevel);
|
||||
if (m < 0) reportError();
|
||||
|
||||
// Create matrix for the return argument.
|
||||
plhs[0] = mxCreateDoubleMatrix(1,1, mxREAL);
|
||||
double* x = mxGetPr(plhs[0]);
|
||||
*x = m;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (job < 10) {
|
||||
|
||||
bool ok = true;
|
||||
switch (job) {
|
||||
case 0:
|
||||
delTransport(n);
|
||||
vv = 0.0;
|
||||
break;
|
||||
case 1:
|
||||
vv = trans_viscosity(n);
|
||||
break;
|
||||
case 2:
|
||||
vv = trans_thermalConductivity(n); break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
if (vv < 0.0) reportError();
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
}
|
||||
else if (job < 20) {
|
||||
nsp = getInt(prhs[3]);
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
|
||||
switch (job) {
|
||||
case 11:
|
||||
iok = trans_getMixDiffCoeffs(n, nsp, h); break;
|
||||
case 12:
|
||||
iok = trans_getThermalDiffCoeffs(n, nsp, h); break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 30) {
|
||||
nsp = getInt(prhs[3]);
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,nsp,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
switch (job) {
|
||||
case 21:
|
||||
iok = trans_getBinDiffCoeffs(n, nsp, h); break;
|
||||
case 22:
|
||||
iok = trans_getMultiDiffCoeffs(n, nsp, h); break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
}
|
||||
|
||||
// set parameters
|
||||
else if (job < 40) {
|
||||
double* params;
|
||||
int typ, k;
|
||||
switch (job) {
|
||||
case 31:
|
||||
typ = getInt(prhs[3]);
|
||||
k = getInt(prhs[4]);
|
||||
params = mxGetPr(prhs[5]);
|
||||
iok = trans_setParameters(n, typ, k, params);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
}
|
||||
else {
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
if (iok < 0) {
|
||||
if (job == -1) {
|
||||
char* model = getString(prhs[3]);
|
||||
int loglevel = getInt(prhs[4]);
|
||||
int m = -2;
|
||||
m = (int) newTransport(model, n, loglevel);
|
||||
if (m < 0) {
|
||||
reportError();
|
||||
}
|
||||
|
||||
// Create matrix for the return argument.
|
||||
plhs[0] = mxCreateDoubleMatrix(1,1, mxREAL);
|
||||
double* x = mxGetPr(plhs[0]);
|
||||
*x = m;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (job < 10) {
|
||||
|
||||
bool ok = true;
|
||||
switch (job) {
|
||||
case 0:
|
||||
delTransport(n);
|
||||
vv = 0.0;
|
||||
break;
|
||||
case 1:
|
||||
vv = trans_viscosity(n);
|
||||
break;
|
||||
case 2:
|
||||
vv = trans_thermalConductivity(n);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
if (vv < 0.0) {
|
||||
reportError();
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
*h = vv;
|
||||
return;
|
||||
} else if (job < 20) {
|
||||
nsp = getInt(prhs[3]);
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
|
||||
switch (job) {
|
||||
case 11:
|
||||
iok = trans_getMixDiffCoeffs(n, nsp, h);
|
||||
break;
|
||||
case 12:
|
||||
iok = trans_getThermalDiffCoeffs(n, nsp, h);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
}
|
||||
|
||||
else if (job < 30) {
|
||||
nsp = getInt(prhs[3]);
|
||||
plhs[0] = mxCreateNumericMatrix(nsp,nsp,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
switch (job) {
|
||||
case 21:
|
||||
iok = trans_getBinDiffCoeffs(n, nsp, h);
|
||||
break;
|
||||
case 22:
|
||||
iok = trans_getMultiDiffCoeffs(n, nsp, h);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
}
|
||||
|
||||
// set parameters
|
||||
else if (job < 40) {
|
||||
double* params;
|
||||
int typ, k;
|
||||
switch (job) {
|
||||
case 31:
|
||||
typ = getInt(prhs[3]);
|
||||
k = getInt(prhs[4]);
|
||||
params = mxGetPr(prhs[5]);
|
||||
iok = trans_setParameters(n, typ, k, params);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
} else {
|
||||
mexErrMsgTxt("unknown Transport method");
|
||||
}
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,106 +8,114 @@
|
||||
|
||||
//const double Undef = -999.123;
|
||||
|
||||
void wallmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
{
|
||||
int m, iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
void wallmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int m, iok, n;
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3) v = getDouble(prhs[3]);
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = wall_new(i);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = wall_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = wall_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = wall_assign(i,int(v));
|
||||
break;
|
||||
case 4:
|
||||
m = getInt(prhs[4]);
|
||||
iok = wall_install(i, int(v), m);
|
||||
break;
|
||||
case 5:
|
||||
iok = wall_setArea(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = wall_setThermalResistance(i, v);
|
||||
break;
|
||||
case 7:
|
||||
iok = wall_setHeatTransferCoeff(i, v);
|
||||
break;
|
||||
case 8:
|
||||
iok = wall_setHeatFlux(i, int(v));
|
||||
break;
|
||||
case 9:
|
||||
iok = wall_setExpansionRateCoeff(i, v);
|
||||
break;
|
||||
case 10:
|
||||
iok = wall_setVelocity(i, int(v));
|
||||
break;
|
||||
case 11:
|
||||
iok = wall_ready(i);
|
||||
break;
|
||||
case 12:
|
||||
n = getInt(prhs[3]);
|
||||
m = getInt(prhs[4]);
|
||||
iok = wall_setkinetics(i, n, m);
|
||||
break;
|
||||
case 13:
|
||||
iok = wall_setEmissivity(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = wall_vdot(i, v);
|
||||
break;
|
||||
case 22:
|
||||
r = wall_Q(i, v);
|
||||
break;
|
||||
case 23:
|
||||
r = wall_area(i);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) reportError();
|
||||
return;
|
||||
}
|
||||
double r = Undef;
|
||||
double v = Undef;
|
||||
if (nrhs > 3) {
|
||||
v = getDouble(prhs[3]);
|
||||
}
|
||||
|
||||
// constructor
|
||||
if (job == 0) {
|
||||
n = wall_new(i);
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(n);
|
||||
if (n < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
|
||||
case 1:
|
||||
iok = wall_del(i);
|
||||
break;
|
||||
case 2:
|
||||
iok = wall_copy(i);
|
||||
break;
|
||||
case 3:
|
||||
iok = wall_assign(i,int(v));
|
||||
break;
|
||||
case 4:
|
||||
m = getInt(prhs[4]);
|
||||
iok = wall_install(i, int(v), m);
|
||||
break;
|
||||
case 5:
|
||||
iok = wall_setArea(i, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = wall_setThermalResistance(i, v);
|
||||
break;
|
||||
case 7:
|
||||
iok = wall_setHeatTransferCoeff(i, v);
|
||||
break;
|
||||
case 8:
|
||||
iok = wall_setHeatFlux(i, int(v));
|
||||
break;
|
||||
case 9:
|
||||
iok = wall_setExpansionRateCoeff(i, v);
|
||||
break;
|
||||
case 10:
|
||||
iok = wall_setVelocity(i, int(v));
|
||||
break;
|
||||
case 11:
|
||||
iok = wall_ready(i);
|
||||
break;
|
||||
case 12:
|
||||
n = getInt(prhs[3]);
|
||||
m = getInt(prhs[4]);
|
||||
iok = wall_setkinetics(i, n, m);
|
||||
break;
|
||||
case 13:
|
||||
iok = wall_setEmissivity(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// options that return a value of type 'double'
|
||||
|
||||
else if (job < 40) {
|
||||
switch (job) {
|
||||
case 21:
|
||||
r = wall_vdot(i, v);
|
||||
break;
|
||||
case 22:
|
||||
r = wall_Q(i, v);
|
||||
break;
|
||||
case 23:
|
||||
r = wall_area(i);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = r;
|
||||
if (r == Undef) {
|
||||
reportError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,25 +8,39 @@
|
||||
|
||||
void reportError();
|
||||
|
||||
static bool nargs_ok(int job, int n) {
|
||||
static bool nargs_ok(int job, int n)
|
||||
{
|
||||
switch (n) {
|
||||
case 1: case 2: case 10: case 21: case 22:
|
||||
case 1:
|
||||
case 2:
|
||||
case 10:
|
||||
case 21:
|
||||
case 22:
|
||||
return (n == 2);
|
||||
case 3: case 4: case 6: case 7: case 8: case 9:
|
||||
case 13: case 14: case 20:
|
||||
case 3:
|
||||
case 4:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 13:
|
||||
case 14:
|
||||
case 20:
|
||||
return (n == 3);
|
||||
case 5: case 11: case 12:
|
||||
case 5:
|
||||
case 11:
|
||||
case 12:
|
||||
return (n == 4);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void xmlmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
void xmlmethods(int nlhs, mxArray* plhs[],
|
||||
int nrhs, const mxArray* prhs[])
|
||||
{
|
||||
int j, m, iok;
|
||||
char *file, *key, *val, *nm;
|
||||
char* file, *key, *val, *nm;
|
||||
|
||||
int job = getInt(prhs[1]);
|
||||
int i = getInt(prhs[2]);
|
||||
@@ -35,14 +49,13 @@ void xmlmethods( int nlhs, mxArray *plhs[],
|
||||
if (!nargs_ok(job,nrhs-1)) {
|
||||
mexErrMsgTxt("Wrong number of inputs.");
|
||||
return;
|
||||
}
|
||||
else if(nlhs > 1) {
|
||||
} else if (nlhs > 1) {
|
||||
mexErrMsgTxt("Too many output arguments");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// options that do not return a value
|
||||
|
||||
|
||||
if (job < 20) {
|
||||
switch (job) {
|
||||
case 0:
|
||||
@@ -64,87 +77,90 @@ void xmlmethods( int nlhs, mxArray *plhs[],
|
||||
iok = xml_build(i, file);
|
||||
break;
|
||||
case 5:
|
||||
key = getString(prhs[3]);
|
||||
val = getString(prhs[4]);
|
||||
iok = xml_addAttrib(i, key, val);
|
||||
break;
|
||||
case 6:
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_child(i, key);
|
||||
break;
|
||||
case 7:
|
||||
m = getInt(prhs[3]);
|
||||
iok = xml_child_bynumber(i, m);
|
||||
break;
|
||||
case 8:
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_findID(i, key);
|
||||
break;
|
||||
case 9:
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_findByName(i, key);
|
||||
break;
|
||||
case 10:
|
||||
iok = xml_nChildren(i);
|
||||
break;
|
||||
case 11:
|
||||
key = getString(prhs[3]);
|
||||
val = getString(prhs[4]);
|
||||
iok = xml_addChild(i, key, val);
|
||||
break;
|
||||
case 12:
|
||||
key = getString(prhs[3]);
|
||||
j = getInt(prhs[4]);
|
||||
iok = xml_addChildNode(i, j);
|
||||
break;
|
||||
case 13:
|
||||
file = getString(prhs[3]);
|
||||
iok = xml_write(i, file);
|
||||
break;
|
||||
case 14:
|
||||
j = getInt(prhs[3]);
|
||||
iok = xml_removeChild(i, j);
|
||||
break;
|
||||
key = getString(prhs[3]);
|
||||
val = getString(prhs[4]);
|
||||
iok = xml_addAttrib(i, key, val);
|
||||
break;
|
||||
case 6:
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_child(i, key);
|
||||
break;
|
||||
case 7:
|
||||
m = getInt(prhs[3]);
|
||||
iok = xml_child_bynumber(i, m);
|
||||
break;
|
||||
case 8:
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_findID(i, key);
|
||||
break;
|
||||
case 9:
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_findByName(i, key);
|
||||
break;
|
||||
case 10:
|
||||
iok = xml_nChildren(i);
|
||||
break;
|
||||
case 11:
|
||||
key = getString(prhs[3]);
|
||||
val = getString(prhs[4]);
|
||||
iok = xml_addChild(i, key, val);
|
||||
break;
|
||||
case 12:
|
||||
key = getString(prhs[3]);
|
||||
j = getInt(prhs[4]);
|
||||
iok = xml_addChildNode(i, j);
|
||||
break;
|
||||
case 13:
|
||||
file = getString(prhs[3]);
|
||||
iok = xml_write(i, file);
|
||||
break;
|
||||
case 14:
|
||||
j = getInt(prhs[3]);
|
||||
iok = xml_removeChild(i, j);
|
||||
break;
|
||||
case 15:
|
||||
file = getString(prhs[3]);
|
||||
iok = xml_get_XML_File(file);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
return;
|
||||
}
|
||||
|
||||
// options that return strings
|
||||
|
||||
char* v = (char*)mxCalloc(80, sizeof(char));
|
||||
switch (job) {
|
||||
case 20:
|
||||
// return an attribute
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_attrib(i, key, v);
|
||||
break;
|
||||
case 21:
|
||||
// return the value of the node
|
||||
iok = xml_value(i, v);
|
||||
break;
|
||||
case 22:
|
||||
iok = xml_tag(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double *h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) reportError();
|
||||
reportError();
|
||||
}
|
||||
else {
|
||||
plhs[0] = mxCreateString(v);
|
||||
return;
|
||||
}
|
||||
|
||||
// options that return strings
|
||||
|
||||
char* v = (char*)mxCalloc(80, sizeof(char));
|
||||
switch (job) {
|
||||
case 20:
|
||||
// return an attribute
|
||||
key = getString(prhs[3]);
|
||||
iok = xml_attrib(i, key, v);
|
||||
break;
|
||||
case 21:
|
||||
// return the value of the node
|
||||
iok = xml_value(i, v);
|
||||
break;
|
||||
case 22:
|
||||
iok = xml_tag(i, v);
|
||||
break;
|
||||
default:
|
||||
mexErrMsgTxt("unknown job parameter");
|
||||
}
|
||||
if (iok < 0) {
|
||||
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
|
||||
double* h = mxGetPr(plhs[0]);
|
||||
*h = double(iok);
|
||||
if (iok < 0) {
|
||||
reportError();
|
||||
}
|
||||
} else {
|
||||
plhs[0] = mxCreateString(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,107 +1,128 @@
|
||||
|
||||
static PyObject*
|
||||
py_bndry_new(PyObject *self, PyObject *args)
|
||||
py_bndry_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int itype;
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_new", &itype))
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_new", &itype)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = bndry_new(itype);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bndry_del(PyObject *self, PyObject *args)
|
||||
py_bndry_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
bndry_del(n);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bndry_temperature(PyObject *self, PyObject *args)
|
||||
py_bndry_temperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_temperature", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_temperature", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double t = bndry_temperature(n);
|
||||
return Py_BuildValue("d",t);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bndry_settemperature(PyObject *self, PyObject *args)
|
||||
py_bndry_settemperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:bndry_settemperature", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:bndry_settemperature", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = bndry_settemperature(n, t);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_bndry_setspreadrate(PyObject *self, PyObject *args)
|
||||
py_bndry_setspreadrate(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:bndry_setspreadrate", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:bndry_setspreadrate", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = bndry_setSpreadRate(n, v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bndry_mdot(PyObject *self, PyObject *args)
|
||||
py_bndry_mdot(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_mdot", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:bndry_mdot", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double mdot = bndry_mdot(n);
|
||||
return Py_BuildValue("d",mdot);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bndry_setmdot(PyObject *self, PyObject *args)
|
||||
py_bndry_setmdot(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double mdot;
|
||||
if (!PyArg_ParseTuple(args, "id:bndry_setmdot", &n, &mdot))
|
||||
if (!PyArg_ParseTuple(args, "id:bndry_setmdot", &n, &mdot)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = bndry_setmdot(n, mdot);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bndry_setxinbyname(PyObject *self, PyObject *args)
|
||||
py_bndry_setxinbyname(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* xin;
|
||||
//PyObject* o;
|
||||
if (!PyArg_ParseTuple(args, "is:bndry_setxin", &n, &xin))
|
||||
if (!PyArg_ParseTuple(args, "is:bndry_setxin", &n, &xin)) {
|
||||
return NULL;
|
||||
}
|
||||
//double* x = (double*)((PyArrayObject*)o)->data;
|
||||
int iok = bndry_setxinbyname(n, xin);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_bndry_setxin(PyObject *self, PyObject *args)
|
||||
py_bndry_setxin(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject* xin;
|
||||
if (!PyArg_ParseTuple(args, "iO:bndry_setxin", &n, &xin))
|
||||
if (!PyArg_ParseTuple(args, "iO:bndry_setxin", &n, &xin)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)xin)->data;
|
||||
int iok = bndry_setxin(n, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,231 +1,273 @@
|
||||
|
||||
static PyObject *
|
||||
py_flow_new(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_flow_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int itype, iph, np;
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_new",
|
||||
&itype, &iph, &np))
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_new",
|
||||
&itype, &iph, &np)) {
|
||||
return NULL;
|
||||
}
|
||||
int nn = flow_new(itype,iph,np);
|
||||
if (nn < 0) return reportError(nn);
|
||||
if (nn < 0) {
|
||||
return reportError(nn);
|
||||
}
|
||||
return Py_BuildValue("i",nn);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_delete(PyObject *self, PyObject *args)
|
||||
py_flow_delete(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:flow_delete", &n)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:flow_delete", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
flow_del(n);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setupgrid(PyObject *self, PyObject *args)
|
||||
py_flow_setupgrid(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject* grid;
|
||||
if (!PyArg_ParseTuple(args, "iO:flow_setupgrid", &n, &grid))
|
||||
if (!PyArg_ParseTuple(args, "iO:flow_setupgrid", &n, &grid)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyArrayObject* g = (PyArrayObject*)grid;
|
||||
double* xd = (double*)g->data;
|
||||
int glen = g->dimensions[0];
|
||||
|
||||
int iok = flow_setupgrid(n, glen, xd);
|
||||
if (iok == -1) return reportCanteraError();
|
||||
else if (iok < 0) return NULL;
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setkinetics(PyObject *self, PyObject *args)
|
||||
{
|
||||
int nn,k;
|
||||
if (!PyArg_ParseTuple(args, "ii:flow_setkinetics", &nn, &k)) return NULL;
|
||||
return Py_BuildValue("i",flow_setkinetics(nn,k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_settransport(PyObject *self, PyObject *args)
|
||||
{
|
||||
int nn,k,soret;
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_settransport",
|
||||
&nn, &k, &soret)) return NULL;
|
||||
return Py_BuildValue("i",flow_settransport(nn,k,soret));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setthermo(PyObject *self, PyObject *args)
|
||||
{
|
||||
int nn,k;
|
||||
if (!PyArg_ParseTuple(args, "ii:flow_setthermo", &nn, &k)) return NULL;
|
||||
return Py_BuildValue("i",flow_setthermo(nn,k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setpressure(PyObject *self, PyObject *args)
|
||||
{
|
||||
int nn;
|
||||
double p;
|
||||
if (!PyArg_ParseTuple(args, "id:flow_setpressure", &nn, &p))
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
} else if (iok < 0) {
|
||||
return NULL;
|
||||
return Py_BuildValue("i",flow_setpressure(nn,p));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_settemperature(PyObject *self, PyObject *args)
|
||||
{
|
||||
int n, j;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "iid:flow_settemperature", &n, &j, &t))
|
||||
return NULL;
|
||||
return Py_BuildValue("i",flow_settemperature(n,j,t));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setenergyfactor(PyObject *self, PyObject *args)
|
||||
{
|
||||
int n;
|
||||
double e;
|
||||
if (!PyArg_ParseTuple(args, "id:flow_setenergyfactor", &n, &e))
|
||||
return NULL;
|
||||
return Py_BuildValue("i",flow_setenergyfactor(n,e));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setmassfraction(PyObject *self, PyObject *args)
|
||||
{
|
||||
int n, j, k;
|
||||
double y;
|
||||
if (!PyArg_ParseTuple(args, "iiid:flow_setinlet_v", &n, &j, &k, &y))
|
||||
return NULL;
|
||||
return Py_BuildValue("i",flow_setmassfraction(n,j,k,y));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_showsolution(PyObject *self, PyObject *args)
|
||||
{
|
||||
int n;
|
||||
char* fname;
|
||||
PyObject* soln;
|
||||
if (!PyArg_ParseTuple(args, "isO:flow_showsolution", &n, &fname, &soln))
|
||||
return NULL;
|
||||
double* x = (double*)((PyArrayObject*)soln)->data;
|
||||
return Py_BuildValue("i",flow_showsolution(n,fname,x));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_solvespecies(PyObject *self, PyObject *args)
|
||||
{
|
||||
int n, slen;
|
||||
PyObject* s;
|
||||
if (!PyArg_ParseTuple(args, "iiO:flow_solvespecies", &n, &slen, &s))
|
||||
return NULL;
|
||||
double* x = (double*)((PyArrayObject*)s)->data;
|
||||
for (int i = 0; i < slen; i++) {
|
||||
if (x[i] <= 0.0)
|
||||
flow_fixspecies(n, i);
|
||||
else
|
||||
flow_solvespecies(n, i);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_copy(PyObject *self, PyObject *args)
|
||||
py_flow_setkinetics(PyObject* self, PyObject* args)
|
||||
{
|
||||
int nn,k;
|
||||
if (!PyArg_ParseTuple(args, "ii:flow_setkinetics", &nn, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_setkinetics(nn,k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_settransport(PyObject* self, PyObject* args)
|
||||
{
|
||||
int nn,k,soret;
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_settransport",
|
||||
&nn, &k, &soret)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_settransport(nn,k,soret));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setthermo(PyObject* self, PyObject* args)
|
||||
{
|
||||
int nn,k;
|
||||
if (!PyArg_ParseTuple(args, "ii:flow_setthermo", &nn, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_setthermo(nn,k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setpressure(PyObject* self, PyObject* args)
|
||||
{
|
||||
int nn;
|
||||
double p;
|
||||
if (!PyArg_ParseTuple(args, "id:flow_setpressure", &nn, &p)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_setpressure(nn,p));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_settemperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, j;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "iid:flow_settemperature", &n, &j, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_settemperature(n,j,t));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setenergyfactor(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject *s, *snew;
|
||||
if (!PyArg_ParseTuple(args, "iOO:copy", &n, &s, &snew))
|
||||
double e;
|
||||
if (!PyArg_ParseTuple(args, "id:flow_setenergyfactor", &n, &e)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_setenergyfactor(n,e));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setmassfraction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, j, k;
|
||||
double y;
|
||||
if (!PyArg_ParseTuple(args, "iiid:flow_setinlet_v", &n, &j, &k, &y)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",flow_setmassfraction(n,j,k,y));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_showsolution(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* fname;
|
||||
PyObject* soln;
|
||||
if (!PyArg_ParseTuple(args, "isO:flow_showsolution", &n, &fname, &soln)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)soln)->data;
|
||||
return Py_BuildValue("i",flow_showsolution(n,fname,x));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_solvespecies(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, slen;
|
||||
PyObject* s;
|
||||
if (!PyArg_ParseTuple(args, "iiO:flow_solvespecies", &n, &slen, &s)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)s)->data;
|
||||
for (int i = 0; i < slen; i++) {
|
||||
if (x[i] <= 0.0) {
|
||||
flow_fixspecies(n, i);
|
||||
} else {
|
||||
flow_solvespecies(n, i);
|
||||
}
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_copy(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject* s, *snew;
|
||||
if (!PyArg_ParseTuple(args, "iOO:copy", &n, &s, &snew)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)s)->data;
|
||||
double* xnew = (double*)((PyArrayObject*)snew)->data;
|
||||
for (int i = 0; i < n; i++) xnew[i] = x[i];
|
||||
for (int i = 0; i < n; i++) {
|
||||
xnew[i] = x[i];
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_flow_settolerances(PyObject *self, PyObject *args)
|
||||
py_flow_settolerances(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, nr, na;
|
||||
PyObject *prtol, *patol;
|
||||
if (!PyArg_ParseTuple(args, "iiOiO:flow_solve", &n, &nr, &prtol,
|
||||
&na, &patol))
|
||||
PyObject* prtol, *patol;
|
||||
if (!PyArg_ParseTuple(args, "iiOiO:flow_solve", &n, &nr, &prtol,
|
||||
&na, &patol)) {
|
||||
return NULL;
|
||||
}
|
||||
double* rtol = (double*)((PyArrayObject*)prtol)->data;
|
||||
double* atol = (double*)((PyArrayObject*)patol)->data;
|
||||
int iok = flow_settolerances(n, nr, rtol, na, atol);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_outputtec(PyObject *self, PyObject *args)
|
||||
py_flow_outputtec(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject *px;
|
||||
char *fname, *title;
|
||||
PyObject* px;
|
||||
char* fname, *title;
|
||||
int zone;
|
||||
if (!PyArg_ParseTuple(args, "iOssi:flow_outputtec", &n, &px,
|
||||
&fname, &title, &zone))
|
||||
if (!PyArg_ParseTuple(args, "iOssi:flow_outputtec", &n, &px,
|
||||
&fname, &title, &zone)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)px)->data;
|
||||
int iok = flow_outputtec(n, x, fname, title, zone);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_resize(PyObject *self, PyObject *args)
|
||||
py_flow_resize(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, points;
|
||||
if (!PyArg_ParseTuple(args, "ii:flow_resize", &n, &points))
|
||||
if (!PyArg_ParseTuple(args, "ii:flow_resize", &n, &points)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flow_resize(n, points);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_energy(PyObject *self, PyObject *args)
|
||||
py_flow_energy(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, j, flag, iok;
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_energy", &n, &j, &flag))
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_energy", &n, &j, &flag)) {
|
||||
return NULL;
|
||||
if (flag == 1)
|
||||
}
|
||||
if (flag == 1) {
|
||||
iok = flow_solveenergyeqn(n, j);
|
||||
else
|
||||
} else {
|
||||
iok = flow_fixtemperature(n, j);
|
||||
if (iok < 0) return reportError(iok);
|
||||
}
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setfixedpoint(PyObject *self, PyObject *args)
|
||||
py_flow_setfixedpoint(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, j0;
|
||||
double t0;
|
||||
if (!PyArg_ParseTuple(args, "iid:flow_setfixedpoint", &n, &j0, &t0))
|
||||
if (!PyArg_ParseTuple(args, "iid:flow_setfixedpoint", &n, &j0, &t0)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flow_setfixedpoint(n, j0, t0);
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_restore(PyObject *self, PyObject *args)
|
||||
py_flow_restore(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, job, iz, isoln;
|
||||
char *fname, *id;
|
||||
PyArrayObject *pz, *psoln;
|
||||
if (!PyArg_ParseTuple(args, "iiss:flow_restore",
|
||||
&n, &job, &fname, &id))
|
||||
char* fname, *id;
|
||||
PyArrayObject* pz, *psoln;
|
||||
if (!PyArg_ParseTuple(args, "iiss:flow_restore",
|
||||
&n, &job, &fname, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok;
|
||||
double *z=0, *soln=0;
|
||||
double* z=0, *soln=0;
|
||||
iok = flow_restore(n, -1, fname, id, iz, z, isoln, soln);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
if (job < 0) {
|
||||
return Py_BuildValue("(ii)",iz,isoln);
|
||||
}
|
||||
@@ -249,17 +291,20 @@ py_flow_restore(PyObject *self, PyObject *args)
|
||||
z = (double*)((PyArrayObject*)pz)->data;
|
||||
soln = (double*)((PyArrayObject*)psoln)->data;
|
||||
iok = flow_restore(n, 0, fname, id, iz, z, isoln, soln);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("(OO)",pz,psoln);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flow_setboundaries(PyObject *self, PyObject *args)
|
||||
py_flow_setboundaries(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, nleft, nright;
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_setboundaries", &n, &nleft,
|
||||
&nright))
|
||||
if (!PyArg_ParseTuple(args, "iii:flow_setboundaries", &n, &nleft,
|
||||
&nright)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flow_setboundaries(n, nleft, nright);
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
@@ -268,89 +313,104 @@ py_flow_setboundaries(PyObject *self, PyObject *args)
|
||||
/* flow boundary objects */
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_bdry_new(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_bdry_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int itype, ip, kin;
|
||||
if (!PyArg_ParseTuple(args, "iii:bdry_new", &itype, &ip, &kin))
|
||||
if (!PyArg_ParseTuple(args, "iii:bdry_new", &itype, &ip, &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
int nn = bdry_new(itype,ip,kin);
|
||||
if (nn < 0) return reportError(nn);
|
||||
if (nn < 0) {
|
||||
return reportError(nn);
|
||||
}
|
||||
return Py_BuildValue("i",nn);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bdry_delete(PyObject *self, PyObject *args)
|
||||
py_bdry_delete(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:bdry_delete", &n)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:bdry_delete", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
bdry_del(n);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_bdry_set(PyObject *self, PyObject *args)
|
||||
py_bdry_set(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, i;
|
||||
double v;
|
||||
PyObject* px;
|
||||
double* x;
|
||||
if (!PyArg_ParseTuple(args, "iidO:bdry_set", &n, &i, &v, &px))
|
||||
if (!PyArg_ParseTuple(args, "iidO:bdry_set", &n, &i, &v, &px)) {
|
||||
return NULL;
|
||||
if (i < 4)
|
||||
}
|
||||
if (i < 4) {
|
||||
bdry_set(n, i, &v);
|
||||
else {
|
||||
} else {
|
||||
x = (double*)((PyArrayObject*)px)->data;
|
||||
bdry_set(n, i, x);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_onedim_new(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_onedim_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject *pydom, *pytype;
|
||||
if (!PyArg_ParseTuple(args, "iOO:onedim_new", &n, &pydom, &pytype))
|
||||
PyObject* pydom, *pytype;
|
||||
if (!PyArg_ParseTuple(args, "iOO:onedim_new", &n, &pydom, &pytype)) {
|
||||
return NULL;
|
||||
}
|
||||
int* dom = (int*)((PyArrayObject*)pydom)->data;
|
||||
int* typ = (int*)((PyArrayObject*)pytype)->data;
|
||||
int nn = onedim_new(n, dom, typ);
|
||||
if (nn == -1) return reportCanteraError();
|
||||
if (nn == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",nn);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_delete(PyObject *self, PyObject *args)
|
||||
py_onedim_delete(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_delete", &n)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_delete", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
onedim_del(n);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_solve(PyObject *self, PyObject *args)
|
||||
py_onedim_solve(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, loglevel;
|
||||
PyObject *s, *snew;
|
||||
if (!PyArg_ParseTuple(args, "iOOi:onedim_solve", &n, &s, &snew, &loglevel))
|
||||
PyObject* s, *snew;
|
||||
if (!PyArg_ParseTuple(args, "iOOi:onedim_solve", &n, &s, &snew, &loglevel)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)s)->data;
|
||||
double* xnew = (double*)((PyArrayObject*)snew)->data;
|
||||
int iok = onedim_solve(n,x,xnew,loglevel);
|
||||
if (iok == -1) return reportCanteraError();
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_onedim_ssnorm(PyObject *self, PyObject *args)
|
||||
py_onedim_ssnorm(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject *ps, *pr;
|
||||
if (!PyArg_ParseTuple(args, "iOO:flow_solve", &n, &ps, &pr))
|
||||
PyObject* ps, *pr;
|
||||
if (!PyArg_ParseTuple(args, "iOO:flow_solve", &n, &ps, &pr)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)ps)->data;
|
||||
double* r = (double*)((PyArrayObject*)pr)->data;
|
||||
double ss = onedim_ssnorm(n,x,r);
|
||||
@@ -358,34 +418,39 @@ py_onedim_ssnorm(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_setnewtonoptions(PyObject *self, PyObject *args)
|
||||
py_onedim_setnewtonoptions(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, age;
|
||||
if (!PyArg_ParseTuple(args, "ii:onedim_setnewtonoptions", &n, &age))
|
||||
if (!PyArg_ParseTuple(args, "ii:onedim_setnewtonoptions", &n, &age)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = onedim_setnewtonoptions(n, age);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_setsteadymode(PyObject *self, PyObject *args)
|
||||
py_onedim_setsteadymode(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_setsteadymode", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_setsteadymode", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = onedim_setsteadymode(n);
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_settransientmode(PyObject *self, PyObject *args)
|
||||
py_onedim_settransientmode(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double dt;
|
||||
PyArrayObject* px;
|
||||
if (!PyArg_ParseTuple(args, "idO:onedim_settransientmode", &n, &dt, &px))
|
||||
if (!PyArg_ParseTuple(args, "idO:onedim_settransientmode", &n, &dt, &px)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)px)->data;
|
||||
int iok = onedim_settransientmode(n, dt, x);
|
||||
return Py_BuildValue("i",iok);
|
||||
@@ -393,27 +458,33 @@ py_onedim_settransientmode(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_onedim_eval(PyObject *self, PyObject *args)
|
||||
py_onedim_eval(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject *px, *pr;
|
||||
if (!PyArg_ParseTuple(args, "iOO:onedim_eval", &n, &px, &pr))
|
||||
PyObject* px, *pr;
|
||||
if (!PyArg_ParseTuple(args, "iOO:onedim_eval", &n, &px, &pr)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)px)->data;
|
||||
double* r = (double*)((PyArrayObject*)pr)->data;
|
||||
int iok = onedim_eval(n, x, r);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_addflow(PyObject *self, PyObject *args)
|
||||
py_onedim_addflow(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:onedim_addflow", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:onedim_addflow", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = onedim_addFlow(n, m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
@@ -421,7 +492,7 @@ py_onedim_addflow(PyObject *self, PyObject *args)
|
||||
// py_onedim_addsurf(PyObject *self, PyObject *args)
|
||||
// {
|
||||
// int n, m;
|
||||
// if (!PyArg_ParseTuple(args, "ii:onedim_addflow", &n, &m))
|
||||
// if (!PyArg_ParseTuple(args, "ii:onedim_addflow", &n, &m))
|
||||
// return NULL;
|
||||
// int iok = onedim_addSurf(n, m);
|
||||
// if (iok < 0) return reportError(iok);
|
||||
@@ -430,54 +501,66 @@ py_onedim_addflow(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_onedim_resize(PyObject *self, PyObject *args)
|
||||
py_onedim_resize(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_resize", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_resize", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = onedim_resize(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_writestats(PyObject *self, PyObject *args)
|
||||
py_onedim_writestats(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_writeStats", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:onedim_writeStats", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = onedim_writeStats(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_timestep(PyObject *self, PyObject *args)
|
||||
py_onedim_timestep(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, nsteps, loglevel;
|
||||
double dt;
|
||||
PyObject *px, *pr;
|
||||
PyObject* px, *pr;
|
||||
if (!PyArg_ParseTuple(args, "iidOOi:onedim_timestep", &n, &nsteps,
|
||||
&dt, &px, &pr, &loglevel))
|
||||
&dt, &px, &pr, &loglevel)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)px)->data;
|
||||
double* r = (double*)((PyArrayObject*)pr)->data;
|
||||
double newdt = onedim_timestep(n, nsteps, dt, x, r, loglevel);
|
||||
if (newdt < 0.0) return reportError(-1);
|
||||
if (newdt < 0.0) {
|
||||
return reportError(-1);
|
||||
}
|
||||
return Py_BuildValue("d",newdt);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_onedim_save(PyObject *self, PyObject *args)
|
||||
py_onedim_save(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char *fname, *id, *desc;
|
||||
char* fname, *id, *desc;
|
||||
PyArrayObject* px;
|
||||
if (!PyArg_ParseTuple(args, "isssO:onedim_save", &n, &fname, &id, &desc, &px))
|
||||
if (!PyArg_ParseTuple(args, "isssO:onedim_save", &n, &fname, &id, &desc, &px)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)px)->data;
|
||||
int iok = onedim_save(n, fname, id, desc, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,59 +1,72 @@
|
||||
|
||||
static PyObject*
|
||||
py_func_new(PyObject *self, PyObject *args)
|
||||
py_func_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int type, n;
|
||||
PyObject* c;
|
||||
if (!PyArg_ParseTuple(args, "iiO:func_new", &type, &n, &c))
|
||||
if (!PyArg_ParseTuple(args, "iiO:func_new", &type, &n, &c)) {
|
||||
return NULL;
|
||||
}
|
||||
PyArrayObject* coeffs = (PyArrayObject*)c;
|
||||
double* xd = (double*)coeffs->data;
|
||||
size_t lenc = coeffs->dimensions[0];
|
||||
int nn = func_new(type, n, lenc, xd);
|
||||
if (nn < 0) return reportError(nn);
|
||||
if (nn < 0) {
|
||||
return reportError(nn);
|
||||
}
|
||||
return Py_BuildValue("i",nn);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_func_newcombo(PyObject *self, PyObject *args)
|
||||
py_func_newcombo(PyObject* self, PyObject* args)
|
||||
{
|
||||
int type, n, m;
|
||||
if (!PyArg_ParseTuple(args, "iii:func_newcombo", &type, &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "iii:func_newcombo", &type, &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int nn = func_new(type, n, m, 0);
|
||||
if (nn < 0) return reportError(nn);
|
||||
if (nn < 0) {
|
||||
return reportError(nn);
|
||||
}
|
||||
return Py_BuildValue("i",nn);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_func_derivative(PyObject *self, PyObject *args)
|
||||
py_func_derivative(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:func_derivative", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:func_derivative", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int nn = func_derivative(n);
|
||||
if (nn < 0) return reportError(nn);
|
||||
if (nn < 0) {
|
||||
return reportError(nn);
|
||||
}
|
||||
return Py_BuildValue("i",nn);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_func_del(PyObject *self, PyObject *args)
|
||||
py_func_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:func_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:func_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = func_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_func_value(PyObject *self, PyObject *args)
|
||||
py_func_value(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:func_value", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:func_value", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
double r = func_value(n, t);
|
||||
return Py_BuildValue("d",r);
|
||||
}
|
||||
@@ -61,14 +74,15 @@ py_func_value(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_func_write(PyObject *self, PyObject *args)
|
||||
py_func_write(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* arg;
|
||||
char* nm;
|
||||
int lennm;
|
||||
if (!PyArg_ParseTuple(args, "iis:func_write", &n, &lennm, &arg))
|
||||
if (!PyArg_ParseTuple(args, "iis:func_write", &n, &lennm, &arg)) {
|
||||
return NULL;
|
||||
}
|
||||
nm = new char[lennm+1];
|
||||
int iok = func_write(n, lennm, arg, nm);
|
||||
if (iok < 0) {
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
// {
|
||||
// int ixml, ith, ikin;
|
||||
// char *src=0, *id=0;
|
||||
// if (!PyArg_ParseTuple(args, "sisii:buildSolutionFromXML", &src, &ixml,
|
||||
// &id, &ith, &ikin))
|
||||
// if (!PyArg_ParseTuple(args, "sisii:buildSolutionFromXML", &src, &ixml,
|
||||
// &id, &ith, &ikin))
|
||||
// return NULL;
|
||||
// int ok = buildSolutionFromXML(src, ixml, id, ith, ikin);
|
||||
// if (ok == -1) { return reportCanteraError();}
|
||||
// return Py_BuildValue("i",ok);
|
||||
// return Py_BuildValue("i",ok);
|
||||
// }
|
||||
|
||||
static PyObject *
|
||||
ct_get_cantera_error(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
ct_get_cantera_error(PyObject* self, PyObject* args)
|
||||
{
|
||||
char* buf = new char[400];
|
||||
getCanteraError(400, buf);
|
||||
@@ -22,11 +22,13 @@ ct_get_cantera_error(PyObject *self, PyObject *args)
|
||||
return msg;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
ct_refcnt(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
ct_refcnt(PyObject* self, PyObject* args)
|
||||
{
|
||||
PyObject* o;
|
||||
if (!PyArg_ParseTuple(args, "O", &o)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &o)) {
|
||||
return NULL;
|
||||
}
|
||||
PyObject* cnt = Py_BuildValue("i",o->ob_refcnt);
|
||||
return cnt;
|
||||
}
|
||||
@@ -35,18 +37,19 @@ ct_refcnt(PyObject *self, PyObject *args)
|
||||
// ct_print(PyObject *self, PyObject *args)
|
||||
// {
|
||||
// char* msg;
|
||||
// if (!PyArg_ParseTuple(args, "s:print", &msg))
|
||||
// if (!PyArg_ParseTuple(args, "s:print", &msg))
|
||||
// return NULL;
|
||||
// printf(msg);
|
||||
// return Py_BuildValue("i",0);
|
||||
// }
|
||||
|
||||
static PyObject *
|
||||
ct_addDirectory(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
ct_addDirectory(PyObject* self, PyObject* args)
|
||||
{
|
||||
char* dir;
|
||||
if (!PyArg_ParseTuple(args, "s:addDirectory", &dir))
|
||||
if (!PyArg_ParseTuple(args, "s:addDirectory", &dir)) {
|
||||
return NULL;
|
||||
}
|
||||
size_t n = strlen(dir);
|
||||
addCanteraDirectory(n, dir);
|
||||
return Py_BuildValue("i",0);
|
||||
@@ -63,34 +66,40 @@ ct_addDirectory(PyObject *self, PyObject *args)
|
||||
// PyObject* r = Py_BuildValue("s",msg);
|
||||
// return r;
|
||||
// }
|
||||
// else
|
||||
// else
|
||||
// return Py_BuildValue("s","");
|
||||
//}
|
||||
|
||||
static PyObject *
|
||||
ct_ck2cti(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
ct_ck2cti(PyObject* self, PyObject* args)
|
||||
{
|
||||
int iok;
|
||||
char *infile, *thermo, *tran, *idtag;
|
||||
char* infile, *thermo, *tran, *idtag;
|
||||
int debug, validate;
|
||||
if (!PyArg_ParseTuple(args, "ssssii:ck2cti", &infile,
|
||||
&thermo, &tran, &idtag, &debug, &validate))
|
||||
if (!PyArg_ParseTuple(args, "ssssii:ck2cti", &infile,
|
||||
&thermo, &tran, &idtag, &debug, &validate)) {
|
||||
return NULL;
|
||||
}
|
||||
iok = ck_to_cti(infile, thermo, tran, idtag, debug, validate);
|
||||
if (iok == -1) { return reportCanteraError();}
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
ct_writelogfile(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
ct_writelogfile(PyObject* self, PyObject* args)
|
||||
{
|
||||
int iok;
|
||||
char *logfile;
|
||||
if (!PyArg_ParseTuple(args, "s:writelogfile", &logfile))
|
||||
char* logfile;
|
||||
if (!PyArg_ParseTuple(args, "s:writelogfile", &logfile)) {
|
||||
return NULL;
|
||||
}
|
||||
iok = writelogfile(logfile);
|
||||
if (iok == -1) { return reportCanteraError();}
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,171 +3,228 @@
|
||||
*
|
||||
*/
|
||||
static PyObject*
|
||||
kin_newFromXML(PyObject *self, PyObject *args) {
|
||||
kin_newFromXML(PyObject* self, PyObject* args)
|
||||
{
|
||||
int mxml, iphase, neighbor1, neighbor2, neighbor3, neighbor4;
|
||||
if (!PyArg_ParseTuple(args, "iiiiii:newFromXML", &mxml,
|
||||
&iphase, &neighbor1, &neighbor2, &neighbor3, &neighbor4))
|
||||
if (!PyArg_ParseTuple(args, "iiiiii:newFromXML", &mxml,
|
||||
&iphase, &neighbor1, &neighbor2, &neighbor3, &neighbor4)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = int(newKineticsFromXML(mxml, iphase, neighbor1, neighbor2,
|
||||
neighbor3, neighbor4));
|
||||
if (n < 0) return reportError(n);
|
||||
neighbor3, neighbor4));
|
||||
if (n < 0) {
|
||||
return reportError(n);
|
||||
}
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_delete(PyObject *self, PyObject *args)
|
||||
kin_delete(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_delete", &kin)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_delete", &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
delKinetics(kin);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_phase(PyObject *self, PyObject *args) {
|
||||
kin_phase(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, n;
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_phase", &kin, &n)) return NULL;
|
||||
return Py_BuildValue("i",kin_phase(kin, n));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_nspecies(PyObject *self, PyObject *args) {
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nspecies", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_nSpecies(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_rstoichcoeff(PyObject *self, PyObject *args) {
|
||||
int kin, i, k;
|
||||
if (!PyArg_ParseTuple(args, "iii:kin_rstoichcoeff", &kin, &k, &i))
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_phase", &kin, &n)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("d",kin_reactantStoichCoeff(kin, k, i));
|
||||
}
|
||||
return Py_BuildValue("i",kin_phase(kin, n));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_pstoichcoeff(PyObject *self, PyObject *args) {
|
||||
int kin, i, k;
|
||||
if (!PyArg_ParseTuple(args, "iii:kin_pstoichcoeff", &kin, &k, &i))
|
||||
kin_nspecies(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nspecies", &kin)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("d",kin_productStoichCoeff(kin, k, i));
|
||||
}
|
||||
return Py_BuildValue("i",kin_nSpecies(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_nrxns(PyObject *self, PyObject *args) {
|
||||
kin_rstoichcoeff(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, i, k;
|
||||
if (!PyArg_ParseTuple(args, "iii:kin_rstoichcoeff", &kin, &k, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",kin_reactantStoichCoeff(kin, k, i));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_pstoichcoeff(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, i, k;
|
||||
if (!PyArg_ParseTuple(args, "iii:kin_pstoichcoeff", &kin, &k, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",kin_productStoichCoeff(kin, k, i));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_nrxns(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nreactions", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_nReactions(kin));
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nreactions", &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_nReactions(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_nPhases(PyObject *self, PyObject *args) {
|
||||
kin_nPhases(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nPhases", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_nPhases(kin));
|
||||
if (!PyArg_ParseTuple(args, "i:kin_nPhases", &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_nPhases(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_phaseIndex(PyObject *self, PyObject *args) {
|
||||
kin_phaseIndex(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
char* ph;
|
||||
if (!PyArg_ParseTuple(args, "is:kin_phaseIndex", &kin, &ph)) return NULL;
|
||||
return Py_BuildValue("i",kin_phaseIndex(kin, ph));
|
||||
if (!PyArg_ParseTuple(args, "is:kin_phaseIndex", &kin, &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_phaseIndex(kin, ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_reactionPhaseIndex(PyObject *self, PyObject *args) {
|
||||
kin_reactionPhaseIndex(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_reactionPhaseIndex", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_reactionPhaseIndex(kin));
|
||||
if (!PyArg_ParseTuple(args, "i:kin_reactionPhaseIndex", &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_reactionPhaseIndex(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_isrev(PyObject *self, PyObject *args) {
|
||||
kin_isrev(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, i;
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_isrev", &kin, &i)) return NULL;
|
||||
return Py_BuildValue("i",kin_isReversible(kin,i));
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_isrev", &kin, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_isReversible(kin,i));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_rxntype(PyObject *self, PyObject *args) {
|
||||
kin_rxntype(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, i;
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_rxntype", &kin, &i)) return NULL;
|
||||
return Py_BuildValue("i",kin_reactionType(kin,i));
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_rxntype", &kin, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_reactionType(kin,i));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_multiplier(PyObject *self, PyObject *args) {
|
||||
kin_multiplier(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, i;
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_multiplier", &kin, &i)) return NULL;
|
||||
return Py_BuildValue("d",kin_multiplier(kin,i));
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_multiplier", &kin, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",kin_multiplier(kin,i));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_setMultiplier(PyObject *self, PyObject *args) {
|
||||
kin_setMultiplier(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, i;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "iid:kin_setMultiplier", &kin, &i, &v)) return NULL;
|
||||
return Py_BuildValue("i",kin_setMultiplier(kin,i,v));
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
kin_type(PyObject *self, PyObject *args) {
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_type", &kin)) return NULL;
|
||||
return Py_BuildValue("i",kin_type(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_start(PyObject *self, PyObject *args) {
|
||||
int kin, p;
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_start", &kin, &p)) return NULL;
|
||||
return Py_BuildValue("i",kin_start(kin,p));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_speciesIndex(PyObject *self, PyObject *args) {
|
||||
int kin;
|
||||
char *nm, *ph;
|
||||
if (!PyArg_ParseTuple(args, "iss:kin_speciesIndex", &kin, &nm, &ph))
|
||||
if (!PyArg_ParseTuple(args, "iid:kin_setMultiplier", &kin, &i, &v)) {
|
||||
return NULL;
|
||||
return Py_BuildValue("i",kin_speciesIndex(kin,nm,ph));
|
||||
}
|
||||
return Py_BuildValue("i",kin_setMultiplier(kin,i,v));
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
kin_type(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "i:kin_type", &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_type(kin));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_advanceCoverages(PyObject *self, PyObject *args) {
|
||||
kin_start(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, p;
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_start", &kin, &p)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_start(kin,p));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_speciesIndex(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
char* nm, *ph;
|
||||
if (!PyArg_ParseTuple(args, "iss:kin_speciesIndex", &kin, &nm, &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",kin_speciesIndex(kin,nm,ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_advanceCoverages(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
double dt;
|
||||
if (!PyArg_ParseTuple(args, "id:kin_advanceCoverages", &kin, &dt))
|
||||
if (!PyArg_ParseTuple(args, "id:kin_advanceCoverages", &kin, &dt)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = kin_advanceCoverages(kin, dt);
|
||||
if (iok < 0) return reportCanteraError();
|
||||
return Py_BuildValue("i",0);
|
||||
if (iok < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
kin_getarray(PyObject *self, PyObject *args)
|
||||
kin_getarray(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin;
|
||||
int job;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_getarray", &kin, &job))
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:kin_getarray", &kin, &job)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// array attributes
|
||||
int iok = -22;
|
||||
size_t nrxns = kin_nReactions(kin);
|
||||
size_t nsp = kin_nSpecies(kin);
|
||||
size_t ix;
|
||||
if (job < 45 || job >= 90) ix = nrxns; else ix = nsp;
|
||||
|
||||
if (job < 45 || job >= 90) {
|
||||
ix = nrxns;
|
||||
} else {
|
||||
ix = nsp;
|
||||
}
|
||||
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nix = ix;
|
||||
PyArrayObject* x = (PyArrayObject*)PyArray_SimpleNew(1, &nix, PyArray_DOUBLE);
|
||||
#else
|
||||
int nix = int(ix);
|
||||
PyArrayObject* x =
|
||||
PyArrayObject* x =
|
||||
(PyArrayObject*)PyArray_FromDims(1, &nix, PyArray_DOUBLE);
|
||||
#endif
|
||||
double* xd = (double*)x->data;
|
||||
@@ -231,22 +288,23 @@ kin_getarray(PyObject *self, PyObject *args)
|
||||
}
|
||||
if (iok >= 0) {
|
||||
return PyArray_Return(x);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return reportError(iok);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// string attributes
|
||||
// string attributes
|
||||
static PyObject*
|
||||
kin_getstring(PyObject *self, PyObject *args)
|
||||
kin_getstring(PyObject* self, PyObject* args)
|
||||
{
|
||||
int kin, job, i, iok = -3;
|
||||
int buflen;
|
||||
char* output_buf = 0;
|
||||
if (!PyArg_ParseTuple(args, "iii:kin_getstring", &kin, &job, &i))
|
||||
if (!PyArg_ParseTuple(args, "iii:kin_getstring", &kin, &job, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
switch (job) {
|
||||
case 1:
|
||||
buflen = 80;
|
||||
@@ -262,10 +320,10 @@ kin_getstring(PyObject *self, PyObject *args)
|
||||
return str;
|
||||
}
|
||||
delete output_buf;
|
||||
if (iok == -1)
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
else {
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Unknown string attribute");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,354 +1,423 @@
|
||||
|
||||
static PyObject *
|
||||
py_mix_new(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
_val = mix_new();
|
||||
_val = mix_new();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_del(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_del", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_del", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_del(i);
|
||||
if (int(_val) < 0) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_del(i);
|
||||
if (int(_val) < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_addPhase(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_addPhase(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
int j;
|
||||
double moles;
|
||||
if (!PyArg_ParseTuple(args, "iid:mix_addPhase", &i, &j, &moles))
|
||||
if (!PyArg_ParseTuple(args, "iid:mix_addPhase", &i, &j, &moles)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_addPhase(i,j,moles);
|
||||
if (int(_val) < 0) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_addPhase(i,j,moles);
|
||||
if (int(_val) < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_init(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_init(PyObject* self, PyObject* args)
|
||||
{
|
||||
int i;
|
||||
int _val;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_init", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_init", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_init(i);
|
||||
if (_val < 0) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_init(i);
|
||||
if (_val < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_nElements(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_nElements(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_nElements", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_nElements", &i)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
_val = int(mix_nElements(i));
|
||||
if (_val < -900) return reportCanteraError();
|
||||
if (_val < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_elementIndex(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_elementIndex(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
char* name;
|
||||
if (!PyArg_ParseTuple(args, "is:mix_elementIndex", &i, &name))
|
||||
if (!PyArg_ParseTuple(args, "is:mix_elementIndex", &i, &name)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
_val = int(mix_elementIndex(i,name));
|
||||
if (_val < -900) return reportCanteraError();
|
||||
if (_val < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_nSpecies(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_nSpecies(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_nSpecies", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_nSpecies", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = int(mix_nSpecies(i));
|
||||
if (_val < -900) return reportCanteraError();
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_speciesIndex(PyObject *self, PyObject *args)
|
||||
{
|
||||
size_t _val;
|
||||
int i, k, p;
|
||||
if (!PyArg_ParseTuple(args, "iii:mix_speciesIndex", &i, &k, &p))
|
||||
return NULL;
|
||||
|
||||
_val = mix_speciesIndex(i,k,p);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
_val = int(mix_nSpecies(i));
|
||||
if (_val < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_nAtoms(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_speciesIndex(PyObject* self, PyObject* args)
|
||||
{
|
||||
size_t _val;
|
||||
int i, k, p;
|
||||
if (!PyArg_ParseTuple(args, "iii:mix_speciesIndex", &i, &k, &p)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_val = mix_speciesIndex(i,k,p);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_mix_nAtoms(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
int k;
|
||||
int m;
|
||||
if (!PyArg_ParseTuple(args, "iii:mix_nAtoms", &i, &k, &m))
|
||||
if (!PyArg_ParseTuple(args, "iii:mix_nAtoms", &i, &k, &m)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_nAtoms(i,k,m);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_nAtoms(i,k,m);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_setTemperature(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_setTemperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:mix_setTemperature", &i, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:mix_setTemperature", &i, &t)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_setTemperature(i,t);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_setTemperature(i,t);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_minTemp(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_minTemp(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_minTemp", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_minTemp", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_minTemp(i);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_minTemp(i);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_maxTemp(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_maxTemp(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_maxTemp", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_maxTemp", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_maxTemp(i);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_maxTemp(i);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_charge(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_charge(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_charge", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_charge", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_charge(i);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_charge(i);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_phaseCharge(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_phaseCharge(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
int p;
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_phaseCharge", &i, &p))
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_phaseCharge", &i, &p)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_phaseCharge(i,p);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_phaseCharge(i,p);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_temperature(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_temperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_temperature", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_temperature", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_temperature(i);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_temperature(i);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_setPressure(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_setPressure(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
double p;
|
||||
if (!PyArg_ParseTuple(args, "id:mix_setPressure", &i, &p))
|
||||
if (!PyArg_ParseTuple(args, "id:mix_setPressure", &i, &p)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_setPressure(i,p);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_setPressure(i,p);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_pressure(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_pressure(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:mix_pressure", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:mix_pressure", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_pressure(i);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_pressure(i);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_phaseMoles(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_phaseMoles(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_phaseMoles", &i, &n))
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_phaseMoles", &i, &n)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_phaseMoles(i,n);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_phaseMoles(i,n);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_setPhaseMoles(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_setPhaseMoles(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "iid:mix_setPhaseMoles", &i, &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "iid:mix_setPhaseMoles", &i, &n, &v)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_setPhaseMoles(i,n,v);
|
||||
if (int(_val) < 0) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_setPhaseMoles(i,n,v);
|
||||
if (int(_val) < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_speciesMoles(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_speciesMoles(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
int k;
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_speciesMoles", &i, &k))
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_speciesMoles", &i, &k)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_speciesMoles(i,k);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_speciesMoles(i,k);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_elementMoles(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_elementMoles(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
int m;
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_elementMoles", &i, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:mix_elementMoles", &i, &m)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
_val = mix_elementMoles(i,m);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_setMoles(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_setMoles(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
PyObject* n;
|
||||
if (!PyArg_ParseTuple(args, "iO:mix_setMoles", &i, &n))
|
||||
if (!PyArg_ParseTuple(args, "iO:mix_setMoles", &i, &n)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
PyArrayObject* n_array = (PyArrayObject*)n;
|
||||
double* n_data = (double*)n_array->data;
|
||||
size_t n_len = n_array->dimensions[0];
|
||||
|
||||
_val = mix_setMoles(i,n_len,n_data);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
_val = mix_setMoles(i,n_len,n_data);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_setMolesByName(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_setMolesByName(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
char* n;
|
||||
if (!PyArg_ParseTuple(args, "is:mix_setMolesByName", &i, &n))
|
||||
if (!PyArg_ParseTuple(args, "is:mix_setMolesByName", &i, &n)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_setMolesByName(i,n);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_setMolesByName(i,n);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_mix_equilibrate(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_equilibrate(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
char* XY;
|
||||
double err;
|
||||
int maxsteps, maxiter, loglevel;
|
||||
if (!PyArg_ParseTuple(args, "isdiii:mix_equilibrate", &i, &XY, &err,
|
||||
&maxsteps, &maxiter, &loglevel))
|
||||
if (!PyArg_ParseTuple(args, "isdiii:mix_equilibrate", &i, &XY, &err,
|
||||
&maxsteps, &maxiter, &loglevel)) {
|
||||
return NULL;
|
||||
|
||||
_val = mix_equilibrate(i,XY,err,maxsteps,maxiter,loglevel);
|
||||
if (int(_val) < -900) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = mix_equilibrate(i,XY,err,maxsteps,maxiter,loglevel);
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_vcs_equilibrate(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_vcs_equilibrate(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
@@ -360,37 +429,40 @@ py_mix_vcs_equilibrate(PyObject *self, PyObject *args)
|
||||
int maxsteps;
|
||||
int maxiter;
|
||||
int loglevel;
|
||||
if (!PyArg_ParseTuple(args, "isiiidiii:mix_vcs_equilibrate", &i, &XY,
|
||||
&estimateEquil, &printLvl, &solver,
|
||||
&rtol, &maxsteps, &maxiter, &loglevel)) {
|
||||
return NULL;
|
||||
if (!PyArg_ParseTuple(args, "isiiidiii:mix_vcs_equilibrate", &i, &XY,
|
||||
&estimateEquil, &printLvl, &solver,
|
||||
&rtol, &maxsteps, &maxiter, &loglevel)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
_val = mix_vcs_equilibrate(i, XY, estimateEquil, printLvl, solver,
|
||||
rtol, maxsteps, maxiter, loglevel);
|
||||
rtol, maxsteps, maxiter, loglevel);
|
||||
|
||||
if (int(_val) < -900) {
|
||||
return reportCanteraError();
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d", _val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_mix_getChemPotentials(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_mix_getChemPotentials(PyObject* self, PyObject* args)
|
||||
{
|
||||
int i;
|
||||
int _val;
|
||||
PyObject* mu;
|
||||
if (!PyArg_ParseTuple(args, "iO:mix_getChemPotentials", &i, &mu))
|
||||
if (!PyArg_ParseTuple(args, "iO:mix_getChemPotentials", &i, &mu)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyArrayObject* mu_array = (PyArrayObject*)mu;
|
||||
double* mu_data = (double*)mu_array->data;
|
||||
size_t mu_len = mu_array->dimensions[0];
|
||||
|
||||
_val = mix_getChemPotentials(i, mu_len, mu_data);
|
||||
if (int(_val) < 0) return reportCanteraError();
|
||||
_val = mix_getChemPotentials(i, mu_len, mu_data);
|
||||
if (int(_val) < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,65 +1,92 @@
|
||||
|
||||
static PyObject*
|
||||
py_temperature(PyObject *self, PyObject *args) {
|
||||
py_temperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
if (!PyArg_ParseTuple(args, "i:py_temperature", &ph)) return NULL;
|
||||
return Py_BuildValue("d",phase_temperature(ph));
|
||||
if (!PyArg_ParseTuple(args, "i:py_temperature", &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_temperature(ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_density(PyObject *self, PyObject *args) {
|
||||
py_density(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
if (!PyArg_ParseTuple(args, "i:py_density", &ph)) return NULL;
|
||||
return Py_BuildValue("d",phase_density(ph));
|
||||
if (!PyArg_ParseTuple(args, "i:py_density", &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_density(ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_molardensity(PyObject *self, PyObject *args) {
|
||||
py_molardensity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
if (!PyArg_ParseTuple(args, "i:py_molardensity", &ph)) return NULL;
|
||||
return Py_BuildValue("d",phase_molarDensity(ph));
|
||||
if (!PyArg_ParseTuple(args, "i:py_molardensity", &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_molarDensity(ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_meanmolwt(PyObject *self, PyObject *args) {
|
||||
py_meanmolwt(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
if (!PyArg_ParseTuple(args, "i:py_meanmolwt", &ph)) return NULL;
|
||||
return Py_BuildValue("d",phase_meanMolecularWeight(ph));
|
||||
if (!PyArg_ParseTuple(args, "i:py_meanmolwt", &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_meanMolecularWeight(ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_molefraction(PyObject *self, PyObject *args) {
|
||||
py_molefraction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph, k;
|
||||
if (!PyArg_ParseTuple(args, "ii:py_molefraction", &ph, &k)) return NULL;
|
||||
return Py_BuildValue("d",phase_moleFraction(ph, k));
|
||||
if (!PyArg_ParseTuple(args, "ii:py_molefraction", &ph, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_moleFraction(ph, k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_massfraction(PyObject *self, PyObject *args) {
|
||||
py_massfraction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph, k;
|
||||
if (!PyArg_ParseTuple(args, "ii:py_massfraction", &ph, &k)) return NULL;
|
||||
return Py_BuildValue("d",phase_massFraction(ph, k));
|
||||
if (!PyArg_ParseTuple(args, "ii:py_massfraction", &ph, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_massFraction(ph, k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_nelements(PyObject *self, PyObject *args) {
|
||||
py_nelements(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
if (!PyArg_ParseTuple(args, "i:py_nelements", &ph)) return NULL;
|
||||
return Py_BuildValue("i",phase_nElements(ph));
|
||||
if (!PyArg_ParseTuple(args, "i:py_nelements", &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",phase_nElements(ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_nspecies(PyObject *self, PyObject *args) {
|
||||
py_nspecies(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
if (!PyArg_ParseTuple(args, "i:py_nspecies", &ph)) return NULL;
|
||||
return Py_BuildValue("i",phase_nSpecies(ph));
|
||||
if (!PyArg_ParseTuple(args, "i:py_nspecies", &ph)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",phase_nSpecies(ph));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_natoms(PyObject *self, PyObject *args) {
|
||||
py_natoms(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph, k, m;
|
||||
if (!PyArg_ParseTuple(args, "iii:py_natoms", &ph, &k, &m)) return NULL;
|
||||
return Py_BuildValue("d",phase_nAtoms(ph, k, m));
|
||||
if (!PyArg_ParseTuple(args, "iii:py_natoms", &ph, &k, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",phase_nAtoms(ph, k, m));
|
||||
}
|
||||
|
||||
// static PyObject*
|
||||
@@ -67,7 +94,7 @@ py_natoms(PyObject *self, PyObject *args) {
|
||||
// int ph;
|
||||
// char* name;
|
||||
// double wt;
|
||||
// if (!PyArg_ParseTuple(args, "isd:py_addelement", &ph, &name, &wt))
|
||||
// if (!PyArg_ParseTuple(args, "isd:py_addelement", &ph, &name, &wt))
|
||||
// return NULL;
|
||||
// int ok = phase_addElement(ph, name, wt);
|
||||
// if (ok < 0) return reportError(ok);
|
||||
@@ -75,37 +102,47 @@ py_natoms(PyObject *self, PyObject *args) {
|
||||
// }
|
||||
|
||||
static PyObject*
|
||||
py_elementindex(PyObject *self, PyObject *args) {
|
||||
py_elementindex(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
char* nm;
|
||||
if (!PyArg_ParseTuple(args, "is:py_elementindex", &ph, &nm)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "is:py_elementindex", &ph, &nm)) {
|
||||
return NULL;
|
||||
}
|
||||
size_t k = phase_elementIndex(ph,nm);
|
||||
return Py_BuildValue("i",k);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_speciesindex(PyObject *self, PyObject *args) {
|
||||
py_speciesindex(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
char* nm;
|
||||
if (!PyArg_ParseTuple(args, "is:py_speciesindex", &ph, &nm)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "is:py_speciesindex", &ph, &nm)) {
|
||||
return NULL;
|
||||
}
|
||||
size_t k = phase_speciesIndex(ph,nm);
|
||||
return Py_BuildValue("i",k);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_report(PyObject *self, PyObject *args) {
|
||||
py_report(PyObject* self, PyObject* args)
|
||||
{
|
||||
int th, show_thermo;
|
||||
int buflen = 400;
|
||||
char* output_buf = new char[buflen];
|
||||
if (!PyArg_ParseTuple(args, "ii:py_report", &th, &show_thermo))
|
||||
char* output_buf = new char[buflen];
|
||||
if (!PyArg_ParseTuple(args, "ii:py_report", &th, &show_thermo)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = phase_report(th, buflen, output_buf, show_thermo);
|
||||
if (iok < -1 && iok != -999) {
|
||||
delete output_buf;
|
||||
output_buf = new char[-iok];
|
||||
iok = phase_report(th, -iok, output_buf, show_thermo);
|
||||
}
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
PyObject* s = Py_BuildValue("s",output_buf);
|
||||
delete output_buf;
|
||||
return s;
|
||||
@@ -113,13 +150,14 @@ py_report(PyObject *self, PyObject *args) {
|
||||
|
||||
|
||||
static PyObject*
|
||||
phase_getarray(PyObject *self, PyObject *args)
|
||||
phase_getarray(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
int job;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:phase_getarray", &ph, &job))
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:phase_getarray", &ph, &job)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// array attributes
|
||||
int iok = -22;
|
||||
@@ -133,7 +171,7 @@ phase_getarray(PyObject *self, PyObject *args)
|
||||
x = (PyArrayObject*)PyArray_SimpleNew(1, &nnn, PyArray_DOUBLE);
|
||||
Py_INCREF(x);
|
||||
#else
|
||||
int nnn = int(nsp);
|
||||
int nnn = int(nsp);
|
||||
x = (PyArrayObject*)PyArray_FromDims(1, &nnn, PyArray_DOUBLE);
|
||||
#endif
|
||||
xd = (double*)x->data;
|
||||
@@ -146,19 +184,18 @@ phase_getarray(PyObject *self, PyObject *args)
|
||||
break;
|
||||
case 22:
|
||||
iok = phase_getMolecularWeights(ph,nsp,xd);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
size_t nel = phase_nElements(ph);
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nnn = nel;
|
||||
x = (PyArrayObject*)PyArray_SimpleNew(1, &nnn, PyArray_DOUBLE);
|
||||
#else
|
||||
int nnn = int(nel);
|
||||
int nnn = int(nel);
|
||||
x = (PyArrayObject*)PyArray_FromDims(1, &nnn, PyArray_DOUBLE);
|
||||
#endif
|
||||
xd = (double*)x->data;
|
||||
@@ -173,23 +210,23 @@ phase_getarray(PyObject *self, PyObject *args)
|
||||
|
||||
if (iok >= 0) {
|
||||
return PyArray_Return(x);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Unknown array attribute");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// string attributes
|
||||
// string attributes
|
||||
static PyObject*
|
||||
phase_getstring(PyObject *self, PyObject *args)
|
||||
phase_getstring(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph, job, iok = -1;
|
||||
int k;
|
||||
int buflen;
|
||||
char* output_buf = 0;
|
||||
if (!PyArg_ParseTuple(args, "iii:phase_getstring", &ph, &job, &k))
|
||||
if (!PyArg_ParseTuple(args, "iii:phase_getstring", &ph, &job, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
switch (job) {
|
||||
case 1:
|
||||
buflen = 20;
|
||||
@@ -210,106 +247,114 @@ phase_getstring(PyObject *self, PyObject *args)
|
||||
return str;
|
||||
}
|
||||
delete output_buf;
|
||||
if (iok == -1)
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
else {
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Unknown string attribute");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
phase_setfp(PyObject *self, PyObject *args)
|
||||
phase_setfp(PyObject* self, PyObject* args)
|
||||
{
|
||||
double vv;
|
||||
int iok = -2;
|
||||
int ph;
|
||||
int job;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iid:phase_getfp", &ph, &job, &vv))
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iid:phase_getfp", &ph, &job, &vv)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// set floating-point attributes
|
||||
switch (job) {
|
||||
case 1:
|
||||
iok = phase_setTemperature(ph, vv); break;
|
||||
iok = phase_setTemperature(ph, vv);
|
||||
break;
|
||||
case 2:
|
||||
iok = phase_setDensity(ph, vv); break;
|
||||
iok = phase_setDensity(ph, vv);
|
||||
break;
|
||||
case 3:
|
||||
iok = phase_setMolarDensity(ph, vv); break;
|
||||
iok = phase_setMolarDensity(ph, vv);
|
||||
break;
|
||||
default:
|
||||
iok = -10;
|
||||
iok = -10;
|
||||
}
|
||||
if (iok >= 0)
|
||||
return Py_BuildValue("i",iok);
|
||||
else {
|
||||
if (iok >= 0) {
|
||||
return Py_BuildValue("i",iok);
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Unknown floating-point attribute");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
phase_setarray(PyObject *self, PyObject *args)
|
||||
phase_setarray(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
int job;
|
||||
int norm;
|
||||
int iok;
|
||||
PyObject* seq;
|
||||
if (!PyArg_ParseTuple(args, "iiiO:phase_setarray", &ph, &job, &norm, &seq))
|
||||
if (!PyArg_ParseTuple(args, "iiiO:phase_setarray", &ph, &job, &norm, &seq)) {
|
||||
return NULL;
|
||||
}
|
||||
PyArrayObject* a = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(seq, PyArray_DOUBLE, 1, 1);
|
||||
PyArray_ContiguousFromObject(seq, PyArray_DOUBLE, 1, 1);
|
||||
double* xd = (double*)a->data;
|
||||
size_t len = a->dimensions[0];
|
||||
switch (job) {
|
||||
case 1:
|
||||
iok = phase_setMoleFractions(ph, len, xd, norm);
|
||||
iok = phase_setMoleFractions(ph, len, xd, norm);
|
||||
break;
|
||||
case 2:
|
||||
iok = phase_setMassFractions(ph, len, xd, norm);
|
||||
iok = phase_setMassFractions(ph, len, xd, norm);
|
||||
break;
|
||||
default:
|
||||
iok = -10;
|
||||
}
|
||||
Py_DECREF(a);
|
||||
if (iok >= 0)
|
||||
if (iok >= 0) {
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1)
|
||||
}
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
else {
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject, "Error in phase_setarray");
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
phase_setstring(PyObject *self, PyObject *args)
|
||||
phase_setstring(PyObject* self, PyObject* args)
|
||||
{
|
||||
int ph;
|
||||
int job;
|
||||
int iok;
|
||||
char* str;
|
||||
if (!PyArg_ParseTuple(args, "iis:phase_setstring", &ph, &job, &str))
|
||||
if (!PyArg_ParseTuple(args, "iis:phase_setstring", &ph, &job, &str)) {
|
||||
return NULL;
|
||||
}
|
||||
switch (job) {
|
||||
case 1:
|
||||
iok = phase_setMoleFractionsByName(ph, str);
|
||||
iok = phase_setMoleFractionsByName(ph, str);
|
||||
break;
|
||||
case 2:
|
||||
iok = phase_setMassFractionsByName(ph, str);
|
||||
iok = phase_setMassFractionsByName(ph, str);
|
||||
break;
|
||||
default:
|
||||
iok = -10;
|
||||
}
|
||||
if (iok >= 0)
|
||||
if (iok >= 0) {
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1)
|
||||
}
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
else {
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject, "Error in phase_setstring");
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +1,41 @@
|
||||
|
||||
static PyObject*
|
||||
py_reactor_new(PyObject *self, PyObject *args)
|
||||
py_reactor_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int type;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_new", &type))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_new", &type)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = reactor_new(type);
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_del(PyObject *self, PyObject *args)
|
||||
py_reactor_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactor_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_setInitialVolume(PyObject *self, PyObject *args)
|
||||
py_reactor_setInitialVolume(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:reactor_setInitialVolume", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:reactor_setInitialVolume", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactor_setInitialVolume(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
@@ -45,78 +52,94 @@ py_reactor_setInitialVolume(PyObject *self, PyObject *args)
|
||||
// }
|
||||
|
||||
static PyObject*
|
||||
py_reactor_setEnergy(PyObject *self, PyObject *args)
|
||||
py_reactor_setEnergy(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, eflag;
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_setEnergy", &n, &eflag))
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_setEnergy", &n, &eflag)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactor_setEnergy(n, eflag);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_setThermoMgr(PyObject *self, PyObject *args)
|
||||
py_reactor_setThermoMgr(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
int th;
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_setThermoMgr", &n, &th))
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_setThermoMgr", &n, &th)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactor_setThermoMgr(n, th);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_setKineticsMgr(PyObject *self, PyObject *args)
|
||||
py_reactor_setKineticsMgr(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
int kin;
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_setKineticsMgr", &n, &kin))
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_setKineticsMgr", &n, &kin)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactor_setKineticsMgr(n, kin);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_reactor_nSensParams(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_reactor_nSensParams(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_nSensParams", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_nSensParams", &i)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
_val = int(reactor_nSensParams(i));
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_reactor_addSensitivityReaction(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_reactor_addSensitivityReaction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
int rxn;
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_addSensitivityReaction", &i, &rxn))
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_addSensitivityReaction", &i, &rxn)) {
|
||||
return NULL;
|
||||
|
||||
_val = reactor_addSensitivityReaction(i,rxn);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = reactor_addSensitivityReaction(i,rxn);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_flowReactor_setMassFlowRate(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_flowReactor_setMassFlowRate(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
double mdot;
|
||||
if (!PyArg_ParseTuple(args, "id:flowReactor_setMassFlowRate", &i, &mdot))
|
||||
if (!PyArg_ParseTuple(args, "id:flowReactor_setMassFlowRate", &i, &mdot)) {
|
||||
return NULL;
|
||||
|
||||
_val = flowReactor_setMassFlowRate(i,mdot);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = flowReactor_setMassFlowRate(i,mdot);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
@@ -154,137 +177,156 @@ py_flowReactor_setMassFlowRate(PyObject *self, PyObject *args)
|
||||
// }
|
||||
|
||||
static PyObject*
|
||||
py_reactor_mass(PyObject *self, PyObject *args)
|
||||
py_reactor_mass(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_mass", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_mass", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double m = reactor_mass(n);
|
||||
return Py_BuildValue("d",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_volume(PyObject *self, PyObject *args)
|
||||
py_reactor_volume(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_volume", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_volume", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double v = reactor_volume(n);
|
||||
return Py_BuildValue("d",v);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_density(PyObject *self, PyObject *args)
|
||||
py_reactor_density(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_density", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_density", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double rho = reactor_density(n);
|
||||
return Py_BuildValue("d",rho);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_temperature(PyObject *self, PyObject *args)
|
||||
py_reactor_temperature(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_temperature", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_temperature", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double t = reactor_temperature(n);
|
||||
return Py_BuildValue("d",t);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_enthalpy_mass(PyObject *self, PyObject *args)
|
||||
py_reactor_enthalpy_mass(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_enthalpy_mass", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_enthalpy_mass", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double h = reactor_enthalpy_mass(n);
|
||||
return Py_BuildValue("d",h);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_intEnergy_mass(PyObject *self, PyObject *args)
|
||||
py_reactor_intEnergy_mass(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_intEnergy_mass", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_intEnergy_mass", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double u = reactor_intEnergy_mass(n);
|
||||
return Py_BuildValue("d",u);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_pressure(PyObject *self, PyObject *args)
|
||||
py_reactor_pressure(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_pressure", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactor_pressure", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double p = reactor_pressure(n);
|
||||
return Py_BuildValue("d",p);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactor_massFraction(PyObject *self, PyObject *args)
|
||||
py_reactor_massFraction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
int k;
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_massFraction", &n, &k))
|
||||
if (!PyArg_ParseTuple(args, "ii:reactor_massFraction", &n, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
double y = reactor_massFraction(n, k);
|
||||
return Py_BuildValue("d",y);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_new(PyObject *self, PyObject *args)
|
||||
py_flowdev_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int type;
|
||||
if (!PyArg_ParseTuple(args, "i:flowdev_new", &type))
|
||||
if (!PyArg_ParseTuple(args, "i:flowdev_new", &type)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = flowdev_new(type);
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_del(PyObject *self, PyObject *args)
|
||||
py_flowdev_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:flowdev_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:flowdev_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flowdev_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_install(PyObject *self, PyObject *args)
|
||||
py_flowdev_install(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, r1, r2;
|
||||
if (!PyArg_ParseTuple(args, "iii:flowdev_install", &n, &r1, &r2))
|
||||
if (!PyArg_ParseTuple(args, "iii:flowdev_install", &n, &r1, &r2)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flowdev_install(n, r1, r2);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_setMaster(PyObject *self, PyObject *args)
|
||||
py_flowdev_setMaster(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:flowdev_setMaster", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:flowdev_setMaster", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flowdev_setMaster(n, m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_massFlowRate(PyObject *self, PyObject *args)
|
||||
py_flowdev_massFlowRate(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:flowdev_massFlowRate", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:flowdev_massFlowRate", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
double mdot = flowdev_massFlowRate(n, t);
|
||||
return Py_BuildValue("d",mdot);
|
||||
}
|
||||
@@ -300,372 +342,447 @@ py_flowdev_massFlowRate(PyObject *self, PyObject *args)
|
||||
// }
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_setMassFlowRate(PyObject *self, PyObject *args)
|
||||
py_flowdev_setMassFlowRate(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double mdot;
|
||||
if (!PyArg_ParseTuple(args, "id:flowdev_setMassFlowRate", &n, &mdot))
|
||||
if (!PyArg_ParseTuple(args, "id:flowdev_setMassFlowRate", &n, &mdot)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flowdev_setMassFlowRate(n, mdot);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_setParameters(PyObject *self, PyObject *args)
|
||||
py_flowdev_setParameters(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, sz;
|
||||
PyObject* c;
|
||||
if (!PyArg_ParseTuple(args, "iiO:flowdev_setParameters", &n, &sz, &c))
|
||||
if (!PyArg_ParseTuple(args, "iiO:flowdev_setParameters", &n, &sz, &c)) {
|
||||
return NULL;
|
||||
}
|
||||
PyArrayObject* ca = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(c, PyArray_DOUBLE, 1, 1);
|
||||
PyArray_ContiguousFromObject(c, PyArray_DOUBLE, 1, 1);
|
||||
double* x = (double*)ca->data;
|
||||
int iok = flowdev_setParameters(n, sz, x);
|
||||
Py_DECREF(ca);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_setFunction(PyObject *self, PyObject *args)
|
||||
py_flowdev_setFunction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:flowdev_setFunction", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:flowdev_setFunction", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flowdev_setFunction(n, m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_flowdev_ready(PyObject *self, PyObject *args)
|
||||
py_flowdev_ready(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:flowdev_ready", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:flowdev_ready", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = flowdev_ready(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_wall_new(PyObject *self, PyObject *args)
|
||||
py_wall_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int type;
|
||||
if (!PyArg_ParseTuple(args, "i:wall_new", &type))
|
||||
if (!PyArg_ParseTuple(args, "i:wall_new", &type)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = wall_new(type);
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_del(PyObject *self, PyObject *args)
|
||||
py_wall_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:wall_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:wall_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_install(PyObject *self, PyObject *args)
|
||||
py_wall_install(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, r1, r2;
|
||||
if (!PyArg_ParseTuple(args, "iii:wall_install", &n, &r1, &r2))
|
||||
if (!PyArg_ParseTuple(args, "iii:wall_install", &n, &r1, &r2)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_install(n, r1, r2);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setkinetics(PyObject *self, PyObject *args)
|
||||
py_wall_setkinetics(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, k1, k2;
|
||||
if (!PyArg_ParseTuple(args, "iii:wall_setkinetics", &n, &k1, &k2))
|
||||
if (!PyArg_ParseTuple(args, "iii:wall_setkinetics", &n, &k1, &k2)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setkinetics(n, k1, k2);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_vdot(PyObject *self, PyObject *args)
|
||||
py_wall_vdot(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_vdot", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:wall_vdot", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
double vdt = wall_vdot(n,t);
|
||||
return Py_BuildValue("d",vdt);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_Q(PyObject *self, PyObject *args)
|
||||
py_wall_Q(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_Q", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:wall_Q", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",wall_Q(n, t));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_area(PyObject *self, PyObject *args)
|
||||
py_wall_area(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:wall_area", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:wall_area", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",wall_area(n));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setArea(PyObject *self, PyObject *args)
|
||||
py_wall_setArea(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double area;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setArea", &n, &area))
|
||||
double area;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setArea", &n, &area)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setArea(n, area);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setThermalResistance(PyObject *self, PyObject *args)
|
||||
py_wall_setThermalResistance(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double rth;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setThermalResistance", &n, &rth))
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setThermalResistance", &n, &rth)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setThermalResistance(n,rth);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setHeatTransferCoeff(PyObject *self, PyObject *args)
|
||||
py_wall_setHeatTransferCoeff(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setHeatTransferCoeff", &n, &u))
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setHeatTransferCoeff", &n, &u)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setHeatTransferCoeff(n,u);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setEmissivity(PyObject *self, PyObject *args)
|
||||
py_wall_setEmissivity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double epsilon;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setEmissivity", &n, &epsilon))
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setEmissivity", &n, &epsilon)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setEmissivity(n,epsilon);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setExpansionRateCoeff(PyObject *self, PyObject *args)
|
||||
py_wall_setExpansionRateCoeff(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double k;
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setExpansionRateCoeff", &n, &k))
|
||||
if (!PyArg_ParseTuple(args, "id:wall_setExpansionRateCoeff", &n, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setExpansionRateCoeff(n,k);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setVelocity(PyObject *self, PyObject *args)
|
||||
py_wall_setVelocity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:wall_setVelocity", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:wall_setVelocity", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setVelocity(n,m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_setHeatFlux(PyObject *self, PyObject *args)
|
||||
py_wall_setHeatFlux(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:wall_setHeatFlux", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:wall_setHeatFlux", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_setHeatFlux(n,m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_wall_ready(PyObject *self, PyObject *args)
|
||||
py_wall_ready(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:wall_ready", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:wall_ready", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = wall_ready(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
py_wall_addSensitivityReaction(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_wall_addSensitivityReaction(PyObject* self, PyObject* args)
|
||||
{
|
||||
int _val;
|
||||
int i;
|
||||
int lr;
|
||||
int rxn;
|
||||
if (!PyArg_ParseTuple(args, "iii:wall_addSensitivityReaction", &i, &lr, &rxn))
|
||||
if (!PyArg_ParseTuple(args, "iii:wall_addSensitivityReaction", &i, &lr, &rxn)) {
|
||||
return NULL;
|
||||
|
||||
_val = wall_addSensitivityReaction(i,lr,rxn);
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
}
|
||||
|
||||
_val = wall_addSensitivityReaction(i,lr,rxn);
|
||||
if (int(_val) == -1) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",_val);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_new(PyObject *self, PyObject *args)
|
||||
py_reactornet_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n = reactornet_new();
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_del(PyObject *self, PyObject *args)
|
||||
py_reactornet_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactornet_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_setTolerances(PyObject *self, PyObject *args)
|
||||
py_reactornet_setTolerances(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double rtol, atol;
|
||||
if (!PyArg_ParseTuple(args, "idd:reactornet_setTolerances", &n, &rtol, &atol))
|
||||
if (!PyArg_ParseTuple(args, "idd:reactornet_setTolerances", &n, &rtol, &atol)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactornet_setTolerances(n, rtol, atol);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_setSensitivityTolerances(PyObject *self, PyObject *args)
|
||||
py_reactornet_setSensitivityTolerances(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double rtol, atol;
|
||||
if (!PyArg_ParseTuple(args, "idd:reactornet_setSensitivityTolerances", &n, &rtol, &atol))
|
||||
if (!PyArg_ParseTuple(args, "idd:reactornet_setSensitivityTolerances", &n, &rtol, &atol)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactornet_setSensitivityTolerances(n, rtol, atol);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_setInitialTime(PyObject *self, PyObject *args)
|
||||
py_reactornet_setInitialTime(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:reactornet_setInitialTime", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:reactornet_setInitialTime", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactornet_setInitialTime(n, t);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_time(PyObject *self, PyObject *args)
|
||||
py_reactornet_time(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_time", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_time", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double t = reactornet_time(n);
|
||||
return Py_BuildValue("d",t);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_addreactor(PyObject *self, PyObject *args)
|
||||
py_reactornet_addreactor(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:reactornet_addreactor", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:reactornet_addreactor", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactornet_addreactor(n, m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_advance(PyObject *self, PyObject *args)
|
||||
py_reactornet_advance(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:reactornet_advance", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:reactornet_advance", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = reactornet_advance(n, t);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_reactornet_step(PyObject *self, PyObject *args)
|
||||
py_reactornet_step(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double t;
|
||||
if (!PyArg_ParseTuple(args, "id:reactornet_step", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "id:reactornet_step", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",reactornet_step(n, t));
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_reactornet_rtol(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_reactornet_rtol(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_rtol", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_rtol", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = reactornet_rtol(i);
|
||||
}
|
||||
|
||||
_val = reactornet_rtol(i);
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_reactornet_atol(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_reactornet_atol(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_atol", &i))
|
||||
if (!PyArg_ParseTuple(args, "i:reactornet_atol", &i)) {
|
||||
return NULL;
|
||||
|
||||
_val = reactornet_atol(i);
|
||||
}
|
||||
|
||||
_val = reactornet_atol(i);
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
py_reactornet_sensitivity(PyObject *self, PyObject *args)
|
||||
static PyObject*
|
||||
py_reactornet_sensitivity(PyObject* self, PyObject* args)
|
||||
{
|
||||
double _val;
|
||||
int i;
|
||||
char* v;
|
||||
int p, r;
|
||||
if (!PyArg_ParseTuple(args, "isii:reactornet_sensitivity", &i, &v, &p, &r))
|
||||
if (!PyArg_ParseTuple(args, "isii:reactornet_sensitivity", &i, &v, &p, &r)) {
|
||||
return NULL;
|
||||
|
||||
_val = reactornet_sensitivity(i,v,p,r);
|
||||
}
|
||||
|
||||
_val = reactornet_sensitivity(i,v,p,r);
|
||||
return Py_BuildValue("d",_val);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,295 +1,368 @@
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_new(PyObject *self, PyObject *args)
|
||||
py_rdiag_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int iok = rdiag_new();
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_del(PyObject *self, PyObject *args)
|
||||
py_rdiag_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:rdiag_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:rdiag_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_detailed(PyObject *self, PyObject *args)
|
||||
py_rdiag_detailed(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:rdiag_detailed", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:rdiag_detailed", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_detailed(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_brief(PyObject *self, PyObject *args)
|
||||
py_rdiag_brief(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:rdiag_brief", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:rdiag_brief", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_brief(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setThreshold(PyObject *self, PyObject *args)
|
||||
py_rdiag_setThreshold(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setThreshold", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setThreshold", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setThreshold(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setFont(PyObject *self, PyObject *args)
|
||||
py_rdiag_setFont(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* font;
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setFont", &n, &font))
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setFont", &n, &font)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setFont(n, font);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setBoldColor(PyObject *self, PyObject *args)
|
||||
py_rdiag_setBoldColor(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* color;
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setBoldColor", &n, &color))
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setBoldColor", &n, &color)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setBoldColor(n, color);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setNormalColor(PyObject *self, PyObject *args)
|
||||
py_rdiag_setNormalColor(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* color;
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setNormalColor", &n, &color))
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setNormalColor", &n, &color)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setNormalColor(n, color);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setDashedColor(PyObject *self, PyObject *args)
|
||||
py_rdiag_setDashedColor(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* color;
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setDashedColor", &n, &color))
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setDashedColor", &n, &color)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setDashedColor(n,color);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setDotOptions(PyObject *self, PyObject *args)
|
||||
py_rdiag_setDotOptions(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* opt;
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setDotOptions", &n, &opt))
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setDotOptions", &n, &opt)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setDotOptions(n,opt);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setBoldThreshold(PyObject *self, PyObject *args)
|
||||
py_rdiag_setBoldThreshold(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setBoldThreshold", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setBoldThreshold", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setBoldThreshold(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setNormalThreshold(PyObject *self, PyObject *args)
|
||||
py_rdiag_setNormalThreshold(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setNormalThreshold", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setNormalThreshold", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setNormalThreshold(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setLabelThreshold(PyObject *self, PyObject *args)
|
||||
py_rdiag_setLabelThreshold(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setLabelThreshold", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setLabelThreshold", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setLabelThreshold(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setScale(PyObject *self, PyObject *args)
|
||||
py_rdiag_setScale(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setScale", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setScale", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setScale(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setFlowType(PyObject *self, PyObject *args)
|
||||
py_rdiag_setFlowType(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
int iflow;
|
||||
if (!PyArg_ParseTuple(args, "ii:rdiag_setFlowType", &n, &iflow))
|
||||
if (!PyArg_ParseTuple(args, "ii:rdiag_setFlowType", &n, &iflow)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setFlowType(n, iflow);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setArrowWidth(PyObject *self, PyObject *args)
|
||||
py_rdiag_setArrowWidth(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double v;
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setArrowWidth", &n, &v))
|
||||
if (!PyArg_ParseTuple(args, "id:rdiag_setArrowWidth", &n, &v)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setArrowWidth(n,v);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_displayOnly(PyObject *self, PyObject *args)
|
||||
py_rdiag_displayOnly(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, k;
|
||||
if (!PyArg_ParseTuple(args, "ii:rdiag_displayOnly", &n, &k))
|
||||
if (!PyArg_ParseTuple(args, "ii:rdiag_displayOnly", &n, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_displayOnly(n,k);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_setTitle(PyObject *self, PyObject *args)
|
||||
py_rdiag_setTitle(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* t;
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setTitle", &n, &t))
|
||||
if (!PyArg_ParseTuple(args, "is:rdiag_setTitle", &n, &t)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_setTitle(n,t);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_add(PyObject *self, PyObject *args)
|
||||
py_rdiag_add(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:rdiag_add", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:rdiag_add", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_add(n,m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_findMajor(PyObject *self, PyObject *args)
|
||||
py_rdiag_findMajor(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double thresh;
|
||||
PyObject* a;
|
||||
if (!PyArg_ParseTuple(args, "idO:rdiag_findMajor", &n, &thresh, &a))
|
||||
if (!PyArg_ParseTuple(args, "idO:rdiag_findMajor", &n, &thresh, &a)) {
|
||||
return NULL;
|
||||
}
|
||||
PyArrayObject* aa = (PyArrayObject*)a;
|
||||
size_t lda = aa->dimensions[0];
|
||||
double* x = (double*)aa->data;
|
||||
int iok = rdiag_findMajor(n, thresh, lda, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rdiag_write(PyObject *self, PyObject *args)
|
||||
py_rdiag_write(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, fmt;
|
||||
char* nm;
|
||||
if (!PyArg_ParseTuple(args, "iis:rdiag_write", &n, &fmt, &nm))
|
||||
if (!PyArg_ParseTuple(args, "iis:rdiag_write", &n, &fmt, &nm)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rdiag_write(n, fmt, nm);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rbuild_new(PyObject *self, PyObject *args)
|
||||
py_rbuild_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
int iok = rbuild_new();
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rbuild_del(PyObject *self, PyObject *args)
|
||||
py_rbuild_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:rbuild_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:rbuild_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rbuild_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rbuild_init(PyObject *self, PyObject *args)
|
||||
py_rbuild_init(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* log;
|
||||
int k;
|
||||
if (!PyArg_ParseTuple(args, "isi:rbuild_init", &n, &log, &k))
|
||||
if (!PyArg_ParseTuple(args, "isi:rbuild_init", &n, &log, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rbuild_init(n,log,k);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_rbuild_build(PyObject *self, PyObject *args)
|
||||
py_rbuild_build(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
int k, idiag, iquiet;
|
||||
char *el, *dotfile;
|
||||
if (!PyArg_ParseTuple(args, "iissii:rbuild_build", &n, &k,
|
||||
&el, &dotfile, &idiag, &iquiet))
|
||||
char* el, *dotfile;
|
||||
if (!PyArg_ParseTuple(args, "iissii:rbuild_build", &n, &k,
|
||||
&el, &dotfile, &idiag, &iquiet)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = rbuild_build(n,k,el,dotfile,idiag,iquiet);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
|
||||
static PyObject*
|
||||
py_surf_setsitedensity(PyObject *self, PyObject *args)
|
||||
py_surf_setsitedensity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
double s0;
|
||||
if (!PyArg_ParseTuple(args, "id:surf_setsitedensity", &n, &s0))
|
||||
if (!PyArg_ParseTuple(args, "id:surf_setsitedensity", &n, &s0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int iok = surf_setsitedensity(n, s0);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_surf_sitedensity(PyObject *self, PyObject *args)
|
||||
py_surf_sitedensity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:surf_sitedensity", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:surf_sitedensity", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double s0 = surf_sitedensity(n);
|
||||
return Py_BuildValue("d",s0);
|
||||
@@ -25,38 +29,45 @@ py_surf_sitedensity(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_surf_setcoverages(PyObject *self, PyObject *args)
|
||||
py_surf_setcoverages(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject* cov;
|
||||
if (!PyArg_ParseTuple(args, "iO:surf_setcoverages", &n, &cov))
|
||||
if (!PyArg_ParseTuple(args, "iO:surf_setcoverages", &n, &cov)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)cov)->data;
|
||||
int iok = surf_setcoverages(n, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_surf_setconcentrations(PyObject *self, PyObject *args)
|
||||
py_surf_setconcentrations(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyObject* c;
|
||||
if (!PyArg_ParseTuple(args, "iO:surf_setconcentrations", &n, &c))
|
||||
if (!PyArg_ParseTuple(args, "iO:surf_setconcentrations", &n, &c)) {
|
||||
return NULL;
|
||||
}
|
||||
double* x = (double*)((PyArrayObject*)c)->data;
|
||||
int iok = surf_setconcentrations(n, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_surf_getcoverages(PyObject *self, PyObject *args)
|
||||
py_surf_getcoverages(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyArrayObject* cov;
|
||||
if (!PyArg_ParseTuple(args, "i:surf_getcoverages", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:surf_getcoverages", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
size_t nsp = th_nSpecies(n);
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nnsp = nsp;
|
||||
@@ -67,17 +78,20 @@ py_surf_getcoverages(PyObject *self, PyObject *args)
|
||||
#endif
|
||||
double* x = (double*)((PyArrayObject*)cov)->data;
|
||||
int iok = surf_getcoverages(n, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("O",cov);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_surf_getconcentrations(PyObject *self, PyObject *args)
|
||||
py_surf_getconcentrations(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
PyArrayObject* c;
|
||||
if (!PyArg_ParseTuple(args, "i:surf_getconcentrations", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:surf_getconcentrations", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
size_t nsp = th_nSpecies(n);
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nnsp = nsp;
|
||||
@@ -88,7 +102,9 @@ py_surf_getconcentrations(PyObject *self, PyObject *args)
|
||||
#endif
|
||||
double* x = (double*)((PyArrayObject*)c)->data;
|
||||
int iok = surf_getconcentrations(n, x);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("O",c);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,191 +1,242 @@
|
||||
|
||||
static PyObject *
|
||||
ct_newThermoFromXML(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject*
|
||||
ct_newThermoFromXML(PyObject* self, PyObject* args)
|
||||
{
|
||||
int mxml;
|
||||
//char* id;
|
||||
if (!PyArg_ParseTuple(args, "i:ct_newThermoFromXML", &mxml))
|
||||
if (!PyArg_ParseTuple(args, "i:ct_newThermoFromXML", &mxml)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = int(newThermoFromXML(mxml));
|
||||
if (n < 0) return reportCanteraError();
|
||||
if (n < 0) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_delete(PyObject *self, PyObject *args)
|
||||
thermo_delete(PyObject* self, PyObject* args)
|
||||
{
|
||||
int th;
|
||||
if (!PyArg_ParseTuple(args, "i:thermo_delete", &th))
|
||||
return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:thermo_delete", &th)) {
|
||||
return NULL;
|
||||
}
|
||||
delThermo(th);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_index(PyObject *self, PyObject *args) {
|
||||
thermo_index(PyObject* self, PyObject* args)
|
||||
{
|
||||
char* id;
|
||||
if (!PyArg_ParseTuple(args, "s:index", &id)) return NULL;
|
||||
return Py_BuildValue("i",th_thermoIndex(id));
|
||||
if (!PyArg_ParseTuple(args, "s:index", &id)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("i",th_thermoIndex(id));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_refpressure(PyObject *self, PyObject *args) {
|
||||
thermo_refpressure(PyObject* self, PyObject* args)
|
||||
{
|
||||
int th;
|
||||
if (!PyArg_ParseTuple(args, "i:refpressure", &th)) return NULL;
|
||||
return Py_BuildValue("d",th_refPressure(th));
|
||||
if (!PyArg_ParseTuple(args, "i:refpressure", &th)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",th_refPressure(th));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_mintemp(PyObject *self, PyObject *args) {
|
||||
thermo_mintemp(PyObject* self, PyObject* args)
|
||||
{
|
||||
int th, k;
|
||||
if (!PyArg_ParseTuple(args, "ii:mintemp", &th, &k)) return NULL;
|
||||
return Py_BuildValue("d",th_minTemp(th,k));
|
||||
if (!PyArg_ParseTuple(args, "ii:mintemp", &th, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",th_minTemp(th,k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_maxtemp(PyObject *self, PyObject *args) {
|
||||
thermo_maxtemp(PyObject* self, PyObject* args)
|
||||
{
|
||||
int th, k;
|
||||
if (!PyArg_ParseTuple(args, "ii:maxtemp", &th, &k)) return NULL;
|
||||
return Py_BuildValue("d",th_maxTemp(th,k));
|
||||
if (!PyArg_ParseTuple(args, "ii:maxtemp", &th, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
return Py_BuildValue("d",th_maxTemp(th,k));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_import(PyObject *self, PyObject *args) {
|
||||
thermo_import(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, mxml;
|
||||
char* id;
|
||||
if (!PyArg_ParseTuple(args, "iis:import", &n, &mxml, &id)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "iis:import", &n, &mxml, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = import_phase(n, mxml, id);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
thermo_getfp(PyObject *self, PyObject *args)
|
||||
thermo_getfp(PyObject* self, PyObject* args)
|
||||
{
|
||||
double vv = -999.999;
|
||||
bool ok = true;
|
||||
int th;
|
||||
int job;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:thermo_getfp", &th, &job))
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:thermo_getfp", &th, &job)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// try {
|
||||
|
||||
// floating-point attributes
|
||||
switch (job) {
|
||||
case 1:
|
||||
vv = th_enthalpy_mole(th); break;
|
||||
case 2:
|
||||
vv = th_intEnergy_mole(th); break;
|
||||
case 3:
|
||||
vv = th_entropy_mole(th); break;
|
||||
case 4:
|
||||
vv = th_gibbs_mole(th); break;
|
||||
case 5:
|
||||
vv = th_cp_mole(th); break;
|
||||
case 6:
|
||||
vv = th_cv_mole(th); break;
|
||||
case 7:
|
||||
vv = th_pressure(th); break;
|
||||
case 8:
|
||||
vv = th_enthalpy_mass(th); break;
|
||||
case 9:
|
||||
vv = th_intEnergy_mass(th); break;
|
||||
case 10:
|
||||
vv = th_entropy_mass(th); break;
|
||||
case 11:
|
||||
vv = th_gibbs_mass(th); break;
|
||||
case 12:
|
||||
vv = th_cp_mass(th); break;
|
||||
case 13:
|
||||
vv = th_cv_mass(th); break;
|
||||
case 25:
|
||||
vv = th_electricPotential(th); break;
|
||||
case 50:
|
||||
vv = th_critTemperature(th); break;
|
||||
case 51:
|
||||
vv = th_critPressure(th); break;
|
||||
case 52:
|
||||
vv = th_critDensity(th); break;
|
||||
case 53:
|
||||
vv = th_vaporFraction(th); break;
|
||||
// floating-point attributes
|
||||
switch (job) {
|
||||
case 1:
|
||||
vv = th_enthalpy_mole(th);
|
||||
break;
|
||||
case 2:
|
||||
vv = th_intEnergy_mole(th);
|
||||
break;
|
||||
case 3:
|
||||
vv = th_entropy_mole(th);
|
||||
break;
|
||||
case 4:
|
||||
vv = th_gibbs_mole(th);
|
||||
break;
|
||||
case 5:
|
||||
vv = th_cp_mole(th);
|
||||
break;
|
||||
case 6:
|
||||
vv = th_cv_mole(th);
|
||||
break;
|
||||
case 7:
|
||||
vv = th_pressure(th);
|
||||
break;
|
||||
case 8:
|
||||
vv = th_enthalpy_mass(th);
|
||||
break;
|
||||
case 9:
|
||||
vv = th_intEnergy_mass(th);
|
||||
break;
|
||||
case 10:
|
||||
vv = th_entropy_mass(th);
|
||||
break;
|
||||
case 11:
|
||||
vv = th_gibbs_mass(th);
|
||||
break;
|
||||
case 12:
|
||||
vv = th_cp_mass(th);
|
||||
break;
|
||||
case 13:
|
||||
vv = th_cv_mass(th);
|
||||
break;
|
||||
case 25:
|
||||
vv = th_electricPotential(th);
|
||||
break;
|
||||
case 50:
|
||||
vv = th_critTemperature(th);
|
||||
break;
|
||||
case 51:
|
||||
vv = th_critPressure(th);
|
||||
break;
|
||||
case 52:
|
||||
vv = th_critDensity(th);
|
||||
break;
|
||||
case 53:
|
||||
vv = th_vaporFraction(th);
|
||||
break;
|
||||
|
||||
default:
|
||||
ok = false;
|
||||
default:
|
||||
ok = false;
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == -999.999) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
if (ok) {
|
||||
if (vv == -999.999) {
|
||||
return reportCanteraError();
|
||||
}
|
||||
return Py_BuildValue("d",vv);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(ErrorObject,"Unknown floating-point attribute");
|
||||
return NULL;
|
||||
}
|
||||
//}
|
||||
//catch (CanteraError) {
|
||||
// return reportCanteraError();
|
||||
//}
|
||||
return Py_BuildValue("d",vv);
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Unknown floating-point attribute");
|
||||
return NULL;
|
||||
}
|
||||
//}
|
||||
//catch (CanteraError) {
|
||||
// return reportCanteraError();
|
||||
//}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
thermo_setfp(PyObject *self, PyObject *args)
|
||||
thermo_setfp(PyObject* self, PyObject* args)
|
||||
{
|
||||
double v1 = -1.0, v2 = -1.0;
|
||||
int iok = -2;
|
||||
int th;
|
||||
int job;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iidd:thermo_setfp", &th, &job, &v1, &v2))
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iidd:thermo_setfp", &th, &job, &v1, &v2)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//vector_fp v(2);
|
||||
double v[2];
|
||||
v[0] = v1; v[1] = v2;
|
||||
v[0] = v1;
|
||||
v[1] = v2;
|
||||
// set floating-point attributes
|
||||
switch (job) {
|
||||
case 1:
|
||||
iok = th_setPressure(th, v1); break;
|
||||
iok = th_setPressure(th, v1);
|
||||
break;
|
||||
case 2:
|
||||
iok = th_set_HP(th, v); break;
|
||||
iok = th_set_HP(th, v);
|
||||
break;
|
||||
case 3:
|
||||
iok = th_set_UV(th, v); break;
|
||||
iok = th_set_UV(th, v);
|
||||
break;
|
||||
case 4:
|
||||
iok = th_set_SV(th, v);
|
||||
break;
|
||||
case 5:
|
||||
iok = th_set_SP(th, v); break;
|
||||
iok = th_set_SP(th, v);
|
||||
break;
|
||||
case 6:
|
||||
iok = th_setElectricPotential(th, v[0]); break;
|
||||
iok = th_setElectricPotential(th, v[0]);
|
||||
break;
|
||||
case 7:
|
||||
iok = th_setState_Tsat(th, v1, v2); break;
|
||||
iok = th_setState_Tsat(th, v1, v2);
|
||||
break;
|
||||
case 8:
|
||||
iok = th_setState_Psat(th, v1, v2); break;
|
||||
iok = th_setState_Psat(th, v1, v2);
|
||||
break;
|
||||
default:
|
||||
iok = -10;
|
||||
iok = -10;
|
||||
}
|
||||
//delete v;
|
||||
if (iok >= 0)
|
||||
if (iok >= 0) {
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1) return reportCanteraError();
|
||||
else {
|
||||
}
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Error in thermo_setfp");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
thermo_getarray(PyObject *self, PyObject *args)
|
||||
thermo_getarray(PyObject* self, PyObject* args)
|
||||
{
|
||||
int th;
|
||||
int job;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii:thermo_getarray", &th, &job))
|
||||
if (!PyArg_ParseTuple(args, "ii:thermo_getarray", &th, &job)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t nsp = th_nSpecies(th);
|
||||
size_t nel = phase_nElements(th);
|
||||
@@ -196,12 +247,12 @@ thermo_getarray(PyObject *self, PyObject *args)
|
||||
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nnn = xlen;
|
||||
PyArrayObject* x =
|
||||
PyArrayObject* x =
|
||||
(PyArrayObject*)PyArray_SimpleNew(1, &nnn, PyArray_DOUBLE);
|
||||
Py_INCREF(x);
|
||||
#else
|
||||
int nnn = int(xlen);
|
||||
PyArrayObject* x =
|
||||
PyArrayObject* x =
|
||||
(PyArrayObject*)PyArray_FromDims(1, &nnn, PyArray_DOUBLE);
|
||||
#endif
|
||||
double* xd = (double*)x->data;
|
||||
@@ -227,9 +278,9 @@ thermo_getarray(PyObject *self, PyObject *args)
|
||||
}
|
||||
if (iok >= 0) {
|
||||
return PyArray_Return(x);
|
||||
}
|
||||
else if (iok == -1) return reportCanteraError();
|
||||
else {
|
||||
} else if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Unknown array attribute");
|
||||
return NULL;
|
||||
}
|
||||
@@ -237,7 +288,7 @@ thermo_getarray(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
static PyObject*
|
||||
thermo_equil(PyObject *self, PyObject *args)
|
||||
thermo_equil(PyObject* self, PyObject* args)
|
||||
{
|
||||
int iok = -2;
|
||||
int th;
|
||||
@@ -248,15 +299,18 @@ thermo_equil(PyObject *self, PyObject *args)
|
||||
int maxiter;
|
||||
int loglevel;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "isidiii:thermo_equil", &th, &XY,
|
||||
&solver, &rtol, &maxsteps, &maxiter, &loglevel))
|
||||
if (!PyArg_ParseTuple(args, "isidiii:thermo_equil", &th, &XY,
|
||||
&solver, &rtol, &maxsteps, &maxiter, &loglevel)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iok = th_equil(th, XY, solver, rtol, maxsteps, maxiter, loglevel);
|
||||
if (iok >= 0)
|
||||
if (iok >= 0) {
|
||||
return Py_BuildValue("i",iok);
|
||||
if (iok == -1) return reportCanteraError();
|
||||
else {
|
||||
}
|
||||
if (iok == -1) {
|
||||
return reportCanteraError();
|
||||
} else {
|
||||
PyErr_SetString(ErrorObject,"Error in thermo_equil");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
/**
|
||||
* Create a new Transport object.
|
||||
*/
|
||||
static PyObject *
|
||||
py_transport_new(PyObject *self, PyObject *args) {
|
||||
static PyObject*
|
||||
py_transport_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
char* model;
|
||||
int ph;
|
||||
int loglevel;
|
||||
if (!PyArg_ParseTuple(args, "sii:transport_new", &model,
|
||||
&ph, &loglevel))
|
||||
if (!PyArg_ParseTuple(args, "sii:transport_new", &model,
|
||||
&ph, &loglevel)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = int(newTransport(model, ph, loglevel));
|
||||
if (n < 0) return reportError(n);
|
||||
if (n < 0) {
|
||||
return reportError(n);
|
||||
}
|
||||
return Py_BuildValue("i",n);
|
||||
}
|
||||
|
||||
@@ -20,74 +24,96 @@ py_transport_new(PyObject *self, PyObject *args) {
|
||||
* Delete the Phase object.
|
||||
*/
|
||||
static PyObject*
|
||||
py_transport_delete(PyObject *self, PyObject *args)
|
||||
py_transport_delete(PyObject* self, PyObject* args)
|
||||
{
|
||||
int tr;
|
||||
if (!PyArg_ParseTuple(args, "i:transport_delete", &tr))
|
||||
return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:transport_delete", &tr)) {
|
||||
return NULL;
|
||||
}
|
||||
delTransport(tr);
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_setParameters(PyObject *self, PyObject *args) {
|
||||
py_setParameters(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, k, typ;
|
||||
PyObject* parray;
|
||||
if (!PyArg_ParseTuple(args, "iiiO:py_setParameters",
|
||||
&n, &typ, &k, &parray)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "iiiO:py_setParameters",
|
||||
&n, &typ, &k, &parray)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyArrayObject* a = (PyArrayObject*)
|
||||
PyArray_ContiguousFromObject(parray, PyArray_DOUBLE, 1, 1);
|
||||
PyArray_ContiguousFromObject(parray, PyArray_DOUBLE, 1, 1);
|
||||
double* xd = (double*)a->data;
|
||||
int ok = trans_setParameters(n, typ, k, xd);
|
||||
Py_DECREF(a);
|
||||
if (ok < 0) return reportError(ok);
|
||||
return Py_BuildValue("i",ok);
|
||||
if (ok < 0) {
|
||||
return reportError(ok);
|
||||
}
|
||||
return Py_BuildValue("i",ok);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_viscosity(PyObject *self, PyObject *args) {
|
||||
py_viscosity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:py_viscosity", &n)) return NULL;
|
||||
double mu = trans_viscosity(n);
|
||||
if (mu < 0.0) return reportError(int(mu));
|
||||
return Py_BuildValue("d",mu);
|
||||
if (!PyArg_ParseTuple(args, "i:py_viscosity", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double mu = trans_viscosity(n);
|
||||
if (mu < 0.0) {
|
||||
return reportError(int(mu));
|
||||
}
|
||||
return Py_BuildValue("d",mu);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_thermalConductivity(PyObject *self, PyObject *args) {
|
||||
py_thermalConductivity(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:py_thermalConductivity", &n)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "i:py_thermalConductivity", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
double lambda = trans_thermalConductivity(n);
|
||||
if (lambda < 0.0) return reportError(int(lambda));
|
||||
if (lambda < 0.0) {
|
||||
return reportError(int(lambda));
|
||||
}
|
||||
return Py_BuildValue("d",lambda);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_thermalDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
py_thermalDiffCoeffs(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, idt;
|
||||
if (!PyArg_ParseTuple(args, "ii:py_thermalDiffCoeffs", &n, &idt))
|
||||
if (!PyArg_ParseTuple(args, "ii:py_thermalDiffCoeffs", &n, &idt)) {
|
||||
return NULL;
|
||||
}
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nidt = idt;
|
||||
PyArrayObject* dt =
|
||||
PyArrayObject* dt =
|
||||
(PyArrayObject*)PyArray_SimpleNew(1, &nidt, PyArray_DOUBLE);
|
||||
#else
|
||||
PyArrayObject* dt =
|
||||
PyArrayObject* dt =
|
||||
(PyArrayObject*)PyArray_FromDims(1, &idt, PyArray_DOUBLE);
|
||||
#endif
|
||||
int iok = trans_getThermalDiffCoeffs(n, idt, (double*)dt->data);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(dt);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_binaryDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
py_binaryDiffCoeffs(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, id;
|
||||
if (!PyArg_ParseTuple(args, "ii:py_binaryDiffCoeffs", &n, &id))
|
||||
if (!PyArg_ParseTuple(args, "ii:py_binaryDiffCoeffs", &n, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp idim[2];
|
||||
idim[0] = id;
|
||||
@@ -100,15 +126,19 @@ py_binaryDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
PyArrayObject* d = (PyArrayObject*)PyArray_FromDims(2, idim, PyArray_DOUBLE);
|
||||
#endif
|
||||
int iok = trans_getBinDiffCoeffs(n, id, (double*)d->data);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(d);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_mixDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
py_mixDiffCoeffs(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, id;
|
||||
if (!PyArg_ParseTuple(args, "ii:py_mixDiffCoeffs", &n, &id))
|
||||
if (!PyArg_ParseTuple(args, "ii:py_mixDiffCoeffs", &n, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nid = id;
|
||||
PyArrayObject* d = (PyArrayObject*)PyArray_SimpleNew(1, &nid, PyArray_DOUBLE);
|
||||
@@ -116,15 +146,19 @@ py_mixDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
PyArrayObject* d = (PyArrayObject*)PyArray_FromDims(1, &id, PyArray_DOUBLE);
|
||||
#endif
|
||||
int iok = trans_getMixDiffCoeffs(n, id, (double*)d->data);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(d);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_multiDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
py_multiDiffCoeffs(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, id;
|
||||
if (!PyArg_ParseTuple(args, "ii:py_multiDiffCoeffs", &n, &id))
|
||||
if (!PyArg_ParseTuple(args, "ii:py_multiDiffCoeffs", &n, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
//vector_int idim(2,id);
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp idim[2];
|
||||
@@ -138,18 +172,22 @@ py_multiDiffCoeffs(PyObject *self, PyObject *args) {
|
||||
PyArrayObject* d = (PyArrayObject*)PyArray_FromDims(2, idim, PyArray_DOUBLE);
|
||||
#endif
|
||||
int iok = trans_getMultiDiffCoeffs(n, id, (double*)d->data);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(d);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_getMolarFluxes(PyObject *self, PyObject *args) {
|
||||
py_getMolarFluxes(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, id;
|
||||
PyObject *state1, *state2;
|
||||
PyObject* state1, *state2;
|
||||
double delta;
|
||||
if (!PyArg_ParseTuple(args, "iiOOd:py_getMolarFluxes", &n, &id,
|
||||
&state1, &state2, &delta))
|
||||
if (!PyArg_ParseTuple(args, "iiOOd:py_getMolarFluxes", &n, &id,
|
||||
&state1, &state2, &delta)) {
|
||||
return NULL;
|
||||
}
|
||||
PyArrayObject* state1array = (PyArrayObject*)state1;
|
||||
PyArrayObject* state2array = (PyArrayObject*)state2;
|
||||
double* d1 = (double*)state1array->data;
|
||||
@@ -162,20 +200,24 @@ py_getMolarFluxes(PyObject *self, PyObject *args) {
|
||||
#endif
|
||||
double* fd = (double*)f->data;
|
||||
int iok = trans_getMolarFluxes(n, d1, d2, delta, fd);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(f);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_getMassFluxes(PyObject *self, PyObject *args)
|
||||
py_getMassFluxes(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, id;
|
||||
PyObject *state1, *state2;
|
||||
PyObject* state1, *state2;
|
||||
double delta;
|
||||
if (!PyArg_ParseTuple(args, "iiOOd:py_getMassFluxes", &n, &id,
|
||||
&state1, &state2, &delta))
|
||||
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
PyArrayObject* state1array = (PyArrayObject*)state1;
|
||||
PyArrayObject* state2array = (PyArrayObject*)state2;
|
||||
double* d1 = (double*)state1array->data;
|
||||
@@ -188,6 +230,8 @@ py_getMassFluxes(PyObject *self, PyObject *args)
|
||||
#endif
|
||||
double* fd = (double*)f->data;
|
||||
int iok = trans_getMassFluxes(n, d1, d2, delta, fd);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(f);
|
||||
}
|
||||
|
||||
@@ -1,241 +1,295 @@
|
||||
|
||||
static PyObject*
|
||||
py_xml_new(PyObject *self, PyObject *args)
|
||||
py_xml_new(PyObject* self, PyObject* args)
|
||||
{
|
||||
char* nm;
|
||||
if (!PyArg_ParseTuple(args, "s:xml_new", &nm))
|
||||
if (!PyArg_ParseTuple(args, "s:xml_new", &nm)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = xml_new(nm);
|
||||
PyObject* pn = Py_BuildValue("i",n);
|
||||
return pn;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_get_XML_File(PyObject *self, PyObject *args)
|
||||
py_xml_get_XML_File(PyObject* self, PyObject* args)
|
||||
{
|
||||
char* file;
|
||||
int debug;
|
||||
if (!PyArg_ParseTuple(args, "si:xml_get_XML_File", &file, &debug))
|
||||
if (!PyArg_ParseTuple(args, "si:xml_get_XML_File", &file, &debug)) {
|
||||
return NULL;
|
||||
}
|
||||
int n = xml_get_XML_File(file, debug);
|
||||
if (n < 0) return reportError(n);
|
||||
if (n < 0) {
|
||||
return reportError(n);
|
||||
}
|
||||
PyObject* pn = Py_BuildValue("i",n);
|
||||
return pn;
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_xml_del(PyObject *self, PyObject *args)
|
||||
py_xml_del(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:xml_del", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:xml_del", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = xml_del(n);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_clear(PyObject *self, PyObject *args)
|
||||
py_xml_clear(PyObject* self, PyObject* args)
|
||||
{
|
||||
int iok = xml_clear();
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",0);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_attrib(PyObject *self, PyObject *args)
|
||||
py_xml_attrib(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char *key;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_attrib", &n, &key))
|
||||
char* key;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_attrib", &n, &key)) {
|
||||
return NULL;
|
||||
}
|
||||
char* val = new char[81];
|
||||
int iok = xml_attrib(n, key, val);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
PyObject* r = Py_BuildValue("s",val);
|
||||
delete[] val;
|
||||
return r;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_tag(PyObject *self, PyObject *args)
|
||||
py_xml_tag(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:xml_tag", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:xml_tag", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
char* val = new char[81];
|
||||
int iok = xml_tag(n, val);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
PyObject* r = Py_BuildValue("s",val);
|
||||
delete val;
|
||||
return r;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_value(PyObject *self, PyObject *args)
|
||||
py_xml_value(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:xml_value", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:xml_value", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
char* val = new char[81];
|
||||
int iok = xml_value(n, val);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
PyObject* r = Py_BuildValue("s",val);
|
||||
delete val;
|
||||
return r;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_child(PyObject *self, PyObject *args)
|
||||
py_xml_child(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* loc;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_child", &n, &loc))
|
||||
if (!PyArg_ParseTuple(args, "is:xml_child", &n, &loc)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_child(n, loc);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_childbynumber(PyObject *self, PyObject *args)
|
||||
py_xml_childbynumber(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, k;
|
||||
if (!PyArg_ParseTuple(args, "ii:xml_childbynumber", &n, &k))
|
||||
if (!PyArg_ParseTuple(args, "ii:xml_childbynumber", &n, &k)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_child_bynumber(n, k);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_findID(PyObject *self, PyObject *args)
|
||||
py_xml_findID(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* id;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_findID", &n, &id))
|
||||
if (!PyArg_ParseTuple(args, "is:xml_findID", &n, &id)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_findID(n, id);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_findByName(PyObject *self, PyObject *args)
|
||||
py_xml_findByName(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char* nm;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_findID", &n, &nm))
|
||||
if (!PyArg_ParseTuple(args, "is:xml_findID", &n, &nm)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_findByName(n, nm);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_nChildren(PyObject *self, PyObject *args)
|
||||
py_xml_nChildren(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
if (!PyArg_ParseTuple(args, "i:xml_nChildren", &n))
|
||||
if (!PyArg_ParseTuple(args, "i:xml_nChildren", &n)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_nChildren(n);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_addChild(PyObject *self, PyObject *args)
|
||||
py_xml_addChild(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char *name, *value;
|
||||
if (!PyArg_ParseTuple(args, "iss:xml_addChild", &n, &name, &value))
|
||||
char* name, *value;
|
||||
if (!PyArg_ParseTuple(args, "iss:xml_addChild", &n, &name, &value)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_addChild(n, name, value);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_xml_addChildNode(PyObject *self, PyObject *args)
|
||||
py_xml_addChildNode(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, j;
|
||||
if (!PyArg_ParseTuple(args, "ii:xml_addChildNode", &n, &j))
|
||||
if (!PyArg_ParseTuple(args, "ii:xml_addChildNode", &n, &j)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_addChildNode(n, j);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_xml_addAttrib(PyObject *self, PyObject *args)
|
||||
py_xml_addAttrib(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char *name, *value;
|
||||
if (!PyArg_ParseTuple(args, "iss:xml_addAttrib", &n, &name, &value))
|
||||
char* name, *value;
|
||||
if (!PyArg_ParseTuple(args, "iss:xml_addAttrib", &n, &name, &value)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_addAttrib(n, name, value);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_addComment(PyObject *self, PyObject *args)
|
||||
py_xml_addComment(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char *comment;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_addComment", &n, &comment))
|
||||
char* comment;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_addComment", &n, &comment)) {
|
||||
return NULL;
|
||||
}
|
||||
int m = xml_addComment(n, comment);
|
||||
if (m < 0) return reportError(m);
|
||||
if (m < 0) {
|
||||
return reportError(m);
|
||||
}
|
||||
return Py_BuildValue("i",m);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_xml_removeChild(PyObject *self, PyObject *args)
|
||||
py_xml_removeChild(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n, m;
|
||||
if (!PyArg_ParseTuple(args, "ii:xml_removeChild", &n, &m))
|
||||
if (!PyArg_ParseTuple(args, "ii:xml_removeChild", &n, &m)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = xml_removeChild(n, m);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
|
||||
static PyObject*
|
||||
py_xml_write(PyObject *self, PyObject *args)
|
||||
py_xml_write(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
char *file;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_write", &n, &file))
|
||||
char* file;
|
||||
if (!PyArg_ParseTuple(args, "is:xml_write", &n, &file)) {
|
||||
return NULL;
|
||||
}
|
||||
int iok = xml_write(n, file);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return Py_BuildValue("i",iok);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
py_ctml_getFloatArray(PyObject *self, PyObject *args)
|
||||
py_ctml_getFloatArray(PyObject* self, PyObject* args)
|
||||
{
|
||||
int n;
|
||||
int iconv, ia;
|
||||
if (!PyArg_ParseTuple(args, "iii", &n, &iconv, &ia))
|
||||
if (!PyArg_ParseTuple(args, "iii", &n, &iconv, &ia)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAS_NUMPY
|
||||
npy_intp nia = ia;
|
||||
PyArrayObject* a =
|
||||
PyArrayObject* a =
|
||||
(PyArrayObject*)PyArray_SimpleNew(1, &nia, PyArray_DOUBLE);
|
||||
#else
|
||||
PyArrayObject* a =
|
||||
PyArrayObject* a =
|
||||
(PyArrayObject*)PyArray_FromDims(1, &ia, PyArray_DOUBLE);
|
||||
#endif
|
||||
double* x = (double*)a->data;
|
||||
int iok = ctml_getFloatArray(n, ia, x, iconv);
|
||||
if (iok < 0) return reportError(iok);
|
||||
if (iok < 0) {
|
||||
return reportError(iok);
|
||||
}
|
||||
return PyArray_Return(a);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ static PyMethodDef ct_methods[] = {
|
||||
{"tran_setParameters", py_setParameters, METH_VARARGS},
|
||||
{"tran_getMolarFluxes", py_getMolarFluxes, METH_VARARGS},
|
||||
{"tran_getMassFluxes", py_getMassFluxes, METH_VARARGS},
|
||||
|
||||
|
||||
{"get_Cantera_Error", ct_get_cantera_error, METH_VARARGS},
|
||||
//{"ct_print", ct_print, METH_VARARGS},
|
||||
{"ct_addDirectory", ct_addDirectory, METH_VARARGS},
|
||||
@@ -192,15 +192,15 @@ static PyMethodDef ct_methods[] = {
|
||||
{"rdiag_setFlowType", py_rdiag_setFlowType, METH_VARARGS},
|
||||
{"rdiag_setLabelThreshold", py_rdiag_setLabelThreshold, METH_VARARGS},
|
||||
|
||||
// {"bndry_temperature", py_bndry_temperature, METH_VARARGS},
|
||||
// {"bndry_setxin", py_bndry_setxin, METH_VARARGS},
|
||||
// {"bndry_setxinbyname", py_bndry_setxinbyname, METH_VARARGS},
|
||||
// {"bndry_settemperature", py_bndry_settemperature, METH_VARARGS},
|
||||
// {"bndry_setspreadrate", py_bndry_setspreadrate, METH_VARARGS},
|
||||
// {"bndry_new", py_bndry_new, METH_VARARGS},
|
||||
// {"bndry_del", py_bndry_del, METH_VARARGS},
|
||||
// {"bndry_mdot", py_bndry_mdot, METH_VARARGS},
|
||||
// {"bndry_setmdot", py_bndry_setmdot, METH_VARARGS},
|
||||
// {"bndry_temperature", py_bndry_temperature, METH_VARARGS},
|
||||
// {"bndry_setxin", py_bndry_setxin, METH_VARARGS},
|
||||
// {"bndry_setxinbyname", py_bndry_setxinbyname, METH_VARARGS},
|
||||
// {"bndry_settemperature", py_bndry_settemperature, METH_VARARGS},
|
||||
// {"bndry_setspreadrate", py_bndry_setspreadrate, METH_VARARGS},
|
||||
// {"bndry_new", py_bndry_new, METH_VARARGS},
|
||||
// {"bndry_del", py_bndry_del, METH_VARARGS},
|
||||
// {"bndry_mdot", py_bndry_mdot, METH_VARARGS},
|
||||
// {"bndry_setmdot", py_bndry_setmdot, METH_VARARGS},
|
||||
|
||||
{"flowdev_ready", py_flowdev_ready, METH_VARARGS},
|
||||
//{"reactor_setInitialTime", py_reactor_setInitialTime, METH_VARARGS},
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
using namespace std;
|
||||
|
||||
// constants defined in the module
|
||||
static PyObject *ErrorObject;
|
||||
static PyObject* ErrorObject;
|
||||
|
||||
// local includes
|
||||
#include "pyutils.h"
|
||||
|
||||
#include "ctphase_methods.cpp"
|
||||
#include "ctthermo_methods.cpp"
|
||||
#include "ctkinetics_methods.cpp"
|
||||
#include "ctkinetics_methods.cpp"
|
||||
#include "cttransport_methods.cpp"
|
||||
#include "ctxml_methods.cpp"
|
||||
#include "ctfuncs.cpp"
|
||||
@@ -60,8 +60,9 @@ static PyObject *ErrorObject;
|
||||
#endif
|
||||
|
||||
static PyObject*
|
||||
pyct_appdelete(PyObject *self, PyObject *args) {
|
||||
return Py_BuildValue("i",ct_appdelete());
|
||||
pyct_appdelete(PyObject* self, PyObject* args)
|
||||
{
|
||||
return Py_BuildValue("i",ct_appdelete());
|
||||
}
|
||||
|
||||
#include "methods.h"
|
||||
@@ -73,20 +74,20 @@ extern "C" {
|
||||
|
||||
DL_EXPORT(void) init_cantera(void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
PyObject* m, *d;
|
||||
|
||||
/* Initialize the type of the new type object here; doing it here
|
||||
* is required for portability to Windows without requiring C++. */
|
||||
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule("_cantera", ct_methods);
|
||||
import_array();
|
||||
Cantera::Logger* pylog = new Cantera::Py_Logger;
|
||||
setLogWriter(pylog);
|
||||
|
||||
|
||||
/* Add some symbolic constants to the module */
|
||||
d = PyModule_GetDict(m);
|
||||
ErrorObject = PyErr_NewException((char *)"cantera.error", NULL, NULL);
|
||||
ErrorObject = PyErr_NewException((char*)"cantera.error", NULL, NULL);
|
||||
PyDict_SetItemString(d, "error", ErrorObject);
|
||||
#ifdef HAS_NUMERIC
|
||||
PyDict_SetItemString(d, "nummod",PyString_FromString("Numeric"));
|
||||
|
||||
@@ -7,40 +7,42 @@
|
||||
|
||||
static std::string ss = "print \"\"\" ";
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
/// Logger for Python.
|
||||
/// @ingroup textlogs
|
||||
class Py_Logger : public Logger {
|
||||
public:
|
||||
Py_Logger() {}
|
||||
virtual ~Py_Logger() {}
|
||||
/// Logger for Python.
|
||||
/// @ingroup textlogs
|
||||
class Py_Logger : public Logger
|
||||
{
|
||||
public:
|
||||
Py_Logger() {}
|
||||
virtual ~Py_Logger() {}
|
||||
|
||||
virtual void write(const std::string& s) {
|
||||
char ch = s[0];
|
||||
int n = 0;
|
||||
while (ch != '\0') {
|
||||
if (ch =='\n') {
|
||||
ss += "\"\"\"";
|
||||
PyRun_SimpleString((char *)ss.c_str());
|
||||
ss = "print \"\"\"";
|
||||
}
|
||||
else
|
||||
ss += ch;
|
||||
n++;
|
||||
ch = s[n];
|
||||
virtual void write(const std::string& s) {
|
||||
char ch = s[0];
|
||||
int n = 0;
|
||||
while (ch != '\0') {
|
||||
if (ch =='\n') {
|
||||
ss += "\"\"\"";
|
||||
PyRun_SimpleString((char*)ss.c_str());
|
||||
ss = "print \"\"\"";
|
||||
} else {
|
||||
ss += ch;
|
||||
}
|
||||
n++;
|
||||
ch = s[n];
|
||||
}
|
||||
}
|
||||
|
||||
virtual void error(const std::string& msg) {
|
||||
std::string err = "raise \""+msg+"\"";
|
||||
PyRun_SimpleString((char *)err.c_str());
|
||||
}
|
||||
virtual void error(const std::string& msg) {
|
||||
std::string err = "raise \""+msg+"\"";
|
||||
PyRun_SimpleString((char*)err.c_str());
|
||||
}
|
||||
|
||||
virtual int env() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
virtual int env() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
11
Cantera/python/src/pyutils.h
Executable file → Normal file
11
Cantera/python/src/pyutils.h
Executable file → Normal file
@@ -3,7 +3,8 @@
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
static PyObject* reportCanteraError() {
|
||||
static PyObject* reportCanteraError()
|
||||
{
|
||||
char* buf = 0;
|
||||
int buflen = getCanteraError(0, buf) + 1;
|
||||
buf = new char[buflen+1];
|
||||
@@ -14,9 +15,11 @@ static PyObject* reportCanteraError() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject* reportError(int n) {
|
||||
if (n == -1) return reportCanteraError();
|
||||
else if (n < 0) {
|
||||
static PyObject* reportError(int n)
|
||||
{
|
||||
if (n == -1) {
|
||||
return reportCanteraError();
|
||||
} else if (n < 0) {
|
||||
PyErr_SetString(ErrorObject,"Exception occurred.");
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
PyMODINIT_FUNC
|
||||
init_spam(void)
|
||||
{
|
||||
Py_InitModule3("_spam", NULL,
|
||||
"Spam, spam, spam, eggs, and spam.");
|
||||
Py_InitModule3("_spam", NULL,
|
||||
"Spam, spam, spam, eggs, and spam.");
|
||||
}
|
||||
|
||||
@@ -14,24 +14,26 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
|
||||
//! A class for 2D arrays stored in column-major
|
||||
//! (Fortran-compatible) form.
|
||||
/*!
|
||||
* In this form, the data entry for an n row, m col
|
||||
* matrix is
|
||||
* index = i + (n-1) * j
|
||||
* where
|
||||
* J(i,j) = data_start + index
|
||||
* i = row
|
||||
* j = column
|
||||
*/
|
||||
class Array2D {
|
||||
|
||||
public:
|
||||
//! A class for 2D arrays stored in column-major
|
||||
//! (Fortran-compatible) form.
|
||||
/*!
|
||||
* In this form, the data entry for an n row, m col
|
||||
* matrix is
|
||||
* index = i + (n-1) * j
|
||||
* where
|
||||
* J(i,j) = data_start + index
|
||||
* i = row
|
||||
* j = column
|
||||
*/
|
||||
class Array2D
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Type definition for the iterator class that is
|
||||
//! can be used by Array2D types.
|
||||
@@ -52,10 +54,9 @@ namespace Cantera {
|
||||
* Default constructor. Create an empty array.
|
||||
*/
|
||||
Array2D() :
|
||||
m_data(0),
|
||||
m_nrows(0),
|
||||
m_ncols(0)
|
||||
{
|
||||
m_data(0),
|
||||
m_nrows(0),
|
||||
m_ncols(0) {
|
||||
}
|
||||
|
||||
//! Constructor.
|
||||
@@ -68,9 +69,9 @@ namespace Cantera {
|
||||
* @param v Default fill value. The default is 0.0
|
||||
*/
|
||||
Array2D(const size_t m, const size_t n, const doublereal v = 0.0)
|
||||
: m_data(0), m_nrows(m), m_ncols(n) {
|
||||
m_data.resize(n*m);
|
||||
std::fill(m_data.begin(), m_data.end(), v);
|
||||
: m_data(0), m_nrows(m), m_ncols(n) {
|
||||
m_data.resize(n*m);
|
||||
std::fill(m_data.begin(), m_data.end(), v);
|
||||
}
|
||||
|
||||
//! Copy constructor
|
||||
@@ -78,14 +79,13 @@ namespace Cantera {
|
||||
* @param y Array2D to make the copy from
|
||||
*/
|
||||
Array2D(const Array2D& y) :
|
||||
m_data(0),
|
||||
m_nrows(0),
|
||||
m_ncols(0)
|
||||
{
|
||||
m_nrows = y.m_nrows;
|
||||
m_ncols = y.m_ncols;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
m_data = y.m_data;
|
||||
m_data(0),
|
||||
m_nrows(0),
|
||||
m_ncols(0) {
|
||||
m_nrows = y.m_nrows;
|
||||
m_ncols = y.m_ncols;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
m_data = y.m_data;
|
||||
}
|
||||
|
||||
//! assignment operator
|
||||
@@ -93,12 +93,14 @@ namespace Cantera {
|
||||
* @param y Array2D to get the values from
|
||||
*/
|
||||
Array2D& operator=(const Array2D& y) {
|
||||
if (&y == this) return *this;
|
||||
m_nrows = y.m_nrows;
|
||||
m_ncols = y.m_ncols;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
m_data = y.m_data;
|
||||
return *this;
|
||||
if (&y == this) {
|
||||
return *this;
|
||||
}
|
||||
m_nrows = y.m_nrows;
|
||||
m_ncols = y.m_ncols;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
m_data = y.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Resize the array, and fill the new entries with 'v'
|
||||
@@ -108,49 +110,53 @@ namespace Cantera {
|
||||
* @param v Default fill value -> defaults to zero.
|
||||
*/
|
||||
void resize(size_t n, size_t m, doublereal v = 0.0) {
|
||||
m_nrows = n;
|
||||
m_ncols = m;
|
||||
m_data.resize(n*m, v);
|
||||
m_nrows = n;
|
||||
m_ncols = m;
|
||||
m_data.resize(n*m, v);
|
||||
}
|
||||
|
||||
//! Copy the data from one array into another without doing any checking
|
||||
/*!
|
||||
* This differs from the assignment operator as no resizing is done and memcpy() is used.
|
||||
* @param y Array to be copied
|
||||
*/
|
||||
*/
|
||||
void copyData(const Array2D& y) {
|
||||
size_t n = sizeof(doublereal) * m_nrows * m_ncols;
|
||||
(void) memcpy(DATA_PTR(m_data), y.ptrColumn(0), n);
|
||||
size_t n = sizeof(doublereal) * m_nrows * m_ncols;
|
||||
(void) memcpy(DATA_PTR(m_data), y.ptrColumn(0), n);
|
||||
}
|
||||
|
||||
//! Append a column to the existing matrix using a std vector
|
||||
/*!
|
||||
* This operation will add a column onto the existing matrix.
|
||||
*
|
||||
*
|
||||
* @param c This vector<doublereal> is the entries in the
|
||||
* column to be added. It must have a length
|
||||
* equal to m_nrows or greater.
|
||||
*/
|
||||
void appendColumn(const vector_fp& c) {
|
||||
m_ncols++;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
size_t m;
|
||||
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
|
||||
m_ncols++;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
size_t m;
|
||||
for (m = 0; m < m_nrows; m++) {
|
||||
value(m_ncols, m) = c[m];
|
||||
}
|
||||
}
|
||||
|
||||
//! Append a column to the existing matrix
|
||||
/*!
|
||||
* This operation will add a column onto the existing matrix.
|
||||
*
|
||||
*
|
||||
* @param c This vector of doubles is the entries in the
|
||||
* column to be added. It must have a length
|
||||
* equal to m_nrows or greater.
|
||||
*/
|
||||
void appendColumn(const doublereal* const c) {
|
||||
m_ncols++;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
size_t m;
|
||||
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
|
||||
m_ncols++;
|
||||
m_data.resize(m_nrows*m_ncols);
|
||||
size_t m;
|
||||
for (m = 0; m < m_nrows; m++) {
|
||||
value(m_ncols, m) = c[m];
|
||||
}
|
||||
}
|
||||
|
||||
//! Set the nth row to array rw
|
||||
@@ -159,21 +165,21 @@ namespace Cantera {
|
||||
* @param rw Vector for the row. Must have a length of m_ncols.
|
||||
*/
|
||||
void setRow(size_t n, const doublereal* const rw) {
|
||||
for (size_t j = 0; j < m_ncols; j++) {
|
||||
m_data[m_nrows*j + n] = rw[j];
|
||||
}
|
||||
for (size_t j = 0; j < m_ncols; j++) {
|
||||
m_data[m_nrows*j + n] = rw[j];
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the nth row and return it in a vector
|
||||
/*!
|
||||
* @param n Index of the row to be returned.
|
||||
* @param rw Return Vector for the operation.
|
||||
* @param rw Return Vector for the operation.
|
||||
* Must have a length of m_ncols.
|
||||
*/
|
||||
void getRow(size_t n, doublereal* const rw) {
|
||||
for (size_t j = 0; j < m_ncols; j++) {
|
||||
rw[j] = m_data[m_nrows*j + n];
|
||||
}
|
||||
for (size_t j = 0; j < m_ncols; j++) {
|
||||
rw[j] = m_data[m_nrows*j + n];
|
||||
}
|
||||
}
|
||||
|
||||
//! Set the values in column m to those in array col
|
||||
@@ -181,84 +187,88 @@ namespace Cantera {
|
||||
* A(i,m) = col(i)
|
||||
*
|
||||
* @param m Column to set
|
||||
* @param col pointer to a col vector. Vector
|
||||
* @param col pointer to a col vector. Vector
|
||||
* must have a length of m_nrows.
|
||||
*/
|
||||
void setColumn(size_t m, doublereal* const col) {
|
||||
for (size_t i = 0; i < m_nrows; i++) {
|
||||
m_data[m_nrows*m + i] = col[i];
|
||||
}
|
||||
for (size_t i = 0; i < m_nrows; i++) {
|
||||
m_data[m_nrows*m + i] = col[i];
|
||||
}
|
||||
}
|
||||
|
||||
//! Get the values in column m
|
||||
//! Get the values in column m
|
||||
/*!
|
||||
* col(i) = A(i,m)
|
||||
* col(i) = A(i,m)
|
||||
*
|
||||
* @param m Column to set
|
||||
* @param col pointer to a col vector that will be returned
|
||||
*/
|
||||
void getColumn(size_t m, doublereal* const col) {
|
||||
for (size_t i = 0; i < m_nrows; i++) {
|
||||
col[i] = m_data[m_nrows*m + i];
|
||||
}
|
||||
for (size_t i = 0; i < m_nrows; i++) {
|
||||
col[i] = m_data[m_nrows*m + i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destructor. Does nothing, since no memory allocated on the
|
||||
* heap.
|
||||
*/
|
||||
virtual ~Array2D(){}
|
||||
|
||||
virtual ~Array2D() {}
|
||||
|
||||
//! Evaluate z = a*x + y.
|
||||
/*!
|
||||
* This function evaluates the AXPY operation, and stores
|
||||
* the result in the object's Array2D object.
|
||||
* It's assumed that all 3 objects have the same dimensions,
|
||||
* but no error checking is done.
|
||||
* but no error checking is done.
|
||||
*
|
||||
* @param a scalar to multiply x with
|
||||
* @param x First Array2D object to be used
|
||||
* @param y Second Array2D object to be used
|
||||
* @param y Second Array2D object to be used
|
||||
*
|
||||
*/
|
||||
void axpy(doublereal a, const Array2D& x, const Array2D& y) {
|
||||
iterator b = begin();
|
||||
const_iterator xb = x.begin();
|
||||
const_iterator yb = y.begin();
|
||||
for (; b != end(); ++b, ++xb, ++yb) *b = a*(*xb) + *yb;
|
||||
iterator b = begin();
|
||||
const_iterator xb = x.begin();
|
||||
const_iterator yb = y.begin();
|
||||
for (; b != end(); ++b, ++xb, ++yb) {
|
||||
*b = a*(*xb) + *yb;
|
||||
}
|
||||
}
|
||||
|
||||
//! Set all of the entries to zero
|
||||
inline void zero() {
|
||||
int nn = m_nrows * m_ncols;
|
||||
if (nn > 0) {
|
||||
/*
|
||||
* Using memset is the fastest way to zero a contiguous
|
||||
* section of memory.
|
||||
*/
|
||||
(void) memset((void *) &m_data[0], 0, nn * sizeof(doublereal));
|
||||
}
|
||||
int nn = m_nrows * m_ncols;
|
||||
if (nn > 0) {
|
||||
/*
|
||||
* Using memset is the fastest way to zero a contiguous
|
||||
* section of memory.
|
||||
*/
|
||||
(void) memset((void*) &m_data[0], 0, nn * sizeof(doublereal));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Allows setting elements using the syntax A(i,j) = x.
|
||||
/*!
|
||||
* @param i row index
|
||||
* @param j column index.
|
||||
*
|
||||
* @return Returns a reference to A(i,j) which may be assigned.
|
||||
*/
|
||||
doublereal& operator()(size_t i, size_t j) { return value(i,j); }
|
||||
*/
|
||||
doublereal& operator()(size_t i, size_t j) {
|
||||
return value(i,j);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Allows retrieving elements using the syntax x = A(i,j).
|
||||
/*!
|
||||
* @param i Index for the row to be retrieved
|
||||
* @param j Index for the column to be retrieved.
|
||||
*
|
||||
* @return Returns the value of the matrix entry
|
||||
*/
|
||||
doublereal operator() (size_t i, size_t j) const {
|
||||
return value(i,j);
|
||||
*/
|
||||
doublereal operator()(size_t i, size_t j) const {
|
||||
return value(i,j);
|
||||
}
|
||||
|
||||
//! Returns a changeable reference to position in the matrix
|
||||
@@ -272,44 +282,60 @@ namespace Cantera {
|
||||
* @return Returns a changeable reference to the matrix entry
|
||||
*/
|
||||
doublereal& value(size_t i, size_t j) {
|
||||
return m_data[m_nrows*j + i];
|
||||
return m_data[m_nrows*j + i];
|
||||
}
|
||||
|
||||
//! Returns the value of a single matrix entry
|
||||
/*!
|
||||
* This is a key entry. Returns the value of the matrix position (i,j)
|
||||
* element.
|
||||
* element.
|
||||
*
|
||||
* @param i The row index
|
||||
* @param j The column index
|
||||
*/
|
||||
doublereal value(size_t i, size_t j) const {
|
||||
return m_data[m_nrows*j + i];
|
||||
return m_data[m_nrows*j + i];
|
||||
}
|
||||
|
||||
/// Number of rows
|
||||
size_t nRows() const { return m_nrows; }
|
||||
size_t nRows() const {
|
||||
return m_nrows;
|
||||
}
|
||||
|
||||
/// Number of columns
|
||||
size_t nColumns() const { return m_ncols; }
|
||||
size_t nColumns() const {
|
||||
return m_ncols;
|
||||
}
|
||||
|
||||
/// Return an iterator pointing to the first element
|
||||
iterator begin() { return m_data.begin(); }
|
||||
iterator begin() {
|
||||
return m_data.begin();
|
||||
}
|
||||
|
||||
/// Return an iterator pointing past the last element
|
||||
iterator end() { return m_data.end(); }
|
||||
iterator end() {
|
||||
return m_data.end();
|
||||
}
|
||||
|
||||
/// Return a const iterator pointing to the first element
|
||||
const_iterator begin() const { return m_data.begin(); }
|
||||
const_iterator begin() const {
|
||||
return m_data.begin();
|
||||
}
|
||||
|
||||
/// Return a const iterator pointing to past the last element
|
||||
const_iterator end() const { return m_data.end(); }
|
||||
const_iterator end() const {
|
||||
return m_data.end();
|
||||
}
|
||||
|
||||
/// Return a reference to the data vector
|
||||
vector_fp& data() { return m_data; }
|
||||
vector_fp& data() {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
/// Return a const reference to the data vector
|
||||
const vector_fp& data() const { return m_data; }
|
||||
const vector_fp& data() const {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
//! Return a pointer to the top of column j, columns are contiguous
|
||||
//! in memory
|
||||
@@ -318,7 +344,9 @@ namespace Cantera {
|
||||
*
|
||||
* @return Returns a pointer to the top of the column
|
||||
*/
|
||||
doublereal * ptrColumn(size_t j) { return &(m_data[m_nrows*j]); }
|
||||
doublereal* ptrColumn(size_t j) {
|
||||
return &(m_data[m_nrows*j]);
|
||||
}
|
||||
|
||||
//! Return a const pointer to the top of column j, columns are contiguous
|
||||
//! in memory
|
||||
@@ -327,11 +355,11 @@ namespace Cantera {
|
||||
*
|
||||
* @return Returns a const pointer to the top of the column
|
||||
*/
|
||||
const doublereal * ptrColumn(size_t j) const {
|
||||
return &(m_data[m_nrows*j]);
|
||||
const doublereal* ptrColumn(size_t j) const {
|
||||
return &(m_data[m_nrows*j]);
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
//! Data storred in a single array
|
||||
vector_fp m_data;
|
||||
@@ -341,56 +369,59 @@ namespace Cantera {
|
||||
|
||||
//! Number of columns
|
||||
size_t m_ncols;
|
||||
};
|
||||
};
|
||||
|
||||
//! Output the current contents of the Array2D object
|
||||
/*!
|
||||
* Example of usage:
|
||||
* s << m << endl;
|
||||
*
|
||||
* @param s Reference to the ostream to write to
|
||||
* @param m Object of type Array2D that you are querying
|
||||
*
|
||||
* @return Returns a reference to the ostream.
|
||||
*/
|
||||
inline std::ostream& operator<<(std::ostream& s, const Array2D& m) {
|
||||
//! Output the current contents of the Array2D object
|
||||
/*!
|
||||
* Example of usage:
|
||||
* s << m << endl;
|
||||
*
|
||||
* @param s Reference to the ostream to write to
|
||||
* @param m Object of type Array2D that you are querying
|
||||
*
|
||||
* @return Returns a reference to the ostream.
|
||||
*/
|
||||
inline std::ostream& operator<<(std::ostream& s, const Array2D& m)
|
||||
{
|
||||
size_t nr = m.nRows();
|
||||
size_t nc = m.nColumns();
|
||||
size_t i,j;
|
||||
for (i = 0; i < nr; i++) {
|
||||
for (j = 0; j < nc; j++) {
|
||||
s << m(i,j) << ", ";
|
||||
}
|
||||
s << std::endl;
|
||||
for (j = 0; j < nc; j++) {
|
||||
s << m(i,j) << ", ";
|
||||
}
|
||||
s << std::endl;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
//! Overload the times equals operator for multiplication
|
||||
//! of a matrix and a scalar.
|
||||
/*!
|
||||
* Scaled every element of the matrix by the scalar input
|
||||
*
|
||||
* @param m Matrix
|
||||
* @param a scalar
|
||||
*/
|
||||
inline void operator*=(Array2D& m, doublereal a) {
|
||||
//! Overload the times equals operator for multiplication
|
||||
//! of a matrix and a scalar.
|
||||
/*!
|
||||
* Scaled every element of the matrix by the scalar input
|
||||
*
|
||||
* @param m Matrix
|
||||
* @param a scalar
|
||||
*/
|
||||
inline void operator*=(Array2D& m, doublereal a)
|
||||
{
|
||||
scale(m.begin(), m.end(), m.begin(), a);
|
||||
}
|
||||
}
|
||||
|
||||
//! Overload the plus equals operator for addition
|
||||
//! of one matrix with another
|
||||
/*!
|
||||
* Adds each element of the second matrix into the first
|
||||
* matrix
|
||||
*
|
||||
* @param x First matrix
|
||||
* @param y Second matrix, which is a const
|
||||
*/
|
||||
inline void operator+=(Array2D& x, const Array2D& y) {
|
||||
//! Overload the plus equals operator for addition
|
||||
//! of one matrix with another
|
||||
/*!
|
||||
* Adds each element of the second matrix into the first
|
||||
* matrix
|
||||
*
|
||||
* @param x First matrix
|
||||
* @param y Second matrix, which is a const
|
||||
*/
|
||||
inline void operator+=(Array2D& x, const Array2D& y)
|
||||
{
|
||||
sum_each(x.begin(), x.end(), y.begin());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,46 +11,43 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#endif
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
//! Base class for factories.
|
||||
/*! This class maintains a registry of
|
||||
* all factories that derive from it, and deletes them all when
|
||||
* its static method deleteFactories is invoked.
|
||||
*/
|
||||
class FactoryBase
|
||||
{
|
||||
public:
|
||||
|
||||
//! Base class for factories.
|
||||
/*! This class maintains a registry of
|
||||
* all factories that derive from it, and deletes them all when
|
||||
* its static method deleteFactories is invoked.
|
||||
*/
|
||||
class FactoryBase
|
||||
{
|
||||
public:
|
||||
|
||||
//! destructor
|
||||
virtual ~FactoryBase()
|
||||
{
|
||||
virtual ~FactoryBase() {
|
||||
}
|
||||
|
||||
|
||||
//! static function that deletes all factories
|
||||
//! in the internal registry maintained in a static variable
|
||||
static void deleteFactories()
|
||||
{
|
||||
std::vector< FactoryBase* >::iterator iter ;
|
||||
for ( iter = s_vFactoryRegistry.begin();
|
||||
iter != s_vFactoryRegistry.end();
|
||||
++iter)
|
||||
{
|
||||
(*iter)->deleteFactory() ;
|
||||
}
|
||||
s_vFactoryRegistry.clear() ;
|
||||
static void deleteFactories() {
|
||||
std::vector< FactoryBase* >::iterator iter ;
|
||||
for (iter = s_vFactoryRegistry.begin();
|
||||
iter != s_vFactoryRegistry.end();
|
||||
++iter) {
|
||||
(*iter)->deleteFactory() ;
|
||||
}
|
||||
s_vFactoryRegistry.clear() ;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
|
||||
//! Constructor.
|
||||
/*!
|
||||
* Adds the current object to the current static list
|
||||
*/
|
||||
FactoryBase()
|
||||
{
|
||||
s_vFactoryRegistry.push_back(this) ;
|
||||
FactoryBase() {
|
||||
s_vFactoryRegistry.push_back(this) ;
|
||||
}
|
||||
|
||||
//! Virtual abstract function that deletes the factory
|
||||
@@ -58,12 +55,12 @@ namespace Cantera {
|
||||
* This must be properly defined in child objects.
|
||||
*/
|
||||
virtual void deleteFactory() = 0 ;
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
//! statically held list of Factories.
|
||||
static std::vector<FactoryBase*> s_vFactoryRegistry ;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,134 +20,144 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
LogPrintCtrl::LogPrintCtrl(int Ndec) :
|
||||
LogPrintCtrl::LogPrintCtrl(int Ndec) :
|
||||
m_ffss(0),
|
||||
m_pc(0)
|
||||
{
|
||||
{
|
||||
m_ffss = new std::ostream(m_os.rdbuf());
|
||||
m_pc = new PrintCtrl(*m_ffss, Ndec);
|
||||
}
|
||||
|
||||
LogPrintCtrl::~LogPrintCtrl() {
|
||||
}
|
||||
|
||||
LogPrintCtrl::~LogPrintCtrl()
|
||||
{
|
||||
delete m_pc;
|
||||
delete m_ffss;
|
||||
}
|
||||
}
|
||||
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces
|
||||
*
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*
|
||||
*
|
||||
*/
|
||||
void LogPrintCtrl::pr_de_c10(const double din, int p, const int wMin,
|
||||
const int wMax) {
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces
|
||||
*
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*
|
||||
*
|
||||
*/
|
||||
void LogPrintCtrl::pr_de_c10(const double din, int p, const int wMin,
|
||||
const int wMax)
|
||||
{
|
||||
m_pc->pr_de_c10(din, p, wMin, wMax);
|
||||
writelog(m_os.str());
|
||||
m_os.str("");
|
||||
}
|
||||
}
|
||||
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces. Rounding of the last digit is carried out
|
||||
* by the standard c++ printing utilities.
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*/
|
||||
void LogPrintCtrl::pr_de(const double d, int sigDigIn, const int wMinIn,
|
||||
const int wMaxIn) {
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces. Rounding of the last digit is carried out
|
||||
* by the standard c++ printing utilities.
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*/
|
||||
void LogPrintCtrl::pr_de(const double d, int sigDigIn, const int wMinIn,
|
||||
const int wMaxIn)
|
||||
{
|
||||
m_pc->pr_de(d, sigDigIn, wMinIn, wMaxIn);
|
||||
writelog(m_os.str());
|
||||
m_os.str("");
|
||||
}
|
||||
}
|
||||
|
||||
// Croup a double at a certain decade level
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* decade lvl. In other words everything below a power of 10^Ndec
|
||||
* will be deleted.
|
||||
* Note, it currently does not do rounding of the last digit.
|
||||
*
|
||||
* @param d Double to be cropped
|
||||
* @param nSig Number of significant digits
|
||||
* example:
|
||||
* d = 1.1305E-15;
|
||||
* Ndec = -16;
|
||||
* This routine will return 1.1E-15
|
||||
*
|
||||
* d = 8.0E-17
|
||||
* Ndec = -16
|
||||
* This routine will return 0.0
|
||||
*/
|
||||
double LogPrintCtrl::cropAbs10(const double d, int Ndec) const {
|
||||
// Croup a double at a certain decade level
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* decade lvl. In other words everything below a power of 10^Ndec
|
||||
* will be deleted.
|
||||
* Note, it currently does not do rounding of the last digit.
|
||||
*
|
||||
* @param d Double to be cropped
|
||||
* @param nSig Number of significant digits
|
||||
* example:
|
||||
* d = 1.1305E-15;
|
||||
* Ndec = -16;
|
||||
* This routine will return 1.1E-15
|
||||
*
|
||||
* d = 8.0E-17
|
||||
* Ndec = -16
|
||||
* This routine will return 0.0
|
||||
*/
|
||||
double LogPrintCtrl::cropAbs10(const double d, int Ndec) const
|
||||
{
|
||||
return m_pc->cropAbs10(d, Ndec);
|
||||
}
|
||||
}
|
||||
|
||||
// Crop a double at a certain number of significant digits
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* number of significant digits. Note, it currently does
|
||||
* rounding up of the last digit.
|
||||
*
|
||||
* example:
|
||||
* d = 1.0305E-15;
|
||||
* nsig = 3;
|
||||
* This routine will return 1.03E-15
|
||||
*/
|
||||
double LogPrintCtrl::cropSigDigits(const double d, int nSig) const {
|
||||
// Crop a double at a certain number of significant digits
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* number of significant digits. Note, it currently does
|
||||
* rounding up of the last digit.
|
||||
*
|
||||
* example:
|
||||
* d = 1.0305E-15;
|
||||
* nsig = 3;
|
||||
* This routine will return 1.03E-15
|
||||
*/
|
||||
double LogPrintCtrl::cropSigDigits(const double d, int nSig) const
|
||||
{
|
||||
return m_pc->cropSigDigits(d, nSig);
|
||||
}
|
||||
|
||||
// Set the default value of N decade
|
||||
/*
|
||||
* @param Ndec new value of Ndec
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int LogPrintCtrl::setNdec(int Ndec) {
|
||||
}
|
||||
|
||||
// Set the default value of N decade
|
||||
/*
|
||||
* @param Ndec new value of Ndec
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int LogPrintCtrl::setNdec(int Ndec)
|
||||
{
|
||||
return m_pc->setNdec(Ndec);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the default significant digits to output
|
||||
/*
|
||||
* @param nSigDigits new value of the sig digits
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int LogPrintCtrl::setSigDigits(int nSigDigits) {
|
||||
// Set the default significant digits to output
|
||||
/*
|
||||
* @param nSigDigits new value of the sig digits
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int LogPrintCtrl::setSigDigits(int nSigDigits)
|
||||
{
|
||||
return m_pc->setSigDigits(nSigDigits);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the default minimum width
|
||||
/*
|
||||
* @param wmin Default minimum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int LogPrintCtrl::setWmin(int wmin) {
|
||||
// Set the default minimum width
|
||||
/*
|
||||
* @param wmin Default minimum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int LogPrintCtrl::setWmin(int wmin)
|
||||
{
|
||||
return m_pc->setWmin(wmin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the default maximum width
|
||||
/*
|
||||
* @param wmin Default maximum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int LogPrintCtrl::setWmax(int wmax) {
|
||||
// Set the default maximum width
|
||||
/*
|
||||
* @param wmin Default maximum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int LogPrintCtrl::setWmax(int wmax)
|
||||
{
|
||||
return m_pc->setWmax(wmax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,30 +17,32 @@
|
||||
|
||||
#include "PrintCtrl.h"
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
//! This class provides some printing and cropping utilities
|
||||
//! for writing to the logfile.
|
||||
/*!
|
||||
* This class writes its output to Cantera's logfile
|
||||
* utility. It's a wrapper around PrintCtrl object.
|
||||
* First, we direct PrintCtrl to write to a string
|
||||
* and then we redirect the string to the logfile utility.
|
||||
* This is a first cut, and it's pretty much a kluge.
|
||||
* The logfile utility, however, demands a string, and this
|
||||
* is what I came up with.
|
||||
*
|
||||
* @ingroup globalUtilFuncs
|
||||
*
|
||||
*/
|
||||
class LogPrintCtrl {
|
||||
public:
|
||||
//! This class provides some printing and cropping utilities
|
||||
//! for writing to the logfile.
|
||||
/*!
|
||||
* This class writes its output to Cantera's logfile
|
||||
* utility. It's a wrapper around PrintCtrl object.
|
||||
* First, we direct PrintCtrl to write to a string
|
||||
* and then we redirect the string to the logfile utility.
|
||||
* This is a first cut, and it's pretty much a kluge.
|
||||
* The logfile utility, however, demands a string, and this
|
||||
* is what I came up with.
|
||||
*
|
||||
* @ingroup globalUtilFuncs
|
||||
*
|
||||
*/
|
||||
class LogPrintCtrl
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
* This also serves to initialize the ticks within the object
|
||||
*
|
||||
* @param Ndec value of Ndec. Defaults to -1000, i.e.,
|
||||
* @param Ndec value of Ndec. Defaults to -1000, i.e.,
|
||||
* no decade cropping
|
||||
*/
|
||||
LogPrintCtrl(int Ndec = -1000);
|
||||
@@ -58,16 +60,16 @@ namespace Cantera {
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param sigDigits Number of significant digits
|
||||
* (-1 = default, means to use the default
|
||||
* (-1 = default, means to use the default
|
||||
* number for the object, which is initially
|
||||
* set to 13.
|
||||
* @param wMin Minimum number of spaces to print out
|
||||
* @param wMax Maximum number of spaces to print out
|
||||
*/
|
||||
void pr_de(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
void pr_de(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
|
||||
//! Print a double using scientific notation cropping
|
||||
//! Print a double using scientific notation cropping
|
||||
//! decade values
|
||||
/*!
|
||||
* Prints a double using scientific notation in a
|
||||
@@ -79,14 +81,14 @@ namespace Cantera {
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param sigDigits Number of significant digits
|
||||
* (-1 = default, means to use the default
|
||||
* (-1 = default, means to use the default
|
||||
* number for the object, which is initially
|
||||
* set to 13.
|
||||
* @param wMin Minimum number of spaces to print out
|
||||
* @param wMax Maximum number of spaces to print out
|
||||
*/
|
||||
void pr_de_c10(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
void pr_de_c10(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
|
||||
//! Crop a double at a certain number of significant digits
|
||||
/*!
|
||||
@@ -116,7 +118,7 @@ namespace Cantera {
|
||||
* d = 1.1305E-15;
|
||||
* nDecades = -16;
|
||||
* This routine will return 1.1E-15
|
||||
*
|
||||
*
|
||||
* d = 8.0E-17
|
||||
* nDecades = -16
|
||||
* This routine will return 0.0
|
||||
@@ -131,7 +133,7 @@ namespace Cantera {
|
||||
*/
|
||||
int setNdec(int nDecades);
|
||||
|
||||
|
||||
|
||||
//! Set the default significant digits to output
|
||||
/*!
|
||||
* @param sigDigits new value of the sig digits
|
||||
@@ -139,7 +141,7 @@ namespace Cantera {
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int setSigDigits(int sigDigits);
|
||||
|
||||
|
||||
//! Set the default minimum width
|
||||
/*!
|
||||
* @param wMin Default minimum width
|
||||
@@ -155,23 +157,23 @@ namespace Cantera {
|
||||
* @return returns the old default
|
||||
*/
|
||||
int setWmax(int wMax);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//! local stringstream class for temp output
|
||||
private:
|
||||
|
||||
//! local stringstream class for temp output
|
||||
std::ostringstream m_os;
|
||||
|
||||
//! Pointer to the ostream where this class actually
|
||||
//! prints its information
|
||||
std::ostream *m_ffss;
|
||||
std::ostream* m_ffss;
|
||||
|
||||
//! Pointer to the PrintCtrl class
|
||||
PrintCtrl *m_pc;
|
||||
PrintCtrl* m_pc;
|
||||
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,93 +19,106 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
// Storage for the global crop flag
|
||||
PrintCtrl::CROP_TYPE_GLOBAL PrintCtrl::GlobalCrop = GCT_NOPREF;
|
||||
// Storage for the global crop flag
|
||||
PrintCtrl::CROP_TYPE_GLOBAL PrintCtrl::GlobalCrop = GCT_NOPREF;
|
||||
|
||||
|
||||
PrintCtrl::PrintCtrl(std::ostream &coutProxy, int Ndec,
|
||||
CROP_TYPE ctlocal) :
|
||||
PrintCtrl::PrintCtrl(std::ostream& coutProxy, int Ndec,
|
||||
CROP_TYPE ctlocal) :
|
||||
m_cout(coutProxy),
|
||||
m_Ndec(Ndec),
|
||||
m_precision(12),
|
||||
m_wMin(9),
|
||||
m_wMax(19),
|
||||
m_cropCntrl(ctlocal)
|
||||
{
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces
|
||||
*
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*
|
||||
*
|
||||
*/
|
||||
void PrintCtrl::pr_de_c10(const double din, int p, const int wMin,
|
||||
const int wMax) {
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces
|
||||
*
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*
|
||||
*
|
||||
*/
|
||||
void PrintCtrl::pr_de_c10(const double din, int p, const int wMin,
|
||||
const int wMax)
|
||||
{
|
||||
double d = cropAbs10(din, m_Ndec);
|
||||
pr_de(d, p, wMin, wMax);
|
||||
}
|
||||
}
|
||||
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces. Rounding of the last digit is carried out
|
||||
* by the standard c++ printing utilities.
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*/
|
||||
void PrintCtrl::pr_de(const double d, int sigDigIn, const int wMinIn,
|
||||
const int wMaxIn) {
|
||||
// Print a double using scientific notation
|
||||
/*
|
||||
* Prints a double using scientific notation in a
|
||||
* fixed number of spaces. Rounding of the last digit is carried out
|
||||
* by the standard c++ printing utilities.
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param w Number of spaces to use
|
||||
* @param p Precision
|
||||
*/
|
||||
void PrintCtrl::pr_de(const double d, int sigDigIn, const int wMinIn,
|
||||
const int wMaxIn)
|
||||
{
|
||||
int p = m_precision;
|
||||
if (sigDigIn != -1) {
|
||||
p = sigDigIn-1;
|
||||
if (p < 0) p = 0;
|
||||
p = sigDigIn-1;
|
||||
if (p < 0) {
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int wMin = m_wMin;
|
||||
if (wMinIn != -1) {
|
||||
wMin = wMinIn;
|
||||
if (wMin < 1) wMin = 1;
|
||||
wMin = wMinIn;
|
||||
if (wMin < 1) {
|
||||
wMin = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int wMax = m_wMax;
|
||||
if (wMaxIn != -1) {
|
||||
wMax = wMaxIn;
|
||||
if (wMax < 1) wMax = 1;
|
||||
wMax = wMaxIn;
|
||||
if (wMax < 1) {
|
||||
wMax = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (wMin > wMax) wMax = wMin;
|
||||
if (wMin > wMax) {
|
||||
wMax = wMin;
|
||||
}
|
||||
|
||||
// Have to do the wMax ourselves, since C++ doesn't seem to
|
||||
// Have to do the wMax ourselves, since C++ doesn't seem to
|
||||
// have a streams manipulator to do this !?!
|
||||
double dfabs = fabs(d);
|
||||
// This is the normal length assuming no sign and an 1.0E+04
|
||||
// formated exponented
|
||||
int requestedLength = 6 + p;
|
||||
if (d < 0.0) {
|
||||
requestedLength++;
|
||||
requestedLength++;
|
||||
}
|
||||
if (dfabs < 9.9999999999E-99) {
|
||||
requestedLength++;
|
||||
requestedLength++;
|
||||
}
|
||||
if (dfabs > 9.9999999999E99) {
|
||||
requestedLength++;
|
||||
requestedLength++;
|
||||
}
|
||||
if (requestedLength > wMax) {
|
||||
p -= (requestedLength - wMax);
|
||||
if (p < 0) p = 0;
|
||||
p -= (requestedLength - wMax);
|
||||
if (p < 0) {
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set to upper case and scientific notation
|
||||
@@ -116,76 +129,84 @@ namespace Cantera {
|
||||
m_cout << d;
|
||||
// Return the precision to the previous value;
|
||||
m_cout.precision(pold);
|
||||
m_cout.unsetf(ios_base::scientific);
|
||||
m_cout.unsetf(ios_base::scientific);
|
||||
|
||||
// Return width to original
|
||||
m_cout.width(wold);
|
||||
}
|
||||
}
|
||||
|
||||
// Croup a double at a certain decade level
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* decade lvl. In other words everything below a power of 10^Ndec
|
||||
* will be deleted.
|
||||
* Note, it currently does not do rounding of the last digit.
|
||||
*
|
||||
* @param d Double to be cropped
|
||||
* @param nSig Number of significant digits
|
||||
* example:
|
||||
* d = 1.1305E-15;
|
||||
* Ndec = -16;
|
||||
* This routine will return 1.1E-15
|
||||
*
|
||||
* d = 8.0E-17
|
||||
* Ndec = -16
|
||||
* This routine will return 0.0
|
||||
*/
|
||||
double PrintCtrl::cropAbs10(const double d, int Ndec) const {
|
||||
// Croup a double at a certain decade level
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* decade lvl. In other words everything below a power of 10^Ndec
|
||||
* will be deleted.
|
||||
* Note, it currently does not do rounding of the last digit.
|
||||
*
|
||||
* @param d Double to be cropped
|
||||
* @param nSig Number of significant digits
|
||||
* example:
|
||||
* d = 1.1305E-15;
|
||||
* Ndec = -16;
|
||||
* This routine will return 1.1E-15
|
||||
*
|
||||
* d = 8.0E-17
|
||||
* Ndec = -16
|
||||
* This routine will return 0.0
|
||||
*/
|
||||
double PrintCtrl::cropAbs10(const double d, int Ndec) const
|
||||
{
|
||||
if (!doCrop()) {
|
||||
return d;
|
||||
return d;
|
||||
}
|
||||
if (Ndec < -301 || Ndec > 301) {
|
||||
return d;
|
||||
return d;
|
||||
}
|
||||
double dfabs = fabs(d);
|
||||
double pdec = pow(10.0, (double) Ndec);
|
||||
if (dfabs < pdec) {
|
||||
return 0.0;
|
||||
return 0.0;
|
||||
}
|
||||
double dl10 = log10(dfabs);
|
||||
int N10 = (int) dl10;
|
||||
if (dl10 > -0.0) {
|
||||
N10 += 1;
|
||||
N10 += 1;
|
||||
}
|
||||
int nsig = N10 - Ndec;
|
||||
double retn = cropSigDigits(d, nsig);
|
||||
return retn;
|
||||
}
|
||||
}
|
||||
|
||||
// Crop a double at a certain number of significant digits
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* number of significant digits. Note, it currently does
|
||||
* rounding up of the last digit.
|
||||
*
|
||||
* example:
|
||||
* d = 1.0305E-15;
|
||||
* nsig = 3;
|
||||
* This routine will return 1.03E-15
|
||||
*/
|
||||
double PrintCtrl::cropSigDigits(const double d, int nSig) const {
|
||||
// Crop a double at a certain number of significant digits
|
||||
/*
|
||||
* This routine will crop a floating point number at a certain
|
||||
* number of significant digits. Note, it currently does
|
||||
* rounding up of the last digit.
|
||||
*
|
||||
* example:
|
||||
* d = 1.0305E-15;
|
||||
* nsig = 3;
|
||||
* This routine will return 1.03E-15
|
||||
*/
|
||||
double PrintCtrl::cropSigDigits(const double d, int nSig) const
|
||||
{
|
||||
if (!doCrop()) {
|
||||
return d;
|
||||
return d;
|
||||
}
|
||||
if (nSig <=0) {
|
||||
nSig = 1;
|
||||
}
|
||||
if (nSig >=9) {
|
||||
nSig = 9;
|
||||
}
|
||||
if (nSig <=0) nSig = 1;
|
||||
if (nSig >=9) nSig = 9;
|
||||
double sgn = 1.0;
|
||||
if (d < 0.0) sgn = -1.0;
|
||||
if (d < 0.0) {
|
||||
sgn = -1.0;
|
||||
}
|
||||
double dfabs = fabs(d);
|
||||
double dl10 = log10(dfabs);
|
||||
int N10 = (int) dl10;
|
||||
if (dl10 > -0.0) {
|
||||
N10 += 1;
|
||||
N10 += 1;
|
||||
}
|
||||
int E10 = -N10 + nSig ;
|
||||
double pfabs = dfabs * pow(10.0, (double) E10);
|
||||
@@ -193,78 +214,86 @@ namespace Cantera {
|
||||
long int nfabs = (long int) pfabs;
|
||||
double remainder = pfabs - nfabs;
|
||||
if (remainder > 0.5) {
|
||||
nfabs++;
|
||||
nfabs++;
|
||||
}
|
||||
double paltabs = (double) nfabs;
|
||||
double daltabs = paltabs * pow(10.0, (double) -E10);
|
||||
return (sgn * daltabs);
|
||||
}
|
||||
|
||||
// Set the default value of N decade
|
||||
/*
|
||||
* @param Ndec new value of Ndec
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int PrintCtrl::setNdec(int Ndec) {
|
||||
}
|
||||
|
||||
// Set the default value of N decade
|
||||
/*
|
||||
* @param Ndec new value of Ndec
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int PrintCtrl::setNdec(int Ndec)
|
||||
{
|
||||
int nold = m_Ndec;
|
||||
m_Ndec = Ndec;
|
||||
return nold;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the default significant digits to output
|
||||
/*
|
||||
* @param nSigDigits new value of the sig digits
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int PrintCtrl::setSigDigits(int nSigDigits) {
|
||||
// Set the default significant digits to output
|
||||
/*
|
||||
* @param nSigDigits new value of the sig digits
|
||||
*
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int PrintCtrl::setSigDigits(int nSigDigits)
|
||||
{
|
||||
int nold = m_precision + 1;
|
||||
m_precision = nSigDigits - 1;
|
||||
if (m_precision < 0) m_precision = 0;
|
||||
if (m_precision < 0) {
|
||||
m_precision = 0;
|
||||
}
|
||||
return nold;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the default minimum width
|
||||
/*
|
||||
* @param wmin Default minimum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int PrintCtrl::setWmin(int wmin) {
|
||||
// Set the default minimum width
|
||||
/*
|
||||
* @param wmin Default minimum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int PrintCtrl::setWmin(int wmin)
|
||||
{
|
||||
int nold = m_wMin;
|
||||
m_wMin = wmin;
|
||||
return nold;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set the default maximum width
|
||||
/*
|
||||
* @param wmin Default maximum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int PrintCtrl::setWmax(int wmax) {
|
||||
// Set the default maximum width
|
||||
/*
|
||||
* @param wmin Default maximum width
|
||||
*
|
||||
* @return returns the old default
|
||||
*/
|
||||
int PrintCtrl::setWmax(int wmax)
|
||||
{
|
||||
int nold = m_wMax;
|
||||
m_wMax = wmax;
|
||||
return nold;
|
||||
}
|
||||
}
|
||||
|
||||
bool PrintCtrl::doCrop() const {
|
||||
bool PrintCtrl::doCrop() const
|
||||
{
|
||||
bool retn = ((m_cropCntrl == CT_ON) || (m_cropCntrl == CT_ON_GLOBALOBEY));
|
||||
if (m_cropCntrl == CT_ON_GLOBALOBEY) {
|
||||
if (GlobalCrop == GCT_NOCROP) {
|
||||
retn = false;
|
||||
}
|
||||
if (GlobalCrop == GCT_NOCROP) {
|
||||
retn = false;
|
||||
}
|
||||
} else if (m_cropCntrl == CT_OFF_GLOBALOBEY) {
|
||||
if (GlobalCrop == GCT_CROP) {
|
||||
retn = true;
|
||||
}
|
||||
if (GlobalCrop == GCT_CROP) {
|
||||
retn = true;
|
||||
}
|
||||
}
|
||||
return retn;
|
||||
}
|
||||
|
||||
void PrintCtrl:: setCropCntrl(CROP_TYPE ctlocal) {
|
||||
m_cropCntrl = ctlocal;
|
||||
}
|
||||
}
|
||||
|
||||
void PrintCtrl:: setCropCntrl(CROP_TYPE ctlocal)
|
||||
{
|
||||
m_cropCntrl = ctlocal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,61 +15,63 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
//! This class provides some printing and cropping utilities
|
||||
/*!
|
||||
* The class is used to provide some formatting options for
|
||||
* printing out real numbers to files and to standard output.
|
||||
* Specifically, it can make sure that a max and min field
|
||||
* width is honored when conducting IO of numbers and strings.
|
||||
* Basically, its the spot to house all wrappers around
|
||||
* commonly used printing facilities.
|
||||
*
|
||||
* It can also handle cropping of numbers below a certain
|
||||
* decade level. This is useful for IO for testing purposes.
|
||||
* For example, if you don't care about anything below
|
||||
* 1.0E-20, you can set up the IO so that it won't print out
|
||||
* any digits below 1.0E-20, even digits that are in numbers
|
||||
* greater than 1.0E-20. In other words the number
|
||||
*
|
||||
* 1.12345E-19
|
||||
*
|
||||
* whould be cropped to the value
|
||||
*
|
||||
* 1.1000E-19
|
||||
*
|
||||
* The class wraps aroud a single std::ostream class. It's
|
||||
* cropping functions are also available as a "double"
|
||||
* conversion utility.
|
||||
*
|
||||
*
|
||||
* @ingroup globalUtilFuncs
|
||||
*
|
||||
*/
|
||||
class PrintCtrl {
|
||||
public:
|
||||
//! This class provides some printing and cropping utilities
|
||||
/*!
|
||||
* The class is used to provide some formatting options for
|
||||
* printing out real numbers to files and to standard output.
|
||||
* Specifically, it can make sure that a max and min field
|
||||
* width is honored when conducting IO of numbers and strings.
|
||||
* Basically, its the spot to house all wrappers around
|
||||
* commonly used printing facilities.
|
||||
*
|
||||
* It can also handle cropping of numbers below a certain
|
||||
* decade level. This is useful for IO for testing purposes.
|
||||
* For example, if you don't care about anything below
|
||||
* 1.0E-20, you can set up the IO so that it won't print out
|
||||
* any digits below 1.0E-20, even digits that are in numbers
|
||||
* greater than 1.0E-20. In other words the number
|
||||
*
|
||||
* 1.12345E-19
|
||||
*
|
||||
* whould be cropped to the value
|
||||
*
|
||||
* 1.1000E-19
|
||||
*
|
||||
* The class wraps aroud a single std::ostream class. It's
|
||||
* cropping functions are also available as a "double"
|
||||
* conversion utility.
|
||||
*
|
||||
*
|
||||
* @ingroup globalUtilFuncs
|
||||
*
|
||||
*/
|
||||
class PrintCtrl
|
||||
{
|
||||
public:
|
||||
|
||||
//! enum for cropping control
|
||||
enum CROP_TYPE {
|
||||
//! Turn off cropping always
|
||||
CT_OFF=0,
|
||||
//! Turn off cropping, unless the global toggle is turned on
|
||||
CT_OFF_GLOBALOBEY,
|
||||
//! Turn on cropping unless the global toggle is turned off
|
||||
CT_ON_GLOBALOBEY,
|
||||
//! Turn on cropping always
|
||||
CT_ON
|
||||
enum CROP_TYPE {
|
||||
//! Turn off cropping always
|
||||
CT_OFF=0,
|
||||
//! Turn off cropping, unless the global toggle is turned on
|
||||
CT_OFF_GLOBALOBEY,
|
||||
//! Turn on cropping unless the global toggle is turned off
|
||||
CT_ON_GLOBALOBEY,
|
||||
//! Turn on cropping always
|
||||
CT_ON
|
||||
};
|
||||
|
||||
//! enum for global cropping control
|
||||
enum CROP_TYPE_GLOBAL {
|
||||
//! no preference for global cropping
|
||||
GCT_NOPREF = 0,
|
||||
//! global toggle for turning on cropping
|
||||
GCT_CROP,
|
||||
//! global toggle for turning off cropping
|
||||
GCT_NOCROP
|
||||
//! no preference for global cropping
|
||||
GCT_NOPREF = 0,
|
||||
//! global toggle for turning on cropping
|
||||
GCT_CROP,
|
||||
//! global toggle for turning off cropping
|
||||
GCT_NOCROP
|
||||
};
|
||||
|
||||
//! static enum for turning on and off cropping
|
||||
@@ -84,12 +86,12 @@ namespace Cantera {
|
||||
*
|
||||
* @param coutProxy This is a reference to the ostream
|
||||
* to use for all IO from ths object.
|
||||
* @param Ndec value of Ndec. Defaults to -1000, i.e.,
|
||||
* @param Ndec value of Ndec. Defaults to -1000, i.e.,
|
||||
* no decade cropping
|
||||
* @param ctlocal The default is to turn on cropping all the time.
|
||||
*/
|
||||
PrintCtrl(std::ostream &coutProxy = std::cout, int Ndec = -1000,
|
||||
CROP_TYPE ctlocal = CT_ON);
|
||||
PrintCtrl(std::ostream& coutProxy = std::cout, int Ndec = -1000,
|
||||
CROP_TYPE ctlocal = CT_ON);
|
||||
|
||||
//! Print a double using scientific notation
|
||||
/*!
|
||||
@@ -101,16 +103,16 @@ namespace Cantera {
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param sigDigits Number of significant digits
|
||||
* (-1 = default, means to use the default
|
||||
* (-1 = default, means to use the default
|
||||
* number for the object, which is initially
|
||||
* set to 13.
|
||||
* @param wMin Minimum number of spaces to print out
|
||||
* @param wMax Maximum number of spaces to print out
|
||||
*/
|
||||
void pr_de(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
void pr_de(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
|
||||
//! Print a double using scientific notation cropping
|
||||
//! Print a double using scientific notation cropping
|
||||
//! decade values
|
||||
/*!
|
||||
* Prints a double using scientific notation in a
|
||||
@@ -122,14 +124,14 @@ namespace Cantera {
|
||||
*
|
||||
* @param d double to be printed
|
||||
* @param sigDigits Number of significant digits
|
||||
* (-1 = default, means to use the default
|
||||
* (-1 = default, means to use the default
|
||||
* number for the object, which is initially
|
||||
* set to 13.
|
||||
* @param wMin Minimum number of spaces to print out
|
||||
* @param wMax Maximum number of spaces to print out
|
||||
*/
|
||||
void pr_de_c10(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
void pr_de_c10(const double d, int sigDigits = -1,
|
||||
const int wMin = -1, const int wMax = -1);
|
||||
|
||||
//! Crop a double at a certain number of significant digits
|
||||
/*!
|
||||
@@ -159,7 +161,7 @@ namespace Cantera {
|
||||
* d = 1.1305E-15;
|
||||
* nDecades = -16;
|
||||
* This routine will return 1.1E-15
|
||||
*
|
||||
*
|
||||
* d = 8.0E-17
|
||||
* nDecades = -16
|
||||
* This routine will return 0.0
|
||||
@@ -174,7 +176,7 @@ namespace Cantera {
|
||||
*/
|
||||
int setNdec(int nDecades);
|
||||
|
||||
|
||||
|
||||
//! Set the default significant digits to output
|
||||
/*!
|
||||
* @param sigDigits new value of the sig digits
|
||||
@@ -182,7 +184,7 @@ namespace Cantera {
|
||||
* @return returns the old value of Ndec
|
||||
*/
|
||||
int setSigDigits(int sigDigits);
|
||||
|
||||
|
||||
//! Set the default minimum width
|
||||
/*!
|
||||
* @param wMin Default minimum width
|
||||
@@ -204,25 +206,25 @@ namespace Cantera {
|
||||
* @param ctlocal Local enum value for the cropping type
|
||||
*/
|
||||
void setCropCntrl(CROP_TYPE ctlocal);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
//! private function to figure out cropping logic
|
||||
/*!
|
||||
* @return Returns the decision as to whether to crop or not
|
||||
*/
|
||||
bool doCrop() const;
|
||||
|
||||
|
||||
//! This is the ostream to send all output from the object
|
||||
/*!
|
||||
* It defaults to cout
|
||||
*/
|
||||
std::ostream &m_cout;
|
||||
std::ostream& m_cout;
|
||||
|
||||
//! Default decade level to use for decade cropping
|
||||
/*!
|
||||
* This is initially set to -1000, which means that
|
||||
* This is initially set to -1000, which means that
|
||||
* no cropping will be carried out
|
||||
*/
|
||||
int m_Ndec;
|
||||
@@ -231,7 +233,7 @@ namespace Cantera {
|
||||
/*!
|
||||
* This actually is one less than the number of significant digits.
|
||||
*
|
||||
* Initially set to 12
|
||||
* Initially set to 12
|
||||
*/
|
||||
int m_precision;
|
||||
|
||||
@@ -249,7 +251,7 @@ namespace Cantera {
|
||||
|
||||
//! Local Cropping Control
|
||||
CROP_TYPE m_cropCntrl;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,98 +4,115 @@
|
||||
// Note: this class is only used by TransportFactory, and is likely to
|
||||
// go away a a future date.
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
////////////////////// XML_Writer //////////////////////////
|
||||
////////////////////// XML_Writer //////////////////////////
|
||||
|
||||
class XML_Writer {
|
||||
public:
|
||||
XML_Writer(std::ostream& output) :
|
||||
m_s(output), _indent(" "), _level(0) {}
|
||||
virtual ~XML_Writer() {}
|
||||
std::ostream& m_s;
|
||||
class XML_Writer
|
||||
{
|
||||
public:
|
||||
XML_Writer(std::ostream& output) :
|
||||
m_s(output), _indent(" "), _level(0) {}
|
||||
virtual ~XML_Writer() {}
|
||||
std::ostream& m_s;
|
||||
|
||||
std::string _indent;
|
||||
int _level;
|
||||
std::string _indent;
|
||||
int _level;
|
||||
|
||||
std::ostream& output() { return m_s; }
|
||||
std::ostream& output() {
|
||||
return m_s;
|
||||
}
|
||||
|
||||
inline std::string XML_filter(std::string name) {
|
||||
int ns = static_cast<int>(name.size());
|
||||
std::string nm(name);
|
||||
for (int m = 0; m < ns; m++)
|
||||
if (name[m] == ' '
|
||||
inline std::string XML_filter(std::string name) {
|
||||
int ns = static_cast<int>(name.size());
|
||||
std::string nm(name);
|
||||
for (int m = 0; m < ns; m++)
|
||||
if (name[m] == ' '
|
||||
|| name[m] == '('
|
||||
|| name[m] == ')')
|
||||
nm[m] = '_';
|
||||
return nm;
|
||||
}
|
||||
|
||||
/**
|
||||
* XML_comment()
|
||||
*
|
||||
* Add a comment element to the current XML output file
|
||||
* Comment elements start with <!-- and end with -->
|
||||
* Comments are indented according to the current lvl,
|
||||
* _level
|
||||
*
|
||||
* input
|
||||
* ---------
|
||||
* s : Output stream containing the XML file
|
||||
* comment : Reference to a string containing the comment
|
||||
*/
|
||||
inline void XML_comment(std::ostream& s, const std::string& comment) {
|
||||
for (int n = 0; n < _level; n++) s << _indent;
|
||||
s << "<!--" << comment << "-->" << std::endl;
|
||||
}
|
||||
|
||||
inline void XML_open(std::ostream& s, const std::string& tag, const std::string p = "") {
|
||||
for (int n = 0; n < _level; n++) s << _indent;
|
||||
_level++;
|
||||
s << "<" << XML_filter(tag) << p << ">" << std::endl;
|
||||
}
|
||||
|
||||
inline void XML_close(std::ostream& s, const std::string& tag) {
|
||||
_level--;
|
||||
for (int n = 0; n < _level; n++) s << _indent;
|
||||
s << "</" << XML_filter(tag) << ">" << std::endl;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void XML_item(std::ostream& s, const std::string& tag, T value) {
|
||||
for (int n = 0; n < _level; n++) s << _indent;
|
||||
s << "<" << XML_filter(tag) << ">"
|
||||
<< value << "</" << tag << ">" << std::endl;
|
||||
}
|
||||
|
||||
template<class iter>
|
||||
void XML_writeVector(std::ostream& s, const std::string& indent,
|
||||
const std::string& name, int vsize, iter v) {
|
||||
int ni;
|
||||
for (ni = 0; ni < _level; ni++) s << _indent;
|
||||
s << "<" << XML_filter(name) << "> ";
|
||||
|
||||
int n = vsize;
|
||||
int n5 = n/5;
|
||||
int i, j, k = 0;
|
||||
for (j = 0; j < n5; j++) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
s << v[k] << (k < n - 1 ? ", " : "");
|
||||
k++;
|
||||
}
|
||||
if (j < n5-1) {
|
||||
s << std::endl;
|
||||
for (ni = 0; ni < _level; ni++) s << _indent;
|
||||
}
|
||||
|| name[m] == ')') {
|
||||
nm[m] = '_';
|
||||
}
|
||||
for (i = k; i < n; i++) {
|
||||
s << v[k] << (k < n - 1 ? ", " : "");
|
||||
return nm;
|
||||
}
|
||||
|
||||
/**
|
||||
* XML_comment()
|
||||
*
|
||||
* Add a comment element to the current XML output file
|
||||
* Comment elements start with <!-- and end with -->
|
||||
* Comments are indented according to the current lvl,
|
||||
* _level
|
||||
*
|
||||
* input
|
||||
* ---------
|
||||
* s : Output stream containing the XML file
|
||||
* comment : Reference to a string containing the comment
|
||||
*/
|
||||
inline void XML_comment(std::ostream& s, const std::string& comment) {
|
||||
for (int n = 0; n < _level; n++) {
|
||||
s << _indent;
|
||||
}
|
||||
s << "<!--" << comment << "-->" << std::endl;
|
||||
}
|
||||
|
||||
inline void XML_open(std::ostream& s, const std::string& tag, const std::string p = "") {
|
||||
for (int n = 0; n < _level; n++) {
|
||||
s << _indent;
|
||||
}
|
||||
_level++;
|
||||
s << "<" << XML_filter(tag) << p << ">" << std::endl;
|
||||
}
|
||||
|
||||
inline void XML_close(std::ostream& s, const std::string& tag) {
|
||||
_level--;
|
||||
for (int n = 0; n < _level; n++) {
|
||||
s << _indent;
|
||||
}
|
||||
s << "</" << XML_filter(tag) << ">" << std::endl;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void XML_item(std::ostream& s, const std::string& tag, T value) {
|
||||
for (int n = 0; n < _level; n++) {
|
||||
s << _indent;
|
||||
}
|
||||
s << "<" << XML_filter(tag) << ">"
|
||||
<< value << "</" << tag << ">" << std::endl;
|
||||
}
|
||||
|
||||
template<class iter>
|
||||
void XML_writeVector(std::ostream& s, const std::string& indent,
|
||||
const std::string& name, int vsize, iter v) {
|
||||
int ni;
|
||||
for (ni = 0; ni < _level; ni++) {
|
||||
s << _indent;
|
||||
}
|
||||
s << "<" << XML_filter(name) << "> ";
|
||||
|
||||
int n = vsize;
|
||||
int n5 = n/5;
|
||||
int i, j, k = 0;
|
||||
for (j = 0; j < n5; j++) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
s << v[k] << (k < n - 1 ? ", " : "");
|
||||
k++;
|
||||
}
|
||||
|
||||
s << "</" << XML_filter(name) << ">" << std::endl;
|
||||
if (j < n5-1) {
|
||||
s << std::endl;
|
||||
for (ni = 0; ni < _level; ni++) {
|
||||
s << _indent;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for (i = k; i < n; i++) {
|
||||
s << v[k] << (k < n - 1 ? ", " : "");
|
||||
k++;
|
||||
}
|
||||
|
||||
s << "</" << XML_filter(name) << ">" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
// We expect that there will be special casing based on the computer
|
||||
// We expect that there will be special casing based on the computer
|
||||
// system here
|
||||
|
||||
#ifdef SOLARIS
|
||||
@@ -33,116 +33,123 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace mdp {
|
||||
|
||||
// Utility routine to check to see that a number is finite.
|
||||
/*
|
||||
* @param tmp number to be checked
|
||||
*/
|
||||
namespace mdp
|
||||
{
|
||||
|
||||
// Utility routine to check to see that a number is finite.
|
||||
/*
|
||||
* @param tmp number to be checked
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
void checkFinite(const double tmp) {
|
||||
void checkFinite(const double tmp)
|
||||
{
|
||||
if (_finite(tmp)) {
|
||||
if(_isnan(tmp)) {
|
||||
printf("checkFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (_fpclass(tmp) == _FPCLASS_PINF) {
|
||||
printf("checkFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
const std::string s = "checkFinite()";
|
||||
throw std::range_error(s);
|
||||
if (_isnan(tmp)) {
|
||||
printf("checkFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (_fpclass(tmp) == _FPCLASS_PINF) {
|
||||
printf("checkFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
const std::string s = "checkFinite()";
|
||||
throw std::range_error(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void checkFinite(const double tmp) {
|
||||
void checkFinite(const double tmp)
|
||||
{
|
||||
if (! finite(tmp)) {
|
||||
if(isnan(tmp)) {
|
||||
printf("checkFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (isinf(tmp) == 1) {
|
||||
printf("checkFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
const std::string s = "checkFinite()";
|
||||
throw std::range_error(s);
|
||||
if (isnan(tmp)) {
|
||||
printf("checkFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (isinf(tmp) == 1) {
|
||||
printf("checkFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
const std::string s = "checkFinite()";
|
||||
throw std::range_error(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Utility routine to link checkFinte() to fortran program
|
||||
/*
|
||||
* This routine is accessible from fortran, usually
|
||||
*
|
||||
* @param tmp Pointer to the number to check
|
||||
*
|
||||
* @todo link it into the usual way Cantera handles Fortran calls
|
||||
*/
|
||||
extern "C" void checkfinite_(double * tmp) {
|
||||
|
||||
// Utility routine to link checkFinte() to fortran program
|
||||
/*
|
||||
* This routine is accessible from fortran, usually
|
||||
*
|
||||
* @param tmp Pointer to the number to check
|
||||
*
|
||||
* @todo link it into the usual way Cantera handles Fortran calls
|
||||
*/
|
||||
extern "C" void checkfinite_(double* tmp)
|
||||
{
|
||||
checkFinite(*tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Utility routine to check that a double stays bounded
|
||||
/*
|
||||
* This routine checks to see if a number stays bounded. The absolute
|
||||
* value of the number is required to stay below the trigger.
|
||||
*
|
||||
* @param tmp Number to be checked
|
||||
* @param trigger bounds on the number. Defaults to 1.0E20
|
||||
*/
|
||||
void checkMagnitude(const double tmp, const double trigger) {
|
||||
checkFinite(tmp);
|
||||
|
||||
// Utility routine to check that a double stays bounded
|
||||
/*
|
||||
* This routine checks to see if a number stays bounded. The absolute
|
||||
* value of the number is required to stay below the trigger.
|
||||
*
|
||||
* @param tmp Number to be checked
|
||||
* @param trigger bounds on the number. Defaults to 1.0E20
|
||||
*/
|
||||
void checkMagnitude(const double tmp, const double trigger)
|
||||
{
|
||||
checkFinite(tmp);
|
||||
if (fabs(tmp) >= trigger) {
|
||||
char sbuf[64];
|
||||
sprintf(sbuf, "checkMagnitude() ERROR: Trigger %g exceeded: %g\n", trigger,
|
||||
tmp);
|
||||
throw std::range_error(sbuf);
|
||||
char sbuf[64];
|
||||
sprintf(sbuf, "checkMagnitude() ERROR: Trigger %g exceeded: %g\n", trigger,
|
||||
tmp);
|
||||
throw std::range_error(sbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility routine to check to see that a number is neither zero
|
||||
// nor indefinite.
|
||||
/*
|
||||
* This check can be used before using the number in a denominator.
|
||||
*
|
||||
* @param tmp number to be checked
|
||||
*/
|
||||
// Utility routine to check to see that a number is neither zero
|
||||
// nor indefinite.
|
||||
/*
|
||||
* This check can be used before using the number in a denominator.
|
||||
*
|
||||
* @param tmp number to be checked
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
void checkZeroFinite(const double tmp) {
|
||||
void checkZeroFinite(const double tmp)
|
||||
{
|
||||
if ((tmp == 0.0) || (! _finite(tmp))) {
|
||||
if (tmp == 0.0) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a zero!\n");
|
||||
} else if(_isnan(tmp)) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (_fpclass(tmp) == _FPCLASS_PINF) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
char sbuf[64];
|
||||
sprintf(sbuf, "checkZeroFinite() ERROR: zero or indef exceeded: %g\n",
|
||||
tmp);
|
||||
throw std::range_error(sbuf);
|
||||
if (tmp == 0.0) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a zero!\n");
|
||||
} else if (_isnan(tmp)) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (_fpclass(tmp) == _FPCLASS_PINF) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
char sbuf[64];
|
||||
sprintf(sbuf, "checkZeroFinite() ERROR: zero or indef exceeded: %g\n",
|
||||
tmp);
|
||||
throw std::range_error(sbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void checkZeroFinite(const double tmp) {
|
||||
void checkZeroFinite(const double tmp)
|
||||
{
|
||||
if ((tmp == 0.0) || (! finite(tmp))) {
|
||||
if (tmp == 0.0) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a zero!\n");
|
||||
} else if(isnan(tmp)) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (isinf(tmp) == 1) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
char sbuf[64];
|
||||
sprintf(sbuf, "checkZeroFinite() ERROR: zero or indef exceeded: %g\n",
|
||||
tmp);
|
||||
throw std::range_error(sbuf);
|
||||
if (tmp == 0.0) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a zero!\n");
|
||||
} else if (isnan(tmp)) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a nan!\n");
|
||||
} else if (isinf(tmp) == 1) {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a pos inf!\n");
|
||||
} else {
|
||||
printf("checkZeroFinite() ERROR: we have encountered a neg inf!\n");
|
||||
}
|
||||
char sbuf[64];
|
||||
sprintf(sbuf, "checkZeroFinite() ERROR: zero or indef exceeded: %g\n",
|
||||
tmp);
|
||||
throw std::range_error(sbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -12,49 +12,54 @@
|
||||
|
||||
#include <time.h>
|
||||
#include "clockWC.h"
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
clockWC::clockWC() :
|
||||
|
||||
clockWC::clockWC() :
|
||||
last_num_ticks(clock()),
|
||||
clock_rollovers(0u),
|
||||
start_ticks(0),
|
||||
inv_clocks_per_sec(1./(double)CLOCKS_PER_SEC),
|
||||
clock_width((double)(1L<<((int)sizeof(clock_t)*8-2))*4./(double)CLOCKS_PER_SEC)
|
||||
{
|
||||
{
|
||||
start_ticks = last_num_ticks;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reinitialize the tick counters within the object
|
||||
*/
|
||||
double clockWC::start()
|
||||
{
|
||||
/*
|
||||
* Reinitialize the tick counters within the object
|
||||
*/
|
||||
double clockWC::start()
|
||||
{
|
||||
start_ticks = last_num_ticks = clock();
|
||||
clock_rollovers = 0u;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns system cpu and wall clock time in seconds. This
|
||||
* is a strictly Ansi C timer, since clock() is defined as an
|
||||
* Ansi C function. On some machines clock() returns type
|
||||
* unsigned long (HP) and on others (SUN) it returns type long.
|
||||
* An attempt to recover the actual time for clocks which have
|
||||
* rolled over is made also. However, it only works if this
|
||||
* function is called fairly regularily during
|
||||
* the solution procedure.
|
||||
*
|
||||
* clock() -> returns the time in microseconds. Division by
|
||||
* the macro CLOCKS_PER_SEC recovers the time in seconds.
|
||||
*/
|
||||
double clockWC::secondsWC()
|
||||
{
|
||||
/*
|
||||
* Returns system cpu and wall clock time in seconds. This
|
||||
* is a strictly Ansi C timer, since clock() is defined as an
|
||||
* Ansi C function. On some machines clock() returns type
|
||||
* unsigned long (HP) and on others (SUN) it returns type long.
|
||||
* An attempt to recover the actual time for clocks which have
|
||||
* rolled over is made also. However, it only works if this
|
||||
* function is called fairly regularily during
|
||||
* the solution procedure.
|
||||
*
|
||||
* clock() -> returns the time in microseconds. Division by
|
||||
* the macro CLOCKS_PER_SEC recovers the time in seconds.
|
||||
*/
|
||||
double clockWC::secondsWC()
|
||||
{
|
||||
clock_t num_ticks = clock();
|
||||
if (num_ticks < last_num_ticks) clock_rollovers++;
|
||||
if (num_ticks < last_num_ticks) {
|
||||
clock_rollovers++;
|
||||
}
|
||||
double value = (num_ticks - start_ticks) * inv_clocks_per_sec;
|
||||
if (clock_rollovers) value += clock_rollovers * clock_width;
|
||||
if (clock_rollovers) {
|
||||
value += clock_rollovers * clock_width;
|
||||
}
|
||||
last_num_ticks = num_ticks;
|
||||
return(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,47 +14,49 @@
|
||||
#define CT_CLOCKWC_H
|
||||
|
||||
#include <time.h>
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
//! The class provides the wall clock timer in seconds
|
||||
/*!
|
||||
* This routine relies on the ANSI C routine, clock(), for
|
||||
* its basic operation. Therefore, it should be fairly
|
||||
* portable.
|
||||
*
|
||||
* The clock will rollover if the calculation is long enough.
|
||||
* The wraparound time is roughly 72 minutes for a 32 bit system.
|
||||
* This object senses that by seeing if the raw tick counter is
|
||||
* has decreased from the last time. If it senses a wraparound has
|
||||
* occurred, it increments an internal counter to account for this.
|
||||
* Therefore, for long calculations, this object must be called
|
||||
* at regular intervals for the seconds timer to be accurate.
|
||||
*
|
||||
* An example of how to use the timer is given below. timeToDoCalcs
|
||||
* countains the wall clock time calculated for the operation.
|
||||
*
|
||||
*
|
||||
* @code
|
||||
* clockWC wc;
|
||||
* do_hefty_calculations_atLeastgreaterThanAMillisecond();
|
||||
* double timeToDoCalcs = wc.secondsWC();
|
||||
* @endcode
|
||||
*
|
||||
* In general, the process to be timed must take more than a millisecond
|
||||
* for this clock to enough of a significant resolution to be
|
||||
* accurate.
|
||||
*
|
||||
* @ingroup globalUtilFuncs
|
||||
*
|
||||
*/
|
||||
class clockWC {
|
||||
public:
|
||||
//! The class provides the wall clock timer in seconds
|
||||
/*!
|
||||
* This routine relies on the ANSI C routine, clock(), for
|
||||
* its basic operation. Therefore, it should be fairly
|
||||
* portable.
|
||||
*
|
||||
* The clock will rollover if the calculation is long enough.
|
||||
* The wraparound time is roughly 72 minutes for a 32 bit system.
|
||||
* This object senses that by seeing if the raw tick counter is
|
||||
* has decreased from the last time. If it senses a wraparound has
|
||||
* occurred, it increments an internal counter to account for this.
|
||||
* Therefore, for long calculations, this object must be called
|
||||
* at regular intervals for the seconds timer to be accurate.
|
||||
*
|
||||
* An example of how to use the timer is given below. timeToDoCalcs
|
||||
* countains the wall clock time calculated for the operation.
|
||||
*
|
||||
*
|
||||
* @code
|
||||
* clockWC wc;
|
||||
* do_hefty_calculations_atLeastgreaterThanAMillisecond();
|
||||
* double timeToDoCalcs = wc.secondsWC();
|
||||
* @endcode
|
||||
*
|
||||
* In general, the process to be timed must take more than a millisecond
|
||||
* for this clock to enough of a significant resolution to be
|
||||
* accurate.
|
||||
*
|
||||
* @ingroup globalUtilFuncs
|
||||
*
|
||||
*/
|
||||
class clockWC
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* This also serves to initialize the ticks within the object
|
||||
*/
|
||||
clockWC();
|
||||
|
||||
|
||||
//! Resets the internal counters and returns the wall clock time
|
||||
//! in seconds
|
||||
double start();
|
||||
@@ -62,7 +64,7 @@ namespace Cantera {
|
||||
//! Returns the wall clock time in seconds since the last reset.
|
||||
double secondsWC();
|
||||
|
||||
private:
|
||||
private:
|
||||
//! Counters the value of the number of ticks from the last call.
|
||||
clock_t last_num_ticks;
|
||||
|
||||
@@ -84,6 +86,6 @@ namespace Cantera {
|
||||
//! internal constant containing the total number of ticks
|
||||
//! per rollover.
|
||||
const double clock_width;
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,62 +27,65 @@
|
||||
using namespace Cantera;
|
||||
using namespace std;
|
||||
|
||||
namespace ctml {
|
||||
namespace ctml
|
||||
{
|
||||
|
||||
//! return the full path to the Python interpreter.
|
||||
/*!
|
||||
* Use the environment variable PYTHON_CMD if it is set. If not, return
|
||||
* the string 'python'.
|
||||
*
|
||||
* Note, there are hidden problems here that really direct us to use
|
||||
* a full pathname for the location of python. Basically the system
|
||||
* call will use the shell /bin/sh, in order to launch python.
|
||||
* This default shell may not be the shell that the user is employing.
|
||||
* Therefore, the default path to python may be different during
|
||||
* a system call than during the default user shell environment.
|
||||
* This is quite a headache. The answer is to always set the
|
||||
* PYTHON_CMD environmental variable in the user environment to
|
||||
* an absolute path to locate the python executable. Then this
|
||||
* issue goes away.
|
||||
*/
|
||||
static string pypath() {
|
||||
//! return the full path to the Python interpreter.
|
||||
/*!
|
||||
* Use the environment variable PYTHON_CMD if it is set. If not, return
|
||||
* the string 'python'.
|
||||
*
|
||||
* Note, there are hidden problems here that really direct us to use
|
||||
* a full pathname for the location of python. Basically the system
|
||||
* call will use the shell /bin/sh, in order to launch python.
|
||||
* This default shell may not be the shell that the user is employing.
|
||||
* Therefore, the default path to python may be different during
|
||||
* a system call than during the default user shell environment.
|
||||
* This is quite a headache. The answer is to always set the
|
||||
* PYTHON_CMD environmental variable in the user environment to
|
||||
* an absolute path to locate the python executable. Then this
|
||||
* issue goes away.
|
||||
*/
|
||||
static string pypath()
|
||||
{
|
||||
string s = "python";
|
||||
const char* py = getenv("PYTHON_CMD");
|
||||
|
||||
// Try to source the "setup_cantera" script from the user's home
|
||||
// directory in order to set PYTHON_CMD.
|
||||
if (!py) {
|
||||
const char* hm = getenv("HOME");
|
||||
if (hm) {
|
||||
string home = stripws(string(hm));
|
||||
string cmd = string(". ") + home
|
||||
+string("/setup_cantera &> /dev/null");
|
||||
system(cmd.c_str());
|
||||
}
|
||||
py = getenv("PYTHON_CMD");
|
||||
const char* hm = getenv("HOME");
|
||||
if (hm) {
|
||||
string home = stripws(string(hm));
|
||||
string cmd = string(". ") + home
|
||||
+string("/setup_cantera &> /dev/null");
|
||||
system(cmd.c_str());
|
||||
}
|
||||
py = getenv("PYTHON_CMD");
|
||||
}
|
||||
if (py) {
|
||||
string sp = stripws(string(py));
|
||||
if (sp.size() > 0) {
|
||||
s = sp;
|
||||
}
|
||||
string sp = stripws(string(py));
|
||||
if (sp.size() > 0) {
|
||||
s = sp;
|
||||
}
|
||||
}
|
||||
//else {
|
||||
// throw CanteraError("ct2ctml",
|
||||
// throw CanteraError("ct2ctml",
|
||||
// "set environment variable PYTHON_CMD");
|
||||
//}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert a cti file into a ctml file
|
||||
/*
|
||||
*
|
||||
* @param file Pointer to the file
|
||||
* @param debug Turn on debug printing
|
||||
*
|
||||
* @ingroup inputfiles
|
||||
*/
|
||||
void ct2ctml(const char* file, const int debug) {
|
||||
// Convert a cti file into a ctml file
|
||||
/*
|
||||
*
|
||||
* @param file Pointer to the file
|
||||
* @param debug Turn on debug printing
|
||||
*
|
||||
* @ingroup inputfiles
|
||||
*/
|
||||
void ct2ctml(const char* file, const int debug)
|
||||
{
|
||||
|
||||
#ifdef HAS_NO_PYTHON
|
||||
/*
|
||||
@@ -90,18 +93,18 @@ namespace ctml {
|
||||
* present in the computation environment.
|
||||
*/
|
||||
string ppath = file;
|
||||
throw CanteraError("ct2ctml",
|
||||
"python cti to ctml conversion requested for file, " + ppath +
|
||||
", but not available in this computational environment");
|
||||
throw CanteraError("ct2ctml",
|
||||
"python cti to ctml conversion requested for file, " + ppath +
|
||||
", but not available in this computational environment");
|
||||
#endif
|
||||
|
||||
time_t aclock;
|
||||
time( &aclock );
|
||||
time(&aclock);
|
||||
int ia = static_cast<int>(aclock);
|
||||
string path = tmpDir()+"/.cttmp"+int2str(ia)+".pyw";
|
||||
ofstream f(path.c_str());
|
||||
if (!f) {
|
||||
throw CanteraError("ct2ctml","cannot open "+path+" for writing.");
|
||||
throw CanteraError("ct2ctml","cannot open "+path+" for writing.");
|
||||
}
|
||||
|
||||
f << "from ctml_writer import *\n"
|
||||
@@ -117,26 +120,25 @@ namespace ctml {
|
||||
#ifdef _WIN32
|
||||
string cmd = pypath() + " " + "\"" + path + "\"" + "> " + logfile + " 2>&1";
|
||||
#else
|
||||
string cmd = "sleep " + sleep() + "; " + "\"" + pypath() + "\"" +
|
||||
" " + "\"" + path + "\"" + " &> " + logfile;
|
||||
string cmd = "sleep " + sleep() + "; " + "\"" + pypath() + "\"" +
|
||||
" " + "\"" + path + "\"" + " &> " + logfile;
|
||||
#endif
|
||||
#ifdef DEBUG_PATHS
|
||||
writelog("ct2ctml: executing the command " + cmd + "\n");
|
||||
#endif
|
||||
if (debug > 0) {
|
||||
writelog("ct2ctml: executing the command " + cmd + "\n");
|
||||
writelog("ct2ctml: the Python command is: " + pypath() + "\n");
|
||||
writelog("ct2ctml: executing the command " + cmd + "\n");
|
||||
writelog("ct2ctml: the Python command is: " + pypath() + "\n");
|
||||
}
|
||||
|
||||
int ierr = 0;
|
||||
try {
|
||||
ierr = system(cmd.c_str());
|
||||
}
|
||||
catch (...) {
|
||||
ierr = -10;
|
||||
if (debug > 0) {
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
}
|
||||
ierr = system(cmd.c_str());
|
||||
} catch (...) {
|
||||
ierr = -10;
|
||||
if (debug > 0) {
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -159,15 +161,14 @@ namespace ctml {
|
||||
#ifndef _WIN32
|
||||
string sss = sleep();
|
||||
if (debug > 0) {
|
||||
writelog("sleeping for " + sss + " secs+\n");
|
||||
writelog("sleeping for " + sss + " secs+\n");
|
||||
}
|
||||
cmd = "sleep " + sss;
|
||||
try {
|
||||
ierr = system(cmd.c_str());
|
||||
}
|
||||
catch (...) {
|
||||
ierr = -10;
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
ierr = system(cmd.c_str());
|
||||
} catch (...) {
|
||||
ierr = -10;
|
||||
writelog("ct2ctml: command execution failed.\n");
|
||||
}
|
||||
#else
|
||||
// This command works on windows machines if Windows.h and Winbase.h are included
|
||||
@@ -175,35 +176,33 @@ namespace ctml {
|
||||
#endif
|
||||
// show the contents of the log file on the screen
|
||||
try {
|
||||
char ch=0;
|
||||
string s = "";
|
||||
ifstream ferr("ct2ctml.log");
|
||||
if (ferr) {
|
||||
while (!ferr.eof()) {
|
||||
ferr.get(ch);
|
||||
s += ch;
|
||||
if (ch == '\n') {
|
||||
writelog(s);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
ferr.close();
|
||||
}
|
||||
else {
|
||||
char ch=0;
|
||||
string s = "";
|
||||
ifstream ferr("ct2ctml.log");
|
||||
if (ferr) {
|
||||
while (!ferr.eof()) {
|
||||
ferr.get(ch);
|
||||
s += ch;
|
||||
if (ch == '\n') {
|
||||
writelog(s);
|
||||
s = "";
|
||||
}
|
||||
}
|
||||
ferr.close();
|
||||
} else {
|
||||
if (debug > 0) {
|
||||
writelog("cannot open ct2ctml.log for reading.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
writelog("ct2ctml: caught something \n");;
|
||||
writelog("cannot open ct2ctml.log for reading.\n");
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
writelog("ct2ctml: caught something \n");;
|
||||
}
|
||||
if (ierr != 0) {
|
||||
string msg = cmd;
|
||||
writelog("ct2ctml: throw cantera error \n");;
|
||||
throw CanteraError("ct2ctml",
|
||||
"could not convert input file to CTML.\n "
|
||||
"Command line was: \n" + msg);
|
||||
string msg = cmd;
|
||||
writelog("ct2ctml: throw cantera error \n");;
|
||||
throw CanteraError("ct2ctml",
|
||||
"could not convert input file to CTML.\n "
|
||||
"Command line was: \n" + msg);
|
||||
}
|
||||
|
||||
// if the conversion succeeded and DEBUG_PATHS is not defined,
|
||||
@@ -211,29 +210,30 @@ namespace ctml {
|
||||
#ifndef DEBUG_PATHS
|
||||
//#ifdef _WIN32
|
||||
//cmd = "cmd /C rm " + path;
|
||||
if (debug == 0)
|
||||
remove(path.c_str());
|
||||
else {
|
||||
writelog("ct2ctml: retaining temporary file "+path+"\n");
|
||||
if (debug == 0) {
|
||||
remove(path.c_str());
|
||||
} else {
|
||||
writelog("ct2ctml: retaining temporary file "+path+"\n");
|
||||
}
|
||||
#else
|
||||
if (debug > 0) {
|
||||
writelog("ct2ctml: retaining temporary file "+path+"\n");
|
||||
writelog("ct2ctml: retaining temporary file "+path+"\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read an ctml file from a file and fill up an XML tree
|
||||
/*
|
||||
* This is the main routine that reads a ctml file and puts it into
|
||||
* an XML_Node tree
|
||||
*
|
||||
* @param node Root of the tree
|
||||
* @param file Name of the file
|
||||
* @param debug Turn on debugging printing
|
||||
*/
|
||||
void get_CTML_Tree(Cantera::XML_Node* rootPtr, const std::string file, const int debug) {
|
||||
// Read an ctml file from a file and fill up an XML tree
|
||||
/*
|
||||
* This is the main routine that reads a ctml file and puts it into
|
||||
* an XML_Node tree
|
||||
*
|
||||
* @param node Root of the tree
|
||||
* @param file Name of the file
|
||||
* @param debug Turn on debugging printing
|
||||
*/
|
||||
void get_CTML_Tree(Cantera::XML_Node* rootPtr, const std::string file, const int debug)
|
||||
{
|
||||
|
||||
std::string ff, ext = "";
|
||||
|
||||
@@ -242,51 +242,51 @@ namespace ctml {
|
||||
#ifdef DEBUG_PATHS
|
||||
writelog("Found file: "+inname+"\n");
|
||||
#endif
|
||||
if (debug > 0)
|
||||
writelog("Found file: "+inname+"\n");
|
||||
|
||||
if (inname == "") {
|
||||
throw CanteraError("get_CTML_Tree", "file "+file+" not found");
|
||||
if (debug > 0) {
|
||||
writelog("Found file: "+inname+"\n");
|
||||
}
|
||||
|
||||
/*
|
||||
if (inname == "") {
|
||||
throw CanteraError("get_CTML_Tree", "file "+file+" not found");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether or not the file is XML. If not, it will be first
|
||||
* processed with the preprocessor.
|
||||
*/
|
||||
std::string::size_type idot = inname.rfind('.');
|
||||
std::string::size_type idot = inname.rfind('.');
|
||||
if (idot != string::npos) {
|
||||
ext = inname.substr(idot, inname.size());
|
||||
ext = inname.substr(idot, inname.size());
|
||||
}
|
||||
if (ext != ".xml" && ext != ".ctml") {
|
||||
try {
|
||||
ctml::ct2ctml(inname.c_str(), debug);
|
||||
try {
|
||||
ctml::ct2ctml(inname.c_str(), debug);
|
||||
} catch (...) {
|
||||
writelog("get_CTML_Tree: caught something \n");;
|
||||
}
|
||||
catch (...) {
|
||||
writelog("get_CTML_Tree: caught something \n");;
|
||||
}
|
||||
string ffull = inname.substr(0,idot) + ".xml";
|
||||
ff = "./" + getBaseName(ffull) + ".xml";
|
||||
string ffull = inname.substr(0,idot) + ".xml";
|
||||
ff = "./" + getBaseName(ffull) + ".xml";
|
||||
#ifdef DEBUG_PATHS
|
||||
writelogf("ffull name = %s\n", ffull.c_str());
|
||||
writelogf("ff name = %s\n", ff.c_str());
|
||||
writelogf("ffull name = %s\n", ffull.c_str());
|
||||
writelogf("ff name = %s\n", ff.c_str());
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
ff = inname;
|
||||
} else {
|
||||
ff = inname;
|
||||
}
|
||||
#ifdef DEBUG_PATHS
|
||||
writelog("Attempting to parse xml file " + ff + "\n");
|
||||
#else
|
||||
if (debug > 0)
|
||||
writelog("Attempting to parse xml file " + ff + "\n");
|
||||
if (debug > 0) {
|
||||
writelog("Attempting to parse xml file " + ff + "\n");
|
||||
}
|
||||
#endif
|
||||
ifstream fin(ff.c_str());
|
||||
if (!fin) {
|
||||
throw
|
||||
CanteraError("get_CTML_Tree",
|
||||
"XML file " + ff + " not found");
|
||||
throw
|
||||
CanteraError("get_CTML_Tree",
|
||||
"XML file " + ff + " not found");
|
||||
}
|
||||
rootPtr->build(fin);
|
||||
fin.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ct_defs.h
|
||||
* This file contains definitions of terms that are used in internal
|
||||
* routines and are unlikely to need modifying (text for module physConstants (see \ref physConstants) is found here).
|
||||
* This file contains definitions of terms that are used in internal
|
||||
* routines and are unlikely to need modifying (text for module physConstants (see \ref physConstants) is found here).
|
||||
* This file is included
|
||||
* in every file that is in the Cantera Namespace.
|
||||
*
|
||||
@@ -29,7 +29,8 @@
|
||||
/**
|
||||
* Namespace for the Cantera kernel.
|
||||
*/
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
#undef CHEMKIN_COMPATIBILITY_MODE
|
||||
|
||||
@@ -38,187 +39,191 @@ namespace Cantera {
|
||||
#define DATA_PTR(vec) &vec[0]
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* All physical constants are stored here.
|
||||
*
|
||||
* @defgroup physConstants Physical Constants
|
||||
* %Cantera uses the MKS system of units. The unit for moles
|
||||
* is defined to be the kmol. All values of physical constants
|
||||
* are consistent with the 2006 CODATA recommendations.
|
||||
* @ingroup globalData
|
||||
* @{
|
||||
*/
|
||||
//! Pi
|
||||
const doublereal Pi = 3.1415926;
|
||||
//! sqrt(Pi)
|
||||
const doublereal SqrtPi = std::sqrt(Pi);
|
||||
/*!
|
||||
* All physical constants are stored here.
|
||||
*
|
||||
* @defgroup physConstants Physical Constants
|
||||
* %Cantera uses the MKS system of units. The unit for moles
|
||||
* is defined to be the kmol. All values of physical constants
|
||||
* are consistent with the 2006 CODATA recommendations.
|
||||
* @ingroup globalData
|
||||
* @{
|
||||
*/
|
||||
//! Pi
|
||||
const doublereal Pi = 3.1415926;
|
||||
//! sqrt(Pi)
|
||||
const doublereal SqrtPi = std::sqrt(Pi);
|
||||
|
||||
|
||||
/*!
|
||||
* @name Variations of the Gas Constant
|
||||
* %Cantera uses the MKS system of units. The unit for moles
|
||||
* is defined to be the kmol.
|
||||
*/
|
||||
//@{
|
||||
|
||||
//! Avogadro's Number
|
||||
/*!
|
||||
* Units are number/kmol
|
||||
*/
|
||||
const doublereal Avogadro = 6.02214179e26;
|
||||
/*!
|
||||
* @name Variations of the Gas Constant
|
||||
* %Cantera uses the MKS system of units. The unit for moles
|
||||
* is defined to be the kmol.
|
||||
*/
|
||||
//@{
|
||||
|
||||
/// Universal Gas Constant. 2006 CODATA value.
|
||||
const doublereal GasConstant = 8314.47215; // J/kmol/K
|
||||
//! Avogadro's Number
|
||||
/*!
|
||||
* Units are number/kmol
|
||||
*/
|
||||
const doublereal Avogadro = 6.02214179e26;
|
||||
|
||||
const doublereal logGasConstant = 9.025752908;
|
||||
/// Universal Gas Constant. 2006 CODATA value.
|
||||
const doublereal GasConstant = 8314.47215; // J/kmol/K
|
||||
|
||||
//! One atmosphere
|
||||
/*!
|
||||
* Units are Pa
|
||||
*/
|
||||
const doublereal OneAtm = 1.01325e5;
|
||||
const doublereal logGasConstant = 9.025752908;
|
||||
|
||||
//! Universal gas constant in cal/mol/K
|
||||
const doublereal GasConst_cal_mol_K = 1.987;
|
||||
//! One atmosphere
|
||||
/*!
|
||||
* Units are Pa
|
||||
*/
|
||||
const doublereal OneAtm = 1.01325e5;
|
||||
|
||||
//! Boltzmann's constant
|
||||
/*!
|
||||
* Units are J/K
|
||||
*/
|
||||
const doublereal Boltzmann = GasConstant / Avogadro;
|
||||
//! Universal gas constant in cal/mol/K
|
||||
const doublereal GasConst_cal_mol_K = 1.987;
|
||||
|
||||
/// Planck's constant. Units of J-s
|
||||
const doublereal Planck = 6.62606896e-34; // J-s
|
||||
const doublereal Planck_bar = 1.05457162853e-34; // m2-kg/s
|
||||
//! Boltzmann's constant
|
||||
/*!
|
||||
* Units are J/K
|
||||
*/
|
||||
const doublereal Boltzmann = GasConstant / Avogadro;
|
||||
|
||||
/// log(k/h)
|
||||
const doublereal logBoltz_Planck = 23.7599032; // ln(k_B/h)
|
||||
/// Stefan-Boltzmann constant
|
||||
const doublereal StefanBoltz = 5.6704004e-8;
|
||||
/// Planck's constant. Units of J-s
|
||||
const doublereal Planck = 6.62606896e-34; // J-s
|
||||
const doublereal Planck_bar = 1.05457162853e-34; // m2-kg/s
|
||||
|
||||
//@}
|
||||
/// @name Electron Properties
|
||||
//@{
|
||||
const doublereal ElectronCharge = 1.60217648740e-19; // C
|
||||
const doublereal ElectronMass = 9.1093821545e-31; // kg
|
||||
const doublereal Faraday = ElectronCharge * Avogadro;
|
||||
//@}
|
||||
/// log(k/h)
|
||||
const doublereal logBoltz_Planck = 23.7599032; // ln(k_B/h)
|
||||
/// Stefan-Boltzmann constant
|
||||
const doublereal StefanBoltz = 5.6704004e-8;
|
||||
|
||||
/// @name Electromagnetism
|
||||
/// %Cantera uses the MKS unit system.
|
||||
//@{
|
||||
//@}
|
||||
/// @name Electron Properties
|
||||
//@{
|
||||
const doublereal ElectronCharge = 1.60217648740e-19; // C
|
||||
const doublereal ElectronMass = 9.1093821545e-31; // kg
|
||||
const doublereal Faraday = ElectronCharge* Avogadro;
|
||||
//@}
|
||||
|
||||
/// Permittivity of free space \f$ \epsilon_0 \f$ in F/m.
|
||||
const doublereal epsilon_0 = 8.85417817e-12; // Farads/m = C^2/N/m^2
|
||||
/// @name Electromagnetism
|
||||
/// %Cantera uses the MKS unit system.
|
||||
//@{
|
||||
|
||||
/// Permeability of free space \f$ \mu_0 \f$ in N/A^2.
|
||||
const doublereal permeability_0 = 4.0e-7*Pi; // N/A^2
|
||||
/// Permittivity of free space \f$ \epsilon_0 \f$ in F/m.
|
||||
const doublereal epsilon_0 = 8.85417817e-12; // Farads/m = C^2/N/m^2
|
||||
|
||||
/// Speed of Light (m/s).
|
||||
const doublereal lightSpeed = 1.0/std::sqrt(epsilon_0 * permeability_0);
|
||||
/// Permeability of free space \f$ \mu_0 \f$ in N/A^2.
|
||||
const doublereal permeability_0 = 4.0e-7*Pi; // N/A^2
|
||||
|
||||
//@}
|
||||
//@}
|
||||
|
||||
/*!
|
||||
* @name Thermodynamic Equilibrium Constraints
|
||||
* Integer numbers representing pairs of thermodynamic variables
|
||||
* which are held constant during equilibration.
|
||||
*/
|
||||
//@{
|
||||
const int TV = 100, HP = 101, SP = 102, PV = 103, TP = 104, UV = 105,
|
||||
ST = 106, SV = 107, UP = 108, VH = 109, TH = 110, SH = 111,
|
||||
PX = 112, TX = 113;
|
||||
const int VT = -100, PH = -101, PS = -102, VP = -103, PT = -104,
|
||||
VU = -105, TS = -106, VS = -107, PU = -108, HV = -109,
|
||||
HT = -110, HS = -111, XP = -112, XT = -113;
|
||||
//@}
|
||||
/// Speed of Light (m/s).
|
||||
const doublereal lightSpeed = 1.0/std::sqrt(epsilon_0* permeability_0);
|
||||
|
||||
//! 1/3
|
||||
const doublereal OneThird = 1.0/3.0;
|
||||
//! 5/16
|
||||
const doublereal FiveSixteenths = 5.0/16.0;
|
||||
//! sqrt(10)
|
||||
const doublereal SqrtTen = std::sqrt(10.0);
|
||||
//! sqrt(8)
|
||||
const doublereal SqrtEight = std::sqrt(8.0);
|
||||
//! sqrt(2)
|
||||
const doublereal SqrtTwo = std::sqrt(2.0);
|
||||
//@}
|
||||
//@}
|
||||
|
||||
//! smallest number to compare to zero.
|
||||
const doublereal SmallNumber = 1.e-300;
|
||||
//! largest number to compare to inf.
|
||||
const doublereal BigNumber = 1.e300;
|
||||
//! largest x such that exp(x) is valid
|
||||
const doublereal MaxExp = 690.775527898;
|
||||
/*!
|
||||
* @name Thermodynamic Equilibrium Constraints
|
||||
* Integer numbers representing pairs of thermodynamic variables
|
||||
* which are held constant during equilibration.
|
||||
*/
|
||||
//@{
|
||||
const int TV = 100, HP = 101, SP = 102, PV = 103, TP = 104, UV = 105,
|
||||
ST = 106, SV = 107, UP = 108, VH = 109, TH = 110, SH = 111,
|
||||
PX = 112, TX = 113;
|
||||
const int VT = -100, PH = -101, PS = -102, VP = -103, PT = -104,
|
||||
VU = -105, TS = -106, VS = -107, PU = -108, HV = -109,
|
||||
HT = -110, HS = -111, XP = -112, XT = -113;
|
||||
//@}
|
||||
|
||||
//! Fairly random number to be used to initialize variables against
|
||||
//! to see if they are subsequently defined.
|
||||
const doublereal Undef = -999.1234;
|
||||
//! Small number to compare differences of mole fractions against.
|
||||
const doublereal Tiny = 1.e-20;
|
||||
//! 1/3
|
||||
const doublereal OneThird = 1.0/3.0;
|
||||
//! 5/16
|
||||
const doublereal FiveSixteenths = 5.0/16.0;
|
||||
//! sqrt(10)
|
||||
const doublereal SqrtTen = std::sqrt(10.0);
|
||||
//! sqrt(8)
|
||||
const doublereal SqrtEight = std::sqrt(8.0);
|
||||
//! sqrt(2)
|
||||
const doublereal SqrtTwo = std::sqrt(2.0);
|
||||
|
||||
//! inline function to return the max value of two doubles.
|
||||
/*!
|
||||
* @param x double value
|
||||
* @param y second double value
|
||||
*/
|
||||
inline doublereal fmaxx(doublereal x, doublereal y)
|
||||
{ return (x > y) ? x : y; }
|
||||
//! smallest number to compare to zero.
|
||||
const doublereal SmallNumber = 1.e-300;
|
||||
//! largest number to compare to inf.
|
||||
const doublereal BigNumber = 1.e300;
|
||||
//! largest x such that exp(x) is valid
|
||||
const doublereal MaxExp = 690.775527898;
|
||||
|
||||
//! inline function to return the min value of two doubles.
|
||||
/*!
|
||||
* @param x double value
|
||||
* @param y second double value
|
||||
*/
|
||||
inline doublereal fminn(doublereal x, doublereal y)
|
||||
{ return (x < y) ? x : y; }
|
||||
|
||||
//! Fairly random number to be used to initialize variables against
|
||||
//! to see if they are subsequently defined.
|
||||
const doublereal Undef = -999.1234;
|
||||
//! Small number to compare differences of mole fractions against.
|
||||
const doublereal Tiny = 1.e-20;
|
||||
|
||||
//! Map connecting a string name with a double.
|
||||
/*!
|
||||
* This is used mostly to assign concentrations and mole fractions
|
||||
* to species.
|
||||
*/
|
||||
typedef std::map<std::string, doublereal> compositionMap;
|
||||
//! inline function to return the max value of two doubles.
|
||||
/*!
|
||||
* @param x double value
|
||||
* @param y second double value
|
||||
*/
|
||||
inline doublereal fmaxx(doublereal x, doublereal y)
|
||||
{
|
||||
return (x > y) ? x : y;
|
||||
}
|
||||
|
||||
//! inline function to return the min value of two doubles.
|
||||
/*!
|
||||
* @param x double value
|
||||
* @param y second double value
|
||||
*/
|
||||
inline doublereal fminn(doublereal x, doublereal y)
|
||||
{
|
||||
return (x < y) ? x : y;
|
||||
}
|
||||
|
||||
|
||||
//! Map connecting a string name with a double.
|
||||
/*!
|
||||
* This is used mostly to assign concentrations and mole fractions
|
||||
* to species.
|
||||
*/
|
||||
typedef std::map<std::string, doublereal> compositionMap;
|
||||
//! Turn on the use of stl vectors for the basic array type within cantera
|
||||
#define USE_STL_VECTOR
|
||||
#ifdef USE_STL_VECTOR
|
||||
//! Vector of doubles.
|
||||
/*!
|
||||
* @deprecated array_fp is going away, because vector_fp means the same thing
|
||||
*/
|
||||
typedef std::vector<double> array_fp;
|
||||
//! Vector of doubles.
|
||||
typedef std::vector<double> vector_fp;
|
||||
//! Vector of ints
|
||||
typedef std::vector<int> array_int;
|
||||
//! Vector of ints
|
||||
typedef std::vector<int> vector_int;
|
||||
//! Vector of doubles.
|
||||
/*!
|
||||
* @deprecated array_fp is going away, because vector_fp means the same thing
|
||||
*/
|
||||
typedef std::vector<double> array_fp;
|
||||
//! Vector of doubles.
|
||||
typedef std::vector<double> vector_fp;
|
||||
//! Vector of ints
|
||||
typedef std::vector<int> array_int;
|
||||
//! Vector of ints
|
||||
typedef std::vector<int> vector_int;
|
||||
#else
|
||||
typedef ct::ctvector_fp array_fp;
|
||||
typedef ct::ctvector_fp vector_fp;
|
||||
typedef ct::ctvector_int array_int;
|
||||
typedef ct::ctvector_int vector_int;
|
||||
typedef ct::ctvector_fp array_fp;
|
||||
typedef ct::ctvector_fp vector_fp;
|
||||
typedef ct::ctvector_int array_int;
|
||||
typedef ct::ctvector_int vector_int;
|
||||
#endif
|
||||
//! typedef for a group of species.
|
||||
/*!
|
||||
* A group of species is a subset of the species in a phase.
|
||||
*/
|
||||
typedef std::vector<size_t> group_t;
|
||||
//! typedef for a vector of groups of species.
|
||||
/*!
|
||||
* A grouplist of species is a vector of groups.
|
||||
*/
|
||||
typedef std::vector<group_t> grouplist_t;
|
||||
|
||||
//! Typedef for a pointer to temporary work storage
|
||||
typedef doublereal* workPtr;
|
||||
//! typedef for a pointer to temporary work storage which is treated as constant
|
||||
typedef const doublereal* const_workPtr;
|
||||
//! typedef for a group of species.
|
||||
/*!
|
||||
* A group of species is a subset of the species in a phase.
|
||||
*/
|
||||
typedef std::vector<size_t> group_t;
|
||||
//! typedef for a vector of groups of species.
|
||||
/*!
|
||||
* A grouplist of species is a vector of groups.
|
||||
*/
|
||||
typedef std::vector<group_t> grouplist_t;
|
||||
|
||||
//! index returned by functions to indicate "no position"
|
||||
const size_t npos = -1;
|
||||
//! Typedef for a pointer to temporary work storage
|
||||
typedef doublereal* workPtr;
|
||||
//! typedef for a pointer to temporary work storage which is treated as constant
|
||||
typedef const doublereal* const_workPtr;
|
||||
|
||||
//! index returned by functions to indicate "no position"
|
||||
const size_t npos = -1;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file ctexceptions.h
|
||||
* Definitions for the classes that are
|
||||
* thrown when %Cantera experiences an error condition
|
||||
* thrown when %Cantera experiences an error condition
|
||||
* (also contains errorhandling module text - see \ref errorhandling).
|
||||
*/
|
||||
// Copyright 2001 California Institute of Technology
|
||||
@@ -15,162 +15,166 @@
|
||||
// See file misc.cpp for implementations of methods/functions declared
|
||||
// here.
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
/*!
|
||||
* @defgroup errorhandling Error Handling
|
||||
*
|
||||
* \brief These classes and related functions are used to handle errors and
|
||||
* unknown events within Cantera.
|
||||
*
|
||||
* The general idea is that exceptions are thrown using the common
|
||||
* base class called CanteraError. Derived types of CanteraError
|
||||
* characterize what type of error is thrown. A list of all
|
||||
* of the thrown errors is kept in the Application class.
|
||||
*
|
||||
* Any exceptions which are not caught cause a fatal error exit
|
||||
* from the program.
|
||||
*
|
||||
* Below is an example of how to catch errors that throw the CanteraError class.
|
||||
* In general, all Cantera C++ programs will have this basic structure.
|
||||
*
|
||||
* \include edemo.cpp
|
||||
*
|
||||
* The function showErrors() will print out the fatal error
|
||||
* condition to standard output.
|
||||
*
|
||||
* A group of defines may be used during debugging to assert
|
||||
* conditions which should be true. These are named AssertTrace(),
|
||||
* AssertThrow(), and AssertThrowMsg(). Examples of their usage is
|
||||
* given below.
|
||||
*
|
||||
* @code
|
||||
* AssertTrace(p == OneAtm);
|
||||
* AssertThrow(p == OneAtm, "Kinetics::update");
|
||||
* AssertThrowMsg(p == OneAtm, "Kinetics::update",
|
||||
* "Algorithm limited to atmospheric pressure");
|
||||
* @endcode
|
||||
*
|
||||
* Their first argument is a boolean. If the boolean is not true, a
|
||||
* CanteraError is thrown, with descriptive information indicating
|
||||
* where the error occured. These functions may be eliminated from
|
||||
* the source code, if the -DNDEBUG option is specified to the
|
||||
* compiler.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//! Base class for exceptions thrown by Cantera classes.
|
||||
/*!
|
||||
* This class is the base class for exceptions thrown by Cantera.
|
||||
* It inherits from std::exception so that normal error handling
|
||||
* operations from applications may automatically handle the
|
||||
* errors in their own way.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class CanteraError : public std::exception
|
||||
{
|
||||
public:
|
||||
//! Normal Constructor for the CanteraError base class
|
||||
/*!
|
||||
* @defgroup errorhandling Error Handling
|
||||
*
|
||||
* \brief These classes and related functions are used to handle errors and
|
||||
* unknown events within Cantera.
|
||||
*
|
||||
* The general idea is that exceptions are thrown using the common
|
||||
* base class called CanteraError. Derived types of CanteraError
|
||||
* characterize what type of error is thrown. A list of all
|
||||
* of the thrown errors is kept in the Application class.
|
||||
*
|
||||
* Any exceptions which are not caught cause a fatal error exit
|
||||
* from the program.
|
||||
*
|
||||
* Below is an example of how to catch errors that throw the CanteraError class.
|
||||
* In general, all Cantera C++ programs will have this basic structure.
|
||||
*
|
||||
* \include edemo.cpp
|
||||
*
|
||||
* The function showErrors() will print out the fatal error
|
||||
* condition to standard output.
|
||||
*
|
||||
* A group of defines may be used during debugging to assert
|
||||
* conditions which should be true. These are named AssertTrace(),
|
||||
* AssertThrow(), and AssertThrowMsg(). Examples of their usage is
|
||||
* given below.
|
||||
*
|
||||
* @code
|
||||
* AssertTrace(p == OneAtm);
|
||||
* AssertThrow(p == OneAtm, "Kinetics::update");
|
||||
* AssertThrowMsg(p == OneAtm, "Kinetics::update",
|
||||
* "Algorithm limited to atmospheric pressure");
|
||||
* @endcode
|
||||
*
|
||||
* Their first argument is a boolean. If the boolean is not true, a
|
||||
* CanteraError is thrown, with descriptive information indicating
|
||||
* where the error occured. These functions may be eliminated from
|
||||
* the source code, if the -DNDEBUG option is specified to the
|
||||
* compiler.
|
||||
* This class doesn't have any storage associated with it. In its
|
||||
* constructor, a call to the Application class is made to store
|
||||
* the strings associated with the generated error condition.
|
||||
*
|
||||
* @param procedure String name for the function within which the error was
|
||||
* generated.
|
||||
* @param msg Descriptive string describing the type of error message.
|
||||
*/
|
||||
|
||||
|
||||
//! Base class for exceptions thrown by Cantera classes.
|
||||
CanteraError(std::string procedure, std::string msg);
|
||||
|
||||
//! Destructor for base class does nothing
|
||||
virtual ~CanteraError() throw();
|
||||
protected:
|
||||
//! Empty base constructor is made protected so that it may be used only by
|
||||
//! inherited classes.
|
||||
/*!
|
||||
* This class is the base class for exceptions thrown by Cantera.
|
||||
* It inherits from std::exception so that normal error handling
|
||||
* operations from applications may automatically handle the
|
||||
* errors in their own way.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
* We want to discourage throwing an error containing no information.
|
||||
*/
|
||||
class CanteraError : public std::exception {
|
||||
public:
|
||||
//! Normal Constructor for the CanteraError base class
|
||||
/*!
|
||||
* This class doesn't have any storage associated with it. In its
|
||||
* constructor, a call to the Application class is made to store
|
||||
* the strings associated with the generated error condition.
|
||||
*
|
||||
* @param procedure String name for the function within which the error was
|
||||
* generated.
|
||||
* @param msg Descriptive string describing the type of error message.
|
||||
*/
|
||||
CanteraError(std::string procedure, std::string msg);
|
||||
CanteraError();
|
||||
};
|
||||
|
||||
//! Destructor for base class does nothing
|
||||
virtual ~CanteraError() throw();
|
||||
protected:
|
||||
//! Empty base constructor is made protected so that it may be used only by
|
||||
//! inherited classes.
|
||||
/*!
|
||||
* We want to discourage throwing an error containing no information.
|
||||
*/
|
||||
CanteraError();
|
||||
};
|
||||
|
||||
//! Array size error.
|
||||
//! Array size error.
|
||||
/*!
|
||||
* This error is thrown if a supplied length to a vector supplied
|
||||
* to Cantera is too small.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class ArraySizeError : public CanteraError
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* This error is thrown if a supplied length to a vector supplied
|
||||
* to Cantera is too small.
|
||||
* The length needed is supplied by the argument, reqd, and the
|
||||
* length supplied is given by the argument sz.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
* @param procedure String name for the function within which the error was
|
||||
* generated.
|
||||
* @param sz This is the length supplied to Cantera.
|
||||
* @param reqd This is the required length needed by Cantera
|
||||
*/
|
||||
class ArraySizeError : public CanteraError {
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* The length needed is supplied by the argument, reqd, and the
|
||||
* length supplied is given by the argument sz.
|
||||
*
|
||||
* @param procedure String name for the function within which the error was
|
||||
* generated.
|
||||
* @param sz This is the length supplied to Cantera.
|
||||
* @param reqd This is the required length needed by Cantera
|
||||
*/
|
||||
ArraySizeError(std::string procedure, size_t sz, size_t reqd);
|
||||
};
|
||||
ArraySizeError(std::string procedure, size_t sz, size_t reqd);
|
||||
};
|
||||
|
||||
//! An element index is out of range.
|
||||
//! An element index is out of range.
|
||||
/*!
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class ElementRangeError : public CanteraError
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* This class indicates an out-of-bounds index.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
class ElementRangeError : public CanteraError {
|
||||
public:
|
||||
//! Constructor
|
||||
/*!
|
||||
* This class indicates an out-of-bounds index.
|
||||
*
|
||||
* @param func String name for the function within which the error was
|
||||
* generated.
|
||||
* @param m This is the value of the out-of-bounds index.
|
||||
* @param mmax This is the maximum allowed value of the index. The
|
||||
* minimum allowed value is assumed to be 0.
|
||||
*/
|
||||
ElementRangeError(std::string func, size_t m, size_t mmax);
|
||||
};
|
||||
|
||||
//! Print a warning when a deprecated method is called.
|
||||
/*!
|
||||
* These methods are slated to go away in future releases of Cantera.
|
||||
* The developer should work towards eliminating the use of these
|
||||
* methods in the near future.
|
||||
*
|
||||
* @param classnm Class the method belongs to
|
||||
* @param oldnm Name of the deprecated method
|
||||
* @param newnm Name of the method users should use instead
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
void deprecatedMethod(std::string classnm, std::string oldnm, std::string newnm);
|
||||
|
||||
//! Throw an error condition for a procedure that has been removed.
|
||||
/*!
|
||||
*
|
||||
* @param func String name for the function within which the error was
|
||||
* generated.
|
||||
* @param version Version of Cantera that first removed this function.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
* @param m This is the value of the out-of-bounds index.
|
||||
* @param mmax This is the maximum allowed value of the index. The
|
||||
* minimum allowed value is assumed to be 0.
|
||||
*/
|
||||
void removeAtVersion(std::string func, std::string version);
|
||||
ElementRangeError(std::string func, size_t m, size_t mmax);
|
||||
};
|
||||
|
||||
//! Provides a line number
|
||||
//! Print a warning when a deprecated method is called.
|
||||
/*!
|
||||
* These methods are slated to go away in future releases of Cantera.
|
||||
* The developer should work towards eliminating the use of these
|
||||
* methods in the near future.
|
||||
*
|
||||
* @param classnm Class the method belongs to
|
||||
* @param oldnm Name of the deprecated method
|
||||
* @param newnm Name of the method users should use instead
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
void deprecatedMethod(std::string classnm, std::string oldnm, std::string newnm);
|
||||
|
||||
//! Throw an error condition for a procedure that has been removed.
|
||||
/*!
|
||||
*
|
||||
* @param func String name for the function within which the error was
|
||||
* generated.
|
||||
* @param version Version of Cantera that first removed this function.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
void removeAtVersion(std::string func, std::string version);
|
||||
|
||||
//! Provides a line number
|
||||
#define XSTR_TRACE_LINE(s) STR_TRACE_LINE(s)
|
||||
|
||||
//! Provides a line number
|
||||
#define STR_TRACE_LINE(s) #s
|
||||
//! Provides a line number
|
||||
#define STR_TRACE_LINE(s) #s
|
||||
|
||||
//! Provides a std::string variable containing the file and line number
|
||||
/*!
|
||||
* This is a std:string containing the file name and the line number
|
||||
*/
|
||||
//! Provides a std::string variable containing the file and line number
|
||||
/*!
|
||||
* This is a std:string containing the file name and the line number
|
||||
*/
|
||||
#define STR_TRACE (std::string(__FILE__) + ":" + XSTR_TRACE_LINE(__LINE__))
|
||||
|
||||
#ifdef NDEBUG
|
||||
@@ -185,47 +189,47 @@ namespace Cantera {
|
||||
#endif
|
||||
#else
|
||||
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string containing the
|
||||
* file and line number, indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string containing the
|
||||
* file and line number, indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
#ifndef AssertTrace
|
||||
# define AssertTrace(expr) ((expr) ? (void) 0 : throw Cantera::CanteraError(STR_TRACE, std::string("failed assert: ") + #expr))
|
||||
#endif
|
||||
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param procedure Character string or std:string expression indicating the procedure where the assertion failed
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A diagnostic string indicating where the error
|
||||
* occured is added to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param procedure Character string or std:string expression indicating the procedure where the assertion failed
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
#ifndef AssertThrow
|
||||
# define AssertThrow(expr, procedure) ((expr) ? (void) 0 : throw Cantera::CanteraError(procedure, std::string("failed assert: ") + #expr))
|
||||
#endif
|
||||
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A
|
||||
* diagnostic string indicating where the error occured is added
|
||||
* to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param procedure Character string or std:string expression indicating
|
||||
* the procedure where the assertion failed
|
||||
* @param message Character string or std:string expression contaiing
|
||||
* a descriptive message is added to the thrown error condition.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
//! Assertion must be true or an error is thrown
|
||||
/*!
|
||||
* Assertion must be true or else a CanteraError is thrown. A
|
||||
* diagnostic string indicating where the error occured is added
|
||||
* to the thrown object.
|
||||
*
|
||||
* @param expr Boolean expression that must be true
|
||||
* @param procedure Character string or std:string expression indicating
|
||||
* the procedure where the assertion failed
|
||||
* @param message Character string or std:string expression contaiing
|
||||
* a descriptive message is added to the thrown error condition.
|
||||
*
|
||||
* @ingroup errorhandling
|
||||
*/
|
||||
#ifndef AssertThrowMsg
|
||||
# define AssertThrowMsg(expr, procedure, message) ((expr) ? (void) 0 : throw Cantera::CanteraError(procedure + std::string(": at failed assert: \"") + std::string(#expr) + std::string("\""), message))
|
||||
#endif
|
||||
@@ -233,7 +237,7 @@ namespace Cantera {
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -10,83 +10,87 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
///
|
||||
/// Base class for 'loggers' that write text messages to log files.
|
||||
///
|
||||
/// This class is used to direct log messages to application- or
|
||||
/// environment-specific output. The default is to simply print
|
||||
/// the messages to the standard output stream or standard error
|
||||
/// stream, but classes may be derived from Logger that implement
|
||||
/// other output options. This is important when Cantera is used
|
||||
/// in applications that do not display the standard output, such
|
||||
/// as MATLAB. The Cantera MATLAB interface derives a class from
|
||||
/// Logger that implements these methods with MATLAB-specific
|
||||
/// procedures, insuring that the messages will be passed through
|
||||
/// to the user. It would also be possible to derive a class that
|
||||
/// displayed the messages in a pop-up window, or redirected them
|
||||
/// to a file, etc.
|
||||
///
|
||||
/// To install a logger, call function setLogger (global.h / misc.cpp).
|
||||
///
|
||||
/// See the files Cantera/python/src/pylogger.h and
|
||||
/// Cantera/matlab/cantera/private/mllogger.h for examples of
|
||||
/// deriving logger classes.
|
||||
/// @ingroup textlogs
|
||||
///
|
||||
class Logger {
|
||||
public:
|
||||
///
|
||||
/// Base class for 'loggers' that write text messages to log files.
|
||||
///
|
||||
/// This class is used to direct log messages to application- or
|
||||
/// environment-specific output. The default is to simply print
|
||||
/// the messages to the standard output stream or standard error
|
||||
/// stream, but classes may be derived from Logger that implement
|
||||
/// other output options. This is important when Cantera is used
|
||||
/// in applications that do not display the standard output, such
|
||||
/// as MATLAB. The Cantera MATLAB interface derives a class from
|
||||
/// Logger that implements these methods with MATLAB-specific
|
||||
/// procedures, insuring that the messages will be passed through
|
||||
/// to the user. It would also be possible to derive a class that
|
||||
/// displayed the messages in a pop-up window, or redirected them
|
||||
/// to a file, etc.
|
||||
///
|
||||
/// To install a logger, call function setLogger (global.h / misc.cpp).
|
||||
///
|
||||
/// See the files Cantera/python/src/pylogger.h and
|
||||
/// Cantera/matlab/cantera/private/mllogger.h for examples of
|
||||
/// deriving logger classes.
|
||||
/// @ingroup textlogs
|
||||
///
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor - empty
|
||||
Logger() {}
|
||||
//! Constructor - empty
|
||||
Logger() {}
|
||||
|
||||
//! Destructor - empty
|
||||
virtual ~Logger() {}
|
||||
//! Destructor - empty
|
||||
virtual ~Logger() {}
|
||||
|
||||
//! Write a log message.
|
||||
/*!
|
||||
* The default behavior is to write to
|
||||
* the standard output. Note that no end-of-line character is
|
||||
* appended to the message, and so if one is desired it must
|
||||
* be included in the string.
|
||||
*
|
||||
* @param msg String message to be written to cout
|
||||
*/
|
||||
virtual void write(const std::string& msg) {
|
||||
std::cout << msg;
|
||||
}
|
||||
//! Write a log message.
|
||||
/*!
|
||||
* The default behavior is to write to
|
||||
* the standard output. Note that no end-of-line character is
|
||||
* appended to the message, and so if one is desired it must
|
||||
* be included in the string.
|
||||
*
|
||||
* @param msg String message to be written to cout
|
||||
*/
|
||||
virtual void write(const std::string& msg) {
|
||||
std::cout << msg;
|
||||
}
|
||||
|
||||
//! Write an end of line character and flush output.
|
||||
/*!
|
||||
* Some systems treat endl and \n differently. The endl
|
||||
* statement causes a flushing of stdout to the screen.
|
||||
*/
|
||||
virtual void writeendl() {
|
||||
//! Write an end of line character and flush output.
|
||||
/*!
|
||||
* Some systems treat endl and \n differently. The endl
|
||||
* statement causes a flushing of stdout to the screen.
|
||||
*/
|
||||
virtual void writeendl() {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
//! Write an error message and quit.
|
||||
/*!
|
||||
* The default behavior is
|
||||
* to write to the standard eror stream, and then call
|
||||
* exit(). Note that no end-of-line character is appended to
|
||||
* the message, and so if one is desired it must be included
|
||||
* in the string. Note that this default behavior will
|
||||
* terminate the application Cantera is invoked from (MATLAB,
|
||||
* Excel, etc.) If this is not desired, then derive a class
|
||||
* and reimplement this method.
|
||||
*
|
||||
* @param msg Error message to be written to cerr.
|
||||
*/
|
||||
virtual void error(const std::string& msg) {
|
||||
std::cerr << msg << std::endl;
|
||||
//! Write an error message and quit.
|
||||
/*!
|
||||
* The default behavior is
|
||||
* to write to the standard eror stream, and then call
|
||||
* exit(). Note that no end-of-line character is appended to
|
||||
* the message, and so if one is desired it must be included
|
||||
* in the string. Note that this default behavior will
|
||||
* terminate the application Cantera is invoked from (MATLAB,
|
||||
* Excel, etc.) If this is not desired, then derive a class
|
||||
* and reimplement this method.
|
||||
*
|
||||
* @param msg Error message to be written to cerr.
|
||||
*/
|
||||
virtual void error(const std::string& msg) {
|
||||
std::cerr << msg << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/// Return an integer specifying the application environment.
|
||||
virtual int env() { return 0; }
|
||||
};
|
||||
/// Return an integer specifying the application environment.
|
||||
virtual int env() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,102 +7,106 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
// Write a Plotting file
|
||||
/*
|
||||
* @param fname Output file name
|
||||
* @param fmt Either TEC or XL or CSV
|
||||
* @param plotTitle Title of the plot
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void writePlotFile(const std::string &fname, const std::string &fmt,
|
||||
const std::string &plotTitle,
|
||||
const std::vector<std::string> &names,
|
||||
const Array2D& data) {
|
||||
// Write a Plotting file
|
||||
/*
|
||||
* @param fname Output file name
|
||||
* @param fmt Either TEC or XL or CSV
|
||||
* @param plotTitle Title of the plot
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void writePlotFile(const std::string& fname, const std::string& fmt,
|
||||
const std::string& plotTitle,
|
||||
const std::vector<std::string> &names,
|
||||
const Array2D& data)
|
||||
{
|
||||
ofstream f(fname.c_str());
|
||||
if (!f) {
|
||||
throw CanteraError("writePlotFile","could not open file "+fname+
|
||||
" for writing.");
|
||||
throw CanteraError("writePlotFile","could not open file "+fname+
|
||||
" for writing.");
|
||||
}
|
||||
if (fmt == "TEC") {
|
||||
outputTEC(f, plotTitle, names, data);
|
||||
f.close();
|
||||
outputTEC(f, plotTitle, names, data);
|
||||
f.close();
|
||||
} else if (fmt == "XL" || fmt == "CSV") {
|
||||
outputExcel(f, plotTitle, names, data);
|
||||
f.close();
|
||||
} else {
|
||||
throw CanteraError("writePlotFile",
|
||||
"unsupported plot type:" + fmt);
|
||||
}
|
||||
else if (fmt == "XL" || fmt == "CSV") {
|
||||
outputExcel(f, plotTitle, names, data);
|
||||
f.close();
|
||||
}
|
||||
else {
|
||||
throw CanteraError("writePlotFile",
|
||||
"unsupported plot type:" + fmt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Write a Tecplot data file.
|
||||
/*
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputTEC(std::ostream &s, const std::string &title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data) {
|
||||
|
||||
|
||||
// Write a Tecplot data file.
|
||||
/*
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputTEC(std::ostream& s, const std::string& title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data)
|
||||
{
|
||||
int i,j;
|
||||
int npts = static_cast<int>(data.nColumns());
|
||||
int nv = static_cast<int>(data.nRows());
|
||||
s << "TITLE = \"" + title + "\"" << endl;
|
||||
s << "VARIABLES = " << endl;
|
||||
for (i = 0; i < nv; i++) {
|
||||
s << "\"" << names[i] << "\"" << endl;
|
||||
s << "\"" << names[i] << "\"" << endl;
|
||||
}
|
||||
s << "ZONE T=\"zone1\"" << endl;
|
||||
s << " I=" << npts << ",J=1,K=1,F=POINT" << endl;
|
||||
s << "DT=( ";
|
||||
for (i = 0; i < nv; i++) s << " SINGLE";
|
||||
for (i = 0; i < nv; i++) {
|
||||
s << " SINGLE";
|
||||
}
|
||||
s << " )" << endl;
|
||||
for (i = 0; i < npts; i++) {
|
||||
for (j = 0; j < nv; j++) {
|
||||
s << data(j,i) << " ";
|
||||
}
|
||||
s << endl;
|
||||
for (j = 0; j < nv; j++) {
|
||||
s << data(j,i) << " ";
|
||||
}
|
||||
s << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write an Excel spreadsheet in 'csv' form.
|
||||
/*
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputExcel(std::ostream &s, const std::string &title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data) {
|
||||
|
||||
// Write an Excel spreadsheet in 'csv' form.
|
||||
/*
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputExcel(std::ostream& s, const std::string& title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data)
|
||||
{
|
||||
int i,j;
|
||||
int npts = static_cast<int>(data.nColumns());
|
||||
int nv = static_cast<int>(data.nRows());
|
||||
s << title + "," << endl;
|
||||
for (i = 0; i < nv; i++) {
|
||||
s << names[i] << ",";
|
||||
s << names[i] << ",";
|
||||
}
|
||||
s << endl;
|
||||
for (i = 0; i < npts; i++) {
|
||||
for (j = 0; j < nv; j++) {
|
||||
s << data(j,i) << ",";
|
||||
}
|
||||
s << endl;
|
||||
for (j = 0; j < nv; j++) {
|
||||
s << data(j,i) << ",";
|
||||
}
|
||||
s << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,47 +16,48 @@
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
//! Write a Plotting file
|
||||
/*!
|
||||
* @param fname Output file name
|
||||
* @param fmt Either TEC or XL or CSV
|
||||
* @param plotTitle Title of the plot
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void writePlotFile(const std::string &fname, const std::string &fmt,
|
||||
const std::string &plotTitle, const std::vector<std::string> &names,
|
||||
const Array2D& data);
|
||||
//! Write a Plotting file
|
||||
/*!
|
||||
* @param fname Output file name
|
||||
* @param fmt Either TEC or XL or CSV
|
||||
* @param plotTitle Title of the plot
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void writePlotFile(const std::string& fname, const std::string& fmt,
|
||||
const std::string& plotTitle, const std::vector<std::string> &names,
|
||||
const Array2D& data);
|
||||
|
||||
|
||||
//! Write a Tecplot data file.
|
||||
/*!
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputTEC(std::ostream &s, const std::string &title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data);
|
||||
|
||||
|
||||
//! Write an Excel spreadsheet in 'csv' form.
|
||||
/*!
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputExcel(std::ostream &s, const std::string &title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data);
|
||||
//! Write a Tecplot data file.
|
||||
/*!
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputTEC(std::ostream& s, const std::string& title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data);
|
||||
|
||||
|
||||
//! Write an Excel spreadsheet in 'csv' form.
|
||||
/*!
|
||||
* @param s output stream
|
||||
* @param title plot title
|
||||
* @param names vector of variable names
|
||||
* @param data N x M data array.
|
||||
* data(n,m) is the m^th value of the n^th variable.
|
||||
*/
|
||||
void outputExcel(std::ostream& s, const std::string& title,
|
||||
const std::vector<std::string>& names,
|
||||
const Array2D& data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,270 +12,271 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
class Phase;
|
||||
class ThermoPhase;
|
||||
class Phase;
|
||||
class ThermoPhase;
|
||||
|
||||
//! Convert a double into a c++ string
|
||||
/*!
|
||||
* This routine doesn't assume a formatting. You
|
||||
* must supply the formatting
|
||||
*
|
||||
* @param x double to be converted
|
||||
* @param fmt Format to be used (printf style)
|
||||
*/
|
||||
std::string fp2str(const double x, const std::string &fmt);
|
||||
//! Convert a double into a c++ string
|
||||
/*!
|
||||
* This routine doesn't assume a formatting. You
|
||||
* must supply the formatting
|
||||
*
|
||||
* @param x double to be converted
|
||||
* @param fmt Format to be used (printf style)
|
||||
*/
|
||||
std::string fp2str(const double x, const std::string& fmt);
|
||||
|
||||
//! Convert a double into a c++ string
|
||||
/*!
|
||||
* The default format to use is equivalent to the default
|
||||
* format used by printf's %g formatting.
|
||||
*
|
||||
* @param x double to be converted
|
||||
*/
|
||||
std::string fp2str(const double x);
|
||||
//! Convert a double into a c++ string
|
||||
/*!
|
||||
* The default format to use is equivalent to the default
|
||||
* format used by printf's %g formatting.
|
||||
*
|
||||
* @param x double to be converted
|
||||
*/
|
||||
std::string fp2str(const double x);
|
||||
|
||||
//! Convert an int to a string using a format converter
|
||||
/*!
|
||||
* @param n int to be converted
|
||||
* @param fmt format converter for an int int the printf command
|
||||
*/
|
||||
std::string int2str(const int n, const std::string &fmt);
|
||||
//! Convert an int to a string using a format converter
|
||||
/*!
|
||||
* @param n int to be converted
|
||||
* @param fmt format converter for an int int the printf command
|
||||
*/
|
||||
std::string int2str(const int n, const std::string& fmt);
|
||||
|
||||
//! Convert an int to a string
|
||||
/*!
|
||||
* @param n int to be converted
|
||||
*/
|
||||
std::string int2str(const int n);
|
||||
//! Convert an int to a string
|
||||
/*!
|
||||
* @param n int to be converted
|
||||
*/
|
||||
std::string int2str(const int n);
|
||||
|
||||
//! Strip the leading and trailing white space
|
||||
//! from a string
|
||||
/*!
|
||||
* The command isprint() is used to determine printable
|
||||
* characters.
|
||||
*
|
||||
* @param s Input string
|
||||
* @return Returns a copy of the string, stripped
|
||||
* of leading and trailing white space
|
||||
*/
|
||||
std::string stripws(const std::string &s);
|
||||
//! Strip the leading and trailing white space
|
||||
//! from a string
|
||||
/*!
|
||||
* The command isprint() is used to determine printable
|
||||
* characters.
|
||||
*
|
||||
* @param s Input string
|
||||
* @return Returns a copy of the string, stripped
|
||||
* of leading and trailing white space
|
||||
*/
|
||||
std::string stripws(const std::string& s);
|
||||
|
||||
//! Strip non-printing characters wherever they are
|
||||
/*!
|
||||
* @param s Input string
|
||||
* @return Returns a copy of the string,
|
||||
* stripped of all non-printing characters.
|
||||
*/
|
||||
std::string stripnonprint(const std::string &s);
|
||||
//! Strip non-printing characters wherever they are
|
||||
/*!
|
||||
* @param s Input string
|
||||
* @return Returns a copy of the string,
|
||||
* stripped of all non-printing characters.
|
||||
*/
|
||||
std::string stripnonprint(const std::string& s);
|
||||
|
||||
//! Cast a copy of a string to lower case
|
||||
/*!
|
||||
* @param s Input string
|
||||
* @return Returns a copy of the string,
|
||||
* with all characters lowercase.
|
||||
*/
|
||||
std::string lowercase(const std::string &s);
|
||||
//! Cast a copy of a string to lower case
|
||||
/*!
|
||||
* @param s Input string
|
||||
* @return Returns a copy of the string,
|
||||
* with all characters lowercase.
|
||||
*/
|
||||
std::string lowercase(const std::string& s);
|
||||
|
||||
//! Parse a composition string into a map consisting of individual key:composition
|
||||
//! pairs.
|
||||
/*!
|
||||
* The composition is a double.
|
||||
* Example
|
||||
*
|
||||
* Input is
|
||||
*
|
||||
* "fire:0 ice:1 snow:2"
|
||||
*
|
||||
* Output is
|
||||
* x["fire"] = 0
|
||||
* x["ice"] = 1
|
||||
* x["snow"] = 2
|
||||
*
|
||||
* @param ss original string consisting of multiple key:composition
|
||||
* pairs on multiple lines
|
||||
* @param x Output map consisting of a composition
|
||||
* map, which is a string to double map
|
||||
*/
|
||||
void parseCompString(const std::string &ss, Cantera::compositionMap& x);
|
||||
//! Parse a composition string into a map consisting of individual key:composition
|
||||
//! pairs.
|
||||
/*!
|
||||
* The composition is a double.
|
||||
* Example
|
||||
*
|
||||
* Input is
|
||||
*
|
||||
* "fire:0 ice:1 snow:2"
|
||||
*
|
||||
* Output is
|
||||
* x["fire"] = 0
|
||||
* x["ice"] = 1
|
||||
* x["snow"] = 2
|
||||
*
|
||||
* @param ss original string consisting of multiple key:composition
|
||||
* pairs on multiple lines
|
||||
* @param x Output map consisting of a composition
|
||||
* map, which is a string to double map
|
||||
*/
|
||||
void parseCompString(const std::string& ss, Cantera::compositionMap& x);
|
||||
|
||||
|
||||
//! Parse a composition string into individual key:composition
|
||||
//! pairs
|
||||
/*!
|
||||
*
|
||||
* @param ss original string consisting of multiple key:composition
|
||||
* pairs on multiple lines
|
||||
* @param w Output vector consisting of single key:composition
|
||||
* items in each index.
|
||||
*/
|
||||
void split(const std::string &ss, std::vector<std::string>& w);
|
||||
//! Parse a composition string into individual key:composition
|
||||
//! pairs
|
||||
/*!
|
||||
*
|
||||
* @param ss original string consisting of multiple key:composition
|
||||
* pairs on multiple lines
|
||||
* @param w Output vector consisting of single key:composition
|
||||
* items in each index.
|
||||
*/
|
||||
void split(const std::string& ss, std::vector<std::string>& w);
|
||||
|
||||
//! Interpret a string as a list of floats, and convert it to a vector
|
||||
//! of floats
|
||||
/*!
|
||||
* @param str String input vector
|
||||
* @param a Output pointer to a vector of floats
|
||||
* @param delim character delimiter. Defaults to a space
|
||||
* @return Returns the number of floats found and converted
|
||||
*/
|
||||
int fillArrayFromString(const std::string& str, doublereal* const a,
|
||||
const char delim = ' ');
|
||||
|
||||
|
||||
//! Generate a logfile name based on an input file name
|
||||
/*!
|
||||
* It tries to find the basename. Then, it appends a .log
|
||||
* to it.
|
||||
*
|
||||
* @param infile Input file name
|
||||
*
|
||||
* @return Returns a logfile name
|
||||
*/
|
||||
std::string logfileName(const std::string& infile);
|
||||
|
||||
|
||||
//! Get the file name without the path or extension
|
||||
/*!
|
||||
* @param fullPath Input file name consisting
|
||||
* of the full file name
|
||||
*
|
||||
* @return Returns the basename
|
||||
*/
|
||||
std::string getBaseName(const std::string& fullPath);
|
||||
|
||||
//! Translate a string into one integer value
|
||||
/*!
|
||||
* No error checking is done on the conversion. The c stdlib function
|
||||
* atoi() is used.
|
||||
*
|
||||
* @param val String value of the integer
|
||||
*
|
||||
* @return Returns an integer
|
||||
*/
|
||||
int intValue(std::string val);
|
||||
|
||||
//! Translate a string into one doublereal value
|
||||
/*!
|
||||
* No error checking is done on the conversion. The c stdlib function
|
||||
* atof() is used.
|
||||
*
|
||||
* @param val String value of the double
|
||||
*
|
||||
* @return Returns a doublereal value
|
||||
*/
|
||||
doublereal fpValue(std::string val);
|
||||
|
||||
//! Translate a string into one doublereal value
|
||||
/*!
|
||||
* Error checking is carried on the conversion.
|
||||
*
|
||||
* @param val String value of the double
|
||||
*
|
||||
* @return Returns a doublereal value
|
||||
*/
|
||||
doublereal fpValueCheck(std::string val);
|
||||
|
||||
//! Parse a name string, separating out the phase name from the species name
|
||||
/*!
|
||||
* Name strings must not contain these internal characters "; \n \t ,"
|
||||
* Only one colon is allowed, the one separating the phase name from the
|
||||
* species name. Therefore, names may not include a colon.
|
||||
*
|
||||
* @param nameStr (input) Name string containing the phase name and the species
|
||||
* name separated by a colon. The phase name is optional.
|
||||
* example: "silane:SiH4"
|
||||
* @param phaseName (output) Name of the phase, if specified. If not specified,
|
||||
* a blank string is returned.
|
||||
* @return (output) Species name is returned. If nameStr is blank
|
||||
* an empty string is returned.
|
||||
*/
|
||||
std::string parseSpeciesName(const std::string& nameStr, std::string &phaseName);
|
||||
|
||||
//! Line wrap a string via a copy operation
|
||||
/*!
|
||||
* @param s Input string to be line wrapped
|
||||
* @param len Length at which to wrap. The
|
||||
* default is 70.
|
||||
*/
|
||||
std::string wrapString(const std::string &s,
|
||||
const int len=70);
|
||||
|
||||
//! Routine strips off white space from a c character string
|
||||
/*!
|
||||
* This routine strips off blanks and tabs (only leading and trailing
|
||||
* characters) in 'str'. On return, it returns the number of
|
||||
* characters still included in the string (excluding the null character).
|
||||
*
|
||||
* Comments are excluded -> All instances of the comment character, '!',
|
||||
* are replaced by NULL character thereby terminating
|
||||
* the string
|
||||
*
|
||||
* Parameter list:
|
||||
*
|
||||
* @param str On output 'str' contains the same characters as on
|
||||
* input except the leading and trailing white space and
|
||||
* comments have been removed.
|
||||
*/
|
||||
int stripLTWScstring(char str[]);
|
||||
|
||||
//! Translate a char string into a single double
|
||||
/*!
|
||||
* atofCheck is a wrapper around the C stdlib routine atof().
|
||||
* It does quite a bit more error checking than atof() or
|
||||
* strtod(), and is quite a bit more restrictive.
|
||||
*
|
||||
* First it interprets both E, e, d, and D as exponents.
|
||||
* atof() only interprets e or E as an exponent character.
|
||||
*
|
||||
* It only accepts a string as well formed if it consists as a
|
||||
* single token. Multiple words will produce an error message
|
||||
*
|
||||
* It will produce an error for NAN and inf entries as well,
|
||||
* in contrast to atof() or strtod().
|
||||
* The user needs to know that a serious numerical issue
|
||||
* has occurred.
|
||||
*
|
||||
* It does not accept hexadecimal numbers.
|
||||
*
|
||||
* @param dptr pointer to the input c string
|
||||
* @return Returns the double
|
||||
*
|
||||
* On any error, it will throw a CanteraError signal.
|
||||
*/
|
||||
doublereal atofCheck(const char * const dptr);
|
||||
//! Interpret a string as a list of floats, and convert it to a vector
|
||||
//! of floats
|
||||
/*!
|
||||
* @param str String input vector
|
||||
* @param a Output pointer to a vector of floats
|
||||
* @param delim character delimiter. Defaults to a space
|
||||
* @return Returns the number of floats found and converted
|
||||
*/
|
||||
int fillArrayFromString(const std::string& str, doublereal* const a,
|
||||
const char delim = ' ');
|
||||
|
||||
|
||||
//! Interpret one or two token string as a single double
|
||||
/*!
|
||||
* This is similar to atof(). However, the second token
|
||||
* is interpreted as an MKS units string and a conversion
|
||||
* factor to MKS is applied.
|
||||
*
|
||||
* Example
|
||||
* " 1.0 atm"
|
||||
*
|
||||
* results in the number 1.01325e5
|
||||
*
|
||||
* @param strSI string to be converted. One or two tokens
|
||||
*
|
||||
* @return returns a converted double
|
||||
*/
|
||||
doublereal strSItoDbl(const std::string& strSI);
|
||||
//! Generate a logfile name based on an input file name
|
||||
/*!
|
||||
* It tries to find the basename. Then, it appends a .log
|
||||
* to it.
|
||||
*
|
||||
* @param infile Input file name
|
||||
*
|
||||
* @return Returns a logfile name
|
||||
*/
|
||||
std::string logfileName(const std::string& infile);
|
||||
|
||||
//! This function separates a string up into tokens
|
||||
//! according to the location of white space.
|
||||
/*!
|
||||
* White space includes the new line character. tokens
|
||||
* are stripped of leading and trailing white space.
|
||||
*
|
||||
* The separate tokens are returned in a string vector, v.
|
||||
*
|
||||
* @param oval String to be broken up
|
||||
* @param v Output vector of tokens.
|
||||
*/
|
||||
void tokenizeString(const std::string& oval,
|
||||
std::vector<std::string>& v);
|
||||
|
||||
//! Get the file name without the path or extension
|
||||
/*!
|
||||
* @param fullPath Input file name consisting
|
||||
* of the full file name
|
||||
*
|
||||
* @return Returns the basename
|
||||
*/
|
||||
std::string getBaseName(const std::string& fullPath);
|
||||
|
||||
//! Translate a string into one integer value
|
||||
/*!
|
||||
* No error checking is done on the conversion. The c stdlib function
|
||||
* atoi() is used.
|
||||
*
|
||||
* @param val String value of the integer
|
||||
*
|
||||
* @return Returns an integer
|
||||
*/
|
||||
int intValue(std::string val);
|
||||
|
||||
//! Translate a string into one doublereal value
|
||||
/*!
|
||||
* No error checking is done on the conversion. The c stdlib function
|
||||
* atof() is used.
|
||||
*
|
||||
* @param val String value of the double
|
||||
*
|
||||
* @return Returns a doublereal value
|
||||
*/
|
||||
doublereal fpValue(std::string val);
|
||||
|
||||
//! Translate a string into one doublereal value
|
||||
/*!
|
||||
* Error checking is carried on the conversion.
|
||||
*
|
||||
* @param val String value of the double
|
||||
*
|
||||
* @return Returns a doublereal value
|
||||
*/
|
||||
doublereal fpValueCheck(std::string val);
|
||||
|
||||
//! Parse a name string, separating out the phase name from the species name
|
||||
/*!
|
||||
* Name strings must not contain these internal characters "; \n \t ,"
|
||||
* Only one colon is allowed, the one separating the phase name from the
|
||||
* species name. Therefore, names may not include a colon.
|
||||
*
|
||||
* @param nameStr (input) Name string containing the phase name and the species
|
||||
* name separated by a colon. The phase name is optional.
|
||||
* example: "silane:SiH4"
|
||||
* @param phaseName (output) Name of the phase, if specified. If not specified,
|
||||
* a blank string is returned.
|
||||
* @return (output) Species name is returned. If nameStr is blank
|
||||
* an empty string is returned.
|
||||
*/
|
||||
std::string parseSpeciesName(const std::string& nameStr, std::string& phaseName);
|
||||
|
||||
//! Line wrap a string via a copy operation
|
||||
/*!
|
||||
* @param s Input string to be line wrapped
|
||||
* @param len Length at which to wrap. The
|
||||
* default is 70.
|
||||
*/
|
||||
std::string wrapString(const std::string& s,
|
||||
const int len=70);
|
||||
|
||||
//! Routine strips off white space from a c character string
|
||||
/*!
|
||||
* This routine strips off blanks and tabs (only leading and trailing
|
||||
* characters) in 'str'. On return, it returns the number of
|
||||
* characters still included in the string (excluding the null character).
|
||||
*
|
||||
* Comments are excluded -> All instances of the comment character, '!',
|
||||
* are replaced by NULL character thereby terminating
|
||||
* the string
|
||||
*
|
||||
* Parameter list:
|
||||
*
|
||||
* @param str On output 'str' contains the same characters as on
|
||||
* input except the leading and trailing white space and
|
||||
* comments have been removed.
|
||||
*/
|
||||
int stripLTWScstring(char str[]);
|
||||
|
||||
//! Translate a char string into a single double
|
||||
/*!
|
||||
* atofCheck is a wrapper around the C stdlib routine atof().
|
||||
* It does quite a bit more error checking than atof() or
|
||||
* strtod(), and is quite a bit more restrictive.
|
||||
*
|
||||
* First it interprets both E, e, d, and D as exponents.
|
||||
* atof() only interprets e or E as an exponent character.
|
||||
*
|
||||
* It only accepts a string as well formed if it consists as a
|
||||
* single token. Multiple words will produce an error message
|
||||
*
|
||||
* It will produce an error for NAN and inf entries as well,
|
||||
* in contrast to atof() or strtod().
|
||||
* The user needs to know that a serious numerical issue
|
||||
* has occurred.
|
||||
*
|
||||
* It does not accept hexadecimal numbers.
|
||||
*
|
||||
* @param dptr pointer to the input c string
|
||||
* @return Returns the double
|
||||
*
|
||||
* On any error, it will throw a CanteraError signal.
|
||||
*/
|
||||
doublereal atofCheck(const char* const dptr);
|
||||
|
||||
|
||||
//! Interpret one or two token string as a single double
|
||||
/*!
|
||||
* This is similar to atof(). However, the second token
|
||||
* is interpreted as an MKS units string and a conversion
|
||||
* factor to MKS is applied.
|
||||
*
|
||||
* Example
|
||||
* " 1.0 atm"
|
||||
*
|
||||
* results in the number 1.01325e5
|
||||
*
|
||||
* @param strSI string to be converted. One or two tokens
|
||||
*
|
||||
* @return returns a converted double
|
||||
*/
|
||||
doublereal strSItoDbl(const std::string& strSI);
|
||||
|
||||
//! This function separates a string up into tokens
|
||||
//! according to the location of white space.
|
||||
/*!
|
||||
* White space includes the new line character. tokens
|
||||
* are stripped of leading and trailing white space.
|
||||
*
|
||||
* The separate tokens are returned in a string vector, v.
|
||||
*
|
||||
* @param oval String to be broken up
|
||||
* @param v Output vector of tokens.
|
||||
*/
|
||||
void tokenizeString(const std::string& oval,
|
||||
std::vector<std::string>& v);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file units.h
|
||||
* Header for units conversion utilities, which are used to translate
|
||||
* user input from input files (See \ref inputfiles and
|
||||
* user input from input files (See \ref inputfiles and
|
||||
* class \link Cantera::Unit Unit\endlink).
|
||||
*
|
||||
* This header is included only by file misc.cpp.
|
||||
@@ -20,255 +20,261 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#endif
|
||||
|
||||
namespace Cantera {
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
//! Unit conversion utility
|
||||
//! Unit conversion utility
|
||||
/*!
|
||||
*
|
||||
* @ingroup inputfiles
|
||||
*/
|
||||
class Unit
|
||||
{
|
||||
public:
|
||||
|
||||
//! Initialize the static Unit class.
|
||||
static Unit* units() {
|
||||
#if defined(THREAD_SAFE_CANTERA)
|
||||
boost::mutex::scoped_lock lock(units_mutex) ;
|
||||
#endif
|
||||
if (!s_u) {
|
||||
s_u = new Unit;
|
||||
}
|
||||
return s_u;
|
||||
}
|
||||
|
||||
//! Destroy the static Unit class
|
||||
/*!
|
||||
*
|
||||
* @ingroup inputfiles
|
||||
* Note this can't be done in a destructor.
|
||||
*/
|
||||
class Unit {
|
||||
public:
|
||||
|
||||
//! Initialize the static Unit class.
|
||||
static Unit* units() {
|
||||
static void deleteUnit() {
|
||||
#if defined(THREAD_SAFE_CANTERA)
|
||||
boost::mutex::scoped_lock lock(units_mutex) ;
|
||||
boost::mutex::scoped_lock lock(units_mutex) ;
|
||||
#endif
|
||||
if (!s_u) s_u = new Unit;
|
||||
return s_u;
|
||||
if (s_u) {
|
||||
delete s_u;
|
||||
s_u = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//! Empty Destructor
|
||||
virtual ~Unit() {}
|
||||
|
||||
/**
|
||||
* Return the multiplier required to convert an activation
|
||||
* energy to SI units.
|
||||
* @param units activation energy units
|
||||
*/
|
||||
doublereal actEnergyToSI(std::string units) {
|
||||
if (m_act_u.find(units) != m_act_u.end()) {
|
||||
return m_act_u[units];
|
||||
} else {
|
||||
return toSI(units);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the multiplier required to convert a dimensional quantity
|
||||
* with units specified by string 'units' to SI units.
|
||||
* The list of recognized units is storred as a stl map
|
||||
* <string, doublereal>called m_u[] and m_act_u for activity
|
||||
* coefficients. These maps are initialized with likely values.
|
||||
*
|
||||
* @param units String containing the units description
|
||||
*/
|
||||
doublereal toSI(std::string units) {
|
||||
|
||||
// if dimensionless, return 1.0
|
||||
if (units == "") {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//! Destroy the static Unit class
|
||||
/*!
|
||||
* Note this can't be done in a destructor.
|
||||
*/
|
||||
static void deleteUnit() {
|
||||
#if defined(THREAD_SAFE_CANTERA)
|
||||
boost::mutex::scoped_lock lock(units_mutex) ;
|
||||
#endif
|
||||
if (s_u) {
|
||||
delete s_u;
|
||||
s_u = 0;
|
||||
doublereal f = 1.0, fctr;
|
||||
int tsize;
|
||||
std::string u = units, tok, tsub;
|
||||
std::string::size_type k;
|
||||
char action = '-';
|
||||
|
||||
while (1 > 0) {
|
||||
|
||||
// get token consisting of all characters up to the next
|
||||
// dash, slash, or the end of the string
|
||||
k = u.find_first_of("/-");
|
||||
if (k != std::string::npos) {
|
||||
tok = u.substr(0,k);
|
||||
} else {
|
||||
tok = u;
|
||||
}
|
||||
tsize = static_cast<int>(tok.size());
|
||||
if (tsize == 0) {
|
||||
fctr = 1.0;
|
||||
} else if (tok[tsize - 1] == '2') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr;
|
||||
} else if (tok[tsize - 1] == '3') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr;
|
||||
} else if (tok[tsize - 1] == '4') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr*fctr;
|
||||
} else if (tok[tsize - 1] == '5') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr*fctr*fctr;
|
||||
} else if (tok[tsize - 1] == '6') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr*fctr*fctr*fctr;
|
||||
} else {
|
||||
tsub = tok;
|
||||
fctr = m_u[tok];
|
||||
}
|
||||
|
||||
// tok is not one of the entries in map m_u, then
|
||||
// m_u[tok] returns 0.0. Check for this.
|
||||
if (fctr == 0) {
|
||||
throw CanteraError("toSI","unknown unit: "+tsub);
|
||||
}
|
||||
if (action == '-') {
|
||||
f *= fctr;
|
||||
} else if (action == '/') {
|
||||
f /= fctr;
|
||||
}
|
||||
if (k == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
action = u[k];
|
||||
u = u.substr(k+1,u.size());
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
//! Empty Destructor
|
||||
virtual ~Unit() {}
|
||||
private:
|
||||
|
||||
/**
|
||||
* Return the multiplier required to convert an activation
|
||||
* energy to SI units.
|
||||
* @param units activation energy units
|
||||
*/
|
||||
doublereal actEnergyToSI(std::string units) {
|
||||
if (m_act_u.find(units) != m_act_u.end()) {
|
||||
return m_act_u[units];
|
||||
}
|
||||
else {
|
||||
return toSI(units);
|
||||
}
|
||||
}
|
||||
/// pointer to the single instance of Unit
|
||||
static Unit* s_u;
|
||||
|
||||
/**
|
||||
* Return the multiplier required to convert a dimensional quantity
|
||||
* with units specified by string 'units' to SI units.
|
||||
* The list of recognized units is storred as a stl map
|
||||
* <string, doublereal>called m_u[] and m_act_u for activity
|
||||
* coefficients. These maps are initialized with likely values.
|
||||
*
|
||||
* @param units String containing the units description
|
||||
*/
|
||||
doublereal toSI(std::string units) {
|
||||
|
||||
// if dimensionless, return 1.0
|
||||
if (units == "") return 1.0;
|
||||
|
||||
doublereal f = 1.0, fctr;
|
||||
int tsize;
|
||||
std::string u = units, tok, tsub;
|
||||
std::string::size_type k;
|
||||
char action = '-';
|
||||
//! Map between a string and a units double value
|
||||
/*!
|
||||
* This map maps the dimension string to the units value adjustment. Example
|
||||
* - m_u["m"] = 1.0;
|
||||
* - m_u["cm"] = 0.01;
|
||||
*/
|
||||
std::map<std::string, doublereal> m_u;
|
||||
|
||||
while (1 > 0) {
|
||||
|
||||
// get token consisting of all characters up to the next
|
||||
// dash, slash, or the end of the string
|
||||
k = u.find_first_of("/-");
|
||||
if (k != std::string::npos)
|
||||
tok = u.substr(0,k);
|
||||
else
|
||||
tok = u;
|
||||
tsize = static_cast<int>(tok.size());
|
||||
if (tsize == 0)
|
||||
fctr = 1.0;
|
||||
else if (tok[tsize - 1] == '2') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr;
|
||||
}
|
||||
else if (tok[tsize - 1] == '3') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr;
|
||||
}
|
||||
else if (tok[tsize - 1] == '4') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr*fctr;
|
||||
}
|
||||
else if (tok[tsize - 1] == '5') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr*fctr*fctr;
|
||||
}
|
||||
else if (tok[tsize - 1] == '6') {
|
||||
tsub = tok.substr(0,tsize-1);
|
||||
fctr = m_u[tsub];
|
||||
fctr *= fctr*fctr*fctr*fctr*fctr;
|
||||
}
|
||||
else {
|
||||
tsub = tok;
|
||||
fctr = m_u[tok];
|
||||
}
|
||||
|
||||
// tok is not one of the entries in map m_u, then
|
||||
// m_u[tok] returns 0.0. Check for this.
|
||||
if (fctr == 0)
|
||||
throw CanteraError("toSI","unknown unit: "+tsub);
|
||||
if (action == '-') f *= fctr;
|
||||
else if (action == '/') f /= fctr;
|
||||
if (k == std::string::npos) break;
|
||||
action = u[k];
|
||||
u = u.substr(k+1,u.size());
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// pointer to the single instance of Unit
|
||||
static Unit* s_u;
|
||||
|
||||
//! Map between a string and a units double value
|
||||
/*!
|
||||
* This map maps the dimension string to the units value adjustment. Example
|
||||
* - m_u["m"] = 1.0;
|
||||
* - m_u["cm"] = 0.01;
|
||||
*/
|
||||
std::map<std::string, doublereal> m_u;
|
||||
|
||||
//! Map between a string and a units double value for activation energy units
|
||||
/*!
|
||||
* This map maps the dimension string to the units value adjustment. Example
|
||||
* - m_act_u["K"] = GasConstant;
|
||||
*/
|
||||
std::map<std::string, doublereal> m_act_u;
|
||||
//! Map between a string and a units double value for activation energy units
|
||||
/*!
|
||||
* This map maps the dimension string to the units value adjustment. Example
|
||||
* - m_act_u["K"] = GasConstant;
|
||||
*/
|
||||
std::map<std::string, doublereal> m_act_u;
|
||||
|
||||
#if defined(THREAD_SAFE_CANTERA)
|
||||
//! Decl for static locker for Units singelton
|
||||
static boost::mutex units_mutex;
|
||||
//! Decl for static locker for Units singelton
|
||||
static boost::mutex units_mutex;
|
||||
#endif
|
||||
|
||||
|
||||
//! Units class constructor, containing the default mappings between
|
||||
//! strings and units.
|
||||
Unit() :
|
||||
m_u(),
|
||||
m_act_u()
|
||||
{
|
||||
//! Units class constructor, containing the default mappings between
|
||||
//! strings and units.
|
||||
Unit() :
|
||||
m_u(),
|
||||
m_act_u() {
|
||||
|
||||
// unity
|
||||
m_u["1"] = 1.0;
|
||||
// unity
|
||||
m_u["1"] = 1.0;
|
||||
|
||||
// length
|
||||
m_u["m"] = 1.0;
|
||||
m_u["cm"] = 0.01;
|
||||
m_u["km"] = 1.0e3;
|
||||
m_u["mm"] = 1.0e-3;
|
||||
m_u["micron"] = 1.0e-6;
|
||||
m_u["nm"] = 1.0e-9;
|
||||
m_u["A"] = 1.0e-10;
|
||||
m_u["Angstrom"] = 1.0e-10;
|
||||
m_u["Angstroms"] = 1.0e-10;
|
||||
// length
|
||||
m_u["m"] = 1.0;
|
||||
m_u["cm"] = 0.01;
|
||||
m_u["km"] = 1.0e3;
|
||||
m_u["mm"] = 1.0e-3;
|
||||
m_u["micron"] = 1.0e-6;
|
||||
m_u["nm"] = 1.0e-9;
|
||||
m_u["A"] = 1.0e-10;
|
||||
m_u["Angstrom"] = 1.0e-10;
|
||||
m_u["Angstroms"] = 1.0e-10;
|
||||
|
||||
// energy
|
||||
m_u["J"] = 1.0;
|
||||
m_u["kJ"] = 1.0e3;
|
||||
m_u["cal"] = 4.184;
|
||||
m_u["kcal"] = 4184.0;
|
||||
m_u["eV"] = Faraday; //1.60217733e-19;
|
||||
// energy
|
||||
m_u["J"] = 1.0;
|
||||
m_u["kJ"] = 1.0e3;
|
||||
m_u["cal"] = 4.184;
|
||||
m_u["kcal"] = 4184.0;
|
||||
m_u["eV"] = Faraday; //1.60217733e-19;
|
||||
|
||||
// resistance
|
||||
m_u["ohm"] = 1.0;
|
||||
// resistance
|
||||
m_u["ohm"] = 1.0;
|
||||
|
||||
// quantity
|
||||
m_u["mol"] = 1.0e-3;
|
||||
m_u["gmol"] = 1.0e-3;
|
||||
m_u["mole"] = 1.0e-3;
|
||||
m_u["kmol"] = 1.0;
|
||||
m_u["kgmol"] = 1.0;
|
||||
m_u["molec"] = 1.0/Avogadro;
|
||||
// quantity
|
||||
m_u["mol"] = 1.0e-3;
|
||||
m_u["gmol"] = 1.0e-3;
|
||||
m_u["mole"] = 1.0e-3;
|
||||
m_u["kmol"] = 1.0;
|
||||
m_u["kgmol"] = 1.0;
|
||||
m_u["molec"] = 1.0/Avogadro;
|
||||
|
||||
// temperature
|
||||
m_u["K"] = 1.0;
|
||||
m_u["C"] = 1.0;
|
||||
m_u["Kelvin"] = 1.0;
|
||||
// temperature
|
||||
m_u["K"] = 1.0;
|
||||
m_u["C"] = 1.0;
|
||||
m_u["Kelvin"] = 1.0;
|
||||
|
||||
// mass
|
||||
m_u["gm"] = 1.0e-3;
|
||||
m_u["g"] = 1.0e-3;
|
||||
m_u["kg"] = 1.0;
|
||||
// mass
|
||||
m_u["gm"] = 1.0e-3;
|
||||
m_u["g"] = 1.0e-3;
|
||||
m_u["kg"] = 1.0;
|
||||
|
||||
// pressure
|
||||
m_u["atm"] = 1.01325e5;
|
||||
m_u["bar"] = 1.0e5;
|
||||
m_u["Pa"] = 1.0;
|
||||
// pressure
|
||||
m_u["atm"] = 1.01325e5;
|
||||
m_u["bar"] = 1.0e5;
|
||||
m_u["Pa"] = 1.0;
|
||||
|
||||
// time
|
||||
m_u["s"] = 1.0;
|
||||
m_u["min"] = 60.0;
|
||||
m_u["hr"] = 3600.0;
|
||||
m_u["ms"] = 0.001;
|
||||
// time
|
||||
m_u["s"] = 1.0;
|
||||
m_u["min"] = 60.0;
|
||||
m_u["hr"] = 3600.0;
|
||||
m_u["ms"] = 0.001;
|
||||
|
||||
// electric potential
|
||||
m_u["volt"] = 1.0;
|
||||
// electric potential
|
||||
m_u["volt"] = 1.0;
|
||||
|
||||
// charge
|
||||
m_u["coulomb"] = 1.0;
|
||||
// charge
|
||||
m_u["coulomb"] = 1.0;
|
||||
|
||||
/*
|
||||
// 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"];
|
||||
*/
|
||||
/*
|
||||
// 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"];
|
||||
*/
|
||||
|
||||
// viscosity
|
||||
m_u["Pa-s"] = 1;
|
||||
m_u["poise"] = 0.1;
|
||||
m_u["centipoise"] = 0.001;
|
||||
m_u["P"] = 0.1;
|
||||
m_u["cP"] = 0.001;
|
||||
// viscosity
|
||||
m_u["Pa-s"] = 1;
|
||||
m_u["poise"] = 0.1;
|
||||
m_u["centipoise"] = 0.001;
|
||||
m_u["P"] = 0.1;
|
||||
m_u["cP"] = 0.001;
|
||||
|
||||
// volume
|
||||
m_u["kL"] = 1.0;
|
||||
m_u["liter"] = 0.001;
|
||||
m_u["L"] = 0.001;
|
||||
m_u["l"] = 0.001;
|
||||
m_u["mL"] = 1.0e-6;
|
||||
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;
|
||||
m_act_u["Dimensionless"] = (GasConstant * 273.15);
|
||||
}
|
||||
};
|
||||
// volume
|
||||
m_u["kL"] = 1.0;
|
||||
m_u["liter"] = 0.001;
|
||||
m_u["L"] = 0.001;
|
||||
m_u["l"] = 0.001;
|
||||
m_u["mL"] = 1.0e-6;
|
||||
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;
|
||||
m_act_u["Dimensionless"] = (GasConstant * 273.15);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user