Added consistent, complete exception handling to C interface functions
This commit is contained in:
parent
0045bc0a71
commit
22bdb58f33
12 changed files with 1765 additions and 910 deletions
|
|
@ -38,8 +38,8 @@ namespace Cantera {
|
|||
//! Exception handler used at language interface boundaries.
|
||||
/*!
|
||||
* When called from a "catch (...)" block, this function will attempt to save
|
||||
* an error message in global error and return a value indicating the type of
|
||||
* exception caught.
|
||||
* an error message in global error stack and return a value indicating the
|
||||
* type of exception caught.
|
||||
*
|
||||
* @param ctErrorCode Value to return if a CanteraError is caught
|
||||
* @param otherErrorCode Value to return if a different exception is caught
|
||||
|
|
|
|||
679
src/clib/ct.cpp
679
src/clib/ct.cpp
File diff suppressed because it is too large
Load diff
|
|
@ -20,36 +20,48 @@ extern "C" {
|
|||
|
||||
int bndry_new(int itype)
|
||||
{
|
||||
Bdry1D* s;
|
||||
switch (itype) {
|
||||
case 1:
|
||||
s = new Inlet1D();
|
||||
break;
|
||||
case 2:
|
||||
s = new Symm1D();
|
||||
break;
|
||||
case 3:
|
||||
s = new Surf1D();
|
||||
break;
|
||||
case 4:
|
||||
s = new ReactingSurf1D();
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
try {
|
||||
Bdry1D* s;
|
||||
switch (itype) {
|
||||
case 1:
|
||||
s = new Inlet1D();
|
||||
break;
|
||||
case 2:
|
||||
s = new Symm1D();
|
||||
break;
|
||||
case 3:
|
||||
s = new Surf1D();
|
||||
break;
|
||||
case 4:
|
||||
s = new ReactingSurf1D();
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
int i = BoundaryCabinet::add(s);
|
||||
return i;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
int i = BoundaryCabinet::add(s);
|
||||
return i;
|
||||
}
|
||||
|
||||
int bndry_del(int i)
|
||||
{
|
||||
BoundaryCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
BoundaryCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double bndry_temperature(int i)
|
||||
{
|
||||
return BoundaryCabinet::item(i).temperature();
|
||||
try {
|
||||
return BoundaryCabinet::item(i).temperature();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int bndry_settemperature(int i, double t)
|
||||
|
|
@ -65,7 +77,7 @@ extern "C" {
|
|||
double bndry_spreadrate(int i)
|
||||
{
|
||||
try {
|
||||
return dynamic_cast<Inlet1D*>(&BoundaryCabinet::item(i))->spreadRate();
|
||||
return dynamic_cast<Inlet1D&>(BoundaryCabinet::item(i)).spreadRate();
|
||||
} catch (...) {
|
||||
return Cantera::handleAllExceptions(-1, ERR);
|
||||
}
|
||||
|
|
@ -75,7 +87,7 @@ extern "C" {
|
|||
int bndry_setSpreadRate(int i, double v)
|
||||
{
|
||||
try {
|
||||
dynamic_cast<Inlet1D*>(&BoundaryCabinet::item(i))->setSpreadRate(v);
|
||||
dynamic_cast<Inlet1D&>(BoundaryCabinet::item(i)).setSpreadRate(v);
|
||||
} catch (...) {
|
||||
return Cantera::handleAllExceptions(-1, ERR);
|
||||
}
|
||||
|
|
@ -92,10 +104,13 @@ extern "C" {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
double bndry_mdot(int i)
|
||||
{
|
||||
return BoundaryCabinet::item(i).mdot();
|
||||
try {
|
||||
return BoundaryCabinet::item(i).mdot();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int bndry_setxin(int i, double* xin)
|
||||
|
|
@ -121,11 +136,11 @@ extern "C" {
|
|||
int surf_setkinetics(int i, int j)
|
||||
{
|
||||
try {
|
||||
ReactingSurf1D* srf =
|
||||
dynamic_cast<ReactingSurf1D*>(&BoundaryCabinet::item(i));
|
||||
InterfaceKinetics* k =
|
||||
dynamic_cast<InterfaceKinetics*>(&Cabinet<Kinetics>::item(j));
|
||||
srf->setKineticsMgr(k);
|
||||
ReactingSurf1D& srf =
|
||||
dynamic_cast<ReactingSurf1D&>(BoundaryCabinet::item(i));
|
||||
InterfaceKinetics& k =
|
||||
dynamic_cast<InterfaceKinetics&>(Cabinet<Kinetics>::item(j));
|
||||
srf.setKineticsMgr(&k);
|
||||
} catch (...) {
|
||||
return Cantera::handleAllExceptions(-1, ERR);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ extern "C" {
|
|||
|
||||
int func_new(int type, size_t n, size_t lenp, double* params)
|
||||
{
|
||||
func_t* r=0;
|
||||
size_t m = lenp;
|
||||
try {
|
||||
func_t* r=0;
|
||||
size_t m = lenp;
|
||||
if (type == SinFuncType) {
|
||||
r = new Sin1(params[0]);
|
||||
} else if (type == CosFuncType) {
|
||||
|
|
@ -95,37 +95,61 @@ extern "C" {
|
|||
|
||||
int func_del(int i)
|
||||
{
|
||||
FuncCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
FuncCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int func_copy(int i)
|
||||
{
|
||||
return FuncCabinet::newCopy(i);
|
||||
try {
|
||||
return FuncCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int func_assign(int i, int j)
|
||||
{
|
||||
return FuncCabinet::assign(i,j);
|
||||
try {
|
||||
return FuncCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double func_value(int i, double t)
|
||||
{
|
||||
return FuncCabinet::item(i).eval(t);
|
||||
try {
|
||||
return FuncCabinet::item(i).eval(t);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int func_derivative(int i)
|
||||
{
|
||||
func_t* r = 0;
|
||||
r = &FuncCabinet::item(i).derivative();
|
||||
return FuncCabinet::add(r);
|
||||
try {
|
||||
func_t* r = 0;
|
||||
r = &FuncCabinet::item(i).derivative();
|
||||
return FuncCabinet::add(r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int func_duplicate(int i)
|
||||
{
|
||||
func_t* r = 0;
|
||||
r = &FuncCabinet::item(i).duplicate();
|
||||
return FuncCabinet::add(r);
|
||||
try {
|
||||
func_t* r = 0;
|
||||
r = &FuncCabinet::item(i).duplicate();
|
||||
return FuncCabinet::add(r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int func_write(int i, size_t lennm, const char* arg, char* nm)
|
||||
|
|
|
|||
|
|
@ -53,100 +53,151 @@ static bool checkPhase(int i, int n)
|
|||
}
|
||||
}
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
int _equilflag(const char* xy);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int mix_new()
|
||||
{
|
||||
MultiPhase* m = new MultiPhase;
|
||||
return mixCabinet::add(m);
|
||||
try {
|
||||
MultiPhase* m = new MultiPhase;
|
||||
return mixCabinet::add(m);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int mix_del(int i)
|
||||
{
|
||||
mixCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
mixCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int mix_copy(int i)
|
||||
{
|
||||
return mixCabinet::newCopy(i);
|
||||
try {
|
||||
return mixCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int mix_assign(int i, int j)
|
||||
{
|
||||
return mixCabinet::assign(i,j);
|
||||
try {
|
||||
return mixCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int mix_addPhase(int i, int j, double moles)
|
||||
{
|
||||
mixCabinet::item(i).addPhase(&Cabinet<ThermoPhase>::item(j), moles);
|
||||
return 0;
|
||||
try {
|
||||
mixCabinet::item(i).addPhase(&Cabinet<ThermoPhase>::item(j), moles);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int mix_init(int i)
|
||||
{
|
||||
mixCabinet::item(i).init();
|
||||
return 0;
|
||||
try {
|
||||
mixCabinet::item(i).init();
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
size_t mix_nElements(int i)
|
||||
{
|
||||
return mixCabinet::item(i).nElements();
|
||||
try {
|
||||
return mixCabinet::item(i).nElements();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
size_t mix_elementIndex(int i, char* name)
|
||||
{
|
||||
return mixCabinet::item(i).elementIndex(string(name));
|
||||
try {
|
||||
return mixCabinet::item(i).elementIndex(string(name));
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
size_t mix_nSpecies(int i)
|
||||
{
|
||||
return mixCabinet::item(i).nSpecies();
|
||||
try {
|
||||
return mixCabinet::item(i).nSpecies();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
size_t mix_speciesIndex(int i, int k, int p)
|
||||
{
|
||||
return mixCabinet::item(i).speciesIndex(k, p);
|
||||
try {
|
||||
return mixCabinet::item(i).speciesIndex(k, p);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_nAtoms(int i, int k, int m)
|
||||
{
|
||||
bool ok = (checkSpecies(i,k) && checkElement(i,m));
|
||||
if (ok) {
|
||||
return mixCabinet::item(i).nAtoms(k,m);
|
||||
} else {
|
||||
return DERR;
|
||||
try {
|
||||
bool ok = (checkSpecies(i,k) && checkElement(i,m));
|
||||
if (ok) {
|
||||
return mixCabinet::item(i).nAtoms(k,m);
|
||||
} else {
|
||||
return DERR;
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
size_t mix_nPhases(int i)
|
||||
{
|
||||
return mixCabinet::item(i).nPhases();
|
||||
try {
|
||||
return mixCabinet::item(i).nPhases();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_phaseMoles(int i, int n)
|
||||
{
|
||||
if (!checkPhase(i, n)) {
|
||||
return DERR;
|
||||
try {
|
||||
if (!checkPhase(i, n)) {
|
||||
return DERR;
|
||||
}
|
||||
return mixCabinet::item(i).phaseMoles(n);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
return mixCabinet::item(i).phaseMoles(n);
|
||||
}
|
||||
|
||||
int mix_setPhaseMoles(int i, int n, double v)
|
||||
{
|
||||
if (!checkPhase(i, n)) {
|
||||
return ERR;
|
||||
try {
|
||||
if (!checkPhase(i, n)) {
|
||||
return ERR;
|
||||
}
|
||||
if (v < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
mixCabinet::item(i).setPhaseMoles(n, v);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
if (v < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
mixCabinet::item(i).setPhaseMoles(n, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mix_setMoles(int i, size_t nlen, double* n)
|
||||
|
|
@ -175,69 +226,109 @@ extern "C" {
|
|||
|
||||
int mix_setTemperature(int i, double t)
|
||||
{
|
||||
if (t < 0.0) {
|
||||
return -1;
|
||||
try {
|
||||
if (t < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
mixCabinet::item(i).setTemperature(t);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
mixCabinet::item(i).setTemperature(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal mix_temperature(int i)
|
||||
{
|
||||
return mixCabinet::item(i).temperature();
|
||||
try {
|
||||
return mixCabinet::item(i).temperature();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_minTemp(int i)
|
||||
{
|
||||
return mixCabinet::item(i).minTemp();
|
||||
try {
|
||||
return mixCabinet::item(i).minTemp();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_maxTemp(int i)
|
||||
{
|
||||
return mixCabinet::item(i).maxTemp();
|
||||
try {
|
||||
return mixCabinet::item(i).maxTemp();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_charge(int i)
|
||||
{
|
||||
return mixCabinet::item(i).charge();
|
||||
try {
|
||||
return mixCabinet::item(i).charge();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_phaseCharge(int i, int p)
|
||||
{
|
||||
if (!checkPhase(i,p)) {
|
||||
return DERR;
|
||||
try {
|
||||
if (!checkPhase(i,p)) {
|
||||
return DERR;
|
||||
}
|
||||
return mixCabinet::item(i).phaseCharge(p);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
return mixCabinet::item(i).phaseCharge(p);
|
||||
}
|
||||
|
||||
int mix_setPressure(int i, double p)
|
||||
{
|
||||
if (p < 0.0) {
|
||||
return -1;
|
||||
try {
|
||||
if (p < 0.0) {
|
||||
return -1;
|
||||
}
|
||||
mixCabinet::item(i).setPressure(p);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
mixCabinet::item(i).setPressure(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal mix_pressure(int i)
|
||||
{
|
||||
return mixCabinet::item(i).pressure();
|
||||
try {
|
||||
return mixCabinet::item(i).pressure();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal mix_speciesMoles(int i, int k)
|
||||
{
|
||||
if (!checkSpecies(i,k)) {
|
||||
return DERR;
|
||||
try {
|
||||
if (!checkSpecies(i,k)) {
|
||||
return DERR;
|
||||
}
|
||||
return mixCabinet::item(i).speciesMoles(k);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
return mixCabinet::item(i).speciesMoles(k);
|
||||
}
|
||||
|
||||
doublereal mix_elementMoles(int i, int m)
|
||||
{
|
||||
if (!checkElement(i,m)) {
|
||||
return DERR;
|
||||
try {
|
||||
if (!checkElement(i,m)) {
|
||||
return DERR;
|
||||
}
|
||||
return mixCabinet::item(i).elementMoles(m);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
return mixCabinet::item(i).elementMoles(m);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -291,8 +382,8 @@ extern "C" {
|
|||
int mix_getValidChemPotentials(int i, double bad_mu,
|
||||
int standard, size_t lenmu, double* mu)
|
||||
{
|
||||
bool st = (standard == 1);
|
||||
try {
|
||||
bool st = (standard == 1);
|
||||
if (lenmu < mixCabinet::item(i).nSpecies()) {
|
||||
throw CanteraError("getChemPotentials","array too small");
|
||||
}
|
||||
|
|
@ -305,36 +396,64 @@ extern "C" {
|
|||
|
||||
double mix_enthalpy(int i)
|
||||
{
|
||||
return mixCabinet::item(i).enthalpy();
|
||||
try {
|
||||
return mixCabinet::item(i).enthalpy();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double mix_entropy(int i)
|
||||
{
|
||||
return mixCabinet::item(i).entropy();
|
||||
try {
|
||||
return mixCabinet::item(i).entropy();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double mix_gibbs(int i)
|
||||
{
|
||||
return mixCabinet::item(i).gibbs();
|
||||
try {
|
||||
return mixCabinet::item(i).gibbs();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double mix_cp(int i)
|
||||
{
|
||||
return mixCabinet::item(i).cp();
|
||||
try {
|
||||
return mixCabinet::item(i).cp();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double mix_volume(int i)
|
||||
{
|
||||
return mixCabinet::item(i).volume();
|
||||
try {
|
||||
return mixCabinet::item(i).volume();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
size_t mix_speciesPhaseIndex(int i, int k)
|
||||
{
|
||||
return mixCabinet::item(i).speciesPhaseIndex(k);
|
||||
try {
|
||||
return mixCabinet::item(i).speciesPhaseIndex(k);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
double mix_moleFraction(int i, int k)
|
||||
{
|
||||
return mixCabinet::item(i).moleFraction(k);
|
||||
try {
|
||||
return mixCabinet::item(i).moleFraction(k);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,28 +59,48 @@ extern "C" {
|
|||
|
||||
int domain_del(int i)
|
||||
{
|
||||
DomainCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
DomainCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1 , ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int domain_type(int i)
|
||||
{
|
||||
return DomainCabinet::item(i).domainType();
|
||||
try {
|
||||
return DomainCabinet::item(i).domainType();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
size_t domain_index(int i)
|
||||
{
|
||||
return DomainCabinet::item(i).domainIndex();
|
||||
try {
|
||||
return DomainCabinet::item(i).domainIndex();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
size_t domain_nComponents(int i)
|
||||
{
|
||||
return DomainCabinet::item(i).nComponents();
|
||||
try {
|
||||
return DomainCabinet::item(i).nComponents();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
size_t domain_nPoints(int i)
|
||||
{
|
||||
return DomainCabinet::item(i).nPoints();
|
||||
try {
|
||||
return DomainCabinet::item(i).nPoints();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
int domain_componentName(int i, int n, int sz, char* buf)
|
||||
|
|
@ -386,11 +406,11 @@ extern "C" {
|
|||
|
||||
int stflow_setTransport(int i, int itr, int iSoret)
|
||||
{
|
||||
bool withSoret = false;
|
||||
if (iSoret > 0) {
|
||||
withSoret = true;
|
||||
}
|
||||
try {
|
||||
bool withSoret = false;
|
||||
if (iSoret > 0) {
|
||||
withSoret = true;
|
||||
}
|
||||
_stflow(i)->setTransport(TransportCabinet::item(itr), withSoret);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
|
|
@ -400,11 +420,11 @@ extern "C" {
|
|||
|
||||
int stflow_enableSoret(int i, int iSoret)
|
||||
{
|
||||
bool withSoret = false;
|
||||
if (iSoret > 0) {
|
||||
withSoret = true;
|
||||
}
|
||||
try {
|
||||
bool withSoret = false;
|
||||
if (iSoret > 0) {
|
||||
withSoret = true;
|
||||
}
|
||||
_stflow(i)->enableSoret(withSoret);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
|
|
@ -473,17 +493,12 @@ extern "C" {
|
|||
|
||||
int sim1D_new(size_t nd, int* domains)
|
||||
{
|
||||
vector<Domain1D*> d;
|
||||
try {
|
||||
// cout << "nd = " << nd << endl;
|
||||
vector<Domain1D*> d;
|
||||
for (size_t n = 0; n < nd; n++) {
|
||||
//writelog("n = "+int2str(n)+"\n");
|
||||
//writelog("dom = "+int2str(domains[n])+"\n");
|
||||
d.push_back(&DomainCabinet::item(domains[n]));
|
||||
}
|
||||
//writelog("in sim1D_new, calling new Sim1D\n");
|
||||
Sim1D* s = new Sim1D(d);
|
||||
//writelog("in sim1D_new, ret Sim1D\n");
|
||||
return SimCabinet::add(s);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
|
|
@ -502,8 +517,12 @@ extern "C" {
|
|||
|
||||
int sim1D_del(int i)
|
||||
{
|
||||
SimCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
SimCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int sim1D_setValue(int i, int dom, int comp,
|
||||
|
|
@ -545,15 +564,19 @@ extern "C" {
|
|||
|
||||
int sim1D_showSolution(int i, char* fname)
|
||||
{
|
||||
string fn = string(fname);
|
||||
if (fn == "-") {
|
||||
SimCabinet::item(i).showSolution();
|
||||
} else {
|
||||
ofstream fout(fname);
|
||||
SimCabinet::item(i).showSolution(fout);
|
||||
fout.close();
|
||||
try {
|
||||
string fn = string(fname);
|
||||
if (fn == "-") {
|
||||
SimCabinet::item(i).showSolution();
|
||||
} else {
|
||||
ofstream fout(fname);
|
||||
SimCabinet::item(i).showSolution(fout);
|
||||
fout.close();
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps)
|
||||
|
|
|
|||
|
|
@ -36,69 +36,105 @@ extern "C" {
|
|||
|
||||
int reactor_new(int type)
|
||||
{
|
||||
ReactorBase* r=0;
|
||||
if (type == ReactorType) {
|
||||
r = new Reactor();
|
||||
} else if (type == FlowReactorType) {
|
||||
r = new FlowReactor();
|
||||
} else if (type == ConstPressureReactorType) {
|
||||
r = new ConstPressureReactor();
|
||||
} else if (type == ReservoirType) {
|
||||
r = new Reservoir();
|
||||
} else {
|
||||
r = new ReactorBase();
|
||||
try {
|
||||
ReactorBase* r=0;
|
||||
if (type == ReactorType) {
|
||||
r = new Reactor();
|
||||
} else if (type == FlowReactorType) {
|
||||
r = new FlowReactor();
|
||||
} else if (type == ConstPressureReactorType) {
|
||||
r = new ConstPressureReactor();
|
||||
} else if (type == ReservoirType) {
|
||||
r = new Reservoir();
|
||||
} else {
|
||||
r = new ReactorBase();
|
||||
}
|
||||
return ReactorCabinet::add(r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return ReactorCabinet::add(r);
|
||||
}
|
||||
|
||||
int reactor_del(int i)
|
||||
{
|
||||
ReactorCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
ReactorCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_copy(int i)
|
||||
{
|
||||
return ReactorCabinet::newCopy(i);
|
||||
try {
|
||||
return ReactorCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_assign(int i, int j)
|
||||
{
|
||||
return ReactorCabinet::assign(i,j);
|
||||
try {
|
||||
return ReactorCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_setInitialVolume(int i, double v)
|
||||
{
|
||||
ReactorCabinet::item(i).setInitialVolume(v);
|
||||
return 0;
|
||||
try {
|
||||
ReactorCabinet::item(i).setInitialVolume(v);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_setInitialTime(int i, double t)
|
||||
{
|
||||
ReactorCabinet::item(i).setInitialTime(t);
|
||||
return 0;
|
||||
try {
|
||||
ReactorCabinet::item(i).setInitialTime(t);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_setThermoMgr(int i, int n)
|
||||
{
|
||||
ReactorCabinet::item(i).setThermoMgr(ThermoCabinet::item(n));
|
||||
return 0;
|
||||
try {
|
||||
ReactorCabinet::item(i).setThermoMgr(ThermoCabinet::item(n));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_setKineticsMgr(int i, int n)
|
||||
{
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
((Reactor*)r)->setKineticsMgr(KineticsCabinet::item(n));
|
||||
try {
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
((Reactor*)r)->setKineticsMgr(KineticsCabinet::item(n));
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reactor_advance(int i, double t)
|
||||
{
|
||||
try {
|
||||
ReactorCabinet::item(i).advance(t);
|
||||
return 0;
|
||||
try {
|
||||
ReactorCabinet::item(i).advance(t);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
|
|
@ -106,88 +142,144 @@ extern "C" {
|
|||
|
||||
double reactor_step(int i, double t)
|
||||
{
|
||||
return ReactorCabinet::item(i).step(t);
|
||||
try {
|
||||
return ReactorCabinet::item(i).step(t);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_time(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).time();
|
||||
try {
|
||||
return ReactorCabinet::item(i).time();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_mass(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).mass();
|
||||
try {
|
||||
return ReactorCabinet::item(i).mass();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_volume(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).volume();
|
||||
try {
|
||||
return ReactorCabinet::item(i).volume();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_density(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).density();
|
||||
try {
|
||||
return ReactorCabinet::item(i).density();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_temperature(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).temperature();
|
||||
try {
|
||||
return ReactorCabinet::item(i).temperature();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_enthalpy_mass(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).enthalpy_mass();
|
||||
try {
|
||||
return ReactorCabinet::item(i).enthalpy_mass();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_intEnergy_mass(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).intEnergy_mass();
|
||||
try {
|
||||
return ReactorCabinet::item(i).intEnergy_mass();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_pressure(int i)
|
||||
{
|
||||
return ReactorCabinet::item(i).pressure();
|
||||
try {
|
||||
return ReactorCabinet::item(i).pressure();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactor_massFraction(int i, int k)
|
||||
{
|
||||
return ReactorCabinet::item(i).massFraction(k);
|
||||
try {
|
||||
return ReactorCabinet::item(i).massFraction(k);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_setEnergy(int i, int eflag)
|
||||
{
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
((Reactor*)r)->setEnergy(eflag);
|
||||
try {
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
((Reactor*)r)->setEnergy(eflag);
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int flowReactor_setMassFlowRate(int i, double mdot)
|
||||
{
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
((FlowReactor*)r)->setMassFlowRate(mdot);
|
||||
try {
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
((FlowReactor*)r)->setMassFlowRate(mdot);
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t reactor_nSensParams(int i)
|
||||
{
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
return ((Reactor*)r)->nSensParams();
|
||||
} else {
|
||||
std::cout << "type problem..." << r->type() << std::endl;
|
||||
return 0;
|
||||
try {
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
if (r->type() >= ReactorType) {
|
||||
return ((Reactor*)r)->nSensParams();
|
||||
} else {
|
||||
std::cout << "type problem..." << r->type() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(npos, npos);
|
||||
}
|
||||
}
|
||||
|
||||
int reactor_addSensitivityReaction(int i, int rxn)
|
||||
{
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
((Reactor*)r)->addSensitivityReaction(rxn);
|
||||
return 0;
|
||||
try {
|
||||
ReactorBase* r = &ReactorCabinet::item(i);
|
||||
((Reactor*)r)->addSensitivityReaction(rxn);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -195,8 +287,12 @@ extern "C" {
|
|||
|
||||
int reactornet_new()
|
||||
{
|
||||
ReactorNet* r = new ReactorNet();
|
||||
return NetworkCabinet::add(r);
|
||||
try {
|
||||
ReactorNet* r = new ReactorNet();
|
||||
return NetworkCabinet::add(r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_del(int i)
|
||||
|
|
@ -205,42 +301,66 @@ extern "C" {
|
|||
NetworkCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return -1;
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_copy(int i)
|
||||
{
|
||||
return NetworkCabinet::newCopy(i);
|
||||
try {
|
||||
return NetworkCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_assign(int i, int j)
|
||||
{
|
||||
return NetworkCabinet::assign(i,j);
|
||||
try {
|
||||
return NetworkCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_setInitialTime(int i, double t)
|
||||
{
|
||||
NetworkCabinet::item(i).setInitialTime(t);
|
||||
return 0;
|
||||
try {
|
||||
NetworkCabinet::item(i).setInitialTime(t);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_setMaxTimeStep(int i, double maxstep)
|
||||
{
|
||||
NetworkCabinet::item(i).setMaxTimeStep(maxstep);
|
||||
return 0;
|
||||
try {
|
||||
NetworkCabinet::item(i).setMaxTimeStep(maxstep);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_setTolerances(int i, double rtol, double atol)
|
||||
{
|
||||
NetworkCabinet::item(i).setTolerances(rtol, atol);
|
||||
return 0;
|
||||
try {
|
||||
NetworkCabinet::item(i).setTolerances(rtol, atol);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_setSensitivityTolerances(int i, double rtol, double atol)
|
||||
{
|
||||
NetworkCabinet::item(i).setSensitivityTolerances(rtol, atol);
|
||||
return 0;
|
||||
try {
|
||||
NetworkCabinet::item(i).setSensitivityTolerances(rtol, atol);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int reactornet_addreactor(int i, int n)
|
||||
|
|
@ -274,50 +394,73 @@ extern "C" {
|
|||
|
||||
double reactornet_time(int i)
|
||||
{
|
||||
return NetworkCabinet::item(i).time();
|
||||
try {
|
||||
return NetworkCabinet::item(i).time();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactornet_rtol(int i)
|
||||
{
|
||||
return NetworkCabinet::item(i).rtol();
|
||||
try {
|
||||
return NetworkCabinet::item(i).rtol();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactornet_atol(int i)
|
||||
{
|
||||
return NetworkCabinet::item(i).atol();
|
||||
try {
|
||||
return NetworkCabinet::item(i).atol();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double reactornet_sensitivity(int i, char* v, int p, int r)
|
||||
{
|
||||
return NetworkCabinet::item(i).sensitivity(v, p, r);
|
||||
try {
|
||||
return NetworkCabinet::item(i).sensitivity(v, p, r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// flow devices
|
||||
|
||||
int flowdev_new(int type)
|
||||
{
|
||||
FlowDevice* r;
|
||||
switch (type) {
|
||||
case MFC_Type:
|
||||
r = new MassFlowController();
|
||||
break;
|
||||
case PressureController_Type:
|
||||
r = new PressureController();
|
||||
break;
|
||||
case Valve_Type:
|
||||
r = new Valve();
|
||||
break;
|
||||
default:
|
||||
r = new FlowDevice();
|
||||
try {
|
||||
FlowDevice* r;
|
||||
switch (type) {
|
||||
case MFC_Type:
|
||||
r = new MassFlowController();
|
||||
break;
|
||||
case PressureController_Type:
|
||||
r = new PressureController();
|
||||
break;
|
||||
case Valve_Type:
|
||||
r = new Valve();
|
||||
break;
|
||||
default:
|
||||
r = new FlowDevice();
|
||||
}
|
||||
return FlowDeviceCabinet::add(r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return FlowDeviceCabinet::add(r);
|
||||
}
|
||||
|
||||
int flowdev_del(int i)
|
||||
{
|
||||
FlowDeviceCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
FlowDeviceCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int flowdev_install(int i, int n, int m)
|
||||
|
|
@ -336,43 +479,67 @@ extern "C" {
|
|||
|
||||
int flowdev_setMaster(int i, int n)
|
||||
{
|
||||
if (FlowDeviceCabinet::item(i).type() == PressureController_Type) {
|
||||
dynamic_cast<PressureController&>(FlowDeviceCabinet::item(i)).setMaster(
|
||||
&FlowDeviceCabinet::item(n));
|
||||
try {
|
||||
if (FlowDeviceCabinet::item(i).type() == PressureController_Type) {
|
||||
dynamic_cast<PressureController&>(FlowDeviceCabinet::item(i)).setMaster(
|
||||
&FlowDeviceCabinet::item(n));
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double flowdev_massFlowRate(int i, double time)
|
||||
{
|
||||
return FlowDeviceCabinet::item(i).massFlowRate(time);
|
||||
try {
|
||||
return FlowDeviceCabinet::item(i).massFlowRate(time);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int flowdev_setMassFlowRate(int i, double mdot)
|
||||
{
|
||||
FlowDeviceCabinet::item(i).setMassFlowRate(mdot);
|
||||
return 0;
|
||||
try {
|
||||
FlowDeviceCabinet::item(i).setMassFlowRate(mdot);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int flowdev_setParameters(int i, int n, double* v)
|
||||
{
|
||||
FlowDeviceCabinet::item(i).setParameters(n, v);
|
||||
return 0;
|
||||
try {
|
||||
FlowDeviceCabinet::item(i).setParameters(n, v);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int flowdev_setFunction(int i, int n)
|
||||
{
|
||||
FlowDeviceCabinet::item(i).setFunction(&FuncCabinet::item(n));
|
||||
return 0;
|
||||
try {
|
||||
FlowDeviceCabinet::item(i).setFunction(&FuncCabinet::item(n));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int flowdev_ready(int i)
|
||||
{
|
||||
bool ok = FlowDeviceCabinet::item(i).ready();
|
||||
if (ok) {
|
||||
return 1;
|
||||
try {
|
||||
bool ok = FlowDeviceCabinet::item(i).ready();
|
||||
if (ok) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -381,118 +548,190 @@ extern "C" {
|
|||
|
||||
int wall_new(int type)
|
||||
{
|
||||
Wall* r;
|
||||
r = new Wall();
|
||||
return WallCabinet::add(r);
|
||||
try {
|
||||
Wall* r;
|
||||
r = new Wall();
|
||||
return WallCabinet::add(r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_del(int i)
|
||||
{
|
||||
WallCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_copy(int i)
|
||||
{
|
||||
return WallCabinet::newCopy(i);
|
||||
try {
|
||||
return WallCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_assign(int i, int j)
|
||||
{
|
||||
return WallCabinet::assign(i,j);
|
||||
try {
|
||||
return WallCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_install(int i, int n, int m)
|
||||
{
|
||||
WallCabinet::item(i).install(ReactorCabinet::item(n),
|
||||
ReactorCabinet::item(m));
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).install(ReactorCabinet::item(n),
|
||||
ReactorCabinet::item(m));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setkinetics(int i, int n, int m)
|
||||
{
|
||||
Kinetics* left=0, *right=0;
|
||||
if (n > 0)
|
||||
if (KineticsCabinet::item(n).type() == cInterfaceKinetics) {
|
||||
left = &KineticsCabinet::item(n);
|
||||
}
|
||||
if (m > 0)
|
||||
if (KineticsCabinet::item(m).type() == cInterfaceKinetics) {
|
||||
right = &KineticsCabinet::item(m);
|
||||
}
|
||||
WallCabinet::item(i).setKinetics(left, right);
|
||||
return 0;
|
||||
try {
|
||||
Kinetics* left=0, *right=0;
|
||||
if (n > 0)
|
||||
if (KineticsCabinet::item(n).type() == cInterfaceKinetics) {
|
||||
left = &KineticsCabinet::item(n);
|
||||
}
|
||||
if (m > 0)
|
||||
if (KineticsCabinet::item(m).type() == cInterfaceKinetics) {
|
||||
right = &KineticsCabinet::item(m);
|
||||
}
|
||||
WallCabinet::item(i).setKinetics(left, right);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double wall_vdot(int i, double t)
|
||||
{
|
||||
return WallCabinet::item(i).vdot(t);
|
||||
try {
|
||||
return WallCabinet::item(i).vdot(t);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double wall_Q(int i, double t)
|
||||
{
|
||||
return WallCabinet::item(i).Q(t);
|
||||
try {
|
||||
return WallCabinet::item(i).Q(t);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
double wall_area(int i)
|
||||
{
|
||||
return WallCabinet::item(i).area();
|
||||
try {
|
||||
return WallCabinet::item(i).area();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setArea(int i, double v)
|
||||
{
|
||||
WallCabinet::item(i).setArea(v);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setArea(v);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setThermalResistance(int i, double rth)
|
||||
{
|
||||
WallCabinet::item(i).setThermalResistance(rth);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setThermalResistance(rth);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setHeatTransferCoeff(int i, double u)
|
||||
{
|
||||
WallCabinet::item(i).setHeatTransferCoeff(u);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setHeatTransferCoeff(u);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setHeatFlux(int i, int n)
|
||||
{
|
||||
WallCabinet::item(i).setHeatFlux(&FuncCabinet::item(n));
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setHeatFlux(&FuncCabinet::item(n));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setExpansionRateCoeff(int i, double k)
|
||||
{
|
||||
WallCabinet::item(i).setExpansionRateCoeff(k);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setExpansionRateCoeff(k);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setVelocity(int i, int n)
|
||||
{
|
||||
WallCabinet::item(i).setVelocity(&FuncCabinet::item(n));
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setVelocity(&FuncCabinet::item(n));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_setEmissivity(int i, double epsilon)
|
||||
{
|
||||
WallCabinet::item(i).setEmissivity(epsilon);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).setEmissivity(epsilon);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_ready(int i)
|
||||
{
|
||||
if (WallCabinet::item(i).ready()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
try {
|
||||
if (WallCabinet::item(i).ready()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_addSensitivityReaction(int i, int lr, int rxn)
|
||||
{
|
||||
WallCabinet::item(i).addSensitivityReaction(lr, rxn);
|
||||
return 0;
|
||||
try {
|
||||
WallCabinet::item(i).addSensitivityReaction(lr, rxn);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,181 +22,288 @@ extern "C" {
|
|||
|
||||
int rdiag_new()
|
||||
{
|
||||
ReactionPathDiagram* d = new ReactionPathDiagram();
|
||||
return DiagramCabinet::add(d);
|
||||
try {
|
||||
ReactionPathDiagram* d = new ReactionPathDiagram();
|
||||
return DiagramCabinet::add(d);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_del(int i)
|
||||
{
|
||||
DiagramCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_copy(int i)
|
||||
{
|
||||
return DiagramCabinet::newCopy(i);
|
||||
try {
|
||||
return DiagramCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_assign(int i, int j)
|
||||
{
|
||||
return DiagramCabinet::assign(i,j);
|
||||
try {
|
||||
return DiagramCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_detailed(int i)
|
||||
{
|
||||
DiagramCabinet::item(i).show_details = true;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).show_details = true;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_brief(int i)
|
||||
{
|
||||
DiagramCabinet::item(i).show_details = false;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).show_details = false;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setThreshold(int i, double v)
|
||||
{
|
||||
DiagramCabinet::item(i).threshold = v;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).threshold = v;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setBoldColor(int i, char* color)
|
||||
{
|
||||
DiagramCabinet::item(i).bold_color = string(color);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).bold_color = string(color);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setNormalColor(int i, char* color)
|
||||
{
|
||||
DiagramCabinet::item(i).normal_color = string(color);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).normal_color = string(color);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setDashedColor(int i, char* color)
|
||||
{
|
||||
DiagramCabinet::item(i).dashed_color = string(color);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).dashed_color = string(color);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setDotOptions(int i, char* opt)
|
||||
{
|
||||
DiagramCabinet::item(i).dot_options = string(opt);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).dot_options = string(opt);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setFont(int i, char* font)
|
||||
{
|
||||
DiagramCabinet::item(i).setFont(string(font));
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).setFont(string(font));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setBoldThreshold(int i, double v)
|
||||
{
|
||||
DiagramCabinet::item(i).bold_min = v;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).bold_min = v;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setNormalThreshold(int i, double v)
|
||||
{
|
||||
DiagramCabinet::item(i).dashed_max = v;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).dashed_max = v;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setLabelThreshold(int i, double v)
|
||||
{
|
||||
DiagramCabinet::item(i).label_min = v;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).label_min = v;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setScale(int i, double v)
|
||||
{
|
||||
DiagramCabinet::item(i).scale = v;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).scale = v;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setFlowType(int i, int iflow)
|
||||
{
|
||||
if (iflow == 0) {
|
||||
DiagramCabinet::item(i).flow_type = OneWayFlow;
|
||||
} else {
|
||||
DiagramCabinet::item(i).flow_type = NetFlow;
|
||||
try {
|
||||
if (iflow == 0) {
|
||||
DiagramCabinet::item(i).flow_type = OneWayFlow;
|
||||
} else {
|
||||
DiagramCabinet::item(i).flow_type = NetFlow;
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rdiag_setArrowWidth(int i, double v)
|
||||
{
|
||||
DiagramCabinet::item(i).arrow_width = v;
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).arrow_width = v;
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_setTitle(int i, char* title)
|
||||
{
|
||||
DiagramCabinet::item(i).title = string(title);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).title = string(title);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_add(int i, int n)
|
||||
{
|
||||
DiagramCabinet::item(i).add(DiagramCabinet::item(n));
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).add(DiagramCabinet::item(n));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_findMajor(int i, double threshold,
|
||||
size_t lda, double* a)
|
||||
{
|
||||
DiagramCabinet::item(i).findMajorPaths(threshold, lda, a);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).findMajorPaths(threshold, lda, a);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rdiag_write(int i, int fmt, char* fname)
|
||||
{
|
||||
ofstream f(fname);
|
||||
if (fmt == 0) {
|
||||
DiagramCabinet::item(i).exportToDot(f);
|
||||
} else {
|
||||
DiagramCabinet::item(i).writeData(f);
|
||||
try {
|
||||
ofstream f(fname);
|
||||
if (fmt == 0) {
|
||||
DiagramCabinet::item(i).exportToDot(f);
|
||||
} else {
|
||||
DiagramCabinet::item(i).writeData(f);
|
||||
}
|
||||
f.close();
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
f.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rdiag_displayOnly(int i, int k)
|
||||
{
|
||||
DiagramCabinet::item(i).displayOnly(k);
|
||||
return 0;
|
||||
try {
|
||||
DiagramCabinet::item(i).displayOnly(k);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rbuild_new()
|
||||
{
|
||||
ReactionPathBuilder* d = new ReactionPathBuilder();
|
||||
return BuilderCabinet::add(d);
|
||||
try {
|
||||
ReactionPathBuilder* d = new ReactionPathBuilder();
|
||||
return BuilderCabinet::add(d);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rbuild_del(int i)
|
||||
{
|
||||
BuilderCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
BuilderCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int rbuild_init(int i, char* logfile, int k)
|
||||
{
|
||||
ofstream flog(logfile);
|
||||
BuilderCabinet::item(i).init(flog, KineticsCabinet::item(k));
|
||||
return 0;
|
||||
try {
|
||||
ofstream flog(logfile);
|
||||
BuilderCabinet::item(i).init(flog, KineticsCabinet::item(k));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int 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;
|
||||
try {
|
||||
ofstream fdot(dotfile);
|
||||
bool quiet = false;
|
||||
if (iquiet > 0) {
|
||||
quiet = true;
|
||||
}
|
||||
BuilderCabinet::item(i).build(KineticsCabinet::item(k), string(el), fdot,
|
||||
DiagramCabinet::item(idiag), quiet);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
BuilderCabinet::item(i).build(KineticsCabinet::item(k), string(el), fdot,
|
||||
DiagramCabinet::item(idiag), quiet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,61 +14,84 @@
|
|||
using namespace std;
|
||||
using namespace Cantera;
|
||||
|
||||
inline SurfPhase* _surfphase(int n)
|
||||
inline SurfPhase& _surfphase(int n)
|
||||
{
|
||||
return dynamic_cast<SurfPhase*>(&Cabinet<ThermoPhase>::item(n));
|
||||
return dynamic_cast<SurfPhase&>(Cabinet<ThermoPhase>::item(n));
|
||||
}
|
||||
|
||||
inline InterfaceKinetics* _surfkin(int n)
|
||||
inline InterfaceKinetics& _surfkin(int n)
|
||||
{
|
||||
return dynamic_cast<InterfaceKinetics*>(&Cabinet<Kinetics>::item(n));
|
||||
return dynamic_cast<InterfaceKinetics&>(Cabinet<Kinetics>::item(n));
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int surf_setsitedensity(int i, double s0)
|
||||
{
|
||||
_surfphase(i)->setSiteDensity(s0);
|
||||
return 0;
|
||||
try {
|
||||
_surfphase(i).setSiteDensity(s0);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
double surf_sitedensity(int i)
|
||||
{
|
||||
return _surfphase(i)->siteDensity();
|
||||
try {
|
||||
return _surfphase(i).siteDensity();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
int surf_setcoverages(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->setCoverages(c);
|
||||
return 0;
|
||||
try {
|
||||
_surfphase(i).setCoverages(c);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int surf_setcoveragesbyname(int i, char* c)
|
||||
{
|
||||
_surfphase(i)->setCoveragesByName(string(c));
|
||||
return 0;
|
||||
try {
|
||||
_surfphase(i).setCoveragesByName(string(c));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int surf_getcoverages(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->getCoverages(c);
|
||||
try {
|
||||
_surfphase(i).getCoverages(c);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int surf_setconcentrations(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->setConcentrations(c);
|
||||
return 0;
|
||||
try {
|
||||
_surfphase(i).setConcentrations(c);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int surf_getconcentrations(int i, double* c)
|
||||
{
|
||||
_surfphase(i)->getConcentrations(c);
|
||||
return 0;
|
||||
try {
|
||||
_surfphase(i).getConcentrations(c);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// int surface_setcoverages(int i, double* c) {
|
||||
// _surface(i)->setCoverages(c);
|
||||
// return 0;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,17 @@ extern "C" {
|
|||
|
||||
int xml_new(const char* name = 0)
|
||||
{
|
||||
XML_Node* x;
|
||||
if (!name) {
|
||||
x = new XML_Node;
|
||||
} else {
|
||||
x = new XML_Node(name);
|
||||
}
|
||||
return XmlCabinet::add(x);
|
||||
try {
|
||||
XML_Node* x;
|
||||
if (!name) {
|
||||
x = new XML_Node;
|
||||
} else {
|
||||
x = new XML_Node(name);
|
||||
}
|
||||
return XmlCabinet::add(x);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int xml_get_XML_File(const char* file, int debug)
|
||||
|
|
@ -53,24 +57,40 @@ extern "C" {
|
|||
|
||||
int xml_del(int i)
|
||||
{
|
||||
XmlCabinet::del(i);
|
||||
return 0;
|
||||
try {
|
||||
XmlCabinet::del(i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int xml_removeChild(int i, int j)
|
||||
{
|
||||
XmlCabinet::item(i).removeChild(&XmlCabinet::item(j));
|
||||
return 0;
|
||||
try {
|
||||
XmlCabinet::item(i).removeChild(&XmlCabinet::item(j));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int xml_copy(int i)
|
||||
{
|
||||
return XmlCabinet::newCopy(i);
|
||||
try {
|
||||
return XmlCabinet::newCopy(i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int xml_assign(int i, int j)
|
||||
{
|
||||
return XmlCabinet::assign(i,j);
|
||||
try {
|
||||
return XmlCabinet::assign(i,j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int xml_build(int i, const char* file)
|
||||
|
|
@ -101,8 +121,6 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int xml_attrib(int i, const char* key, char* value)
|
||||
{
|
||||
try {
|
||||
|
|
@ -230,10 +248,9 @@ extern "C" {
|
|||
try {
|
||||
XML_Node& node = XmlCabinet::item(i);
|
||||
return (int) node.nChildren();
|
||||
} catch (CanteraError& err) {
|
||||
err.save();
|
||||
return -1;
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
int xml_addChild(int i, const char* name, const char* value)
|
||||
|
|
|
|||
|
|
@ -71,12 +71,6 @@ std::string f2string(const char* s, ftnlen n)
|
|||
return ss;
|
||||
}
|
||||
|
||||
static void handleError(CanteraError& err)
|
||||
{
|
||||
err.save();
|
||||
error(lastErrorMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Exported functions.
|
||||
*/
|
||||
|
|
@ -85,13 +79,9 @@ extern "C" {
|
|||
status_t cantera_error_(const char* proc, const char* msg,
|
||||
ftnlen proclen, ftnlen msglen)
|
||||
{
|
||||
try {
|
||||
std::string sproc = f2string(proc, proclen);
|
||||
std::string smsg = f2string(msg, msglen);
|
||||
throw CanteraError(sproc, smsg);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
std::string sproc = f2string(proc, proclen);
|
||||
std::string smsg = f2string(msg, msglen);
|
||||
throw CanteraError(sproc, smsg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -107,96 +97,157 @@ extern "C" {
|
|||
for (int nn = lout; nn < lennm; nn++) {
|
||||
nm[nn] = ' ';
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
integer phase_nelements_(const integer* n)
|
||||
{
|
||||
try {
|
||||
return _fph(n)->nElements();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer phase_nspecies_(const integer* n)
|
||||
{
|
||||
try {
|
||||
return _fph(n)->nSpecies();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer phase_nelements_(const integer* n)
|
||||
{
|
||||
return _fph(n)->nElements();
|
||||
}
|
||||
|
||||
integer phase_nspecies_(const integer* n)
|
||||
{
|
||||
return _fph(n)->nSpecies();
|
||||
}
|
||||
|
||||
doublereal phase_temperature_(const integer* n)
|
||||
{
|
||||
return _fph(n)->temperature();
|
||||
try {
|
||||
return _fph(n)->temperature();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t phase_settemperature_(const integer* n, doublereal* t)
|
||||
{
|
||||
_fph(n)->setTemperature(*t);
|
||||
try {
|
||||
_fph(n)->setTemperature(*t);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal phase_density_(const integer* n)
|
||||
{
|
||||
return _fph(n)->density();
|
||||
try {
|
||||
return _fph(n)->density();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t phase_setdensity_(const integer* n, doublereal* rho)
|
||||
{
|
||||
_fph(n)->setDensity(*rho);
|
||||
try {
|
||||
_fph(n)->setDensity(*rho);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal phase_molardensity_(const integer* n)
|
||||
{
|
||||
return _fph(n)->molarDensity();
|
||||
try {
|
||||
return _fph(n)->molarDensity();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal phase_meanmolecularweight_(const integer* n)
|
||||
{
|
||||
return _fph(n)->meanMolecularWeight();
|
||||
try {
|
||||
return _fph(n)->meanMolecularWeight();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer phase_elementindex_(const integer* n, char* nm, ftnlen lennm)
|
||||
{
|
||||
std::string elnm = f2string(nm, lennm);
|
||||
return _fph(n)->elementIndex(elnm) + 1;
|
||||
try {
|
||||
std::string elnm = f2string(nm, lennm);
|
||||
return _fph(n)->elementIndex(elnm) + 1;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer phase_speciesindex_(const integer* n, char* nm, ftnlen lennm)
|
||||
{
|
||||
std::string spnm = f2string(nm, lennm);
|
||||
return _fph(n)->speciesIndex(spnm) + 1;
|
||||
try {
|
||||
std::string spnm = f2string(nm, lennm);
|
||||
return _fph(n)->speciesIndex(spnm) + 1;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t phase_getmolefractions_(const integer* n, doublereal* x)
|
||||
{
|
||||
_fph(n)->getMoleFractions(x);
|
||||
try {
|
||||
_fph(n)->getMoleFractions(x);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal phase_molefraction_(const integer* n, integer* k)
|
||||
{
|
||||
return _fph(n)->moleFraction(*k-1);
|
||||
try {
|
||||
return _fph(n)->moleFraction(*k-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
status_t phase_getmassfractions_(const integer* n, doublereal* y)
|
||||
{
|
||||
ThermoPhase* p = _fph(n);
|
||||
p->getMassFractions(y);
|
||||
return 0;
|
||||
try {
|
||||
ThermoPhase* p = _fph(n);
|
||||
p->getMassFractions(y);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal phase_massfraction_(const integer* n, integer* k)
|
||||
{
|
||||
return _fph(n)->massFraction(*k-1);
|
||||
try {
|
||||
return _fph(n)->massFraction(*k-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t phase_setmolefractions_(const integer* n, double* x, const integer* norm)
|
||||
{
|
||||
ThermoPhase* p = _fph(n);
|
||||
if (*norm) {
|
||||
p->setMoleFractions(x);
|
||||
} else {
|
||||
p->setMoleFractions_NoNorm(x);
|
||||
try {
|
||||
ThermoPhase* p = _fph(n);
|
||||
if (*norm) {
|
||||
p->setMoleFractions(x);
|
||||
} else {
|
||||
p->setMoleFractions_NoNorm(x);
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -212,19 +263,23 @@ extern "C" {
|
|||
}
|
||||
parseCompString(f2string(x, lx), xx);
|
||||
p->setMoleFractionsByName(xx);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t phase_setmassfractions_(const integer* n, doublereal* y, const integer* norm)
|
||||
{
|
||||
ThermoPhase* p = _fph(n);
|
||||
if (*norm) {
|
||||
p->setMassFractions(y);
|
||||
} else {
|
||||
p->setMassFractions_NoNorm(y);
|
||||
try {
|
||||
ThermoPhase* p = _fph(n);
|
||||
if (*norm) {
|
||||
p->setMassFractions(y);
|
||||
} else {
|
||||
p->setMassFractions_NoNorm(y);
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -240,29 +295,36 @@ extern "C" {
|
|||
}
|
||||
parseCompString(f2string(y, leny), yy);
|
||||
p->setMassFractionsByName(yy);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t phase_getatomicweights_(const integer* n, doublereal* atw)
|
||||
{
|
||||
ThermoPhase* p = _fph(n);
|
||||
const vector_fp& wt = p->atomicWeights();
|
||||
copy(wt.begin(), wt.end(), atw);
|
||||
try {
|
||||
ThermoPhase* p = _fph(n);
|
||||
const vector_fp& wt = p->atomicWeights();
|
||||
copy(wt.begin(), wt.end(), atw);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t phase_getmolecularweights_(const integer* n, doublereal* mw)
|
||||
{
|
||||
ThermoPhase* p = _fph(n);
|
||||
const vector_fp& wt = p->molecularWeights();
|
||||
copy(wt.begin(), wt.end(), mw);
|
||||
try {
|
||||
ThermoPhase* p = _fph(n);
|
||||
const vector_fp& wt = p->molecularWeights();
|
||||
copy(wt.begin(), wt.end(), mw);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
status_t phase_getspeciesname_(const integer* n, integer* k, char* nm, ftnlen lennm)
|
||||
{
|
||||
try {
|
||||
|
|
@ -272,10 +334,10 @@ extern "C" {
|
|||
for (int nn = lout; nn < lennm; nn++) {
|
||||
nm[nn] = ' ';
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t phase_getelementname_(const integer* n, integer* m, char* nm, ftnlen lennm)
|
||||
|
|
@ -287,10 +349,10 @@ extern "C" {
|
|||
for (int nn = lout; nn < lennm; nn++) {
|
||||
nm[nn] = ' ';
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -303,9 +365,6 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------- Thermo --------------------//
|
||||
|
||||
integer newthermofromxml_(integer* mxml)
|
||||
|
|
@ -321,12 +380,20 @@ extern "C" {
|
|||
|
||||
integer th_nspecies_(const integer* n)
|
||||
{
|
||||
return _fth(n)->nSpecies();
|
||||
try {
|
||||
return _fth(n)->nSpecies();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer th_eostype_(const integer* n)
|
||||
{
|
||||
return _fth(n)->eosType();
|
||||
try {
|
||||
return _fth(n)->eosType();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal th_enthalpy_mole_(const integer* n)
|
||||
|
|
@ -448,8 +515,12 @@ extern "C" {
|
|||
|
||||
status_t th_chempotentials_(const integer* n, doublereal* murt)
|
||||
{
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getChemPotentials(murt);
|
||||
try {
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getChemPotentials(murt);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -457,96 +528,120 @@ extern "C" {
|
|||
{
|
||||
try {
|
||||
_fth(n)->setPressure(*p);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_set_hp_(const integer* n, doublereal* v1, doublereal* v2)
|
||||
{
|
||||
try {
|
||||
_fth(n)->setState_HP(*v1, *v2);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_set_uv_(const integer* n, doublereal* v1, doublereal* v2)
|
||||
{
|
||||
try {
|
||||
_fth(n)->setState_UV(*v1, *v2);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_set_sv_(const integer* n, doublereal* v1, doublereal* v2)
|
||||
{
|
||||
try {
|
||||
_fth(n)->setState_SV(*v1, *v2);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_set_sp_(const integer* n, doublereal* v1, doublereal* v2)
|
||||
{
|
||||
try {
|
||||
_fth(n)->setState_SP(*v1, *v2);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_equil_(const integer* n, char* XY, ftnlen lenxy)
|
||||
{
|
||||
try {
|
||||
equilibrate(*_fth(n), f2string(XY,lenxy).c_str());
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal th_refpressure_(const integer* n)
|
||||
{
|
||||
try {
|
||||
return _fth(n)->refPressure();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal th_refpressure_(const integer* n)
|
||||
{
|
||||
return _fth(n)->refPressure();
|
||||
}
|
||||
|
||||
doublereal th_mintemp_(const integer* n, integer* k)
|
||||
{
|
||||
return _fth(n)->minTemp(*k-1);
|
||||
try {
|
||||
return _fth(n)->minTemp(*k-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal th_maxtemp_(const integer* n, integer* k)
|
||||
{
|
||||
return _fth(n)->maxTemp(*k-1);
|
||||
try {
|
||||
return _fth(n)->maxTemp(*k-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status_t th_getenthalpies_rt_(const integer* n, doublereal* h_rt)
|
||||
{
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getEnthalpy_RT(h_rt);
|
||||
try {
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getEnthalpy_RT(h_rt);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_getentropies_r_(const integer* n, doublereal* s_r)
|
||||
{
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getEntropy_R(s_r);
|
||||
try {
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getEntropy_R(s_r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t th_getcp_r_(const integer* n, integer* lenm, doublereal* cp_r)
|
||||
{
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getCp_R(cp_r);
|
||||
try {
|
||||
thermo_t* thrm = _fth(n);
|
||||
thrm->getCp_R(cp_r);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -585,98 +680,130 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
// status_t installRxnArrays_(integer* pxml, integer* ikin,
|
||||
// char* default_phase) {
|
||||
// try {
|
||||
// XML_Node* p = _xml(pxml);
|
||||
// kinetics_t* k = kin(ikin);
|
||||
// string defphase = string(default_phase);
|
||||
// installReactionArrays(*p, *k, defphase);
|
||||
// return 0;
|
||||
// }
|
||||
// catch (CanteraError) { handleError(); return -1; }
|
||||
// }
|
||||
|
||||
//-------------------------------------
|
||||
integer kin_type_(const integer* n)
|
||||
{
|
||||
return _fkin(n)->type();
|
||||
try {
|
||||
return _fkin(n)->type();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_start_(const integer* n, integer* p)
|
||||
{
|
||||
return _fkin(n)->start(*p)+1;
|
||||
try {
|
||||
return _fkin(n)->start(*p)+1;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_speciesindex_(const integer* n, const char* nm, const char* ph,
|
||||
ftnlen lennm, ftnlen lenph)
|
||||
{
|
||||
return _fkin(n)->kineticsSpeciesIndex(f2string(nm, lennm), f2string(ph, lenph))+1;
|
||||
try {
|
||||
return _fkin(n)->kineticsSpeciesIndex(f2string(nm, lennm),
|
||||
f2string(ph, lenph)) + 1;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
integer kin_ntotalspecies_(const integer* n)
|
||||
{
|
||||
return _fkin(n)->nTotalSpecies();
|
||||
try {
|
||||
return _fkin(n)->nTotalSpecies();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_nreactions_(const integer* n)
|
||||
{
|
||||
return _fkin(n)->nReactions();
|
||||
try {
|
||||
return _fkin(n)->nReactions();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_nphases_(const integer* n)
|
||||
{
|
||||
return _fkin(n)->nPhases();
|
||||
try {
|
||||
return _fkin(n)->nPhases();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_phaseindex_(const integer* n, const char* ph,
|
||||
ftnlen lenph)
|
||||
integer kin_phaseindex_(const integer* n, const char* ph, ftnlen lenph)
|
||||
{
|
||||
return _fkin(n)->phaseIndex(f2string(ph, lenph));
|
||||
try {
|
||||
return _fkin(n)->phaseIndex(f2string(ph, lenph));
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal kin_reactantstoichcoeff_(const integer* n, integer* k, integer* i)
|
||||
{
|
||||
return _fkin(n)->reactantStoichCoeff(*k-1,*i-1);
|
||||
try {
|
||||
return _fkin(n)->reactantStoichCoeff(*k-1,*i-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
doublereal kin_productstoichcoeff_(const integer* n, integer* k, integer* i)
|
||||
{
|
||||
return _fkin(n)->productStoichCoeff(*k-1,*i-1);
|
||||
try {
|
||||
return _fkin(n)->productStoichCoeff(*k-1,*i-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
integer kin_reactiontype_(const integer* n, integer* i)
|
||||
{
|
||||
return _fkin(n)->reactionType(*i-1);
|
||||
try {
|
||||
return _fkin(n)->reactionType(*i-1);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t kin_getfwdratesofprogress_(const integer* n, doublereal* fwdROP)
|
||||
{
|
||||
Kinetics* k = _fkin(n);
|
||||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getFwdRatesOfProgress(fwdROP);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_getrevratesofprogress_(const integer* n, doublereal* revROP)
|
||||
{
|
||||
Kinetics* k = _fkin(n);
|
||||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getRevRatesOfProgress(revROP);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
integer kin_isreversible_(const integer* n, integer* i)
|
||||
{
|
||||
return (int)_fkin(n)->isReversible(*i);
|
||||
try {
|
||||
return (int)_fkin(n)->isReversible(*i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t kin_getnetratesofprogress_(const integer* n, doublereal* netROP)
|
||||
|
|
@ -684,10 +811,10 @@ extern "C" {
|
|||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getNetRatesOfProgress(netROP);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_getcreationrates_(const integer* n, doublereal* cdot)
|
||||
|
|
@ -695,10 +822,10 @@ extern "C" {
|
|||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getCreationRates(cdot);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_getdestructionrates_(const integer* n, doublereal* ddot)
|
||||
|
|
@ -706,10 +833,10 @@ extern "C" {
|
|||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getDestructionRates(ddot);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_getnetproductionrates_(const integer* n, doublereal* wdot)
|
||||
|
|
@ -717,15 +844,19 @@ extern "C" {
|
|||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getNetProductionRates(wdot);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal kin_multiplier_(const integer* n, integer* i)
|
||||
{
|
||||
return _fkin(n)->multiplier(*i);
|
||||
try {
|
||||
return _fkin(n)->multiplier(*i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(DERR, DERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t kin_getequilibriumconstants_(const integer* n, doublereal* kc)
|
||||
|
|
@ -733,10 +864,10 @@ extern "C" {
|
|||
try {
|
||||
Kinetics* k = _fkin(n);
|
||||
k->getEquilibriumConstants(kc);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_getreactionstring_(const integer* n, integer* i, char* buf, ftnlen lenbuf)
|
||||
|
|
@ -749,20 +880,20 @@ extern "C" {
|
|||
for (int nn = lout; nn < lenbuf; nn++) {
|
||||
buf[nn] = ' ';
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_setmultiplier_(const integer* n, integer* i, doublereal* v)
|
||||
{
|
||||
try {
|
||||
_fkin(n)->setMultiplier(*i-1,*v);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t kin_advancecoverages_(const integer* n, doublereal* tstep)
|
||||
|
|
@ -775,20 +906,20 @@ extern "C" {
|
|||
throw CanteraError("kin_advanceCoverages",
|
||||
"wrong kinetics manager type");
|
||||
}
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------- Transport ---------------------------
|
||||
|
||||
integer newtransport_(char* model,
|
||||
integer* ith, integer* loglevel, ftnlen lenmodel)
|
||||
integer newtransport_(char* model, integer* ith,
|
||||
integer* loglevel, ftnlen lenmodel)
|
||||
{
|
||||
std::string mstr = f2string(model, lenmodel);
|
||||
thermo_t* t = _fth(ith);
|
||||
try {
|
||||
std::string mstr = f2string(model, lenmodel);
|
||||
thermo_t* t = _fth(ith);
|
||||
Transport* tr = newTransportMgr(mstr, t, *loglevel);
|
||||
return TransportCabinet::add(tr);
|
||||
} catch (...) {
|
||||
|
|
@ -866,34 +997,6 @@ extern "C" {
|
|||
|
||||
//-------------------- Functions ---------------------------
|
||||
|
||||
// status_t import_phase_(const integer* nth, const integer* nxml, char* id, ftnlen lenid) {
|
||||
// thermo_t* thrm = th(nth);
|
||||
// XML_Node* node = _xml(nxml);
|
||||
// string idstr = f2string(id, lenid);
|
||||
// try {
|
||||
// importPhase(*node, thrm);
|
||||
// return 0;
|
||||
// }
|
||||
// catch (CanteraError) { handleError(); return -1; }
|
||||
// }
|
||||
|
||||
// status_t import_kinetics_(const integer* nxml, char* id,
|
||||
// const integer* nphases, integer* ith, const integer* nkin, ftnlen lenid) {
|
||||
// vector<thermo_t*> phases;
|
||||
// for (int i = 0; i < nphases; i++) {
|
||||
// phases.push_back(th(ith[i]));
|
||||
// }
|
||||
// XML_Node* node = _xml(nxml);
|
||||
// Kinetics* k = kin(nkin);
|
||||
// string idstr = f2string(id, lenid);
|
||||
// try {
|
||||
// importKinetics(*node, phases, k);
|
||||
// return 0;
|
||||
// }
|
||||
// catch (CanteraError) { handleError(); return -1; }
|
||||
// }
|
||||
|
||||
|
||||
status_t ctphase_report_(const integer* nth,
|
||||
char* buf, integer* show_thermo, ftnlen buflen)
|
||||
{
|
||||
|
|
@ -915,20 +1018,28 @@ extern "C" {
|
|||
|
||||
status_t ctgetcanteraerror_(char* buf, ftnlen buflen)
|
||||
{
|
||||
std::string e; // = "<no error>";
|
||||
//if (nErrors() > 0)
|
||||
e = lastErrorMessage();
|
||||
int n = std::min((int) e.size(), buflen-1);
|
||||
copy(e.begin(), e.begin() + n, buf);
|
||||
for (int nn = n; nn < buflen; nn++) {
|
||||
buf[nn] = ' ';
|
||||
try {
|
||||
std::string e; // = "<no error>";
|
||||
//if (nErrors() > 0)
|
||||
e = lastErrorMessage();
|
||||
int n = std::min((int) e.size(), buflen-1);
|
||||
copy(e.begin(), e.begin() + n, buf);
|
||||
for (int nn = n; nn < buflen; nn++) {
|
||||
buf[nn] = ' ';
|
||||
}
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t ctaddcanteradirectory_(integer* buflen, char* buf)
|
||||
{
|
||||
addDirectory(std::string(buf));
|
||||
try {
|
||||
addDirectory(std::string(buf));
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -936,42 +1047,44 @@ extern "C" {
|
|||
status_t ctbuildsolutionfromxml(char* src, integer* ixml, char* id,
|
||||
integer* ith, integer* ikin, ftnlen lensrc, ftnlen lenid)
|
||||
{
|
||||
try {
|
||||
XML_Node* root = 0;
|
||||
if (*ixml > 0) {
|
||||
root = _xml(ixml);
|
||||
}
|
||||
|
||||
XML_Node* root = 0;
|
||||
if (*ixml > 0) {
|
||||
root = _xml(ixml);
|
||||
}
|
||||
thermo_t* t = _fth(ith);
|
||||
kinetics_t* k = _fkin(ikin);
|
||||
|
||||
thermo_t* t = _fth(ith);
|
||||
kinetics_t* k = _fkin(ikin);
|
||||
|
||||
Kinetics& kin = *k;
|
||||
XML_Node* x, *r=0;
|
||||
if (root) {
|
||||
r = &root->root();
|
||||
}
|
||||
std::string srcS = f2string(src, lensrc);
|
||||
std::string idS = f2string(id, lenid);
|
||||
if (srcS != "") {
|
||||
x = get_XML_Node(srcS, r);
|
||||
} else {
|
||||
x = get_XML_Node(idS, r);
|
||||
}
|
||||
// x = find_XML(f2string(src, lensrc), r, f2string(id,lenid), "", "phase");
|
||||
if (!x) {
|
||||
return 0;
|
||||
}
|
||||
importPhase(*x, t);
|
||||
kin.addPhase(*t);
|
||||
kin.init();
|
||||
installReactionArrays(*x, kin, x->id());
|
||||
t->setState_TP(300.0, OneAtm);
|
||||
if (r) {
|
||||
if (&x->root() != &r->root()) {
|
||||
Kinetics& kin = *k;
|
||||
XML_Node* x, *r=0;
|
||||
if (root) {
|
||||
r = &root->root();
|
||||
}
|
||||
std::string srcS = f2string(src, lensrc);
|
||||
std::string idS = f2string(id, lenid);
|
||||
if (srcS != "") {
|
||||
x = get_XML_Node(srcS, r);
|
||||
} else {
|
||||
x = get_XML_Node(idS, r);
|
||||
}
|
||||
if (!x) {
|
||||
return 0;
|
||||
}
|
||||
importPhase(*x, t);
|
||||
kin.addPhase(*t);
|
||||
kin.init();
|
||||
installReactionArrays(*x, kin, x->id());
|
||||
t->setState_TP(300.0, OneAtm);
|
||||
if (r) {
|
||||
if (&x->root() != &r->root()) {
|
||||
delete &x->root();
|
||||
}
|
||||
} else {
|
||||
delete &x->root();
|
||||
}
|
||||
} else {
|
||||
delete &x->root();
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using namespace ctml;
|
|||
using namespace std;
|
||||
using Cantera::XML_Node;
|
||||
using Cantera::CanteraError;
|
||||
using Cantera::handleAllExceptions;
|
||||
|
||||
#include "clib/Cabinet.h"
|
||||
|
||||
|
|
@ -27,25 +28,23 @@ inline XML_Node* _xml(const integer* i)
|
|||
return &XmlCabinet::item(*i);
|
||||
}
|
||||
|
||||
static void handleError(CanteraError& err)
|
||||
{
|
||||
err.save();
|
||||
Cantera::error(Cantera::lastErrorMessage());
|
||||
}
|
||||
|
||||
std::string f2string(const char* s, ftnlen n);
|
||||
|
||||
extern "C" {
|
||||
|
||||
integer fxml_new_(const char* name, ftnlen namelen)
|
||||
{
|
||||
XML_Node* x;
|
||||
if (!name) {
|
||||
x = new XML_Node;
|
||||
} else {
|
||||
x = new XML_Node(f2string(name, namelen), 0);
|
||||
try {
|
||||
XML_Node* x;
|
||||
if (!name) {
|
||||
x = new XML_Node;
|
||||
} else {
|
||||
x = new XML_Node(f2string(name, namelen), 0);
|
||||
}
|
||||
return XmlCabinet::add(x);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return XmlCabinet::add(x);
|
||||
}
|
||||
|
||||
status_t fxml_get_xml_file_(const char* file, ftnlen filelen)
|
||||
|
|
@ -54,9 +53,8 @@ extern "C" {
|
|||
XML_Node* x = Cantera::get_XML_File(f2string(file, filelen));
|
||||
int ix = XmlCabinet::add(x);
|
||||
return ix;
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
return -1;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,36 +64,51 @@ extern "C" {
|
|||
XmlCabinet::clear();
|
||||
Cantera::close_XML_File("all");
|
||||
return 0;
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
return -1;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t fxml_del_(const integer* i)
|
||||
{
|
||||
XmlCabinet::del(*i);
|
||||
return 0;
|
||||
try {
|
||||
XmlCabinet::del(*i);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t fxml_removechild_(const integer* i, const integer* j)
|
||||
{
|
||||
_xml(i)->removeChild(_xml(j));
|
||||
return 0;
|
||||
try {
|
||||
_xml(i)->removeChild(_xml(j));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t fxml_copy_(const integer* i)
|
||||
{
|
||||
return XmlCabinet::newCopy(*i);
|
||||
try {
|
||||
return XmlCabinet::newCopy(*i);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t fxml_assign_(const integer* i, const integer* j)
|
||||
{
|
||||
return XmlCabinet::assign(*i,*j);
|
||||
try {
|
||||
return XmlCabinet::assign(*i,*j);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
}
|
||||
|
||||
status_t fxml_attrib_(const integer* i, const char* key,
|
||||
char* value, ftnlen keylen, ftnlen valuelen)
|
||||
status_t fxml_attrib_(const integer* i, const char* key, char* value,
|
||||
ftnlen keylen, ftnlen valuelen)
|
||||
{
|
||||
try {
|
||||
std::string ky = f2string(key, keylen);
|
||||
|
|
@ -106,35 +119,35 @@ extern "C" {
|
|||
} else
|
||||
throw CanteraError("fxml_attrib","node "
|
||||
" has no attribute '"+ky+"'");
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t fxml_addattrib_(const integer* i,
|
||||
const char* key, const char* value, ftnlen keylen, ftnlen valuelen)
|
||||
status_t 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& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t fxml_addcomment_(const integer* i, const char* comment,
|
||||
ftnlen commentlen)
|
||||
ftnlen commentlen)
|
||||
{
|
||||
try {
|
||||
std::string c = f2string(comment, commentlen);
|
||||
XML_Node& node = *_xml(i);
|
||||
node.addComment(c);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -145,8 +158,8 @@ extern "C" {
|
|||
XML_Node& node = *_xml(i);
|
||||
const std::string v = node.name();
|
||||
strncpy(tag, v.c_str(), taglen);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -157,8 +170,8 @@ extern "C" {
|
|||
XML_Node& node = *_xml(i);
|
||||
const std::string v = node.value();
|
||||
strncpy(value, v.c_str(), valuelen);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -169,10 +182,9 @@ extern "C" {
|
|||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.child(f2string(loc, loclen));
|
||||
return XmlCabinet::add(&c);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t fxml_child_bynumber_(const integer* i, const integer* m)
|
||||
|
|
@ -181,8 +193,8 @@ extern "C" {
|
|||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.child(*m);
|
||||
return XmlCabinet::add(&c);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -197,8 +209,8 @@ extern "C" {
|
|||
} else {
|
||||
throw CanteraError("fxml_find_id","id not found: "+f2string(id, idlen));
|
||||
}
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -213,8 +225,8 @@ extern "C" {
|
|||
} else
|
||||
throw CanteraError("fxml_findByName","name "+f2string(nm, nmlen)
|
||||
+" not found");
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -224,22 +236,22 @@ extern "C" {
|
|||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
return node.nChildren();
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t fxml_addchild_(const integer* i, const char* name,
|
||||
const char* value, ftnlen namelen, ftnlen valuelen)
|
||||
const char* value, ftnlen namelen, ftnlen valuelen)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
XML_Node& c = node.addChild(f2string(name, namelen),
|
||||
f2string(value,valuelen));
|
||||
return XmlCabinet::add(&c);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -251,8 +263,8 @@ extern "C" {
|
|||
XML_Node& chld = *_xml(j);
|
||||
XML_Node& c = node.addChild(chld);
|
||||
return XmlCabinet::add(&c);
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -270,14 +282,14 @@ extern "C" {
|
|||
"file "+f2string(file, filelen)+" not found.");
|
||||
}
|
||||
return 0;
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t ctml_getfloatarray_(const integer* i, const integer* n,
|
||||
doublereal* data, const integer* iconvert)
|
||||
doublereal* data, const integer* iconvert)
|
||||
{
|
||||
try {
|
||||
XML_Node& node = *_xml(i);
|
||||
|
|
@ -299,8 +311,8 @@ extern "C" {
|
|||
data[i] = v[i];
|
||||
}
|
||||
//n = nv;
|
||||
} catch (CanteraError& err) {
|
||||
handleError(err);
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue