-
Notifications
You must be signed in to change notification settings - Fork 1
/
OceanEngineering.mo
3309 lines (2546 loc) · 144 KB
/
OceanEngineering.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 OceanEngineering
extends Modelica.Icons.Package;
package Components
package Waves
package RegularWave
model Regular_Airy_Wave
extends Modelica.Blocks.Icons.Block;
OceanEngineering.Connectors.WaveDataConnector wdoc(n_omega_i = 1) annotation(
Placement(transformation(extent = {{80, -20}, {120, 20}})));
constant Real pi = Modelica.Constants.pi "Value of pi";
constant Real g = Modelica.Constants.g_n "Acceleration due to gravity";
parameter Modelica.SIunits.Length d = 100 "Water depth";
parameter Modelica.SIunits.Density rho_w = 1025 "Density of Water";
parameter Modelica.SIunits.Length Hr = 1 "Wave Height";
parameter Real Tr = 7 "Wave Period";
parameter Real Trmp = 20 "Wave ramp time";
parameter Real Tdel = 0 "Wave delay";
parameter Integer n_omega_i = 1 "Number of frequency components";
Real T[size(omega, 1)] "Wave period";
Modelica.SIunits.AngularFrequency omega[n_omega_i] "Frequency components of time series";
Modelica.SIunits.Length zeta0i[n_omega_i] "Amplitude of wave component";
Modelica.SIunits.Length SSE_X0 "Sea surface elevation at x=0 - to plot generated waves";
Real epsilon[n_omega_i] "Random phase of wave components";
Real k[n_omega_i](each unit = "m^-1") = OceanEngineering.Functions.waveNumberIterator(d, omega) "Wave number of component waves";
equation
for i in 1:n_omega_i loop
omega[i] = 2 * pi / Tr;
epsilon[i] = 0;
if time < Tdel then
zeta0i[i] = 0;
elseif time < Tdel + Trmp then
zeta0i[i] = sin(pi / 2 * (time - Tdel) / Trmp) * Hr / 2;
else
zeta0i[i] = Hr / 2;
end if;
T[i] = Tr;
end for;
SSE_X0 = sum(zeta0i .* cos(omega * time - 2 * pi * epsilon));
wdoc.d = d;
wdoc.rho_w = rho_w;
wdoc.omega = omega;
wdoc.T = T;
wdoc.k = k;
wdoc.epsilon = epsilon;
wdoc.zeta0i = zeta0i;
wdoc.SSE_X0 = SSE_X0;
annotation(
Icon(graphics = {Text(origin = {-54, 65}, extent = {{-40, 17}, {40, -17}}, textString = "H,T"), Rectangle(origin = {100, 0}, fillColor = {170, 255, 0}, fillPattern = FillPattern.Solid, extent = {{-20, -20}, {20, 20}}), Line(origin = {-15, 0}, points = {{-81, 0}, {81, 0}}), Line(origin = {-14.97, 1.01}, points = {{-81.0281, -1.00867}, {-33.0281, 42.9913}, {36.9719, -43.0087}, {80.9719, -1.00867}}, color = {0, 0, 255}, thickness = 0.5, smooth = Smooth.Bezier)}, coordinateSystem(initialScale = 0.1)),
experiment(StartTime = 0, StopTime = 400, Tolerance = 1e-06, Interval = 0.5));
end Regular_Airy_Wave;
end RegularWave;
package IrregularWave
model IRW_PM_RDFCWI
extends Modelica.Blocks.Icons.Block;
OceanEngineering.Connectors.WaveDataConnector wdoc(n_omega_i = 100) annotation(
Placement(transformation(extent = {{80, -20}, {120, 20}})));
constant Real pi = Modelica.Constants.pi "Value of pi";
constant Real g = Modelica.Constants.g_n "Acceleration due to gravity";
parameter Modelica.SIunits.Length d = 100 "Water depth";
parameter Modelica.SIunits.Density rho_w = 1025 "Density of Water";
parameter Modelica.SIunits.Length Hs = 1 "Significant Wave Height";
parameter Modelica.SIunits.AngularFrequency omega_min = 0.03141 "Lowest frequency component/frequency interval";
parameter Modelica.SIunits.AngularFrequency omega_max = 3.141 "Highest frequency component";
parameter Integer n_omega_i = 100 "Number of frequency components";
parameter Integer localSeed = 614657 "Local seed for random number generator";
parameter Integer globalSeed = 30020 "Global seed for random number generator";
parameter Real rnd_shft[n_omega_i] = OceanEngineering.Functions.randomNumberGenerator(localSeed, globalSeed, n_omega_i);
parameter Integer localSeed1 = 614757 "Local seed for random number generator";
parameter Integer globalSeed1 = 40020 "Global seed for random number generator";
parameter Real epsilon[n_omega_i] = OceanEngineering.Functions.randomNumberGenerator(localSeed1, globalSeed1, n_omega_i);
parameter Integer SSE_X0on = 1 "Flag for generating SSE profile";
parameter Real Trmp = 200 "Interval for ramping up of waves during start phase";
parameter Real omega[n_omega_i] = OceanEngineering.Functions.frequencySelector(omega_min, omega_max, rnd_shft);
parameter Real S[n_omega_i] = OceanEngineering.Functions.spectrumGenerator_PM(Hs, omega);
parameter Modelica.SIunits.Length zeta0i[n_omega_i] = sqrt(2 * S * omega_min) "Amplitude of wave component";
parameter Real T[n_omega_i] = 2 * pi ./ omega "Wave period";
parameter Real k[n_omega_i] = OceanEngineering.Functions.waveNumberIterator(d, omega) "Wave number";
Modelica.SIunits.Length SSE_X0 "Sea surface elevation at x=0 - to plot generated waves";
Real zeta0i_rmp[n_omega_i] "Ramp value of zeta0i";
equation
for i in 1:n_omega_i loop
if time < Trmp then
zeta0i_rmp[i] = sin(pi / 2 * time / Trmp) * zeta0i[i];
else
zeta0i_rmp[i] = zeta0i[i];
end if;
end for;
if SSE_X0on == 1 then
SSE_X0 = sum(zeta0i_rmp .* cos(omega * time - 2 * pi * epsilon));
else
SSE_X0 = 0;
end if;
wdoc.d = d;
wdoc.rho_w = rho_w;
wdoc.omega = omega;
wdoc.T = T;
wdoc.k = k;
wdoc.epsilon = epsilon;
wdoc.zeta0i = zeta0i_rmp;
wdoc.SSE_X0 = SSE_X0;
annotation(
Icon(graphics = {Line(origin = {-50.91, 48.08}, points = {{-33.2809, -22.5599}, {-21.2809, -20.5599}, {-13.2809, 27.4401}, {6.71907, -20.5599}, {24.7191, -24.5599}, {42.7191, -24.5599}, {44.7191, -24.5599}}, color = {255, 0, 0}, smooth = Smooth.Bezier), Line(origin = {-37, 51}, points = {{-51, 29}, {-51, -29}, {37, -29}}), Text(origin = {6, 55}, extent = {{-40, 17}, {40, -17}}, textString = "Hs"), Line(origin = {22, 4}, points = {{0, 22}, {0, -22}}, thickness = 1, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-7.57, -61.12}, points = {{-82.4341, -12.8774}, {-76.4341, -2.87735}, {-72.4341, -6.87735}, {-62.4341, 13.1226}, {-50.4341, -26.8774}, {-46.4341, -20.8774}, {-38.4341, -26.8774}, {-34.4341, -18.8774}, {-34.4341, 3.12265}, {-26.4341, 1.12265}, {-20.4341, 7.12265}, {-12.4341, 9.12265}, {-8.43408, 19.1226}, {1.56592, -4.87735}, {7.56592, -24.8774}, {19.5659, -6.87735}, {21.5659, 9.12265}, {31.5659, 13.1226}, {39.5659, -0.87735}, {43.5659, 11.1226}, {55.5659, 15.1226}, {63.5659, 27.1226}, {79.5659, -22.8774}}, color = {0, 0, 255}, smooth = Smooth.Bezier), Rectangle(origin = {100, 0}, fillColor = {85, 255, 127}, fillPattern = FillPattern.Solid, extent = {{-20, 20}, {20, -20}})}, coordinateSystem(initialScale = 0.1)),
experiment(StartTime = 0, StopTime = 400, Tolerance = 1e-06, Interval = 0.5));
end IRW_PM_RDFCWI;
end IrregularWave;
end Waves;
package CurrentProfiles
block CurrentProfile_4pt
extends Modelica.Blocks.Icons.Block;
OceanEngineering.Connectors.CurrentDataConnector cdc annotation(
Placement(transformation(extent = {{80, -20}, {120, 20}})));
constant Real pi = Modelica.Constants.pi "Value of pi";
parameter Real zcg[:] = {-100, -20, -10, 0};
parameter Real Uf[:] = {0, 0, 1, 1};
parameter Real Trmp = 200;
Real Ucg[size(Uf, 1)];
equation
for i in 1:size(Uf, 1) loop
if time < Trmp then
Ucg[i] = sin(pi / 2 * time / Trmp) * Uf[i];
else
Ucg[i] = Uf[i];
end if;
end for;
cdc.zcg = zcg;
cdc.Ucg = Ucg;
annotation(
Icon(graphics = {Rectangle(origin = {0, -30}, fillColor = {0, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 70}, {100, -70}}), Line(origin = {-80, -29}, points = {{0, 69}, {0, -69}}), Line(origin = {-50.0068, -29.0068}, points = {{62.0068, 69.0068}, {10.0068, 17.0068}, {-9.99322, -58.9932}, {-29.9932, -68.9932}}), Line(origin = {-53, 16.0755}, points = {{-27, 0}, {41, 0}}, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-60, -14}, points = {{-20, 0}, {20, 0}}, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-65, -48}, points = {{-15, 0}, {15, 0}}, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-70, -86}, points = {{-10, 0}, {10, 0}}, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-47.6886, 40.3302}, points = {{-32, 0}, {60, 0}}, arrow = {Arrow.None, Arrow.Filled}), Rectangle(origin = {100, 0}, fillColor = {255, 255, 0}, fillPattern = FillPattern.Solid, extent = {{-20, -20}, {20, 20}})}, coordinateSystem(initialScale = 0.1)));
end CurrentProfile_4pt;
end CurrentProfiles;
package Floaters
model CylindricalBuoy
extends Modelica.Blocks.Icons.Block;
Modelica.Mechanics.Translational.Interfaces.Flange_a TopHook(s = z2) "Hook for spring" annotation(
Placement(transformation(extent = {{-20, 120}, {20, 80}})));
Modelica.Mechanics.Translational.Interfaces.Flange_a Fairlead[2](s = {x, z3}) annotation(
Placement(transformation(extent = {{-20, -120}, {20, -80}})));
OceanEngineering.Connectors.EnvironmentBuoyDataConnector ebdc(n_omega_i = nOmega) annotation(
Placement(visible = true, transformation(extent = {{-80, -20}, {-120, 20}}, rotation = 0), iconTransformation(extent = {{-118, -20}, {-78, 20}}, rotation = 0)));
parameter Integer nOmega = 100 "Number of wave components; 1 for regular wave and more than 1 for irregular wave";
constant Real g = Modelica.Constants.g_n "Value of acceleration due to gravity";
constant Real pi = Modelica.Constants.pi "Value of pi";
parameter Real d = 100;
parameter Real rho_w = 1025;
parameter Modelica.SIunits.Length r = 0.6 "Radius of the buoy";
parameter Modelica.SIunits.Length h = 2 "Height of the buoy";
parameter Modelica.SIunits.Mass mbu =350 "Structural mass of the buoy";
parameter Modelica.SIunits.Mass mba = 0 "Ballast mass";
parameter Real Cma = 1 "Added mass coefficient in heave";
parameter Real Cd_buoy = 1 "Drag coefficient of buoy";
parameter Modelica.SIunits.Mass M1 =mbu+mba;
parameter Modelica.SIunits.Mass M = (mbu + mba)*(1+Cma)"Effective mass of body including added mass";
parameter Modelica.SIunits.Length KGb = 1.25 "KG of buoy";
parameter Real zeta = 0.5 "Damping factor";
parameter Real K(unit = "N m^-1") = rho_w * g * pi * r ^ 2 "Coefficient of Stiffness";
parameter Real C(unit = "kg/s") = 2 * zeta * (K * M) ^ 0.5 "Coefficient of damping";
parameter Modelica.SIunits.Mass spm_chain_sub = 14 "submerged mass of mooring chain";
parameter Modelica.SIunits.Length z_s_m=(spm_chain_sub*g*d)/(K+spm_chain_sub*g);
parameter Modelica.SIunits.Length z_s = (mbu + mba) / (pi * r ^ 2 * rho_w) "Static draught";
parameter Modelica.SIunits.Length z_fb = KGb - z_s "VCG of body wrt SWL";
parameter Modelica.SIunits.Length pz = 0.5 "Depth of panel to calculate current force & Morison Force";
parameter Integer CMf_b = 0;
Modelica.SIunits.Length SSE_X "Sea surface elevation corresponding to buoy CG X coordinate";
Modelica.SIunits.Length z "Displacement of body VCG from z_fb";
Modelica.SIunits.Velocity v_z "Velocity of body VCG in vertical direction";
Modelica.SIunits.Length z1 "Position of body VCG";
Modelica.SIunits.Length z2 "Position of deck";
Modelica.SIunits.Length z3 "Position of keel";
Modelica.SIunits.Length x "x co-ordinate of VCG";
Modelica.SIunits.Velocity u_x "Velocity of body VCG in horizontal direction";
Modelica.SIunits.Acceleration a_x "Acceleration of body VCG in horizontal direction";
Modelica.SIunits.Force Mf "Morison force due to current and waves";
initial equation
z = -z_s_m;
der(z) = 0;
x = ebdc.xinit;
der(x) = 0;
equation
SSE_X = sum(ebdc.zeta0i .* cos(ebdc.k * x - ebdc.omega * time - 2 * pi * ebdc.epsilon));
v_z = der(z);
M*der(v_z) + C/2 * der(z)*(SSE_X-z3) + K * z = rho_w * g * pi * r ^ 2 * SSE_X + TopHook.f + Fairlead[2].f;
z1 = z_fb + z;
z2 = z3+h;
z3 = -z_s+z;
Mf = OceanEngineering.Functions.morisonForceCydlBuoy(time, d, ebdc.omega, ebdc.T, ebdc.k, x, u_x, a_x, ebdc.epsilon, ebdc.zeta0i, rho_w, SSE_X, r, h, Cd_buoy, Cma, z3, pz, ebdc.zcg, ebdc.Ucg);
u_x = der(x);
a_x = der(u_x);
(M1+Cma*pi*r^2*rho_w*(SSE_X-z3))*der(u_x)+0*C*u_x*(SSE_X-z3) = Fairlead[1].f + Mf;
annotation(
Icon(graphics = {Rectangle(origin = {0, -50}, fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 50}, {100, -50}}), Rectangle(origin = {0, 3}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-28, 53}, {28, -53}}), Ellipse(origin = {0, 57}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-28, 5}, {28, -5}}, endAngle = 360), Ellipse(origin = {0, -51}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-28, 5}, {28, -5}}, endAngle = 360)}, coordinateSystem(initialScale = 0.1)),
experiment(StartTime = 0, StopTime = 300, Tolerance = 1e-05, Interval = 0.5));
end CylindricalBuoy;
model CylindricalBobbingBuoy
extends Modelica.Blocks.Icons.Block;
Modelica.Mechanics.Translational.Interfaces.Flange_b Slide(s = x - r) annotation(
Placement(visible = true, transformation(extent = {{-20, -120}, {20, -80}}, rotation = 0), iconTransformation(extent = {{-120, -20}, {-80, 20}}, rotation = 0)));
OceanEngineering.Connectors.EnvironmentBuoyDataConnector ebdc annotation(
Placement(visible = true, transformation(extent = {{80, -20}, {120, 20}}, rotation = 0), iconTransformation(extent = {{-122, 60}, {-82, 100}}, rotation = 0)));
constant Real g = Modelica.Constants.g_n "Value of acceleration due to gravity";
constant Real pi = Modelica.Constants.pi "Value of pi";
parameter Real d = 100;
parameter Real rho_w = 1025;
parameter Modelica.SIunits.Length r = 0.6 "Radius of the buoy";
parameter Modelica.SIunits.Length h = 2 "Height of the buoy";
parameter Modelica.SIunits.Mass mbu = 350 "Structural mass of the buoy";
parameter Modelica.SIunits.Mass mba = 0 "Ballast mass";
parameter Real Cma = 0.8 "Added mass coefficient";
parameter Real Cd_buoy = 1 "Drag coefficient of buoy";
parameter Modelica.SIunits.Mass M = (mbu + mba) * (1 + Cma) "Effective mass of body including added mass";
parameter Modelica.SIunits.Mass M1 =mbu+mba;
parameter Modelica.SIunits.Length KGb = 1.25 "KG of buoy";
parameter Real zeta = 0.3 "Damping factor";
parameter Real K(unit = "N m^-1") = rho_w * g * pi * r ^ 2 "Coefficient of Stiffness";
parameter Real C(unit = "kg/s") = 2 * zeta * (K * M) ^ 0.5 "Coefficient of damping";
parameter Modelica.SIunits.Length z_s = (mbu + mba) / (pi * r ^ 2 * rho_w) "Static draught";
parameter Modelica.SIunits.Length z_fb = KGb - z_s "VCG of body wrt SWL";
parameter Modelica.SIunits.Length pz = 0.5 "Depth of panel to calculate current force & Morison Force";
parameter Integer CMf_b = 0;
Modelica.SIunits.Length SSE_X "Sea surface elevation corresponding to buoy CG X coordinate";
Modelica.SIunits.Length z "Displacement of body VCG from z_fb";
Modelica.SIunits.Velocity v_z "Velocity of body VCG in z direction";
Modelica.SIunits.Length z1 "Position of body VCG";
Modelica.SIunits.Length z2 "Position of deck";
Modelica.SIunits.Length z3 "Position of keel";
Modelica.SIunits.Length x "x co-ordinate of VCG";
Modelica.SIunits.Velocity v_x "Velocity of body VCG in x direction";
Modelica.SIunits.Acceleration a_x "Acceleration of body VCG in x direction";
Modelica.SIunits.Force Mf "Morison force due to current and waves";
initial equation
z = 0;
der(z) = 0;
equation
SSE_X = sum(ebdc.zeta0i .* cos(ebdc.k * x - ebdc.omega * time - 2 * pi * ebdc.epsilon));
v_z = der(z);
M*der(v_z) + C/2 * der(z)*(SSE_X-z3) + K * z = rho_w * g * pi * r ^ 2 * SSE_X +z_s;
z1 = z_fb + z;
z2 = z3+h;
z3 = -z_s+z;
v_x = der(x);
a_x = der(v_x);
Mf = OceanEngineering.Functions.morisonForceCydlBuoy(time, d, ebdc.omega, ebdc.T, ebdc.k, x, v_x, a_x, ebdc.epsilon, ebdc.zeta0i, rho_w, SSE_X, r, h, Cd_buoy, Cma, z3, pz, ebdc.zcg, ebdc.Ucg);
Slide.f = -Mf;
annotation(
Icon(graphics = {Rectangle(origin = {0, -50}, fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 50}, {100, -50}}), Rectangle(origin = {0, 3}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-28, 53}, {28, -53}}), Ellipse(origin = {0, 57}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-28, 5}, {28, -5}}, endAngle = 360), Ellipse(origin = {0, -51}, fillColor = {255, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-28, 5}, {28, -5}}, endAngle = 360), Line(origin = {52, 55}, points = {{0, 25}, {0, -25}}, arrow = {Arrow.Filled, Arrow.Filled})}, coordinateSystem(initialScale = 0.1)));
end CylindricalBobbingBuoy;
model BoxPlatform
extends Modelica.Blocks.Icons.Block;
Modelica.Mechanics.Translational.Interfaces.Flange_a Slide(s = x + L / 2) "Guide for Oscillating Cylinder" annotation(
Placement(visible = true, transformation(extent = {{-20, 120}, {20, 80}}, rotation = 0), iconTransformation(extent = {{80, 20}, {120, -20}}, rotation = 0)));
Modelica.Mechanics.Translational.Interfaces.Flange_a Fairlead[2](s = {x - L / 2, z3}) annotation(
Placement(visible = true, transformation(extent = {{-20, -120}, {20, -80}}, rotation = 0), iconTransformation(extent = {{-120, -60}, {-80, -20}}, rotation = 0)));
OceanEngineering.Connectors.EnvironmentBuoyDataConnector ebdc annotation(
Placement(visible = true, transformation(extent = {{80, -20}, {120, 20}}, rotation = 0), iconTransformation(extent = {{-120, 20}, {-80, 60}}, rotation = 0)));
constant Real g = Modelica.Constants.g_n "Value of acceleration due to gravity";
constant Real pi = Modelica.Constants.pi "Value of pi";
parameter Real d = 100;
parameter Real rho_w = 1025;
parameter Modelica.SIunits.Length L = 5 "Length of barge";
parameter Modelica.SIunits.Length B = 2 "Breadth of barge";
parameter Modelica.SIunits.Length H = 2 "Height of barge";
parameter Modelica.SIunits.Area Awp = L * B "Waterplane area";
parameter Modelica.SIunits.Mass ms = 2750 "Structural mass of the buoy";
parameter Modelica.SIunits.Mass mb = 7500 "Ballast mass";
parameter Real Cma = 0.8 "Added mass coefficient";
parameter Real Cd = 1 "Drag coefficient of buoy";
parameter Modelica.SIunits.Mass M1 = (ms + mb);
parameter Modelica.SIunits.Mass M = (ms + mb)*(1+Cma) "Effective mass of body including added mass";
parameter Modelica.SIunits.Length KGb = 1 "KG of buoy";
parameter Real zeta = 0.3 "Damping factor";
parameter Real K(unit = "N m^-1") = rho_w * g * Awp "Coefficient of Stiffness";
parameter Real C(unit = "kg/s") = 2 * zeta * (K * M) ^ 0.5 "Coefficient of damping";
parameter Modelica.SIunits.Mass spm_chain_sub = 14 "submerged mass of mooring chain";
parameter Modelica.SIunits.Length z_s_m=(spm_chain_sub*g*d)/(K+spm_chain_sub*g);
parameter Modelica.SIunits.Length z_s = (ms + mb) / (Awp* rho_w)+z_s_m "Static draught";
parameter Modelica.SIunits.Length z_fb = KGb - z_s "VCG of body wrt SWL";
parameter Modelica.SIunits.Length pz = 0.5 "Depth of panel to calculate current force & Morison Force";
Modelica.SIunits.Length SSE_X "Sea surface elevation corresponding to buoy CG X coordinate";
Modelica.SIunits.Force f_t "Downward force on deck due to immersion";
Modelica.SIunits.Length z "Displacement of body VCG from z_fb";
Modelica.SIunits.Velocity v_z "Velocity of body VCG in vertical direction";
Modelica.SIunits.Length z1 "Position of body VCG";
Modelica.SIunits.Length z2 "Position of deck";
Modelica.SIunits.Length z3 "Position of keel";
Modelica.SIunits.Length x "x co-ordinate of VCG";
Modelica.SIunits.Velocity v_x "Velocity of body VCG in horizontal direction";
Modelica.SIunits.Acceleration a_x "Acceleration of body VCG in horizontal direction";
Modelica.SIunits.Force Mf "Morison force due to current and waves";
initial equation
z = 0;
der(z) = 0;
x = ebdc.xinit + L / 2;
der(x) = 0;
equation
SSE_X = sum(ebdc.zeta0i .* cos(ebdc.k * x - ebdc.omega * time - 2 * pi * ebdc.epsilon));
f_t = if SSE_X > z2 then rho_w * g * (SSE_X - z2) else 0;
v_z = der(z);
M* der(v_z) + C/2 * der(z)*(SSE_X-z3) + K * z = rho_w * g * Awp *SSE_X+ Fairlead[2].f;
z1 = z_fb + z;
z2 = z3+H;
z3 = -z_s+z;
Mf = OceanEngineering.Functions.morisonForceBoxPlatform(time, d, ebdc.omega, ebdc.T, ebdc.k, x, v_x, a_x, ebdc.epsilon, ebdc.zeta0i, rho_w, SSE_X, L, B, H, Awp, Cd, Cma, z2, z3, pz, ebdc.zcg, ebdc.Ucg);
v_x = der(x);
a_x = der(v_x);
(M1+Cma*(SSE_X-z3)*Awp*rho_w)*der(v_x)+0*C*v_x*(SSE_X-z3) = Fairlead[1].f + Mf + Slide.f;
annotation(
Icon(graphics = {Rectangle(origin = {0, -50}, fillColor = {85, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 50}, {100, -50}}), Rectangle(origin = {12, -25}, fillColor = {255, 0, 0}, fillPattern = FillPattern.Solid, extent = {{-104, 65}, {74, -9}}), Line(origin = {-24, 56}, points = {{-30, 0}, {30, 0}}, arrow = {Arrow.Filled, Arrow.Filled}), Line(origin = {34, 65}, points = {{0, 19}, {0, -19}, {0, -19}, {0, -19}}, arrow = {Arrow.Filled, Arrow.Filled})}, coordinateSystem(initialScale = 0.1)));
end BoxPlatform;
end Floaters;
package Moorings
model CatenaryMooring_Mf0
extends Modelica.Blocks.Icons.Block;
Modelica.Mechanics.Translational.Interfaces.Flange_b shackle[2] annotation(
Placement(transformation(extent = {{-20, 80}, {20, 120}})));
OceanEngineering.Connectors.EnvironmentMooringDataConnector emdc(n_omega_i = nOmega) annotation(
Placement(visible = true, transformation(extent = {{-80, -20}, {-120, 20}}, rotation = 0), iconTransformation(extent = {{-120, -20}, {-80, 20}}, rotation = 0)));
parameter Integer nOmega = 100 "Number of wave components; 1 for regular wave and more than 1 for irregular wave";
constant Real g = Modelica.Constants.g_n;
constant Real pi = Modelica.Constants.pi;
parameter Real rho_w = 1025;
parameter Real d = 100;
parameter Real lnk_l = 3;
parameter Integer n_lnk = 50;
parameter Real L_chain = lnk_l * n_lnk;
parameter Real d_chain = 0.022;
parameter Real rho_mat_chain = 7800;
parameter Real spm_chain = 10;
parameter Real spm_chain_sub = spm_chain-spm_chain/rho_mat_chain*rho_w "Submerged weight per meter of chain";
parameter Real Xmax = sqrt(L_chain ^ 2 - d ^ 2);
parameter Real X0 = L_chain - d;
parameter Real xmax = Xmax - 10;
parameter Real x[:] = 0:0.1:xmax;
parameter Real Th[:] = OceanEngineering.Functions.catThIterator(L_chain, x, d, spm_chain_sub);
parameter Real X[:] = OceanEngineering.Functions.catXIterator(L_chain, d, spm_chain_sub, Th, x);
parameter Real Cdn = 0.75;
parameter Real Cdt = 0;
parameter Real Cman = 1;
parameter Real Cmat = 0.0;
parameter Real Cmn = 1 + Cman;
parameter Real Cmt = 1 + Cmat;
parameter Real D = 1.8 * d_chain;
parameter Real Ai = rho_w * pi * D ^ 2 / 4;
parameter Real Ad = 0.5 * rho_w * D;
parameter Real Trmp=50;
Real x_lnk_cat[n_lnk + 1];
Real x_lnk_plot_o;
Real z_lnk_cat[n_lnk + 1];
Real x_lnk_plot[n_lnk + 1];
Real z_lnk_plot[n_lnk + 1];
Real fd0;
Real a;
Real z_cat;
Real x_cat;
Real psi_cat;
Real s_cat;
equation
if shackle[1].s <= X0 - shackle[2].s then
fd0 = 0;
a = 0;
z_cat = d + shackle[2].s;
psi_cat = pi / 2;
x_cat = X0 - shackle[2].s;
s_cat = d + shackle[2].s;
x_lnk_cat[1] = 0;
x_lnk_plot_o = shackle[1].s;
x_lnk_plot[1] = shackle[1].s;
z_lnk_cat[1] = 0;
z_lnk_plot[1] = shackle[2].s;
for i in 2:n_lnk loop
if z_lnk_plot[i - 1] > (-(d - lnk_l)) then
x_lnk_cat[i] = 0;
x_lnk_plot[i] = shackle[1].s;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = z_lnk_plot[i - 1] - lnk_l;
elseif z_lnk_plot[i - 1] > (-d) then
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i - 1] - sqrt(lnk_l ^ 2 - (d + z_lnk_plot[i - 1]) ^ 2);
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
else
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i - 1] - lnk_l;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end if;
end for;
x_lnk_cat[n_lnk + 1] = 0;
x_lnk_plot[n_lnk + 1] = 0;
z_lnk_cat[n_lnk + 1] = 0;
z_lnk_plot[n_lnk + 1] = -d;
shackle[1].f = -10;
shackle[2].f = s_cat * spm_chain_sub * g;
elseif shackle[1].s < sqrt(L_chain ^ 2 - d ^ 2) then
fd0 = OceanEngineering.Functions.linearInterpolatorSV(X, Th, shackle[1].s);
a = fd0 / (spm_chain_sub * g);
z_cat = a + d + shackle[2].s;
psi_cat = acos(a / z_cat);
x_cat = fd0 / (spm_chain_sub * g) * Modelica.Math.acosh(1 + spm_chain_sub * g * (d + shackle[2].s) / fd0);
s_cat = (d + shackle[2].s) * (1 + 2 * (fd0 / (spm_chain_sub * g * (d + shackle[2].s)))) ^ 0.5;
x_lnk_cat[1] = x_cat;
x_lnk_plot_o = L_chain - s_cat + x_lnk_cat[1];
x_lnk_plot[1] = x_lnk_plot_o - (x_lnk_plot_o - shackle[1].s);
z_lnk_cat[1] = shackle[2].s + d + a;
z_lnk_plot[1] = (-(d + a)) + z_lnk_cat[1];
for i in 2:n_lnk loop
if x_lnk_cat[i - 1] > 0 then
x_lnk_cat[i] = a * Modelica.Math.asinh((s_cat - (i - 1) * lnk_l) / a);
if x_lnk_cat[i] > 0 then
x_lnk_plot[i] = L_chain - s_cat + x_lnk_cat[i] - (x_lnk_plot_o - shackle[1].s);
z_lnk_cat[i] = a * cosh(x_lnk_cat[i] / a);
z_lnk_plot[i] = (-(d + a)) + z_lnk_cat[i];
else
x_lnk_plot[i] = x_lnk_plot[i - 1] - sqrt(lnk_l ^ 2 - (d + z_lnk_plot[i - 1]) ^ 2);
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end if;
else
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i - 1] - lnk_l;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end if;
end for;
x_lnk_cat[n_lnk + 1] = 0;
x_lnk_plot[n_lnk + 1] = 0;
z_lnk_cat[n_lnk + 1] = 0;
z_lnk_plot[n_lnk + 1] = -d;
shackle[1].f = fd0;
shackle[2].f = s_cat * spm_chain_sub * g;
else
fd0 = 0;
a = 0;
z_cat = 0;
psi_cat = 0;
x_cat = 0;
s_cat = 0;
x_lnk_cat[1] = 0;
x_lnk_plot_o = 0;
x_lnk_plot[1] = n_lnk*lnk_l;
z_lnk_cat[1] = 0;
z_lnk_plot[1] = -d;
for i in 2:n_lnk loop
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i-1]-lnk_l;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end for;
x_lnk_cat[n_lnk + 1] = 0;
x_lnk_plot[n_lnk + 1] = 0;
z_lnk_cat[n_lnk + 1] = 0;
z_lnk_plot[n_lnk + 1] = -d;
shackle[1].f = 0;
shackle[2].f = 0;
end if;
emdc.xinit = X0 - shackle[2].s;
annotation(
Icon(graphics = {Rectangle(origin = {0, -92}, fillColor = {170, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-100, 8}, {100, -8}}), Rectangle(origin = {0, -18}, fillColor = {0, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 68}, {100, -68}}), Rectangle(origin = {-87, -78}, fillColor = {170, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-9, 8}, {9, -8}}), Line(origin = {1.26, -16.13}, points = {{-78.9938, -64.1437}, {-68.9938, -70.1437}, {-8.9938, -70.1437}, {33.0062, -36.1437}, {65.0062, 15.8563}, {79.0062, 63.8563}}, color = {255, 0, 0}, thickness = 0.5, smooth = Smooth.Bezier)}, coordinateSystem(initialScale = 0.1)),
experiment(StartTime = 0, StopTime = 300, Tolerance = 1e-06, Interval = 0.5));
end CatenaryMooring_Mf0;
model CatenaryMooring_MfC
extends Modelica.Blocks.Icons.Block;
Modelica.Mechanics.Translational.Interfaces.Flange_b shackle[2] annotation(
Placement(transformation(extent = {{-20, 80}, {20, 120}})));
OceanEngineering.Connectors.EnvironmentMooringDataConnector emdc(n_omega_i = nOmega) annotation(
Placement(visible = true, transformation(extent = {{80, -20}, {120, 20}}, rotation = 0), iconTransformation(extent = {{-120, -20}, {-80, 20}}, rotation = 0)));
parameter Integer nOmega = 100 "Number of wave components; 1 for regular wave and more than 1 for irregular wave";
constant Real g = Modelica.Constants.g_n;
constant Real pi = Modelica.Constants.pi;
parameter Real rho_w = 1025;
parameter Real d = 100;
parameter Real lnk_l = 3;
parameter Integer n_lnk = 50;
parameter Real L_chain = lnk_l * n_lnk;
parameter Real d_chain = 0.022;
parameter Real rho_mat_chain = 7800;
parameter Real spm_chain = 10;
parameter Real spm_chain_sub = spm_chain - spm_chain / rho_mat_chain * rho_w "Submerged weight per meter of chain";
parameter Real Xmax = sqrt(L_chain ^ 2 - d ^ 2);
parameter Real X0 = L_chain - d;
parameter Real xmax = Xmax - 10;
parameter Real x[:] = 0:0.1:xmax;
parameter Real Th[:] = OceanEngineering.Functions.catThIterator(L_chain, x, d, spm_chain_sub);
parameter Real X[:] = OceanEngineering.Functions.catXIterator(L_chain, d, spm_chain_sub, Th, x);
parameter Real Cdn = 0.75;
parameter Real Cdt = 0;
parameter Real Cman = 1;
parameter Real Cmat = 0.0;
parameter Real Cmn = 1 + Cman;
parameter Real Cmt = 1 + Cmat;
parameter Real D = 1.8 * d_chain;
parameter Real Ai = rho_w * pi * D ^ 2 / 4;
parameter Real Ad = 0.5 * rho_w * D;
Real x_lnk_cat[n_lnk + 1];
Real x_lnk_plot_o;
Real z_lnk_cat[n_lnk + 1];
Real x_lnk_plot[n_lnk + 1];
Real z_lnk_plot[n_lnk + 1];
Real xl[n_lnk];
Real zl[n_lnk];
Real vxl[n_lnk];
Real vzl[n_lnk];
Real psil[n_lnk];
Real vl[n_lnk];
Real vl_ang[n_lnk];
Real vln[n_lnk];
Real vlt[n_lnk];
Real fd0;
Real a;
Real z_cat;
Real x_cat;
Real s_cat;
Real SSE_Xl[n_lnk];
Real Uc[n_lnk];
Real Ucn[n_lnk];
Real Uct[n_lnk];
Real Mfni[n_lnk];
Real Mfti[n_lnk];
Real Mfxi[n_lnk];
Real Mfzi[n_lnk];
Real Mfx;
Real Mfz;
parameter Real Trmp = 50;
Real Mfxa;
Real Mfza;
equation
if shackle[1].s <= X0 - shackle[2].s then
fd0 = 0;
a = 0;
z_cat = d + shackle[2].s;
x_cat = X0 - shackle[2].s;
s_cat = d + shackle[2].s;
x_lnk_cat[1] = 0;
x_lnk_plot_o = shackle[1].s;
x_lnk_plot[1] = shackle[1].s;
z_lnk_cat[1] = 0;
z_lnk_plot[1] = shackle[2].s;
for i in 2:n_lnk loop
if z_lnk_plot[i - 1] > (-(d - lnk_l)) then
x_lnk_cat[i] = 0;
x_lnk_plot[i] = shackle[1].s;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = z_lnk_plot[i - 1] - lnk_l;
elseif z_lnk_plot[i - 1] > (-d) then
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i - 1] - sqrt(lnk_l ^ 2 - (d + z_lnk_plot[i - 1]) ^ 2);
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
else
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i - 1] - lnk_l;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end if;
end for;
x_lnk_cat[n_lnk + 1] = 0;
x_lnk_plot[n_lnk + 1] = 0;
z_lnk_cat[n_lnk + 1] = 0;
z_lnk_plot[n_lnk + 1] = -d;
for i in 1:n_lnk loop
xl[i] = (x_lnk_plot[i] + x_lnk_plot[i + 1]) / 2;
zl[i] = (z_lnk_plot[i] + z_lnk_plot[i + 1]) / 2;
end for;
for i in 1:n_lnk loop
if zl[i] > (-d) + 1 then
vxl[i] = if noEvent(der(xl[i])) then der(xl[i]) else 0;
vzl[i] = if noEvent(der(zl[i])) then der(zl[i]) else 0;
else
vxl[i] = 0;
vzl[i] = 0;
end if;
end for;
// Mf Calculation loop 1
for i in 1:n_lnk loop
if zl[i] > (-d) + 1 * lnk_l then
psil[i] = if noEvent(abs(x_lnk_plot[i] - x_lnk_plot[i + 1]) > 0) then atan((z_lnk_plot[i] - z_lnk_plot[i + 1]) / (x_lnk_plot[i] - x_lnk_plot[i + 1])) else 0;
SSE_Xl[i] = OceanEngineering.Functions.sSE_X_cat(time, emdc.omega, emdc.k, emdc.zeta0i, emdc.epsilon, xl[i]);
vl[i] = sqrt(vxl[i] ^ 2 + vzl[i] ^ 2);
vl_ang[i] = if noEvent(abs(vxl[i]) > 0) then atan(vzl[i] / vxl[i]) else pi / 2;
vln[i] = -vl[i] * sin(psil[i] - vl_ang[i]);
vlt[i] = vl[i] * cos(psil[i] - vl_ang[i]);
Uc[i] = OceanEngineering.Functions.linearInterpolatorSV(emdc.zcg, emdc.Ucg, zl[i] + SSE_Xl[i]);
Ucn[i] = Uc[i] * sin(psil[i]);
Uct[i] = Uc[i] * cos(psil[i]);
Mfni[i] = Cdn * Ad * abs(Ucn[i] - vln[i]) * (Ucn[i] - vln[i]) * lnk_l;
Mfti[i] = Cdt * Ad * abs(Uct[i] - vlt[i]) * (Uct[i] - vlt[i]) * lnk_l;
Mfxi[i] = Mfni[i] * sin(psil[i]) + Mfti[i] * cos(psil[i]);
Mfzi[i] = Mfni[i] * cos(psil[i]) + Mfti[i] * sin(psil[i]);
else
psil[i] = 0;
SSE_Xl[i] = 0;
vl[i] = 0;
vl_ang[i] = 0;
vln[i] = 0;
vlt[i] = 0;
Uc[i] = 0;
Ucn[i] = 0;
Uct[i] = 0;
Mfni[i] = 0;
Mfti[i] = 0;
Mfxi[i] = 0;
Mfzi[i] = 0;
end if;
end for;
Mfx = sum(Mfxi);
Mfz = sum(Mfzi);
if time < Trmp then
Mfxa = time / Trmp * Mfx;
Mfza = time / Trmp * Mfz;
else
Mfxa = Mfx;
Mfza = Mfz;
end if;
shackle[1].f = fd0 - Mfxa-10;
shackle[2].f = s_cat * spm_chain_sub * g + Mfza;
//MAIN IF cond 2
elseif shackle[1].s < sqrt(L_chain ^ 2 - d ^ 2) then
fd0 = OceanEngineering.Functions.linearInterpolatorSV(X, Th, shackle[1].s);
a = fd0 / (spm_chain_sub * g);
z_cat = a + d + shackle[2].s;
x_cat = fd0 / (spm_chain_sub * g) * Modelica.Math.acosh(1 + spm_chain_sub * g * (d + shackle[2].s) / fd0);
s_cat = (d + shackle[2].s) * (1 + 2 * (fd0 / (spm_chain_sub * g * (d + shackle[2].s)))) ^ 0.5;
x_lnk_cat[1] = x_cat;
x_lnk_plot_o = L_chain - s_cat + x_lnk_cat[1];
x_lnk_plot[1] = x_lnk_plot_o - (x_lnk_plot_o - shackle[1].s);
z_lnk_cat[1] = shackle[2].s + d + a;
z_lnk_plot[1] = (-(d + a)) + z_lnk_cat[1];
for i in 2:n_lnk loop
if x_lnk_cat[i - 1] > 0 then
x_lnk_cat[i] = a * Modelica.Math.asinh((s_cat - (i - 1) * lnk_l) / a);
if x_lnk_cat[i] > 0 then
x_lnk_plot[i] = L_chain - s_cat + x_lnk_cat[i] - (x_lnk_plot_o - shackle[1].s);
z_lnk_cat[i] = a * cosh(x_lnk_cat[i] / a);
z_lnk_plot[i] = (-(d + a)) + z_lnk_cat[i];
else
x_lnk_plot[i] = x_lnk_plot[i - 1] - sqrt(lnk_l ^ 2 - (d + z_lnk_plot[i - 1]) ^ 2);
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end if;
else
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i - 1] - lnk_l;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end if;
end for;
x_lnk_cat[n_lnk + 1] = 0;
x_lnk_plot[n_lnk + 1] = 0;
z_lnk_cat[n_lnk + 1] = 0;
z_lnk_plot[n_lnk + 1] = -d;
for i in 1:n_lnk loop
xl[i] = (x_lnk_plot[i] + x_lnk_plot[i + 1]) / 2;
zl[i] = (z_lnk_plot[i] + z_lnk_plot[i + 1]) / 2;
end for;
for i in 1:n_lnk loop
if zl[i] > (-d) + 1 then
vxl[i] = if noEvent(der(xl[i])) then der(xl[i]) else 0;
vzl[i] = if noEvent(der(zl[i])) then der(zl[i]) else 0;
else
vxl[i] = 0;
vzl[i] = 0;
end if;
end for;
//Mf calculation loop 2
for i in 1:n_lnk loop
if zl[i] > (-d) + 1 * lnk_l then
psil[i] = if noEvent(abs(x_lnk_plot[i] - x_lnk_plot[i + 1]) > 0) then atan((z_lnk_plot[i] - z_lnk_plot[i + 1]) / (x_lnk_plot[i] - x_lnk_plot[i + 1])) else 0;
SSE_Xl[i] = OceanEngineering.Functions.sSE_X_cat(time, emdc.omega, emdc.k, emdc.zeta0i, emdc.epsilon, xl[i]);
vl[i] = sqrt(vxl[i] ^ 2 + vzl[i] ^ 2);
vl_ang[i] = if noEvent(abs(vxl[i]) > 0) then atan(vzl[i] / vxl[i]) else pi / 2;
vln[i] = -vl[i] * sin(psil[i] - vl_ang[i]);
vlt[i] = vl[i] * cos(psil[i] - vl_ang[i]);
Uc[i] = OceanEngineering.Functions.linearInterpolatorSV(emdc.zcg, emdc.Ucg, zl[i] + SSE_Xl[i]);
Ucn[i] = Uc[i] * sin(psil[i]);
Uct[i] = Uc[i] * cos(psil[i]);
Mfni[i] = Cdn * Ad * abs(Ucn[i] - vln[i]) * (Ucn[i] - vln[i]) * lnk_l;
Mfti[i] = Cdt * Ad * abs(Uct[i] - vlt[i]) * (Uct[i] - vlt[i]) * lnk_l;
Mfxi[i] = Mfni[i] * sin(psil[i]) + Mfti[i] * cos(psil[i]);
Mfzi[i] = Mfni[i] * cos(psil[i]) + Mfti[i] * sin(psil[i]);
else
psil[i] = 0;
SSE_Xl[i] = 0;
vl[i] = 0;
vl_ang[i] = 0;
vln[i] = 0;
vlt[i] = 0;
Uc[i] = 0;
Ucn[i] = 0;
Uct[i] = 0;
Mfni[i] = 0;
Mfti[i] = 0;
Mfxi[i] = 0;
Mfzi[i] = 0;
end if;
end for;
Mfx = sum(Mfxi);
Mfz = sum(Mfzi);
if time < Trmp then
Mfxa = time / Trmp * Mfx;
Mfza = time / Trmp * Mfz;
else
Mfxa = Mfx;
Mfza = Mfz;
end if;
shackle[1].f = fd0 - Mfxa;
shackle[2].f = s_cat * spm_chain_sub * g + Mfza;
//MAIN IF cond 3
else
fd0 = 0;
a = 0;
z_cat = 0;
x_cat = 0;
s_cat = 0;
x_lnk_cat[1] = 0;
x_lnk_plot_o = 0;
x_lnk_plot[1] = lnk_l*n_lnk;
z_lnk_cat[1] = 0;
z_lnk_plot[1] = -d;
for i in 2:n_lnk loop
x_lnk_cat[i] = 0;
x_lnk_plot[i] = x_lnk_plot[i-1]-lnk_l;
z_lnk_cat[i] = 0;
z_lnk_plot[i] = -d;
end for;
x_lnk_cat[n_lnk + 1] = 0;
x_lnk_plot[n_lnk + 1] = 0;
z_lnk_cat[n_lnk + 1] = 0;
z_lnk_plot[n_lnk + 1] = -d;
for i in 1:n_lnk loop
xl[i] = 0;
zl[i] = 0;
end for;
for i in 1:n_lnk loop
vxl[i] = 0;
vzl[i] = 0;
end for;
//Mf calculation loop 2
for i in 1:n_lnk loop
psil[i] = 0;
SSE_Xl[i] = 0;
vl[i] = 0;
vl_ang[i] = 0;
vln[i] = 0;
vlt[i] = 0;
Uc[i] = 0;
Ucn[i] = 0;
Uct[i] = 0;
Mfni[i] = 0;
Mfti[i] = 0;
Mfxi[i] = 0;
Mfzi[i] = 0;
end for;
Mfx = 0;
Mfz = 0;
Mfxa = 0;
Mfza = 0;
shackle[1].f = 0;
shackle[2].f = 0;
end if;
emdc.xinit = X0 - shackle[2].s;
annotation(
Icon(graphics = {Rectangle(origin = {0, -92}, fillColor = {170, 85, 0}, fillPattern = FillPattern.Solid, extent = {{-100, 8}, {100, -8}}), Rectangle(origin = {0, -18}, fillColor = {0, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 68}, {100, -68}}), Rectangle(origin = {-87, -78}, fillColor = {170, 170, 255}, fillPattern = FillPattern.Solid, extent = {{-9, 8}, {9, -8}}), Line(origin = {0.99, -15.86}, points = {{-78.9938, -64.1437}, {-68.9938, -70.1437}, {-8.9938, -70.1437}, {33.0062, -36.1437}, {65.0062, 15.8563}, {79.0062, 63.8563}}, color = {255, 0, 0}, thickness = 0.5, smooth = Smooth.Bezier), Line(origin = {-22.3805, 26.2699}, points = {{-34, 0}, {34, 0}}, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-21.2879, 6.5784}, points = {{-34, 0}, {20, 0}}, arrow = {Arrow.None, Arrow.Filled}), Line(origin = {-20.7352, -10.6838}, points = {{-34, 0}, {4, 0}}, arrow = {Arrow.None, Arrow.Filled}), Text(origin = {-33, -27}, extent = {{-21, 7}, {21, -7}}, textString = "Current")}, coordinateSystem(initialScale = 0.1)),
experiment(StartTime = 0, StopTime = 300, Tolerance = 1e-6, Interval = 0.5));
end CatenaryMooring_MfC;