Cantera  2.3.0
ctml.h
Go to the documentation of this file.
1 /**
2  * @file ctml.h
3  * CTML ("Cantera Markup Language") is the variant of XML that Cantera uses
4  * to store data. These functions read and write it.
5  * (see \ref inputfiles and importCTML, ck2ctml)
6  */
7 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
11 #ifndef CT_CTML_H
12 #define CT_CTML_H
13 
14 #include "ct_defs.h"
15 #include "xml.h"
16 
17 namespace Cantera
18 {
19 class Array2D;
20 
21 //! const Specifying the CTML version number
22 /*!
23  * @deprecated Unused. To be removed after Cantera 2.3.
24  */
25 const std::string CTML_Version = "1.4.1";
26 
27 //! This function adds a child node with the name, "integer", with a value
28 //! consisting of a single integer
29 /*!
30  * This function will add a child node to the current XML node, with the name
31  * "integer". It will have a title attribute, and the body of the XML node will
32  * be filled out with a single integer
33  *
34  * Example:
35  *
36  * @code
37  * const XML_Node &node;
38  * std::string titleString = "maxIterations";
39  * int value = 1000;
40  * std::string typeString = "optional";
41  * std::string units = "";
42  * addInteger(node, titleString, value, typeString, units);
43  * @endcode
44  *
45  * Creates the following the snippet in the XML file:
46  *
47  * <parentNode>
48  * <integer title="maxIterations" type="optional">
49  * 100
50  * <\integer>
51  * <\parentNode>
52  *
53  * @param node reference to the XML_Node object of the parent XML element
54  * @param titleString String name of the title attribute
55  * @param value Value - single integer
56  * @param unitsString String name of the Units attribute. The default is to
57  * have an empty string.
58  * @param typeString String type. This is an optional parameter. The default
59  * is to have an empty string.
60  * @deprecated Unused. to be removed after Cantera 2.3.
61  */
62 void addInteger(XML_Node& node, const std::string& titleString,
63  const int value, const std::string& unitsString="",
64  const std::string& typeString="");
65 
66 //! This function adds a child node with the name, "float", with a value
67 //! consisting of a single floating point number
68 /*!
69  * This function will add a child node to the current XML node, with the name
70  * "float". It will have a title attribute, and the body of the XML node will be
71  * filled out with a single float
72  *
73  * Example:
74  *
75  * @code
76  * const XML_Node &node;
77  * std::string titleString = "activationEnergy";
78  * doublereal value = 50.3;
79  * doublereal maxval = 1.0E3;
80  * doublereal minval = 0.0;
81  * std::string typeString = "optional";
82  * std::string unitsString = "kcal/gmol";
83  * addFloat(node, titleString, value, unitsString, typeString, minval, maxval);
84  * @endcode
85  *
86  * Creates the following the snippet in the XML file:
87  *
88  * <parentNode>
89  * <float title="activationEnergy" type="optional" units="kcal/gmol" min="0.0" max="1.0E3">
90  * 50.3
91  * <\float>
92  * <\parentNode>
93  *
94  * @param node reference to the XML_Node object of the parent XML element
95  * @param titleString String name of the title attribute
96  * @param value Value - single integer
97  * @param unitsString String name of the Units attribute. The default is to
98  * have an empty string.
99  * @param typeString String type. This is an optional parameter. The default
100  * is to have an empty string.
101  * @param minval Minimum allowed value of the float. The default is the
102  * special double, Undef, which means to ignore the entry.
103  * @param maxval Maximum allowed value of the float. The default is the
104  * special double, Undef, which means to ignore the entry.
105  */
106 void addFloat(XML_Node& node, const std::string& titleString,
107  const doublereal value, const std::string& unitsString="",
108  const std::string& typeString="", const doublereal minval=Undef,
109  const doublereal maxval=Undef);
110 
111 //! This function adds a child node with the name, "floatArray", with a value
112 //! consisting of a comma separated list of floats
113 /*!
114  * This function will add a child node to the current XML node, with the name
115  * "floatArray". It will have a title attribute, and the body of the XML node
116  * will be filled out with a comma separated list of doublereals.
117  *
118  * Example:
119  *
120  * @code
121  * const XML_Node &node;
122  * std::string titleString = "additionalTemperatures";
123  * int n = 3;
124  * int Tcases[3] = [273.15, 298.15, 373.15];
125  * std::string typeString = "optional";
126  * std::string units = "Kelvin";
127  * addFloatArray(node, titleString, n, &cases[0], typeString, units);
128  * @endcode
129  *
130  * Creates the following the snippet in the XML file:
131  *
132  * <parentNode>
133  * <floatArray title="additionalTemperatures" type="optional" units="Kelvin">
134  * 273.15, 298.15, 373.15
135  * <\floatArray>
136  * <\parentNode>
137  *
138  * @param node reference to the XML_Node object of the parent XML element
139  * @param titleString String name of the title attribute
140  * @param n Length of the doubles vector.
141  * @param values Pointer to a vector of doubles
142  * @param unitsString String name of the Units attribute. This is an optional
143  * parameter. The default is to have an empty string.
144  * @param typeString String type. This is an optional parameter. The default
145  * is to have an empty string.
146  * @param minval Minimum allowed value of the int. This is an optional
147  * parameter. The default is the special double, Undef,
148  * which means to ignore the entry.
149  * @param maxval Maximum allowed value of the int. This is an optional
150  * parameter. The default is the special double,
151  * Undef, which means to ignore the entry.
152  */
153 void addFloatArray(XML_Node& node, const std::string& titleString,
154  const size_t n, const doublereal* const values,
155  const std::string& unitsString="", const std::string& typeString="",
156  const doublereal minval=Undef,
157  const doublereal maxval=Undef);
158 
159 //! This function adds a child node with the name given by the first parameter
160 //! with a value consisting of a comma separated list of floats
161 /*!
162  * This function will add a child node to the current XML node, with the name
163  * given in the list. It will have a title attribute, and the body of the XML
164  * node will be filled out with a comma separated list of integers
165  *
166  * Example:
167  *
168  * @code
169  * const XML_Node &node;
170  * std::string titleString = "additionalTemperatures";
171  * int n = 3;
172  * int Tcases[3] = [273.15, 298.15, 373.15];
173  * std::string typeString = "optional";
174  * std::string units = "Kelvin";
175  * addNamedFloatArray(node, titleString, n, &cases[0], typeString, units);
176  * @endcode
177  *
178  * Creates the following the snippet in the XML file:
179  *
180  * <parentNode>
181  * <additionalTemperatures type="optional" vtype="floatArray" size = "3" units="Kelvin">
182  * 273.15, 298.15, 373.15
183  * <\additionalTemperatures>
184  * <\parentNode>
185  *
186  * @param parentNode reference to the XML_Node object of the parent XML element
187  * @param name Name of the XML node
188  * @param n Length of the doubles vector.
189  * @param vals Pointer to a vector of doubles
190  * @param units String name of the Units attribute. This is an optional
191  * parameter. The default is to have an empty string.
192  * @param type String type. This is an optional parameter. The default
193  * is to have an empty string.
194  * @param minval Minimum allowed value of the int. This is an optional
195  * parameter. The default is the special double,
196  * Undef, which means to ignore the entry.
197  * @param maxval Maximum allowed value of the int. This is an optional
198  * parameter. The default is the special double,
199  * Undef, which means to ignore the entry.
200  */
201 void addNamedFloatArray(XML_Node& parentNode, const std::string& name, const size_t n,
202  const doublereal* const vals, const std::string units = "",
203  const std::string type = "",
204  const doublereal minval=Undef,
205  const doublereal maxval=Undef);
206 
207 //! This function adds a child node with the name string with a string value
208 //! to the current node
209 /*!
210  * This function will add a child node to the current XML node, with the name
211  * "string". It will have a title attribute, and the body of the XML node will
212  * be filled out with the valueString argument verbatim.
213  *
214  * Example:
215  *
216  * @code
217  * const XML_Node &node;
218  * addString(node, "titleString", "valueString", "typeString");
219  * @endcode
220  *
221  * Creates the following the snippet in the XML file:
222  *
223  * <string title="titleString" type="typeString">
224  * valueString
225  * <\string>
226  *
227  * @param node reference to the XML_Node object of the parent XML element
228  * @param valueString Value string to be used in the new XML node.
229  * @param titleString String name of the title attribute
230  * @param typeString String type. This is an optional parameter.
231  */
232 void addString(XML_Node& node, const std::string& titleString,
233  const std::string& valueString, const std::string& typeString="");
234 
235 //! This function reads the current node or a child node of the current node
236 //! with the default name, "floatArray", with a value field
237 //! consisting of a comma separated list of floats
238 /*!
239  * This function will read either the current XML node or a child node to the
240  * current XML node, with the name "floatArray". It will have a title
241  * attribute, and the body of the XML node will be filled out with a comma
242  * separated list of doublereals. Get an array of floats from the XML Node.
243  * The argument field is assumed to consist of an arbitrary number of comma
244  * separated floats, with an arbitrary amount of white space separating each
245  * field. If the node array has an units attribute field, then the units are
246  * used to convert the floats, iff convert is true.
247  *
248  * Example:
249  *
250  * @code
251  * const XML_Node &State_XMLNode;
252  * vector_fp v;
253  * bool convert = true;
254  * unitsString = "";
255  * nodeName="floatArray";
256  * getFloatArray(State_XMLNode, v, convert, unitsString, nodeName);
257  * @endcode
258  *
259  * reads the corresponding XML file:
260  *
261  * <state>
262  * <floatArray units="m3"> 32.4, 1, 100. <\floatArray>
263  * <\state>
264  *
265  * and will produce the vector:
266  *
267  * v[0] = 32.4
268  * v[1] = 1.0
269  * v[2] = 100.
270  *
271  * @param node XML parent node of the floatArray
272  * @param v Output vector of floats containing the floatArray information.
273  * @param convert Conversion to SI is carried out if this boolean is
274  * True. The default is true.
275  * @param unitsString String name of the type attribute. This is an optional
276  * parameter. The default is to have an empty string. The
277  * only string that is recognized is actEnergy. Anything
278  * else has no effect. This affects what units converter is
279  * used.
280  * @param nodeName XML Name of the XML node to read. The default value for
281  * the node name is floatArray
282  * @returns the number of floats read into v.
283  */
284 size_t getFloatArray(const XML_Node& node, vector_fp & v,
285  const bool convert=true, const std::string& unitsString="",
286  const std::string& nodeName = "floatArray");
287 
288 //! This function interprets the value portion of an XML element as a string. It
289 //! then separates the string up into tokens according to the location of white
290 //! space.
291 /*!
292  * The separate tokens are returned in the string vector
293  *
294  * @param node Node to get the value from
295  * @param v Output vector containing the string tokens
296  */
297 void getStringArray(const XML_Node& node, std::vector<std::string>& v);
298 
299 //! This routine is used to interpret the value portions of XML
300 //! elements that contain colon separated pairs.
301 /*!
302  * These are used, for example, in describing the element composition of
303  * species.
304  *
305  * <atomArray> H:4 C:1 <atomArray>
306  *
307  * The string is first separated into a string vector according to the location
308  * of white space. Then each string is again separated into two parts according
309  * to the location of a colon in the string. The first part of the string is
310  * used as the key, while the second part of the string is used as the value, in
311  * the return map. It is an error to not find a colon in each string pair.
312  *
313  * @param node Current node
314  * @param m Output Map containing the pairs of values found in the XML Node
315  */
316 void getMap(const XML_Node& node, std::map<std::string, std::string>& m);
317 
318 //! This function interprets the value portion of an XML element
319 //! as a series of "Pairs" separated by white space.
320 /*!
321  * Each pair consists of non-whitespace characters. The first ":" found in the
322  * pair string is used to separate the string into two parts. The first part
323  * is called the "key" The second part is called the "val". String vectors of
324  * key[i] and val[i] are returned in the argument list. Warning: No spaces are
325  * allowed in each pair. Quotes get included as part of the string. Example:
326  *
327  * <xmlNode>
328  * red:112 blue:34
329  * green:banana
330  * </xmlNode>
331  *
332  * Returns:
333  *
334  * index | key | val
335  * ----- | ------- | ---------
336  * 0 | "red" | "112"
337  * 1 | "blue" | "34"
338  * 2 | "green" | "banana"
339  *
340  * @param node XML Node
341  * @param key Vector of keys for each entry
342  * @param val Vector of values for each entry
343  * @returns the number of pairs found
344  */
345 int getPairs(const XML_Node& node, std::vector<std::string>& key,
346  std::vector<std::string>& val);
347 
348 //! This function interprets the value portion of an XML element as a series of
349 //! "Matrix ids and entries" separated by white space.
350 /*!
351  * Each pair consists of non-whitespace characters. The first two ":" found in
352  * the pair string is used to separate the string into three parts. The first
353  * part is called the first key. The second part is the second key. Both parts
354  * must match an entry in the keyString1 and keyString2, respectively, in
355  * order to provide a location to place the object in the matrix. The third
356  * part is called the value. It is expected to be a double. It is translated
357  * into a double and placed into the correct location in the matrix.
358  *
359  * Warning: No spaces are allowed in each triplet. Quotes are part of the
360  * string.
361  *
362  * Example:
363  * keyString = red, blue, black, green
364  *
365  * <xmlNode>
366  * red:green:112
367  * blue:black:3.3E-23
368  * </xmlNode>
369  *
370  * Returns:
371  *
372  * retnValues(0, 3) = 112
373  * retnValues(1, 2) = 3.3E-23
374  *
375  * @param node XML Node containing the information for the matrix
376  * @param keyStringRow Key string for the row
377  * @param keyStringCol Key string for the column entries
378  * @param returnValues Return Matrix.
379  * @param convert If this is true, and if the node has a units attribute,
380  * then conversion to SI units is carried out. Default is
381  * true.
382  * @param matrixSymmetric If true entries are made so that the matrix is always
383  * symmetric. Default is false.
384  */
385 void getMatrixValues(const XML_Node& node,
386  const std::vector<std::string>& keyStringRow,
387  const std::vector<std::string>& keyStringCol,
388  Array2D& returnValues, const bool convert = true,
389  const bool matrixSymmetric = false);
390 
391 //! Get a vector of integer values from a child element.
392 /*!
393  * Returns a std::map containing a keyed values for child XML_Nodes of the
394  * current node with the name, "integer". In the keyed mapping there will be a
395  * list of titles vs. values for all of the XML nodes. The integer XML_nodes
396  * are expected to be in a particular form, with one value per XML_node.
397  *
398  * Example:
399  * @code
400  * const XML_Node &State_XMLNode;
401  * std::map<std::string, integer> v;
402  * getInteger(State_XMLNode, v);
403  * @endcode
404  * reads the corresponding XML file:
405  *
406  * <state>
407  * <integer title="i1"> 1 <\integer>
408  * <integer title="i2"> 2 <\integer>
409  * <integer title="i3"> 3 <\integer>
410  * <\state>
411  *
412  * Will produce the mapping:
413  *
414  * v["i1"] = 1
415  * v["i2"] = 2
416  * v["i3"] = 3
417  *
418  * @param node Current XML node to get the values from
419  * @param v Output map of the results.
420  */
421 void getIntegers(const XML_Node& node, std::map<std::string,int>& v);
422 
423 //! Get a floating-point value from a child element.
424 /*!
425  * Returns a doublereal value for the child named 'name' of element 'parent'.
426  * If 'type' is supplied and matches a known unit type, unit conversion to SI
427  * will be done if the child element has an attribute 'units'.
428  *
429  * Note, it's an error for the child element not to exist.
430  *
431  * Example:
432  *
433  * @code
434  * const XML_Node &State_XMLNode;
435  * doublereal pres = OneAtm;
436  * if (state_XMLNode.hasChild("pressure")) {
437  * pres = getFloat(State_XMLNode, "pressure", "toSI");
438  * }
439  * @endcode
440  *
441  * reads the corresponding XML file:
442  *
443  * <state>
444  * <pressure units="Pa"> 101325.0 </pressure>
445  * <\state>
446  *
447  * @param parent reference to the XML_Node object of the parent XML element
448  * @param name Name of the XML child element
449  * @param type String type. Currently known types are "toSI" and "actEnergy",
450  * and "" , for no conversion. The default value is "",
451  * which implies that no conversion is allowed.
452  */
453 doublereal getFloat(const XML_Node& parent, const std::string& name,
454  const std::string& type="");
455 
456 //! Get a floating-point value from the current XML element
457 /*!
458  * Returns a doublereal value from the current element. If 'type' is supplied
459  * and matches a known unit type, unit conversion to SI will be done if the
460  * child element has an attribute 'units'.
461  *
462  * Note, it's an error for the child element not to exist.
463  *
464  * Example:
465  *
466  * @code
467  * const XML_Node &State_XMLNode;
468  * doublereal pres = OneAtm;
469  * if (state_XMLNode.hasChild("pressure")) {
470  * XML_Node *pres_XMLNode = State_XMLNode.getChild("pressure");
471  * pres = getFloatCurrent(pres_XMLNode, "toSI");
472  * }
473  * @endcode
474  *
475  * Reads the corresponding XML file:
476  *
477  * <state>
478  * <pressure units="Pa"> 101325.0 </pressure>
479  * <\state>
480  *
481  * @param currXML reference to the current XML_Node object
482  * @param type String type. Currently known types are "toSI" and "actEnergy",
483  * and "" , for no conversion. The default value is "",
484  * which implies that no conversion is allowed.
485  */
486 doublereal getFloatCurrent(const XML_Node& currXML, const std::string& type="");
487 
488 //! Get an optional floating-point value from a child element.
489 /*!
490  * Returns a doublereal value for the child named 'name' of element 'parent'.
491  * If 'type' is supplied and matches a known unit type, unit conversion to SI
492  * will be done if the child element has an attribute 'units'.
493  *
494  * Example:
495  *
496  * @code
497  * const XML_Node &State_XMLNode;
498  * doublereal pres = OneAtm;
499  * bool exists = getOptionalFloat(State_XMLNode, "pressure", pres, "toSI");
500  * @endcode
501  *
502  * reads the corresponding XML file:
503  *
504  * <state>
505  * <pressure units="Pa"> 101325.0 </pressure>
506  * <\state>
507  *
508  * @param parent reference to the XML_Node object of the parent XML element
509  * @param name Name of the XML child element
510  * @param fltRtn Float Return. It will be overridden if the XML element exists.
511  * @param type String type. Currently known types are "toSI" and
512  * "actEnergy", and "" , for no conversion. The default value is
513  * "", which implies that no conversion is allowed.
514  *
515  * @returns true if the child element named "name" exists
516  */
517 bool getOptionalFloat(const XML_Node& parent, const std::string& name,
518  doublereal& fltRtn, const std::string& type="");
519 
520 //! Get an integer value from a child element.
521 /*!
522  * Returns an integer value for the child named 'name' of element 'parent'.
523  * Note, it's an error for the child element not to exist.
524  *
525  * Example:
526  *
527  * @code
528  * const XML_Node &State_XMLNode;
529  * int number = 1;
530  * if (state_XMLNode.hasChild("NumProcs")) {
531  * number = getInteger(State_XMLNode, "numProcs");
532  * }
533  * @endcode
534  *
535  * reads the corresponding XML file:
536  *
537  * <state>
538  * <numProcs> 10 <numProcs/>
539  * <\state>
540  *
541  * @param parent reference to the XML_Node object of the parent XML element
542  * @param name Name of the XML child element
543  */
544 int getInteger(const XML_Node& parent, const std::string& name);
545 
546 //! Get a floating-point value from a child element with a defined units field
547 /*!
548  * Returns a doublereal value for the child named 'name' of element 'parent'.
549  * 'type' must be supplied and match a known unit type. Note, it's an error
550  * for the child element not to exist.
551  *
552  * Example:
553  *
554  * @code
555  * const XML_Node &State_XMLNode;
556  * doublereal pres = OneAtm;
557  * if (state_XMLNode.hasChild("pressure")) {
558  * pres = getFloatDefaultUnits(State_XMLNode, "pressure", "Pa", "toSI");
559  * }
560  * @endcode
561  *
562  * reads the corresponding XML file:
563  *
564  * <state>
565  * <pressure units="Pa"> 101325.0 </pressure>
566  * <\state>
567  *
568  * @param parent reference to the XML_Node object of the parent XML element
569  * @param name Name of the XML child element
570  * @param defaultUnits Default units string to be found in the units attribute.
571  * If the units string in the XML field is equal to defaultUnits,
572  * no units conversion will be carried out.
573  * @param type String type. Currently known types are "toSI" and "actEnergy",
574  * and "" , for no conversion. The default value is "",
575  * which implies that no conversion is allowed.
576  * @deprecated Use getFloat and toSI directly. To be removed after Cantera 2.3.
577  */
578 doublereal getFloatDefaultUnits(const XML_Node& parent,
579  const std::string& name,
580  const std::string& defaultUnits,
581  const std::string& type="toSI");
582 
583 //! Get an optional model name from a named child node.
584 /*!
585  * Returns the model name attribute for the child named 'nodeName' of element
586  * 'parent'. Note, it's optional for the child node to exist
587  *
588  * Example:
589  *
590  * @code
591  * std::string modelName = "";
592  * bool exists = getOptionalModel(transportNode, "compositionDependence",
593  * modelName);
594  * @endcode
595  *
596  * reads the corresponding XML file:
597  *
598  * <transport model="Simple">
599  * <compositionDependence model="Solvent_Only"/>
600  * </transport>
601  *
602  * On return modelName is set to "Solvent_Only".
603  *
604  * @param parent reference to the XML_Node object of the parent XML element
605  * @param nodeName Name of the XML child element
606  * @param modelName On return this contains the contents of the model attribute
607  * @return True if the nodeName XML node exists. False otherwise.
608  */
609 bool getOptionalModel(const XML_Node& parent, const std::string& nodeName,
610  std::string& modelName);
611 
612 //! Search the child nodes of the current node for an XML Node with a Title
613 //! attribute of a given name.
614 /*!
615  * @param node Current node from which to conduct the search
616  * @param title Name of the title attribute
617  * @returns a pointer to the matched child node. Returns 0 if no node is found.
618  */
619 XML_Node* getByTitle(const XML_Node& node, const std::string& title);
620 
621 //! This function reads a child node with the name string with a specific
622 //! title attribute named titleString
623 /*!
624  * This function will read a child node to the current XML node with the name
625  * "string". It must have a title attribute, named titleString, and the body
626  * of the XML node will be read into the valueString output argument.
627  *
628  * If the child node is not found then the empty string is returned.
629  *
630  * Example:
631  *
632  * @code
633  * const XML_Node &node;
634  * getString(XML_Node& node, std::string titleString, std::string valueString,
635  * std::string typeString);
636  * @endcode
637  *
638  * Reads the following the snippet in the XML file:
639  *
640  * <string title="titleString" type="typeString">
641  * valueString
642  * <\string>
643  *
644  * @param node Reference to the XML_Node object of the parent XML element
645  * @param titleString String name of the title attribute of the child node
646  * @param valueString Value string that is found in the child node. output
647  * variable
648  * @param typeString String type. This is an optional output variable. It
649  * is filled with the attribute "type" of the XML entry.
650  */
651 void getString(const XML_Node& node, const std::string& titleString,
652  std::string& valueString, std::string& typeString);
653 
654 //! This function reads a child node with the name, nameString, and returns
655 //! its XML value as the return string
656 /*!
657  * If the child XML_node named "name" doesn't exist, the empty string is returned.
658  *
659  * Example:
660  * @code
661  * const XML_Node &parent;
662  * string nameString = "vacancy_species";
663  * string valueString = getChildValue(parent, nameString
664  * std::string typeString);
665  * @endcode
666  *
667  * returns `valueString = "O(V)"` from the following the snippet in the XML file:
668  *
669  * <vacancySpecies>
670  * O(V)
671  * <\vacancySpecies>
672  *
673  * @param parent parent reference to the XML_Node object of the parent XML element
674  * @param nameString Name of the child XML_Node to read the value from.
675  * @return String value of the child XML_Node
676  */
677 std::string getChildValue(const XML_Node& parent,
678  const std::string& nameString);
679 
680 //! Convert a cti file into a ctml file
681 /*!
682  * @param file Pointer to the file
683  * @param debug Turn on debug printing
684  *
685  * @ingroup inputfiles
686  */
687 void ct2ctml(const char* file, const int debug = 0);
688 
689 //! Get a string with the ctml representation of a cti file.
690 /*!
691  * @param file Path to the input file in CTI format
692  * @return String containing the XML representation of the input file
693  *
694  * @ingroup inputfiles
695  */
696 std::string ct2ctml_string(const std::string& file);
697 
698 //! Get a string with the ctml representation of a cti input string.
699 /*!
700  * @param cti String containing the cti representation
701  * @return String containing the XML representation of the input
702  *
703  * @ingroup inputfiles
704  */
705 std::string ct_string2ctml_string(const std::string& cti);
706 
707 //! Convert a Chemkin-format mechanism into a CTI file.
708 /*!
709  * @param in_file input file containing species and reactions
710  * @param thermo_file optional input file containing thermo data
711  * @param transport_file optional input file containing transport parameters
712  * @param id_tag id of the phase
713  */
714 void ck2cti(const std::string& in_file, const std::string& thermo_file="",
715  const std::string& transport_file="",
716  const std::string& id_tag="gas");
717 
718 }
719 
720 // namespace alias for backward compatibility
721 namespace ctml = Cantera;
722 
723 #endif
void getMap(const XML_Node &node, std::map< std::string, std::string > &m)
This routine is used to interpret the value portions of XML elements that contain colon separated pai...
Definition: ctml.cpp:373
void addFloatArray(XML_Node &node, const std::string &title, const size_t n, const doublereal *const vals, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "floatArray", with a value consisting of a comma separ...
Definition: ctml.cpp:54
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
Definition: ctml.cpp:299
std::string ct2ctml_string(const std::string &file)
Get a string with the ctml representation of a cti file.
Definition: ct2ctml.cpp:235
std::string getChildValue(const XML_Node &parent, const std::string &nameString)
This function reads a child node with the name, nameString, and returns its XML value as the return s...
Definition: ctml.cpp:145
void addNamedFloatArray(XML_Node &node, const std::string &name, const size_t n, const doublereal *const vals, const std::string units, const std::string type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name given by the first parameter with a value consisting of...
Definition: ctml.cpp:87
void addInteger(XML_Node &node, const std::string &title, const int val, const std::string &units, const std::string &type)
This function adds a child node with the name, "integer", with a value consisting of a single integer...
Definition: ctml.cpp:19
void addString(XML_Node &node, const std::string &titleString, const std::string &valueString, const std::string &typeString)
This function adds a child node with the name string with a string value to the current node...
Definition: ctml.cpp:125
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
const doublereal Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:134
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:31
void ct2ctml(const char *file, const int debug)
Convert a cti file into a ctml file.
Definition: ct2ctml.cpp:58
const std::string CTML_Version
const Specifying the CTML version number
Definition: ctml.h:25
void getIntegers(const XML_Node &node, std::map< std::string, int > &v)
Get a vector of integer values from a child element.
Definition: ctml.cpp:166
doublereal getFloatCurrent(const XML_Node &node, const std::string &type)
Get a floating-point value from the current XML element.
Definition: ctml.cpp:191
void ck2cti(const std::string &in_file, const std::string &thermo_file, const std::string &transport_file, const std::string &id_tag)
Convert a Chemkin-format mechanism into a CTI file.
Definition: ct2ctml.cpp:245
Classes providing support for XML data files.
int getPairs(const XML_Node &node, std::vector< std::string > &key, std::vector< std::string > &val)
This function interprets the value portion of an XML element as a series of "Pairs" separated by whit...
Definition: ctml.cpp:387
void getString(const XML_Node &node, const std::string &titleString, std::string &valueString, std::string &typeString)
This function reads a child node with the name string with a specific title attribute named titleStri...
Definition: ctml.cpp:153
std::string ct_string2ctml_string(const std::string &cti)
Get a string with the ctml representation of a cti input string.
Definition: ct2ctml.cpp:240
void addFloat(XML_Node &node, const std::string &title, const doublereal val, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "float", with a value consisting of a single floating ...
Definition: ctml.cpp:33
void getMatrixValues(const XML_Node &node, const std::vector< std::string > &keyStringRow, const std::vector< std::string > &keyStringCol, Array2D &retnValues, const bool convert, const bool matrixSymmetric)
This function interprets the value portion of an XML element as a series of "Matrix ids and entries" ...
Definition: ctml.cpp:405
int getInteger(const XML_Node &parent, const std::string &name)
Get an integer value from a child element.
Definition: ctml.cpp:277
bool getOptionalModel(const XML_Node &parent, const std::string &nodeName, std::string &modelName)
Get an optional model name from a named child node.
Definition: ctml.cpp:267
XML_Node * getByTitle(const XML_Node &node, const std::string &title)
Search the child nodes of the current node for an XML Node with a Title attribute of a given name...
Definition: ctml.cpp:136
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
void getStringArray(const XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
Definition: ctml.cpp:470
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:178
doublereal getFloatDefaultUnits(const XML_Node &parent, const std::string &name, const std::string &defaultUnits, const std::string &type)
Get a floating-point value from a child element with a defined units field.
Definition: ctml.cpp:238
Namespace for the Cantera kernel.
Definition: application.cpp:29
bool getOptionalFloat(const XML_Node &parent, const std::string &name, doublereal &fltRtn, const std::string &type)
Get an optional floating-point value from a child element.
Definition: ctml.cpp:226