Computational simulation of marine devices by coupled ...

152
Computational simulation of marine devices by coupled seakeeping and control system analysis tools Treball Final de Màster Facultat de Nàutica de Barcelona Universitat Politècnica de Catalunya Treball realitzat per: Bárbara Alcayde Romo Dirigit per: Prof. Julio García Espinosa Dr. Borja Serván Camas Màster en Enginyeria Naval i Oceànica (MUENO) Barcelona, Juliol 2020 Departament de Ciència i Enginyeria Nàutiques

Transcript of Computational simulation of marine devices by coupled ...

Page 1: Computational simulation of marine devices by coupled ...

Computational simulation of marine devices by coupled seakeeping and

control system analysis tools

Treball Final de Màster

Facultat de Nàutica de Barcelona Universitat Politècnica de Catalunya

Treball realitzat per:

Bárbara Alcayde Romo

Dirigit per:

Prof. Julio García Espinosa Dr. Borja Serván Camas

Màster en Enginyeria Naval i Oceànica (MUENO)

Barcelona, Juliol 2020

Departament de Ciència i Enginyeria Nàutiques

Page 2: Computational simulation of marine devices by coupled ...

ii

Page 3: Computational simulation of marine devices by coupled ...

iii

Dedication

To my grandmothers,

Mari and Filo.

Page 4: Computational simulation of marine devices by coupled ...

iv

Page 5: Computational simulation of marine devices by coupled ...

v

Acknowledgements

Many people have helped me, either directly or indirectly, to carry out this Master's Thesis,

sharing their knowledge, experiences and concerns, solving doubts, or supporting and

motivating me to continue with the work.

I would like to thank my supervisors, Professor Julio García and Dr. Borja Serván, for all their

help, from their motivational words to their knowledge that they have shared with me. I am

very grateful to have had the opportunity to develop this project with them since it has

allowed me to reinforce, strengthen and expand the knowledge acquired during the studies.

Finally, I would like to thank Jonathan Colom from CIMNE for his great support and his

programming advice. I am also very grateful to Ovidi Casals and Rosa Peyrau from CompassIS

for their technical assistance.

Page 6: Computational simulation of marine devices by coupled ...

vi

Page 7: Computational simulation of marine devices by coupled ...

vii

Table of contents

List of figures ................................................................................................................................. xi

List of tables ................................................................................................................................. xv

Summary ....................................................................................................................................... 3

Resumen ........................................................................................................................................ 5

Glossary ......................................................................................................................................... 7

Chapter 1. Introduction ................................................................................................................ 9

1.1 Scope ............................................................................................................................. 9

1.2 Content description ..................................................................................................... 10

1.3 Previous concepts ....................................................................................................... 11

PART I: SIMULINK-SEAFEM COUPLING SYSTEM ........................................................................ 13

Chapter 2: Programs description ............................................................................................... 15

2.1 Introduction ................................................................................................................ 15

2.2 SeaFEM basic description ............................................................................................ 15

2.2.1 Information processing in SeaFEM .......................................................................... 16

2.2.2 Tcl extension ............................................................................................................ 17

2.3 Simulink description .................................................................................................... 20

2.4 Description of the TCL language ................................................................................. 21

2.5 Summary ..................................................................................................................... 23

Chapter 3: Communication interface development .................................................................. 25

3.1 Introduction ................................................................................................................ 25

3.2 Communication Interface concept definition ............................................................. 25

3.3 Approach ..................................................................................................................... 27

3.4 Communication between two Tcl scripts .................................................................... 27

3.5 Direct communication interface in Simulink ............................................................... 29

3.6 Communication Interface between Simulink and a TCL script ................................... 31

3.6.1 Simulink model ........................................................................................................ 33

3.6.2 Tcl script code .......................................................................................................... 33

3.7 Comunication interface between Simulink and SeaFem ............................................ 37

3.7.1 Simulink model ........................................................................................................ 45

3.7.2 TCL script code ........................................................................................................ 48

Page 8: Computational simulation of marine devices by coupled ...

viii

3.8 Summary ..................................................................................................................... 51

Chapter 4 Program case: oscillating water column device ....................................................... 53

4.1 Introduction ................................................................................................................ 53

4.2 Approach ..................................................................................................................... 53

4.3 Development ............................................................................................................... 53

Chapter 5: Program case: fins effect on a Wigley hull .............................................................. 57

5.1 Introduction ................................................................................................................ 57

5.2 Approach ..................................................................................................................... 57

5.3 Development ............................................................................................................... 58

5.3.1 Modifications on the TCL script ............................................................................... 58

5.3.2 Modifications on Simulink ....................................................................................... 58

5.3.3 Modifications on SeaFEM ........................................................................................ 60

PART II: VERIFICATION................................................................................................................ 61

Chapter 6: Analysis of an oscillating water column device ....................................................... 63

6.1 Introduction ................................................................................................................ 63

6.2 Oscillating water column description .......................................................................... 63

6.3 Turbine model ............................................................................................................. 64

6.4 Model description ....................................................................................................... 64

6.5 Verification case: produced power ............................................................................. 65

Chapter 7. Fins effect control algorithm .................................................................................... 67

7.1 Introduction ................................................................................................................ 67

7.2 Fins model ................................................................................................................... 67

7.3 Environment and computational domain ................................................................... 72

7.4 Case: Fins effect in a sea without waves ..................................................................... 73

7.5 Case: Fins effect in irregular sea ................................................................................. 74

Chapter 8: Conclusions ............................................................................................................... 77

APPENDICES ................................................................................................................................ 79

Appendix A: Previous concepts .................................................................................................. 81

A.1 Introduction ................................................................................................................ 81

A.2 Rolling tests ................................................................................................................. 81

A.3 Wave spectrums .......................................................................................................... 81

Appendix B: Simulink blocks description ................................................................................... 83

B.1 Introduction ................................................................................................................ 83

B.2 TCP/IP Client Send block ............................................................................................. 83

Page 9: Computational simulation of marine devices by coupled ...

ix

B.3 TCP/IP Client Receive block ..................................................................................... 84

B.4 Mux and Demux ...................................................................................................... 86

Appendix C: Communication interface development ............................................................... 87

C.1 Introduction ................................................................................................................ 87

C.2 TCL to TCL communication .......................................................................................... 87

C.3 Simulink TCL communication ...................................................................................... 88

C.4 Simulink to SeaFEM Communication .......................................................................... 93

Appendix D: OWC codes ........................................................................................................... 107

D.1 Introduction .............................................................................................................. 107

D.2 TCL code .................................................................................................................... 107

D.3 Simulink file description ............................................................................................ 110

Appendix E: Fins effect control ................................................................................................ 113

E.1 Introduction .............................................................................................................. 113

E.2 TCL code .................................................................................................................... 113

Appendix F: Fins effect control verification ............................................................................. 125

F.1 Verification case: Sea without waves ........................................................................ 126

F.2 Verification case: Sea with waves ............................................................................. 129

F.3 Summary ................................................................................................................... 133

References ................................................................................................................................ 135

Page 10: Computational simulation of marine devices by coupled ...

x

Page 11: Computational simulation of marine devices by coupled ...

xi

List of figures

Figure 1. Images of the different parts of the communication process between Simulink and

SeaFem. ....................................................................................................................................... 10

Figure 2. Definitions of coordinate system ................................................................................. 11

Figure 3. Body dynamics solver algorithm integrated with the wave diffraction-radiation solver

and mooring solver. .................................................................................................................... 17

Figure 4. SeaFEM data capture with activated TCL extension. ................................................... 18

Figure 5. Simplified scheme of the dynamic integration solver of SeaFEM. ............................... 19

Figure 6. Simplex communication. .............................................................................................. 25

Figure 7. Half Duplex Communication. ....................................................................................... 26

Figure 8. Duplex Communication. ............................................................................................... 26

Figure 9. Communication interface development followed process. ......................................... 27

Figure 10. Communication between two TCL scripts process. ................................................... 28

Figure 11. Capture of the communication between the TCL scripts. ......................................... 29

Figure 12. Scheme of the TCP/IP communication system. ......................................................... 30

Figure 13. Signal received by the TCP/IP Receive block. ............................................................. 31

Figure 14. Tcl to Simulink communication Interface process. .................................................... 32

Figure 15. Communication scheme in Simulink. ......................................................................... 33

Figure 16. Data Received in Simulink. ......................................................................................... 37

Figure 17. Diagram of the communication process between SeaFEM and Simulink. ................ 38

Figure 18. Simulink structure. ..................................................................................................... 39

Figure 19. Simulink process. ........................................................................................................ 40

Figure 20. Structures of the Simulink model and the TCL script. ................................................ 41

Figure 21. Initiate Problem diagram. .......................................................................................... 42

Figure 22. Start New Step diagram. ............................................................................................ 43

Figure 23. Start New Iteration diagram. ..................................................................................... 43

Figure 24. Finish Iteration diagram. ............................................................................................ 43

Figure 25. Finish Step diagram. ................................................................................................... 44

Figure 26. Start New Iteration diagram. ..................................................................................... 45

Figure 27. Finish Problem diagram. ............................................................................................. 45

Figure 28. Simulink general structure. ........................................................................................ 46

Figure 29. Simulink general scheme. ........................................................................................... 47

Figure 30. Description of the data transfer between Simulink and SeaFEM. ............................. 53

Figure 31. Scheme of the general communication procedure between the Simulink and

SeaFEM. ....................................................................................................................................... 54

Figure 32. Scheme of the communication procedure between the Simulink and SeaFEM. ....... 55

Figure 33. Scheme of the general communication procedure between the Simulink and

SeaFEM. ....................................................................................................................................... 56

Figure 34. Description of the data transfer between Simulink and SeaFEM. ............................. 57

Figure 35. Parts of the movement equation solved by Simulink and SeaFEM. .......................... 58

Figure 36. Simulink general scheme. ........................................................................................... 59

Figure 37. Simulink Finish Iteration subsystem. .......................................................................... 60

Page 12: Computational simulation of marine devices by coupled ...

xii

Figure 38. Scheme of the oscillating water columns (OWCs) operating system. ....................... 63

Figure 39. Isometric view of the computational domain (Length in meters). ............................ 64

Figure 40. Mesh scheme. ............................................................................................................ 65

Figure 41. Pressure in the OWC. ................................................................................................. 66

Figure 42. Power produced in the OWC...................................................................................... 66

Figure 43. Principles of roll reduction by fin stabilizer.(Kawazoe, Nishikido, & Wada, 1993) .... 68

Figure 44. Localizing active fins on ship hull and stabilizing fin angles. (Rahimuddin, Maimun, &

Gani, 2014)(Kula, 2015) ............................................................................................................... 69

Figure 45. Directions of lift force and drag force.(Kim & Kim, 2011) .......................................... 69

Figure 46. Fin-induced forces and moments.(Lihua, Peng, Songtao, Ming, & Jia, 2018) ............ 70

Figure 47. Simulink scheme. Fixed fins. ...................................................................................... 71

Figure 48. Simulink scheme. Active fins. ..................................................................................... 72

Figure 49. Wigley hull model. ...................................................................................................... 72

Figure 50. Wigley hull generated mesh....................................................................................... 73

Figure 51. Roll movement. Fins effect in a sea without waves. .................................................. 73

Figure 52. Roll velocity. Fins effect in a sea without waves. ....................................................... 74

Figure 53. Roll acceleration. Fins effect in a sea without waves................................................. 74

Figure 54. Roll movement. Fins effect in irregular sea. .............................................................. 75

Figure 55. Roll velocity. Fins effect in irregular sea. .................................................................... 76

Figure 56. Roll acceleration. Fins effect in irregular sea. ............................................................ 76

Figure 57: Block TCP/IP Client Send. ........................................................................................... 83

Figure 58: Block TCP/IP Client Receive ........................................................................................ 84

Figure 59: Block TCP/IP Client Receive with Blocking mode activated ....................................... 84

Figure 60: Block TCP/IP Client Receive Blocking mode not activated ......................................... 84

Figure 61. Representation of a FIFO (queue) with enqueue and dequeue operations. ............. 85

Figure 62. Mux block. .................................................................................................................. 86

Figure 63. Demux block. .............................................................................................................. 86

Figure 64. Simulink client configuration...................................................................................... 88

Figure 65: Block parameters TCP/IP Receive .............................................................................. 89

Figure 66: Block parameters TCP/IP Send ................................................................................... 89

Figure 67: Block parameters Data Type Conversion ................................................................... 90

Figure 68: Simulink general scheme ........................................................................................... 94

Figure 69: Block Parameters TCP/IP Receive .............................................................................. 95

Figure 70: Block Parameters Demux ........................................................................................... 95

Figure 71: Block Parameters Data Type Conversion ................................................................... 96

Figure 72: Block Parameters If .................................................................................................... 96

Figure 73: Block Parameters Merge ............................................................................................ 97

Figure 74: Block Parameters TCP/IP Send ................................................................................... 97

Figure 75. Action 0 - Initiate Problem ......................................................................................... 98

Figure 76. Action 1 - Start New Step ........................................................................................... 98

Figure 77. Action 2 - Start New Iteration .................................................................................... 99

Figure 78. Action 3 - Finish Iteration ........................................................................................... 99

Figure 79. Action 4 - Finish Time Step ....................................................................................... 100

Figure 80. Action 5 - Finish Problem ......................................................................................... 100

Figure 81. Simulink general scheme. OWC. .............................................................................. 110

Page 13: Computational simulation of marine devices by coupled ...

xiii

Figure 82. Simulink subsystem: Finish iteration. OWC. ............................................................ 111

Figure 83. Simulink subsystem: Finish iteration. Pressure calculation subsystem. OWC. ........ 111

Figure 84. Simulink subsystem: Finish iteration. Pressure calculation. OWC. .......................... 112

Figure 85. Simulink general scheme. Active fins installed on a Wigley hull.............................. 121

Figure 86. Start New Iteration. Active fins installed on a Wigley hull. ...................................... 122

Figure 87. Operations subsystem. Active fins installed on a Wigley hull. ................................. 123

Figure 88. General roll moment and angular roll velocity curve. ............................................. 126

Figure 89. Roll movement. Ship without fins. Sea without waves. ........................................... 126

Figure 90. Roll movement. Fixed fins. Sea without waves. ....................................................... 127

Figure 91. Curve Mx-wx. Fixed fins. Sea without waves. .......................................................... 127

Figure 92. Roll movement. Fixed fins. Sea without waves. Verification. .................................. 128

Figure 93. Roll movement. Active fins. Sea without waves. ..................................................... 128

Figure 94. Mx-wx curve. Active fins. Sea without waves. ......................................................... 129

Figure 95. Roll movement. Active fins. Sea without waves. Verification. ................................. 129

Figure 96. Roll movement. Ship without fins. Sea with waves. ................................................ 130

Figure 97. Roll movement. Fixed fins. Sea with waves. ............................................................ 130

Figure 98. Mx-wx curve. Active fins. Sea with waves. ............................................................... 131

Figure 99. Roll movement. Fixed fins. Sea with waves. Verification. ........................................ 131

Figure 100. Roll movement. Active fins. Sea with waves. ......................................................... 132

Figure 101. Roll movement. Active fins. Sea with waves. Verification. .................................... 132

Figure 102. Roll movement. Active fins. Sea with waves. Verification. .................................... 133

Figure 103. Roll movement comparison for the three considered cases. Sea without waves. 134

Figure 104. Roll movement comparison for the three considered cases. Sea with waves. ..... 134

Page 14: Computational simulation of marine devices by coupled ...

xiv

Page 15: Computational simulation of marine devices by coupled ...

xv

List of tables

Table 1. SeaFEM TCL procedures execution point and task. ...................................................... 20

Table 2. Simulink Instrumet Control Toolbox blocks description. .............................................. 21

Table 3. Process flags and tasks. ................................................................................................. 40

Table 4. Tasks correspondence with flag value. .......................................................................... 42

Table 5. Wave data. OWC. .......................................................................................................... 65

Table 6. Wave data. Fins analysis on irregular sea. ..................................................................... 75

Table 7. Waves data. Sea with waves. ...................................................................................... 129

Page 16: Computational simulation of marine devices by coupled ...
Page 17: Computational simulation of marine devices by coupled ...

1

Computational simulation of marine devices by coupled seakeeping and

control system analysis tools

Page 18: Computational simulation of marine devices by coupled ...

2

Page 19: Computational simulation of marine devices by coupled ...

3

Summary

The aim of this Master’s Thesis is to extend the functionalities of a simulation of marine

devices program, SeaFEM, by coupling it to a control simulation program, Simulink, through a

communication interface following a TCP/IP protocol. Thus, more complex external loads could

be applied on the model to simulate.

To verify and demonstrate the correct functioning of the suggested system it has been used to

solve two situations: finding the power produced from the flux going through the turbine of an

Oscillating Water Column device and finding the reduction of the roll due to the effect of the

stabilizing fins installed onboard a Wigley type hull introducing a control algorithm. Finally, this

last case has been applied in more adverse sea conditions similar to reality.

Page 20: Computational simulation of marine devices by coupled ...

4

Page 21: Computational simulation of marine devices by coupled ...

5

Resumen

En este Trabajo Final de Máster se ha pretendido extender las capacidades de un programa de

simulación de artefactos marinos, SeaFEM, acoplándolo con un programa de simulación de

control, Simulink, mediante una interfaz de comunicación siguiendo un protocolo TCP/IP. De

esta manera, se podrían aplicar cargas externas más complejas y bajo un algoritmo de control

sobre el modelo a simular.

Para verificar y demostrar el correcto funcionamiento del sistema propuesto se han resuelto

dos situaciones: conocer la potencia producida a partir del flujo que circula a través de la

turbina de una columna de agua oscilante y la reducción del balance debida al efecto de las

aletas estabilizadoras instaladas en un casco de tipo Wigley introduciendo así un algoritmo de

control. Finalmente, este último caso se ha aplicado en unas condiciones de mar más adversas,

similares a las reales.

Page 22: Computational simulation of marine devices by coupled ...

6

Page 23: Computational simulation of marine devices by coupled ...

7

Glossary

a Inertial moment of the virtual mass around a longitudinal axis

𝐴𝑗 Wave amplitude

b Damping coefficient

c Restoring coefficient

CD Drag coefficient

CL Lift coefficient

D Drag forcé

d2θ/d2t2 Angular acceleration

dθ/dt Angular velocity

F factor to calibrate

Fz_fin fin vertical force

𝐻13

Significant wave height

L Lift forcé

MX Rolling momento

MF Fins momento

p pressure (Kpa)

P Power (Kw)

Q Flux (m3/s)

Rx Tilt

S (m2) Surface

S (w) Wave spectrum

𝑇1 Mean wave period

Troll fundamental period of the ship

U Ship velocity vector

Vs Forward ship velocity

Vz_fin Velocity of the fluid respect to a system of reference located in the fin

𝑤𝑗 Circular frequency

wx Roll angular velocity

yp Rolling arm

αE Angle of attack

αF Angle of attack

αP Pitch angle

∆𝑤 Constant difference between successive frequencies

Page 24: Computational simulation of marine devices by coupled ...

8

𝜖𝑗 Random phase angle of wave component number j

Acceleration

Velocities

θ Movements

Λ Ratio of aspect

φ Angular amplitude

Page 25: Computational simulation of marine devices by coupled ...

9

Chapter 1. Introduction

Times are noticeably changing for engineering. Currently we find structures such as wave

energy converters or marine wind power generation plants, something that a few years ago

was almost unthinkable. For this reason it is essential to find an association between the

product, nature and life, so that they play a joint role. Not only to create innovative designs,

but also to offer optimal functionality, guaranteeing safety and safeguarding sustainability for

ecological well-being. But how can we include these three elements in the design processes of

the structures? To achieve this, it is necessary to make realistic computational simulations that

take into account the precise geometry and properties of different materials, realistic

representations of physical and natural processes, and rational predictions of people's

experiences.

1.1 Scope

The aim of this Master's thesis is to develop a communication interface that couples a

seakeeping program (SeaFEM) with a control system analysis tool (Simulink) to obtain a

simulation that approaches reality more properly. Communicating with Simulink enlarges the

functionalities of SeaFEM since it allows adding a control on how the program applies loads on

the model.

Since SeaFEM has a powerful TCL interface, the commands that govern the communication

between the programs will be collected in a TCL script. SeaFEM TCL enables users to enhance

simulations without recourse to external compiled subroutines by accessing to advanced

features, including operations on internal structures and execution/communication with

external programs.

Several recent studies try to communicate Simulink with other programs to enhance their

capabilities. The procedure followed until these days consisted of creating a block from an S-

function type that used C MEX file (Sysel, 2009), which is complex from the user’s point of

view. Now, Simulink offers a new pack of tools called Instrument Control Toolbox that

facilitates the connection with any device. Among the different protocols that the pack offers

to stablish the communication the TCP/IP protocol has been chosen for the development of

this project.

The procedure of the simulation using the communication interface is the following. The

geometry of a model will be generated in SeaFEM (Figure 1. A) and parameters as current,

waves and other boundary conditions will be configured. From those conditions, SeaFem will

obtain displacements, velocities and accelerations values. Those values will be sent to a

Page 26: Computational simulation of marine devices by coupled ...

10

Simulink file (Figure 1.B) that will use them to calculate the loads to be applied on the model.

A control system can also be added on those loads. The resulting forces and moments will be

sent back to SeaFEM that will apply them on the model (Figure 1.D). As mentioned, a TCL code

will govern all the communication procedures between the programs (Figure 1.C).

Figure 1. Images of the different parts of the communication process between Simulink and SeaFem.

Once the communication interface structure has been defined, several tests have been carried

out to verify its correct functioning. These tests are described in the following section.

1.2 Content description

As already mentioned, this project aims to couple two programs in order to apply complex

loads on a model. For this, it is necessary to design the communication interface and verify

that it works correctly to finally apply it to a specific case. Thus, this project is divided in two

parts: Simulink-SeaFEM coupling system and verification.

In the first part, the process followed to establish the communication interface between both

programs is described. This part includes the design of a general structure and two customized

applications for future applications in the second part of this project.

A

C

D

B

Page 27: Computational simulation of marine devices by coupled ...

11

As mentioned, in the second part, the general communication structure is applied on two

different situations in order to verify the correct functioning: an oscillating water column

(OWC) and a ship Wigley type hull. On the first situation the intention is to calculate the power

obtained from the flux through the turbine of an OWC. The results obtained from calculating

only using SeaFEM and using the coupling system have been compared concluding on a

satisfactory functioning. Once the loads on a model are correctly applied, in the second

situation the intention is to add a control algorithm. For that, a pair of fins acting on a Wigley

hull has been simulated. Several tests considering different fins and sea conditions have been

carried out. The verification method followed is described. Finally, the fins control algorithm

from the previous part is applied in two sea situations to analyze their effect on the decreasing

of ship roll movement: without waves and considering more adverse sea conditions, irregular

sea. As expected, in both situations, the fins have a significant impact on the reduction of the

ship roll movements.

1.3 Previous concepts

This section pretends to introduce the movements of the ship. The study of the dynamic

behavior of a ship considers six movements depending on its six freedom degrees as a rigid

body; this means, three translations and three rotations. The movements of a ship are referred

to a Cartesian coordinate system which origin is located on the waterplane; coinciding with the

x-axis in the longitudinal direction; the y-axis with the transversal direction and the z-axis with

the vertical(Newman, 1979).

The translation in the x-axis is called “surging”; on the y-axis, “swaying” and on the vertical

axis heaving. The rotation around the x-axis is called rolling, on the y-axis, pitching and in the

vertical axis yawing. In Figure 2 the six movements are shown.

Figure 2. Definitions of coordinate system

The surging of a ship is closely related with the effects of the propeller system and is studied in

relation with the resistance and propulsion problems. The yawing and the swaying depend on

the propeller system and on the govern device installed, being usually studied under

manoeuvrability aspects (Faltinsen, 1993).

The heaving, pitching and rolling are the movements related with the resistance, the

propulsion and the manoeuvrability not contained in the vertical plane. These last three

movements compose the object of study that is normally designated Dynamics of the ship and

Page 28: Computational simulation of marine devices by coupled ...

12

are those that have a greater influence on the determination of the habitability conditions

onboard, as in the effect of the forces induced by the waves acting on the ship.

The interaction of the movements together with the manoeuvrability of the ship and the

vertical movements is significant, thus, the manoeuvrability studies are frequently included in

the dynamics of the ship. It is already known that the yawing has an important impact on the

roll, especially in high velocities.

It is also important to mention that only three of these movements are purely oscillatory since

it exists in them restoring forces or moments when the ship is moved from her equilibrium

state: heaving, rolling and pitching. In the surging, swaying and yawing, the ship does not

return to her initial equilibrium state when it is displaced from it.

Page 29: Computational simulation of marine devices by coupled ...

13

PART I: SIMULINK-SEAFEM COUPLING

SYSTEM

Page 30: Computational simulation of marine devices by coupled ...

14

Page 31: Computational simulation of marine devices by coupled ...

15

Chapter 2: Programs description

2.1 Introduction

In this chapter the programs involved in this project as well as the programming language used

to stablish the communication between them are described. The reasons for choosing these

programs for the development of this project will also be remarked.

2.2 SeaFEM basic description

Tdyn is a simulation software that includes a complete set of simulation tools, in a single

computing environment, which allows to solve almost any sort of engineering analysis,

including problems of structural calculation, fluid dynamics, heat transfer , coupled, multi-

physical and seakeeping. Tdyn is made up of three analysis packages: Tdyn CFD + HT,

RamSeries and SeaFEM.

SeaFEM is a module that includes the Tdyn program that offers a set of advanced tools for

simulating the behavior of the sea that allows analysis of the effect of waves, wind and

currents on naval and oceanic structures, as well as for maneuverability studies. The program

covers a wide range of applications such as ships, semi-submersible platforms and TLP type,

FPSO systems, marine wind turbines and oceanic energy generation devices.

SeaFem has been developed at the International Center for Numerical Methods Applied to

Engineering, CIMNE, of the UPC, in collaboration with the company Compass Ingeniería y

Sistemas.

With a new generation solver, SeaFEM allows realistic simulations of 3D wave radiation

diffraction models with multiple bodies, by solving potential flow equations in the time

domain, using the finite element method in non-mesh structured. It also allows solving first

and second order diffraction-radiation equations with real sea states.

In contrast to other programs that simulate the behavior of the sea, which do so in the

frequency domain and with the Boundary Elements Method, SeaFEM works in the time

domain and bases its operation on the Elements Method Finite. The advantage of this method

is that complex geometries can be represented as it allows the use of unstructured meshes.

This Tdyn module is built in GID which is a universal, adaptable and easy to use pre and post

processor, developed by CIMNE. In this way, the operation of this program is based on a set of

steps that must take place consecutively: the pre-process and the post-process.

The preprocess includes the model definition steps:

Page 32: Computational simulation of marine devices by coupled ...

16

- Geometric representation

o Element geometry

o Geometry of the study area

o Definition of the open sea area

- Definition of Tdyn data

o Simulation Type

o General Data

o Problem Description

o Environment Data

o Time Data

o Body Data

o Initial Conditions

o Numerical Data

o Boundary Conditions

- Mesh generation

Finally, the part in which the results are analyzed is the Postprocess.

2.2.1 Information processing in SeaFEM

When designing a program it is necessary to think first on the algorithm that the new program

will have allowing creating a general scheme. In this case, the program will follow and adapt to

the algorithm that governs SeaFEM. In this section the general algorithm of the program is

explained as well as the sequence of the different intern calculations. Thus, this section will

clarify the decisions taken in the following chapter regarding the communication interface

development.

A relaxation algorithm based on the Aitken method is used to accelerate convergence within

each loop (Serván Camas, 2016).In this way, the dynamic solver is implemented in SeaFEM by

means of three nested loops shown in Figure 3.

Page 33: Computational simulation of marine devices by coupled ...

17

Figure 3. Body dynamics solver algorithm integrated with the wave diffraction-radiation solver and mooring

solver.

- Time marching loop: In the time marching loop the information from the previous

time step is used as initial values of the iterative procedure. This is the most

external loop in the program and refers to the time step.

- Solver loop: Hydrodynamic loads are calculated in the Solver Loop. This loop will

perform iterations in which will solve the linear system corresponding to the

problem of wave diffraction radiation. The program will iterate until the condition

of convergence of hydrodynamic loads is reached along with the kinematics of the

body.

- Body dynamics loop: The body dynamics loop is the inner loop. Within this loop,

wave diffraction and radiation loads remain unchanged, hydrostatic forces are

updated based on body position, and the rest of loads will be updated in each

iteration.

2.2.2 Tcl extension

Occasionally, the program does not have incorporated the functionalities that the user wants

to perform. For this reason SeaFEM offers the possibility of extending them by adding a TCL

script in the configuration of the program. Thus, SeaFem distribution includes a basic TCL

installation that allows implementing new capabilities in SeaFem. As the aim of this project is

Page 34: Computational simulation of marine devices by coupled ...

18

connecting SeaFem with Simulink in order to extend the capabilities of the program to

calculate external loads and add a control system on them, the TCL extension facility has been

used.

The SeaFem extension is activated when the check-box is selected in the TCL Data section of

the General Data part in the problem definition. The route to the location of the TCL script that

the program is going to read should also be indicated as shown in Figure 4.

Figure 4. SeaFEM data capture with activated TCL extension.

SeaFem has implemented some standard SeaFEM TCL event procedures (SeaFEM Theory

Manual, n.d.). These procedures have specific names that SeaFem recognizes as well as a

specific syntax in the definition of values. For this project the procedures that we are going to

use include:

- TdynTcl_InitiateProblem

- TdynTcl_StartNewStep

- TdynTcl_StartNewIteration

- TdynTcl_FinishIteration

- TdynTcl_FinishStep

- TdynTcl_FinishProblem

These procedures correspond to different parts of the loops described in the previous section

and illustrated in Figure 3. In order to understand more easily in which points are those loops

located and allow the access to these procedures a generalized example is presented. Thus,

the following figure pretends illustrating how SeaFEM process the data to achieve results to

apply to the model. In this general case it has been considered that firstly the program does

not reach the convergence and it has to begin again until it reaches the convergence in the

next iteration. In the graphic it is supposed that the process has already begun

(TdynTcl_InitiateProblem) continuing in the following way:

- Beginning of the time loop (TdynTcl_StartNewStep): the information from the

previous time step is used as initial values of the iterative procedure.

1) Begins to count time and iterations.

- Solver loop and Body Dynamics loop (TdynTcl_StartNewIteration): The program

will iterate until the condition of convergence of hydrodynamic loads is reached

along with the kinematics of the body

2) As convergence is not reached the iteration is manteined i = 0; the following time step

begins.

Page 35: Computational simulation of marine devices by coupled ...

19

3) The program returns to the beginning of the time step (TdynTcl_StartNewStep). It is a

new time step t = 1 but in the same iteration i = 0.

- SeaFEM studies again the hidrodynamic loads convergence.

4) In this case convergence is reached. Thus, iteration finishes. (TdynTcl_FinishIteration).

5) The program ads a new time step (TdynTcl_FinsihStep).

6) The program ads the new data (TdynTcl_StartNewStep) to carry out the calculus in the

new iteration i =1 and time step t = 2.

The program will continue this process until the desired time duration for this simulation is

reached. Once reached, the program will activate the endings orders (TdynTcl_FinishProblem).

Figure 5. Simplified scheme of the dynamic integration solver of SeaFEM.

The following Table 1 clarifies and summarizes in which point of the loop are located the

procedures and which is their task.

Page 36: Computational simulation of marine devices by coupled ...

20

Procedure Point of execution Task

TdynTcl_InitiateProblem Called at the beginning of the

execution, once all the data

structures have been created.

This procedure runs the

execution of the program.

TdynTcl_StartNewStep Called at the beginning of the

time marching loop.

The previous time step is used

as initial values of the iterative

procedure.

TdynTcl_StartNewIteration

Called at the beginning of the

solver and body dynamics loop.

Convergence study.

TdynTcl_FinishIteration Called when the convergence is

reached.

Ads a new iteration.

TdynTcl_FinishStep Called once the current step is

finished.

Ads a new time step.

TdynTcl_FinishProblem This procedure is called at the

end of the execution of the

current problem.

Closes and stops the

procedures and execution of

the program.

Table 1. SeaFEM TCL procedures execution point and task.

Using the aforementioned procedures, information can be introduced and extracted from

SeaFEM at computational time.

2.3 Simulink description

Simulink is a graphical programming environment for modeling, simulating and analyzing

multidomain dynamical systems developed by MathWorks. Its primary interface is a graphical

block diagramming tool and a customizable set of block libraries. It offers a good quality

integration with the rest of the MATLAB environment and can either drive MATLAB or be

scripted from it. Simulink is used in automatic control and digital signal processing for

multidomain simulation and model-based design.

In essence, Simulink is a visual programming environment, which works on the Matlab

programming environment. Simulink provides the user a packet of tools that allows sending

and receiving information by means of a different communication protocols called Instrument

Control Toolbox.

The Instrument Control Toolbox was designed to connect MATLAB directly to instruments such

as oscilloscopes, function generators, signal analyzers, power supplies, and analytical

instruments (Instrument Control Toolbox 2 User ’s Guide, n.d.). The toolbox connects to the

instruments via instrument drivers such as IVI and VXIplug&play or via text-based SCPI

commands over commonly used communication protocols such as GPIB, VISA, TCP/IP, and

UDP. The user can also control and acquire data from test equipment without writing code.

But the functionality that we are interested in for this project is that allows generating data in

MATLAB to send out to an instrument or read data into MATLAB for analysis and visualization.

The packet contains the blocks of the Table 2.

Page 37: Computational simulation of marine devices by coupled ...

21

As it has been mentioned, for this project:

- The TCP/IP Communication protocol will be used.

- Only TCP/IP Client Receive block and TCP/IP Client Send block will be used.

- Both of the blocks are for use as TCP/IP clients. They do not work as TCP/IP servers.

Block Description

Query Instrument Query or read instrument data

To Instrument Send simulation data to instrument

Serial Configuration Configure parameters for serial port

Serial Receive Receive binary data over serial port

Serial Send Send binary data over serial port

TCP/IP Client Receive block Send binary data over serial port

TCP/IP Client Send block Send data over TCP/IP to specified remote

machine

UDP Receive Receive data over UDP network from

specified remote machine

UDP Send Send data over UDP network to specified

remote machine

Table 2. Simulink Instrumet Control Toolbox blocks description.

2.4 Description of the TCL language

Tcl (Tool Command Language) is a high-level, general-purpose, interpreted, dynamic

programming language. It was designed with the goal of being very simple but powerful. Tcl

casts everything into the mold of a command, even programming constructs like variable

assignment and procedure definition. Tcl supports multiple programming paradigms, including

object-oriented, imperative and functional programming or procedural styles.

It is commonly used embedded into C applications, for rapid prototyping, scripted applications,

GUIs, and testing. Tcl interpreters are available for many operating systems, allowing Tcl code

to run on a wide variety of systems. Because Tcl is a very compact language, it is used on

embedded systems platforms, both in its full form and in several other small-footprint

versions.

Page 38: Computational simulation of marine devices by coupled ...

22

The popular combination of Tcl with the Tk extension is referred to as Tcl/Tk, and enables

building a graphical user interface (GUI) natively in Tcl. Tcl/Tk is included in the standard

Python installation in the form of Tkinter.

It was first created by John Osterhout in 1989.

A socket is defined by a pair of local and remote IP addresses, a transport protocol and a pair

of local and remote port numbers. In order for two programs to communicate with each other,

certain requirements must be met:

- That one program is able to locate the other.

- That both programs are capable of exchanging any sequence of octets, that is, data

relevant to their purpose.

For this, the three resources that originate the concept of socket are necessary:

- A communications protocol, which allows the exchange of octets.

- A pair of Network Protocol addresses (IP Address, if TCP / IP Protocol is used), which

identifies the source and remote computer.

- A pair of port numbers, which identifies a program within each computer.

There are two distinct types of socket network applications: Server and Client. Servers and

Clients have different behaviors; therefore, the process of creating them is different. What

follows is the general model for creating a streaming TCP/IP Server and Client.

- Server

o Initialize Winsock.

o Create a socket.

o Bind the socket.

o Listen on the socket for a client.

o Accept a connection from a client.

o Receive and send data.

o Disconnect.

- Client

o Initialize Winsock.

o Create a socket.

o Connect to the server.

o Send and receive data.

o Disconnect.

Sockets allow implementing a client-server or peer to peer architecture. The communication

must be initiated by one of the programs called the client program. The second program waits

for another to initiate communication, for this reason it is called the server program.

A socket is an existing process or thread on the client machine and the server machine, which

ultimately serves the server and client program to read and write the information. This

information will be transmitted by the different network layers.

Page 39: Computational simulation of marine devices by coupled ...

23

When a client connects to the server a new socket is created, in this way, the server can

continue to wait for connections in the main socket and communicate with the connected

client, in the same way a socket is established in the client in a local port.

A server application usually listens for a specific port waiting for a client connection request.

Once it is received the client and the server connect so that they can communicate with each

other. During this process, the client is assigned to a port number, through which it sends

requests to the server and receives the corresponding responses from it.

Similarly, the server obtains a new local port number that will help it to continue listening to

each connection request from the original port. Similarly connect a socket to this local port.

2.5 Summary

Once the programs and the communication language used in this project have been described,

the facilities offered by their tools to implement it can be listed.

TCL is the best option since SeaFEM incorporates a TCL extension that allows enlarging the

capabilities of the program. Furthermore, this Language allows creating a simple structure to

communicate the clients with the server.

The tools package Instrument Control Toolbox of Simulink, for its parts, allows Simulink to

send and receive information from other devices through a TCP/IP protocol. Thanks to the

presentation and the format of the tools, the Package offers a visual and intuitive handling.

Page 40: Computational simulation of marine devices by coupled ...

24

Page 41: Computational simulation of marine devices by coupled ...

25

Transmitter Receiver

Chapter 3: Communication interface

development

3.1 Introduction

In this chapter, the process followed to transmit data between Simulink and SeaFEM through a

TCL script is detailed. Before detailing each step of the design process some concepts

regarding the communication interface concept will be revised.

Several tests have been made in this project in order to develop the communication interface

between SeaFEM and Simulink increasing the difficulty each time. For each test a general

example is presented.

3.2 Communication Interface concept definition

The interfaces are responsible for preparing the data so that they can travel through the

transmission medium. If the transmission medium is copper the data can be represented as

voltage or current levels and if it is optical fiber the data must be represented by light pulses.

The protocol, in turn, is responsible for establishing the rules that govern the exchange of data

between two devices.

One method of characterizing lines, terminal devices, computers and modems is by their mode

of transmission or communication. The three kinds of transmission modes are simplex, half-

duplex and full-duplex.

- Simplex communication: Simplex or unidirectional transmission (See Figure 6) only

occurs in one direction, disabling the receiver from responding to the transmitter.

Normally simplex transmission is not used where human-machine interaction is

required. Examples of simplex transmission are: TV and radio broadcasting,

unidirectional paging, etc.

Figure 6. Simplex communication.

Page 42: Computational simulation of marine devices by coupled ...

26

Transmitter

Receiver

Receiver

Transmitter

- Half Duplex Communication: Half-duplex transmission (See Figure 7) allows

transmission in both directions; however, transmission can occur only in one direction

at a time. Both transmitter and receiver share a single frequency. A typical example of

half-duplex is the civil band radio (CB) where the operator can transmit or receive, but

cannot perform both functions simultaneously on the same channel. When the

operator has completed the transmission, the other party must be advised that it can

start transmitting (e.g. saying "change").

Figure 7. Half Duplex Communication.

- Duplex Communication: Full-duplex transmission (fdx) (See Figure 8) allows the

transmission in both directions, but simultaneously on the same channel. There are

two frequencies: one to transmit and another to receive. In the telecommunications

field abound the examples. The most typical case is telephony, where the transmitter

and receiver communicate simultaneously using the same channel, but using two

frequencies.

Figure 8. Duplex Communication.

A protocol is the language with which devices communicate on the network. It is the way in

which the devices of a network exchange information. For example, two computers connected

in the same network but with different protocols could never communicate, for this, it is

necessary that both "speak" the same language, therefore, the TCP / IP protocol was created

for Internet communications. It is necessary to have this communication protocol installed in

order to allow any computer to connect to the Internet. They can be well implemented in

hardware (network cards), software (drivers), or a combination of both.

Then, a more appropriate way to define it would be: it is a set of conventions related to data

format, transmission methods, network topology, bus accesses and control procedures in

general necessary for communication between two or more equipment and services.

Transmitter

Receiver

Receiver

Transmitter

Page 43: Computational simulation of marine devices by coupled ...

27

3.3 Approach

Several tests have been made in this project in order to develop the communication interface

between SeaFEM and Simulink increasing the difficulty each time. This means that the first

tests were trying to communicate the programs with themselves and then tried to

communicate the programs with each other.

Figure 9 shows the followed communication interface development process. On the first step

it is necessary to be able to send and receive data from a channel in TCL and in Simulink,

separately. Once both programs work, on the second step it has to be possible to transfer data

between TCL and Simulink. Finally, on a third step the communication interface between

Simulink and SeaFEM through a TCL Script can be developed. The following sections describe

each step.

Figure 9. Communication interface development followed process.

3.4 Communication between two Tcl scripts

The first step to develop the communication interface between the two programs is to know

how to communicate a program with itself. In TCL language it is possible to communicate two

scripts, acting as server and client, through a channel. For that, once the socket is opened and

the channel is assigned, the server begins the communication between them begins. In order

to check that the communication works satisfactorily the server sends the data back to the

client.

Figure 10 describes the communication process between the server and client scripts. As

shown, the client assigns a channel and both scripts try to connect to the channel. If the server

is not able to connect to the channel the connection aborts and ends. If the server

satisfactorily connects to the channel the communication between the two programs can

begin.

1st 2nd 3rd

TCL

SIMULINK

SEAFEM

Tcl to Tcl

communication

Direct Interface

Communication

Communication

between Tcl and

Simulink

Communication

between

SeaFem and

Simulink

Page 44: Computational simulation of marine devices by coupled ...

28

In order to establish a communication between the scripts a loop has been created in such way

that the server will ask a message to the client and wait for it, the client will answer and the

server will ask a message and wait again.

Figure 10. Communication between two TCL scripts process.

Client script

The client assigns the channel and waits for the server to connect. Then, the client asks the

user to write a message and sends it to the channel.

Sever script

The procedure that performs the server actions is called proc Receive_Data.

As mentioned, the server tries to connect to the channel and configures it. Then,

communication loop where the data transfer takes place is defined. Finally, the socket is

closed.

SERVER CLIENT

Open socket

Channel

configuration

Channel asignement

Connection

YES

NO Exit

Wait for client data

Introduce message to send to server

Send message to channel

Get message from the channel

Send message to channel

Receive server response

Loop

Page 45: Computational simulation of marine devices by coupled ...

29

The different commands of the codes can be found in the Appendix C (p. 87). Figure 11 shows

an example of an established communication between the two scripts on the Command

Windows.

Figure 11. Capture of the communication between the TCL scripts.

3.5 Direct communication interface in Simulink

Following with the communication interface development process described in

Figure 9, the remaining part of the first step (data transfer involves one program) is

implementing a Simulink model to send and receive data through a channel. The process,

described in the example below, requires using the blocks from the Instrument Control

Toolbox pack.

Sending and Receiving Data over a TCP/IP Network

This example details how to build a simple model using the Instrument Control Toolbox blocks

in the library block in conjunction with other blocks in the Simulink library. It also illustrates a

different possibility of communication since, unlike the previous TCL case, the data is sent to

an echo server using TCP/IP protocol.

As mentioned, it is necessary to create an echo server on the machine that simulates sending a

signal to the TCP/IP send block and echoes the result back to the Send block to send data.

Then, the TCP/IP Receive block will read that same data back into the model.

The steps to create this communication example are listed and described below:

Step 1: Create an Echo Server

Step 2: Create a New Model

Step 3: Open the Block Library

Step 4: Drag the Instrument Control Toolbox Blocks into the Model

Step 5: Drag the Sine Wave and Scope Blocks to Complete the Model

Step 6: Connect the Blocks

Step 7: Specify the Block Parameter Values

Step 8: Specify the Block Priorities

Step 9: Run the Simulation

Step 10: View the Result

Page 46: Computational simulation of marine devices by coupled ...

30

- Step 1. Create an Echo Server: this step consists opens a port on the computer to work

as an echo server that sends and receives signals via TCP/IP. To create an echo server

(in this example port 50000 was used) the following command in MATLAB should be

used:

echotcpip('on', 50000)

- Step 2. Create a New Model: open an empty Editor window.

- Step 3. Open the Block Library: In this example the blocks on the Instrument Control

Toolbox node are used.

- Step 4. Drag the Instrument Control Toolbox Blocks into the Model: For this example

the blocks used are the TCP/IP Client Send and the TCP/IP Client Receive. A Scope

block is used to display the data received by the TCP/IP Receive block.

- Step 5. Drag the Sine Wave and Scope Blocks to Complete the Model

- Step 6. Connect the Blocks: Once all the blocks are on the editor window the Sine Wave

block and the TCP/IP Client Send block are connected as shown in Figure 12. In the

same way, the output port of the TCP/IP Client Receive block and the input port of the

Scope block are connected.

Figure 12. Scheme of the TCP/IP communication system.

- Step 7. Specify the Block Parameter Values: In this part the parameters for the blocks in

the model are configured.

o TCP/IP Client Send Block configuration: The Remote Address and the Port fields are set with the address of the echo server.

o TCP/IP Client Receive Block configuration: The Remote Address and the Port fields are set with the address of the echo server.

o Sine Wave Block configuration: the Sample Time Field of this block must match the one in the TCP/IP Client Receive Block.

- Step 8. Specify the Block Priorities: the order in which Simulink should process the

blocks is specified on the Properties section by assigning a priority number. In this case,

the priority of TCP/IP Client Send and TCP/IP Receive is set to 1 and 2, respectively. In

the Configuration Parameters dialog box, the Type field is set to Fixed-step and

the Solver field to discrete (no continuous states).

Page 47: Computational simulation of marine devices by coupled ...

31

- Step 9. Run the Simulation: While the simulation runs, the status bar at the bottom of

the Simulink Editor updates the progress of the simulation.

- Step 10. View the Result: The Scope block shows the graph in Figure 13 correspondent

to the signal received by the TCP/IP Client Receive block.

Figure 13. Signal received by the TCP/IP Receive block.

3.6 Communication Interface between Simulink and a TCL script

Once it is known how to communicate TCL and Simulink separately, the second step, following

the scheme in

Figure 9, is to communicate the programs between them. The following example was used to

stables the communication between Simulink and TCL.

In this example, the following iterative operation is solved:

𝑂𝑢𝑡𝑛𝑢𝑚 = 2(2 + 𝑖) 𝑖 = 0,1,2, … ,50

𝐼𝑛𝑡𝑜𝑢𝑡 = (𝑖 + 0.98888999999) 𝑖 = 0,1,2, … ,50

Both values, Outnum and Intout1, are calculated in the TCL script and sent to Simulink. Once

Simulink has received the values it shows them on a graph. In order to check that the process

works successfully Simulink will send the values back to TCL and be shown on the Command

Window. Thus, Simulink will act as a client and TCL as the server. Figure 14 shows the process

1 In this example Intout is used to introduce the error to check that Simulink reads properly an integer

that has been transformed to double.

Page 48: Computational simulation of marine devices by coupled ...

32

of the communication between TCL and Simulink. The functioning is very similar to the

communication between two TCL scripts.

Figure 14. Tcl to Simulink communication Interface process.

Thus, in this example, two values are sent and received and will be interpreted as a vector for

both programs:

(intout, outnum)

TCL SIMULIN

K

Open socket

Accept client

connection

Connects to channel

Connection

YES

NO Exit

Operations

Receive data

Transform data and send

Receive data and transform

Send data

Loop

Show

data

Close socket and channel

Page 49: Computational simulation of marine devices by coupled ...

33

The Simulink model and the TCL script code implemented are described in detail in the

following sections.

3.6.1 Simulink model

Figure 15 shows the communication scheme in Simulink. The blocks used are the following:

- TCP/IP Client Receive: The remote address and port must be indicated in the data

reception block. Since two data will be received, it must be indicated as a vector [1

2].

- TCP/IP Client Send: In the data sending block the Remote address and the Port

must coincide with those previously indicated in the TCP/IP Client Receive block.

- Scope: shows the values received on a graph.

- Display: shows the values received.

- Data Type Converter: In this case, this tool is added to check if the values were

received in the correct format.

Figure 15. Communication scheme in Simulink.

3.6.2 Tcl script code

As shown in the Figure 14, the TCL has to perform the following tasks:

- Open a socket.

- Accept the connection of the client.

- Operate.

- Send data.

- Receive data.

- Transform data.

- Close the socket.

Page 50: Computational simulation of marine devices by coupled ...

34

All those tasks compose the different procedures of the code. The procedures have to be

written in certain order so the process runs as in the Figure 14.

As it is already known, in TCL, the code begins describing the procedures and after begins the

main program, in which the procedures are called.

- Procedures description:

o Proc close_socket

o Proc accept_client_connection

o Proc open_socket

o Proc send_data

o Proc receive_data

- Main program:

o Variables description

o Open socket

o Operation loop

o Send data

o Receive data

o Close socket

Now the procedures are going to be described in detail.

- Proc close_socket: This procedure closes the channel in which the communication

takes place.

- Proc accept_client_connection: This procedure configures the channel and determines

if the communication between programs has been stablished correctly. If the

communication is successful the connection will be set to value 1, otherwise an error

message will appear indicating that the client tried to connect to server.

Page 51: Computational simulation of marine devices by coupled ...

35

- Proc open_socket: In this procedure the channel and port where the communication

will take place are defined.

- Proc send_data: This procedure sends data to Simulink.

- Proc receive_data: this procedure sets the size of the data packet that we want to

receive from Simulink and reads the data. In this example we will receive 2 doubles (2

packs of 8 bytes).

As mentioned, all those procedures are going to be called in a particular order in the Main

program.

- Variables description and Open socket: Since Simulink can only act as a Client, the

TCL script will obligatorily act as a server. As described in the previous section, a

server socket begins defining the socket, the port in which the communication will

take place (in the example the port will be 9901) and the channel. The channel is

defined by opening the socket on the wished port.

Page 52: Computational simulation of marine devices by coupled ...

36

- Operation loop: In the main program the operations loop also has to be described.

In this example the loop operation takes into account the error in the

transformation of the data in its sending and reception. The expression “set

intout” introduces the error to check that Simulink reads properly an integer that

has been transformed to double.

- Send data: Before sending the data it is necessary to transform it to the correct

format by using the command “binary format”2.

Once the data is transformed, the sending procedure can be called defining the data to

be sent and the channel. In order to verify that the process is successful, a message

that shows the data that has been sent to Simulink can be added.

- Receive data: Now the program is going to receive data from Simulink. The data

will be received and transformed into the readable format for TCL. Once again, a

verification message that shows the values received can be added.

- Close socket: Finally, and to ensure that the process of sending information does

not interfere with future tasks, it is necessary to close the channel and the port

that has been used. To achieve this purpose, the procedures created above will be

called.

2 Binary is a built-in Tcl command, performs conversions on the bytes in a string, rather than the

characters. The most commonly used binary type commands are the following: binary format formatString ?arg arg ...? binary scan string formatString ?varName varName ...?

Binary facilitates the direct manipulation of bytes in a string, and can interpret those bytes in various ways. Binary scan is used to extract data, and binary format is used to generate data.

Page 53: Computational simulation of marine devices by coupled ...

37

Figure 16 shows the graphic obtained in Simulink in which appear two lines that correspond to

the two different operations of the loop. The blue line corresponds to the outnum values and

the yellow line to the intout values.

Figure 16. Data Received in Simulink.

3.7 Comunication interface between Simulink and SeaFem

Once the data transfer between TCL and Simulink works successfully, the third step (See

Figure 9) which is communicating Simulink and SeaFEM through a TCL script can be developed.

Before describing the designing process, it is opportune to mention that it has been designed

in such way, that it is as intuitive as possible and that the user has to make the minimum

modifications when using it for different applications. Meaning, it is expected that the user

only has to modify the operational part to add the required functions to obtain the external

forces and moments but not the communication algorithm. The place where the user should

add those calculi is inside a Simulink box called Operations.

In the example used to illustrate this section it is considered that there is a SeaFEM model of a

body and the intention is to apply an external force on it. That external force has been

calculated in Simulink and sent to SeaFEM.

As it can be intuit, until this moment iterative processes have been treated. In the cases seen

until now there were loops and, in each loop there was a data reception, a calculus and a

sending of the result. From now on, each loop will be called Time Step.

Page 54: Computational simulation of marine devices by coupled ...

38

As explained in the previous chapter, SeaFEM works with three loops to control the

convergence of its results. The communication interface developed in this project has been

designed following the steps succession of SeaFEM. Thus, there will be different time steps on

each one of the iterations until SeaFEM reaches the convergence.

The diagram in figure shows a general preliminary scheme of the first time step of the iterative

communication process between the two programs. The process would be the following (see

Figure 17):

- Simulink calculates the external forces acting on the model and sends them to

SeaFEM.

- SeaFEM applies the forces on the body and calculates the new displacements.

- SeaFEM sends the new displacements to Simulink.

- SeaFEM will calculate the convergence of the results. If the results converge a new

iteration with new displacement values will begin. If not a new time step inside the

iteration will begin and SeaFEM will recalculate the displacements asking values to

Simulink until convergence is reached.

Figure 17. Diagram of the communication process between SeaFEM and Simulink.

Thus, it can be clearly observed that Simulink is going to act as the client role and SeaFEM as

the server. Once assigned the role to each program the client general scheme can be defined.

Figure 18 shows general structure of the Simulink part. The functioning of the diagram

beginning at time t = 0 would be the following:

YES/NO YES/NO

Convergence

Control

Send displacements

Send forces

Convergence

Control

SIMULINK SEAFEM

tn = t

tn = t + 1

Page 55: Computational simulation of marine devices by coupled ...

39

- Simulink, as it has preconfigured the role of Client, needs to be the first to receive

data. For this reason, in this step, Simulink makes a first reception and delivery of

empty data, in order to activate the program. This data will be used later to

indicate which task the program is going to develop.

- Simulink receives from SeaFEM the displacements.

o If there is not any operation to be solved the program ends and exits.

- Otherwise, Simulink solves the operations required to obtain the forces from the

displacements.

- Simulink sends the obtained forces to SeaFEM.

- SeaFEM studies the convergence.

o If it reaches the convergence a new iteration begins (it = it+1) and the

process continues.

o If convergence is not reached a new time step begins in the same iteration.

Figure 18. Simulink structure.

In order to send several values in each time step it is grouped in a vector. In this case, the

intention is to obtain forces (fx, fy, fz) from the displacements (dx, dy, dz) in the three

directions (x-,y- , z-):

(dx, dy, dz, fx, fy, fz)

It is also necessary that this vector includes a value indicating which task Simulink has to

develop (flag) and the time increase (dt). Thus, the vector used has two new components:

(flag, dt, dx, dy, dz, fx, fy, fz)

it = it + 1 t = t + dt

it=0

NO

RECEIVE

SEND

RECEIVE

OPERAT

E

SEND

CONVERGENCE

END YES

EXIT

t = 0

YES NO

SIMULINK

Page 56: Computational simulation of marine devices by coupled ...

40

Figure 19. Simulink process.

Figure 19 shows the same process of figure but the different actions that take place have been

grouped in four tasks and each task has been assigned to a different number called Flag.

Flag Task

0 Initialization

1 Iteration

2 Convergence

3 End

Table 3. Process flags and tasks.

Once the client structure is determined the structure of the TCL script can be planned. Figure

20 shows the relation between the TCL code and Simulink. The following tasks previously

defined can be distinguished (See Table 3):

- 0 → Initialization: the first reception and delivery from Simulink that was empty

has been used to begin the program by receiving a flag value 0 and a time step.

- 1 → Iteration: When Simulinks receives the flag value 1 and the displacements

from SeaFEM operates to obtain the forces and sends them back to the channel.

- 2 → Convergence: If convergence is not reached Simulink receives the flag value 2

and the process begins again on a new time step (t = t+1). Otherwise, a new

iteration begins (it = it + 1). This steps makes reference to the time step.

it = it + 1 t = t + dt

it=0

NO

RECEIVE

SEND

RECEIVE

OPERAT

E

SEND

CONVERGENCE

END YES

EXIT

t = 0

YES NO

SIMULINK

Convergence

End

Iteration

Initialization

Page 57: Computational simulation of marine devices by coupled ...

41

- 3 → End: Simulink receives the flag value 3 and ends the communication.

Figure 20. Structures of the Simulink model and the TCL script.

To adequate the defined steps to the loops in the TCL code and to SeaFEM the iteration and

convergence steps have been divided into the beginning and end of the loop.

- Iteration:

o Start New Iteration

o Finish Iteration

- Convergence:

o Start New Step

o Finish Time Step

Thus, the sequence of steps is:

Send [0,…]

Receive

For (time)

While (it)

Send [1,…]

Operations

Receive

Send [2,…]

Receive

Send [3,…]

TCL

it = it + 1 t = t + dt

it=0

NO

RECEIVE

SEND

RECEIVE

OPERAT

E

SEND

CONVERGENCE

END YES

EXIT

t = 0

YES NO

SIMULINK

Page 58: Computational simulation of marine devices by coupled ...

42

Flag Name of the task

0 Initiate Problem

1 Start New Step

2 Start New Iteration

3 Finish Iteration

4 Finish Time Step

5 Finish Problem

Table 4. Tasks correspondence with flag value.

Now that the tasks are defined and the general structure of the communication has been

established, an example of the process is described in detail.

1. Initiate Problem (Flag 0) (t = 0):

- TCL opens the socket stablishing the channel in which the data transfer takes place.

- We launch SeaFEM to calculate. SeaFEM connects to the channel and waits for the

Client to connect.

- We launch Simulink to calculate. Simulink tries to connect to the channel.

- TCL accepts the client connection. Now both programs are connected on the

channel waiting for an action.

- SeaFEM sends a time increment, dt, to the channel.

- TCL sends value flag 0 and the time increment, dt, to Simulink.

- Simulink initiates the problem and stores the value of the time increment, dt.

Figure 21. Initiate Problem diagram.

2. Start New Step (Flag 1) (t=0): This step enters to the time loop and there is only a

delivery and reception of data. As shown in Figure 20 the time increases if there is no

convergence meaning at the end of the time step.

SIMULINK TCL SEAFEM

Initiate

Problem

(Flag 0) Conection

Wait

Receive

Send

Open socket

Accept Client

Conection

Send (0,…)

Receive

Wait

Conection

Store dt

Page 59: Computational simulation of marine devices by coupled ...

43

Figure 22. Start New Step diagram.

3. Start New Iteration (Flag 2) (t = 0): As SeaFEM has not developed any calculus yet it is

assumed that convergence is not reached. There is only a delivery and reception of

data since iterations have not been initialized yet.

Figure 23. Start New Iteration diagram.

4. Finish Iteration (Flag 3) (t = 0):

- As SeaFEM has not arrived to the end of the calculation process the program sends

the displacements to the channel.

- TCL collects the displacements and sends them to the channel.

- Simulink receives the displacements from the channel and operates them to obtain

the forces.

- Simulink sends the forces to the channel.

- Tcl collects the forces from the channel and orders SeaFEM to apply them to the

model.

Figure 24. Finish Iteration diagram.

Send (1,…)

Receive

Send

Start New Step

(Flag 1) Receive

Send (2,…)

Receive

it = it+1

Receive

Send

Start New

Iteration

(Flag 2)

NO

END

OPERATIONS

Send (3,…)

Receive

Receive Finish Iteration

(Flag 3)

Send

Send (dx, dy, dz)

Receive (fx, fy, fz)

Page 60: Computational simulation of marine devices by coupled ...

44

Once SeaFEM has received the displacements the program checks the convergence.

Depending if convergence is found or not a different step will succeed. Let us comment first

the no convergence situation.

5A. Finish Time Step (Flag 4) (t = 0):

- If convergence is not reached TCL send the value flag 4 to the channel.

- Simulink receives the flag value from the channel and ads a new time step (t = t +

dt). In this step iterations are initialized (it = 0).

- Simulink sends the new time step to the channel.

- TCL receives the new time step from the channel.

Figure 25. Finish Step diagram.

6A. Finish Iteration (Flag 3) (t = t + dt): Simulink calculates the forces again and sends

them back to SeaFEM until convergence is reached (

Figure 24).

Let us comment now the situation in which Simulink and SeaFEM converge to a result. In that

situation the program goes back to the second flag 2. Start New Step. It is possible that

convergence is not reached at the first time step (t = 0). We consider that this situation takes

places at a certain time step (t = t + dt).

5B. Start New Iteration (Flag 2) (t = t + dt) (it = 0):

- TCL sends the value flag 2 to the channel.

- Simulink receives the flag from the channel and ads a new iteration.

- Simulink sends the information to the channel.

- TCL receives the information from the channel.

CONVERGENCE

NO Receive Send (4,…)

Receive

Finish Step

(Flag 4)

it = 0

t = t + dt

Send

Page 61: Computational simulation of marine devices by coupled ...

45

Figure 26. Start New Iteration diagram.

6A. Finish Iteration (Flag 3) (t = t + dt) (it = it + 1): Simulink begins the calculation process

to obtain the forces from the displacements received from SeaFEM (

Figure 24).

The program is going to iterate until SeaFEM sends all the displacements to Simulink. Then, the

execution ends and the communication is closed. For this explanation we are going to assume

the program ends at certain time step (t = t + dt) and at a certain iteration (it = it + 1).

7. Finish problem (t = t + dt) (it = it + 1):

- There are not more displacements that SeaFEM can send to Simulink.

- TCL sends to the channel the value flag 5.

- Simulink receives the flag value and disconnects from the channel.

- TCL closes the socket and the channel disconnecting SeaFEM.

Figure 27. Finish Problem diagram.

After the Finish Problem step, SeaFEM has applied to the model all the forces received from

Simulink. Now SeaFEM is able to show the simulation postprocess.

In the following sections the TCL code and the Simulink model developed are going to be

described.

3.7.1 Simulink model

As described above Simulink is expected to perform different tasks depending on a condition

imposed by the flag value. In Simulink those tasks are called actions.

Send (2,…)

Receive

it = it+1

Receive

Send

Start New

Iteration

(Flag 2)

Send (5,…)

EXIT

END

YES

Receive Finish Problem

(Flag 5)

Page 62: Computational simulation of marine devices by coupled ...

46

The following vector, that TCL sent to the channel, arrives to the receive block:

(flag, dt, dx, dy, dz, fx, fy, fz)

This vector is discomposed into the flag and the other components. The flag indicates to the

conditional block which action to perform while the other components are needed in every

action. The results of each action are grouped and sent to the channel. This process is shown in

Figure 28.

Figure 28. Simulink general structure.

The diagram in Figure 28 shows the general configuration of the Simulink model. As can be

seen, the program receives a vector and breaks it down into its different component values.

One of them, the flag, must be converted to a correct format. This value indicates to the

conditional block what action should be performed. The other values go to the different

actions. The output elements of the actions are grouped and sent to the channel.

RECEIVE (dt, dx, dy,

fx, fy, fz)

SEND (dt, dx, dy,

fx, fy, fz)

ACTION 0

ACTION 1

ACTION 2

ACTION 3

CONDITIONAL

ACTION 4

ACTION 5

(flag)

(dt, dx, dy, fx, fy, fz)

Page 63: Computational simulation of marine devices by coupled ...

47

Figure 29. Simulink general scheme.

Page 64: Computational simulation of marine devices by coupled ...

48

The most relevant blocks used to create the model are:

- TCP/IP Client Receive Block: This block receives data from the channel. The channel in

which the communication takes place has is configured in this block indicating the

remote address and the port. The data that is going to be received has to be also

defined.

- Demux: This block allows separating the data that arrives in the form of a vector in its

components.

- Data Type Conversion: This block transforms the value of the flag into a readable

format.

- Mux: Unlike the Demux block, this block allows recomposing the vector.

- If: This block allows entering the condition that imposes the flag value for the program

to perform the different actions.

- Merge: This block should be added whenever an If block is used.

- TCP/IP Client Send Block: The same configuration data as in the TCP/IP Client Receive

is entered in this block.

As mentioned previously, the actions that Simulink are the following Appendix C (p. 93):

- ACTION 0 – Initiate Problem: This action corresponds to the beginning of the program.

The value of the time increment, dt, is stored in the variable dt_.

- ACTION 1 – Start New Step: Simulink does not perform any task in this action.

- ACTION 2 – Start New Iteration: This action counts the iterations.

- ACTION 3 – Finish Iteration: In this action the forces are obtained from the

displacements.

- ACTION 4 – Finish Time Step: In this action iterations are initialized and time

increased.

- ACTION 5 – Finish Problem: The Stop block disconnects Simulink from the channel.

3.7.2 TCL script code

As mentioned above, the TCL code will follow the structure shown in Figure 20. To describe

the code it is going to be divided into three parts: procedures created specifically for this

project, procedures that are already created for SeaFEM and the main program. The code can

be found in the Appendix C (p. 93).

The procedures that were created for this project are:

- proc close_socket: in this procedure the communication channel is closed.

- proc accept_client_connection: in this procedure the buffer size of the channel is set.

The value 1 is also assigned to the connection variable to confirm that the connection

with the client has been successful.

- proc open_socket: In this procedure the socket is created and the channel where

communication between programs will take place is defined. The messages that you

want SeaFem to display on the screen will also be added to check that the process is

progressing correctly. Finally, the vwait command instructs the program to wait until

Page 65: Computational simulation of marine devices by coupled ...

49

the connection with the client is accepted. This was defined in the previous procedure.

This means that the moment we call the procedure accept_client_conection within

the creation of the socket, the program will stop until the variable connection takes

the value 1. Then SeaFem will display a message indicating that the connection was

established correctly and on which channel it will take place.

- proc send_data: In this procedure the data is sent.

- proc receive_data: In this procedure, the format for receiving the data is defined. In

this case it is a vector of 7 doubles (8 bytes).

Now the procedures that are previously defined in the SeaFem program are described.

proc TdynTcl_InitiateProblem

proc TdynTcl_StartNewStep

proc TdynTcl_StartNewIteration

proc TdynTcl_FinishIteration

proc TdynTcl_FinishStep

proc TdynTcl_FinishProblem

- proc TdynTcl_InitiateProblem (flag 0): This procedure opens the channel in which the

communication will take place by calling the procedure open_socket. Both programs,

Simulink and SeaFEM, connect to the channel. The vector (flag, dt, dx, dy, dz, fx, fy, fz)

is defined by adding the term func_.

The command [:: mather :: create_function waves" dx; "] assigns the values of

SeaFEM to the functions created before. The process is repeated with every function.

Page 66: Computational simulation of marine devices by coupled ...

50

Once SeaFem data is collected, it must be transformed to the appropriate format for

its correct reading. This data can already be sent to the channel.

Finally, the data in the channel is received and converted to a readable format.

- proc TdynTcl_StartNewStep (flag 1): For this project this procedure only sends and

receives data.

- proc TdynTcl_StartNewIteration (flag 2): This procedure sends the displacement

values from SeaFEM to the channel and receives the forces from the channel. Then

SeaFEM receives the instruction to apply the forces on the model.

o The values of the displacements in SeaFem will be evaluated using the

command :: mather :: evaluate_function $ func_dx. The process must be

repeated with every function.

o The data will be transformed to the format suitable for its correct reading and

sent to the channel.

o Data from the channel is received and transformed back to the original format.

o The TdynTcl_Set_Body_Loads command indicates SeaFEM to apply the forces

received from Simulink on the model.

Page 67: Computational simulation of marine devices by coupled ...

51

- proc TdynTcl_FinishStep (flag 4): For this project this procedure only sends and

receives data.

- proc TdynTcl_FinishProblem (flag 5): This procedure ends the communication process

(channel and server_socket) by calling the procedure close_socket. The last remaining

data is transformed to the correct format and sent to the channel.

3.8 Summary

In this chapter, the different steps followed to establish the communication between Simulink

and SeaFEM through a TCL script have been described. As shown in the

Figure 9, the programs have been connected to themselves, then, Simulink with a TCL script

and, finally, the desired communication have been established.

In order to facilitate the creation process of the communication interface between the two

programs making it more intuitive it has been applied to a general case that will be useful for

the following chapters. In this case, it has been considered that SeaFEM will apply a load on a

model. Simulink will calculate the load from the displacement, velocity and acceleration data

that SeaFEM will send in each time step. This process will be repeated until reaching the

selected simulation time. This process is illustrated in Figure 17.

As shown, one of the most important points for the interface design is to understand which

program and why should develop the client role and the server role. Since Simulink is already

preconfigured as a client this role has been assigned whereas SeaFEM would be the one

demanding information.

Once the roles have been assigned, the program that will define the structure and the

algorithm has been chosen. The conclusion has been that SeaFEM is the best option since, as

Page 68: Computational simulation of marine devices by coupled ...

52

mentioned previously, it offers the possibility of extending the functionalities by adding a TCL

script in the configuration of the program.

Among the procedures it offers, the following have been chosen:

- TdynTcl_InitiateProblem

- TdynTcl_StartNewStep

- TdynTcl_StartNewIteration

- TdynTcl_FinishIteration

- TdynTcl_FinishStep

- TdynTcl_FinishProblem

Hereafter, the diagrams from Figure 3 and Figure 5 have been taken as a basis and

complementary functioning schemes have been designed in Simulink and TCL following its

structure. Finally, the tasks developed in each procedure have been chosen and the programs

that can be found in the Appendix C (p. 93) created.

Page 69: Computational simulation of marine devices by coupled ...

53

Chapter 4 Program case: oscillating

water column device

4.1 Introduction

Once determined a general model to establish the connection between Simulink and SeaFEM

some modifications can be carried out to adapt it in different cases. In this chapter and in the

following one, two examples for future applications will be described. In this first case it will be

adapted to simulate an oscillating water column device. The intention is to obtain the

produced energy from the flux passing through the turbine.

4.2 Approach

As mentioned, in this situation Simulink will calcúlate the pressure due to the flux that

circulates through the cilinder and sends it to SeaFEM to be applied on the model. Figure 30

shows the general communication scheme.

Figure 30. Description of the data transfer between Simulink and SeaFEM.

4.3 Development

The development process description is divided in three parts that reference the three

involved files: TCL, Simulink and SeaFEM. The detailed explanation and the complete codes can

be found in the Appendix D (p. 107). As described in the previous chapter, the operations that

Simulink has to perform to obtain the pressure from the flux take place in the step Finish

Iteration.

Figure 31 shows a general communication scheme between TCL and Simulink. In each

procedure of the TCL script a different value is assigned to the flag and sent to Simulink.

Depending on that flag value Simulink is going to develop a different action. It can be noticed

that flag values 1 and 2 correspond to the time and iteration loops, respectively, from SeaFEM.

Pressure

Flux

SEAFEM SIMULINK

Page 70: Computational simulation of marine devices by coupled ...

54

Figure 31. Scheme of the general communication procedure between the Simulink and SeaFEM.

- Initiate Problem: The program begins in this step and corresponds to the flag value

0. The TCL develops the following tasks:

o Socket definition and opening

o Variables definition

o Functions creation (time and flux)

o Evaluate time function

o Send time and flag to Simulink

o Receive time from Simulink

Simulink receives the flag value and the time increase which is stored and sent

back to TCL. The relation between the tasks in the TCL script and the with the

Simulink actions is shown in Figure 32.

TdynTcl_InitiateProblem

TdynTcl_StartNewStep

TdynTcl_StartNewIteration

TdynTcl_FinishIteration

TdynTcl_FinishStep

TdynTcl_FinishProblem

RECEIVE

SEND

For (0: time)

[counts time]

RECEIVE

SEND

While (body_iterations)

[counts iterations]

RECEIVE

SEND

RECEIVE

OPERATIONS

SEND

RECEIVE

SEND

RECEIVE

END

START

FLAG 0

FLAG 1

FLAG 2

FLAG 3

FLAG 4

FLAG 5

TCL SIMULINK

Page 71: Computational simulation of marine devices by coupled ...

55

Figure 32. Scheme of the communication procedure between the Simulink and SeaFEM.

- Start New Step: In this section both, TCL and Simulink, send and receive data. This

section corresponds with flag value 1.

- Start New Iteration: TCL and Simulink send and receive data. Simulink counts

iterations and stores the value. This section corresponds with flag value 2.

RECEIVE

Time increase (dt)

is stored

SEND

FLAG 0

TCL SIMULINK

- Socket definition

- Variables definition

- Call procedure Open_Socket

….

- Functions creation (time and flux)

- Functions Evaluation (time)

- Convert and send data

- Recieve and convert data dt

Page 72: Computational simulation of marine devices by coupled ...

56

RECEIVE

Operations

SEND

FLAG 3, flux, dt

TCL SIMULINK

- Variables definition

….

- Functions Evaluation (flux)

- Convert and send data

- Recieve and convert data dt, pressure

- Finish Iteration: In this section that corresponds with flag value 3 the pressure is

obtained from the flux. Figure 33 shows the scheme of the succession of tasks that

Tcl and Simulink perform.

o TCL evaluates the flux received from SeaFEM.

o TCL sends the time increase, the flag value 3 and the flux to the channel.

o Simulink receives the flux from the channel and calculates the pressure.

o Simulink sends the pressure obtained to the channel.

o TCL receives the flux from the channel and sends it to SeaFEM.

o SeaFEM applies the pressure on the model.

Figure 33. Scheme of the general communication procedure between the Simulink and SeaFEM.

- Finish Time Step: In this section correspondent with flag value 4 both, TCL and

Simulink, send and receive data. Simulink counts time and stores the value. In this

step Simulink also initializes the iterations.

- Finish program: In this section correspondent with flag value 5 the communication

between programs ends.

Page 73: Computational simulation of marine devices by coupled ...

57

Chapter 5: Program case: fins effect on

a Wigley hull

5.1 Introduction

In this chapter, the modifications that have been carried out on the general coupling case

between Simulink and SeaFEM to adapt it to a one of the cases of interest in this project: to be

able to simulate the effect of the stabilizing fins on a Wigley hull. This allows illustrating an

application example of the program showing the points that should be modified.

5.2 Approach

In this situation the intention was to be able to simulate the behavior of stabilizing fin installed

on a Wigley hull. The general idea is that Simulink calculates the moment generated by the

stabilizing fins and sends it to SeaFEM to be applied on the model. For its part, SeaFEM should

send to Simulink the data necessary to calculate the moment. (See Figure 34).

Figure 34. Description of the data transfer between Simulink and SeaFEM.

Departing from the movement equation:

𝑎𝑑2𝜃

𝑑2𝑡2+ 𝑏

𝑑𝜃

𝑑𝑡+ 𝑐𝜃 = ∑ 𝑀

(5.1)

Where the first term represents the inertial moment, d2θ/d2t2 is the angular acceleration and

a is the inertial moment of the virtual mass around a longitudinal axis. The second term

represents the damping moment, dθ/dt the angular velocity and b the damping coefficient.

The third term cθ represents the restoring moment, θ is the angular amplitude and c is the

coefficient that makes the ship returns to the equilibrium position when the ship is displaced

from it (Patil, Chandra Dubey, & Anantha Subramanian, 2019)(P.G. Howlett, 2006).

, , 𝜃

Forces and moments

SEAFEM SIMULINK

Page 74: Computational simulation of marine devices by coupled ...

58

The movement equation can be written as:

𝐼 + 𝐵 + 𝐶𝜃 = ∑ 𝑀 (5.2)

In the case of a ship equipped with fins, considering the x-direction, the external moments are

the rolling moment MX and MF the moment due to the fins. The first one is solved by SeaFEM

and the second one by Simulink.

𝐼 + 𝐵 + 𝐶𝜃 = 𝑀𝑥 + 𝑀𝐹

Figure 35. Parts of the movement equation solved by Simulink and SeaFEM.

Figure 35 shows the communication process scheme. SeaFEM will send the angular amplitude,

velocity and acceleration to Simulink that will use these data to obtain a fin moment. This

moment will be sent back to SeaFEM that will apply it to the ship and obtain new angular

values to send to Simulink.

5.3 Development

As in the previous chapter, the explanation is divided in three parts that reference the three

involved files: TCL, Simulin and SeaFEM. The detailed explanation and the complete codes can

be found in the Appendix E (p. 113).

5.3.1 Modifications on the TCL script

This scenario is more complicated than the previous since in this one the intention is to send

displacements, velocities and accelerations and receive forces and moments. Thus, all of them

should be defined in the script and added in the places where the data transference takes

place.

5.3.2 Modifications on Simulink

As in the TCL script, the new data that Simulink is going to use in its calculus should be defined.

The convenient iterative moment for Simulink to calculate the moment produced by the

stabilizing fins is in the Finish Iteration as shown in Figure 36. In this point SeaFEM will have

finished its intern calculus obtaining new displacement, velocity and acceleration values of the

correspondent time step and will be prepared to receive new forces and moments to apply to

the model. Figure 37 shows the extraction of the velocities and loads needed.

SeaFEM Simulink

Page 75: Computational simulation of marine devices by coupled ...

59

Figure 36. Simulink general scheme.

Page 76: Computational simulation of marine devices by coupled ...

60

Figure 37. Simulink Finish Iteration subsystem.

5.3.3 Modifications on SeaFEM

The unique modification on SeaFEM is indicating the program the external forces or moments

to be applied on the model. In this case, the fins generate a moment in the x-direction, Mx. It

must be indicated as mx_tcl.

Dem

ux

Div

ides

vel

oci

ties

an

d

mo

men

ts in

co

mp

on

ents

Sub

syst

em

Intr

od

uce

fu

nct

ion

s h

ere

Page 77: Computational simulation of marine devices by coupled ...

61

PART II: VERIFICATION

Page 78: Computational simulation of marine devices by coupled ...

62

Page 79: Computational simulation of marine devices by coupled ...

63

Chapter 6: Analysis of an oscillating

water column device

6.1 Introduction

In Chapter 3 (p. 37), the adaptation process of a general communication model between

SeaFEM and Simulink to a case which intention was to know the power obtained in an

oscillating water column device was described. Thus, in this chapter the application on a model

is described and the obtained results, verified.

6.2 Oscillating water column description

Inexhaustible and trustworthy, wave power has long been considered as one of the most

promising renewable energy sources. Wave Energy Converters (WECs) convert wave power

into electricity.

Figure 38. Scheme of the oscillating water columns (OWCs) operating system.

The functioning of the oscillating water columns (OWCs) is very similar to that of a wind

turbine, being based on the principle of wave induced air pressurization. The device is set upon

a closed air chamber, which is placed above the water. The passage of waves changes the

water level within the closed housing and the rising and falling water level increases and

decreases the air pressure within the housing introducing a bidirectional air flow. By placing a

turbine on top of this chamber air will pass in and out of it with the changing air pressure

levels. There are two options to separate the bidirectional flow: alternatively, pressure

Page 80: Computational simulation of marine devices by coupled ...

64

generating valves or, as in this case, a Wells turbine to create suction. The process is described

in Figure 38.

An Oscillating Water Column (OWC) is a wave energy converter consisting of a partially

submerged chamber with an air column over the water column. The work done by the air

column under excitation by the incident waves is used to generate electrical energy through a

power take-off (PTO) device. The air column is under pressure due to the damping from the

PTO device and this pressure is essential for the extraction of wave energy using the OWC. The

relationship between the PTO damping and the hydrodynamic efficiency of the OWC provides

more insight into the wave energy extraction using an OWC.

6.3 Turbine model

In this case, a wells type turbine is considered. The pressure, p (KPa), can be obtained from

the flux, Q (m3/s), by the following expression3:

𝑝 =𝑄|𝑄|

0,078072

(6.1)

The power generated in the OWC, P (Kw) can be obtained from the pressure from the

following expression:

𝑃 = −0,0051 (|𝑝

1000|)

3

+ 0,2815 (|𝑝

1000|)

2

+ 1,1857 |𝑝

1000|

(6.2)

6.4 Model description

The geometry of the model is shown in Figure 39. A cylinder of 6 meters of diameter and 2,5

meters draft has been created. A wave damping zone of 10 meters of draft and starting 7

meters away from the OWC and extended until a diameter of 60 meters has also been created.

3 The expressions to obtain the pressure and the power have been obtained experimentally from the

curve of a Well turbine test.

Figure 39. Isometric view of the computational domain (Length in meters).

Page 81: Computational simulation of marine devices by coupled ...

65

The mesh size of the OWC is 0,2 meters and 0,5 for the volume near field as shown in the

Figure 40. That results in a mesh of 45849 nodes and 267133 elements.

Figure 40. Mesh scheme.

For this simulation monochromatic waves of 1 meter amplitude and 4 s period have been

considered. The simulation time is 10 seconds.

Amplitude (s) 1

Period (s) 4

Heading (0) 45

Table 5. Wave data. OWC.

This model will be used for both cases, only using SeaFEM and using the communication

interface. For the first one in which only SeaFEM is used the equation to obtain the pressure is

introduced in the P Free Surface section. In the second one Simulink obtains the pressure from

the flux received from SeaFEM. Then the TCL Data is activated.

6.5 Verification case: produced power

To verify that the created model works correctly, firstly the OWC has been simulated

introducing directly the function for obtaining the pressure from the flux in SeaFEM. Then, the

simulation has been carried out again but, in this case, Simulink has calculated the pressure to

send it to SeaFEM. The following graphics show the pressure and power obtained in both tests.

As it can be observed, the results coincide verifying the correct functioning of the simulations.

Page 82: Computational simulation of marine devices by coupled ...

66

Figure 41. Pressure in the OWC.

Figure 42. Power produced in the OWC.

-800000

-600000

-400000

-200000

0

200000

400000

600000

0 2 4 6 8 10 12

Pre

sure

(kP

a)

Time (s)

SeaFEM

SeaFEM+Simulink

-1600000

-1400000

-1200000

-1000000

-800000

-600000

-400000

-200000

0

200000

0 2 4 6 8 10 12

Po

we

r (k

W)

Time (s)

SeaFEM

SeaFEM+Simulink

Page 83: Computational simulation of marine devices by coupled ...

67

Chapter 7. Fins effect control algorithm

7.1 Introduction

The intention of this section is to develop and incorporate a simple control element in Simulink that simulates the effect of the fins reducing the roll of the ship. The following sea situations have been considered for that purpose:

- Sea without waves. - Irregular sea.

The decreasing of the roll has been compared for each one of the previous sea situations in the following cases:

- Ship without fins. - Fixed fins. - Active fins.

The fins model used and is also described in this chapter. The verification method followed to prove the correct functioning of the program and the demonstrations can be found in the Appendix F (p. 126).

7.2 Fins model

Fin stabilizers are stability equipment used onboard ships to reduce the roll motion that causes

a decrease of ship's performances and operability. The sea waves produce a perturbation to

the hull, then the stabilizer fins placed on the opposite lateral surfaces of the ship, provide a

torque in contrast to the roll ship (See Figure 43) (Perez & Blanke, 2014).

Page 84: Computational simulation of marine devices by coupled ...

68

Figure 43. Principles of roll reduction by fin stabilizer.(Kawazoe, Nishikido, & Wada, 1993)

When the water flows around the fins the zones of high and low pressure are created on their

surfaces, thus generating a force perpendicular to the fin surface S. This force can be divided

into two components: the lift, L, directed perpendicular to the horizon line and the drag, D

(Liang, Sun, Shi, & Luan, 2017).

𝐿 =1

2𝑆𝜌𝑉𝑠

2𝐶𝐿(𝛼) (7.1)

𝐷 =1

2𝑆𝜌𝑉𝑠

2𝐶𝐷(𝛼) (7.2)

Lift and drag coefficients can be obtained depending on the attack angle:

𝐶𝐿(𝛼) =𝑑𝐶𝐿

𝑑𝛼=

1.8𝜋𝛼𝐸

1.8 + √𝛼𝐸2 + 4

(7.3)

𝐶𝐷(𝛼) = 𝐶𝐷0 +𝐶𝐿

2(𝛼)

0.9𝜋𝛬 (7.4)

Where CD0=0.0065 and Λ is the ratio of aspect.

Page 85: Computational simulation of marine devices by coupled ...

69

Figure 44. Localizing active fins on ship hull and stabilizing fin angles. (Rahimuddin, Maimun, & Gani, 2014)(Kula, 2015)

Figure 44 shows the directions of lift and drag forces (Kim & Kim, 2011). The directions of force

and moment due to the fin are determined by the direction of incoming fluid flow to the lifting

surface. Assuming only a forward ship speed, U = (VS, 0, 0), the velocity vector and angle of

incoming flow to the fin, the effective angle of attack αE, can be written as:

𝑉 = (𝑉𝑥 , 𝑉𝑧) (7.5)

and

𝛼𝐸 = 𝛼𝐹 + 𝛼𝑃 (7.6)

𝛼𝑃 = 𝑎𝑟𝑐𝑡𝑎𝑛 (𝑟𝑓𝑤𝑥

𝑉𝑆) (7.7)

Figure 45. Directions of lift force and drag force.(Kim & Kim, 2011)

Page 86: Computational simulation of marine devices by coupled ...

70

Figure 46. Fin-induced forces and moments.(Lihua, Peng, Songtao, Ming, & Jia, 2018)

Case 1: Ship without fins

This is the simplest case in which no external forces are applied on the ship. For the simulation

the following damping moment has been considered:

𝑀𝑥 = 0.05𝑤𝑋√4𝐾44𝐼𝑥𝑥 (7.8)

To include the effect of physical damping due to the effects of viscosity, the value commonly

used value of 5% of the critical damping has been considered.

Case 2: Fixed fins

Assuming initially that the fin is fixed on the hull and that has been horizontally installed (angle

of the fin, αF= 00), the instantaneous angle of attack of the fin (αE) is the pitch angle (αP).

𝛼𝐸 = 𝛼𝑃 + 𝛼𝐹 (7.9)

𝛼𝐹 = 0 ; 𝛼𝐸 = 𝛼𝑃 (7.10)

Being Vs the velocity of the current in the x-direction, wx the roll angular velocity and yp the

rolling arm (See Figure 46), the vertical velocity induced by the roll is:

𝑉𝑧−𝑓𝑖𝑛 = 𝑤𝑥𝑦𝑝 (7.11)

Thus, the velocity of the fluid respect to a system of reference located in the fin will be (Vs, -

Vz_fin).

𝛼𝐸 = 𝛼𝑃 = arctan (−𝑉𝑧−𝑓𝑖𝑛

𝑉𝑆) = arctan (−

𝑤𝑥𝑦𝑝

𝑉𝑠) (7.12)

In this way, when the ship begins to move in roll, an angle of attack and a relative velocity of

the instantaneous fluid will appear generating a vertical force Fz_fin and a moment that will

dampen the roll.

Page 87: Computational simulation of marine devices by coupled ...

71

𝑀𝑥 = 𝐹𝑧−𝑠𝑡𝑎𝑟𝑏𝑜𝑎𝑟𝑑𝑦𝑝−𝑠𝑡𝑎𝑟𝑏𝑜𝑎𝑟𝑑 + 𝐹𝑧−𝑝𝑜𝑟𝑡𝑦𝑝−𝑝𝑜𝑟𝑡 (7.13)

The functions previously described have been introduced in the Simulink program as shown in

the Figure 47.

Figure 47. Simulink scheme. Fixed fins.

Case 3: Active fins

In this case, the intention has been to obtain an algorithm able to reduce the roll more that in

the previous case having the 00 fixed fins. An option that has been considered is to create an

algorithm that modifies the angle of the fin depending of the ship rolling velocity and

acceleration. Furthermore, the angle of the fin should not exceed an angle of +-100.

A simple function could be considering that the angle of the fin is proportional to the rolling

angular velocity.

𝛼𝐹 =𝐹𝑤𝑥

Ω𝑥 ; Ω𝑥 =

2𝜋

𝑇𝑟𝑜𝑙𝑙

(7.14)

Where Troll is the fundamental period of the ship and F is a factor to calibrate.

Figure 48 shows the resultant scheme in Simulink once the previous functions are added.

Page 88: Computational simulation of marine devices by coupled ...

72

Figure 48. Simulink scheme. Active fins.

7.3 Environment and computational domain

The stabilizing fins are installed on a Wigley type hull (see Figure 49) of length L = 100 m and

breadth B = 10 m with a forward speed Vs=6,263 m/s. The vertical center of gravity is located

at ZG=-1.2 m resulting in a natural roll period, Troll=12s (see Figure 51).

Figure 49. Wigley hull model.

An unstructured mesh has been generated. Figure 50 shows the generated mesh that consists

of 128744 nodes and 748333 elements.

Page 89: Computational simulation of marine devices by coupled ...

73

Figure 50. Wigley hull generated mesh.

The following cases have been carried out for 100s. The wave parameters considered in each

case are described in the following sections.

7.4 Case: Fins effect in a sea without waves

In this case an extinction test with an initial tilt Rx=50rad has been simulated. As mentioned,

no waves have been considered. Figure 51, Figure 52 and Figure 53 show a significant

decreasing in the roll movement, velocity and acceleration, respectively due to the fins effect.

Figure 51. Roll movement. Fins effect in a sea without waves.

-0.1

-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

0.06

0.08

0.1

0 20 40 60 80 100

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Active fins

Without fins

Fixed fins

Page 90: Computational simulation of marine devices by coupled ...

74

Figure 52. Roll velocity. Fins effect in a sea without waves.

Figure 53. Roll acceleration. Fins effect in a sea without waves.

7.5 Case: Fins effect in irregular sea

In this case, an irregular sea situation has been considered. A Jonswap spectrum has been

selected to define the irregular waves (See Appendix A (p. 81)). The wave data are summarized

in the Table 6.

Wave data

Wave spectrum type Jonswap

Mean wave period (s) 12

Significant wave height (m) 2

Shortest period (s) 5

-0.05

-0.04

-0.03

-0.02

-0.01

0

0.01

0.02

0.03

0.04

0 20 40 60 80 100

Ro

ll ve

loci

ty (

rad

/s)

Time (s)

Active fins

Without fins

Fixed fins

-0.03

-0.025

-0.02

-0.015

-0.01

-0.005

0

0.005

0.01

0.015

0.02

0.025

0 20 40 60 80 100

Ro

ll ac

cele

rati

on

(ra

d/s

2 )

Time (s)

Active fins

Without fins

Fixed fins

Page 91: Computational simulation of marine devices by coupled ...

75

Longest period (s) 26

Number of waves periods 15

Mean wave heading (0) 90

Spreading angle (0) 60

Number of waves headings 5

Table 6. Wave data. Fins analysis on irregular sea.

As in the previous section, considered forward speed is Vs=6,263 m/s and the three following

cases have been compared: ship without fins, fixed fins and active fins.

Figure 54 shows the effect of the different fins cases on the roll movement. As expected, the

active fins stabilize the ship having a significant impact on the decreasing of the roll

movement. The roll velocity and acceleration also experiment a decrease due to the fins action

as shown in Figure 55 and Figure 56.

Figure 54. Roll movement. Fins effect in irregular sea.

-0.15

-0.1

-0.05

0

0.05

0.1

0.15

0 20 40 60 80 100

Ro

ll M

ove

me

nt

(rad

)

Time (s)

Active Fins

No Fins

Fixed Fins

Page 92: Computational simulation of marine devices by coupled ...

76

Figure 55. Roll velocity. Fins effect in irregular sea.

Figure 56. Roll acceleration. Fins effect in irregular sea.

-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

0.06

0.08

0 20 40 60 80 100

Ro

ll V

elo

city

(ra

d/s

)

Time (s)

Active Fins

No Fins

Fixed Fins

-0.04

-0.03

-0.02

-0.01

0

0.01

0.02

0.03

0.04

0 20 40 60 80 100

Ro

ll A

cce

lera

tio

n (

rad

/s2 )

Time (s)

Active Fins

No Fins

Fixed Fins

Page 93: Computational simulation of marine devices by coupled ...

77

Chapter 8: Conclusions

The objective of this Master’s thesis was to develop a communication interface between two

programs, Simulink and SeaFEM, to allow the simulation of complex loads adding a control

algorithm. This proposal takes advantage of the facilities that Simulink offers, thanks to the

Instrument Control Toolbox that allows communicating through a TCP/IP protocol, and the TCL

extension included in SeaFEM that brings the possibility of enlarging its functionalities. Thus,

the programs communicate through a TCL code script.

As mentioned during the project, the process would be the following. There is a model created

in SeaFEM and we want to simulate the effect of some loads acting on it. As the loads are

described by a complex function that cannot be introduced directly in SeaFEM they will be

introduced in Simulink that offers this functionality. The data that Simulink needs to solve the

operations come from the internal solver loops of SeaFEM. The loads obtained in Simulink are

sent to SeaFEM that applies them on the model. This process repeats until simulation time is

reached.

For developing the definitive interface several tests have been carried out communicating

firstly the programs with themselves and, later, between them. Some examples to verify the

correct functioning have been presented in this work.

Once it has been possible to transfer data between both programs, the interface has been

applied to simulate two different cases: an oscillating water column (OWC) device and the

stabilizing fins installed on a Wigley type hull. The intention was to verify the correct data

transfer in the first case and the possibility of introducing a control algorithm in the second

case.

The OWC case tried to simulate the effect of a flux through the device turbine obtaining the

applied pressure and the produced power. To verify the functioning it has been tested two

times: introducing the pressure from the flux function directly on SeaFEM and using the

communication interface. The obtained graphics (see Figure 41) show that the simulation

worked as expected.

For the stabilizing fins, three cases have been tested in two different sea conditions making a

total of six situations. The three cases included the ship sailing freely without the fins, the ship

equipped with fixed fins and the ship equipped with active fins using a control algorithm.

These cases have been tested. As it was expected, the fins have a significant impact on the

decrease of the roll movement as shown in Figure 51 and Figure 54 . The results obtained have

been verified introducing a fins effect approximate function directly on SeaFEM.

Page 94: Computational simulation of marine devices by coupled ...

78

It is possible to consider a fins effect approximate function from the movement equation and the results obtained in the simulation coupling both programs. As it has been described in

detail in Chapter7(p.125), SeaFEM solves the dynamics equation, and evaluates the

moment due to the inertia, damping and restoring loads acting on the ship and Simulink calculates the external loads. From the results with the coupling system, the roll damping constant can be easily obtained as the slope of the curve of roll moment and roll velocity.

In this project, it has been demonstrated the possibility of enlarging the functionalities of a

program by a coupling system. Furthermore, the capability of introducing control algorithms

acting on the external loads allows obtaining more realistic simulations.

Page 95: Computational simulation of marine devices by coupled ...

79

APPENDICES

Page 96: Computational simulation of marine devices by coupled ...

80

Page 97: Computational simulation of marine devices by coupled ...

81

Appendix A: Previous concepts

A.1 Introduction

This annex aims to offer some complementary information for a better understanding of the

simulations carried out in the project. The two different tests that have been simulated in the

project are described in this section: rolling test and extinction test. Additionally, the selected

wave spectrum considered to define the irregular sea is described.

A.2 Rolling tests

Rolling test: The ship model is located in a transversal position respect to the longitudinal

direction of the towing tank. Initially, the ship is in its equilibrium position. After, an external

force is applied on the model allowing the model to oscillate.

On the other hand, the extinction test can be described: The model is located in a transversal

position respect to the longitudinal direction of the towing tank and it is obligated (by an

external force) to reach an initial tilt, Rx. After, the model is left to oscillate freely.

A.3 Wave spectrums

The present status of computer facilities prevents from using certain techniques to obtain

statistical estimates for ocean waves, since the estimated CPU-time makes direct calculations

unrealistic. In addition, there are unsolved physical problems associated with modelling of

breaking waves. In practice, linear theory is used to simulate irregular sea and to obtain

statistical estimates (Faltinsen, 1993). The wave elevation of a long-crested irregular sea

propagating along the positive axis can be written as the sum of a large number of wave

components:

𝜁 = ∑ 𝐴𝑗sin (𝑤𝑗 − 𝑘𝑗𝑥 + 𝜖𝑗)

𝑁

𝑗=1

(A.1)

Here, 𝑨𝒋, 𝒘𝒋and 𝝐𝒋 mean respectively the wave amplitude, circular frequency, wave number

and random phase angle of wave component number j. The random phase angles are

uniformly distributed between 0 and 2π.The wave amplitude can be expressed by a wave

spectrum S (w) (Newman, 1979).

1

2𝐴𝑗

2 = 𝑆(𝑤𝑗)∆𝑤 (A.2)

where ∆𝒘 is a constant difference between successive frequencies.

Page 98: Computational simulation of marine devices by coupled ...

82

To define the irregular sea, SeaFEM includes the following wave spectra types:

- Pearson Moskowitz spectrum: for open sea conditions the 15th ITTC recommended the

use of this spectrum. It is obtained assuming fully developed sea state (Serván Camas,

2016).

𝑆(𝑤)

𝐻13

2 𝑇1

=0.11

2𝜋(

𝑤𝑇1

2𝜋)

−5

𝑒𝑥𝑝 [−0.44 (𝑤𝑇1

2𝜋)

−4

] (A.3)

Where 𝑯𝟏

𝟑

is the significant wave height defined as the mean of the one third highest

waves and 𝑻𝟏 is mean wave period.

- Jonswap and Jonswap2 spectrum: this spectrum stands for Joint North Sea Wave

Project and it is a peak-enhanced Pierson-Moskovitz spectrum. The 17th ITTC

recommended this spectrum for limited fetch (SeaFEM Theory Manual, n.d.).

155𝐻13

2

𝑇14𝑤5

𝑒𝑥𝑝 (−944

𝑇14𝑤4

) (3.3)𝑌 (A.4)

Where

𝑌 = exp (− (0.191𝑇1 − 1

212𝜎

)

2

)

and

𝜎 = 0.07 𝑓𝑜𝑟 𝑤 ≤ 5.24/ 𝑇1

𝜎 = 0.09 𝑓𝑜𝑟 𝑤 > 5.24/ 𝑇1

- White noise: introduce a number of waves with periods uniformly distributed across

an interval, and with same amplitude and direction. This spectrum is used to carry out

response amplitude operator (RAO) analyses.

Page 99: Computational simulation of marine devices by coupled ...

83

Appendix B: Simulink blocks

description

B.1 Introduction

In this annex, a detailed description of the Control Instrument Toolbox blocs used for this

project is given (Instrument Control Toolbox 2 User ’s Guide, n.d.).

B.2 TCP/IP Client Send block

Figure 57: Block TCP/IP Client Send.

The TCP/IP Send block (see Figure 57) sends data from the model to remote machines using

the TCP/IP protocol. This data is sent at the end of the simulation or at fixed intervals during a

simulation.

As it is shown in the image, the TCP/IP Send block only has one input port. The size of the input

port is dynamic and inherited from the driving block.

In order to configure the block there are several parameters that the user can modify:

- Remote address: Specify the IP address, name, or the Web server address of the

machine to which send data. This field is empty by default.

- Port: Specify the remote port on the host you need to send the data to. The default

port value is 80. Valid port values are 1 to 65535.

- Verify address and port connectivity: If this button is activated it allows to:

o Check if the specified remote address is correct.

o Establish connection with the specified remote address and port.

Page 100: Computational simulation of marine devices by coupled ...

84

- Byte order: Specify the instrument's byte order for the data when using binary or

binblock format with more than 8 bits. The options that it offers

are BigEndian or LittleEndian.

- Enable blocking mode: Specify if the user wants to block the simulation while sending

data. This option is selected by default. If this option is not selected the write

operation will not block the simulation.

B.3 TCP/IP Client Receive block

Figure 58: Block TCP/IP Client Receive

This block is used to receive data over TCP/IP from specified remote machine.

The TCP/IP Receive block configures and opens an interface to a specified remote address

using the TCP/IP protocol. The configuration and initialization occur once at the start of the

model's execution. During the model's run time, the block acquires data either in blocking

mode or nonblocking mode.

On the opposite of the TCP/IP Send block, and to complement it, this block has no input ports

and it has either one or two output ports, based on the selection of blocking or nonblocking

mode.

If the blocking mode is selected the block will have one output port corresponding to the data

it receives.

Figure 59: Block TCP/IP Client Receive with Blocking mode activated

If the block is not selected, it will have two output ports, the Data port and the Status port.

Figure 60: Block TCP/IP Client Receive Blocking mode not activated

Page 101: Computational simulation of marine devices by coupled ...

85

A First In First Out (FIFO) buffer 4receives the data. At every time step, the Data port outputs

the requested values from the buffer. In Nonblocking mode, the Status port indicates if the

block has received new data.

Figure 61. Representation of a FIFO (queue) with enqueue and dequeue operations.

As in the TCP/IP Send block, this block also allows to modify some parameters to configure it.

- Remote address: Enter the IP address, name, or the Web server address of the

machine from which you need to receive data. This field is empty by default.

- Port: Enter the remote port on the remote machine you need to connect to. The

default port value is 80. Valid port values are 1 to 65535.

- Verify address and port connectivity: This option must be activated in order to:

o Check if the specified remote address is correct.

o Establish connection with the specified remote address and port.

- Data size: Specify the output data size, or the number of values that should be read at

every simulation time step. The default size is [1 1].

- Source Data type: Specify the input data type to receive from the block.

- ASCII format string: It defines the format string for the data. This option is only

available ASCII data type is selected.

- Terminator: this option is only available when ASCII data type is selected. It can be

used to set a terminator5 for the data read.

4 FIFO is an acronym for first in, first out, a method for organising and manipulating a data buffer, where

the oldest (first) entry, or 'head' of the queue, is processed first. It is analogous to processing a queue with first-come, first-served (FCFS) behaviour: where the people leave the queue in the order in which they arrive. Figure 12 shows a representation of a FIFO method. 5 The Terminator block can be used to cap blocks whose output ports are not connected to other blocks.

If you run a simulation with blocks having unconnected output ports, Simulink issues warning messages. Using Terminator blocks to cap those blocks avoids warning messages.

Page 102: Computational simulation of marine devices by coupled ...

86

- Byte order: When using binary or binblock format with more than 8 bits, you can

specify the instrument's byte order for the data. Your options are BigEndian or

LittleEndian.

- Enable blocking mode: this option, selected by default, specifies if the simulation will

be blocked while receiving data. If this option is not selected the read operation will

not block the simulation.

If the blocking mode is enabled, the model will block the simulation while it is waiting for the

requested data to be available. When it is not enabled blocking mode, the simulation runs

continuously. The block has two output ports, Status and Data. The Data port contains the

requested set of data at each time step. The Status port contains 0 or 1 based on whether it

received new data at the given time step. The following diagrams show the difference

between receiving data using blocking mode and nonblocking mode.

B.4 Mux and Demux

Mux block: This block combines inputs with the same data type and complexity into a vector

output. The output mux signal is flat, even if you create the mux signal from other mux signals.

However, you can use multiple Mux blocks to create a mux signal in stages.

A mux signal simplifies the visual appearance of a model by combining two or more signal lines

into one line. Mux signals do not affect simulation or code generation.

Figure 62. Mux block.

Demux: The Demux block extracts the components of an input vector signal and outputs

separate signals. The output signal ports are ordered from top to bottom.

Figure 63. Demux block.

Page 103: Computational simulation of marine devices by coupled ...

87

Appendix C: Communication interface

development

C.1 Introduction

This annex contains the complete codes and files used for the different communications

between programs.

C.2 TCL to TCL communication

Client code

Sets the channel.

This loop will run until socket is closed.

Asks the user for a message.

Flushes any output buffered for

channelId .

Collects data and saves it in msg.

Page 104: Computational simulation of marine devices by coupled ...

88

Server code

C.3 Simulink TCL communication

Simulink client configuration

Figure 64. Simulink client configuration.

For each of the blocks, the parameters set by default must be modified.

- TCP/IP Client Receive: The remote address and port must be indicated in the data

reception block. For this example, a port that is known to be available has been

chosen. Since two data are received, it must be indicated as a vector [1 2].

This loop is related to vwait. It

will iterate until vwait condition.

Collects data from the channel

and saves it in clientMsg variable.

Program starts here. Opens the

socket and executes the

procedure Recieve_Data.

Indicates that the while loop will

run forever. It will keep waiting

for the client message.

Configures the channel.

Page 105: Computational simulation of marine devices by coupled ...

89

The desired format must also be indicated. In this case, double Data Type and

LittleEndian byte order.

The Enable blocking mode option has to be selected.

Figure 65: Block parameters TCP/IP Receive

- TCP/IP Client Send: In the data sending block the Remote address and the Port must

match those previously indicated in the receiving block.

The same Byte order and Timeout must also be maintained. The Enable blocking

mode option has to be activated and the Transfer Delay option deactivated.

Figure 66: Block parameters TCP/IP Send

Page 106: Computational simulation of marine devices by coupled ...

90

- Data Type Conversion: This block indicates that which format to read. In this case an

int64 format has to be selected.

Figure 67: Block parameters Data Type Conversion

Page 107: Computational simulation of marine devices by coupled ...

91

TCL server code

Close communication

Channel configuration

vwait waits until

connection is stablished

(value 1 is assigned to

connection).

Calls the procedure proc

accept_client_connection

If connection is stablished value 1 is

assigned to connection otherwise, if it takes

too long to connect, an error message

appears.

Defines the size of the

data that is going to

receive from the channel

Sends data to the

channel

Page 108: Computational simulation of marine devices by coupled ...

92

Channel definition

Operations

Data type conversion.

Send data to the channel

Get data from the

channel and convert the

data type

End of the communication. Close channel and socket by

calling the procedure proc close_socket

Page 109: Computational simulation of marine devices by coupled ...

93

C.4 Simulink to SeaFEM Communication

General scheme

Page 110: Computational simulation of marine devices by coupled ...

94

Simulink client configuration

Next, starting from the explanations of the different blocks that have been given previously, it

will be explained in detail how each one has been configured.

Figure 68: Simulink general scheme

Page 111: Computational simulation of marine devices by coupled ...

95

TCP/IP Client Receive Block: In this block the Remote Address (127.0.0.1) and the Port (9901)

are defined. A seven component double vector is also defined indicating the Byte order

LittleEndian.

Figure 69: Block Parameters TCP/IP Receive

Demux: This block allows separating the data that arrives in the form of a vector in its seven

components to be able to work with each of them separately.

Figure 70: Block Parameters Demux

Page 112: Computational simulation of marine devices by coupled ...

96

Data Type Conversion: As it has been done in the TCL script, it is necessary to transform the

value of the flag into a value of type int32.

Figure 71: Block Parameters Data Type Conversion

Mux: Unlike the Demux block, this block allows you to recompose the vector from the

remaining six components to work with them more easily.

If: This block allows entering the condition that imposes the flag value for the program to

perform one or another action. The expression "if" is u1 == 0 and the Elseif expressions are u1

== 1, u1 == 2 and u1 == 3.

Figure 72: Block Parameters If

Page 113: Computational simulation of marine devices by coupled ...

97

Merge: This block should be added whenever an If block is used to join the conditional results

at the input into a single output signal.

Figure 73: Block Parameters Merge

TCP/IP Client Send Block: The same configuration data as in the TCP / IP Client Receive is

defined in this block.

Figure 74: Block Parameters TCP/IP Send

Page 114: Computational simulation of marine devices by coupled ...

98

The different actions that Simulink must execute are described below.

ACTION 0 – INITIATE PROBLEM: This action corresponds to the beginning of the program. The

vector composed by the six remaining components enters on the input. A Demux block is used

to split the vector to store the time increment, dt, in the variable dt_. A Mux block is used to

recompose the vector.

Figure 75. Action 0 - Initiate Problem

ACTION 1 – START NEW STEP: Simulink does not perform any task in this action. The data

vector enters on the block by input 1 and exits by output 1.

Figure 76. Action 1 - Start New Step

Page 115: Computational simulation of marine devices by coupled ...

99

ACTION 2 – Start New Iteration: This action counts the iterations. Iterations are saved on a

Data Store block named “iterations_”. Any changes are made on the data vector. It enters on

the block by input 1 and exits by output 1.

Figure 77. Action 2 - Start New Iteration

ACTION 3 – Finish Iteration: In this action the forces are obtained from the displacements. The

data vector enters in the block on input 1. In the Subsystem block named “OPERATIONS” the

user will have to introduce the operations required to obtain the forces from the

displacements. The resulting vector with the calculated forces exits the block on output 1.

Figure 78. Action 3 - Finish Iteration

ACTION 4 – Finish Time Step: In this action iterations are initialized and time increased. The

time increment, dt, stored in Action 0 is used here to count the time step saved in a data store

named “time_”. Iterations are initialized by saving a value 0 on the “iterations_” data store.

Page 116: Computational simulation of marine devices by coupled ...

100

Figure 79. Action 4 - Finish Time Step

ACTION 5 – Finish Problem: The Stop Simulation block disconnects Simulink from the channel.

The Stop Simulation block stops the simulation when the input is nonzero, in this case value 1

is assigned to the block.

Figure 80. Action 5 - Finish Problem

TCL server code

Page 117: Computational simulation of marine devices by coupled ...

101

Close communication

Channel configuration

vwait waits until

connection is stablished

(value 1 is assigned to

connection).

Calls the procedure proc

accept_client_connection

If connection is stablished value 1 is

assigned to connection otherwise, if it takes

too long to connect, an error message

appears.

Defines the size of the

data that is going to

receive from the channel

Sends data to the

channel

Page 118: Computational simulation of marine devices by coupled ...

102

Channel definition

Functions definition

Functions creation

dt function creation. Get

the value from SeaFEM

Data type

conversion. Send

data to the

channel

Get data from the

channel and convert the

data type

Start Communication

Flag Value assignment

Page 119: Computational simulation of marine devices by coupled ...

103

Channel and functions

definition

Data type

conversion.

Send data to

the channel

Get data from the

channel and convert the

data type

Flag Value assignment

Channel and functions

definition

Data type

conversion

Send data

to the

channel

Get data from the

channel and convert the

data type

Flag Value assignment

Channel and functions

definition

Flag Value assignement

Page 120: Computational simulation of marine devices by coupled ...

104

Channel and functions

definition

Data type

conversion.

Send data to

the channel

Get data from the

channel and convert the

data type

Flag Value assignment

Channel and functions

definition

Data type

conversion.

Send data to

the channel

Get data from the

channel and convert the

data type

Flag Value assignment

Page 121: Computational simulation of marine devices by coupled ...

105

Channel and functions

definition

Data type

conversion.

Send data to

the channel

Communication ending

Flag Value assignment

Page 122: Computational simulation of marine devices by coupled ...

106

Page 123: Computational simulation of marine devices by coupled ...

107

Appendix D: OWC codes

D.1 Introduction

This annex contains the complete codes used for the OWC simulation. These codes allow to

obtain the power from the flux through the turbine.

D.2 TCL code

Close communication

Channel configuration

vwait waits until

connection is stablished

(value 1 is assigned to

connection).

Calls the procedure proc

accept_client_connection

If connection is stablished value 1 is

assigned to connection otherwise, if it takes

too long to connect, an error message

appears.

Defines the size of the

data that is going to

receive from the channel

Sends data to the

channel

Page 124: Computational simulation of marine devices by coupled ...

108

Channel and functions

definitions

Start Communication and

Flag Value assignment

dt function creation. Get

the value from SeaFEM

Functions creation

Data type conversion.

Send data to the channel

Get data from the

channel and convert the

data type

Channel and functions

definition. Flag

assignement.

Function evaluation

Data type conversion.

Send data to the channel

Get data from the

channel and convert the

data type

Apply pressure

Channel definition and

flag assignment.

Data type conversion.

Send to the channel

Get data from the

channel and convert type

Page 125: Computational simulation of marine devices by coupled ...

109

Channel definition and

flag assignment.

Data type conversion.

Send to the channel

Get data from the

channel and convert type

Channel definition and

flag assignment.

Data type conversion.

Send to the channel

Get data from the

channel and convert type

Channel definition and

flag assignment.

Data type conversion.

Send to the channel

Communication ending

Page 126: Computational simulation of marine devices by coupled ...

110

D.3 Simulink file description

Figure 81. Simulink general scheme. OWC.

Page 127: Computational simulation of marine devices by coupled ...

111

Figure 82. Simulink subsystem: Finish iteration. OWC.

Figure 83. Simulink subsystem: Finish iteration. Pressure calculation subsystem. OWC.

Page 128: Computational simulation of marine devices by coupled ...

112

Figure 84. Simulink subsystem: Finish iteration. Pressure calculation. OWC.

Page 129: Computational simulation of marine devices by coupled ...

113

Appendix E: Fins effect control

E.1 Introduction

The codes used to simulate the control acting on the stabilizing fin son a Wigley hull are

detailed in this annex.

E.2 TCL code

Close communication

Channel configuration

vwait waits until

connection is stablished

(value 1 is assigned to

connection).

Calls the procedure proc

accept_client_connection

If connection is stablished value 1 is

assigned to connection otherwise, if it takes

too long to connect, an error message

appears.

Defines the size of the

data that is going to

receive from the channel

Sends data to the

channel

Page 130: Computational simulation of marine devices by coupled ...

114

dt function creation. Get

the value from SeaFEM

Functions creation

Functions evaluation

Channel and functions

definitions

Start Communication and

Flag Value assignment

Variables definition

Page 131: Computational simulation of marine devices by coupled ...

115

Channel definition and

flag value assignment

Variables definition

Data type

conversion.

Send data to

the channel

Get data

from the

channel

and convert

type

Functions evaluation

Page 132: Computational simulation of marine devices by coupled ...

116

Data type

conversion.

Send data to

the channel

Get data

from the

channel

and convert

type

Functions definition

Channel definition and

flag value assignment

Variables definition

Functions definition

Page 133: Computational simulation of marine devices by coupled ...

117

Functions definition

Type

conversion.

Send data

to channel

Get data from

the channel

and convert

type

Apply loads on

SeaFEM

Channel definition and

flag value assignment

Variables definition

Page 134: Computational simulation of marine devices by coupled ...

118

Functions definition

Type

conversion.

Send data

to channel

Get data from

the channel

and convert

type

Channel definition and

flag value assignment

Variables definition

Functions definition

Page 135: Computational simulation of marine devices by coupled ...

119

Type

conversion.

Send data

to channel

Get data from

the channel

and convert

type

Channel definition and

flag value assignment

Variables definition

Page 136: Computational simulation of marine devices by coupled ...

120

Functions definition

Communication ending

Type

conversion.

Send data

to channel

Page 137: Computational simulation of marine devices by coupled ...

121

E.3 Simulink file description

Figure 85. Simulink general scheme. Active fins installed on a Wigley hull.

Page 138: Computational simulation of marine devices by coupled ...

122

Figure 86. Start New Iteration. Active fins installed on a Wigley hull.

Page 139: Computational simulation of marine devices by coupled ...

123

Figure 87. Operations subsystem. Active fins installed on a Wigley hull.

Page 140: Computational simulation of marine devices by coupled ...

124

Page 141: Computational simulation of marine devices by coupled ...

125

Appendix F: Fins effect control

verification

In order to verify the correct functioning of the communication between both programs and

the Simulink control element, the three aforementioned cases have been solved introducing

an analogue function as an external force in SeaFEM.

Considering the movement equation for a ship with fins previously described in Chapter 5

(p.57):

𝐼 + 𝐵 + 𝐶𝜃 = 𝑀𝑥 + 𝑀𝐹 (E.1)

the fin moment, MF, can be translated as a damping moment:

𝑀𝐹 = 𝑏𝐹 𝑑𝜃

𝑑𝑡

(E.2)

When the fins are installed on the ship it moves as a damped harmonic oscillator. Thus, the roll

moment, Mx, can be rewritten as a damping moment:

𝑀𝑥 = −𝑐𝑡𝑒 ∗ 𝑤𝑥 (E.3)

Thus, in this case the way to verify that the coupling between programs is correct is to enter

this equation in SeaFEM as an external moment and verify that a similar result is obtained.

In order to be able to introduce the equation in SeaFEM it will be necessary to know the value

of the constant. This value can be obtained as the slope of the Mx-wx curve. Then, once the

calculation of the moment of balance of a ship with fins has been carried out by coupling

Simulink and SeaFEM, the values of angular speed wx and roll moment Mx can be extracted

and represented in a curve as shown in the next Figure 88.

Page 142: Computational simulation of marine devices by coupled ...

126

Figure 88. General roll moment and angular roll velocity curve.

The following sections describe two verification cases considering two different sea situations:

with waves and without waves. The environment conditions are described in Chapter 7 (p.72).

F.1 Verification case: Sea without waves

A sea situation without waves or currents has been selected to begin the verifications since it

is the simplest scenario. In the following cases a roll extinction test has been simulated by

introducing an initial tilt, Rx = 50.

Case 1: Ship without fins

As previously mentioned in this case a damping external moment has been considered and

introduced in Simulink. Figure 89 shows the rolling movement obtained.

Figure 89. Roll movement. Ship without fins. Sea without waves.

-40000

-20000

0

20000

40000

60000

80000

100000

120000

-0.015 -0.01 -0.005 0 0.005

Mx

(Nm

)

Wx (rad/s)

-0.1

-0.05

0

0.05

0.1

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Page 143: Computational simulation of marine devices by coupled ...

127

Case 2: Fixed Fins

The obtained rolling movement for the ship equipped with fixed fins is shown in Figure 90.

Figure 90. Roll movement. Fixed fins. Sea without waves.

The result obtained has been verified comparing it with the one obtained considering the slope

of the curve of rolling moment and angular velocity shown in Figure 91. The equation

introduced in SeaFEM for the verification is:

𝑴𝒙 = −𝟐. 𝟎𝟒𝟕. 𝟏𝟓𝟒, 𝟑𝟒 𝒘𝒙

Figure 91. Curve Mx-wx. Fixed fins. Sea without waves.

The obtained graphic of rolling movement of Figure 92 shows the same behavior as the

previous graphic obtained coupling the two programs. As shown, due to the fixed fins, the

rolling moment is considerably reduced.

-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

0.06

0.08

0.1

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

-40000

-30000

-20000

-10000

0

10000

20000

30000

40000

50000

-0.03 -0.02 -0.01 0 0.01 0.02

Mx

wx

Page 144: Computational simulation of marine devices by coupled ...

128

Figure 92. Roll movement. Fixed fins. Sea without waves. Verification.

Case 3: Active Fins

In this case the control algorithm has been tested. Figure 93 shows that the active fins have a

higher impact on the decreasing of the roll movement.

Figure 93. Roll movement. Active fins. Sea without waves.

The result obtained has been verified comparing it with the one obtained considering the slope

of the curve of rolling moment and angular velocity shown in Figure 94. The equation

introduced in SeaFEM for the verification is:

𝑴𝒙 = −𝟕. 𝟗𝟕𝟕. 𝟎𝟒𝟑, 𝟕𝟖 𝒘𝒙

-0.1

-0.05

0

0.05

0.1

0 10 20 30 40 50 60R

oll

mo

vem

en

t (r

ad)

Time (s)

-0.02

0

0.02

0.04

0.06

0.08

0.1

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Page 145: Computational simulation of marine devices by coupled ...

129

Figure 94. Mx-wx curve. Active fins. Sea without waves.

The obtained graphic of rolling movement of figure shows the same behavior as the previous

graphic obtained coupling the two programs.

Figure 95. Roll movement. Active fins. Sea without waves. Verification.

F.2 Verification case: Sea with waves

Following the same procedure of the previous verification case, the three cases have been

tested for the new sea conditions. In this situation a lateral monochromatic wave of 24,5 s of

period and 0,5 m of amplitude has been considered.

Table 7. Waves data. Sea with waves.

Amplitude (m) 0,5

Period (s) 24,5

Heading (0) 90

The situation simulated is a rolling test. For that reason the initial tilt, Rx, is set to 0.

-40000

-20000

0

20000

40000

60000

80000

100000

120000

-0.015 -0.01 -0.005 0 0.005M

x

wx

-0.04

-0.02

0

0.02

0.04

0.06

0.08

0.1

0 10 20 30 40 50 60Ro

ll m

ove

me

nt

(rad

)

Time (s)

Page 146: Computational simulation of marine devices by coupled ...

130

Case 1: Ship without fins

As previously mentioned in this case a damping external moment has been considered and

introduced in Simulink. Figure 96 shows the rolling movement obtained.

Figure 96. Roll movement. Ship without fins. Sea with waves.

Case 2: Fixed Fins

The obtained rolling movement for the ship equipped with fixed fins is shown in Figure 97.

Figure 97. Roll movement. Fixed fins. Sea with waves.

The result obtained has been verified comparing it with the one obtained considering the slope

of the curve of rolling moment and angular velocity shown in Figure 98. The equation

introduced in SeaFEM for the verification is:

𝑴𝒙 = −𝟐. 𝟎𝟓𝟐. 𝟎𝟗𝟒, 𝟏𝟗𝒘𝒙

-0.1

-0.05

0

0.05

0.1

0.15

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

-0.015

-0.01

-0.005

0

0.005

0.01

0.015

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Page 147: Computational simulation of marine devices by coupled ...

131

-40000

-20000

0

20000

40000

60000

80000

100000

-0.06 -0.04 -0.02 0 0.02

Mx

(Nm

)

Wx (rad/s)

Figure 98. Mx-wx curve. Active fins. Sea with waves.

The obtained graphic of rolling movement of Figure 99 shows the same behavior as the

previous graphic obtained coupling the two programs. As shown, due to the fixed fins, the

rolling moment is considerably reduced.

Figure 99. Roll movement. Fixed fins. Sea with waves. Verification.

-0.08

-0.06

-0.04

-0.02

0

0.02

0.04

0.06

0.08

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Page 148: Computational simulation of marine devices by coupled ...

132

Case 3: Active Fins

In this case the control algorithm has been tested. Figure 100 shows that the active fins have a

higher impact on the decreasing of the roll movement.

Figure 100. Roll movement. Active fins. Sea with waves.

The result obtained has been verified comparing it with the one obtained considering the slope

of the curve of rolling moment and angular velocity shown in Figure 101. The equation

introduced in SeaFEM for the verification is:

𝑴𝒙 = −𝟖. 𝟎𝟎𝟓. 𝟔𝟎𝟕, 𝟐𝟕 𝒘𝒙

Figure 101. Roll movement. Active fins. Sea with waves. Verification.

The obtained graphic of rolling movement of Figure 102 shows the same behavior as the

previous graphic obtained coupling the two programs.

-0.006

-0.004

-0.002

0

0.002

0.004

0.006

0 10 20 30 40 50 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

-150000

-100000

-50000

0

50000

100000

150000

200000

250000

300000

-0.04 -0.03 -0.02 -0.01 0 0.01 0.02

Mx

(Nm

)

wx (rad/s)

Page 149: Computational simulation of marine devices by coupled ...

133

Figure 102. Roll movement. Active fins. Sea with waves. Verification.

F.3 Summary

The intention of this section was to verify the correct functioning of the coupling between

SeaFEM and Simulink and the control algorithm of the fins. In order to do that the following

sea situations have been considered:

- Sea without waves.

- Sea with waves.

For each situation three different cases have been simulated:

- Ship without fins.

- Ship with fixed fins.

- Ship with active fins.

To verify that the obtained results are correct other simulations have been carried out

introducing in SeaFEM an analogue fins effect function. As shown in the previous section, the

obtained results with the verification method match with the results obtained coupling

Simulink and SeaFEM.

Furthermore, the following figures show the decreasing in the roll movement due to the fins

effect in each sea situation demonstrating the correct functioning of the program. The active

fins have a major impact on the damping of the roll.

-0.03

-0.02

-0.01

0

0.01

0.02

0.03

0 10 20 30 40 50 60R

oll

mo

vem

en

t (r

ad)

Time (s)

Page 150: Computational simulation of marine devices by coupled ...

134

Figure 103. Roll movement comparison for the three considered cases. Sea without waves.

Figure 104. Roll movement comparison for the three considered cases. Sea with waves.

-0.1

-0.05

0

0.05

0.1

0 20 40 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Active fins

Fixed fins

Without fins

-0.1

-0.05

0

0.05

0.1

0 20 40 60

Ro

ll m

ove

me

nt

(rad

)

Time (s)

Active fins

Fixed fins

Without fins

Page 151: Computational simulation of marine devices by coupled ...

135

References

Faltinsen, O. M. (1993). Sea loads on ships and offshore structures (C. U. Press, ed.). Cambridge.

Instrument Control Toolbox 2 User ’s Guide. (n.d.).

Kawazoe, T., Nishikido, S., & Wada, Y. (1993). Effect of Fin Area and Contorol Methods on Reduction of Rool Motion with Fin Stabilizers. Journal of the Marine Engineering Society in Japan, 28(4), 279–285. https://doi.org/10.5988/jime1966.28.279

Kim, J. H., & Kim, Y. H. (2011). Motion control of a cruise ship by using active stabilizing fins. Proceedings of the Institution of Mechanical Engineers Part M: Journal of Engineering for the Maritime Environment, 225(4), 311–324. https://doi.org/10.1177/1475090211421268

Kula, K. S. (2015). An Overview of Roll Stabilizers and Systems for Their Control. TransNav, the International Journal on Marine Navigation and Safety of Sea Transportation, 9(3), 405–414. https://doi.org/10.12716/1001.09.03.14

Liang, L., Sun, M., Shi, H., & Luan, T. (2017). Design and analyze a new measuring lift device for fin stabilizers using stiffness matrix of Euler-Bernoulli beam. PLoS ONE, 12(1), 1–22. https://doi.org/10.1371/journal.pone.0168972

Lihua, L., Peng, Z., Songtao, Z., Ming, J., & Jia, Y. (2018). Simulation analysis of fin stabilizer on ship roll control during turning motion. Ocean Engineering, 164(June), 733–748. https://doi.org/10.1016/j.oceaneng.2018.07.015

Newman, J. N. (1979). The Theory of Ship Motions. In Advances in Applied Mechanics (Vol. 18). https://doi.org/10.1016/S0065-2156(08)70268-0

P.G. Howlett, P. J. P. (2006). Advances in Industrial Control. https://doi.org/10.1007/978-3-319-08413-8

Patil, N. S., Chandra Dubey, A., & Anantha Subramanian, V. (2019). Fin based active control for ship roll motion stabilization. MATEC Web of Conferences, 272, 01026. https://doi.org/10.1051/matecconf/201927201026

Perez, T., & Blanke, M. (2014). Control of Ship Roll Motion. Encyclopedia of Systems and Control, 1–8. https://doi.org/10.1007/978-1-4471-5102-9_123-1

Rahimuddin, Maimun, A., & Gani, P. A. (2014). Application of fuzzy logic controller to enhance the semi-SWATH performance in following seas. Jurnal Teknologi (Sciences and Engineering), 69(7), 17–25. https://doi.org/10.11113/jt.v69.3261

SeaFEM Theory Manual. (n.d.).

Serván Camas, B. (2016). A time-domain finite element method for seakeeping and wave resistance problems. (10.20868/UPM.thesis.39794). https://doi.org/10.20868/UPM.thesis.39794

Sysel, M. (2009). TCP/IP OUTPUT FROM THE SIMULINK. 634–637.

Page 152: Computational simulation of marine devices by coupled ...

136