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