35template<> KineticsCabinet* KineticsCabinet::s_storage = 0;
38template<> ThermoPhaseCabinet* ThermoPhaseCabinet::s_storage;
41template<> ReactionCabinet* ReactionCabinet::s_storage;
51 string out = KineticsCabinet::at(handle)->kineticsType();
53 return int(out.size()) + 1;
63 return static_cast<int32_t
>(KineticsCabinet::at(handle)->nReactions());
73 if (i < 0 ||
static_cast<size_t>(i) >= KineticsCabinet::at(handle)->nReactions()) {
74 throw IndexError(
"kin_reaction",
"", i, KineticsCabinet::at(handle)->nReactions());
76 return ReactionCabinet::add(KineticsCabinet::at(handle)->reaction(i));
86 return static_cast<int32_t
>(KineticsCabinet::at(handle)->nPhases());
96 if (n < 0 ||
static_cast<size_t>(n) >= KineticsCabinet::at(handle)->nPhases()) {
97 throw IndexError(
"kin_phase",
"", n, KineticsCabinet::at(handle)->nPhases());
99 return ThermoPhaseCabinet::add(KineticsCabinet::at(handle)->phase(n));
109 return ThermoPhaseCabinet::add(KineticsCabinet::at(handle)->reactionPhase());
120 return static_cast<int32_t
>(KineticsCabinet::at(handle)->phaseIndex(ph,
true));
131 return static_cast<int32_t
>(KineticsCabinet::at(handle)->nTotalSpecies());
141 return KineticsCabinet::at(handle)->reactantStoichCoeff(k, i);
151 return KineticsCabinet::at(handle)->productStoichCoeff(k, i);
161 auto& obj = KineticsCabinet::at(handle);
163 span<double> fwdROP_(fwdROP, fwdROPLen);
164 obj->getFwdRatesOfProgress(fwdROP_);
175 auto& obj = KineticsCabinet::at(handle);
177 span<double> revROP_(revROP, revROPLen);
178 obj->getRevRatesOfProgress(revROP_);
189 auto& obj = KineticsCabinet::at(handle);
191 span<double> netROP_(netROP, netROPLen);
192 obj->getNetRatesOfProgress(netROP_);
203 auto& obj = KineticsCabinet::at(handle);
205 span<double> kc_(kc, kcLen);
206 obj->getEquilibriumConstants(kc_);
217 auto& obj = KineticsCabinet::at(handle);
219 span<double> kfwd_(kfwd, kfwdLen);
220 obj->getFwdRateConstants(kfwd_);
231 span<double> krev_(krev, krevLen);
232 bool doIrreversible_ = (doIrreversible != 0);
233 KineticsCabinet::at(handle)->getRevRateConstants(krev_, doIrreversible_);
244 auto& obj = KineticsCabinet::at(handle);
246 span<double> cdot_(cdot, cdotLen);
247 obj->getCreationRates(cdot_);
258 auto& obj = KineticsCabinet::at(handle);
260 span<double> ddot_(ddot, ddotLen);
261 obj->getDestructionRates(ddot_);
272 auto& obj = KineticsCabinet::at(handle);
274 span<double> wdot_(wdot, wdotLen);
275 obj->getNetProductionRates(wdot_);
286 auto& obj = KineticsCabinet::at(handle);
288 span<double> drop_(drop, dropLen);
289 obj->getFwdRatesOfProgress_ddT(drop_);
300 auto& obj = KineticsCabinet::at(handle);
302 span<double> drop_(drop, dropLen);
303 obj->getFwdRatesOfProgress_ddP(drop_);
314 auto& obj = KineticsCabinet::at(handle);
316 span<double> drop_(drop, dropLen);
317 obj->getFwdRatesOfProgress_ddC(drop_);
328 auto& obj = KineticsCabinet::at(handle);
330 span<double> drop_(drop, dropLen);
331 obj->getRevRatesOfProgress_ddT(drop_);
342 auto& obj = KineticsCabinet::at(handle);
344 span<double> drop_(drop, dropLen);
345 obj->getRevRatesOfProgress_ddP(drop_);
356 auto& obj = KineticsCabinet::at(handle);
358 span<double> drop_(drop, dropLen);
359 obj->getRevRatesOfProgress_ddC(drop_);
370 auto& obj = KineticsCabinet::at(handle);
372 span<double> drop_(drop, dropLen);
373 obj->getNetRatesOfProgress_ddT(drop_);
384 auto& obj = KineticsCabinet::at(handle);
386 span<double> drop_(drop, dropLen);
387 obj->getNetRatesOfProgress_ddP(drop_);
398 auto& obj = KineticsCabinet::at(handle);
400 span<double> drop_(drop, dropLen);
401 obj->getNetRatesOfProgress_ddC(drop_);
412 auto& obj = KineticsCabinet::at(handle);
414 span<double> dwdot_(dwdot, dwdotLen);
415 obj->getCreationRates_ddT(dwdot_);
426 auto& obj = KineticsCabinet::at(handle);
428 span<double> dwdot_(dwdot, dwdotLen);
429 obj->getCreationRates_ddP(dwdot_);
440 auto& obj = KineticsCabinet::at(handle);
442 span<double> dwdot_(dwdot, dwdotLen);
443 obj->getCreationRates_ddC(dwdot_);
454 auto& obj = KineticsCabinet::at(handle);
456 span<double> dwdot_(dwdot, dwdotLen);
457 obj->getDestructionRates_ddT(dwdot_);
468 auto& obj = KineticsCabinet::at(handle);
470 span<double> dwdot_(dwdot, dwdotLen);
471 obj->getDestructionRates_ddP(dwdot_);
482 auto& obj = KineticsCabinet::at(handle);
484 span<double> dwdot_(dwdot, dwdotLen);
485 obj->getDestructionRates_ddC(dwdot_);
496 auto& obj = KineticsCabinet::at(handle);
498 span<double> dwdot_(dwdot, dwdotLen);
499 obj->getNetProductionRates_ddT(dwdot_);
510 auto& obj = KineticsCabinet::at(handle);
512 span<double> dwdot_(dwdot, dwdotLen);
513 obj->getNetProductionRates_ddP(dwdot_);
524 auto& obj = KineticsCabinet::at(handle);
526 span<double> dwdot_(dwdot, dwdotLen);
527 obj->getNetProductionRates_ddC(dwdot_);
539 auto& obj = KineticsCabinet::at(handle);
540 auto mat = obj->netProductionRates_ddX();
541 int32_t rows =
static_cast<int32_t
>(mat.rows());
542 int32_t cols =
static_cast<int32_t
>(mat.cols());
543 int32_t need = rows * cols;
545 throw CanteraError(
"kin_getNetProductionRates_ddX",
"bufLen is too small");
547 for (int32_t idx = 0; idx < need; ++idx) {
550 for (
int k = 0; k < mat.outerSize(); ++k) {
551 for (Eigen::SparseMatrix<double>::InnerIterator it(mat, k); it; ++it) {
552 buf[it.col() * rows + it.row()] = it.value();
567 auto& obj = KineticsCabinet::at(handle);
568 auto mat = obj->netRatesOfProgress_ddX();
569 int32_t rows =
static_cast<int32_t
>(mat.rows());
570 int32_t cols =
static_cast<int32_t
>(mat.cols());
571 int32_t need = rows * cols;
573 throw CanteraError(
"kin_getNetRatesOfProgress_ddX",
"bufLen is too small");
575 for (int32_t idx = 0; idx < need; ++idx) {
578 for (
int k = 0; k < mat.outerSize(); ++k) {
579 for (Eigen::SparseMatrix<double>::InnerIterator it(mat, k); it; ++it) {
580 buf[it.col() * rows + it.row()] = it.value();
594 return KineticsCabinet::at(handle)->multiplier(i);
604 KineticsCabinet::at(handle)->setMultiplier(i, f);
615 bool out = KineticsCabinet::at(handle)->isReversible(i);
627 return static_cast<int32_t
>(KineticsCabinet::at(handle)->kineticsSpeciesIndex(nm,
true));
638 KineticsCabinet::as<InterfaceKinetics>(handle)->advanceCoverages(tstep);
649 auto& obj = KineticsCabinet::at(handle);
651 span<double> deltaH_(deltaH, deltaHLen);
652 obj->getDeltaEnthalpy(deltaH_);
663 auto& obj = KineticsCabinet::at(handle);
665 span<double> deltaG_(deltaG, deltaGLen);
666 obj->getDeltaGibbs(deltaG_);
677 auto& obj = KineticsCabinet::at(handle);
679 span<double> deltaS_(deltaS, deltaSLen);
680 obj->getDeltaEntropy(deltaS_);
691 auto& obj = KineticsCabinet::at(handle);
693 span<double> deltaH_(deltaH, deltaHLen);
694 obj->getDeltaSSEnthalpy(deltaH_);
705 auto& obj = KineticsCabinet::at(handle);
707 span<double> deltaG_(deltaG, deltaGLen);
708 obj->getDeltaSSGibbs(deltaG_);
719 auto& obj = KineticsCabinet::at(handle);
721 span<double> deltaS_(deltaS, deltaSLen);
722 obj->getDeltaSSEntropy(deltaS_);
733 KineticsCabinet::del(handle);
745 return KineticsCabinet::size();
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.
Base class for exceptions thrown by Cantera classes.
An array index is out of range.
CTKIN - Generated CLib Cantera interface library.
int32_t kin_getNetRatesOfProgress_ddC(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for net rates-of-progress with respect to molar concentration at constant tempe...
int32_t kin_getDeltaGibbs(int32_t handle, int32_t deltaGLen, double *deltaG)
Return the vector of values for the reaction Gibbs free energy change.
int32_t kin_setMultiplier(int32_t handle, int32_t i, double f)
Set the multiplier for reaction i to f.
int32_t kin_getRevRatesOfProgress_ddP(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for reverse rates-of-progress with respect to pressure at constant temperature,...
int32_t kin_getDestructionRates_ddC(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species destruction rates with respect to molar concentration at constant t...
int32_t kin_getNetProductionRates_ddT(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species net production rates with respect to temperature at constant pressu...
int32_t kin_del(int32_t handle)
Delete Kinetics object.
int32_t kin_reaction(int32_t handle, int32_t i)
Return the Reaction object for reaction i.
int32_t kin_getCreationRates_ddT(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species creation rates with respect to temperature at constant pressure,...
int32_t kin_nPhases(int32_t handle)
The number of phases participating in the reaction mechanism.
int32_t kin_reactionPhase(int32_t handle)
Return pointer to phase where the reactions occur.
int32_t kin_getFwdRatesOfProgress_ddC(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for forward rates-of-progress with respect to molar concentration at constant t...
double kin_productStoichCoeff(int32_t handle, int32_t k, int32_t i)
Stoichiometric coefficient of species k as a product in reaction i.
int32_t kin_getEquilibriumConstants(int32_t handle, int32_t kcLen, double *kc)
Get the vector of equilibrium constants in concentration units.
int32_t kin_getRevRatesOfProgress(int32_t handle, int32_t revROPLen, double *revROP)
Return the Reverse rates of progress of the reactions.
int32_t kin_getRevRatesOfProgress_ddT(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for reverse rates-of-progress with respect to temperature at constant pressure,...
int32_t kin_getDestructionRates(int32_t handle, int32_t ddotLen, double *ddot)
Species destruction rates [kmol/m^3/s or kmol/m^2/s].
int32_t kin_getNetProductionRates_ddX(int32_t handle, int32_t bufLen, double *buf)
Dense composition Jacobian d(net production rate)/dX, column-major (n x n).
int32_t kin_advanceCoverages(int32_t handle, double tstep)
Advance the surface coverages in time.
int32_t kin_getDestructionRates_ddT(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species destruction rates with respect to temperature at constant pressure,...
int32_t kin_phase(int32_t handle, int32_t n)
Return pointer to phase associated with Kinetics by index.
int32_t kin_getRevRateConstants(int32_t handle, int32_t krevLen, double *krev, int32_t doIrreversible)
Return the reverse rate constants.
int32_t kin_getNetProductionRates_ddP(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species net production rates with respect to pressure at constant temperatu...
int32_t kin_getDeltaEntropy(int32_t handle, int32_t deltaSLen, double *deltaS)
Return the vector of values for the reactions change in entropy.
int32_t kin_getCreationRates_ddP(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species creation rates with respect to pressure at constant temperature,...
int32_t kin_getDeltaEnthalpy(int32_t handle, int32_t deltaHLen, double *deltaH)
Return the vector of values for the reactions change in enthalpy.
int32_t kin_kineticsType(int32_t handle, int32_t bufLen, char *buf)
Identifies the Kinetics manager type.
int32_t kin_getCreationRates(int32_t handle, int32_t cdotLen, double *cdot)
Species creation rates [kmol/m^3/s or kmol/m^2/s].
int32_t kin_getNetRatesOfProgress_ddP(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for net rates-of-progress with respect to pressure at constant temperature,...
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.
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.
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.
int32_t kin_getNetRatesOfProgress_ddT(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for net rates-of-progress with respect to temperature at constant pressure,...
int32_t kin_getFwdRatesOfProgress_ddP(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for forward rates-of-progress with respect to pressure at constant temperature,...
int32_t kin_getDestructionRates_ddP(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species destruction rates with respect to pressure at constant temperature,...
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].
double kin_reactantStoichCoeff(int32_t handle, int32_t k, int32_t i)
Stoichiometric coefficient of species k as a reactant in reaction i.
int32_t kin_getFwdRatesOfProgress(int32_t handle, int32_t fwdROPLen, double *fwdROP)
Return the forward rates of progress of the reactions.
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.
int32_t kin_getNetRatesOfProgress(int32_t handle, int32_t netROPLen, double *netROP)
Net rates of progress.
int32_t kin_isReversible(int32_t handle, int32_t i)
True if reaction i has been declared to be reversible.
int32_t kin_getNetRatesOfProgress_ddX(int32_t handle, int32_t bufLen, double *buf)
Dense reaction composition Jacobian d(net rate of progress)/dX, column-major.
int32_t kin_getNetProductionRates_ddC(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species net production rates with respect to molar concentration at constan...
int32_t kin_nTotalSpecies(int32_t handle)
The total number of species in all phases participating in the kinetics mechanism.
int32_t kin_nReactions(int32_t handle)
Number of reactions in the reaction mechanism.
int32_t kin_kineticsSpeciesIndex(int32_t handle, const char *nm)
Return the index of a species within the phases participating in this kinetic mechanism.
int32_t kin_getRevRatesOfProgress_ddC(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for reverse rates-of-progress with respect to molar concentration at constant t...
int32_t kin_getFwdRateConstants(int32_t handle, int32_t kfwdLen, double *kfwd)
Return the forward rate constants.
int32_t kin_getCreationRates_ddC(int32_t handle, int32_t dwdotLen, double *dwdot)
Calculate derivatives for species creation rates with respect to molar concentration at constant temp...
int32_t kin_getFwdRatesOfProgress_ddT(int32_t handle, int32_t dropLen, double *drop)
Calculate derivatives for forward rates-of-progress with respect to temperature at constant pressure,...
int32_t kin_cabinetSize()
Return size of Kinetics storage.
double kin_multiplier(int32_t handle, int32_t i)
The current value of the multiplier for reaction i.
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.
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Contains declarations for string manipulation functions within Cantera.