Wec-Sim/Mooring Model Issue

Hi All,

I am trying to run a WEC-Sim model with MoorDyn with a water depth of 3.7m. This is specified in the point section, with the anchor at 3.7m, and water depth of 3.7m as well. Attached is the lines.txt. This is also specified in Wec-Sim.

However, when running the model, I keep getting that the node 0 position is [0,0,0], when it seems like it should be the anchor point at [0,0,-3.7]. Weirdly, the node 25 position is at [0,0,-0.1] (which is the correct specified coupling location with Body1).


Does anyone know how I could troubleshoot this? Or if this is a MoorDyn initialization issue or perhaps something to do with the way I set it up in WEC-Sim? Any help is appreciated, thanks!

Best,
Elaine

Hi @Elaine.Liu,

I ran that input file on MoorDyn-C and saw nans as well, but with node 0 at the correct depth:

I reduced the MoorDyn internal timestep to 0.000001 and was able to get the simulation to run (though it was slower than realtime). I was also able to get it to run with a 0.00001 timestep, the Rk4 time integration scheme, and only 10 segments. I would suggest playing with a smaller segment count, a shorter internal timestep, and other integration schemes to see what you can get to run the fastest. A quick way to check this without running an entire WECSim simulation would be to run a simple loop with the body fixed in place. The following python code should work for your single coupled body:

import moordyn
import numpy as np

# Create the MoorDyn system from the input file
system = moordyn.Create("<file name>")

# You can get the initial positions and velocities from the system itself using the MoorDyn-C API
body = moordyn.GetBody(system, 1)
state = moordyn.GetBodyState(body) # tuple with (x, xd)

x = np.array(state[0]) # x, y, z, roll, pitch, yaw 
xd = np.array(state[1]) # xdot, ydot, zdot, roll_dot, pitch_dot, yaw_dot 

# Setup the initial condition
moordyn.Init(system, x, xd)

# Set the simulation time
t, dt = 0.0, 0.5

# Run the simulation for five timesteps
for i in range(5):
    f = moordyn.Step(system, x, xd, t, dt)
    t += dt
    x += xd * dt # update the position 

# Alright, time to finish!
moordyn.Close(system)

Hi Ryan,
Thanks for the help! This worked now!

Best,
Elaine

1 Like

Hi All,

I am trying to simulate the OC3 spar in WEC-SIM with the MoorDyn-C, and my code and model :

%% Body Data
body(1) = bodyClass(bodyFile);
body(1).geometryFile = 'geometry/Spar_OC3_mm.stl';
body(1).mass = 7.46633E+06; % 7.46633E+06
body(1).inertia = [4229230000 4229230000 164230000];

B_linear = zeros(6);
B_linear(1,1) = 1.0e5;  % Surge
B_linear(2,2) = 1.0e5;  % Sway
B_linear(3,3) = 1.3e5;  % Heave
B_linear(6,6) = 1.3e7;  % Yaw
body(1).linearDamping = B_linear;

%% PTO and Constraint Parameters
% Floating (6DOF) Joint
constraint(1) = constraintClass('Constraint1'); 
constraint(1).location = [0 0 0];     
                       
%% Mooring
% Moordyn
mooring(1) = mooringClass('mooring');       	             % Initialize mooringClass
mooring(1).moorDyn = 1;
mooring(1).moorDynLines = 3;                	             % Specify number of lines
mooring(1).moorDynNodes = [20 20 20];       	             % Specify number of nodes per line
mooring(1).location = [0.0 0.0 -70.0];

mooring(1).moorDynInputFile = 'Mooring/lines_v2.txt';        % Specify MoorDyn input file path"

and the “lines_v2.txt” is

--------------------- MoorDyn Input File ------------------------------------
Mooring system for OC3-Hywind
----------------------- LINE TYPES ------------------------------------------
Name     Diam      MassDen       EA    BA/-zeta    EI    Cd      Ca     CdAx   CaAx
(-)       (m)      (kg/m)        (N)    (N-s/-)    (-)   (-)     (-)    (-)    (-)
main     0.09      77.7066   384.243E6  -0.8       0.0   1.6     1.0    0.1    0.0
---------------------- POINTS --------------------------------
ID     Attachment  X        Y         Z      M      V    CdA   CA
(-)     (-)      (m)      (m)      (m)     (kg)  (m^3) (m^2)  (-)
1      fixed    853.87     0.0    -320.0    0     0      0     0
2      fixed   -426.94   739.47   -320.0    0     0      0     0
3      fixed   -426.94  -739.47   -320.0    0     0      0     0
4      vessel     5.2      0.0     -70.0    0     0      0     0
5      vessel    -2.6      4.5     -70.0    0     0      0     0
6      vessel    -2.6     -4.5     -70.0    0     0      0     0
---------------------- LINES --------------------------------------
ID      LineType   AttachA   AttachB  UnstrLen  NumSegs   Outputs
(-)       (-)        (-)       (-)       (m)       (-)      (-)
1         main       1         4        902.2      20        tp
2         main       2         5        902.2      20        tp
3         main       3         6        902.2      20        tp
---------------------- SOLVER OPTIONS ---------------------------------------
2             writeLog      Write a log file
rk4          tscheme       2nd order Runge-Kutta
0.0001         dtM           time step to use in mooring integration (s)
3.0e6         kBot          bottom stiffness (Pa/m)
3.0e5         cBot          bottom damping (Pa-s/m)
1025.0        WtrDnsty      water density (kg/m^3)
320           WtrDpth       water depth (m)
20.0           dtIC          time interval for analyzing convergence during IC gen (s)
100.0         TmaxIC        max time for ic gen (s)
3.0           CdScaleIC     factor by which to scale drag coefficients during dynamic relaxation (-)
0.0001         threshIC      threshold for IC convergence (-)
1       disableOutTime
------------------------ OUTPUTS --------------------------------------------
FairTen1
FairTen2
FairTen3
AnchTen1
AnchTen2
AnchTen3
------------------------- need this line --------------------------------------

But, every time I ran the Simulink, the mooring line initialization would give the wrong coordinates of coupled points 4, 5, and 6. Then, if I run the simulation, MATLAB crashed and gave the following crash report. But when I try the same “lines_v2.txt” in Python like @Ryan.Davies suggested, there are no errors.


Does anyone know how I could troubleshoot this? Any help is appreciated. Thanks in advance!

Best,
Chaozhi Qiu

Hi @Chaozhi.Qiu,

This is because MoorDyn is only set up with WECSim to have a 6 DOF coupling via a coupled body. In your case you are using three coupled points instead (type vessel). Check out MoorDyn/example/Running WECSim with MoorDyn.pdf at dev · FloatingArrayDesign/MoorDyn · GitHub for WECSim instructions and 3-lines with Body Simple Example in MoorDyn/example/MoorDyn_standalone_demo.ipynb at dev · FloatingArrayDesign/MoorDyn · GitHub for an example of an input file using a 6 DOF coupling.

Hi, @Ryan.Davies,
Thank you very much for the reply.
It works. Thanks.

Best,
Chaozhi Qiu

1 Like