-
Notifications
You must be signed in to change notification settings - Fork 298
/
SimCodeTV.mo
4250 lines (3680 loc) · 113 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 listEmpty
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
output Boolean b;
end listEmpty;
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 intNeg
input Integer a;
output Integer b;
end intNeg;
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 intMod
input Integer a;
input Integer b;
output Integer c;
end intMod;
function intEq
input Integer a;
input Integer b;
output Boolean c;
end intEq;
function realEq
input Real a;
input Real b;
output Boolean c;
end realEq;
function realAlmostEq
input Real a;
input Real b;
input Real absTol;
output Boolean c;
end realAlmostEq;
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 intReal
input Integer i;
output Real r;
end intReal;
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 realMul
input Real x;
input Real y;
output Real z;
end realMul;
function realDiv
input Real x;
input Real y;
output Real z;
end realDiv;
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;
function stringHashDjb2Mod
input String str;
input Integer mod;
output Integer hash;
end stringHashDjb2Mod;
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<SimVar> mixedArrayVars;
list<SimVar> residualVars;
list<SimVar> algebraicDAEVars;
list<SimVar> sensitivityVars;
list<SimVar> dataReconSetcVars;
list<SimVar> dataReconinputVars;
list<SimVar> dataReconSetBVars;
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;
Option<Causality> causality;
Option<Integer> variable_index "valueReference";
Option<Integer> fmi_index "index of variable in modelDescription.xml";
list<String> numArrayElement;
Boolean isValueChangeable;
Boolean isProtected;
Option<Boolean> hideResult;
Option<String> matrixName;
Option<Variability> variability "FMI-2.0 variabilty attribute";
Option<Initial> initial_ "FMI-2.0 initial attribute";
Option<DAE.ComponentRef> exportVar "variables will only be exported to the modelDescription.xml if this attribute is SOME(cref)";
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 OUTPUT end OUTPUT;
record INPUT end INPUT;
// cases for FMI-2.0 exports Causality attribute
record LOCAL
"replacement for INTERNAL(), as we handle PARAMETER and CALCULATED_PARAMETER, the default causality should be defined as LOCAL according to FMI 2.0 Specification"
end LOCAL;
record PARAMETER end PARAMETER;
record CALCULATED_PARAMETER end CALCULATED_PARAMETER;
end Causality;
// for setting initial attribute of variable for FMI-2.0 export
uniontype Initial
record NONE_INITIAL end NONE_INITIAL;
record EXACT end EXACT;
record APPROX end APPROX;
record CALCULATED end CALCULATED;
end Initial;
// for setting Variability attribute for FMI-2.0 export
uniontype Variability
record CONSTANT end CONSTANT;
record FIXED end FIXED;
record TUNABLE end TUNABLE;
record DISCRETE end DISCRETE;
record CONTINUOUS end CONTINUOUS;
end Variability;
end SimCodeVar;
package HashTableCrefSimVar
type Key = DAE.ComponentRef;
type Value = SimCodeVar.SimVar;
type HashTableCrefFunctionsType = tuple<FuncHashCref,FuncCrefEqual,FuncCrefStr,FuncExpStr>;
type HashTable = tuple<
array<list<tuple<Key,Integer>>>,
tuple<Integer,Integer,array<Option<tuple<Key,Value>>>>,
Integer,
HashTableCrefFunctionsType
>;
function FuncHashCref
input Key cr;
input Integer mod;
output Integer res;
end FuncHashCref;
function FuncCrefEqual
input Key cr1;
input Key cr2;
output Boolean res;
end FuncCrefEqual;
function FuncCrefStr
input Key cr;
output String res;
end FuncCrefStr;
function FuncExpStr
input Value exp;
output String res;
end FuncExpStr;
end HashTableCrefSimVar;
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 SparsityPattern = list<tuple<Integer, list<Integer>>>;
type NonlinearPattern = SparsityPattern;
uniontype JacobianColumn
record JAC_COLUMN
list<SimEqSystem> columnEqns;
list<SimCodeVar.SimVar> columnVars;
Integer numberOfResultVars;
list<SimEqSystem> constantEqns;
end JAC_COLUMN;
end JacobianColumn;
uniontype JacobianMatrix
record JAC_MATRIX
list<JacobianColumn> columns;
list<SimCodeVar.SimVar> seedVars;
String matrixName;
SparsityPattern sparsity;
SparsityPattern sparsityT;
NonlinearPattern nonlinear;
NonlinearPattern nonlinearT;
list<list<Integer>> coloredCols;
Integer maxColorCols;
Integer jacobianIndex;
Integer partitionIndex;
list<SimGenericCall> generic_loop_calls;
Option<HashTableCrefSimVar.HashTable> crefsHT;
end JAC_MATRIX;
end JacobianMatrix;
uniontype SimCode
record SIMCODE
ModelInfo modelInfo;
list<DAE.Exp> literals;
list<SimCodeFunction.RecordDeclaration> recordDecls;
list<String> externalFunctionIncludes;
list<SimGenericCall> generic_loop_calls;
list<SimEqSystem> localKnownVars;
list<SimEqSystem> allEquations;
list<list<SimEqSystem>> odeEquations;
list<list<SimEqSystem>> algebraicEquations;
list<ClockedPartition> clockedPartitions;
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> initialEquations_lambda0;
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<DAE.ComponentRef> discreteModelVars;
ExtObjInfo extObjInfo;
SimCodeFunction.MakefileParams makefileParams;
DelayedExpression delayedExps;
SpatialDistributionInfo spatialInfo;
list<JacobianMatrix> jacobianMatrices;
Option<SimulationSettings> simulationSettingsOpt;
String fileNamePrefix;
String fullPathPrefix; // Used for FMI where code is not generated in the same directory
String fmuTargetName;
HpcOmSimCode.HpcOmData hpcomData;
HashTableCrIListArray.HashTable varToArrayIndexMapping;
Option<FmiModelStructure> modelStructure;
Option<FmiSimulationFlags> fmiSimulationFlags;
PartitionData partitionData;
Option<DaeModeData> daeModeData;
list<SimEqSystem> inlineEquations;
Option<OMSIData> omsiData;
end SIMCODE;
end SimCode;
uniontype PartitionData
record PARTITIONDATA
Integer numPartitions;
list<list<Integer>> partitions; // which equations are assigned to the partitions
list<list<Integer>> activatorsForPartitions; // which activators can activate each partition
list<Integer> stateToActivators; // which states belong to which activator
end PARTITIONDATA;
end PartitionData;
uniontype ClockedPartition
record CLOCKED_PARTITION
DAE.ClockKind baseClock;
list<SubPartition> subPartitions;
end CLOCKED_PARTITION;
end ClockedPartition;
uniontype SubPartition
record SUBPARTITION
list<tuple<SimCodeVar.SimVar, Boolean>> vars;
list<SimEqSystem> equations;
list<SimEqSystem> removedEquations;
BackendDAE.SubClock subClock;
Boolean holdEvents;
end SUBPARTITION;
end SubPartition;
uniontype DelayedExpression
record DELAYED_EXPRESSIONS
list<tuple<Integer, tuple<DAE.Exp, DAE.Exp, DAE.Exp>>> delayedExps;
Integer maxDelayedIndex;
end DELAYED_EXPRESSIONS;
end DelayedExpression;
uniontype SpatialDistributionInfo
record SPATIAL_DISTRIBUTION_INFO
list<SpatialDistribution> spatialDistributions;
Integer maxIndex;
end SPATIAL_DISTRIBUTION_INFO;
end SpatialDistributionInfo;
uniontype SpatialDistribution
record SPATIAL_DISTRIBUTION
Integer index "uniqueIndex";
DAE.Exp in0 "input 0";
DAE.Exp in1 "input 1";
DAE.Exp pos "current pos";
DAE.Exp dir "flow direction";
DAE.Exp initPnts "initial grid points";
DAE.Exp initVals "initial grid values";
Integer initSize "number of initial points";
end SPATIAL_DISTRIBUTION;
end SpatialDistribution;
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 ExtObjInfo
record EXTOBJINFO
list<SimCodeVar.SimVar> vars;
list<ExtAlias> aliases;
end EXTOBJINFO;
end ExtObjInfo;
uniontype OMSIData
record OMSI_DATA
OMSIFunction initialization;
OMSIFunction simulation;
end OMSI_DATA;
end OMSIData;
uniontype OMSIFunction
record OMSI_FUNCTION
list<SimEqSystem> equations;
list<SimCodeVar.SimVar> inputVars;
list<SimCodeVar.SimVar> outputVars;
list<SimCodeVar.SimVar> innerVars;
Integer nAllVars;
SimCodeFunction.Context context;
Integer nAlgebraicSystems;
end OMSI_FUNCTION;
end OMSIFunction;
uniontype SimEqSystem
record SES_RESIDUAL
Integer index;
Integer res_index;
DAE.Exp exp;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_RESIDUAL;
record SES_FOR_RESIDUAL
Integer index;
Integer res_index;
list<tuple<DAE.ComponentRef, DAE.Exp>> iterators;
DAE.Exp exp;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_FOR_RESIDUAL;
record SES_GENERIC_RESIDUAL
Integer index;
Integer res_index;
list<Integer> scal_indices;
list<tuple<DAE.ComponentRef, DAE.Exp>> iterators;
DAE.Exp exp;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_GENERIC_RESIDUAL;
record SES_SIMPLE_ASSIGN
Integer index;
DAE.ComponentRef cref;
DAE.Exp exp;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_SIMPLE_ASSIGN;
record SES_SIMPLE_ASSIGN_CONSTRAINTS
Integer index;
DAE.ComponentRef cref;
DAE.Exp exp;
DAE.ElementSource source;
BackendDAE.Constraints cons;
BackendDAE.EquationAttributes eqAttr;
end SES_SIMPLE_ASSIGN_CONSTRAINTS;
record SES_ARRAY_CALL_ASSIGN
Integer index;
DAE.Exp lhs;
DAE.Exp exp;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_ARRAY_CALL_ASSIGN;
record SES_GENERIC_ASSIGN
"a generic assignment calling a for loop body function with an index list."
Integer index;
Integer call_index;
list<Integer> scal_indices;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_GENERIC_ASSIGN;
record SES_ENTWINED_ASSIGN
"entwined generic assignments calling for loop body functions with an index list and a call order."
Integer index;
list<Integer> call_order;
list<SimEqSystem> single_calls;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_ENTWINED_ASSIGN;
record SES_IFEQUATION
Integer index;
list<tuple<DAE.Exp,list<SimEqSystem>>> ifbranches;
list<SimEqSystem> elsebranch;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
end SES_IFEQUATION;
record SES_ALGORITHM
Integer index;
list<DAE.Statement> statements;
BackendDAE.EquationAttributes eqAttr;
end SES_ALGORITHM;
record SES_INVERSE_ALGORITHM
Integer index;
list<DAE.Statement> statements;
list<DAE.ComponentRef> knownOutputCrefs "this is a subset of output crefs of the original algorithm, which are already known";
Boolean insideNonLinearSystem;
BackendDAE.EquationAttributes eqAttr;
end SES_INVERSE_ALGORITHM;
record SES_LINEAR
LinearSystem lSystem;
Option<LinearSystem> alternativeTearing;
BackendDAE.EquationAttributes eqAttr;
end SES_LINEAR;
record SES_NONLINEAR
NonlinearSystem nlSystem;
Option<NonlinearSystem> alternativeTearing;
BackendDAE.EquationAttributes eqAttr;
end SES_NONLINEAR;
record SES_MIXED
Integer index;
SimEqSystem cont;
list<SimCodeVar.SimVar> discVars;
list<SimEqSystem> discEqs;
Integer indexMixedSystem;
BackendDAE.EquationAttributes eqAttr;
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()
list<BackendDAE.WhenOperator> whenStmtLst;
Option<SimEqSystem> elseWhen;
DAE.ElementSource source;
BackendDAE.EquationAttributes eqAttr;
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;
BackendDAE.EquationAttributes eqAttr;
end SES_FOR_LOOP;
record SES_ALIAS
Integer aliasOf;
end SES_ALIAS;
record SES_ALGEBRAIC_SYSTEM
Integer index;
Integer algSysIndex;
Integer dim_n;
Boolean partOfMixed;
Boolean tornSystem;
Boolean linearSystem;
OMSIFunction residual;
Option<DerivativeMatrix> matrix;
list<Integer> zeroCrossingConditions;
list<DAE.ElementSource> sources;
BackendDAE.EquationAttributes eqAttr;
end SES_ALGEBRAIC_SYSTEM;
end SimEqSystem;
uniontype DerivativeMatrix
"represents directional derivatives with sparsity and coloring"
record DERIVATIVE_MATRIX
list<OMSIFunction> columns; // column(s) equations and variables
// inputVars: seedVars
// innerVars: inner column vars
// outputVars: result vars of the column
String matrixName; // unique matrix name
SparsityPattern sparsity;
SparsityPattern sparsityT;
list<list<Integer>> coloredCols;
Integer maxColorCols;
end DERIVATIVE_MATRIX;
end DerivativeMatrix;
uniontype LinearSystem
record LINEARSYSTEM
Integer index;
Boolean partOfMixed;
Boolean tornSystem;
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;
Integer nUnknowns;
Boolean partOfJac "if TRUE then this system is part of a jacobian matrix";
end LINEARSYSTEM;
end LinearSystem;
uniontype NonlinearSystem
record NONLINEARSYSTEM
Integer index;
list<SimEqSystem> eqs;
list<DAE.ComponentRef> crefs;
Integer indexNonLinearSystem;
Integer nUnknowns;
Option<JacobianMatrix> jacobianMatrix;
Boolean homotopySupport;
Boolean mixedSystem;
Boolean tornSystem;
Option<Integer> clockIndex;
end NONLINEARSYSTEM;
end NonlinearSystem;
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 ModelInfo
record MODELINFO
Absyn.Path name;
String description;
String directory;
VarInfo varInfo;
SimCodeVar.SimVars vars;
list<SimCodeFunction.Function> functions;
list<String> labels;
list<Absyn.Class> sortedClasses;
Integer nClocks;
Integer nSubClocks;
Integer nSpatialDistributions;
list<SimEqSystem> linearSystems;
list<SimEqSystem> nonLinearSystems;
list<UnitDefinition> unitDefinitions "export unitDefintion in modelDescription.xml";
end MODELINFO;
end ModelInfo;
uniontype UnitDefinition "unitDefinitions for fmi modelDescription.xml"
record UNITDEFINITION
String name;
BaseUnit baseUnit;
//TODO DisplayUnit
end UNITDEFINITION;
end UnitDefinition;
uniontype BaseUnit
record BASEUNIT
Integer mol "exponent";
Integer cd "exponent";
Integer m "exponent";
Integer s "exponent";
Integer A "exponent";
Integer K "exponent";
Integer kg "exponent";
Real factor "prefix";
Real offset "offset";
end BASEUNIT;
record NOBASEUNIT "no baseunit definition available"
end NOBASEUNIT;
end BaseUnit;
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;
Integer numSensitivityParameters;
Integer numSetcVars;
Integer numDataReconVars;
Integer numRealInputVars "for fmi cs to interpolate inputs";
Integer numSetbVars "for data reconciliation setB vars";
Integer numRelatedBoundaryConditions "for data reconciliation count number of boundary conditions which failed the extraction algorithm";
end VARINFO;
end VarInfo;
uniontype SimGenericCall
record SINGLE_GENERIC_CALL
Integer index;
list<BackendDAE.SimIterator> iters;
DAE.Exp lhs;
DAE.Exp rhs;
end SINGLE_GENERIC_CALL;
record IF_GENERIC_CALL
Integer index;
list<BackendDAE.SimIterator> iters;
list<SimBranch> branches;
end IF_GENERIC_CALL;
record WHEN_GENERIC_CALL
Integer index;
list<BackendDAE.SimIterator> iters;
list<SimBranch> branches;
end WHEN_GENERIC_CALL;
end SimGenericCall;
uniontype SimBranch
record SIM_BRANCH
Option<DAE.Exp> condition;
list<tuple<DAE.Exp, DAE.Exp>> body;
end SIM_BRANCH;
record SIM_BRANCH_STMT
Option<DAE.Exp> condition;
list<DAE.Statement> body;
end SIM_BRANCH_STMT;
end SimBranch;
uniontype DaeModeConfig
record ALL_EQUATIONS end ALL_EQUATIONS;
record DYNAMIC_EQUATIONS end DYNAMIC_EQUATIONS;
end DaeModeConfig;
uniontype DaeModeData
"contains data that belongs to the dae mode"
record DAEMODEDATA
list<list<SimEqSystem>> daeEquations "daeModel residuals equations";
Option<JacobianMatrix> sparsityPattern "contains the sparsity pattern for the daeMode";
list<SimCodeVar.SimVar> residualVars; // variable used to calculate residuals of a DAE form, they are real
list<SimCodeVar.SimVar> algebraicVars; // algebraic variable used to calculate residuals of a DAE form, they are real
list<SimCodeVar.SimVar> auxiliaryVars; // auxiliary variable used to calculate residuals of a DAE form, they are real
end DAEMODEDATA;
end DaeModeData;
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 FmiDiscreteStates
record FMIDISCRETESTATES
list<FmiUnknown> fmiUnknownsList;
end FMIDISCRETESTATES;
end FmiDiscreteStates;
uniontype FmiInitialUnknowns
record FMIINITIALUNKNOWNS
list<FmiUnknown> fmiUnknownsList;
list<tuple<Integer, DAE.ComponentRef>> sortedUnknownCrefs "use the sorted crefs to get the ValueReference of unknowns";
list<tuple<Integer, DAE.ComponentRef>> sortedknownCrefs "use the sorted crefs to get the ValueReference of knowns";
end FMIINITIALUNKNOWNS;
end FmiInitialUnknowns;
uniontype FmiModelStructure
record FMIMODELSTRUCTURE
FmiOutputs fmiOutputs;
FmiDerivatives fmiDerivatives;
Option<JacobianMatrix> continuousPartialDerivatives;
Option<JacobianMatrix> initialPartialDerivatives;
FmiDiscreteStates fmiDiscreteStates;
FmiInitialUnknowns fmiInitialUnknowns;
end FMIMODELSTRUCTURE;
end FmiModelStructure;
uniontype FmiSimulationFlags
record FMI_SIMULATION_FLAGS
list<tuple<String,String>> nameValueTuples;
end FMI_SIMULATION_FLAGS;
record FMI_SIMULATION_FLAGS_FILE
String path;
end FMI_SIMULATION_FLAGS_FILE;
end FmiSimulationFlags;
end SimCode;
package SimCodeFunction
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 Variable
record VARIABLE
DAE.ComponentRef name;
DAE.Type ty;
Option<DAE.Exp> value;
list<DAE.Dimension> instDims;
DAE.VarParallelism parallelism;
DAE.VarKind kind;
Boolean bind_from_outside;
end VARIABLE;
record FUNCTION_PTR