1+ %% Mooring Module Example
2+ % In this example, we'll explore the functionalities of the Mooring module of
3+ % the Marine and Hydrokinetic Toolkit (MHKiT). As of now, this module primarily
4+ % supports output from MoorDyn, an innovative tool for simulating the complex
5+ % dynamics of mooring lines used in marine applications.
6+ %
7+ % The objective will be to analyze the MoorDyn output data of a single mooring
8+ % line. The steps are:
9+ %%
10+ % # *Import Data* - Import the MoorDyn output
11+ % # *Lay Length* - Calculate the lay length parameter
12+ % # *Visualize* - Create graphical animations
13+ % Importing Data
14+ % The first step is to import the MoorDyn output file. This file contains the
15+ % key data that we'll be analyzing throughout this notebook. If support for other
16+ % types of output is desired, please raise an issue or reach out to the MHKiT
17+ % team!
18+ %
19+ % The code below provides paths to two files:
20+ %%
21+ % * |fpath| = MoorDyn output file of a single mooring line containing node positions
22+ % and segment tensions
23+ % * |inputfile| = Path to MoorDyn input file that corresponds to the output.
24+ % This is an optional argument which parses the input parameters and writes them
25+ % a struct for reference. Note: the input file provided here does not match the
26+ % output and is only meant for demonstration purposes.
27+
28+ % define the paths
29+ fpath = " ./examples/data/mooring/line1_test.out" ;
30+ inputfile = " ./examples/data/mooring/TestInput.MD.dat" ;
31+ % load in data
32+ [data , input ] = read_moordyn(fpath , inputfile )
33+ % Calculating the Lay Length with MoorDyn Data
34+ % Next, we turn our focus to calculating the 'lay length'. Lay length is the
35+ % measure of how much of the mooring line is in contact with the seabed.
36+ %
37+ % To calculate the lay length, we'll use the MoorDyn output data we imported
38+ % in the previous step. We also need to define two key parameters:
39+ %%
40+ % * The |depth| of the seabed, which we've set as -56m for this example. Please
41+ % note that the seabed depth is considered negative as we're measuring downwards
42+ % from the sea level.
43+ % * The |tolerance|, or the threshold, for determining when a node is deemed
44+ % to be in contact with the seabed. For this exercise, we'll use a tolerance of
45+ % 0.25m. The selection of a suitable tolerance value depends on various factors
46+ % including the resolution of your data and the specifics of your application.
47+ %%
48+ % We use the |lay_length| function for this calculation, which will yield an
49+ % array representing the lay length of the mooring line at each time step. Let's
50+ % execute the function:
51+
52+ depth = - 56 ; % meters
53+ tolerance = 0.25 ; % meters
54+ laylength = lay_length(data , - 56 , 0.25 )
55+ %%
56+ % Additionally we can use this information to get an average lay length for
57+ % the whole time period.
58+
59+ fprintf(' The average lay length of the mooring line is: %.1f meters' , mean(laylength ))
60+ % Visualizing Mooring Line Dynamics with Graphics
61+ % After calculating the lay length, let's progress to the final step of our
62+ % journey: visualization. The mooring module within MHKiT provides tools to create
63+ % interactive, informative graphics that can help us visualize and better understand
64+ % the behavior of the mooring line.
65+ %
66+ % However, to keep things performance-friendly, we will first slice our initial
67+ % data down to a 10-second window. This reduces computational demand while still
68+ % providing a useful snapshot of our mooring line's dynamics.
69+ %
70+ % With our data subset ready, we can create a 3D animation of the mooring line
71+ % using the |plot_mooring_animate|.
72+
73+ plot_mooring_animate(data(data .Time < 10, : ), ' 3D' , 0.05 , ...
74+ ' xlabel' ,' X-axis' ,' ylabel' ,' Y-axis' ,' zlabel' ,' depth' ,' title' ,' 3D example' )
75+ %%
76+ % In this simplified example, the mooring line is constrained from moving along
77+ % the y-axis. Since there is no motion along the y-axis, it would actually be
78+ % easier to view the animation in 2D instead. This can be accomplished with the
79+ % |plot_mooring_animate| function specifying dimension=|'2D'|.
80+
81+ plot_mooring_animate(data(data .Time < 10, : ), ' 2D' , 0.05 , ...
82+ ' xlabel' ,' X-axis' ,' ylabel' ,' depth [m]' ,' title' ,' 2D example' )
83+ %%
84+ % Through these graphical representations, we can gain a more intuitive understanding
85+ % of how the mooring line interacts with the surrounding marine environment over
86+ % time.
87+ % Summary and Conclusion
88+ % In this notebook, we walked through the MHKiT Mooring module learning how
89+ % to utilize MHKiT in conjunction with MoorDyn output to analyze the dynamics
90+ % of a single mooring line.
91+ %
92+ % We used the |read_moordyn| function to bring this data into Matlab, preparing
93+ % it for further analysis. Next, we calculated the 'lay length' of our mooring
94+ % line using the |lay_length| function, obtaining an array representing the lay
95+ % length at each time step. Finally, we visualized 2D and 3D animations of the
96+ % mooring line's behavior over a 10-second period using the |plot_mooring_animate|
97+ % function.
98+ %
99+ % We hope that this example serves as a valuable guide to employing the MHKiT
100+ % Mooring module and MoorDyn analyses.
101+ %
102+ % Thank you for your interest in MHKiT! We encourage you to continue to open
103+ % an issue or pull request if you have any feedback or expansions which would
104+ % help you improve your mooring data analysis.
0 commit comments