-
Notifications
You must be signed in to change notification settings - Fork 164
/
Basic.mo
1962 lines (1869 loc) · 78.8 KB
/
Basic.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
within Modelica.Electrical.Analog;
package Basic "Basic electrical components"
extends Modelica.Icons.Package;
model Ground "Ground node"
Interfaces.Pin p annotation (Placement(transformation(
origin={0,100},
extent={{10,-10},{-10,10}},
rotation=270)));
equation
p.v = 0;
annotation (
Documentation(info="<html>
<p>Ground of an electrical circuit. The potential at the ground node is zero. Every electrical circuit has to contain at least one ground object.</p>
</html>", revisions="<html>
<ul>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{-60,50},{60,50}}, color={0,0,255}),
Line(points={{-40,30},{40,30}}, color={0,0,255}),
Line(points={{-20,10},{20,10}}, color={0,0,255}),
Line(points={{0,90},{0,50}}, color={0,0,255}),
Text(
extent={{-150,-10},{150,-50}},
textString="%name",
textColor={0,0,255})}));
end Ground;
model Resistor "Ideal linear electrical resistor"
parameter SI.Resistance R(start=1)
"Resistance at temperature T_ref";
parameter SI.Temperature T_ref=300.15 "Reference temperature";
parameter SI.LinearTemperatureCoefficient alpha=0
"Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))";
extends Modelica.Electrical.Analog.Interfaces.OnePort;
extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T=T_ref);
SI.Resistance R_actual
"Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))";
equation
assert((1 + alpha*(T_heatPort - T_ref)) >= Modelica.Constants.eps,
"Temperature outside scope of model!");
R_actual = R*(1 + alpha*(T_heatPort - T_ref));
v = R_actual*i;
LossPower = v*i;
annotation (
Documentation(info="<html>
<p>The linear resistor connects the branch voltage <em>v</em> with the branch current <em>i</em> by <em>i*R = v</em>. The Resistance <em>R</em> is allowed to be positive, zero, or negative.</p>
</html>", revisions="<html>
<ul>
<li><em> August 07, 2009 </em>
by Anton Haumer<br> temperature dependency of resistance added<br>
</li>
<li><em> March 11, 2009 </em>
by Christoph Clauss<br> conditional heat port added<br>
</li>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Rectangle(
extent={{-70,30},{70,-30}},
lineColor={0,0,255},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Line(points={{-90,0},{-70,0}}, color={0,0,255}),
Line(points={{70,0},{90,0}}, color={0,0,255}),
Text(
extent={{-150,-40},{150,-80}},
textString="R=%R"),
Line(
visible=useHeatPort,
points={{0,-100},{0,-30}},
color={127,0,0},
pattern=LinePattern.Dot),
Text(
extent={{-150,90},{150,50}},
textString="%name",
textColor={0,0,255})}));
end Resistor;
model Conductor "Ideal linear electrical conductor"
parameter SI.Conductance G(start=1)
"Conductance at temperature T_ref";
parameter SI.Temperature T_ref=300.15 "Reference temperature";
parameter SI.LinearTemperatureCoefficient alpha=0
"Temperature coefficient of conductance (G_actual = G_ref/(1 + alpha*(T_heatPort - T_ref))";
extends Modelica.Electrical.Analog.Interfaces.OnePort;
extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T=T_ref);
SI.Conductance G_actual
"Actual conductance = G_ref/(1 + alpha*(T_heatPort - T_ref))";
equation
assert((1 + alpha*(T_heatPort - T_ref)) >= Modelica.Constants.eps,
"Temperature outside scope of model!");
G_actual = G/(1 + alpha*(T_heatPort - T_ref));
i = G_actual*v;
LossPower = v*i;
annotation (
Documentation(info="<html>
<p>The linear conductor connects the branch voltage <em>v</em> with the branch current <em>i</em> by <em>i = v*G</em>. The Conductance <em>G</em> is allowed to be positive, zero, or negative.</p>
</html>", revisions="<html>
<ul>
<li><em> August 07, 2009 </em>
by Anton Haumer<br> temperature dependency of conductance added<br>
</li>
<li><em> March 11, 2009 </em>
by Christoph Clauss<br> conditional heat port added<br>
</li>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Rectangle(
extent={{-70,30},{70,-30}},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Rectangle(extent={{-70,30},{70,-30}}, lineColor={0,0,255}),
Line(points={{-90,0},{-70,0}}, color={0,0,255}),
Line(points={{70,0},{90,0}}, color={0,0,255}),
Line(
visible=useHeatPort,
points={{0,-100},{0,-30}},
color={127,0,0},
pattern=LinePattern.Dot),
Text(
extent={{-150,-40},{150,-80}},
textString="G=%G"),
Text(
extent={{-150,90},{150,50}},
textString="%name",
textColor={0,0,255})}));
end Conductor;
model Capacitor "Ideal linear electrical capacitor"
extends Interfaces.OnePort(v(start=0));
parameter SI.Capacitance C(start=1) "Capacitance";
equation
i = C*der(v);
annotation (
Documentation(info="<html>
<p>The linear capacitor connects the branch voltage <em>v</em> with the branch current <em>i</em> by <em>i = C * dv/dt</em>. The Capacitance <em>C</em> is allowed to be positive or zero.</p>
</html>", revisions="<html>
<ul>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{-6,28},{-6,-28}}, color={0,0,255}),
Line(points={{6,28},{6,-28}}, color={0,0,255}),
Line(points={{-90,0},{-6,0}}, color={0,0,255}),
Line(points={{6,0},{90,0}}, color={0,0,255}),
Text(
extent={{-150,-40},{150,-80}},
textString="C=%C"),
Text(
extent={{-150,90},{150,50}},
textString="%name",
textColor={0,0,255})}));
end Capacitor;
model Inductor "Ideal linear electrical inductor"
extends Interfaces.OnePort(i(start=0));
parameter SI.Inductance L(start=1) "Inductance";
equation
L*der(i) = v;
annotation (
Documentation(info="<html>
<p>The linear inductor connects the branch voltage <em>v</em> with the branch current <em>i</em> by <em>v = L * di/dt</em>. The Inductance <em>L</em> is allowed to be positive, or zero.</p>
</html>", revisions="<html>
<ul>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{60,0},{90,0}}, color={0,0,255}),
Line(points={{-90,0},{-60,0}}, color={0,0,255}),
Text(
extent={{-150,-40},{150,-80}},
textString="L=%L"),
Line(
points={{-60,0},{-59,6},{-52,14},{-38,14},{-31,6},{-30,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{-30,0},{-29,6},{-22,14},{-8,14},{-1,6},{0,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{0,0},{1,6},{8,14},{22,14},{29,6},{30,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{30,0},{31,6},{38,14},{52,14},{59,6},{60,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Text(
extent={{-150,90},{150,50}},
textString="%name",
textColor={0,0,255})}));
end Inductor;
model SaturatingInductor "Simple model of an inductor with saturation"
extends Modelica.Electrical.Analog.Interfaces.OnePort(i(start=0));
import Modelica.Constants.pi;
import Modelica.Constants.eps;
import Modelica.Constants.small;
import Modelica.Math.atan;
parameter SI.Current Inom(start=1) "Nominal current" annotation(Dialog(
groupImage="modelica://Modelica/Resources/Images/Electrical/Analog/Basic/SaturatingInductor_Lact_i_tight.png"));
parameter SI.Inductance Lnom(start=1)
"Nominal inductance at Nominal current";
parameter SI.Inductance Lzer(start=2*Lnom)
"Inductance near current=0";
parameter SI.Inductance Linf(start=Lnom/2)
"Inductance at large currents";
SI.Inductance Lact(start=Lzer) "Present inductance";
SI.MagneticFlux Psi "Present flux";
protected
parameter SI.Current Ipar(start=Inom/10, fixed=false);
initial equation
(Lnom - Linf)/(Lzer - Linf)=Ipar/Inom*(pi/2 - atan(Ipar/Inom));
equation
assert(Lzer > Lnom*(1 + eps), "Lzer (= " + String(Lzer) +
") has to be > Lnom (= " + String(Lnom) + ")");
assert(Linf < Lnom*(1 - eps), "Linf (= " + String(Linf) +
") has to be < Lnom (= " + String(Lnom) + ")");
Lact = Linf + (Lzer - Linf)*(if noEvent(abs(i)/Ipar<small) then 1 else atan(i/Ipar)/(i/Ipar));
Psi = Linf*i + (Lzer - Linf)*Ipar*atan(i/Ipar);
v = der(Psi);
annotation (defaultComponentName="inductor",
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Line(points={{60,0},{90,0}}, color={0,0,255}),
Line(points={{-90,0},{-60,0}}, color={0,0,255}),
Text(
extent={{-150,-40},{150,-80}},
textString="Lnom=%Lnom"),
Line(
points={{-60,0},{-59,6},{-52,14},{-38,14},{-31,6},{-30,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{-30,0},{-29,6},{-22,14},{-8,14},{-1,6},{0,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{0,0},{1,6},{8,14},{22,14},{29,6},{30,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{30,0},{31,6},{38,14},{52,14},{59,6},{60,0}},
color={0,0,255},
smooth=Smooth.Bezier),
Text(
extent={{-150,90},{150,50}},
textString="%name",
textColor={0,0,255}),
Line(points={{-60,-20},{60,-20}}, color={0,0,255})}),
Documentation(info="<html>
<p>This model approximates the behaviour of an inductor with the influence of saturation, i.e.,
the value of the inductance depends on the current flowing through the inductor (<strong>Fig. 1</strong>).
The inductance decreases as current increases. Note, that hysteresis is not taken into account.
</p>
<p>
The approximation of the flux linkage is based on the <code>atan</code> function with an additional linear term,
as shown in <strong>Fig. 2</strong>:</p>
<blockquote><pre>
Psi = Linf*i + (Lzer - Linf)*Ipar*atan(i/Ipar)
L = Psi/i = Linf + (Lzer - Linf)*atan(i/Ipar)/(i/Ipar)
</pre></blockquote>
<p>
This approximation is with good performance and easy to adjust to a given characteristic with only four parameters (<strong>Tab. 1</strong>).
</p>
<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<caption align=\"bottom\"><strong>Tab. 1:</strong> Characteristic parameters of the saturating inductor model</caption>
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<tr>
<td><code>Inom</code>.</td>
<td>Nominal current</td>
</tr>
<tr>
<td><code>Lnom</code></td>
<td>Nominal inductance at nominal current</td>
</tr>
<tr>
<td><code>Lzer</code></td>
<td>Inductance near current = 0; <code>Lzer</code> has to be greater than <code>Lnom</code></td>
</tr>
<tr>
<td><code>Linf</code></td>
<td>Inductance at large currents; <code>Linf</code> has to be less than <code>Lnom</code></td>
</tr>
</table>
<p>
The parameter <code>Ipar</code> is calculated internally from the relationship:</p>
<blockquote><pre>
Lnom = Linf + (Lzer - Linf)*atan(Inom/Ipar)/(Inom/Ipar)
</pre></blockquote>
<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
<caption align=\"bottom\"><strong>Fig. 1:</strong> Actual inductance <code>Lact</code> versus current <code>i</code></caption>
<tr>
<td>
<img src=\"modelica://Modelica/Resources/Images/Electrical/Analog/Basic/SaturatingInductor_Lact_i.png\" alt=\"Lact vs. i\">
</td>
</tr>
</table>
<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
<caption align=\"bottom\"><strong>Fig. 2:</strong> Actual flux linkage <code>Psi</code> versus current <code>i</code></caption>
<tr>
<td>
<img src=\"modelica://Modelica/Resources/Images/Electrical/Analog/Basic/SaturatingInductor_Psi_i.png\" alt=\"Psi vs. i\">
</td>
</tr>
</table>
<p>The flux slope in <strong>Fig. 2</strong> is equal to <code>Lzer</code> for small currents.
The limit of the flux slope is <code>Linf</code> as the current <code>i</code> approaches infinity.
The nominal flux is indicated by the product of the nominal inductance <code>Lnom</code> and the nominal current <code>Inom</code>.
</p>
</html>", revisions="<html>
<dl>
<dt><strong>Main Author:</strong></dt>
<dd>
<a href=\"https://www.haumer.at/\">Anton Haumer</a><br>
Technical Consulting & Electrical Engineering<br>
D-93049 Regensburg<br>Germany<br>
email: <a href=\"mailto:a.haumer@haumer.at\">a.haumer@haumer.at</a>
</dd>
<dt><strong>Release Notes:</strong></dt>
<dd>Jul 23, 2019: Improved by Anton Haumer</dd>
<dd>May 27, 2004: Implemented by Anton Haumer</dd>
</dl>
</html>"));
end SaturatingInductor;
model Transformer "Transformer with two ports"
extends Interfaces.TwoPort(i1(start=0),i2(start=0));
parameter SI.Inductance L1(start=1) "Primary inductance";
parameter SI.Inductance L2(start=1) "Secondary inductance";
parameter SI.Inductance M(start=1) "Coupling inductance";
Real dv "Difference between voltage drop over primary inductor and voltage drop over secondary inductor";
equation
v1 = L1*der(i1) + M*der(i2);
/* Original equation:
v2 = M*der(i1) + L2*der(i2);
If L1 = L2 = M, then this model has one state less. However,
it might be difficult for a tool to detect this. For this reason
the model is defined with a relative potential:
*/
dv = (L1 - M)*der(i1) + (M - L2)*der(i2);
v2 = v1 - dv;
annotation (
Documentation(info="<html>
<p>The transformer is a two port. The left port voltage <em>v1</em>, left port current <em>i1</em>, right port voltage <em>v2</em> and right port current <em>i2</em> are connected by the following relation:</p>
<blockquote><pre>
| v1 | | L1 M | | i1' |
| | = | | | |
| v2 | | M L2 | | i2' |
</pre></blockquote>
<p><em>L1</em>, <em>L2</em>, and <em>M</em> are the primary, secondary, and coupling inductances respectively.</p>
</html>", revisions="<html>
<ul>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Text(
extent={{-150,150},{150,110}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-20,-60},{20,-100}},
textString="M",
textColor={0,0,255}),
Line(points={{-40,60},{-40,100},{-90,100}}, color={0,0,255}),
Line(points={{40,60},{40,100},{90,100}}, color={0,0,255}),
Line(points={{-40,-60},{-40,-100},{-90,-100}}, color={0,0,255}),
Line(points={{40,-60},{40,-100},{90,-100}}, color={0,0,255}),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={-33,45},
rotation=270),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={-33,15},
rotation=270),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={-33,-15},
rotation=270),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={-33,-45},
rotation=270),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={33,45},
rotation=90),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={33,15},
rotation=90),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={33,-15},
rotation=90),
Line(
points={{-15,-7},{-14,-1},{-7,7},{7,7},{14,-1},{15,-7}},
color={0,0,255},
smooth=Smooth.Bezier,
origin={33,-45},
rotation=90),
Text(
extent={{-100,20},{-58,-20}},
textString="L1",
textColor={0,0,255}),
Text(
extent={{60,20},{100,-20}},
textString="L2",
textColor={0,0,255})}));
end Transformer;
model M_Transformer "Generic transformer with free number of inductors"
parameter Integer N(final min=1) = 3 "Number of inductors";
protected
parameter Integer dimL=div(N*(N + 1), 2);
public
parameter SI.Inductance L[dimL]={1,0.1,0.2,2,0.3,3}
"Inductances and coupling inductances";
Modelica.Electrical.Analog.Interfaces.PositivePin p[N] "Positive pin"
annotation (Placement(transformation(extent={{-110,-70},{-90,70}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n[N] "Negative pin"
annotation (Placement(transformation(extent={{90,-70},{110,70}})));
SI.Voltage v[N] "Voltage drop over inductors";
SI.Current i[N](each start=0, each fixed=true)
"Current through inductors";
parameter SI.Inductance Lm[N, N](each final fixed=false)
"Complete symmetric inductance matrix, calculated internally";
initial equation
for s in 1:N loop
Lm[s,s] = L[(s - 1)*N - div((s - 1)*s, 2) + s];
for z in s + 1:N loop
Lm[s,z] = L[(s - 1)*N - div((s - 1)*s, 2) + z];
Lm[z,s] = L[(s - 1)*N - div((s - 1)*s, 2) + z];
end for;
end for;
equation
for j in 1:N loop
v[j] = p[j].v - n[j].v;
0 = p[j].i + n[j].i;
i[j] = p[j].i;
end for;
v = Lm*der(i);
annotation (defaultComponentName="transformer", Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
{100,100}}), graphics={
Text(
extent={{-150,120},{150,80}},
textString="%name",
textColor={0,0,255}),
Text(extent={{-150,-80},{150,-120}}, textString="N=%N"),
Line(points={{60,-50},{90,-50}},
color={0,0,255}),
Line(points={{-90,-50},{-60,-50}},
color={0,0,255}),
Line(
points={{-60,-50},{-59,-44},{-52,-36},{-38,-36},{-31,-44},{-30,-50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{-30,-50},{-29,-44},{-22,-36},{-8,-36},{-1,-44},{0,-50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{0,-50},{1,-44},{8,-36},{22,-36},{29,-44},{30,-50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{30,-50},{31,-44},{38,-36},{52,-36},{59,-44},{60,-50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(points={{60,20},{90,20}},
color={0,0,255}),
Line(points={{-90,20},{-60,20}},
color={0,0,255}),
Line(
points={{-60,20},{-59,26},{-52,34},{-38,34},{-31,26},{-30,20}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{-30,20},{-29,26},{-22,34},{-8,34},{-1,26},{0,20}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{0,20},{1,26},{8,34},{22,34},{29,26},{30,20}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{30,20},{31,26},{38,34},{52,34},{59,26},{60,20}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(points={{60,50},{90,50}},
color={0,0,255}),
Line(points={{-90,50},{-60,50}},
color={0,0,255}),
Line(
points={{-60,50},{-59,56},{-52,64},{-38,64},{-31,56},{-30,50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{-30,50},{-29,56},{-22,64},{-8,64},{-1,56},{0,50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{0,50},{1,56},{8,64},{22,64},{29,56},{30,50}},
color={0,0,255},
smooth=Smooth.Bezier),
Line(
points={{30,50},{31,56},{38,64},{52,64},{59,56},{60,50}},
color={0,0,255},
smooth=Smooth.Bezier),
Ellipse(
extent={{-2,6},{2,2}},
lineColor={0,0,255},
fillColor={0,0,255},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-2,-22},{2,-26}},
lineColor={0,0,255},
fillColor={0,0,255},
fillPattern=FillPattern.Solid),
Ellipse(
extent={{-2,-8},{2,-12}},
lineColor={0,0,255},
fillColor={0,0,255},
fillPattern=FillPattern.Solid)}),
Documentation(info="<html>
<p>The model <em>M_Transformer</em> is a model of a transformer with the possibility to choose the number of inductors. Inside the model, an inductance matrix is built based on the inductance of the inductors and the coupling inductances between the inductors given as a parameter vector from the user of the model.</p>
<p>An example shows that approach:<br>
The user chooses a model with <strong>three</strong> inductors, that means the parameter <em><strong>N</strong></em> has to be <strong>3</strong>. Then he has to specify the inductances of the three inductors and the three coupling inductances. The coupling inductances are no real existing devices, but effects that occur between two inductors. The inductances (main diagonal of the inductance matrix) and the coupling inductances have to be specified in the parameter vector <em>L</em>. The length <em>dimL</em> of the parameter vector is calculated as follows: <em><strong>dimL=(N*(N+1))/2</strong></em></p>
<p>The following example shows how the parameter vector is used to fill in the inductance matrix. To specify the inductance matrix of a three inductances transformer (<em>N=3</em>):
</p>
<p>
<img
src=\"modelica://Modelica/Resources/Images/Electrical/Analog/Basic/M_Transformer-eq.png\"
alt=\"L_m\">
</p>
<p>
the user has to allocate the parameter vector <em>L[6] </em>, since <em>Nv=(N*(N+1))/2=(3*(3+1))/2=6</em>. The parameter vector must be filled like this: <em>L=[1,0.1,0.2,2,0.3,3] </em>.</p>
<p>Inside the model, two loops are used to fill the inductance matrix to guarantee that it is filled in a symmetric way.</p>
</html>", revisions="<html>
<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<th>Version</th>
<th>Revision</th>
<th>Date</th>
<th>Author</th>
<th>Comment</th>
</tr>
<tr>
<td></td>
<td>4163</td>
<td>2010-09-11</td>
<td>Dietmar Winkler</td>
<td>Documentation corrected according to documentation guidelines.</td>
</tr>
<tr>
<td></td>
<td></td>
<td>2008-11-24</td>
<td>Kristin Majetta</td>
<td>Documentation added.</td>
</tr>
<tr>
<td></td>
<td></td>
<td>2008-11-16</td>
<td>Kristin Majetta</td>
<td>Initially implemented</td>
</tr>
</table>
</html>"));
end M_Transformer;
model Gyrator "Gyrator"
extends Interfaces.TwoPort;
parameter SI.Conductance G1(start=1) "Primary gyration conductance";
parameter SI.Conductance G2(start=1) "Secondary gyration conductance";
equation
i1 = G2*v2;
i2 = -G1*v1;
annotation (
Documentation(info="<html>
<p>A gyrator is a two-port element defined by the following equations:</p>
<blockquote><pre>
i1 = G2 * v2
i2 = -G1 * v1
</pre></blockquote>
<p>where the constants <em>G1</em>, <em>G2</em> are called the gyration conductance.</p>
</html>", revisions="<html>
<ul>
<li><em> 1998 </em>
by Christoph Clauss<br> initially implemented<br>
</li>
</ul>
</html>"),
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Rectangle(
extent={{-80,80},{80,-80}},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Line(points={{-40,30},{40,30}}, color={0,0,255}),
Line(points={{-20,-30},{20,-30}}, color={0,0,255}),
Polygon(
points={{30,34},{40,30},{30,26},{30,34}},
fillColor={0,0,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Line(points={{-5,10},{-10,-10}}),
Line(points={{9,10},{4,-9}}),
Line(points={{-12,10},{16,10}}),
Text(
extent={{-29,69},{30,40}},
textString="G1"),
Text(
extent={{-29,-39},{29,-68}},
textString="G2"),
Text(
extent={{-150,151},{150,111}},
textString="%name",
textColor={0,0,255}),
Polygon(
points={{-10,-26},{-20,-30},{-10,-34},{-10,-26}},
fillColor={0,0,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Line(points={{-100,100},{-40,100},{-40,60}}, color={0,0,255}),
Line(
points={{20,25},{-40,25},{-40,-15}},
color={0,0,255},
origin={80,75},
rotation=360),
Line(
points={{-35,-20},{25,-20},{25,20}},
color={0,0,255},
origin={-65,-80},
rotation=360),
Line(
points={{20,-25},{-40,-25},{-40,15}},
color={0,0,255},
origin={80,-75},
rotation=360)}));
end Gyrator;
model RotationalEMF "Electromotoric force (electric/mechanic transformer)"
parameter Boolean useSupport=false
"= true, if support flange enabled, otherwise implicitly grounded"
annotation (
Evaluate=true,
HideResult=true,
choices(checkBox=true));
parameter SI.ElectricalTorqueConstant k(start=1)
"Transformation coefficient";
SI.Voltage v "Voltage drop between the two pins";
SI.Current i "Current flowing from positive to negative pin";
SI.Angle phi
"Angle of shaft flange with respect to support (= flange.phi - support.phi)";
SI.AngularVelocity w "Angular velocity of flange relative to support";
SI.Torque tau "Torque of flange";
SI.Torque tauElectrical "Electrical torque";
Interfaces.PositivePin p "Positive electrical pin" annotation (Placement(transformation(
origin={0,100},
extent={{-10,-10},{10,10}},
rotation=90)));
Interfaces.NegativePin n "Negative electrical pin" annotation (Placement(transformation(
origin={0,-100},
extent={{-10,-10},{10,10}},
rotation=90)));
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange "Flange" annotation (
Placement(transformation(extent={{90,-10},{110,10}})));
Mechanics.Rotational.Interfaces.Support support if useSupport
"Support/housing of emf shaft"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
protected
Mechanics.Rotational.Components.Fixed fixed if not useSupport
annotation (Placement(transformation(extent={{-90,-20},{-70,0}})));
Mechanics.Rotational.Interfaces.InternalSupport internalSupport(tau=-tau) "Internal support"
annotation (Placement(transformation(extent={{-90,-10},{-70,10}})));
equation
v = p.v - n.v;
0 = p.i + n.i;
i = p.i;
phi = flange.phi - internalSupport.phi;
w = der(phi);
k*w = v;
tau = -k*i;
tauElectrical = -tau;
tau = flange.tau;
connect(internalSupport.flange, support) annotation (Line(
points={{-80,0},{-100,0}}));
connect(internalSupport.flange, fixed.flange) annotation (Line(
points={{-80,0},{-80,-10}}));
annotation (
defaultComponentName="emf",
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
100}}), graphics={
Rectangle(
extent={{-85,10},{-36,-10}},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={192,192,192}),
Rectangle(
extent={{35,10},{100,-10}},
fillPattern=FillPattern.HorizontalCylinder,
fillColor={192,192,192}),
Ellipse(
extent={{-40,40},{40,-40}},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
lineColor={0,0,255}),
Text(
extent={{-150,90},{150,50}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-150,-50},{150,-90}},
textString="k=%k"),
Line(
visible=not useSupport,
points={{-100,-30},{-40,-30}}),
Line(
visible=not useSupport,
points={{-100,-50},{-80,-30}}),
Line(
visible=not useSupport,
points={{-80,-50},{-60,-30}}),
Line(
visible=not useSupport,
points={{-60,-50},{-40,-30}}),
Line(
visible=not useSupport,
points={{-70,-30},{-70,-10}}),
Line(points={{0,40},{0,50}}, color={0,0,255}),
Line(points={{0,-50},{0,-40}}, color={0,0,255})}),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={Polygon(
points={{-17,95},{-20,85},{-23,95},{-17,95}},
lineColor={160,160,164},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),Line(points={{-20,110},{-20,85}},
color={160,160,164}),Text(
extent={{-40,110},{-30,90}},
textColor={160,160,164},
textString="i"),Line(points={{9,75},{19,75}}, color={192,192,192}),
Line(points={{-20,-110},{-20,-85}}, color={160,160,164}),Polygon(
points={{-17,-100},{-20,-110},{-23,-100},{-17,-100}},
lineColor={160,160,164},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),Text(
extent={{-40,-110},{-30,-90}},
textColor={160,160,164},
textString="i"),Line(points={{8,-79},{18,-79}}, color={192,192,192}),
Line(points={{14,80},{14,70}}, color={192,192,192})}),
Documentation(info="<html>
<p>EMF transforms electrical energy into rotational mechanical energy. It is used as basic building block of an electrical motor. The mechanical connector flange can be connected to elements of the Modelica.Mechanics.Rotational library. flange.tau is the cut-torque, flange.phi is the angle at the rotational connection.</p>
</html>", revisions="<html>
<ul>
<li><em> 1998 </em>
by Martin Otter<br> initially implemented<br>
</li>
</ul>
</html>"));
end RotationalEMF;
model TranslationalEMF "Electromotoric force (electric/mechanic transformer)"
parameter Boolean useSupport=false
"= true, if support flange enabled, otherwise implicitly grounded"
annotation (
Evaluate=true,
HideResult=true,
choices(checkBox=true));
parameter SI.ElectricalForceConstant k(start=1)
"Transformation coefficient";
SI.Voltage v "Voltage drop between the two pins";
SI.Current i "Current flowing from positive to negative pin";
SI.Position s "Position of flange relative to support";
SI.Velocity vel "Velocity of flange relative to support";
SI.Force f "Force of flange";
SI.Force fElectrical "Electrical force";
Modelica.Electrical.Analog.Interfaces.PositivePin p "Positive electrical pin" annotation (Placement(
transformation(
origin={0,100},
extent={{-10,-10},{10,10}},
rotation=90)));
Modelica.Electrical.Analog.Interfaces.NegativePin n "Negative electrical pin" annotation (Placement(
transformation(
origin={0,-100},
extent={{-10,-10},{10,10}},
rotation=90)));
Modelica.Mechanics.Translational.Interfaces.Flange_b flange "Flange" annotation (
Placement(transformation(extent={{90,-10},{110,10}})));
Modelica.Mechanics.Translational.Interfaces.Support support if useSupport
"Support/housing"
annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
protected
Modelica.Mechanics.Translational.Components.Fixed fixed if not useSupport
annotation (Placement(transformation(extent={{-90,-20},{-70,0}})));
Modelica.Mechanics.Translational.Interfaces.InternalSupport internalSupport(f=-f) "Internal support"
annotation (Placement(transformation(extent={{-90,-10},{-70,10}})));
equation
v = p.v - n.v;
0 = p.i + n.i;
i = p.i;
s = flange.s - internalSupport.s;
vel = der(s);
k*vel = v;
f = -k*i;
fElectrical = -f;
f = flange.f;
connect(internalSupport.flange, support) annotation (Line(
points={{-80,0},{-90,0},{-90,0},{-100,0}}, color={0,127,0}));
connect(internalSupport.flange, fixed.flange) annotation (Line(
points={{-80,0},{-80,-10}}, color={0,127,0}));
annotation (defaultComponentName="emf",
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
100}}), graphics={
Rectangle(
extent={{-90,51},{-40,-50}},
fillColor={135,135,135},
fillPattern=FillPattern.HorizontalCylinder),
Rectangle(
extent={{-21,20},{90,-20}},
lineColor={135,135,135},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Text(
extent={{40,-40},{200,-80}},
textString="k=%k"),
Line(points={{-30,49},{-30,80},{0,80},{0,91}}, color={0,0,255}),
Line(points={{20,-49},{20,-80},{0,-80},{0,-89},{0,-90}}, color={0,0,255}),
Ellipse(extent={{-21,50},{9,-50}}, lineColor={0,0,255}),
Ellipse(extent={{2,50},{32,-50}}, lineColor={0,0,255}),
Ellipse(extent={{-43,50},{-13,-50}}, lineColor={0,0,255}),
Rectangle(
extent={{-4,20},{-1,-20}},
lineColor={135,135,135},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{7,20},{10,-20}},
lineColor={135,135,135},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-14,20},{-11,-20}},
lineColor={135,135,135},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{19,20},{44,-20}},
lineColor={135,135,135},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Line(
visible=not useSupport,
points={{-100,-70},{-40,-70}}),
Line(
visible=not useSupport,
points={{-100,-90},{-80,-70}}),
Line(
visible=not useSupport,
points={{-80,-90},{-60,-70}}),
Line(
visible=not useSupport,
points={{-60,-90},{-40,-70}}),
Line(
visible=not useSupport,
points={{-70,-70},{-70,-50}}),
Text(
extent={{20,80},{220,40}},
textString="%name",
textColor={0,0,255})}),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={Polygon(
points={{-17,95},{-20,85},{-23,95},{-17,95}},
lineColor={160,160,164},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),Line(points={{-20,110},{-20,85}},
color={160,160,164}),Text(
extent={{-40,110},{-30,90}},
textColor={160,160,164},
textString="i"),Line(points={{9,75},{19,75}}, color={192,192,192}),
Line(points={{-20,-110},{-20,-85}}, color={160,160,164}),Polygon(
points={{-17,-100},{-20,-110},{-23,-100},{-17,-100}},
lineColor={160,160,164},
fillColor={160,160,164},
fillPattern=FillPattern.Solid),Text(
extent={{-40,-110},{-30,-90}},
textColor={160,160,164},
textString="i"),Line(points={{8,-79},{18,-79}}, color={192,192,192}),
Line(points={{14,80},{14,70}}, color={192,192,192}),Polygon(
points={{140,3},{150,0},{140,-3},{140,3},{140,3}},
fillPattern=FillPattern.Solid)}),
Documentation(info="<html>
<p>EMF transforms electrical energy into translational mechanical energy. It is used as basic building block of an electrical linear motor. The mechanical connector flange can be connected to elements of the Modelica.Mechanics.Translational library. flange.f is the cut-force, flange.s is the distance at the translational connection.</p>
</html>", revisions="<html>
<dl>
<dt>2009</dt>
<dd>by Anton Haumer<br> initially implemented</dd>
</dl>
</html>"));
end TranslationalEMF;
model VCV "Linear voltage-controlled voltage source"
extends Interfaces.TwoPort;
parameter Real gain(start=1) "Voltage gain";
equation
v2 = v1*gain;
i1 = 0;
annotation (defaultComponentName="vcv",
Documentation(info="<html>
<p>The linear voltage-controlled voltage source is a TwoPort. The right port voltage v2 is controlled by the left port voltage v1 via</p>
<blockquote><pre>
v2 = v1 * gain.
</pre></blockquote>
<p>The left port current is zero. Any voltage gain can be chosen.</p>
</html>", revisions="<html>
<ul>