forked from opencor/libopencor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsed.cpp
More file actions
210 lines (152 loc) · 13.5 KB
/
Copy pathsed.cpp
File metadata and controls
210 lines (152 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
Copyright libOpenCOR contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <libopencor>
#include <nanobind/stl/shared_ptr.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/vector.h>
namespace nb = nanobind;
void sedApi(nb::module_ &m)
{
// SedBase API.
nb::class_<libOpenCOR::SedBase, libOpenCOR::Logger> sedBase(m, "SedBase");
sedBase.def_prop_rw("id", &libOpenCOR::SedBase::id, &libOpenCOR::SedBase::setId, "The id of the SedBase object.");
// SedAbstractTask API.
nb::class_<libOpenCOR::SedAbstractTask, libOpenCOR::SedBase> sedAbstractTask(m, "SedAbstractTask");
// SedChange API.
nb::class_<libOpenCOR::SedChange, libOpenCOR::SedBase> sedChange(m, "SedChange");
sedChange.def_prop_ro("target", &libOpenCOR::SedChange::target, "Return the target of the SedChange object.");
// SedChangeAttribute API.
nb::class_<libOpenCOR::SedChangeAttribute, libOpenCOR::SedChange> sedChangeAttribute(m, "SedChangeAttribute");
sedChangeAttribute.def(nb::new_(&libOpenCOR::SedChangeAttribute::create), "Create a SedChangeAttribute object.", nb::arg("component"), nb::arg("variable"), nb::arg("new_value"))
.def_prop_rw("component_name", &libOpenCOR::SedChangeAttribute::componentName, &libOpenCOR::SedChangeAttribute::setComponentName, "The name of the component of the SedChangeAttribute object.")
.def_prop_rw("variable_name", &libOpenCOR::SedChangeAttribute::variableName, &libOpenCOR::SedChangeAttribute::setVariableName, "The name of the variable of the SedChangeAttribute object.")
.def_prop_rw("new_value", &libOpenCOR::SedChangeAttribute::newValue, &libOpenCOR::SedChangeAttribute::setNewValue, "The new value of the SedChangeAttribute object.");
// SedDataDescription API.
nb::class_<libOpenCOR::SedDataDescription, libOpenCOR::SedBase> sedDataDescription(m, "SedDataDescription");
// SedDataGenerator API.
nb::class_<libOpenCOR::SedDataGenerator, libOpenCOR::SedBase> sedDataGenerator(m, "SedDataGenerator");
// SedDocument API.
nb::class_<libOpenCOR::SedDocument, libOpenCOR::Logger> sedDocument(m, "SedDocument");
sedDocument.def(nb::new_([]() {
return libOpenCOR::SedDocument::create();
}),
"Create a SedDocument object.")
.def(nb::new_(&libOpenCOR::SedDocument::create), "Create a SedDocument object.", nb::arg("file").none())
.def("serialise", nb::overload_cast<>(&libOpenCOR::SedDocument::serialise, nb::const_), "Get the serialised version of this SedDocument object.")
.def("serialise", nb::overload_cast<const std::string &>(&libOpenCOR::SedDocument::serialise, nb::const_), "Get the serialised version of this SedDocument object.", nb::arg("base_path"))
.def_prop_ro("has_models", &libOpenCOR::SedDocument::hasModels, "Return whether there are some models.")
.def_prop_ro("model_count", &libOpenCOR::SedDocument::modelCount, "Return the number of models.")
.def_prop_ro("models", &libOpenCOR::SedDocument::models, "Return the models.")
.def("model", &libOpenCOR::SedDocument::model, "Return the model.")
.def("add_model", &libOpenCOR::SedDocument::addModel, "Add a model.", nb::arg("model").none())
.def("remove_model", &libOpenCOR::SedDocument::removeModel, "Remove a model.", nb::arg("model").none())
.def("remove_all_models", &libOpenCOR::SedDocument::removeAllModels, "Remove all models.")
.def_prop_ro("has_simulations", &libOpenCOR::SedDocument::hasSimulations, "Return whether there are some simulations.")
.def_prop_ro("simulation_count", &libOpenCOR::SedDocument::simulationCount, "Return the number of simulations.")
.def_prop_ro("simulations", &libOpenCOR::SedDocument::simulations, "Return the simulations.")
.def("simulation", &libOpenCOR::SedDocument::simulation, "Return the simulation.")
.def("add_simulation", &libOpenCOR::SedDocument::addSimulation, "Add a simulation.", nb::arg("simulation").none())
.def("remove_simulation", &libOpenCOR::SedDocument::removeSimulation, "Remove a simulation.", nb::arg("simulation").none())
.def("remove_all_simulations", &libOpenCOR::SedDocument::removeAllSimulations, "Remove all simulations.")
.def_prop_ro("has_tasks", &libOpenCOR::SedDocument::hasTasks, "Return whether there are some tasks.")
.def_prop_ro("task_count", &libOpenCOR::SedDocument::taskCount, "Return the number of tasks.")
.def_prop_ro("tasks", &libOpenCOR::SedDocument::tasks, "Return the tasks.")
.def("task", &libOpenCOR::SedDocument::task, "Return the task.")
.def("add_task", &libOpenCOR::SedDocument::addTask, "Add a task.", nb::arg("task").none())
.def("remove_task", &libOpenCOR::SedDocument::removeTask, "Remove a task.", nb::arg("task").none())
.def("remove_all_tasks", &libOpenCOR::SedDocument::removeAllTasks, "Remove all tasks.")
.def("instantiate", &libOpenCOR::SedDocument::instantiate, "Instantiate this SedDocument object.");
// SedInstance API.
nb::class_<libOpenCOR::SedInstance, libOpenCOR::Logger> sedInstance(m, "SedInstance");
sedInstance.def("run", &libOpenCOR::SedInstance::run, "Run the tasks associated with this SedInstance object.")
.def_prop_ro("has_tasks", &libOpenCOR::SedInstance::hasTasks, "Return whether there are some tasks.")
.def_prop_ro("task_count", &libOpenCOR::SedInstance::taskCount, "Return the number of tasks.")
.def_prop_ro("tasks", &libOpenCOR::SedInstance::tasks, "Return the tasks.")
.def("task", &libOpenCOR::SedInstance::task, "Return the task.")
.def("__len__", &libOpenCOR::SedInstance::taskCount)
.def("__iter__", [](const libOpenCOR::SedInstance &self) {
return nb::cast(self.tasks()).attr("__iter__")();
});
// SedInstanceTask API.
nb::class_<libOpenCOR::SedInstanceTask, libOpenCOR::Logger> sedInstanceTask(m, "SedInstanceTask");
sedInstanceTask.def_prop_ro("voi", &libOpenCOR::SedInstanceTask::voi, "Return the values of the variable of integration.")
.def_prop_ro("voi_name", &libOpenCOR::SedInstanceTask::voiName, "Return the name of the variable of integration.")
.def_prop_ro("voi_unit", &libOpenCOR::SedInstanceTask::voiUnit, "Return the unit of the variable of integration.")
.def_prop_ro("state_count", &libOpenCOR::SedInstanceTask::stateCount, "Return the number of states.")
.def("state", &libOpenCOR::SedInstanceTask::state, "Return the values of a state.")
.def("state_name", &libOpenCOR::SedInstanceTask::stateName, "Return the name of a state.")
.def("state_unit", &libOpenCOR::SedInstanceTask::stateUnit, "Return the unit of a state.")
.def_prop_ro("rate_count", &libOpenCOR::SedInstanceTask::rateCount, "Return the number of rates.")
.def("rate", &libOpenCOR::SedInstanceTask::rate, "Return the values of a rate.")
.def("rate_name", &libOpenCOR::SedInstanceTask::rateName, "Return the name of a rate.")
.def("rate_unit", &libOpenCOR::SedInstanceTask::rateUnit, "Return the unit of a rate.")
.def_prop_ro("constant_count", &libOpenCOR::SedInstanceTask::constantCount, "Return the number of constants.")
.def("constant", &libOpenCOR::SedInstanceTask::constant, "Return the values of a constant.")
.def("constant_name", &libOpenCOR::SedInstanceTask::constantName, "Return the name of a constant.")
.def("constant_unit", &libOpenCOR::SedInstanceTask::constantUnit, "Return the unit of a constant.")
.def_prop_ro("computed_constant_count", &libOpenCOR::SedInstanceTask::computedConstantCount, "Return the number of computed constants.")
.def("computed_constant", &libOpenCOR::SedInstanceTask::computedConstant, "Return the values of a computed constant.")
.def("computed_constant_name", &libOpenCOR::SedInstanceTask::computedConstantName, "Return the name of a computed constant.")
.def("computed_constant_unit", &libOpenCOR::SedInstanceTask::computedConstantUnit, "Return the unit of a computed constant.")
.def_prop_ro("algebraic_variable_count", &libOpenCOR::SedInstanceTask::algebraicVariableCount, "Return the number of algebraic variables.")
.def("algebraic_variable", &libOpenCOR::SedInstanceTask::algebraicVariable, "Return the values of an algebraic variable.")
.def("algebraic_variable_name", &libOpenCOR::SedInstanceTask::algebraicVariableName, "Return the name of an algebraic variable.")
.def("algebraic_variable_unit", &libOpenCOR::SedInstanceTask::algebraicVariableUnit, "Return the unit of an algebraic variable.");
// SedModel API.
nb::class_<libOpenCOR::SedModel, libOpenCOR::SedBase> sedModel(m, "SedModel");
sedModel.def(nb::new_(&libOpenCOR::SedModel::create), "Create a SedModel object.", nb::arg("document"), nb::arg("file"))
.def_prop_ro("file", &libOpenCOR::SedModel::file, "Return the file.")
.def_prop_ro("has_changes", &libOpenCOR::SedModel::hasChanges, "Return whether there are some changes.")
.def_prop_ro("change_count", &libOpenCOR::SedModel::changeCount, "Return the number of changes.")
.def_prop_ro("changes", &libOpenCOR::SedModel::changes, "Return the changes.")
.def("change", &libOpenCOR::SedModel::change, "Return the change.")
.def("add_change", &libOpenCOR::SedModel::addChange, "Add a change.", nb::arg("change").none())
.def("remove_change", &libOpenCOR::SedModel::removeChange, "Remove a change.", nb::arg("change").none())
.def("remove_all_changes", &libOpenCOR::SedModel::removeAllChanges, "Remove all changes.");
// SedOutput API.
nb::class_<libOpenCOR::SedOutput, libOpenCOR::SedBase>
sedOutput(m, "SedOutput");
// SedRepeatedTask API.
/*---GRY---
nb::class_<libOpenCOR::SedRepeatedTask, libOpenCOR::SedAbstractTask> sedRepeatedTask(m, "SedRepeatedTask");
sedRepeatedTask.def(nb::new_(&libOpenCOR::SedRepeatedTask::create), "Create a SedRepeatedTask object.", nb::arg("document"));
*/
// SedSimulation API.
nb::class_<libOpenCOR::SedSimulation, libOpenCOR::SedBase> sedSimulation(m, "SedSimulation");
sedSimulation.def_prop_rw("ode_solver", &libOpenCOR::SedSimulation::odeSolver, &libOpenCOR::SedSimulation::setOdeSolver, "The ODE solver for the SedSimulation object.", nb::arg("ode_solver").none())
.def_prop_rw("nla_solver", &libOpenCOR::SedSimulation::nlaSolver, &libOpenCOR::SedSimulation::setNlaSolver, "The NLA solver for the SedSimulation object.", nb::arg("nla_solver").none());
// SedAnalysis API.
nb::class_<libOpenCOR::SedAnalysis, libOpenCOR::SedSimulation> sedAnalysis(m, "SedAnalysis");
sedAnalysis.def(nb::new_(&libOpenCOR::SedAnalysis::create), "Create a SedAnalysis object.", nb::arg("document"));
// SedOneStep API.
nb::class_<libOpenCOR::SedOneStep, libOpenCOR::SedSimulation> sedOneStep(m, "SedOneStep");
sedOneStep.def(nb::new_(&libOpenCOR::SedOneStep::create), "Create a SedOneStep object.", nb::arg("document"))
.def_prop_rw("step", &libOpenCOR::SedOneStep::step, &libOpenCOR::SedOneStep::setStep, "The step of the SedOneStep object.");
// SedSteadyState API.
nb::class_<libOpenCOR::SedSteadyState, libOpenCOR::SedSimulation> sedSteadyState(m, "SedSteadyState");
sedSteadyState.def(nb::new_(&libOpenCOR::SedSteadyState::create), "Create a SedSteadyState object.", nb::arg("document"));
// SedUniformTimeCourse API.
nb::class_<libOpenCOR::SedUniformTimeCourse, libOpenCOR::SedSimulation> sedUniformTimeCourse(m, "SedUniformTimeCourse");
sedUniformTimeCourse.def(nb::new_(&libOpenCOR::SedUniformTimeCourse::create), "Create a SedUniformTimeCourse object.", nb::arg("document"))
.def_prop_rw("initial_time", &libOpenCOR::SedUniformTimeCourse::initialTime, &libOpenCOR::SedUniformTimeCourse::setInitialTime, "The initial time of the SedUniformTimeCourse object.")
.def_prop_rw("output_start_time", &libOpenCOR::SedUniformTimeCourse::outputStartTime, &libOpenCOR::SedUniformTimeCourse::setOutputStartTime, "The output start time of the SedUniformTimeCourse object.")
.def_prop_rw("output_end_time", &libOpenCOR::SedUniformTimeCourse::outputEndTime, &libOpenCOR::SedUniformTimeCourse::setOutputEndTime, "The output end time of the SedUniformTimeCourse object.")
.def_prop_rw("number_of_steps", &libOpenCOR::SedUniformTimeCourse::numberOfSteps, &libOpenCOR::SedUniformTimeCourse::setNumberOfSteps, "The number of steps of the SedUniformTimeCourse object.");
// SedStyle API.
nb::class_<libOpenCOR::SedStyle, libOpenCOR::SedBase> sedStyle(m, "SedStyle");
// SedTask API.
nb::class_<libOpenCOR::SedTask, libOpenCOR::SedAbstractTask> sedTask(m, "SedTask");
sedTask.def(nb::new_(&libOpenCOR::SedTask::create), "Create a SedTask object.", nb::arg("document"), nb::arg("model"), nb::arg("simulation"))
.def_prop_rw("model", &libOpenCOR::SedTask::model, &libOpenCOR::SedTask::setModel, "The model of the SedTask object.", nb::arg("model").none())
.def_prop_rw("simulation", &libOpenCOR::SedTask::simulation, &libOpenCOR::SedTask::setSimulation, "The simulation of the SedTask object.", nb::arg("simulation").none());
}