forked from OpenIPSL/OpenIPSL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenIPSL_GFM_DLL.mo
1430 lines (1369 loc) · 68.8 KB
/
OpenIPSL_GFM_DLL.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 ;
package OpenIPSL_GFM_DLL
class GFM_DLL
extends ExternalObject;
function constructor
input Real c_filt;
input Real r_filt;
input Real l_filt;
input Real r_l;
input Real Vbase;
input Real Sbase;
input Real VDC_base;
input Real w_type;
output GFM_DLL gfm_dll;
external "C" gfm_dll = init_gfm_model(c_filt,r_filt,l_filt,r_l,Vbase,Sbase,
VDC_base,w_type) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end constructor;
function destructor
input GFM_DLL gfm_dll;
external "C" deinit_gfm_model(gfm_dll) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end destructor;
annotation (Icon(graphics={Rectangle(extent={{-100,100},{100,-100}},
lineColor={255,0,0}), Text(
extent={{-100,44},{98,-104}},
textColor={238,46,47},
textString="Class
")}));
end GFM_DLL;
package Functions
function my_add_c
input Real a;
input Real b;
output Real sum;
external "C" sum = my_add(a,b) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end my_add_c;
function save_ss_state
input GFM_DLL gfm_dll;
external "C" save_states(gfm_dll) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end save_ss_state;
function load_ss_state
input GFM_DLL gfm_dll;
output Real x;
external "C" x = load_states(gfm_dll) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end load_ss_state;
function update
input GFM_DLL gfm_dll;
input Real t;
input Real va;
input Real vb;
input Real vc;
input Real ia;
input Real ib;
input Real ic;
input Real ial;
input Real ibl;
input Real icl;
input Real pref;
input Real qref;
input Real vref;
external "C" update_gfm_input(gfm_dll,t,va,vb,vc,ia,ib,ic,ial,ibl,icl,pref,qref,vref) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end update;
function model_output
input GFM_DLL gfm_dll;
output Real out[12];
external "C" model_calculate(gfm_dll, out) annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end model_output;
function get_time
output Real out;
external "C" out = get_sim_time() annotation (Library="GFM_GFL_IBR",LibraryDirectory="modelica://OpenIPSL/Resources/Library");
end get_time;
end Functions;
package Tests
model test
constant Real line_inductance = 0;
constant Real line_resistance = 0;
Blocks.GFM_GFL_IBR gFM_GFL_IBR annotation (Placement(transformation(rotation=0,
extent={{-62,-30},{-2,30}})));
Modelica.Blocks.Sources.Constant Qref(k=0)
annotation (Placement(transformation(extent={{-92,-6},{-80,6}})));
Modelica.Blocks.Sources.Constant Vref(k=1)
annotation (Placement(transformation(extent={{-92,-24},{-80,-12}})));
Modelica.Blocks.Sources.Step Pref(
height=0.3,
offset=0.5,
startTime=10)
annotation (Placement(transformation(extent={{-92,12},{-80,24}})));
Blocks.GridWithFault gridWithFault(FaultVoltage=0.4) annotation (Placement(
transformation(rotation=0, extent={{28,-30},{88,30}})));
equation
connect(Qref.y, gFM_GFL_IBR.Q_ref_pu)
annotation (Line(points={{-79.4,0},{-62,0}}, color={0,0,127}));
connect(Vref.y, gFM_GFL_IBR.V_ref_pu)
annotation (Line(points={{-79.4,-18},{-62,-18}}, color={0,0,127}));
connect(Pref.y, gFM_GFL_IBR.P_ref_pu)
annotation (Line(points={{-79.4,18},{-62,18}}, color={0,0,127}));
connect(gFM_GFL_IBR.n2, gridWithFault.p)
annotation (Line(points={{-2,18},{-2,18},{28,18}}, color={0,0,255}));
connect(gridWithFault.p1, gFM_GFL_IBR.n1)
annotation (Line(points={{28,0},{-2,0}}, color={0,0,255}));
connect(gFM_GFL_IBR.n, gridWithFault.p2)
annotation (Line(points={{-2,-18},{28,-18}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent={{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
StopTime=20,
Interval=1e-05,
__Dymola_fixedstepsize=1e-05,
__Dymola_Algorithm="Euler"));
end test;
model test_line
constant Real line_inductance = 0;
constant Real line_resistance = 0;
parameter Real Inductance = 1e-9
"line inductance";
Blocks.GFM_GFL_IBR gFM_GFL_IBR annotation (Placement(transformation(rotation=0,
extent={{-68,-30},{-8,30}})));
Modelica.Blocks.Sources.Constant Qref(k=0)
annotation (Placement(transformation(extent={{-98,-6},{-86,6}})));
Modelica.Blocks.Sources.Constant Vref(k=1)
annotation (Placement(transformation(extent={{-98,-24},{-86,-12}})));
Modelica.Blocks.Sources.Step Pref(
height=0.3,
offset=0.5,
startTime=10)
annotation (Placement(transformation(extent={{-98,12},{-86,24}})));
Blocks.GridWithFault gridWithFault(FaultVoltage=0.4) annotation (Placement(
transformation(rotation=0, extent={{20,-30},{80,30}})));
equation
connect(Qref.y, gFM_GFL_IBR.Q_ref_pu)
annotation (Line(points={{-85.4,0},{-68,0}}, color={0,0,127}));
connect(Vref.y, gFM_GFL_IBR.V_ref_pu)
annotation (Line(points={{-85.4,-18},{-68,-18}}, color={0,0,127}));
connect(Pref.y, gFM_GFL_IBR.P_ref_pu)
annotation (Line(points={{-85.4,18},{-68,18}}, color={0,0,127}));
connect(gFM_GFL_IBR.n2, gridWithFault.p)
annotation (Line(points={{-8,18},{20,18},{20,18}}, color={0,0,255}));
connect(gridWithFault.p1, gFM_GFL_IBR.n1)
annotation (Line(points={{20,0},{-8,0}}, color={0,0,255}));
connect(gFM_GFL_IBR.n, gridWithFault.p2)
annotation (Line(points={{-8,-18},{20,-18}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent={{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
StopTime=20,
Interval=1e-05,
__Dymola_fixedstepsize=1e-05,
__Dymola_Algorithm="Euler"));
end test_line;
model test_no_fault
constant Real line_inductance = 0;
constant Real line_resistance = 0;
Blocks.GFM_GFL_IBR gFM_GFL_IBR annotation (Placement(transformation(rotation=0,
extent={{-62,-30},{-2,30}})));
Modelica.Blocks.Sources.Constant Qref(k=0)
annotation (Placement(transformation(extent={{-92,-6},{-80,6}})));
Modelica.Blocks.Sources.Constant Vref(k=1)
annotation (Placement(transformation(extent={{-92,-24},{-80,-12}})));
Modelica.Blocks.Sources.Step Pref(
height=0,
offset=0.5,
startTime=10)
annotation (Placement(transformation(extent={{-92,12},{-80,24}})));
Blocks.GridWithFault gridWithFault(FaultVoltage=1) annotation (Placement(
transformation(rotation=0, extent={{28,-30},{88,30}})));
equation
connect(Qref.y, gFM_GFL_IBR.Q_ref_pu)
annotation (Line(points={{-79.4,0},{-62,0}}, color={0,0,127}));
connect(Vref.y, gFM_GFL_IBR.V_ref_pu)
annotation (Line(points={{-79.4,-18},{-62,-18}}, color={0,0,127}));
connect(Pref.y, gFM_GFL_IBR.P_ref_pu)
annotation (Line(points={{-79.4,18},{-62,18}}, color={0,0,127}));
connect(gFM_GFL_IBR.n2, gridWithFault.p)
annotation (Line(points={{-2,18},{-2,18},{28,18}}, color={0,0,255}));
connect(gridWithFault.p1, gFM_GFL_IBR.n1)
annotation (Line(points={{28,0},{-2,0}}, color={0,0,255}));
connect(gFM_GFL_IBR.n, gridWithFault.p2)
annotation (Line(points={{-2,-18},{28,-18}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent={{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
StopTime=5,
Interval=1e-05,
__Dymola_fixedstepsize=1e-05,
__Dymola_Algorithm="Euler"));
end test_no_fault;
model init_ss_p05_v10
constant Real line_inductance = 0;
constant Real line_resistance = 0;
Blocks.GFM_GFL_IBR_Init_SS
gFM_GFL_IBR_Init_SS
annotation (Placement(transformation(rotation=0,
extent={{-62,-30},{-2,30}})));
Modelica.Blocks.Sources.Constant Qref(k=0)
annotation (Placement(transformation(extent={{-92,-6},{-80,6}})));
Modelica.Blocks.Sources.Constant Vref(k=1)
annotation (Placement(transformation(extent={{-92,-24},{-80,-12}})));
Modelica.Blocks.Sources.Step Pref(
height=0,
offset=0.5,
startTime=10)
annotation (Placement(transformation(extent={{-92,12},{-80,24}})));
Blocks.GridWithFault gridWithFault_Init(FaultVoltage=1, FaultTime=1)
annotation (Placement(
transformation(rotation=0, extent={{32,-30},{92,30}})));
equation
connect(Qref.y, gFM_GFL_IBR_Init_SS.Q_ref_pu)
annotation (Line(points={{-79.4,0},{-62,0}}, color={0,0,127}));
connect(Vref.y, gFM_GFL_IBR_Init_SS.V_ref_pu)
annotation (Line(points={{-79.4,-18},{-62,-18}}, color={0,0,127}));
connect(Pref.y, gFM_GFL_IBR_Init_SS.P_ref_pu)
annotation (Line(points={{-79.4,18},{-62,18}}, color={0,0,127}));
connect(gFM_GFL_IBR_Init_SS.n2, gridWithFault_Init.p)
annotation (Line(points={{-2,18},{32,18}}, color={0,0,255}));
connect(gridWithFault_Init.p1, gFM_GFL_IBR_Init_SS.n1)
annotation (Line(points={{32,0},{-2,0}}, color={0,0,255}));
connect(gFM_GFL_IBR_Init_SS.n, gridWithFault_Init.p2)
annotation (Line(points={{-2,-18},{32,-18}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent={{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
StopTime=5,
Interval=1e-05,
__Dymola_fixedstepsize=1e-05,
__Dymola_Algorithm="Rkfix4"));
end init_ss_p05_v10;
model init_ss_line
constant Real line_inductance = 0;
constant Real line_resistance = 0.1;
Blocks.GFM_GFL_IBR_Init_SS
gFM_GFL_IBR_Init_SS
annotation (Placement(transformation(rotation=0,
extent={{-62,-30},{-2,30}})));
Modelica.Blocks.Sources.Constant Qref(k=0)
annotation (Placement(transformation(extent={{-92,-6},{-80,6}})));
Modelica.Blocks.Sources.Constant Vref(k=1)
annotation (Placement(transformation(extent={{-92,-24},{-80,-12}})));
Modelica.Blocks.Sources.Step Pref(
height=0,
offset=0.5,
startTime=10)
annotation (Placement(transformation(extent={{-92,12},{-80,24}})));
Blocks.GridWithFault gridWithFault_Init(FaultVoltage=0.5, FaultTime=1)
annotation (Placement(
transformation(rotation=0, extent={{74,-30},{134,30}})));
Modelica.Electrical.Analog.Basic.Resistor resistor(R=line_resistance)
annotation (Placement(transformation(extent={{24,-10},{44,10}})));
Modelica.Electrical.Analog.Basic.Resistor resistor1(R=line_resistance)
annotation (Placement(transformation(extent={{24,-28},{44,-8}})));
Modelica.Electrical.Analog.Basic.Resistor resistor2(R=line_resistance)
annotation (Placement(transformation(extent={{24,8},{44,28}})));
equation
connect(Qref.y, gFM_GFL_IBR_Init_SS.Q_ref_pu)
annotation (Line(points={{-79.4,0},{-62,0}}, color={0,0,127}));
connect(Vref.y, gFM_GFL_IBR_Init_SS.V_ref_pu)
annotation (Line(points={{-79.4,-18},{-62,-18}}, color={0,0,127}));
connect(Pref.y, gFM_GFL_IBR_Init_SS.P_ref_pu)
annotation (Line(points={{-79.4,18},{-62,18}}, color={0,0,127}));
connect(gridWithFault_Init.p1, resistor.n)
annotation (Line(points={{74,0},{44,0}}, color={0,0,255}));
connect(gFM_GFL_IBR_Init_SS.n1, resistor.p)
annotation (Line(points={{-2,0},{24,0}}, color={0,0,255}));
connect(resistor2.p, gFM_GFL_IBR_Init_SS.n2)
annotation (Line(points={{24,18},{-2,18}}, color={0,0,255}));
connect(resistor2.n, gridWithFault_Init.p)
annotation (Line(points={{44,18},{74,18}}, color={0,0,255}));
connect(gFM_GFL_IBR_Init_SS.n, resistor1.p)
annotation (Line(points={{-2,-18},{24,-18}}, color={0,0,255}));
connect(resistor1.n, gridWithFault_Init.p2)
annotation (Line(points={{44,-18},{74,-18}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent={{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
StopTime=5,
Interval=1e-05,
__Dymola_fixedstepsize=1e-05,
__Dymola_Algorithm="Euler"));
end init_ss_line;
model init_ss_line_L
constant Real line_inductance = 1e-9;
constant Real line_resistance = 0.1;
Blocks.GFM_GFL_IBR_Init_SS
gFM_GFL_IBR_Init_SS
annotation (Placement(transformation(rotation=0,
extent={{-62,-30},{-2,30}})));
Modelica.Blocks.Sources.Constant Qref(k=0)
annotation (Placement(transformation(extent={{-92,-6},{-80,6}})));
Modelica.Blocks.Sources.Constant Vref(k=1)
annotation (Placement(transformation(extent={{-92,-24},{-80,-12}})));
Modelica.Blocks.Sources.Step Pref(
height=0,
offset=0.5,
startTime=10)
annotation (Placement(transformation(extent={{-92,12},{-80,24}})));
Blocks.GridWithFault gridWithFault_Init(FaultVoltage=0.5, FaultTime=1)
annotation (Placement(
transformation(rotation=0, extent={{36,-30},{96,30}})));
Modelica.Electrical.Analog.Basic.Inductor inductor(L=Modelica.Constants.eps)
annotation (Placement(transformation(extent={{6,8},{26,28}})));
Modelica.Electrical.Analog.Basic.Inductor inductor1(L=Modelica.Constants.eps)
annotation (Placement(transformation(extent={{6,-10},{26,10}})));
Modelica.Electrical.Analog.Basic.Inductor inductor2(L=Modelica.Constants.eps)
annotation (Placement(transformation(extent={{6,-28},{26,-8}})));
equation
connect(Qref.y, gFM_GFL_IBR_Init_SS.Q_ref_pu)
annotation (Line(points={{-79.4,0},{-62,0}}, color={0,0,127}));
connect(Vref.y, gFM_GFL_IBR_Init_SS.V_ref_pu)
annotation (Line(points={{-79.4,-18},{-62,-18}}, color={0,0,127}));
connect(Pref.y, gFM_GFL_IBR_Init_SS.P_ref_pu)
annotation (Line(points={{-79.4,18},{-62,18}}, color={0,0,127}));
connect(gFM_GFL_IBR_Init_SS.n2, inductor.p)
annotation (Line(points={{-2,18},{6,18}}, color={0,0,255}));
connect(inductor.n, gridWithFault_Init.p)
annotation (Line(points={{26,18},{36,18}}, color={0,0,255}));
connect(gFM_GFL_IBR_Init_SS.n1, inductor1.p)
annotation (Line(points={{-2,0},{6,0}}, color={0,0,255}));
connect(inductor1.n, gridWithFault_Init.p1)
annotation (Line(points={{26,0},{36,0}}, color={0,0,255}));
connect(gridWithFault_Init.p2, inductor2.n)
annotation (Line(points={{36,-18},{26,-18}}, color={0,0,255}));
connect(inductor2.p, gFM_GFL_IBR_Init_SS.n)
annotation (Line(points={{6,-18},{-2,-18}}, color={0,0,255}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent={{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}), Diagram(
coordinateSystem(preserveAspectRatio=false)),
experiment(
StopTime=5,
Interval=1e-05,
__Dymola_fixedstepsize=1e-05,
__Dymola_Algorithm="Euler"));
end init_ss_line_L;
end Tests;
package Blocks
model GFM_GFL_IBR
Real out[12];
//Real get_time_result;
parameter Modelica.Units.SI.Capacitance c_filter = 0.0000627830 "Filter Capacitance";
parameter Modelica.Units.SI.Resistance r_damp = 845 "Damping Resistance";
parameter Modelica.Units.SI.Inductance l_filter = 0.0008965728461 "Filter Inductance";
parameter Modelica.Units.SI.Resistance r_l = 0.021125 "Inductor Resistance";
parameter Real Vbase = 6.5 "kV";
parameter Real Sbase = 10 "MVA";
parameter Real VDC_base = 13 "kV";
parameter Real w_type = 1 "0 - PLL, 1 - Droop";
GFM_DLL gfm_struct = GFM_DLL(c_filter,r_damp,l_filter,r_l,Vbase,Sbase,VDC_base,w_type);
Modelica.Electrical.Analog.Basic.Resistor resistor(R=r_l)
annotation (Placement(transformation(extent={{-30,4},{-18,16}})));
Modelica.Electrical.Analog.Basic.Inductor inductor(i(start=0, fixed=true), L=
l_filter) annotation (Placement(transformation(extent={{-10,4},{2,16}})));
Modelica.Electrical.Analog.Basic.Capacitor c_b(v(start=0, fixed=false), C=
c_filter) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={20,-26})));
Modelica.Electrical.Analog.Basic.Resistor r_b(R=r_damp) annotation (Placement(
transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={52,-26})));
Modelica.Electrical.Analog.Basic.Capacitor c_c(v(start=0, fixed=false), C=
c_filter) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={30,-26})));
Modelica.Electrical.Analog.Basic.Resistor r_c(R=r_damp) annotation (Placement(
transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={62,-26})));
Modelica.Electrical.Analog.Basic.Capacitor c_a(v(start=0, fixed=false), C=
c_filter) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={10,-26})));
Modelica.Electrical.Analog.Basic.Resistor r_a(R=r_damp) annotation (Placement(
transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={42,-26})));
Modelica.Electrical.Analog.Basic.Resistor resistor4(R=r_l)
annotation (Placement(transformation(extent={{-26,-6},{-14,6}})));
Modelica.Electrical.Analog.Basic.Inductor inductor1(i(start=0, fixed=true), L
=l_filter) annotation (Placement(transformation(extent={{-6,-6},{6,6}})));
Modelica.Electrical.Analog.Basic.Resistor resistor5(R=r_l)
annotation (Placement(transformation(extent={{-22,-16},{-10,-4}})));
Modelica.Electrical.Analog.Basic.Inductor inductor2(i(start=0, fixed=true), L
=l_filter)
annotation (Placement(transformation(extent={{-2,-16},{10,-4}})));
tools.votlage_current_sensor bridge_sensor_c
annotation (Placement(transformation(extent={{-48,8},{-38,12}})));
tools.votlage_current_sensor bridge_sensor_b
annotation (Placement(transformation(extent={{-48,-2},{-38,2}})));
tools.votlage_current_sensor bridge_sensor_a
annotation (Placement(transformation(extent={{-48,-12},{-38,-8}})));
tools.votlage_current_sensor grid_sensor_c
annotation (Placement(transformation(extent={{68,8},{78,12}})));
tools.votlage_current_sensor grid_sensor_b
annotation (Placement(transformation(extent={{68,-2},{78,2}})));
tools.votlage_current_sensor grid_sensor_a
annotation (Placement(transformation(extent={{68,-12},{78,-8}})));
Modelica.Electrical.Analog.Sources.SignalVoltage phase_c annotation (
Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={-78,-22})));
Modelica.Electrical.Analog.Sources.SignalVoltage phase_b annotation (
Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={-66,-22})));
Modelica.Electrical.Analog.Sources.SignalVoltage phase_a annotation (
Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={-54,-22})));
Modelica.Electrical.Analog.Basic.Ground ground2
annotation (Placement(transformation(extent={{-72,-56},{-60,-44}})));
Modelica.Electrical.Analog.Basic.Ground ground1
annotation (Placement(transformation(extent={{30,-62},{42,-50}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n annotation (Placement(
transformation(rotation=0, extent={{90,-70},{110,-50}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n1 annotation (Placement(
transformation(rotation=0, extent={{90,-10},{110,10}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n2 annotation (Placement(
transformation(rotation=0, extent={{90,50},{110,70}})));
Modelica.Blocks.Interfaces.RealInput P_ref_pu
annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
Modelica.Blocks.Interfaces.RealInput Q_ref_pu
annotation (Placement(transformation(extent={{-120,-20},{-80,20}})));
Modelica.Blocks.Interfaces.RealInput V_ref_pu
annotation (Placement(transformation(extent={{-120,-80},{-80,-40}})));
algorithm
Functions.update(
gfm_struct,
time,
grid_sensor_a.voltage,
grid_sensor_b.voltage,
grid_sensor_c.voltage,
grid_sensor_a.current,
grid_sensor_b.current,
grid_sensor_c.current,
bridge_sensor_a.current,
bridge_sensor_b.current,
bridge_sensor_c.current,
P_ref_pu,
Q_ref_pu,
V_ref_pu);
out :=Functions.model_output(gfm_struct);
phase_a.v :=out[1];
phase_b.v :=out[2];
phase_c.v :=out[3];
when terminal() then
OpenIPSL_GFM_DLL.Functions.save_ss_state(gfm_struct);
Modelica.Utilities.Streams.print("Saved states in list.dat");
end when;
//Modelica.Utilities.Streams.print(String(time));
equation
connect(resistor.n,inductor. p)
annotation (Line(points={{-18,10},{-10,10}},
color={0,0,255}));
connect(resistor4.n,inductor1. p)
annotation (Line(points={{-14,0},{-6,0}},
color={0,0,255}));
connect(resistor5.n,inductor2. p)
annotation (Line(points={{-10,-10},{-2,-10}},
color={0,0,255}));
connect(c_a.p,inductor2. n)
annotation (Line(points={{10,-20},{10,-10}}, color={0,0,255}));
connect(resistor.p,bridge_sensor_c. n)
annotation (Line(points={{-30,10},{-38,10}}, color={0,0,255}));
connect(bridge_sensor_b.n,resistor4. p)
annotation (Line(points={{-38,0},{-26,0}}, color={0,0,255}));
connect(resistor5.p,bridge_sensor_a. n)
annotation (Line(points={{-22,-10},{-38,-10}}, color={0,0,255}));
connect(inductor.n,grid_sensor_c. p)
annotation (Line(points={{2,10},{68,10}}, color={0,0,255}));
connect(inductor1.n,grid_sensor_b. p)
annotation (Line(points={{6,0},{68,0}}, color={0,0,255}));
connect(inductor2.n,grid_sensor_a. p)
annotation (Line(points={{10,-10},{68,-10}}, color={0,0,255}));
connect(c_b.p,grid_sensor_b. p)
annotation (Line(points={{20,-20},{20,0},{68,0}}, color={0,0,255}));
connect(c_c.p,grid_sensor_c. p)
annotation (Line(points={{30,-20},{30,10},{68,10}}, color={0,0,255}));
connect(phase_b.n,ground2. p)
annotation (Line(points={{-66,-28},{-66,-44}}, color={0,0,255}));
connect(phase_c.n,ground2. p) annotation (Line(points={{-78,-28},{-78,-40},{-66,
-40},{-66,-44}}, color={0,0,255}));
connect(phase_a.n,ground2. p) annotation (Line(points={{-54,-28},{-54,-40},{-66,
-40},{-66,-44}}, color={0,0,255}));
connect(phase_a.p,bridge_sensor_a. p)
annotation (Line(points={{-54,-16},{-48,-16},{-48,-10}}, color={0,0,255}));
connect(phase_b.p,bridge_sensor_b. p)
annotation (Line(points={{-66,-16},{-66,0},{-48,0}}, color={0,0,255}));
connect(phase_c.p,bridge_sensor_c. p)
annotation (Line(points={{-78,-16},{-78,10},{-48,10}}, color={0,0,255}));
connect(r_c.p,grid_sensor_c. p)
annotation (Line(points={{62,-20},{62,10},{68,10}}, color={0,0,255}));
connect(r_b.p,grid_sensor_b. p)
annotation (Line(points={{52,-20},{52,0},{68,0}}, color={0,0,255}));
connect(r_a.p,grid_sensor_a. p)
annotation (Line(points={{42,-20},{42,-10},{68,-10}}, color={0,0,255}));
connect(c_a.n,r_c. n) annotation (Line(points={{10,-32},{10,-36},{62,-36},{62,
-32}}, color={0,0,255}));
connect(c_b.n,r_c. n) annotation (Line(points={{20,-32},{20,-36},{62,-36},{62,
-32}}, color={0,0,255}));
connect(c_c.n,r_c. n) annotation (Line(points={{30,-32},{30,-36},{62,-36},{62,
-32}}, color={0,0,255}));
connect(r_a.n,r_c. n) annotation (Line(points={{42,-32},{42,-36},{62,-36},{62,
-32}}, color={0,0,255}));
connect(r_b.n,r_c. n) annotation (Line(points={{52,-32},{52,-36},{62,-36},{62,
-32}}, color={0,0,255}));
connect(ground1.p,r_c. n) annotation (Line(points={{36,-50},{36,-36},{62,-36},
{62,-32}}, color={0,0,255}));
connect(n, grid_sensor_a.n)
annotation (Line(points={{100,-60},{84,-60},{84,-10},{78,-10}},
color={0,0,255}));
connect(n1, grid_sensor_b.n)
annotation (Line(points={{100,0},{78,0}}, color={0,0,255}));
connect(n2, grid_sensor_c.n)
annotation (Line(points={{100,60},{84,60},{84,10},{78,10}},
color={0,0,255}));
annotation (Icon(graphics={
Rectangle(extent={{-100,100},{100,-100}}, lineColor={28,108,200}),
Line(points={{-100,100},{100,-100}}, color={28,108,200}),
Text(
extent={{-14,82},{78,16}},
textColor={28,108,200},
textString="AC"),
Text(
extent={{-74,-14},{18,-80}},
textColor={28,108,200},
textString="DC")}));
end GFM_GFL_IBR;
model GridWithFault
parameter Modelica.Units.SI.Voltage Vbase=6500 "base voltage L-L RMS";
parameter Real Vgrid = 1 "p.u.";
parameter Real FaultVoltage = 0.7 "p.u.";
parameter Modelica.Units.SI.Time FaultTime =5 "When fault happen";
parameter Modelica.Units.SI.Time FaultDuration = 0.1 "for how long";
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-64,-78})));
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1 annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-30,-48})));
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage2 annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-14,-18})));
Modelica.Blocks.Sources.Sine sine(
amplitude=sqrt(2)*Vbase/sqrt(3),
f=60,
phase=2.0943951023932) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={84,-24})));
Modelica.Blocks.Sources.Sine sine1(amplitude=sqrt(2)*Vbase/sqrt(3),f=60)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={84,-54})));
Modelica.Blocks.Sources.Sine sine2(
amplitude=sqrt(2)*Vbase/sqrt(3),
f=60,
phase=-2.0943951023932) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={84,-84})));
Modelica.Electrical.Analog.Basic.Ground ground4
annotation (Placement(transformation(extent={{-70,-106},{-58,-94}})));
Modelica.Blocks.Sources.Step step1(
height=FaultVoltage - Vgrid,
offset=Vgrid,
startTime=FaultTime)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={28,82})));
Modelica.Blocks.Math.Product product1 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={18,-18})));
Modelica.Blocks.Math.Product product2 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={18,-48})));
Modelica.Blocks.Math.Product product3 annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={18,-78})));
Modelica.Blocks.Continuous.FirstOrder firstOrder(
k=1,
T=0.0001,
initType=Modelica.Blocks.Types.Init.InitialState,
y_start=1) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={44,18})));
Modelica.Blocks.Sources.Step step2(
height=Vgrid - FaultVoltage,
offset=0,
startTime=FaultTime + FaultDuration)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={60,82})));
Modelica.Blocks.Math.Add add annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={44,46})));
Modelica.Electrical.Analog.Interfaces.PositivePin p annotation (Placement(
transformation(rotation=0, extent={{-110,50},{-90,70}}),
iconTransformation(extent={{-110,50},{-90,70}})));
Modelica.Electrical.Analog.Interfaces.PositivePin p1 annotation (Placement(
transformation(rotation=0, extent={{-110,-10},{-90,10}}),
iconTransformation(extent={{-110,-10},{-90,10}})));
Modelica.Electrical.Analog.Interfaces.PositivePin p2 annotation (Placement(
transformation(rotation=0, extent={{-110,-70},{-90,-50}}),
iconTransformation(extent={{-110,-70},{-90,-50}})));
Modelica.Electrical.Analog.Basic.Resistor resistor(R=1e6) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-76,-78})));
Modelica.Electrical.Analog.Basic.Resistor resistor1(R=1e6) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-46,-48})));
Modelica.Electrical.Analog.Basic.Resistor resistor2(R=1e6) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-24,-18})));
equation
connect(product1.u1,sine. y)
annotation (Line(points={{30,-24},{73,-24}}, color={0,0,127}));
connect(product2.u1,sine1. y)
annotation (Line(points={{30,-54},{73,-54}}, color={0,0,127}));
connect(product3.u1,sine2. y)
annotation (Line(points={{30,-84},{73,-84}}, color={0,0,127}));
connect(product1.y,signalVoltage2. v) annotation (Line(points={{7,-18},{-2,-18}},
color={0,0,127}));
connect(product2.y,signalVoltage1. v) annotation (Line(points={{7,-48},{-18,-48}},
color={0,0,127}));
connect(product3.y,signalVoltage. v) annotation (Line(points={{7,-78},{-52,-78}},
color={0,0,127}));
connect(firstOrder.y,product1. u2)
annotation (Line(points={{44,7},{44,-12},{30,-12}}, color={0,0,127}));
connect(product2.u2,firstOrder. y) annotation (Line(points={{30,-42},{44,-42},
{44,7}}, color={0,0,127}));
connect(product3.u2,firstOrder. y) annotation (Line(points={{30,-72},{44,-72},
{44,7}}, color={0,0,127}));
connect(firstOrder.u,add. y)
annotation (Line(points={{44,30},{44,35}}, color={0,0,127}));
connect(step1.y,add. u2) annotation (Line(points={{28,71},{28,68},{38,68},{38,
58}}, color={0,0,127}));
connect(step2.y,add. u1) annotation (Line(points={{60,71},{60,68},{50,68},{50,
58}}, color={0,0,127}));
connect(p, signalVoltage.p)
annotation (Line(points={{-100,60},{-64,60},{-64,-68}}, color={0,0,255}));
connect(p1, signalVoltage1.p)
annotation (Line(points={{-100,0},{-30,0},{-30,-38}}, color={0,0,255}));
connect(p2, signalVoltage2.p) annotation (Line(points={{-100,-60},{-78,-60},{-78,
-4},{-14,-4},{-14,-8}}, color={0,0,255}));
connect(signalVoltage2.n, ground4.p)
annotation (Line(points={{-14,-28},{-14,-94},{-64,-94}}, color={0,0,255}));
connect(signalVoltage1.n, ground4.p)
annotation (Line(points={{-30,-58},{-30,-94},{-64,-94}}, color={0,0,255}));
connect(signalVoltage.n, ground4.p)
annotation (Line(points={{-64,-88},{-64,-94}}, color={0,0,255}));
connect(resistor.n, signalVoltage.n)
annotation (Line(points={{-76,-88},{-64,-88}}, color={0,0,255}));
connect(resistor.p, signalVoltage.p)
annotation (Line(points={{-76,-68},{-64,-68}}, color={0,0,255}));
connect(resistor1.p, signalVoltage1.p)
annotation (Line(points={{-46,-38},{-30,-38}}, color={0,0,255}));
connect(resistor1.n, signalVoltage1.n)
annotation (Line(points={{-46,-58},{-30,-58}}, color={0,0,255}));
connect(resistor2.n, signalVoltage2.n)
annotation (Line(points={{-24,-28},{-14,-28}}, color={0,0,255}));
connect(resistor2.p, signalVoltage2.p)
annotation (Line(points={{-24,-8},{-14,-8}}, color={0,0,255}));
annotation (Icon(graphics={Rectangle(extent={{-100,100},{100,-100}},
lineColor={0,0,255}), Text(
extent={{-76,58},{88,-52}},
textColor={0,0,255},
textString="Grid")}));
end GridWithFault;
model Line_L
parameter Real Time = 1
"start";
parameter Real Inductance = 0
"line inductance";
parameter Real Resistance = 0
"line resistance";
Modelica.Electrical.Analog.Interfaces.PositivePin p annotation (Placement(
transformation(rotation=0, extent={{-110,-10},{-90,10}})));
Modelica.Electrical.Analog.Interfaces.PositivePin p1 annotation (Placement(
transformation(rotation=0, extent={{-110,-70},{-90,-50}})));
Modelica.Electrical.Analog.Interfaces.PositivePin p2 annotation (Placement(
transformation(rotation=0, extent={{-110,50},{-90,70}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n annotation (Placement(
transformation(rotation=0, extent={{90,-10},{110,10}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n1 annotation (Placement(
transformation(rotation=0, extent={{90,-70},{110,-50}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n2 annotation (Placement(
transformation(rotation=0, extent={{90,50},{110,70}})));
Modelica.Electrical.Analog.Basic.Inductor inductor(L=Inductance)
annotation (Placement(transformation(extent={{-12,10},{8,30}})));
Modelica.Electrical.Analog.Basic.Inductor inductor1(L=Inductance)
annotation (Placement(transformation(extent={{-10,-34},{10,-14}})));
Modelica.Electrical.Analog.Basic.Inductor inductor2(L=Inductance)
annotation (Placement(transformation(extent={{-10,-92},{10,-72}})));
equation
connect(p2, inductor.p) annotation (Line(points={{-100,60},{-18,60},{-18,
20},{-12,20}}, color={0,0,255}));
connect(p, inductor1.p) annotation (Line(points={{-100,0},{-16,0},{-16,
-24},{-10,-24}}, color={0,0,255}));
connect(p1, inductor2.p) annotation (Line(points={{-100,-60},{-16,-60},{
-16,-82},{-10,-82}}, color={0,0,255}));
connect(inductor.n, n2) annotation (Line(points={{8,20},{86,20},{86,60},{
100,60}}, color={0,0,255}));
connect(n, inductor1.n) annotation (Line(points={{100,0},{16,0},{16,-24},
{10,-24}}, color={0,0,255}));
connect(n1, inductor2.n) annotation (Line(points={{100,-60},{16,-60},{16,
-82},{10,-82}}, color={0,0,255}));
end Line_L;
model GFM_GFL_IBR_Init_SS
Real out[12];
//Real get_time_result;
parameter Modelica.Units.SI.Capacitance c_filter = 0.0000627830 "Filter Capacitance";
parameter Modelica.Units.SI.Resistance r_damp = 845 "Damping Resistance";
parameter Modelica.Units.SI.Inductance l_filter = 0.0008965728461 "Filter Inductance";
parameter Modelica.Units.SI.Resistance r_l = 0.021125 "Inductor Resistance";
parameter Real Vbase = 6.5 "kV";
parameter Real Sbase = 10 "MVA";
parameter Real VDC_base = 13 "kV";
parameter Real w_type = 1 "0 - PLL, 1 - Droop";
GFM_DLL gfm_struct = GFM_DLL(c_filter,r_damp,l_filter,r_l,Vbase,Sbase,VDC_base,w_type);
Modelica.Electrical.Analog.Basic.Resistor resistor(R=r_l)
annotation (Placement(transformation(extent={{-30,4},{-18,16}})));
Modelica.Electrical.Analog.Basic.Inductor inductor(i(start=-122.771, fixed=true),
L=
l_filter) annotation (Placement(transformation(extent={{-10,4},{2,16}})));
Modelica.Electrical.Analog.Basic.Capacitor c_b(v(start=-5.41e-10, fixed=false),
C=
c_filter) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={20,-26})));
Modelica.Electrical.Analog.Basic.Resistor r_b(R=r_damp) annotation (Placement(
transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={52,-26})));
Modelica.Electrical.Analog.Basic.Capacitor c_c(v(start=-4596.194, fixed=false),
C=
c_filter) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={30,-26})));
Modelica.Electrical.Analog.Basic.Resistor r_c(R=r_damp) annotation (Placement(
transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={62,-26})));
Modelica.Electrical.Analog.Basic.Capacitor c_a(v(start=4596.194, fixed=false),
C=
c_filter) annotation (Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={10,-26})));
Modelica.Electrical.Analog.Basic.Resistor r_a(R=r_damp) annotation (Placement(
transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={42,-26})));
Modelica.Electrical.Analog.Basic.Resistor resistor4(R=r_l)
annotation (Placement(transformation(extent={{-26,-6},{-14,6}})));
Modelica.Electrical.Analog.Basic.Inductor inductor1(i(start=125.84578, fixed=true),
L
=l_filter) annotation (Placement(transformation(extent={{-6,-6},{6,6}})));
Modelica.Electrical.Analog.Basic.Resistor resistor5(R=r_l)
annotation (Placement(transformation(extent={{-22,-16},{-10,-4}})));
Modelica.Electrical.Analog.Basic.Inductor inductor2(i(start=-3.074736, fixed=true),
L
=l_filter)
annotation (Placement(transformation(extent={{-2,-16},{10,-4}})));
tools.votlage_current_sensor_no_init
bridge_sensor_c
annotation (Placement(transformation(extent={{-48,8},{-38,12}})));
tools.votlage_current_sensor_no_init
bridge_sensor_b
annotation (Placement(transformation(extent={{-48,-2},{-38,2}})));
tools.votlage_current_sensor_no_init
bridge_sensor_a
annotation (Placement(transformation(extent={{-48,-12},{-38,-8}})));
tools.votlage_current_sensor_no_init
grid_sensor_c
annotation (Placement(transformation(extent={{68,8},{78,12}})));
tools.votlage_current_sensor_no_init
grid_sensor_b
annotation (Placement(transformation(extent={{68,-2},{78,2}})));
tools.votlage_current_sensor_no_init
grid_sensor_a
annotation (Placement(transformation(extent={{68,-12},{78,-8}})));
Modelica.Electrical.Analog.Sources.SignalVoltage phase_c annotation (
Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={-78,-22})));
Modelica.Electrical.Analog.Sources.SignalVoltage phase_b annotation (
Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={-66,-22})));
Modelica.Electrical.Analog.Sources.SignalVoltage phase_a annotation (
Placement(transformation(
extent={{-6,-6},{6,6}},
rotation=270,
origin={-54,-22})));
Modelica.Electrical.Analog.Basic.Ground ground2
annotation (Placement(transformation(extent={{-72,-56},{-60,-44}})));
Modelica.Electrical.Analog.Basic.Ground ground1
annotation (Placement(transformation(extent={{30,-62},{42,-50}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n annotation (Placement(
transformation(rotation=0, extent={{90,-70},{110,-50}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n1 annotation (Placement(
transformation(rotation=0, extent={{90,-10},{110,10}})));
Modelica.Electrical.Analog.Interfaces.NegativePin n2 annotation (Placement(
transformation(rotation=0, extent={{90,50},{110,70}})));
Modelica.Blocks.Interfaces.RealInput P_ref_pu
annotation (Placement(transformation(extent={{-120,40},{-80,80}})));
Modelica.Blocks.Interfaces.RealInput Q_ref_pu
annotation (Placement(transformation(extent={{-120,-20},{-80,20}})));
Modelica.Blocks.Interfaces.RealInput V_ref_pu
annotation (Placement(transformation(extent={{-120,-80},{-80,-40}})));
initial equation
OpenIPSL_GFM_DLL.Functions.load_ss_state(gfm_struct);
algorithm
Functions.update(
gfm_struct,
time,
grid_sensor_a.voltage,
grid_sensor_b.voltage,
grid_sensor_c.voltage,
grid_sensor_a.current,
grid_sensor_b.current,
grid_sensor_c.current,
bridge_sensor_a.current,
bridge_sensor_b.current,
bridge_sensor_c.current,
P_ref_pu,
Q_ref_pu,
V_ref_pu);
out :=Functions.model_output(gfm_struct);
phase_a.v :=out[1];
phase_b.v :=out[2];
phase_c.v :=out[3];
//Modelica.Utilities.Streams.print(String(time));
equation
connect(resistor.n,inductor. p)
annotation (Line(points={{-18,10},{-10,10}},
color={0,0,255}));
connect(resistor4.n,inductor1. p)
annotation (Line(points={{-14,0},{-6,0}},
color={0,0,255}));
connect(resistor5.n,inductor2. p)
annotation (Line(points={{-10,-10},{-2,-10}},
color={0,0,255}));
connect(c_a.p,inductor2. n)
annotation (Line(points={{10,-20},{10,-10}}, color={0,0,255}));
connect(resistor.p,bridge_sensor_c. n)
annotation (Line(points={{-30,10},{-38,10}}, color={0,0,255}));
connect(bridge_sensor_b.n,resistor4. p)
annotation (Line(points={{-38,0},{-26,0}}, color={0,0,255}));
connect(resistor5.p,bridge_sensor_a. n)
annotation (Line(points={{-22,-10},{-38,-10}}, color={0,0,255}));
connect(inductor.n,grid_sensor_c. p)
annotation (Line(points={{2,10},{68,10}}, color={0,0,255}));
connect(inductor1.n,grid_sensor_b. p)
annotation (Line(points={{6,0},{68,0}}, color={0,0,255}));
connect(inductor2.n,grid_sensor_a. p)
annotation (Line(points={{10,-10},{68,-10}}, color={0,0,255}));
connect(c_b.p,grid_sensor_b. p)
annotation (Line(points={{20,-20},{20,0},{68,0}}, color={0,0,255}));
connect(c_c.p,grid_sensor_c. p)
annotation (Line(points={{30,-20},{30,10},{68,10}}, color={0,0,255}));
connect(phase_b.n,ground2. p)
annotation (Line(points={{-66,-28},{-66,-44}}, color={0,0,255}));
connect(phase_c.n,ground2. p) annotation (Line(points={{-78,-28},{-78,-40},{-66,