-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIVCurveParameterOptimizationTotal.mo
3603 lines (3354 loc) · 158 KB
/
IVCurveParameterOptimizationTotal.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
package ModelicaServices
"ModelicaServices (Default implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation"
extends Modelica.Icons.Package;
package Machine
final constant Real eps=1.e-15 "Biggest number such that 1.0 + eps = 1.0";
annotation (Documentation(info="<html>
<p>
Package in which processor specific constants are defined that are needed
by numerical algorithms. Typically these constants are not directly used,
but indirectly via the alias definition in
<a href=\"modelica://Modelica.Constants\">Modelica.Constants</a>.
</p>
</html>"));
end Machine;
annotation (
Protection(access=Access.hide),
preferredView="info",
version="3.2.2",
versionBuild=0,
versionDate="2016-01-15",
dateModified = "2016-01-15 08:44:41Z",
revisionId="$Id:: package.mo 9141 2016-03-03 19:26:06Z #$",
uses(Modelica(version="3.2.2")),
conversion(
noneFromVersion="1.0",
noneFromVersion="1.1",
noneFromVersion="1.2",
noneFromVersion="3.2.1"),
Documentation(info="<html>
<p>
This package contains a set of functions and models to be used in the
Modelica Standard Library that requires a tool specific implementation.
These are:
</p>
<ul>
<li> <a href=\"modelica://ModelicaServices.Animation.Shape\">Shape</a>
provides a 3-dim. visualization of elementary
mechanical objects. It is used in
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape</a>
via inheritance.</li>
<li> <a href=\"modelica://ModelicaServices.Animation.Surface\">Surface</a>
provides a 3-dim. visualization of
moveable parameterized surface. It is used in
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Surface\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Surface</a>
via inheritance.</li>
<li> <a href=\"modelica://ModelicaServices.ExternalReferences.loadResource\">loadResource</a>
provides a function to return the absolute path name of an URI or a local file name. It is used in
<a href=\"modelica://Modelica.Utilities.Files.loadResource\">Modelica.Utilities.Files.loadResource</a>
via inheritance.</li>
<li> <a href=\"modelica://ModelicaServices.Machine\">ModelicaServices.Machine</a>
provides a package of machine constants. It is used in
<a href=\"modelica://Modelica.Constants\">Modelica.Constants</a>.</li>
<li> <a href=\"modelica://ModelicaServices.Types.SolverMethod\">Types.SolverMethod</a>
provides a string defining the integration method to solve differential equations in
a clocked discretized continuous-time partition (see Modelica 3.3 language specification).
It is not yet used in the Modelica Standard Library, but in the Modelica_Synchronous library
that provides convenience blocks for the clock operators of Modelica version ≥ 3.3.</li>
</ul>
<p>
This implementation is targeted for Dymola.
</p>
<p>
<b>Licensed by DLR and Dassault Systèmes AB under the Modelica License 2</b><br>
Copyright © 2009-2016, DLR and Dassault Systèmes AB.
</p>
<p>
<i>This Modelica package is <u>free</u> software and the use is completely at <u>your own risk</u>; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see <a href=\"modelica://Modelica.UsersGuide.ModelicaLicense2\">Modelica.UsersGuide.ModelicaLicense2</a> or visit <a href=\"https://www.modelica.org/licenses/ModelicaLicense2\"> https://www.modelica.org/licenses/ModelicaLicense2</a>.</i>
</p>
</html>"));
end ModelicaServices;
package Modelica "Modelica Standard Library - Version 3.2.2"
extends Modelica.Icons.Package;
package Blocks
"Library of basic input/output control blocks (continuous, discrete, logical, table blocks)"
import SI = Modelica.SIunits;
extends Modelica.Icons.Package;
package Continuous
"Library of continuous control blocks with internal states"
import Modelica.Blocks.Interfaces;
import Modelica.SIunits;
extends Modelica.Icons.Package;
block Integrator "Output the integral of the input signal"
import Modelica.Blocks.Types.Init;
parameter Real k(unit="1")=1 "Integrator gain";
/* InitialState is the default, because it was the default in Modelica 2.2
and therefore this setting is backward compatible
*/
parameter Modelica.Blocks.Types.Init initType=Modelica.Blocks.Types.Init.InitialState
"Type of initialization (1: no init, 2: steady state, 3,4: initial output)" annotation(Evaluate=true,
Dialog(group="Initialization"));
parameter Real y_start=0 "Initial or guess value of output (= state)"
annotation (Dialog(group="Initialization"));
extends Interfaces.SISO(y(start=y_start));
initial equation
if initType == Init.SteadyState then
der(y) = 0;
elseif initType == Init.InitialState or
initType == Init.InitialOutput then
y = y_start;
end if;
equation
der(y) = k*u;
annotation (
Documentation(info="<html>
<p>
This blocks computes output <b>y</b> (element-wise) as
<i>integral</i> of the input <b>u</b> multiplied with
the gain <i>k</i>:
</p>
<pre>
k
y = - u
s
</pre>
<p>
It might be difficult to initialize the integrator in steady state.
This is discussed in the description of package
<a href=\"modelica://Modelica.Blocks.Continuous#info\">Continuous</a>.
</p>
</html>"), Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Line(
points={{-80.0,78.0},{-80.0,-90.0}},
color={192,192,192}),
Polygon(
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid,
points={{-80.0,90.0},{-88.0,68.0},{-72.0,68.0},{-80.0,90.0}}),
Line(
points={{-90.0,-80.0},{82.0,-80.0}},
color={192,192,192}),
Polygon(
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid,
points={{90.0,-80.0},{68.0,-72.0},{68.0,-88.0},{90.0,-80.0}}),
Text(
lineColor={192,192,192},
extent={{0.0,-70.0},{60.0,-10.0}},
textString="I"),
Text(
extent={{-150.0,-150.0},{150.0,-110.0}},
textString="k=%k"),
Line(
points={{-80.0,-80.0},{80.0,80.0}},
color={0,0,127})}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(extent={{-60,60},{60,-60}}, lineColor={0,0,255}),
Line(points={{-100,0},{-60,0}}, color={0,0,255}),
Line(points={{60,0},{100,0}}, color={0,0,255}),
Text(
extent={{-36,60},{32,2}},
lineColor={0,0,0},
textString="k"),
Text(
extent={{-32,0},{36,-58}},
lineColor={0,0,0},
textString="s"),
Line(points={{-46,0},{46,0}})}));
end Integrator;
annotation (
Documentation(info="<html>
<p>
This package contains basic <b>continuous</b> input/output blocks
described by differential equations.
</p>
<p>
All blocks of this package can be initialized in different
ways controlled by parameter <b>initType</b>. The possible
values of initType are defined in
<a href=\"modelica://Modelica.Blocks.Types.Init\">Modelica.Blocks.Types.Init</a>:
</p>
<table border=1 cellspacing=0 cellpadding=2>
<tr><td valign=\"top\"><b>Name</b></td>
<td valign=\"top\"><b>Description</b></td></tr>
<tr><td valign=\"top\"><b>Init.NoInit</b></td>
<td valign=\"top\">no initialization (start values are used as guess values with fixed=false)</td></tr>
<tr><td valign=\"top\"><b>Init.SteadyState</b></td>
<td valign=\"top\">steady state initialization (derivatives of states are zero)</td></tr>
<tr><td valign=\"top\"><b>Init.InitialState</b></td>
<td valign=\"top\">Initialization with initial states</td></tr>
<tr><td valign=\"top\"><b>Init.InitialOutput</b></td>
<td valign=\"top\">Initialization with initial outputs (and steady state of the states if possible)</td></tr>
</table>
<p>
For backward compatibility reasons the default of all blocks is
<b>Init.NoInit</b>, with the exception of Integrator and LimIntegrator
where the default is <b>Init.InitialState</b> (this was the initialization
defined in version 2.2 of the Modelica standard library).
</p>
<p>
In many cases, the most useful initial condition is
<b>Init.SteadyState</b> because initial transients are then no longer
present. The drawback is that in combination with a non-linear
plant, non-linear algebraic equations occur that might be
difficult to solve if appropriate guess values for the
iteration variables are not provided (i.e., start values with fixed=false).
However, it is often already useful to just initialize
the linear blocks from the Continuous blocks library in SteadyState.
This is uncritical, because only linear algebraic equations occur.
If Init.NoInit is set, then the start values for the states are
interpreted as <b>guess</b> values and are propagated to the
states with fixed=<b>false</b>.
</p>
<p>
Note, initialization with Init.SteadyState is usually difficult
for a block that contains an integrator
(Integrator, LimIntegrator, PI, PID, LimPID).
This is due to the basic equation of an integrator:
</p>
<pre>
<b>initial equation</b>
<b>der</b>(y) = 0; // Init.SteadyState
<b>equation</b>
<b>der</b>(y) = k*u;
</pre>
<p>
The steady state equation leads to the condition that the input to the
integrator is zero. If the input u is already (directly or indirectly) defined
by another initial condition, then the initialization problem is <b>singular</b>
(has none or infinitely many solutions). This situation occurs often
for mechanical systems, where, e.g., u = desiredSpeed - measuredSpeed and
since speed is both a state and a derivative, it is always defined by
Init.InitialState or Init.SteadyState initialization.
</p>
<p>
In such a case, <b>Init.NoInit</b> has to be selected for the integrator
and an additional initial equation has to be added to the system
to which the integrator is connected. E.g., useful initial conditions
for a 1-dim. rotational inertia controlled by a PI controller are that
<b>angle</b>, <b>speed</b>, and <b>acceleration</b> of the inertia are zero.
</p>
</html>"), Icon(graphics={Line(
origin={0.061,4.184},
points={{81.939,36.056},{65.362,36.056},{14.39,-26.199},{-29.966,
113.485},{-65.374,-61.217},{-78.061,-78.184}},
color={95,95,95},
smooth=Smooth.Bezier)}));
end Continuous;
package Interfaces
"Library of connectors and partial models for input/output blocks"
import Modelica.SIunits;
extends Modelica.Icons.InterfacesPackage;
connector RealInput = input Real "'input Real' as connector" annotation (
defaultComponentName="u",
Icon(graphics={
Polygon(
lineColor={0,0,127},
fillColor={0,0,127},
fillPattern=FillPattern.Solid,
points={{-100.0,100.0},{100.0,0.0},{-100.0,-100.0}})},
coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}},
preserveAspectRatio=true,
initialScale=0.2)),
Diagram(
coordinateSystem(preserveAspectRatio=true,
initialScale=0.2,
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Polygon(
lineColor={0,0,127},
fillColor={0,0,127},
fillPattern=FillPattern.Solid,
points={{0.0,50.0},{100.0,0.0},{0.0,-50.0},{0.0,50.0}}),
Text(
lineColor={0,0,127},
extent={{-10.0,60.0},{-10.0,85.0}},
textString="%name")}),
Documentation(info="<html>
<p>
Connector with one input signal of type Real.
</p>
</html>"));
connector RealOutput = output Real "'output Real' as connector" annotation (
defaultComponentName="y",
Icon(
coordinateSystem(preserveAspectRatio=true,
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Polygon(
lineColor={0,0,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
points={{-100.0,100.0},{100.0,0.0},{-100.0,-100.0}})}),
Diagram(
coordinateSystem(preserveAspectRatio=true,
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Polygon(
lineColor={0,0,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
points={{-100.0,50.0},{0.0,0.0},{-100.0,-50.0}}),
Text(
lineColor={0,0,127},
extent={{30.0,60.0},{30.0,110.0}},
textString="%name")}),
Documentation(info="<html>
<p>
Connector with one output signal of type Real.
</p>
</html>"));
connector RealVectorInput = input Real
"Real input connector used for vector of connectors" annotation (
defaultComponentName="u",
Icon(graphics={Ellipse(
extent={{-100,100},{100,-100}},
lineColor={0,0,127},
fillColor={0,0,127},
fillPattern=FillPattern.Solid)}, coordinateSystem(
extent={{-100,-100},{100,100}},
preserveAspectRatio=true,
initialScale=0.2)),
Diagram(coordinateSystem(
preserveAspectRatio=false,
initialScale=0.2,
extent={{-100,-100},{100,100}}), graphics={Text(
extent={{-10,85},{-10,60}},
lineColor={0,0,127},
textString="%name"), Ellipse(
extent={{-50,50},{50,-50}},
lineColor={0,0,127},
fillColor={0,0,127},
fillPattern=FillPattern.Solid)}),
Documentation(info="<html>
<p>
Real input connector that is used for a vector of connectors,
for example <a href=\"modelica://Modelica.Blocks.Interfaces.PartialRealMISO\">PartialRealMISO</a>,
and has therefore a different icon as RealInput connector.
</p>
</html>"));
partial block SO "Single Output continuous control block"
extends Modelica.Blocks.Icons.Block;
RealOutput y "Connector of Real output signal" annotation (Placement(
transformation(extent={{100,-10},{120,10}})));
annotation (Documentation(info="<html>
<p>
Block has one continuous Real output signal.
</p>
</html>"));
end SO;
partial block SISO "Single Input Single Output continuous control block"
extends Modelica.Blocks.Icons.Block;
RealInput u "Connector of Real input signal" annotation (Placement(
transformation(extent={{-140,-20},{-100,20}})));
RealOutput y "Connector of Real output signal" annotation (Placement(
transformation(extent={{100,-10},{120,10}})));
annotation (Documentation(info="<html>
<p>
Block has one continuous Real input and one continuous Real output signal.
</p>
</html>"));
end SISO;
partial block SI2SO
"2 Single Input / 1 Single Output continuous control block"
extends Modelica.Blocks.Icons.Block;
RealInput u1 "Connector of Real input signal 1" annotation (Placement(
transformation(extent={{-140,40},{-100,80}})));
RealInput u2 "Connector of Real input signal 2" annotation (Placement(
transformation(extent={{-140,-80},{-100,-40}})));
RealOutput y "Connector of Real output signal" annotation (Placement(
transformation(extent={{100,-10},{120,10}})));
annotation (Documentation(info="<html>
<p>
Block has two continuous Real input signals u1 and u2 and one
continuous Real output signal y.
</p>
</html>"));
end SI2SO;
partial block PartialRealMISO
"Partial block with a RealVectorInput and a RealOutput signal"
parameter Integer significantDigits(min=1) = 3
"Number of significant digits to be shown in dynamic diagram layer for y"
annotation (Dialog(tab="Advanced"));
parameter Integer nu(min=0) = 0 "Number of input connections"
annotation (Dialog(connectorSizing=true), HideResult=true);
Modelica.Blocks.Interfaces.RealVectorInput u[nu]
annotation (Placement(transformation(extent={{-120,70},{-80,-70}})));
Modelica.Blocks.Interfaces.RealOutput y
annotation (Placement(transformation(extent={{100,-17},{134,17}})));
annotation (Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}},
initialScale=0.06), graphics={
Text(
extent={{110,-50},{300,-70}},
lineColor={0,0,0},
textString=DynamicSelect(" ", String(y, significantDigits=
significantDigits))),
Text(
extent={{-250,170},{250,110}},
textString="%name",
lineColor={0,0,255}),
Rectangle(
extent={{-100,100},{100,-100}},
lineColor={255,137,0},
lineThickness=5.0,
fillColor={255,255,255},
borderPattern=BorderPattern.Raised,
fillPattern=FillPattern.Solid)}));
end PartialRealMISO;
partial block PartialConversionBlock
"Partial block defining the interface for conversion blocks"
RealInput u "Connector of Real input signal to be converted" annotation (
Placement(transformation(extent={{-140,-20},{-100,20}})));
RealOutput y
"Connector of Real output signal containing input signal u in another unit"
annotation (Placement(transformation(extent={{100,-10},{120,10}})));
annotation (
Icon(
coordinateSystem(preserveAspectRatio=true,
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Rectangle(
lineColor={0,0,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
extent={{-100.0,-100.0},{100.0,100.0}}),
Line(
points={{-90.0,0.0},{30.0,0.0}},
color={191,0,0}),
Polygon(
lineColor={191,0,0},
fillColor={191,0,0},
fillPattern=FillPattern.Solid,
points={{90.0,0.0},{30.0,20.0},{30.0,-20.0},{90.0,0.0}}),
Text(
lineColor={0,0,255},
extent={{-115.0,105.0},{115.0,155.0}},
textString="%name")}), Documentation(info="<html>
<p>
This block defines the interface of a conversion block that
converts from one unit into another one.
</p>
</html>"));
end PartialConversionBlock;
annotation (Documentation(info="<html>
<p>
This package contains interface definitions for
<b>continuous</b> input/output blocks with Real,
Integer and Boolean signals. Furthermore, it contains
partial models for continuous and discrete blocks.
</p>
</html>", revisions="<html>
<ul>
<li><i>Oct. 21, 2002</i>
by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
and Christian Schweiger:<br>
Added several new interfaces.</li>
<li><i>Oct. 24, 1999</i>
by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
RealInputSignal renamed to RealInput. RealOutputSignal renamed to
output RealOutput. GraphBlock renamed to BlockIcon. SISOreal renamed to
SISO. SOreal renamed to SO. I2SOreal renamed to M2SO.
SignalGenerator renamed to SignalSource. Introduced the following
new models: MIMO, MIMOs, SVcontrol, MVcontrol, DiscreteBlockIcon,
DiscreteBlock, DiscreteSISO, DiscreteMIMO, DiscreteMIMOs,
BooleanBlockIcon, BooleanSISO, BooleanSignalSource, MI2BooleanMOs.</li>
<li><i>June 30, 1999</i>
by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
Realized a first version, based on an existing Dymola library
of Dieter Moormann and Hilding Elmqvist.</li>
</ul>
</html>"));
end Interfaces;
package Math
"Library of Real mathematical functions as input/output blocks"
import Modelica.SIunits;
import Modelica.Blocks.Interfaces;
extends Modelica.Icons.Package;
encapsulated package UnitConversions
"Conversion blocks to convert between SI and non-SI unit signals"
import Modelica;
import SI = Modelica.SIunits;
import NonSI = Modelica.SIunits.Conversions.NonSIunits;
extends Modelica.Icons.Package;
block From_degC "Convert from degCelsius to Kelvin"
extends Modelica.Blocks.Interfaces.PartialConversionBlock(u(unit="degC"),
y(unit="K"));
equation
y = SI.Conversions.from_degC(u);
annotation (Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,
-100},{100,100}}), graphics={Text(
extent={{-20,100},{-100,20}},
lineColor={0,0,0},
textString="degC"),Text(
extent={{100,-20},{20,-100}},
lineColor={0,0,0},
textString="K")}), Documentation(info="<html>
<p>
This block converts the input signal from degCelsius to Kelvin and returns
the result as output signal.
</p>
</html>"));
end From_degC;
annotation (Documentation(info="<html>
<p>
This package consists of blocks that convert an input signal
with a specific unit to an output signal in another unit
(e.g., conversion of an angle signal from \"deg\" to \"rad\").
</p>
</html>"));
end UnitConversions;
block Gain "Output the product of a gain value with the input signal"
parameter Real k(start=1, unit="1")
"Gain value multiplied with input signal";
public
Interfaces.RealInput u "Input signal connector" annotation (Placement(
transformation(extent={{-140,-20},{-100,20}})));
Interfaces.RealOutput y "Output signal connector" annotation (Placement(
transformation(extent={{100,-10},{120,10}})));
equation
y = k*u;
annotation (
Documentation(info="<html>
<p>
This block computes output <i>y</i> as
<i>product</i> of gain <i>k</i> with the
input <i>u</i>:
</p>
<pre>
y = k * u;
</pre>
</html>"),Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Polygon(
points={{-100,-100},{-100,100},{100,0},{-100,-100}},
lineColor={0,0,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Text(
extent={{-150,-140},{150,-100}},
lineColor={0,0,0},
textString="k=%k"),
Text(
extent={{-150,140},{150,100}},
textString="%name",
lineColor={0,0,255})}),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={Polygon(
points={{-100,-100},{-100,100},{100,0},{-100,-100}},
lineColor={0,0,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Text(
extent={{-76,38},{0,-34}},
textString="k",
lineColor={0,0,255})}));
end Gain;
block MultiSum "Sum of Reals: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]"
extends Modelica.Blocks.Interfaces.PartialRealMISO;
parameter Real k[nu]=fill(1, nu) "Input gains";
equation
if size(u, 1) > 0 then
y = k*u;
else
y = 0;
end if;
annotation (Icon(graphics={Text(
extent={{-200,-110},{200,-140}},
lineColor={0,0,0},
fillColor={255,213,170},
fillPattern=FillPattern.Solid,
textString="%k"), Text(
extent={{-72,68},{92,-68}},
lineColor={0,0,0},
fillColor={255,213,170},
fillPattern=FillPattern.Solid,
textString="+")}), Documentation(info="<html>
<p>
This blocks computes the scalar Real output \"y\" as sum of the elements of the
Real input signal vector u:
</p>
<blockquote><pre>
y = k[1]*u[1] + k[2]*u[2] + ... k[N]*u[N];
</pre></blockquote>
<p>
The input connector is a vector of Real input signals.
When a connection line is drawn, the dimension of the input
vector is enlarged by one and the connection is automatically
connected to this new free index (thanks to the
connectorSizing annotation).
</p>
<p>
The usage is demonstrated, e.g., in example
<a href=\"modelica://Modelica.Blocks.Examples.RealNetwork1\">Modelica.Blocks.Examples.RealNetwork1</a>.
</p>
<p>
If no connection to the input connector \"u\" is present,
the output is set to zero: y=0.
</p>
</html>"));
end MultiSum;
block Product "Output product of the two inputs"
extends Interfaces.SI2SO;
equation
y = u1*u2;
annotation (
Documentation(info="<html>
<p>
This blocks computes the output <b>y</b> (element-wise)
as <i>product</i> of the corresponding elements of
the two inputs <b>u1</b> and <b>u2</b>:
</p>
<pre>
y = u1 * u2;
</pre>
</html>"),Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Line(points={{-100,60},{-40,60},{-30,40}}, color={0,0,127}),
Line(points={{-100,-60},{-40,-60},{-30,-40}}, color={0,0,127}),
Line(points={{50,0},{100,0}}, color={0,0,127}),
Line(points={{-30,0},{30,0}}),
Line(points={{-15,25.99},{15,-25.99}}),
Line(points={{-15,-25.99},{15,25.99}}),
Ellipse(lineColor={0,0,127}, extent={{-50,-50},{50,50}})}),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={Rectangle(
extent={{-100,-100},{100,100}},
lineColor={0,0,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(points={{-100,60},{-40,60},{-30,
40}}, color={0,0,255}),Line(points={{-100,-60},{-40,-60},{-30,-40}},
color={0,0,255}),Line(points={{50,0},{100,0}}, color={0,0,255}),
Line(points={{-30,0},{30,0}}),Line(points={{-15,
25.99},{15,-25.99}}),Line(points={{-15,-25.99},{15,
25.99}}),Ellipse(extent={{-50,50},{50,-50}},
lineColor={0,0,255})}));
end Product;
block Sqrt "Output the square root of the input (input >= 0 required)"
extends Interfaces.SISO;
equation
y = sqrt(u);
annotation (
defaultComponentName="sqrt1",
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{-90,-80},{68,-80}}, color={192,192,192}),
Polygon(
points={{90,-80},{68,-72},{68,-88},{90,-80}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(
points={{-80,-80},{-79.2,-68.7},{-78.4,-64},{-76.8,-57.3},{-73.6,-47.9},
{-67.9,-36.1},{-59.1,-22.2},{-46.2,-6.49},{-28.5,10.7},{-4.42,
30},{27.7,51.3},{69.5,74.7},{80,80}},
smooth=Smooth.Bezier),
Polygon(
points={{-80,90},{-88,68},{-72,68},{-80,90}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(points={{-80,-88},{-80,68}}, color={192,192,192}),
Text(
extent={{-8,-4},{64,-52}},
lineColor={192,192,192},
textString="sqrt")}),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={Line(points={{-92,-80},{84,-80}}, color={
192,192,192}),Polygon(
points={{100,-80},{84,-74},{84,-86},{100,-80}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),Line(points={{-80,-80},{-79.2,-68.7},
{-78.4,-64},{-76.8,-57.3},{-73.6,-47.9},{-67.9,-36.1},{-59.1,-22.2},
{-46.2,-6.49},{-28.5,10.7},{-4.42,30},{27.7,51.3},{69.5,74.7},{80,
80}}),Polygon(
points={{-80,98},{-86,82},{-74,82},{-80,98}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),Line(points={{-80,-90},{-80,84}},
color={192,192,192}),Text(
extent={{-71,98},{-44,78}},
lineColor={160,160,164},
textString="y"),Text(
extent={{60,-52},{84,-72}},
lineColor={160,160,164},
textString="u")}),
Documentation(info="<html>
<p>
This blocks computes the output <b>y</b>
as <i>square root</i> of the input <b>u</b>:
</p>
<pre>
y = <b>sqrt</b>( u );
</pre>
<p>
All elements of the input vector shall be zero or positive.
Otherwise an error occurs.
</p>
</html>"));
end Sqrt;
annotation (Documentation(info="<html>
<p>
This package contains basic <b>mathematical operations</b>,
such as summation and multiplication, and basic <b>mathematical
functions</b>, such as <b>sqrt</b> and <b>sin</b>, as
input/output blocks. All blocks of this library can be either
connected with continuous blocks or with sampled-data blocks.
</p>
</html>", revisions="<html>
<ul>
<li><i>October 21, 2002</i>
by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
and Christian Schweiger:<br>
New blocks added: RealToInteger, IntegerToReal, Max, Min, Edge, BooleanChange, IntegerChange.</li>
<li><i>August 7, 1999</i>
by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
Realized (partly based on an existing Dymola library
of Dieter Moormann and Hilding Elmqvist).
</li>
</ul>
</html>"), Icon(graphics={Line(
points={{-80,-2},{-68.7,32.2},{-61.5,51.1},{-55.1,64.4},{-49.4,72.6},
{-43.8,77.1},{-38.2,77.8},{-32.6,74.6},{-26.9,67.7},{-21.3,57.4},
{-14.9,42.1},{-6.83,19.2},{10.1,-32.8},{17.3,-52.2},{23.7,-66.2},
{29.3,-75.1},{35,-80.4},{40.6,-82},{46.2,-79.6},{51.9,-73.5},{
57.5,-63.9},{63.9,-49.2},{72,-26.8},{80,-2}},
color={95,95,95},
smooth=Smooth.Bezier)}));
end Math;
package Sources
"Library of signal source blocks generating Real and Boolean signals"
import Modelica.Blocks.Interfaces;
import Modelica.SIunits;
extends Modelica.Icons.SourcesPackage;
block Constant "Generate constant signal of type Real"
parameter Real k(start=1) "Constant output value";
extends Interfaces.SO;
equation
y = k;
annotation (
defaultComponentName="const",
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Line(points={{-80,68},{-80,-80}}, color={192,192,192}),
Polygon(
points={{-80,90},{-88,68},{-72,68},{-80,90}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(points={{-90,-70},{82,-70}}, color={192,192,192}),
Polygon(
points={{90,-70},{68,-62},{68,-78},{90,-70}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(points={{-80,0},{80,0}}),
Text(
extent={{-150,-150},{150,-110}},
lineColor={0,0,0},
textString="k=%k")}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Polygon(
points={{-80,90},{-86,68},{-74,68},{-80,90}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Line(points={{-80,68},{-80,-80}}, color={95,95,95}),
Line(
points={{-80,0},{80,0}},
color={0,0,255},
thickness=0.5),
Line(points={{-90,-70},{82,-70}}, color={95,95,95}),
Polygon(
points={{90,-70},{68,-64},{68,-76},{90,-70}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Text(
extent={{-83,92},{-30,74}},
lineColor={0,0,0},
textString="y"),
Text(
extent={{70,-80},{94,-100}},
lineColor={0,0,0},
textString="time"),
Text(
extent={{-101,8},{-81,-12}},
lineColor={0,0,0},
textString="k")}),
Documentation(info="<html>
<p>
The Real output y is a constant signal:
</p>
<p>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Sources/Constant.png\"
alt=\"Constant.png\">
</p>
</html>"));
end Constant;
block Ramp "Generate ramp signal"
parameter Real height=1 "Height of ramps";
parameter Modelica.SIunits.Time duration(min=0.0, start=2)
"Duration of ramp (= 0.0 gives a Step)";
parameter Real offset=0 "Offset of output signal";
parameter Modelica.SIunits.Time startTime=0
"Output = offset for time < startTime";
extends Interfaces.SO;
equation
y = offset + (if time < startTime then 0 else if time < (startTime +
duration) then (time - startTime)*height/duration else height);
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Line(points={{-80,68},{-80,-80}}, color={192,192,192}),
Polygon(
points={{-80,90},{-88,68},{-72,68},{-80,90}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(points={{-90,-70},{82,-70}}, color={192,192,192}),
Polygon(
points={{90,-70},{68,-62},{68,-78},{90,-70}},
lineColor={192,192,192},
fillColor={192,192,192},
fillPattern=FillPattern.Solid),
Line(points={{-80,-70},{-40,-70},{31,38}}),
Text(
extent={{-150,-150},{150,-110}},
lineColor={0,0,0},
textString="duration=%duration"),
Line(points={{31,38},{86,38}})}),
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Polygon(
points={{-80,90},{-86,68},{-74,68},{-80,90}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Line(points={{-80,68},{-80,-80}}, color={95,95,95}),
Line(
points={{-80,-20},{-20,-20},{50,50}},
color={0,0,255},
thickness=0.5),
Line(points={{-90,-70},{82,-70}}, color={95,95,95}),
Polygon(
points={{90,-70},{68,-64},{68,-76},{90,-70}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Polygon(
points={{-40,-20},{-42,-30},{-38,-30},{-40,-20}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Line(
points={{-40,-20},{-40,-70}},
color={95,95,95}),
Polygon(
points={{-40,-70},{-42,-60},{-38,-60},{-40,-70},{-40,-70}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Text(
extent={{-72,-39},{-34,-50}},
lineColor={0,0,0},
textString="offset"),
Text(
extent={{-38,-72},{6,-83}},
lineColor={0,0,0},
textString="startTime"),
Text(
extent={{-78,92},{-37,72}},
lineColor={0,0,0},
textString="y"),
Text(
extent={{70,-80},{94,-91}},
lineColor={0,0,0},
textString="time"),
Line(points={{-20,-20},{-20,-70}}, color={95,95,95}),
Line(
points={{-19,-20},{50,-20}},
color={95,95,95}),
Line(
points={{50,50},{101,50}},
color={0,0,255},
thickness=0.5),
Line(
points={{50,50},{50,-20}},
color={95,95,95}),
Polygon(
points={{50,-20},{42,-18},{42,-22},{50,-20}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Polygon(
points={{-20,-20},{-11,-18},{-11,-22},{-20,-20}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Polygon(
points={{50,50},{48,40},{52,40},{50,50}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Polygon(
points={{50,-20},{48,-10},{52,-10},{50,-20},{50,-20}},
lineColor={95,95,95},
fillColor={95,95,95},
fillPattern=FillPattern.Solid),
Text(
extent={{53,23},{82,10}},
lineColor={0,0,0},
textString="height"),
Text(
extent={{-2,-21},{37,-33}},
lineColor={0,0,0},
textString="duration")}),
Documentation(info="<html>
<p>