Cantera  2.1.2
wrappers.h
1 #include "cantera/base/logger.h"
5 
6 #include "Python.h"
7 
8 // Wrappers for preprocessor defines
9 std::string get_cantera_version()
10 {
11  return std::string(CANTERA_VERSION);
12 }
13 
14 int get_sundials_version()
15 {
16  return SUNDIALS_VERSION;
17 }
18 
19 class PythonLogger : public Cantera::Logger
20 {
21 public:
22  virtual void write(const std::string& s) {
23  // 1000 bytes is the maximum size permitted by PySys_WriteStdout
24  static const size_t N = 999;
25  for (size_t i = 0; i < s.size(); i+=N) {
26  PySys_WriteStdout("%s", s.substr(i, N).c_str());
27  }
28  }
29 
30  virtual void error(const std::string& msg) {
31  std::string err = "raise Exception('''"+msg+"''')";
32  PyRun_SimpleString(err.c_str());
33  }
34 };
35 
36 // Function which populates a 1D array
37 #define ARRAY_FUNC(PREFIX, CLASS_NAME, FUNC_NAME) \
38  void PREFIX ## _ ## FUNC_NAME(Cantera::CLASS_NAME* object, double* data) \
39  { object->FUNC_NAME(data); }
40 
41 // function which takes a stride as the first argument and populates a 2D array
42 #define ARRAY_FUNC2(PREFIX, CLASS_NAME, FUNC_NAME) \
43  void PREFIX ## _ ## FUNC_NAME(Cantera::CLASS_NAME* object, size_t dim, double* data) \
44  { object->FUNC_NAME(dim, data); }
45 
46 
47 #define THERMO_1D(FUNC_NAME) ARRAY_FUNC(thermo, ThermoPhase, FUNC_NAME)
48 #define KIN_1D(FUNC_NAME) ARRAY_FUNC(kin, Kinetics, FUNC_NAME)
49 #define TRANSPORT_1D(FUNC_NAME) ARRAY_FUNC(tran, Transport, FUNC_NAME)
50 #define TRANSPORT_2D(FUNC_NAME) ARRAY_FUNC2(tran, Transport, FUNC_NAME)
51 
52 THERMO_1D(getMassFractions)
53 THERMO_1D(setMassFractions)
54 THERMO_1D(getMoleFractions)
55 THERMO_1D(setMoleFractions)
56 THERMO_1D(getConcentrations)
57 THERMO_1D(setConcentrations)
58 
59 THERMO_1D(getMolecularWeights)
60 THERMO_1D(getChemPotentials)
61 THERMO_1D(getElectrochemPotentials)
62 THERMO_1D(getPartialMolarEnthalpies)
63 THERMO_1D(getPartialMolarEntropies)
64 THERMO_1D(getPartialMolarIntEnergies)
65 THERMO_1D(getPartialMolarCp)
66 THERMO_1D(getPartialMolarVolumes)
67 THERMO_1D(getEnthalpy_RT)
68 THERMO_1D(getEntropy_R)
69 THERMO_1D(getIntEnergy_RT)
70 THERMO_1D(getGibbs_RT)
71 THERMO_1D(getCp_R)
72 
73 KIN_1D(getFwdRatesOfProgress)
74 KIN_1D(getRevRatesOfProgress)
75 KIN_1D(getNetRatesOfProgress)
76 
77 KIN_1D(getEquilibriumConstants)
78 KIN_1D(getActivationEnergies)
79 KIN_1D(getFwdRateConstants)
80 KIN_1D(getRevRateConstants)
81 
82 KIN_1D(getDeltaEnthalpy)
83 KIN_1D(getDeltaGibbs)
84 KIN_1D(getDeltaEntropy)
85 KIN_1D(getDeltaSSEnthalpy)
86 KIN_1D(getDeltaSSGibbs)
87 KIN_1D(getDeltaSSEntropy)
88 
89 KIN_1D(getCreationRates)
90 KIN_1D(getDestructionRates)
91 KIN_1D(getNetProductionRates)
92 
93 TRANSPORT_1D(getMixDiffCoeffs)
94 TRANSPORT_1D(getMixDiffCoeffsMass)
95 TRANSPORT_1D(getMixDiffCoeffsMole)
96 TRANSPORT_1D(getThermalDiffCoeffs)
97 
98 TRANSPORT_2D(getMultiDiffCoeffs)
99 TRANSPORT_2D(getBinaryDiffCoeffs)
Base class for 'loggers' that write text messages to log files.
Definition: logger.h:39
virtual void write(const std::string &msg)
Write a log message.
Definition: logger.h:58
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
virtual void error(const std::string &msg)
Write an error message and quit.
Definition: logger.h:84
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header for Base class for 'loggers' that write text messages to log files (see Writing messages to th...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).