Cantera  3.2.0a4
Loading...
Searching...
No Matches
ctkin.cpp
Go to the documentation of this file.
1/**
2 * CTKIN - Generated CLib %Cantera interface library.
3 *
4 * @file ctkin.cpp
5 *
6 * Generated CLib API for Cantera's Kinetics class.
7 *
8 * This file was generated by sourcegen. It will be re-generated by the
9 * %Cantera build process. Do not manually edit.
10 *
11 * @warning This module is an experimental part of the %Cantera API and
12 * may be changed without notice.
13 */
14
15// This file is part of Cantera. See License.txt in the top-level directory or
16// at https://cantera.org/license.txt for license and copyright information.
17
18#include "clib_utils.h"
19#include "cantera_clib/ctkin.h"
20
27
28using namespace Cantera;
29
30//! @cond
31//! Cabinet type definitions will be ignored by Doxygen
32
33// Define Cabinet<Kinetics> (single-instance object)
34typedef Cabinet<Kinetics> KineticsCabinet;
35template<> KineticsCabinet* KineticsCabinet::s_storage = 0; // initialized here
36
37typedef Cabinet<ThermoPhase> ThermoPhaseCabinet;
38template<> ThermoPhaseCabinet* ThermoPhaseCabinet::s_storage; // initialized elsewhere
39
40typedef Cabinet<Reaction> ReactionCabinet;
41template<> ReactionCabinet* ReactionCabinet::s_storage; // initialized elsewhere
42
43//! @endcond
44
45extern "C" {
46
47 int32_t kin_getType(int32_t handle, int32_t bufLen, char* buf)
48 {
49 // getter: virtual string Kinetics::kineticsType()
50 try {
51 string out = KineticsCabinet::at(handle)->kineticsType();
52 copyString(out, buf, bufLen);
53 return int(out.size()) + 1;
54 } catch (...) {
55 return handleAllExceptions(-1, ERR);
56 }
57 }
58
59 int32_t kin_nReactions(int32_t handle)
60 {
61 // getter: size_t Kinetics::nReactions()
62 try {
63 return KineticsCabinet::at(handle)->nReactions();
64 } catch (...) {
65 return handleAllExceptions(ERR, ERR);
66 }
67 }
68
69 int32_t kin_reaction(int32_t handle, int32_t i)
70 {
71 // accessor: shared_ptr<Reaction> Kinetics::reaction(size_t)
72 try {
73 if (i < 0 || i >= KineticsCabinet::at(handle)->nReactions()) {
74 throw IndexError("kin_reaction", "", i, KineticsCabinet::at(handle)->nReactions());
75 }
76 return ReactionCabinet::add(KineticsCabinet::at(handle)->reaction(i));
77 } catch (...) {
78 return handleAllExceptions(-2, ERR);
79 }
80 }
81
82 int32_t kin_nPhases(int32_t handle)
83 {
84 // getter: size_t Kinetics::nPhases()
85 try {
86 return KineticsCabinet::at(handle)->nPhases();
87 } catch (...) {
88 return handleAllExceptions(ERR, ERR);
89 }
90 }
91
92 int32_t kin_phase(int32_t handle, int32_t n)
93 {
94 // accessor: shared_ptr<ThermoPhase> Kinetics::phase(size_t)
95 try {
96 if (n < 0 || n >= KineticsCabinet::at(handle)->nPhases()) {
97 throw IndexError("kin_phase", "", n, KineticsCabinet::at(handle)->nPhases());
98 }
99 return ThermoPhaseCabinet::add(KineticsCabinet::at(handle)->phase(n));
100 } catch (...) {
101 return handleAllExceptions(-2, ERR);
102 }
103 }
104
105 int32_t kin_reactionPhase(int32_t handle)
106 {
107 // accessor: shared_ptr<ThermoPhase> Kinetics::reactionPhase()
108 try {
109 return ThermoPhaseCabinet::add(KineticsCabinet::at(handle)->reactionPhase());
110 } catch (...) {
111 return handleAllExceptions(-2, ERR);
112 }
113 }
114
115 int32_t kin_phaseIndex(int32_t handle, const char* ph)
116 {
117 // method: size_t Kinetics::phaseIndex(const string&)
118 try {
119 return KineticsCabinet::at(handle)->phaseIndex(ph);
120 } catch (...) {
121 return handleAllExceptions(ERR, ERR);
122 }
123 }
124
125 int32_t kin_nTotalSpecies(int32_t handle)
126 {
127 // getter: size_t Kinetics::nTotalSpecies()
128 try {
129 return KineticsCabinet::at(handle)->nTotalSpecies();
130 } catch (...) {
131 return handleAllExceptions(ERR, ERR);
132 }
133 }
134
135 double kin_reactantStoichCoeff(int32_t handle, int32_t k, int32_t i)
136 {
137 // method: virtual double Kinetics::reactantStoichCoeff(size_t, size_t)
138 try {
139 return KineticsCabinet::at(handle)->reactantStoichCoeff(k, i);
140 } catch (...) {
141 return handleAllExceptions(DERR, DERR);
142 }
143 }
144
145 double kin_productStoichCoeff(int32_t handle, int32_t k, int32_t i)
146 {
147 // method: virtual double Kinetics::productStoichCoeff(size_t, size_t)
148 try {
149 return KineticsCabinet::at(handle)->productStoichCoeff(k, i);
150 } catch (...) {
151 return handleAllExceptions(DERR, DERR);
152 }
153 }
154
155 int32_t kin_getFwdRatesOfProgress(int32_t handle, int32_t fwdROPLen, double* fwdROP)
156 {
157 // getter: virtual void Kinetics::getFwdRatesOfProgress(double*)
158 try {
159 auto& obj = KineticsCabinet::at(handle);
160 // no size checking specified
161 obj->getFwdRatesOfProgress(fwdROP);
162 return 0;
163 } catch (...) {
164 return handleAllExceptions(-1, ERR);
165 }
166 }
167
168 int32_t kin_getRevRatesOfProgress(int32_t handle, int32_t revROPLen, double* revROP)
169 {
170 // getter: virtual void Kinetics::getRevRatesOfProgress(double*)
171 try {
172 auto& obj = KineticsCabinet::at(handle);
173 // no size checking specified
174 obj->getRevRatesOfProgress(revROP);
175 return 0;
176 } catch (...) {
177 return handleAllExceptions(-1, ERR);
178 }
179 }
180
181 int32_t kin_getNetRatesOfProgress(int32_t handle, int32_t netROPLen, double* netROP)
182 {
183 // getter: virtual void Kinetics::getNetRatesOfProgress(double*)
184 try {
185 auto& obj = KineticsCabinet::at(handle);
186 // no size checking specified
187 obj->getNetRatesOfProgress(netROP);
188 return 0;
189 } catch (...) {
190 return handleAllExceptions(-1, ERR);
191 }
192 }
193
194 int32_t kin_getEquilibriumConstants(int32_t handle, int32_t kcLen, double* kc)
195 {
196 // getter: virtual void Kinetics::getEquilibriumConstants(double*)
197 try {
198 auto& obj = KineticsCabinet::at(handle);
199 // no size checking specified
200 obj->getEquilibriumConstants(kc);
201 return 0;
202 } catch (...) {
203 return handleAllExceptions(-1, ERR);
204 }
205 }
206
207 int32_t kin_getFwdRateConstants(int32_t handle, int32_t kfwdLen, double* kfwd)
208 {
209 // getter: virtual void Kinetics::getFwdRateConstants(double*)
210 try {
211 auto& obj = KineticsCabinet::at(handle);
212 // no size checking specified
213 obj->getFwdRateConstants(kfwd);
214 return 0;
215 } catch (...) {
216 return handleAllExceptions(-1, ERR);
217 }
218 }
219
220 int32_t kin_getRevRateConstants(int32_t handle, int32_t krevLen, double* krev, int32_t doIrreversible)
221 {
222 // method: virtual void Kinetics::getRevRateConstants(double*, bool)
223 try {
224 bool doIrreversible_ = (doIrreversible != 0);
225 KineticsCabinet::at(handle)->getRevRateConstants(krev, doIrreversible_);
226 return 0;
227 } catch (...) {
228 return handleAllExceptions(-1, ERR);
229 }
230 }
231
232 int32_t kin_getCreationRates(int32_t handle, int32_t cdotLen, double* cdot)
233 {
234 // getter: virtual void Kinetics::getCreationRates(double*)
235 try {
236 auto& obj = KineticsCabinet::at(handle);
237 // no size checking specified
238 obj->getCreationRates(cdot);
239 return 0;
240 } catch (...) {
241 return handleAllExceptions(-1, ERR);
242 }
243 }
244
245 int32_t kin_getDestructionRates(int32_t handle, int32_t ddotLen, double* ddot)
246 {
247 // getter: virtual void Kinetics::getDestructionRates(double*)
248 try {
249 auto& obj = KineticsCabinet::at(handle);
250 // no size checking specified
251 obj->getDestructionRates(ddot);
252 return 0;
253 } catch (...) {
254 return handleAllExceptions(-1, ERR);
255 }
256 }
257
258 int32_t kin_getNetProductionRates(int32_t handle, int32_t wdotLen, double* wdot)
259 {
260 // getter: virtual void Kinetics::getNetProductionRates(double*)
261 try {
262 auto& obj = KineticsCabinet::at(handle);
263 // no size checking specified
264 obj->getNetProductionRates(wdot);
265 return 0;
266 } catch (...) {
267 return handleAllExceptions(-1, ERR);
268 }
269 }
270
271 double kin_multiplier(int32_t handle, int32_t i)
272 {
273 // method: double Kinetics::multiplier(size_t)
274 try {
275 return KineticsCabinet::at(handle)->multiplier(i);
276 } catch (...) {
277 return handleAllExceptions(DERR, DERR);
278 }
279 }
280
281 int32_t kin_setMultiplier(int32_t handle, int32_t i, double f)
282 {
283 // method: virtual void Kinetics::setMultiplier(size_t, double)
284 try {
285 KineticsCabinet::at(handle)->setMultiplier(i, f);
286 return 0;
287 } catch (...) {
288 return handleAllExceptions(-1, ERR);
289 }
290 }
291
292 int32_t kin_isReversible(int32_t handle, int32_t i)
293 {
294 // method: bool Kinetics::isReversible(size_t)
295 try {
296 bool out = KineticsCabinet::at(handle)->isReversible(i);
297 return int(out);
298 } catch (...) {
299 return handleAllExceptions(-1, ERR);
300 }
301 }
302
303 int32_t kin_speciesIndex(int32_t handle, const char* nm)
304 {
305 // method: size_t Kinetics::kineticsSpeciesIndex(const string&)
306 try {
307 return KineticsCabinet::at(handle)->kineticsSpeciesIndex(nm);
308 } catch (...) {
309 return handleAllExceptions(ERR, ERR);
310 }
311 }
312
313 int32_t kin_advanceCoverages(int32_t handle, double tstep)
314 {
315 // setter: void InterfaceKinetics::advanceCoverages(double)
316 try {
317 KineticsCabinet::as<InterfaceKinetics>(handle)->advanceCoverages(tstep);
318 return 0;
319 } catch (...) {
320 return handleAllExceptions(-1, ERR);
321 }
322 }
323
324 int32_t kin_getDeltaEnthalpy(int32_t handle, int32_t deltaHLen, double* deltaH)
325 {
326 // getter: virtual void Kinetics::getDeltaEnthalpy(double*)
327 try {
328 auto& obj = KineticsCabinet::at(handle);
329 // no size checking specified
330 obj->getDeltaEnthalpy(deltaH);
331 return 0;
332 } catch (...) {
333 return handleAllExceptions(-1, ERR);
334 }
335 }
336
337 int32_t kin_getDeltaGibbs(int32_t handle, int32_t deltaGLen, double* deltaG)
338 {
339 // getter: virtual void Kinetics::getDeltaGibbs(double*)
340 try {
341 auto& obj = KineticsCabinet::at(handle);
342 // no size checking specified
343 obj->getDeltaGibbs(deltaG);
344 return 0;
345 } catch (...) {
346 return handleAllExceptions(-1, ERR);
347 }
348 }
349
350 int32_t kin_getDeltaEntropy(int32_t handle, int32_t deltaSLen, double* deltaS)
351 {
352 // getter: virtual void Kinetics::getDeltaEntropy(double*)
353 try {
354 auto& obj = KineticsCabinet::at(handle);
355 // no size checking specified
356 obj->getDeltaEntropy(deltaS);
357 return 0;
358 } catch (...) {
359 return handleAllExceptions(-1, ERR);
360 }
361 }
362
363 int32_t kin_getDeltaSSEnthalpy(int32_t handle, int32_t deltaHLen, double* deltaH)
364 {
365 // getter: virtual void Kinetics::getDeltaSSEnthalpy(double*)
366 try {
367 auto& obj = KineticsCabinet::at(handle);
368 // no size checking specified
369 obj->getDeltaSSEnthalpy(deltaH);
370 return 0;
371 } catch (...) {
372 return handleAllExceptions(-1, ERR);
373 }
374 }
375
376 int32_t kin_getDeltaSSGibbs(int32_t handle, int32_t deltaGLen, double* deltaG)
377 {
378 // getter: virtual void Kinetics::getDeltaSSGibbs(double*)
379 try {
380 auto& obj = KineticsCabinet::at(handle);
381 // no size checking specified
382 obj->getDeltaSSGibbs(deltaG);
383 return 0;
384 } catch (...) {
385 return handleAllExceptions(-1, ERR);
386 }
387 }
388
389 int32_t kin_getDeltaSSEntropy(int32_t handle, int32_t deltaSLen, double* deltaS)
390 {
391 // getter: virtual void Kinetics::getDeltaSSEntropy(double*)
392 try {
393 auto& obj = KineticsCabinet::at(handle);
394 // no size checking specified
395 obj->getDeltaSSEntropy(deltaS);
396 return 0;
397 } catch (...) {
398 return handleAllExceptions(-1, ERR);
399 }
400 }
401
402 int32_t kin_del(int32_t handle)
403 {
404 // destructor
405 try {
406 KineticsCabinet::del(handle);
407 return 0;
408 } catch (...) {
409 return handleAllExceptions(-1, ERR);
410 }
411 }
412
414 {
415 // reserved CLib function: custom code
416 try {
417 // *************** begin custom code ***************
418 return KineticsCabinet::size();
419 // **************** end custom code ****************
420 } catch (...) {
421 return handleAllExceptions(-1, ERR);
422 }
423 }
424
425} // extern "C"
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Template for classes to hold pointers to objects.
Definition Cabinet.h:51
An array index is out of range.
CTKIN - Generated CLib Cantera interface library.
int32_t kin_getDeltaGibbs(int32_t handle, int32_t deltaGLen, double *deltaG)
Return the vector of values for the reaction Gibbs free energy change.
Definition ctkin.cpp:337
int32_t kin_setMultiplier(int32_t handle, int32_t i, double f)
Set the multiplier for reaction i to f.
Definition ctkin.cpp:281
int32_t kin_del(int32_t handle)
Delete Kinetics object.
Definition ctkin.cpp:402
int32_t kin_reaction(int32_t handle, int32_t i)
Return the Reaction object for reaction i.
Definition ctkin.cpp:69
int32_t kin_nPhases(int32_t handle)
The number of phases participating in the reaction mechanism.
Definition ctkin.cpp:82
int32_t kin_reactionPhase(int32_t handle)
Return pointer to phase where the reactions occur.
Definition ctkin.cpp:105
double kin_productStoichCoeff(int32_t handle, int32_t k, int32_t i)
Stoichiometric coefficient of species k as a product in reaction i.
Definition ctkin.cpp:145
int32_t kin_getEquilibriumConstants(int32_t handle, int32_t kcLen, double *kc)
Return a vector of Equilibrium constants.
Definition ctkin.cpp:194
int32_t kin_getRevRatesOfProgress(int32_t handle, int32_t revROPLen, double *revROP)
Return the Reverse rates of progress of the reactions.
Definition ctkin.cpp:168
int32_t kin_getDestructionRates(int32_t handle, int32_t ddotLen, double *ddot)
Species destruction rates [kmol/m^3/s or kmol/m^2/s].
Definition ctkin.cpp:245
int32_t kin_advanceCoverages(int32_t handle, double tstep)
Advance the surface coverages in time.
Definition ctkin.cpp:313
int32_t kin_phase(int32_t handle, int32_t n)
Return pointer to phase associated with Kinetics by index.
Definition ctkin.cpp:92
int32_t kin_getRevRateConstants(int32_t handle, int32_t krevLen, double *krev, int32_t doIrreversible)
Return the reverse rate constants.
Definition ctkin.cpp:220
int32_t kin_getDeltaEntropy(int32_t handle, int32_t deltaSLen, double *deltaS)
Return the vector of values for the reactions change in entropy.
Definition ctkin.cpp:350
int32_t kin_speciesIndex(int32_t handle, const char *nm)
This routine will look up a species number based on the input string nm.
Definition ctkin.cpp:303
int32_t kin_getDeltaEnthalpy(int32_t handle, int32_t deltaHLen, double *deltaH)
Return the vector of values for the reactions change in enthalpy.
Definition ctkin.cpp:324
int32_t kin_getCreationRates(int32_t handle, int32_t cdotLen, double *cdot)
Species creation rates [kmol/m^3/s or kmol/m^2/s].
Definition ctkin.cpp:232
int32_t kin_phaseIndex(int32_t handle, const char *ph)
Return the phase index of a phase in the list of phases defined within the object.
Definition ctkin.cpp:115
int32_t kin_getDeltaSSEnthalpy(int32_t handle, int32_t deltaHLen, double *deltaH)
Return the vector of values for the change in the standard state enthalpies of reaction.
Definition ctkin.cpp:363
int32_t kin_getDeltaSSGibbs(int32_t handle, int32_t deltaGLen, double *deltaG)
Return the vector of values for the reaction standard state Gibbs free energy change.
Definition ctkin.cpp:376
int32_t kin_getNetProductionRates(int32_t handle, int32_t wdotLen, double *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
Definition ctkin.cpp:258
double kin_reactantStoichCoeff(int32_t handle, int32_t k, int32_t i)
Stoichiometric coefficient of species k as a reactant in reaction i.
Definition ctkin.cpp:135
int32_t kin_getFwdRatesOfProgress(int32_t handle, int32_t fwdROPLen, double *fwdROP)
Return the forward rates of progress of the reactions.
Definition ctkin.cpp:155
int32_t kin_getDeltaSSEntropy(int32_t handle, int32_t deltaSLen, double *deltaS)
Return the vector of values for the change in the standard state entropies for each reaction.
Definition ctkin.cpp:389
int32_t kin_getType(int32_t handle, int32_t bufLen, char *buf)
Identifies the Kinetics manager type.
Definition ctkin.cpp:47
int32_t kin_getNetRatesOfProgress(int32_t handle, int32_t netROPLen, double *netROP)
Net rates of progress.
Definition ctkin.cpp:181
int32_t kin_isReversible(int32_t handle, int32_t i)
True if reaction i has been declared to be reversible.
Definition ctkin.cpp:292
int32_t kin_nTotalSpecies(int32_t handle)
The total number of species in all phases participating in the kinetics mechanism.
Definition ctkin.cpp:125
int32_t kin_nReactions(int32_t handle)
Number of reactions in the reaction mechanism.
Definition ctkin.cpp:59
int32_t kin_getFwdRateConstants(int32_t handle, int32_t kfwdLen, double *kfwd)
Return the forward rate constants.
Definition ctkin.cpp:207
int32_t kin_cabinetSize()
Return size of Kinetics storage.
Definition ctkin.cpp:413
double kin_multiplier(int32_t handle, int32_t i)
The current value of the multiplier for reaction i.
Definition ctkin.cpp:271
size_t copyString(const string &source, char *dest, size_t length)
Copy the contents of a string into a char array of a given length.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32
Contains declarations for string manipulation functions within Cantera.