Cantera  4.0.0a1
Loading...
Searching...
No Matches
ctreactornet.cpp
Go to the documentation of this file.
1/**
2 * CTREACTORNET - Generated CLib %Cantera interface library.
3 *
4 * @file ctreactornet.cpp
5 *
6 * Generated CLib API for Cantera's ReactorNet 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"
20
24
25using namespace Cantera;
26
27//! @cond
28//! Cabinet type definitions will be ignored by Doxygen
29
30// Define Cabinet<ReactorNet> (single-instance object)
31typedef Cabinet<ReactorNet> ReactorNetCabinet;
32template<> ReactorNetCabinet* ReactorNetCabinet::s_storage = 0; // initialized here
33
34typedef Cabinet<ReactorBase> ReactorBaseCabinet;
35template<> ReactorBaseCabinet* ReactorBaseCabinet::s_storage; // initialized elsewhere
36
37//! @endcond
38
39extern "C" {
40
41 int32_t reactornet_new(int32_t reactorsLen, int32_t* reactors)
42 {
43 // constructor: shared_ptr<ReactorNet> newReactorNet(span<shared_ptr<ReactorBase>>)
44 try {
45 vector<shared_ptr<ReactorBase>> reactors_;
46 for (int i = 0; i < reactorsLen; i++) {
47 reactors_.push_back(ReactorBaseCabinet::at(reactors[i]));
48 }
49 return ReactorNetCabinet::add(newReactorNet(reactors_));
50 } catch (...) {
51 return handleAllExceptions(-2, ERR);
52 }
53 }
54
55 int32_t reactornet_setInitialTime(int32_t handle, double time)
56 {
57 // setter: void ReactorNet::setInitialTime(double)
58 try {
59 ReactorNetCabinet::at(handle)->setInitialTime(time);
60 return 0;
61 } catch (...) {
62 return handleAllExceptions(-1, ERR);
63 }
64 }
65
66 int32_t reactornet_setMaxTimeStep(int32_t handle, double maxstep)
67 {
68 // setter: void ReactorNet::setMaxTimeStep(double)
69 try {
70 ReactorNetCabinet::at(handle)->setMaxTimeStep(maxstep);
71 return 0;
72 } catch (...) {
73 return handleAllExceptions(-1, ERR);
74 }
75 }
76
77 int32_t reactornet_setRelativeTolerance(int32_t handle, double rtol)
78 {
79 // setter: void ReactorNet::setRelativeTolerance(double)
80 try {
81 ReactorNetCabinet::at(handle)->setRelativeTolerance(rtol);
82 return 0;
83 } catch (...) {
84 return handleAllExceptions(-1, ERR);
85 }
86 }
87
88 int32_t reactornet_setAbsoluteTolerance(int32_t handle, double atol)
89 {
90 // setter: void ReactorNet::setAbsoluteTolerance(double)
91 try {
92 ReactorNetCabinet::at(handle)->setAbsoluteTolerance(atol);
93 return 0;
94 } catch (...) {
95 return handleAllExceptions(-1, ERR);
96 }
97 }
98
99 int32_t reactornet_clearAbsoluteTolerance(int32_t handle)
100 {
101 // method: void ReactorNet::clearAbsoluteTolerance()
102 try {
103 ReactorNetCabinet::at(handle)->clearAbsoluteTolerance();
104 return 0;
105 } catch (...) {
106 return handleAllExceptions(-1, ERR);
107 }
108 }
109
110 int32_t reactornet_setTolerances(int32_t handle, double rtol, double atol)
111 {
112 // method: void ReactorNet::setTolerances(double, double)
113 try {
114 ReactorNetCabinet::at(handle)->setTolerances(rtol, atol);
115 return 0;
116 } catch (...) {
117 return handleAllExceptions(-1, ERR);
118 }
119 }
120
121 int32_t reactornet_setSensitivityTolerances(int32_t handle, double rtol, double atol)
122 {
123 // method: void ReactorNet::setSensitivityTolerances(double, double)
124 try {
125 ReactorNetCabinet::at(handle)->setSensitivityTolerances(rtol, atol);
126 return 0;
127 } catch (...) {
128 return handleAllExceptions(-1, ERR);
129 }
130 }
131
132 int32_t reactornet_advance(int32_t handle, double t)
133 {
134 // setter: void ReactorNet::advance(double)
135 try {
136 ReactorNetCabinet::at(handle)->advance(t);
137 return 0;
138 } catch (...) {
139 return handleAllExceptions(-1, ERR);
140 }
141 }
142
143 double reactornet_step(int32_t handle)
144 {
145 // getter: double ReactorNet::step()
146 try {
147 return ReactorNetCabinet::at(handle)->step();
148 } catch (...) {
149 return handleAllExceptions(DERR, DERR);
150 }
151 }
152
153 double reactornet_time(int32_t handle)
154 {
155 // getter: double ReactorNet::time()
156 try {
157 return ReactorNetCabinet::at(handle)->time();
158 } catch (...) {
159 return handleAllExceptions(DERR, DERR);
160 }
161 }
162
163 double reactornet_rtol(int32_t handle)
164 {
165 // getter: double ReactorNet::rtol()
166 try {
167 return ReactorNetCabinet::at(handle)->rtol();
168 } catch (...) {
169 return handleAllExceptions(DERR, DERR);
170 }
171 }
172
173 double reactornet_atol(int32_t handle)
174 {
175 // getter: double ReactorNet::atol()
176 try {
177 return ReactorNetCabinet::at(handle)->atol();
178 } catch (...) {
179 return handleAllExceptions(DERR, DERR);
180 }
181 }
182
183 double reactornet_sensitivity(int32_t handle, const char* component, int32_t p, int32_t reactor)
184 {
185 // method: double ReactorNet::sensitivity(const string&, size_t, int)
186 try {
187 return ReactorNetCabinet::at(handle)->sensitivity(component, p, reactor);
188 } catch (...) {
189 return handleAllExceptions(DERR, DERR);
190 }
191 }
192
193 int32_t reactornet_del(int32_t handle)
194 {
195 // destructor
196 try {
197 ReactorNetCabinet::del(handle);
198 return 0;
199 } catch (...) {
200 return handleAllExceptions(-1, ERR);
201 }
202 }
203
205 {
206 // reserved CLib function: custom code
207 try {
208 // *************** begin custom code ***************
209 return ReactorNetCabinet::size();
210 // **************** end custom code ****************
211 } catch (...) {
212 return handleAllExceptions(-1, ERR);
213 }
214 }
215
216} // extern "C"
Template for classes to hold pointers to objects.
Definition Cabinet.h:51
CTREACTORNET - Generated CLib Cantera interface library.
int32_t reactornet_advance(int32_t handle, double t)
Advance the state of all reactors in the independent variable (time or space).
int32_t reactornet_setSensitivityTolerances(int32_t handle, double rtol, double atol)
Set the relative and absolute tolerances for integrating the sensitivity equations.
int32_t reactornet_setRelativeTolerance(int32_t handle, double rtol)
Set the relative tolerance for the integrator.
int32_t reactornet_clearAbsoluteTolerance(int32_t handle)
Clear the user-specified scalar absolute tolerance.
int32_t reactornet_setAbsoluteTolerance(int32_t handle, double atol)
Set the scalar absolute tolerance for the integrator.
double reactornet_time(int32_t handle)
Current value of the simulation time [s], for reactor networks that are solved in the time domain.
int32_t reactornet_cabinetSize()
Return size of ReactorNet storage.
int32_t reactornet_del(int32_t handle)
Delete ReactorNet object.
double reactornet_rtol(int32_t handle)
Relative tolerance.
double reactornet_step(int32_t handle)
Advance the state of all reactors with respect to the independent variable (time or space).
int32_t reactornet_new(int32_t reactorsLen, int32_t *reactors)
Create a reactor network containing one or more coupled reactors.
int32_t reactornet_setTolerances(int32_t handle, double rtol, double atol)
Set the relative and scalar absolute tolerances for the integrator.
int32_t reactornet_setInitialTime(int32_t handle, double time)
Set the initial value of the independent variable (typically time).
double reactornet_atol(int32_t handle)
Scalar absolute integration tolerance.
double reactornet_sensitivity(int32_t handle, const char *component, int32_t p, int32_t reactor)
Return the sensitivity of the component named component with respect to the p-th sensitivity paramete...
int32_t reactornet_setMaxTimeStep(int32_t handle, double maxstep)
Set the maximum integrator step.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
shared_ptr< ReactorNet > newReactorNet(span< shared_ptr< ReactorBase > > reactors)
Create a reactor network containing one or more coupled reactors.
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition clib_utils.h:32