-
Notifications
You must be signed in to change notification settings - Fork 299
/
openmodelica_func.h
347 lines (296 loc) · 10.6 KB
/
openmodelica_func.h
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
* GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the OSMC (Open Source Modelica Consortium)
* Public License (OSMC-PL) are obtained from OSMC, either from the above
* address, from the URLs: http://www.openmodelica.org or
* http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica
* distribution. GNU version 3 is obtained from:
* http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from:
* http://www.opensource.org/licenses/BSD-3-Clause.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS
* EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE
* CONDITIONS OF OSMC-PL.
*
*/
/* File: modelica.h
* Description: This is the C header file for the C code generated from
* Modelica. It includes e.g. the C object representation of the builtin types
* and arrays, etc.
*/
#ifndef OPENMODELICAFUNC_H_
#define OPENMODELICAFUNC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "simulation_data.h"
#include "util/memory_pool.h"
#include "util/index_spec.h"
#include "util/boolean_array.h"
#include "util/integer_array.h"
#include "util/real_array.h"
#include "util/string_array.h"
#include "util/modelica_string.h"
#include "util/division.h"
#include "util/utility.h"
struct OpenModelicaGeneratedFunctionCallbacks {
/* Defined in perform_simulation.c and omp_perform_simulation.c */
int (*performSimulation)(DATA* data, threadData_t*, void* solverInfo);
int (*performQSSSimulation)(DATA* data, threadData_t*, void* solverInfo);
void (*updateContinuousSystem)(DATA *data, threadData_t*);
/* Function for calling external object constructors */
void (*callExternalObjectConstructors)(DATA *data, threadData_t*);
/* Function for calling external object deconstructors */
void (*callExternalObjectDestructors)(DATA *_data, threadData_t*);
/*! \fn initialNonLinearSystem
*
* This function initialize nonlinear system structure.
*
* \param [ref] [data]
*/
void (*initialNonLinearSystem)(int nNonLinearSystems, NONLINEAR_SYSTEM_DATA *data);
/*! \fn initialLinearSystem
*
* This function initialize nonlinear system structure.
*
* \param [ref] [data]
*/
void (*initialLinearSystem)(int nLinearSystems, LINEAR_SYSTEM_DATA *data);
/*! \fn initialNonLinearSystem
*
* This function initialize nonlinear system structure.
*
* \param [ref] [data]
*/
void (*initialMixedSystem)(int nMixedSystems, MIXED_SYSTEM_DATA *data);
/*! \fn initialNonLinearSystem
*
* This function initialize state set structure.
*
* \param [ref] [data]
*/
void (*initializeStateSets)(int nStateSets, STATE_SET_DATA* statesetData, DATA *data);
/*! \fn initializeDAEmodeData
*
* This function to initialize the daeMode data structure in Data
*
* \param [ref] [data]
*/
int (*initializeDAEmodeData)(DATA *data, DAEMODE_DATA* daeModeData);
/* functionODE contains those equations that are needed
* to calculate the dynamic part of the system */
int (*functionODE)(DATA *data, threadData_t*);
/* functionAlgebraics contains all continuous equations that
* are not part of the dynamic part of the system */
int (*functionAlgebraics)(DATA *data, threadData_t*);
/* function for calculating all equation sorting order
uses in EventHandle */
int (*functionDAE)(DATA *data, threadData_t*);
/* functions for input and output */
int (*input_function)(DATA*, threadData_t*);
int (*input_function_init)(DATA*, threadData_t*);
int (*input_function_updateStartValues)(DATA*, threadData_t*);
int (*output_function)(DATA*, threadData_t*);
/* function for storing value histories of delayed expressions
* called from functionDAE_output()
*/
int (*function_storeDelayed)(DATA *data, threadData_t*);
/*! \fn updateBoundVariableAttributes
*
* This function updates all bound start, nominal, min, and max values.
*
* \param [ref] [data]
*/
int (*updateBoundVariableAttributes)(DATA *data, threadData_t*);
/*! \var useHomotopy
*
* is 1 if homotopy(...) is used during initialization, otherwise 0
*/
const int useHomotopy;
/*! \fn functionInitialEquations
*
* function for calculate initial values from the initial equations and initial algorithms
*
* \param [ref] [data]
*/
int (*functionInitialEquations)(DATA *data, threadData_t*);
/*! \fn functionInitialEquations_lambda0
*
* function for calculate initial values from the initial equations and initial algorithms
*
* \param [ref] [data]
*/
int (*functionInitialEquations_lambda0)(DATA *data, threadData_t*);
/*! \fn functionRemovedInitialEquations
*
* This function contains removed equations from the initialization problem,
* which need to be checked to verify the consistency of the initialization
* problem.
*
* \param [ref] [data]
*/
int (*functionRemovedInitialEquations)(DATA *data, threadData_t*);
/*! \fn updateBoundParameters
*
* This function calculates bound parameters that depend on other parameters,
* e.g. parameter Real n=1/m;
* obsolete: bound_parameters
*
* \param [ref] [data]
*/
int (*updateBoundParameters)(DATA *data, threadData_t*);
/* function for checking for asserts and terminate */
int (*checkForAsserts)(DATA *data, threadData_t*);
/*! \fn function_ZeroCrossingsEquations
*
* This function updates all equations to evaluate function_ZeroCrossings
*
* \param [ref] [data]
*/
int (*function_ZeroCrossingsEquations)(DATA *data, threadData_t*);
/*! \fn function_ZeroCrossings
*
* This function evaluates if a sign change occurs at the current state
*
* \param [ref] [data]
* \param [ref] [gout]
*/
int (*function_ZeroCrossings)(DATA *data, threadData_t*, double* gout);
/*! \fn function_updateRelations
*
* This function evaluates current continuous relations.
*
* \param [ref] [data]
* \param [in] [evalZeroCross] flag for evaluating Relation with hysteresis
* function or without
*/
int (*function_updateRelations)(DATA *data, threadData_t*, int evalZeroCross);
/*! \fn checkForDiscreteChanges
*
* This function checks if any discrete variable changed
*
* \param [ref] [data]
*/
int (*checkForDiscreteChanges)(DATA *data, threadData_t*);
/*! \var zeroCrossingDescription
*
* This variable contains a description string for zero crossing condition.
*/
const char *(*zeroCrossingDescription)(int i, int **out_EquationIndexes);
/*! \var relationDescription
*
* This variable contains a description string for continuous relations.
*/
const char *(*relationDescription)(int i);
/*! \fn function_initSample
*
* This function initialize the sample-info struct.
*
* \param [ref] [data]
*/
void (*function_initSample)(DATA *data, threadData_t*);
/* function for calculation Jacobian */
/*#ifdef D_OMC_JACOBIAN*/
const int INDEX_JAC_A;
const int INDEX_JAC_B;
const int INDEX_JAC_C;
const int INDEX_JAC_D;
/*
* These functions initialize specific jacobians.
* Return-value 0: jac is present
* Return-value 1: jac is not present
*/
int (*initialAnalyticJacobianA)(void* data, threadData_t *threadData);
int (*initialAnalyticJacobianB)(void* data, threadData_t *threadData);
int (*initialAnalyticJacobianC)(void* data, threadData_t *threadData);
int (*initialAnalyticJacobianD)(void* data, threadData_t *threadData);
/*
* These functions calculate specific jacobian column.
*/
int (*functionJacA_column)(void* data, threadData_t *threadData);
int (*functionJacB_column)(void* data, threadData_t *threadData);
int (*functionJacC_column)(void* data, threadData_t *threadData);
int (*functionJacD_column)(void* data, threadData_t *threadData);
/*#endif*/
const char *(*linear_model_frame)(void); /* printf format-string with holes for 6 strings */
const char *(*linear_model_datarecovery_frame)(void); /* printf format-string with holes for 9 strings */
/*
* This function is used only for optimization purpose
* and calculates the mayer term. In case it's not present
* a dummy function is added which return -1.
*/
int (*mayer)(DATA* data, modelica_real** res, short *);
/*
* This function is used only for optimization purpose
* and calculates the lagrange term. In case it's not present
* a dummy function is added which return -1.
*/
int (*lagrange)(DATA* data, modelica_real** res, short *, short *);
/*
* This function is used only for optimization purpose
* and pick up the bounds of inputs. In case it's not present
* a dummy function is added which return -1.
*/
int (*pickUpBoundsForInputsInOptimization)(DATA* data, modelica_real* min, modelica_real* max, modelica_real*nominal,
modelica_boolean *useNominal, char ** name, modelica_real * start, modelica_real * startTimeOpt);
/*
* This function is used only for optimization purpose
* and set simulationInfo->inputVars. In case it's not present
* a dummy function is added which return -1.
*/
int (*setInputData)(DATA* data, const modelica_boolean file);
/*
* This function is used only for optimization purpose
* and return the time gride. In case it's not present
* a dummy function is added which return -1.
*/
int (*getTimeGrid)(DATA *data, modelica_integer * nsi, modelica_real**t);
/*
* update parameter for symEuler
*/
int (*symEulerUpdate)(DATA * data, modelica_real dt);
/*
* initialize clocks and subclocks info in modelData
*/
void (*function_initSynchronous)(DATA * data, threadData_t *threadData);
/*
* Update clock interval.
*/
void (*function_updateSynchronous)(DATA *data, threadData_t *threadData, long i);
/*
* Sub-partition's equations
*/
int (*function_equationsSynchronous)(DATA *data, threadData_t *threadData, long i);
/*
* FMU's do not need the XML-file; they use this callback instead.
*/
void (*read_input_fmu)(MODEL_DATA* modelData, SIMULATION_INFO* simulationData);
/*
* return input names
*/
int (*inputNames)(DATA* modelData, char ** names);
#ifdef FMU_EXPERIMENTAL
/* functionODEPartial contains those equations that are needed
* to calculate the state derivative i-th */
void (*functionODEPartial)(DATA *data, threadData_t*, int i);
void (*functionFMIJacobian)(DATA *data, threadData_t*, const unsigned *unknown, int nUnk, const unsigned *ders, int nKnown, double *dvKnown, double *out);
#endif
};
#ifdef __cplusplus
}
#endif
#endif