Cantera  3.2.0a5
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<Reaction> ReactionCabinet;
38template<> ReactionCabinet* ReactionCabinet::s_storage; // initialized elsewhere
39
40typedef Cabinet<ThermoPhase> ThermoPhaseCabinet;
41template<> ThermoPhaseCabinet* ThermoPhaseCabinet::s_storage; // initialized elsewhere
42
43//! @endcond
44
45extern "C" {
46
47 int32_t kin_kineticsType(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 // size getter: size_t Kinetics::nReactions()
62 try {
63 return static_cast<int32_t>(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 || static_cast<size_t>(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 // size getter: size_t Kinetics::nPhases()
85 try {
86 return static_cast<int32_t>(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 || static_cast<size_t>(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: custom code
118 try {
119 // *************** begin custom code ***************
120 return static_cast<int32_t>(KineticsCabinet::at(handle)->phaseIndex(ph, true));
121 // **************** end custom code ****************
122 } catch (...) {
123 return handleAllExceptions(-1, ERR);
124 }
125 }
126
127 int32_t kin_nTotalSpecies(int32_t handle)
128 {
129 // size getter: size_t Kinetics::nTotalSpecies()
130 try {
131 return static_cast<int32_t>(KineticsCabinet::at(handle)->nTotalSpecies());
132 } catch (...) {
133 return handleAllExceptions(ERR, ERR);
134 }
135 }
136
137 double kin_reactantStoichCoeff(int32_t handle, int32_t k, int32_t i)
138 {
139 // method: virtual double Kinetics::reactantStoichCoeff(size_t, size_t)
140 try {
141 return KineticsCabinet::at(handle)->reactantStoichCoeff(k, i);
142 } catch (...) {
143 return handleAllExceptions(DERR, DERR);
144 }
145 }
146
147 double kin_productStoichCoeff(int32_t handle, int32_t k, int32_t i)
148 {
149 // method: virtual double Kinetics::productStoichCoeff(size_t, size_t)
150 try {
151 return KineticsCabinet::at(handle)->productStoichCoeff(k, i);
152 } catch (...) {
153 return handleAllExceptions(DERR, DERR);
154 }
155 }
156
157 int32_t kin_getFwdRatesOfProgress(int32_t handle, int32_t fwdROPLen, double* fwdROP)
158 {
159 // array getter: virtual void Kinetics::getFwdRatesOfProgress(double*)
160 try {
161 auto& obj = KineticsCabinet::at(handle);
162 // no size checking specified
163 obj->getFwdRatesOfProgress(fwdROP);
164 return 0;
165 } catch (...) {
166 return handleAllExceptions(-1, ERR);
167 }
168 }
169
170 int32_t kin_getRevRatesOfProgress(int32_t handle, int32_t revROPLen, double* revROP)
171 {
172 // array getter: virtual void Kinetics::getRevRatesOfProgress(double*)
173 try {
174 auto& obj = KineticsCabinet::at(handle);
175 // no size checking specified
176 obj->getRevRatesOfProgress(revROP);
177 return 0;
178 } catch (...) {
179 return handleAllExceptions(-1, ERR);
180 }
181 }
182
183 int32_t kin_getNetRatesOfProgress(int32_t handle, int32_t netROPLen, double* netROP)
184 {
185 // array getter: virtual void Kinetics::getNetRatesOfProgress(double*)
186 try {
187 auto& obj = KineticsCabinet::at(handle);
188 // no size checking specified
189 obj->getNetRatesOfProgress(netROP);
190 return 0;
191 } catch (...) {
192 return handleAllExceptions(-1, ERR);
193 }
194 }
195
196 int32_t kin_getEquilibriumConstants(int32_t handle, int32_t kcLen, double* kc)
197 {
198 // array getter: virtual void Kinetics::getEquilibriumConstants(double*)
199 try {
200 auto& obj = KineticsCabinet::at(handle);
201 // no size checking specified
202 obj->getEquilibriumConstants(kc);
203 return 0;
204 } catch (...) {
205 return handleAllExceptions(-1, ERR);
206 }
207 }
208
209 int32_t kin_getFwdRateConstants(int32_t handle, int32_t kfwdLen, double* kfwd)
210 {
211 // array getter: virtual void Kinetics::getFwdRateConstants(double*)
212 try {
213 auto& obj = KineticsCabinet::at(handle);
214 // no size checking specified
215 obj->getFwdRateConstants(kfwd);
216 return 0;
217 } catch (...) {
218 return handleAllExceptions(-1, ERR);
219 }
220 }
221
222 int32_t kin_getRevRateConstants(int32_t handle, int32_t krevLen, double* krev, int32_t doIrreversible)
223 {
224 // method: virtual void Kinetics::getRevRateConstants(double*, bool)
225 try {
226 bool doIrreversible_ = (doIrreversible != 0);
227 KineticsCabinet::at(handle)->getRevRateConstants(krev, doIrreversible_);
228 return 0;
229 } catch (...) {
230 return handleAllExceptions(-1, ERR);
231 }
232 }
233
234 int32_t kin_getCreationRates(int32_t handle, int32_t cdotLen, double* cdot)
235 {
236 // array getter: virtual void Kinetics::getCreationRates(double*)
237 try {
238 auto& obj = KineticsCabinet::at(handle);
239 // no size checking specified
240 obj->getCreationRates(cdot);
241 return 0;
242 } catch (...) {
243 return handleAllExceptions(-1, ERR);
244 }
245 }
246
247 int32_t kin_getDestructionRates(int32_t handle, int32_t ddotLen, double* ddot)
248 {
249 // array getter: virtual void Kinetics::getDestructionRates(double*)
250 try {
251 auto& obj = KineticsCabinet::at(handle);
252 // no size checking specified
253 obj->getDestructionRates(ddot);
254 return 0;
255 } catch (...) {
256 return handleAllExceptions(-1, ERR);
257 }
258 }
259
260 int32_t kin_getNetProductionRates(int32_t handle, int32_t wdotLen, double* wdot)
261 {
262 // array getter: virtual void Kinetics::getNetProductionRates(double*)
263 try {
264 auto& obj = KineticsCabinet::at(handle);
265 // no size checking specified
266 obj->getNetProductionRates(wdot);
267 return 0;
268 } catch (...) {
269 return handleAllExceptions(-1, ERR);
270 }
271 }
272
273 double kin_multiplier(int32_t handle, int32_t i)
274 {
275 // method: double Kinetics::multiplier(size_t)
276 try {
277 return KineticsCabinet::at(handle)->multiplier(i);
278 } catch (...) {
279 return handleAllExceptions(DERR, DERR);
280 }
281 }
282
283 int32_t kin_setMultiplier(int32_t handle, int32_t i, double f)
284 {
285 // method: virtual void Kinetics::setMultiplier(size_t, double)
286 try {
287 KineticsCabinet::at(handle)->setMultiplier(i, f);
288 return 0;
289 } catch (...) {
290 return handleAllExceptions(-1, ERR);
291 }
292 }
293
294 int32_t kin_isReversible(int32_t handle, int32_t i)
295 {
296 // method: bool Kinetics::isReversible(size_t)
297 try {
298 bool out = KineticsCabinet::at(handle)->isReversible(i);
299 return int(out);
300 } catch (...) {
301 return handleAllExceptions(-1, ERR);
302 }
303 }
304
305 int32_t kin_kineticsSpeciesIndex(int32_t handle, const char* nm)
306 {
307 // method: custom code
308 try {
309 // *************** begin custom code ***************
310 return static_cast<int32_t>(KineticsCabinet::at(handle)->kineticsSpeciesIndex(nm, true));
311 // **************** end custom code ****************
312 } catch (...) {
313 return handleAllExceptions(-1, ERR);
314 }
315 }
316
317 int32_t kin_advanceCoverages(int32_t handle, double tstep)
318 {
319 // setter: void InterfaceKinetics::advanceCoverages(double)
320 try {
321 KineticsCabinet::as<InterfaceKinetics>(handle)->advanceCoverages(tstep);
322 return 0;
323 } catch (...) {
324 return handleAllExceptions(-1, ERR);
325 }
326 }
327
328 int32_t kin_getDeltaEnthalpy(int32_t handle, int32_t deltaHLen, double* deltaH)
329 {
330 // array getter: virtual void Kinetics::getDeltaEnthalpy(double*)
331 try {
332 auto& obj = KineticsCabinet::at(handle);
333 // no size checking specified
334 obj->getDeltaEnthalpy(deltaH);
335 return 0;
336 } catch (...) {
337 return handleAllExceptions(-1, ERR);
338 }
339 }
340
341 int32_t kin_getDeltaGibbs(int32_t handle, int32_t deltaGLen, double* deltaG)
342 {
343 // array getter: virtual void Kinetics::getDeltaGibbs(double*)
344 try {
345 auto& obj = KineticsCabinet::at(handle);
346 // no size checking specified
347 obj->getDeltaGibbs(deltaG);
348 return 0;
349 } catch (...) {
350 return handleAllExceptions(-1, ERR);
351 }
352 }
353
354 int32_t kin_getDeltaEntropy(int32_t handle, int32_t deltaSLen, double* deltaS)
355 {
356 // array getter: virtual void Kinetics::getDeltaEntropy(double*)
357 try {
358 auto& obj = KineticsCabinet::at(handle);
359 // no size checking specified
360 obj->getDeltaEntropy(deltaS);
361 return 0;
362 } catch (...) {
363 return handleAllExceptions(-1, ERR);
364 }
365 }
366
367 int32_t kin_getDeltaSSEnthalpy(int32_t handle, int32_t deltaHLen, double* deltaH)
368 {
369 // array getter: virtual void Kinetics::getDeltaSSEnthalpy(double*)
370 try {
371 auto& obj = KineticsCabinet::at(handle);
372 // no size checking specified
373 obj->getDeltaSSEnthalpy(deltaH);
374 return 0;
375 } catch (...) {
376 return handleAllExceptions(-1, ERR);
377 }
378 }
379
380 int32_t kin_getDeltaSSGibbs(int32_t handle, int32_t deltaGLen, double* deltaG)
381 {
382 // array getter: virtual void Kinetics::getDeltaSSGibbs(double*)
383 try {
384 auto& obj = KineticsCabinet::at(handle);
385 // no size checking specified
386 obj->getDeltaSSGibbs(deltaG);
387 return 0;
388 } catch (...) {
389 return handleAllExceptions(-1, ERR);
390 }
391 }
392
393 int32_t kin_getDeltaSSEntropy(int32_t handle, int32_t deltaSLen, double* deltaS)
394 {
395 // array getter: virtual void Kinetics::getDeltaSSEntropy(double*)
396 try {
397 auto& obj = KineticsCabinet::at(handle);
398 // no size checking specified
399 obj->getDeltaSSEntropy(deltaS);
400 return 0;
401 } catch (...) {
402 return handleAllExceptions(-1, ERR);
403 }
404 }
405
406 int32_t kin_del(int32_t handle)
407 {
408 // destructor
409 try {
410 KineticsCabinet::del(handle);
411 return 0;
412 } catch (...) {
413 return handleAllExceptions(-1, ERR);
414 }
415 }
416
418 {
419 // reserved CLib function: custom code
420 try {
421 // *************** begin custom code ***************
422 return KineticsCabinet::size();
423 // **************** end custom code ****************
424 } catch (...) {
425 return handleAllExceptions(-1, ERR);
426 }
427 }
428
429} // 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:341
int32_t kin_setMultiplier(int32_t handle, int32_t i, double f)
Set the multiplier for reaction i to f.
Definition ctkin.cpp:283
int32_t kin_del(int32_t handle)
Delete Kinetics object.
Definition ctkin.cpp:406
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:147
int32_t kin_getEquilibriumConstants(int32_t handle, int32_t kcLen, double *kc)
Return a vector of Equilibrium constants.
Definition ctkin.cpp:196
int32_t kin_getRevRatesOfProgress(int32_t handle, int32_t revROPLen, double *revROP)
Return the Reverse rates of progress of the reactions.
Definition ctkin.cpp:170
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:247
int32_t kin_advanceCoverages(int32_t handle, double tstep)
Advance the surface coverages in time.
Definition ctkin.cpp:317
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:222
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:354
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:328
int32_t kin_kineticsType(int32_t handle, int32_t bufLen, char *buf)
Identifies the Kinetics manager type.
Definition ctkin.cpp:47
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:234
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:367
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:380
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:260
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:137
int32_t kin_getFwdRatesOfProgress(int32_t handle, int32_t fwdROPLen, double *fwdROP)
Return the forward rates of progress of the reactions.
Definition ctkin.cpp:157
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:393
int32_t kin_getNetRatesOfProgress(int32_t handle, int32_t netROPLen, double *netROP)
Net rates of progress.
Definition ctkin.cpp:183
int32_t kin_isReversible(int32_t handle, int32_t i)
True if reaction i has been declared to be reversible.
Definition ctkin.cpp:294
int32_t kin_nTotalSpecies(int32_t handle)
The total number of species in all phases participating in the kinetics mechanism.
Definition ctkin.cpp:127
int32_t kin_nReactions(int32_t handle)
Number of reactions in the reaction mechanism.
Definition ctkin.cpp:59
int32_t kin_kineticsSpeciesIndex(int32_t handle, const char *nm)
Return the index of a species within the phases participating in this kinetic mechanism.
Definition ctkin.cpp:305
int32_t kin_getFwdRateConstants(int32_t handle, int32_t kfwdLen, double *kfwd)
Return the forward rate constants.
Definition ctkin.cpp:209
int32_t kin_cabinetSize()
Return size of Kinetics storage.
Definition ctkin.cpp:417
double kin_multiplier(int32_t handle, int32_t i)
The current value of the multiplier for reaction i.
Definition ctkin.cpp:273
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.