-
Notifications
You must be signed in to change notification settings - Fork 297
/
NFModelicaBuiltin.mo
5656 lines (5041 loc) · 195 KB
/
NFModelicaBuiltin.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
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, 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 GPL VERSION 3 LICENSE OR
* THIS 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 Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* 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.
*
* See the full OSMC Public License conditions for more details.
*
*/
type StateSelect = enumeration(
never "Do not use as state at all.",
avoid "Use as state, if it cannot be avoided (but only if variable appears differentiated and no other potential state with attribute default, prefer, or always can be selected).",
default "Use as state if appropriate, but only if variable appears differentiated.",
prefer "Prefer it as state over those having the default value (also variables can be selected, which do not appear differentiated).",
always "Do use it as a state."
) annotation(__OpenModelica_builtin = true);
type Uncertainty = enumeration(
given,
sought,
refine,
propagate
) annotation(__OpenModelica_builtin = true);
partial class Clock
annotation(__OpenModelica_builtin=true);
end Clock;
partial class ExternalObject
annotation(__OpenModelica_builtin=true);
end ExternalObject;
function der "Derivative of the input expression"
input Real x(unit="'p");
output Real dx(unit="'p/s");
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'der()'\">der()</a>
</html>"));
end der;
impure function initial "True if in initialization phase"
discrete output Boolean isInitial;
external "builtin";
annotation(__OpenModelica_builtin=true, __OpenModelica_Impure=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'initial()'\">initial()</a>
</html>"));
end initial;
impure function terminal "True after successful analysis"
discrete output Boolean isTerminal;
external "builtin";
annotation(__OpenModelica_builtin=true, __OpenModelica_Impure=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'terminal()'\">terminal()</a>
</html>"));
end terminal;
type AssertionLevel = enumeration(warning, error) annotation(__OpenModelica_builtin=true,
Documentation(info="<html>Used by <a href=\"modelica://assert\">assert()</a></html>"));
function assert "Check an assertion condition"
input Boolean condition;
input String message;
input AssertionLevel level = AssertionLevel.error;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'assert()'\">assert()</a>
</html>"));
end assert;
function ceil "Round a real number towards plus infinity"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'ceil()'\">ceil()</a>
</html>"));
end ceil;
function floor "Round a real number towards minus infinity"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'floor()'\">floor()</a>
</html>"));
end floor;
function integer "Returns the largest integer not greater than x. The argument shall have type Real. The result has type Integer. [Note, outside of a when-clause state events are triggered when the return value changes discontinuously.]."
input Real x;
output Integer y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'integer()'\">integer()</a>
</html>"));
end integer;
function sqrt "Square root"
input Real x(unit="'p");
output Real y(unit="'p(1/2)");
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sqrt()'\">sqrt()</a>
</html>"));
end sqrt;
function sign "Sign of real or integer number"
input Real v;
output Integer _sign;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sign()'\">sign()</a>
</html>"));
/* We do this with external "builtin" for now. But maybe we should inline it instead...
annotation(__OpenModelica_EarlyInline = true);
algorithm
_sign := noEvent(if v > 0 then 1 else if v < 0 then -1 else 0);
*/
end sign;
function identity "Identity matrix of given size"
input Integer arraySize;
output Integer[arraySize,arraySize] outArray;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'identity()'\">identity()</a>
</html>"));
end identity;
function semiLinear
input Real x;
input Real positiveSlope;
input Real negativeSlope;
output Real result;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'semiLinear()'\">semiLinear()</a>
</html>"));
end semiLinear;
impure function edge "Indicate rising edge"
input Boolean b;
output Boolean edgeEvent;
// TODO: Ceval parameters? Needed to remove the builtin handler
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'edge()'\">edge()</a>
</html>"));
end edge;
function sin "Sine"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sin()'\">sin()</a>
</html>"));
end sin;
function cos "Cosine"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'cos()'\">cos()</a>
</html>"));
end cos;
function tan "Tangent (u shall not be -pi/2, pi/2, 3*pi/2, ...)"
input Real u;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'tan()'\">tan()</a>
</html>"));
end tan;
function sinh "Hyperbolic sine"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sinh()'\">sinh()</a>
</html>"));
end sinh;
function cosh "Hyperbolic cosine"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'cosh()'\">cosh()</a>
</html>"));
end cosh;
function tanh "Hyperbolic tangent"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'tanh()'\">tanh()</a>
</html>"));
end tanh;
function asin "Inverse sine (-1 <= u <= 1)"
input Real u;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'asin()'\">asin()</a>
</html>"));
end asin;
function acos "Inverse cosine (-1 <= u <= 1)"
input Real u;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'acos()'\">acos()</a>
</html>"));
end acos;
function atan "Inverse tangent"
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'atan()'\">atan()</a>
</html>"));
end atan;
function atan2 "Four quadrant inverse tangent"
input Real y;
input Real x;
output Real z;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'atan2()'\">atan2()</a>
</html>"));
end atan2;
function exp "Exponential, base e"
input Real x(unit="1");
output Real y(unit="1");
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'exp()'\">exp()</a>
</html>"));
end exp;
function log "Natural (base e) logarithm (u shall be > 0)"
input Real u(unit="1");
output Real y(unit="1");
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'log()'\">log()</a>
</html>"));
end log;
function log10 "Base 10 logarithm (u shall be > 0)"
input Real u(unit="1");
output Real y(unit="1");
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'log10()'\">log10()</a>
</html>"));
end log10;
impure function homotopy
input Real actual;
input Real simplified;
output Real outValue;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.2",Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'homotopy()'\">homotopy()</a> (experimental implementation)
</html>"));
end homotopy;
function linspace "Real vector with equally spaced elements"
input Real x1 "start";
input Real x2 "end";
input Integer n "number";
output Real v[n];
algorithm
// Error.assertion(n >= 2, "linspace requires n>=2 but got " + String(n), sourceInfo());
v := {x1 + (x2-x1)*(i-1)/(n-1) for i in 1:n};
annotation(__OpenModelica_builtin=true,__OpenModelica_EarlyInline=true,Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'linspace()'\">linspace()</a>
</html>"));
end linspace;
function div = $overload(OpenModelica.Internal.intDiv,OpenModelica.Internal.realDiv)
"Integer part of a division of two Real numbers"
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'div()'\">div()</a>
</html>"));
function mod = $overload(OpenModelica.Internal.intMod,OpenModelica.Internal.realMod)
"Integer modulus of a division of two Real numbers"
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'mod()'\">mod()</a>
</html>"));
function rem = $overload(OpenModelica.Internal.intRem,OpenModelica.Internal.realRem)
"Integer remainder of the division of two Real numbers"
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'rem()'\">rem()</a>
</html>"));
function abs = $overload(OpenModelica.Internal.intAbs,OpenModelica.Internal.realAbs)
"Absolute value"
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'abs()'\">abs()</a>
</html>"));
function outerProduct "Outer product of two vectors"
input Real[:] v1;
input Real[:] v2;
output Real[size(v1,1),size(v2,1)] o;
algorithm
o := matrix(v1) * transpose(matrix(v2));
annotation(__OpenModelica_builtin=true,__OpenModelica_EarlyInline=true,preferredView="text",Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'outerProduct()'\">outerProduct()</a>
</html>"));
end outerProduct;
function cross "Cross product of two 3-vectors"
input Real[3] x;
input Real[3] y;
output Real[3] z;
algorithm
z := { x[2]*y[3]-x[3]*y[2] , x[3]*y[1]-x[1]*y[3] , x[1]*y[2]-x[2]*y[1] };
annotation(__OpenModelica_builtin=true, __OpenModelica_EarlyInline = true, preferredView="text",Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'cross()'\">cross()</a>
</html>"));
end cross;
function skew "The skew matrix associated with the vector"
input Real[3] x;
output Real[3,3] y;
algorithm
y := {{0, -x[3], x[2]}, {x[3], 0, -x[1]}, {-x[2], x[1], 0}};
annotation(__OpenModelica_builtin=true, __OpenModelica_EarlyInline = true, preferredView = "text", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'skew()'\">skew()</a>
</html>"));
end skew;
function delay = $overload(OpenModelica.Internal.delay2,OpenModelica.Internal.delay3) "Delay expression"
annotation(__OpenModelica_builtin=true, __OpenModelica_Impure=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'delay()'\">delay()</a>
</html>"));
// function min = $overload(OpenModelica.Internal.realMin, OpenModelica.Internal.intMin
// , OpenModelica.Internal.boolMin, OpenModelica.Internal.enumMin
// , OpenModelica.Internal.arrayMin)
//function min = $overload(OpenModelica.Internal.scalarMin, OpenModelica.Internal.arrayMin)
function min
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'min()'\">min()</a>
</html>"));
end min;
// function max = $overload(OpenModelica.Internal.realMax, OpenModelica.Internal.intMax
// , OpenModelica.Internal.boolMax, OpenModelica.Internal.enumMax
// , OpenModelica.Internal.arrayMax)
//function max = $overload(OpenModelica.Internal.scalarMax, OpenModelica.Internal.arrayMax)
function max
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'max()'\">max()</a>
</html>"));
end max;
function sum<__Array, __Scalar> "Sum of all array elements"
input __Array a;
output __Scalar s;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sum()'\">sum()</a>
</html>"));
end sum;
function product<__Array, __Scalar> "Product of all array elements"
input __Array a;
output __Scalar s;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'product()'\">product()</a>
</html>"));
end product;
function promote
external "builtin";
annotation(__OpenModelica_builtin=true);
end promote;
function transpose<T> "Transpose a matrix"
input T a;
output T b;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'transpose()'\">transpose()</a>
</html>"));
end transpose;
function symmetric<T> "Returns a symmetric matrix"
input T[:, size(a, 1)] a;
output T[size(a, 1), size(a, 2)] b;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'symmetric()'\">symmetric()</a>
</html>"));
end symmetric;
function smooth<RealArrayOrRecord> "Indicate smoothness of expression"
parameter input Integer p annotation(__OpenModelica_functionVariability=true);
input RealArrayOrRecord expr;
output RealArrayOrRecord s;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'smooth()'\">smooth()</a>
</html>"));
end smooth;
function diagonal<__Scalar> "Returns a diagonal matrix"
input __Scalar v[:];
output __Scalar mat[size(v,1),size(v,1)];
external "builtin";
annotation(__OpenModelica_builtin=true, __OpenModelica_UnboxArguments=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'diagonal()'\">diagonal()</a>
</html>"));
end diagonal;
function cardinality<__Connector> "Number of connectors in connection"
input __Connector c;
parameter output Integer numOccurances;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'cardinality()'\">cardinality()</a>
</html>"),version="Deprecated");
end cardinality;
function array "Constructs an array"
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'array()'\">array()</a>
</html>"));
end array;
function zeros "Returns a zero array"
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'zeros()'\">zeros()</a>
</html>"));
end zeros;
function ones "Returns a one array"
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'ones()'\">ones()</a>
</html>"));
end ones;
function fill "Returns an array with all elements equal"
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'fill()'\">fill()</a>
</html>"));
end fill;
function noEvent<__Any> "Turn off event triggering"
input __Any x;
output __Any y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'noEvent()'\">noEvent()</a>
</html>"));
end noEvent;
impure function pre<PodCref> "Refer to left limit"
discrete input PodCref y;
output PodCref p;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'pre()'\">pre()</a>
</html>"));
end pre;
impure function change<PodCref> "Indicate discrete variable changing"
discrete input PodCref y;
output Boolean p;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'change()'\">change()</a>
</html>"));
end change;
function reinit<RealOrArrayCref, RealOrArrayExpr> "Reinitialize state variable"
input RealOrArrayCref x;
input RealOrArrayExpr expr;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'reinit()'\">reinit()</a>
</html>"));
end reinit;
function sample = $overload(OMC_NO_CLOCK.sample, OMC_CLOCK.sample)
"Returns the interval between the previous and present tick of the clock of its argument"
annotation(__OpenModelica_builtin=true, __OpenModelica_UnboxArguments=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sample()'\">sample()</a>
</html>"));
package OMC_NO_CLOCK
impure function sample "Overloaded operator to either trigger time events or to convert between continuous-time and clocked-time representation"
parameter input Real start annotation(__OpenModelica_functionVariability=true);
parameter input Real interval annotation(__OpenModelica_functionVariability=true);
output Boolean b;
external "builtin";
annotation(Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sample()'\">sample()</a>
</html>"));
end sample;
end OMC_NO_CLOCK;
package OMC_CLOCK
impure function sample<T> "Overloaded operator to either trigger time events or to convert between continuous-time and clocked-time representation"
input T u;
input Clock c = OpenModelica.Internal.inferredClock();
output T o;
external "builtin";
annotation(version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'sample()'\">sample()</a>
</html>"));
end sample;
end OMC_CLOCK;
function shiftSample<__Any> "First activation of clock is shifted in time"
input __Any u;
parameter input Integer shiftCounter(min = 0) annotation(__OpenModelica_functionVariability=true);
parameter input Integer resolution(min = 1) = 1 annotation(__OpenModelica_functionVariability=true);
output __Any c;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'shiftSample()'\">shiftSample()</a>
</html>"));
end shiftSample;
function backSample<__Any> "First activation of clock is shifted in time before activation of u"
input __Any u;
parameter input Integer backCounter(min = 0) annotation(__OpenModelica_functionVariability=true);
parameter input Integer resolution(min = 1) = 1 annotation(__OpenModelica_functionVariability=true);
output __Any c;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'backSample()'\">backSample()</a>
</html>"));
end backSample;
function transition<__Block> "Define state machine transition"
input __Block from;
input __Block to;
input Boolean condition;
input Boolean immediate = true;
input Boolean reset = true;
input Boolean synchronize = false;
input Integer priority = 1;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'transition()'\">transition()</a>
</html>"));
end transition;
function initialState<__Block> "Define inital state of a state machine"
input __Block state;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'initialState()'\">initialState()</a>
</html>"));
end initialState;
function activeState<__Block> "Return true if instance of a state machine is active, otherwise false"
input __Block state;
output Boolean active;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'activeState()'\">activeState()</a>
</html>"));
end activeState;
function ndims<T> "Number of array dimensions"
input T a;
parameter output Integer d;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'ndims()'\">ndims()</a>
</html>"));
end ndims;
function size "Returns dimensions of an array"
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'size()'\">size()</a>
</html>"));
end size;
impure function DynamicSelect<__Any> "select static or dynamic expressions in the annotations"
input __Any static;
input __Any dynamic;
output __Any selected;
external "builtin";
annotation(__OpenModelica_builtin=true, __OpenModelica_Impure=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Annotations.DynamicSelect\">DynamicSelect</a>
</html>"));
end DynamicSelect;
function scalar<T,ScalarType> "Returns a one-element array as scalar"
input T i;
output ScalarType s;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'scalar()'\">scalar()</a>
</html>"));
end scalar;
function vector<T,VectorType> "Returns an array as vector"
input T i;
output VectorType v;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'vector()'\">vector()</a>
</html>"));
end vector;
function matrix<T,Matrix> "Returns the first two dimensions of an array as matrix"
input T i;
output Matrix m;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'matrix()'\">matrix()</a>
</html>"));
end matrix;
function cat "Concatenate arrays along given dimension"
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'cat()'\">cat()</a>
</html>"));
end cat;
function actualStream
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true);
end actualStream;
function inStream
input Real x;
output Real y;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'inStream()'\">inStream()</a>
</html>"));
end inStream;
function pure<__Any>
input __Any x;
output __Any y;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.4");
end pure;
/* Extension for uncertainty computations */
record Distribution
String name "the name of the distibution, e.g \"normal\" ";
Real params[:] "parameter values for the specified distribution, e.g {0,0.1} for a normal distribution";
String paramNames[:/*should be size(params,1) but doesn't work, cb issue #1682*/] "the parameter names for the specified distribution, e.g {\"my\",\"sigma\"} for a normal distribution";
end Distribution;
record Correlation "defines correlation between two uncertainty variables"
Real v1 "first variable";
Real v2 "second variable";
Real c "correlation value";
end Correlation;
function rooted
external "builtin";
annotation(__OpenModelica_builtin=true);
end rooted;
encapsulated package Connections
import OpenModelica.$Code.VariableName;
function branch
input VariableName node1;
input VariableName node2;
external "builtin";
annotation(__OpenModelica_builtin=true);
end branch;
function root
input VariableName node;
external "builtin";
annotation(__OpenModelica_builtin=true);
end root;
function potentialRoot
input VariableName node;
parameter input Integer priority = 0 annotation(__OpenModelica_functionVariability=true);
external "builtin";
annotation(__OpenModelica_builtin=true);
end potentialRoot;
function isRoot
input VariableName node;
output Boolean isroot;
external "builtin";
annotation(__OpenModelica_builtin=true);
end isRoot;
function uniqueRoot
input VariableName root;
input String message = "";
external "builtin";
annotation(__OpenModelica_builtin=true);
end uniqueRoot;
function uniqueRootIndices
input VariableName[:] roots;
input VariableName[:] nodes;
input String message = "";
output Integer[size(roots, 1)] rootIndices;
// adrpo: I would like an assert here: size(nodes) <= size (roots)
external "builtin";
annotation(__OpenModelica_builtin=true);
end uniqueRootIndices;
function rooted
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
<h4>Syntax</h4>
<blockquote>
<pre><b>Connections.rooted</b>(x)</pre>
</blockquote>
<h4>Description</h4>
<p>The operator \"rooted\" was introduced to improve efficiency:
A tool that constructs the graph with the Connections.branch/.root etc.
built-in operators has to cut the graph in order to arrive at \"spanning trees\".
If there is a statement \"Connections.branch(A,B)\", then \"rooted(A)\" returns true,
if \"A\" is closer to the root of the spanning tree as \"B\". Otherwise false is returned.
For the MultiBody library this allows to avoid unnecessary small linear systems of equations.
</p>
<h4>Known Bugs</h4>
<p>
OpenModelica, <b>rooted</b>(x) always returns true.
See <a href=\"https://trac.modelica.org/Modelica/ticket/95\">rooted ticket in the Modelica Trac</a> for details.
</p>
</html>"));
end rooted;
annotation(__OpenModelica_builtin=true);
end Connections;
encapsulated package Subtask
type SamplingType = enumeration(Disabled, Continuous, Periodic);
function decouple
external "builtin";
end decouple;
function activated
output Boolean activated;
external "builtin";
end activated;
function lastInterval
external "builtin";
end lastInterval;
end Subtask;
impure function print "Prints to stdout, useful for debugging."
input String str;
external "builtin";
annotation(__OpenModelica_Impure=true, version="OpenModelica extension");
end print;
function classDirectory "Non-standard operator"
output String str;
external "builtin";
annotation(Documentation(info="<html>
<p>classDirectory() is a <b>non-standard operator</b> that was replaced by <a href=\"modelica://Modelica.Utilities.Files.loadResource\">Modelica.Utilities.Files.loadResource(uri)</a> before it was added to the language specification.</p>
<p>Returns the directory of the file where the classDirectory() call came from.</p>
</html>"),version="Dymola / MSL 2.2.1");
end classDirectory;
function getInstanceName
output String instanceName;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
<h4>
Modelica definition:
</h4>
<p>
Returns a string with the name of the model/block that is simulated,
appended with the fully qualified name of the instance in which this
function is called.
</p>
<p>
If MyLib.Vehicle is simulated, the call of <b>getInstanceName()</b> might return:
<em>Vehicle.engine.controller</em>
</p>
<p>
Outside of a model or block, the return value is not specified.
</p>
<h4>
OpenModelica specifics:
</h4>
<p>
When OpenModelica does not have a prefix (e.g. in functions or packages),
it returns the name of the function or package.
</p>
<p>
If no class was being simulated, the last simulated class or a default will be used
(applicable for functions called from the scripting environment).
</p>
</html>
"),version="Modelica 3.3");
end getInstanceName;
function spatialDistribution "Not yet implemented"
input Real in0;
input Real in1;
input Real x;
input Boolean positiveVelocity;
parameter input Real initialPoints[:](each min = 0, each max = 1) = {0.0, 1.0} annotation(__OpenModelica_functionVariability=true);
parameter input Real initialValues[size(initialPoints, 1)] = {0.0, 0.0} annotation(__OpenModelica_functionVariability=true);
output Real out0;
output Real out1;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.3");
end spatialDistribution;
function previous<__ComponentExpression> "Access previous value of a clocked variable"
input __ComponentExpression u;
output __ComponentExpression y;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'previous()'\">previous()</a>
</html>"));
end previous;
function firstTick = $overload(OMC_NO_ARGS.firstTick, OMC_ARGS.firstTick)
"Returns the interval between the previous and present tick of the clock of its argument"
annotation(__OpenModelica_builtin=true, __OpenModelica_UnboxArguments=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'firstTick()'\">firstTick()</a>
</html>"));
function interval = $overload(OMC_NO_ARGS.interval, OMC_ARGS.interval)
"Returns the interval between the previous and present tick of the clock of its argument"
annotation(__OpenModelica_builtin=true, __OpenModelica_UnboxArguments=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'interval()'\">interval()</a>
</html>"));
package OMC_NO_ARGS
impure function firstTick<T>
"This operator returns true at the first tick of the clock of the expression, in which this operator is called. The operator returns false at all subsequent ticks of the clock. The optional argument u is only used for clock inference"
output Boolean b;
external "builtin";
annotation(__OpenModelica_UnboxArguments=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'firstTick()'\">firstTick()</a>
</html>"));
end firstTick;
impure function interval<T>
"This operator returns true at the first tick of the clock of the expression, in which this operator is called. The operator returns false at all subsequent ticks of the clock. The optional argument u is only used for clock inference"
output Real b;
external "builtin";
annotation(__OpenModelica_UnboxArguments=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'interval()'\">interval()</a>
</html>"));
end interval;
end OMC_NO_ARGS;
package OMC_ARGS
impure function firstTick<T>
"This operator returns true at the first tick of the clock of the expression, in which this operator is called. The operator returns false at all subsequent ticks of the clock. The optional argument u is only used for clock inference"
input T u annotation(__OpenModelica_optionalArgument=true);
output Boolean b;
external "builtin";
annotation(__OpenModelica_UnboxArguments=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'firstTick()'\">firstTick()</a>
</html>"));
end firstTick;
impure function interval<T>
"This operator returns true at the first tick of the clock of the expression, in which this operator is called. The operator returns false at all subsequent ticks of the clock. The optional argument u is only used for clock inference"
input T u annotation(__OpenModelica_optionalArgument=true);
output Real b;
external "builtin";
annotation(__OpenModelica_UnboxArguments=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'interval()'\">interval()</a>
</html>"));
end interval;
end OMC_ARGS;
function subSample = $overload(OpenModelica.Internal.subSampleExpression, OpenModelica.Internal.subSampleClock)
"Conversion from faster clock to slower clock"
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'subSample()'\">subSample()</a>
</html>"));
function superSample = $overload(OpenModelica.Internal.superSampleExpression, OpenModelica.Internal.superSampleClock)
"Conversion from slower clock to faster clock"
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'superSample()'\">superSample()</a>
</html>"));
function hold<__Any> "Conversion from clocked discrete-time to continuous time"
input __Any u;
output __Any y;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'hold()'\">hold()</a>
</html>"));
end hold;
function noClock<__Any> "Clock of y=Clock(u) is always inferred"
input __Any u;
output __Any y;
external "builtin";
annotation(__OpenModelica_builtin=true, version="Modelica 3.3", Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'noClock()'\">noClock()</a>
</html>"));
end noClock;
impure function ticksInState "Returns the number of clock ticks since a transition was made to the currently active state"
output Integer ticks;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'ticksInState()'\">ticksInState()</a>
</html>"));
end ticksInState;
impure function timeInState "Returns the time duration as Real in [s] since a transition was made to the currently active state"
output Real t;
external "builtin";
annotation(__OpenModelica_builtin=true, Documentation(info="<html>
See <a href=\"modelica://ModelicaReference.Operators.'ticksInState()'\">ticksInState()</a>
</html>"));
end timeInState;
/* Actually contains more...
record SimulationResult
String resultFile;
String simulationOptions;
String messages;
end SimulationResult; */
encapsulated package OpenModelica "OpenModelica internal definitions and scripting functions"
package $Code
"Code quoting is not a uniontype yet because that would require enabling MetaModelica
extensions in the regular compiler. Besides, it has special semantics."
type Expression
"An expression of some kind"
annotation(__OpenModelica_builtinType=true);
end Expression;
type ExpressionOrModification
"An expression or modification of some kind"
annotation(__OpenModelica_builtinType=true);
end ExpressionOrModification;