/
SimCodeTV.mo
3636 lines (3154 loc) · 93.3 KB
/
SimCodeTV.mo
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
interface package SimCodeTV
package builtin
function listReverse
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
output list<TypeVar> result;
end listReverse;
function listLength "Return the length of the list"
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
output Integer result;
end listLength;
function listGet
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
input Integer ix;
output TypeVar result;
end listGet;
function intAdd
input Integer a;
input Integer b;
output Integer c;
end intAdd;
function boolAnd
input Boolean b1;
input Boolean b2;
output Boolean b;
end boolAnd;
function boolOr
input Boolean a;
input Boolean b;
output Boolean c;
end boolOr;
function boolNot
input Boolean b;
output Boolean nb;
end boolNot;
function intMax
input Integer a;
input Integer b;
output Integer c;
end intMax;
function intSub
input Integer a;
input Integer b;
output Integer c;
end intSub;
function intMul
input Integer a;
input Integer b;
output Integer c;
end intMul;
function intDiv
input Integer a;
input Integer b;
output Integer c;
end intDiv;
function intEq
input Integer a;
input Integer b;
output Boolean c;
end intEq;
function intNe
input Integer a;
input Integer b;
output Boolean c;
end intNe;
function intGt
input Integer i1;
input Integer i2;
output Boolean b;
end intGt;
function intLt
input Integer i1;
input Integer i2;
output Boolean b;
end intLt;
function realInt
input Real r;
output Integer i;
end realInt;
function arrayList
replaceable type TypeVar subtypeof Any;
input array<TypeVar> arr;
output list<TypeVar> lst;
end arrayList;
function arrayGet
replaceable type TypeVar subtypeof Any;
input array<TypeVar> arr;
input Integer index;
output TypeVar value;
end arrayGet;
function arrayLength
replaceable type TypeVar subtypeof Any;
input array<TypeVar> arr;
output Integer length;
end arrayLength;
function stringEq
input String s1;
input String s2;
output Boolean b;
end stringEq;
function stringInt
input String s1;
output Integer i;
end stringInt;
function listAppend
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
input list<TypeVar> lst1;
output list<TypeVar> result;
end listAppend;
function realDiv
input Real x;
input Real y;
output Real z;
end realDiv;
function listGet
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
input Integer index;
output TypeVar result;
end listGet;
function stringLength
input String str;
output Integer length;
end stringLength;
function stringGet
input String str;
input Integer index;
output Integer ch;
end stringGet;
function listHead
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
output TypeVar head;
end listHead;
uniontype SourceInfo "The Info attribute provides location information for elements and classes."
record SOURCEINFO
String fileName;
Boolean isReadOnly;
Integer lineNumberStart;
Integer columnNumberStart;
Integer lineNumberEnd;
Integer columnNumberEnd;
Real lastModification;
end SOURCEINFO;
end SourceInfo;
end builtin;
package SimCodeVar
uniontype SimVars
record SIMVARS
list<SimVar> stateVars;
list<SimVar> derivativeVars;
list<SimVar> algVars;
list<SimVar> discreteAlgVars;
list<SimVar> intAlgVars;
list<SimVar> boolAlgVars;
list<SimVar> inputVars;
list<SimVar> outputVars;
list<SimVar> aliasVars;
list<SimVar> intAliasVars;
list<SimVar> boolAliasVars;
list<SimVar> paramVars;
list<SimVar> intParamVars;
list<SimVar> boolParamVars;
list<SimVar> stringAlgVars;
list<SimVar> stringParamVars;
list<SimVar> stringAliasVars;
list<SimVar> extObjVars;
list<SimVar> constVars;
list<SimVar> intConstVars;
list<SimVar> boolConstVars;
list<SimVar> stringConstVars;
list<SimVar> jacobianVars;
list<SimVar> realOptimizeConstraintsVars;
list<SimVar> realOptimizeFinalConstraintsVars;
list<SimCodeVar.SimVar> mixedArrayVars;
end SIMVARS;
end SimVars;
uniontype SimVar
record SIMVAR
DAE.ComponentRef name;
BackendDAE.VarKind varKind;
String comment;
String unit;
String displayUnit;
Integer index;
Option<DAE.Exp> minValue;
Option<DAE.Exp> maxValue;
Option<DAE.Exp> initialValue;
Option<DAE.Exp> nominalValue;
Boolean isFixed;
DAE.Type type_;
Boolean isDiscrete;
Option<DAE.ComponentRef> arrayCref;
AliasVariable aliasvar;
DAE.ElementSource source;
Causality causality;
Option<Integer> variable_index;
list<String> numArrayElement;
Boolean isValueChangeable;
Boolean isProtected;
end SIMVAR;
end SimVar;
uniontype AliasVariable
record NOALIAS end NOALIAS;
record ALIAS
DAE.ComponentRef varName;
end ALIAS;
record NEGATEDALIAS
DAE.ComponentRef varName;
end NEGATEDALIAS;
end AliasVariable;
uniontype Causality
record NONECAUS end NONECAUS;
record INTERNAL end INTERNAL;
record OUTPUT end OUTPUT;
record INPUT end INPUT;
end Causality;
end SimCodeVar;
package SimCode
type ExtConstructor = tuple<DAE.ComponentRef, String, list<DAE.Exp>>;
type ExtDestructor = tuple<String, DAE.ComponentRef>;
type ExtAlias = tuple<DAE.ComponentRef, DAE.ComponentRef>;
type JacobianColumn = tuple<list<SimEqSystem>, list<SimCodeVar.SimVar>, String>; // column equations, column vars, column length
type JacobianMatrix = tuple<list<JacobianColumn>, // column
list<SimCodeVar.SimVar>, // seed vars
String, // matrix name
tuple<list< tuple<Integer, list<Integer>>>,list< tuple<Integer, list<Integer>>>>, // sparse pattern
list<list<Integer>>, // colored cols
Integer, // max color used
Integer>; // jacobian index
uniontype SimCode
record SIMCODE
ModelInfo modelInfo;
list<DAE.Exp> literals;
list<RecordDeclaration> recordDecls;
list<String> externalFunctionIncludes;
list<SimEqSystem> allEquations;
list<list<SimEqSystem>> odeEquations;
list<list<SimEqSystem>> algebraicEquations;
Boolean useSymbolicInitialization; // true if a system to solve the initial problem symbolically is generated, otherwise false
Boolean useHomotopy; // true if homotopy(...) is used during initialization
list<SimEqSystem> initialEquations;
list<SimEqSystem> removedInitialEquations;
list<SimEqSystem> startValueEquations;
list<SimEqSystem> nominalValueEquations;
list<SimEqSystem> minValueEquations;
list<SimEqSystem> maxValueEquations;
list<SimEqSystem> parameterEquations;
list<SimEqSystem> removedEquations;
list<SimEqSystem> algorithmAndEquationAsserts;
list<SimEqSystem> equationsForZeroCrossings;
list<SimEqSystem> jacobianEquations;
//list<DAE.Statement> algorithmAndEquationAsserts;
list<StateSet> stateSets;
list<DAE.Constraint> constraints;
list<DAE.ClassAttributes> classAttributes;
list<BackendDAE.ZeroCrossing> zeroCrossings;
list<BackendDAE.ZeroCrossing> relations;
list<BackendDAE.TimeEvent> timeEvents;
list<SimWhenClause> whenClauses;
list<DAE.ComponentRef> discreteModelVars;
ExtObjInfo extObjInfo;
MakefileParams makefileParams;
DelayedExpression delayedExps;
list<JacobianMatrix> jacobianMatrixes;
Option<SimulationSettings> simulationSettingsOpt;
String fileNamePrefix;
HpcOmSimCode.HpcOmData hpcomData;
HashTableCrIListArray.HashTable varToArrayIndexMapping;
Option<FmiModelStructure> modelStructure;
end SIMCODE;
end SimCode;
uniontype DelayedExpression
record DELAYED_EXPRESSIONS
list<tuple<Integer, tuple<DAE.Exp, DAE.Exp, DAE.Exp>>> delayedExps;
Integer maxDelayedIndex;
end DELAYED_EXPRESSIONS;
end DelayedExpression;
uniontype FunctionCode
record FUNCTIONCODE
String name;
Option<Function> mainFunction;
list<Function> functions;
list<DAE.Exp> literals;
list<String> externalFunctionIncludes;
MakefileParams makefileParams;
list<RecordDeclaration> extraRecordDecls;
end FUNCTIONCODE;
end FunctionCode;
uniontype MakefileParams
record MAKEFILE_PARAMS
String ccompiler;
String cxxcompiler;
String linker;
String exeext;
String dllext;
String omhome;
String cflags;
String ldflags;
String runtimelibs;
list<String> includes;
list<String> libs;
list<String> libPaths;
String platform;
String compileDir;
end MAKEFILE_PARAMS;
end MakefileParams;
uniontype SimulationSettings
record SIMULATION_SETTINGS
Real startTime;
Real stopTime;
Integer numberOfIntervals;
Real stepSize;
Real tolerance;
String method;
String options;
String outputFormat;
String variableFilter;
String cflags;
end SIMULATION_SETTINGS;
end SimulationSettings;
uniontype Context
record SIMULATION_CONTEXT
Boolean genDiscrete;
end SIMULATION_CONTEXT;
record FUNCTION_CONTEXT
end FUNCTION_CONTEXT;
record JACOBIAN_CONTEXT
end JACOBIAN_CONTEXT;
record ALGLOOP_CONTEXT
Boolean genInitialisation;
Boolean genJacobian;
end ALGLOOP_CONTEXT;
record OTHER_CONTEXT
end OTHER_CONTEXT;
record PARALLEL_FUNCTION_CONTEXT
end PARALLEL_FUNCTION_CONTEXT;
record ZEROCROSSINGS_CONTEXT
end ZEROCROSSINGS_CONTEXT;
record OPTIMIZATION_CONTEXT
end OPTIMIZATION_CONTEXT;
record FMI_CONTEXT
end FMI_CONTEXT;
end Context;
uniontype Variable
record VARIABLE
DAE.ComponentRef name;
DAE.Type ty;
Option<DAE.Exp> value;
list<DAE.Exp> instDims;
DAE.VarParallelism parallelism;
DAE.VarKind kind;
end VARIABLE;
record FUNCTION_PTR
String name;
list<DAE.Type> tys;
list<Variable> args;
Option<DAE.Exp> defaultValue;
end FUNCTION_PTR;
end Variable;
uniontype Statement
record ALGORITHM
list<DAE.Statement> statementLst;
end ALGORITHM;
end Statement;
uniontype ExtObjInfo
record EXTOBJINFO
list<SimCodeVar.SimVar> vars;
list<ExtAlias> aliases;
end EXTOBJINFO;
end ExtObjInfo;
uniontype SimEqSystem
record SES_RESIDUAL
Integer index;
DAE.Exp exp;
DAE.ElementSource source;
end SES_RESIDUAL;
record SES_SIMPLE_ASSIGN
Integer index;
DAE.ComponentRef cref;
DAE.Exp exp;
DAE.ElementSource source;
end SES_SIMPLE_ASSIGN;
record SES_ARRAY_CALL_ASSIGN
Integer index;
DAE.Exp lhs;
DAE.Exp exp;
DAE.ElementSource source;
end SES_ARRAY_CALL_ASSIGN;
record SES_IFEQUATION
Integer index;
list<tuple<DAE.Exp,list<SimEqSystem>>> ifbranches;
list<SimEqSystem> elsebranch;
DAE.ElementSource source;
end SES_IFEQUATION;
record SES_ALGORITHM
Integer index;
list<DAE.Statement> statements;
end SES_ALGORITHM;
record SES_LINEAR
Integer index;
Boolean partOfMixed;
list<SimCodeVar.SimVar> vars;
list<DAE.Exp> beqs;
list<tuple<Integer, Integer, SimEqSystem>> simJac;
/* solver linear tearing system */
list<SimEqSystem> residual;
Option<JacobianMatrix> jacobianMatrix;
list<DAE.ElementSource> sources;
Integer indexLinearSystem;
end SES_LINEAR;
record SES_NONLINEAR
Integer index;
list<SimEqSystem> eqs;
list<DAE.ComponentRef> crefs;
Integer indexNonLinearSystem;
Option<JacobianMatrix> jacobianMatrix;
Boolean linearTearing;
Boolean homotopySupport;
Boolean mixedSystem;
end SES_NONLINEAR;
record SES_MIXED
Integer index;
SimEqSystem cont;
list<SimCodeVar.SimVar> discVars;
list<SimEqSystem> discEqs;
Integer indexMixedSystem;
end SES_MIXED;
record SES_WHEN
Integer index;
list<DAE.ComponentRef> conditions; // list of boolean variables as conditions
Boolean initialCall; // true, if top-level branch with initial()
DAE.ComponentRef left;
DAE.Exp right;
Option<SimEqSystem> elseWhen;
DAE.ElementSource source;
end SES_WHEN;
record SES_FOR_LOOP
Integer index;
DAE.Exp iter;
DAE.Exp startIt;
DAE.Exp endIt;
DAE.ComponentRef cref;//lhs
DAE.Exp exp;//rhs
DAE.ElementSource source;
end SES_FOR_LOOP;
end SimEqSystem;
uniontype StateSet
record SES_STATESET
Integer index;
Integer nCandidates;
Integer nStates;
list<DAE.ComponentRef> states;
list<DAE.ComponentRef> statescandidates;
DAE.ComponentRef crA;
JacobianMatrix jacobianMatrix;
end SES_STATESET;
end StateSet;
uniontype SimWhenClause
record SIM_WHEN_CLAUSE
list<DAE.ComponentRef> conditionVars; // is no longer needed
list<DAE.ComponentRef> conditions; // list of boolean variables as conditions
Boolean initialCall; // true, if top-level branch with initial()
list<BackendDAE.WhenOperator> reinits;
Option<BackendDAE.WhenEquation> whenEq;
end SIM_WHEN_CLAUSE;
end SimWhenClause;
uniontype ModelInfo
record MODELINFO
Absyn.Path name;
String description;
String directory;
VarInfo varInfo;
SimCodeVar.SimVars vars;
list<Function> functions;
list<String> labels;
end MODELINFO;
end ModelInfo;
uniontype VarInfo
record VARINFO
Integer numZeroCrossings;
Integer numTimeEvents;
Integer numRelations;
Integer numMathEventFunctions;
Integer numStateVars;
Integer numAlgVars;
Integer numDiscreteReal;
Integer numIntAlgVars;
Integer numBoolAlgVars;
Integer numAlgAliasVars;
Integer numIntAliasVars;
Integer numBoolAliasVars;
Integer numParams;
Integer numIntParams;
Integer numBoolParams;
Integer numOutVars;
Integer numInVars;
Integer numExternalObjects;
Integer numStringAlgVars;
Integer numStringParamVars;
Integer numStringAliasVars;
Integer numEquations;
Integer numLinearSystems;
Integer numNonLinearSystems;
Integer numMixedSystems;
Integer numStateSets;
Integer numJacobians;
Integer numOptimizeConstraints;
Integer numOptimizeFinalConstraints;
end VARINFO;
end VarInfo;
uniontype Function
record FUNCTION
Absyn.Path name;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
list<Statement> body;
SCode.Visibility visibility;
builtin.SourceInfo info;
end FUNCTION;
record PARALLEL_FUNCTION
Absyn.Path name;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
list<Statement> body;
builtin.SourceInfo info;
end PARALLEL_FUNCTION;
record KERNEL_FUNCTION
Absyn.Path name;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
list<Statement> body;
builtin.SourceInfo info;
end KERNEL_FUNCTION;
record EXTERNAL_FUNCTION
Absyn.Path name;
String extName;
list<Variable> funArgs;
list<SimExtArg> extArgs;
SimExtArg extReturn;
list<Variable> inVars;
list<Variable> outVars;
list<Variable> biVars;
list<String> includes;
list<String> libs;
String language;
builtin.SourceInfo info;
SCode.Visibility visibility;
Boolean dynamicLoad;
end EXTERNAL_FUNCTION;
record RECORD_CONSTRUCTOR
Absyn.Path name;
list<Variable> funArgs;
list<Variable> locals;
builtin.SourceInfo info;
SCode.Visibility visibility;
DAE.VarKind kind;
end RECORD_CONSTRUCTOR;
end Function;
uniontype RecordDeclaration
record RECORD_DECL_FULL
String name;
Option<String> aliasName;
Absyn.Path defPath;
list<Variable> variables;
end RECORD_DECL_FULL;
record RECORD_DECL_DEF
Absyn.Path path;
list<String> fieldNames;
end RECORD_DECL_DEF;
end RecordDeclaration;
uniontype SimExtArg
record SIMEXTARG
DAE.ComponentRef cref;
Boolean isInput;
Integer outputIndex;
Boolean isArray;
Boolean hasBinding;
DAE.Type type_;
end SIMEXTARG;
record SIMEXTARGEXP
DAE.Exp exp;
DAE.Type type_;
end SIMEXTARGEXP;
record SIMEXTARGSIZE
DAE.ComponentRef cref;
Boolean isInput;
Integer outputIndex;
DAE.Type type_;
DAE.Exp exp;
end SIMEXTARGSIZE;
record SIMNOEXTARG end SIMNOEXTARG;
end SimExtArg;
uniontype FmiUnknown
record FMIUNKNOWN
Integer index;
list<Integer> dependencies;
list<String> dependenciesKind;
end FMIUNKNOWN;
end FmiUnknown;
uniontype FmiOutputs
record FMIOUTPUTS
list<FmiUnknown> fmiUnknownsList;
end FMIOUTPUTS;
end FmiOutputs;
uniontype FmiDerivatives
record FMIDERIVATIVES
list<FmiUnknown> fmiUnknownsList;
end FMIDERIVATIVES;
end FmiDerivatives;
uniontype FmiInitialUnknowns
record FMIINITIALUNKNOWNS
list<FmiUnknown> fmiUnknownsList;
end FMIINITIALUNKNOWNS;
end FmiInitialUnknowns;
uniontype FmiModelStructure
record FMIMODELSTRUCTURE
FmiOutputs fmiOutputs;
FmiDerivatives fmiDerivatives;
FmiInitialUnknowns fmiInitialUnknowns;
end FMIMODELSTRUCTURE;
end FmiModelStructure;
constant Context contextSimulationNonDiscrete;
constant Context contextSimulationDiscrete;
constant Context contextFunction;
constant Context contextOther;
constant Context contextAlgloopJacobian;
constant Context contextAlgloop;
constant Context contextJacobian;
constant Context contextAlgloopInitialisation;
constant Context contextParallelFunction;
constant Context contextZeroCross;
constant Context contextOptimization;
constant Context contextFMI;
constant list<DAE.Exp> listExpLength1;
constant list<Variable> boxedRecordOutVars;
end SimCode;
package SimCodeUtil
function elementVars
input list<DAE.Element> ld;
output list<SimCode.Variable> vars;
end elementVars;
function crefSubIsScalar
input DAE.ComponentRef cref;
output Boolean isScalar;
end crefSubIsScalar;
function crefNoSub
input DAE.ComponentRef cref;
output Boolean noSub;
end crefNoSub;
function crefIsScalar
input DAE.ComponentRef cref;
input SimCode.Context context;
output Boolean isScalar;
end crefIsScalar;
function buildCrefExpFromAsub
input DAE.Exp cref;
input list<DAE.Exp> subs;
output DAE.Exp cRefOut;
end buildCrefExpFromAsub;
function incrementInt
input Integer inInt;
input Integer increment;
output Integer outInt;
end incrementInt;
function decrementInt
input Integer inInt;
input Integer decrement;
output Integer outInt;
end decrementInt;
function isProtected
input SimCodeVar.SimVar simVar;
output Boolean isProtected;
end isProtected;
function protectedVars
input list<SimCodeVar.SimVar> InSimVars;
output list<SimCodeVar.SimVar> OutSimVars;
end protectedVars;
function makeCrefRecordExp
input DAE.ComponentRef inCRefRecord;
input DAE.Var inVar;
output DAE.Exp outExp;
end makeCrefRecordExp;
function cref2simvar
input DAE.ComponentRef cref;
input SimCode.SimCode simCode;
output SimCodeVar.SimVar outSimVar;
end cref2simvar;
function isModelTooBigForCSharpInOneFile
input SimCode.SimCode simCode;
output Boolean outIsTooBig;
end isModelTooBigForCSharpInOneFile;
function derComponentRef
input DAE.ComponentRef inCref;
output DAE.ComponentRef derCref;
end derComponentRef;
function hackArrayReverseToCref
input DAE.Exp inExp;
input SimCode.Context context;
output DAE.Exp outExp;
end hackArrayReverseToCref;
function hackGetFirstExternalFunctionLib
input list<String> libs;
output String outFirstLib;
end hackGetFirstExternalFunctionLib;
function hackMatrixReverseToCref
input DAE.Exp inExp;
input SimCode.Context context;
output DAE.Exp outExp;
end hackMatrixReverseToCref;
function createArray
input Integer size;
output DAE.Exp outArray;
end createArray;
function createAssertforSqrt
input DAE.Exp inExp;
output DAE.Exp outExp;
end createAssertforSqrt;
function appendLists
input list<SimCode.SimEqSystem> inEqn1;
input list<SimCode.SimEqSystem> inEqn2;
output list<SimCode.SimEqSystem> outEqn;
end appendLists;
function createDAEString
input String inString;
output DAE.Exp outExp;
end createDAEString;
function isBoxedFunction
input SimCode.Function fn;
output Boolean b;
end isBoxedFunction;
function functionInfo
input SimCode.Function fn;
output builtin.SourceInfo info;
end functionInfo;
function twodigit
input Integer i;
output String s;
end twodigit;
function countDynamicExternalFunctions
input list<SimCode.Function> inFncLst;
output Integer outDynLoadFuncs;
end countDynamicExternalFunctions;
function eqInfo
input SimCode.SimEqSystem eq;
output builtin.SourceInfo info;
end eqInfo;
function varName
input SimCodeVar.SimVar var;
output DAE.ComponentRef cr;
end varName;
function dimsToAllIndexes
input DAE.Dimensions inDims;
output list<list<Integer>> outIndexes;
end dimsToAllIndexes;
function sortEqSystems
input list<SimCode.SimEqSystem> eqs;
output list<SimCode.SimEqSystem> outEqs;
end sortEqSystems;
function isParallelFunctionContext
input SimCode.Context context;
output Boolean s;
end isParallelFunctionContext;
function getEnumerationTypes
input SimCodeVar.SimVars inVars;
output list<SimCodeVar.SimVar> outVars;
end getEnumerationTypes;
function getFMIModelStructure
input SimCode.SimCode simCode;
input list<SimCode.JacobianMatrix> jacobianMatrixes;
output SimCode.FmiModelStructure outFmiModelStructure;
end getFMIModelStructure;
function getStateSimVarIndexFromIndex
input list<SimCodeVar.SimVar> inStateVars;
input Integer inIndex;
output Integer outVariableIndex;
end getStateSimVarIndexFromIndex;
function getVariableIndex
input SimCodeVar.SimVar inVar;
output Integer outVariableIndex;
end getVariableIndex;
function getMaxSimEqSystemIndex
input SimCode.SimCode simCode;
output Integer idxOut;
end getMaxSimEqSystemIndex;
function translateSparsePatterSimVarInts
input list<tuple<DAE.ComponentRef, list<DAE.ComponentRef>>> sparsePattern;
input SimCode.SimCode simCode;
output list<tuple<Integer, list<Integer>>> outSparsePattern;
end translateSparsePatterSimVarInts;
function translateColorsSimVarInts
input list<list<DAE.ComponentRef>> inColors;
input SimCode.SimCode simCode;
output list<list<Integer>> outColors;
end translateColorsSimVarInts;
function generateSubPalceholders
input DAE.ComponentRef cr;
output String outdef;
end generateSubPalceholders;
function getDaeEqsNotPartOfOdeSystem
input SimCode.SimCode iSimCode;
output list<SimCode.SimEqSystem> oEqs;
end getDaeEqsNotPartOfOdeSystem;
function codegenResetTryThrowIndex
end codegenResetTryThrowIndex;
function codegenPushTryThrowIndex
input Integer i;
end codegenPushTryThrowIndex;
function codegenPopTryThrowIndex
end codegenPopTryThrowIndex;
function codegenPeekTryThrowIndex
output Integer i;
end codegenPeekTryThrowIndex;
function getVarIndexListByMapping
input HashTableCrIListArray.HashTable iVarToArrayIndexMapping;
input DAE.ComponentRef iVarName;
input Integer iIndexForUndefinedReferences;
output list<Integer> oVarIndexList;
end getVarIndexListByMapping;
end SimCodeUtil;
package BackendDAE
uniontype VarKind "- Variabile kind"
record VARIABLE end VARIABLE;
record STATE
Integer index;
Option<DAE.ComponentRef> derName;
end STATE;
record STATE_DER end STATE_DER;
record DUMMY_DER end DUMMY_DER;
record DUMMY_STATE end DUMMY_STATE;
record DISCRETE end DISCRETE;
record PARAM end PARAM;
record CONST end CONST;
record EXTOBJ Absyn.Path fullClassName; end EXTOBJ;
record JAC_VAR end JAC_VAR;
record JAC_DIFF_VAR end JAC_DIFF_VAR;
record OPT_CONSTR end OPT_CONSTR;
record OPT_FCONSTR end OPT_FCONSTR;
record OPT_INPUT_WITH_DER end OPT_INPUT_WITH_DER;
record OPT_INPUT_DER end OPT_INPUT_DER;
record OPT_TGRID end OPT_TGRID;
record OPT_LOOP_INPUT
DAE.ComponentRef replaceExp;
end OPT_LOOP_INPUT;
end VarKind;
uniontype ZeroCrossing
record ZERO_CROSSING
DAE.Exp relation_;
list<Integer> occurEquLst;
list<Integer> occurWhenLst;
end ZERO_CROSSING;
end ZeroCrossing;
uniontype TimeEvent
record SIMPLE_TIME_EVENT "e.g. time > 0.5"
end SIMPLE_TIME_EVENT;
record COMPLEX_TIME_EVENT "e.g. sin(time) > 0"
end COMPLEX_TIME_EVENT;
record SAMPLE_TIME_EVENT "e.g. sample(1, 1)"
Integer index "unique sample index" ;
DAE.Exp startExp;
DAE.Exp intervalExp;
end SAMPLE_TIME_EVENT;
end TimeEvent;
uniontype WhenOperator "- Reinit Statement"
record REINIT