From ef8f30c7f7cab1a8f24347f0466e9e9bef4b9b74 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Fri, 15 Aug 2003 15:45:42 +0000 Subject: [PATCH] *** empty log message *** --- Cantera/clib/src/ct.cpp | 8 +-- Cantera/clib/src/ct.h | 4 +- Cantera/matlab/cantera/@Kinetics/Kinetics.m | 59 +++++++++++++------ .../cantera/@Kinetics/private/kinetics_get.m | 6 +- .../matlab/cantera/private/ctfunctions.cpp | 9 ++- .../cantera/private/kineticsmethods.cpp | 6 +- Cantera/python/src/ctfuncs.cpp | 10 ++-- Cantera/python/src/methods.h | 2 +- Cantera/src/converters/ck2ct.cpp | 40 ++++++------- Cantera/src/importCTML.cpp | 4 +- data/inputs/mkxml | 14 ++--- 11 files changed, 95 insertions(+), 67 deletions(-) diff --git a/Cantera/clib/src/ct.cpp b/Cantera/clib/src/ct.cpp index ae9f65d65..062e08f91 100755 --- a/Cantera/clib/src/ct.cpp +++ b/Cantera/clib/src/ct.cpp @@ -19,7 +19,7 @@ #include "transport/TransportFactory.h" #include "ctml.h" #include "importCTML.h" -#include "converters/ck2ctml.h" +#include "converters/ck2ct.h" #include "Storage.h" #include "Cabinet.h" #include "InterfaceKinetics.h" @@ -895,9 +895,9 @@ extern "C" { } - int DLL_EXPORT ck_to_ctml(char* in_file, char* db_file, - char* tr_file, char* out_file, char* id_tag) { - return convert_ck(in_file, db_file, tr_file, out_file, id_tag); + int DLL_EXPORT ck_to_cti(char* in_file, char* db_file, + char* tr_file, char* id_tag) { + return pip::convert_ck(in_file, db_file, tr_file, id_tag); } } diff --git a/Cantera/clib/src/ct.h b/Cantera/clib/src/ct.h index 5cc907e36..43f691ac5 100755 --- a/Cantera/clib/src/ct.h +++ b/Cantera/clib/src/ct.h @@ -130,8 +130,8 @@ extern "C" { int DLL_IMPORT buildSolutionFromXML(char* src, int ixml, char* id, int ith, int ikin); - int DLL_IMPORT ck_to_ctml(char* in_file, char* db_file, - char* tr_file, char* out_file, char* id_tag); + int DLL_IMPORT ck_to_cti(char* in_file, char* db_file, + char* tr_file, char* id_tag); } #endif diff --git a/Cantera/matlab/cantera/@Kinetics/Kinetics.m b/Cantera/matlab/cantera/@Kinetics/Kinetics.m index 7b73ee38d..109643900 100755 --- a/Cantera/matlab/cantera/@Kinetics/Kinetics.m +++ b/Cantera/matlab/cantera/@Kinetics/Kinetics.m @@ -1,4 +1,5 @@ -function k = Kinetics(r, ph, neighbor1, neighbor2) +function k = Kinetics(r, ph, neighbor1, neighbor2, neighbor3, neighbor4) +% % KINETICS - Kinetics class constructor. % % Class Kinetics represents kinetics managers, which are classes @@ -6,28 +7,50 @@ function k = Kinetics(r, ph, neighbor1, neighbor2) % attributes are specified in a CTML file. % % + +% indices for bulk phases in a heterogeneous mechanism. +% initialize < 0 so that bulk phases will not be included. +ineighbor1 = -1; +ineighbor2 = -1; +ineighbor3 = -1; +ineighbor4 = -1; + if nargin == 1 if isa(r,'Kinetics') % create a copy k = r; return - end -elseif nargin == 2 - if isa(r,'XML_Node') - k.owner = 1; - i = hndl(r); - iph = hndl(ph); - ineighbor1 = -1; - ineighbor2 = -1; - k.id = kinetics_get(i,0,iph,ineighbor1,ineighbor2); - if k.id < 0 - error(geterr); - end else - k.owner = 0; - k.id = r; + error('wrong number of arguments') end - k = class(k,'Kinetics'); -else - error('wrong number of arguments'); end + + +if ~isa(r,'XML_Node') + error('first argument must be an XML_Node object') +end + +k.owner = 1; +ixml = hndl(r); + +iphase = hndl(ph) +if nargin > 2 + ineighbor1 = hndl(neighbor1) + if nargin > 3 + ineighbor2 = hndl(neighbor2) + if nargin > 4 + ineighbor3 = hndl(neighbor3) + if nargin > 5 + ineighbor4 = hndl(neighbor4) + end + end + end +end +k.id = kinetics_get(ixml,0,iphase,ineighbor1,ineighbor2,ineighbor3, ... + ineighbor4); +if k.id < 0 + error(geterr); +end + +k = class(k,'Kinetics'); + diff --git a/Cantera/matlab/cantera/@Kinetics/private/kinetics_get.m b/Cantera/matlab/cantera/@Kinetics/private/kinetics_get.m index 933dce0f0..72c8d54d6 100644 --- a/Cantera/matlab/cantera/@Kinetics/private/kinetics_get.m +++ b/Cantera/matlab/cantera/@Kinetics/private/kinetics_get.m @@ -1,4 +1,4 @@ -function v = kinetics_get(n, job, a, b, c, d) +function v = kinetics_get(n, job, a, b, c, d, e, f) % KINETICS_GET - get kinetics attributes % if nargin == 2 @@ -11,4 +11,8 @@ elseif nargin == 5 v = ctmethods(40, n, job, a, b, c); elseif nargin == 6 v = ctmethods(40, n, job, a, b, c, d); +elseif nargin == 7 + v = ctmethods(40, n, job, a, b, c, d, e); +elseif nargin == 8 + v = ctmethods(40, n, job, a, b, c, d, e, f); end \ No newline at end of file diff --git a/Cantera/matlab/cantera/private/ctfunctions.cpp b/Cantera/matlab/cantera/private/ctfunctions.cpp index db96919f0..c6c080754 100644 --- a/Cantera/matlab/cantera/private/ctfunctions.cpp +++ b/Cantera/matlab/cantera/private/ctfunctions.cpp @@ -25,19 +25,18 @@ void ctfunctions( int nlhs, mxArray *plhs[], switch (job) { - // convert CK file to CTML + // convert CK file to CTI case 1: - if (nrhs < 7) { + if (nrhs < 6) { mexErrMsgTxt("Wrong number of inputs."); return; } infile = getString(prhs[2]); dbfile = getString(prhs[3]); trfile = getString(prhs[4]); - outfile = getString(prhs[5]); - idtag = getString(prhs[6]); + idtag = getString(prhs[5]); - iok = ck_to_ctml(infile, dbfile, trfile, outfile, idtag); + iok = ck_to_cti(infile, dbfile, trfile, idtag); break; // get Cantera error diff --git a/Cantera/matlab/cantera/private/kineticsmethods.cpp b/Cantera/matlab/cantera/private/kineticsmethods.cpp index 28760d6b1..71fe60cf1 100644 --- a/Cantera/matlab/cantera/private/kineticsmethods.cpp +++ b/Cantera/matlab/cantera/private/kineticsmethods.cpp @@ -17,12 +17,14 @@ void kineticsmethods( int nlhs, mxArray *plhs[], // construct a new instance if (job == 0) { - checkNArgs(6, nrhs); + checkNArgs(8, nrhs); int root = getInt(prhs[1]); int iph = getInt(prhs[3]); int in1 = getInt(prhs[4]); int in2 = getInt(prhs[5]); - vv = newKineticsFromXML(root, iph, in1, in2); + int in3 = getInt(prhs[6]); + int in4 = getInt(prhs[7]); + vv = newKineticsFromXML(root, iph, in1, in2, in3, in4); plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); double *h = mxGetPr(plhs[0]); *h = vv; diff --git a/Cantera/python/src/ctfuncs.cpp b/Cantera/python/src/ctfuncs.cpp index 766bd7a30..9cb1cf38c 100644 --- a/Cantera/python/src/ctfuncs.cpp +++ b/Cantera/python/src/ctfuncs.cpp @@ -48,14 +48,14 @@ ct_readlog(PyObject *self, PyObject *args) } static PyObject * -ct_ck2ctml(PyObject *self, PyObject *args) +ct_ck2cti(PyObject *self, PyObject *args) { int iok; - char *infile, *thermo, *tran, *outfile, *idtag; - if (!PyArg_ParseTuple(args, "sssss:ck2ctml", &infile, - &thermo, &tran, &outfile, &idtag)) + char *infile, *thermo, *tran, *idtag; + if (!PyArg_ParseTuple(args, "ssss:ck2cti", &infile, + &thermo, &tran, &idtag)) return NULL; - iok = ck_to_ctml(infile, thermo, tran, outfile, idtag); + iok = ck_to_cti(infile, thermo, tran, idtag); if (iok == -1) { return reportCanteraError();} return Py_BuildValue("i",iok); } diff --git a/Cantera/python/src/methods.h b/Cantera/python/src/methods.h index 79066ccda..63e924d9f 100644 --- a/Cantera/python/src/methods.h +++ b/Cantera/python/src/methods.h @@ -83,7 +83,7 @@ static PyMethodDef ct_methods[] = { {"get_Cantera_Error", ct_get_cantera_error, METH_VARARGS}, {"ct_print", ct_print, METH_VARARGS}, {"readlog", ct_readlog, METH_VARARGS}, - {"ck2ctml", ct_ck2ctml, METH_VARARGS}, + {"ck2cti", ct_ck2cti, METH_VARARGS}, {"buildSolutionFromXML", ct_buildSolutionFromXML, METH_VARARGS}, {"Flow", py_flow_new, METH_VARARGS}, diff --git a/Cantera/src/converters/ck2ct.cpp b/Cantera/src/converters/ck2ct.cpp index fb7ef4690..304b53045 100644 --- a/Cantera/src/converters/ck2ct.cpp +++ b/Cantera/src/converters/ck2ct.cpp @@ -312,11 +312,11 @@ namespace pip { //cout << "dataset(\"" << idtag << "\")" << endl; - cout << "\n\n"; - writeline(); - cout << "#\n# The default units. These will be used for dimensional quantities" << endl - << "# with unspecified units." << endl; - writeline(); + // cout << "\n\n"; + //writeline(); + //cout << "#\n# The default units. These will be used for dimensional quantities" << endl + // << "# with unspecified units." << endl; + //writeline(); cout << "units(length = \"cm\", time = \"s\", quantity = \"mol\", "; string e_unit; @@ -335,15 +335,15 @@ namespace pip { e_unit = "eV"; cout << "act_energy = " << "\"" << e_unit << "\")\n\n"; - cout << "\n\n\n"; - writeline(); - cout << "#\n# The phase definition. This specifies an ideal gas mixture that" << endl - << "# includes all species and reactions defined in this file." - << "\n#\n"; - writeline(); + //cout << "\n\n\n"; + //writeline(); + //cout << "#\n# The phase definition. This specifies an ideal gas mixture that" << endl + // << "# includes all species and reactions defined in this file." + // << "\n#\n"; + //writeline(); - printf("ideal_gas(name = \"%s\",\n",idtag.c_str()); + printf("\nideal_gas(name = \"%s\",\n",idtag.c_str()); string enames; int nel = r.elements.size(); @@ -372,7 +372,7 @@ namespace pip { cout << "\n\n\n"; writeline(); - cout << "#\n# Species data \n#\n"; + cout << "# Species data \n"; writeline(); for (i = 0; i < nsp; i++) { @@ -381,7 +381,7 @@ namespace pip { cout << "\n\n\n"; writeline(); - cout << "#\n# Reaction data \n#\n"; + cout << "# Reaction data \n"; writeline(); @@ -422,6 +422,7 @@ namespace pip { int convert_ck(const char* in_file, const char* db_file, const char* tr_file, const char* id_tag) { ckr::CKReader r; + r.validate = true; //int i=1; @@ -441,19 +442,18 @@ namespace pip { try { - logfile = "ck2ct.log"; + logfile = "ck2cti.log"; if (!r.read(infile, dbfile, logfile)) { throw CanteraError("convert_ck", "error encountered in input file " + string(infile) - + "\nsee file ck2ct.log for more information.\n"); + + "\nsee file ck2cti.log for more information.\n"); } - cout << "#" << endl; cout << "# Generated from file " - << infile << "\n# by ck2ct on " << asctime(newtime) << "#\n" << endl; + << infile << "\n# by ck2cti on " << asctime(newtime) << "#" << endl; if (trfile != "") { - cout << "# Transport data from file "+trfile+"." << endl; + cout << "# Transport data from file "+trfile+".\n" << endl; getTransportData(trfile); } ck2ct(idtag, r); @@ -461,10 +461,8 @@ namespace pip { catch (CanteraError) { return -1; } - return 0; } - } diff --git a/Cantera/src/importCTML.cpp b/Cantera/src/importCTML.cpp index 44bca5cce..a88a60f93 100755 --- a/Cantera/src/importCTML.cpp +++ b/Cantera/src/importCTML.cpp @@ -1132,6 +1132,7 @@ next: bool phase_ok; string phase_id; + string msg = ""; for (int n = 0; n < np; n++) { phase_id = phase_ids[n]; phase_ok = false; @@ -1148,10 +1149,11 @@ next: kin.addPhase(*th[m]); } } + msg += " "+th[m]->id(); } if (!phase_ok) { throw CanteraError("importKinetics", - "phase "+phase_id+" not found."); + "phase "+phase_id+" not found. Supplied phases are:"+msg); } } diff --git a/data/inputs/mkxml b/data/inputs/mkxml index 6c322f104..d5b50ad1a 100755 --- a/data/inputs/mkxml +++ b/data/inputs/mkxml @@ -1,9 +1,9 @@ -#!/usr/bin/env bash - -../../bin/ck2ctml -i gri30.inp -id gri30 -o gri30_data.xml -tr ../transport/gri30_tran.dat > gri30.in -../../bin/ck2ctml -i air.inp -o air.xml -t gri30.inp -id air -tr ../transport/gri30_tran.dat > air.in -../../bin/ck2ctml -i h2o2.inp -o h2o2.xml -id ohmech -tr ../transport/gri30_tran.dat > h2o2.in -../../bin/ck2ctml -i silane.inp -o silane.xml -id silane > silane.in -../../bin/ck2ctml -i argon.inp -o argon.xml -id argon -t gri30.inp -tr ../transport/gri30_tran.dat > argon.in +# run ck2cti to convert Chemkin-format files to Cantera format +# +../../bin/ck2cti -i gri30.inp -id gri30 -tr ../transport/gri30_tran.dat > gri30.cti +../../bin/ck2cti -i air.inp -t gri30.inp -id air -tr ../transport/gri30_tran.dat > air.cti +../../bin/ck2cti -i h2o2.inp -id ohmech -tr ../transport/gri30_tran.dat > h2o2.cti +../../bin/ck2cti -i silane.inp -id silane > silane.cti +../../bin/ck2cti -i argon.inp -id argon -t gri30.inp -tr ../transport/gri30_tran.dat > argon.cti rm *.xml python ./makexml.py