Appendix B: Modelling

1. Transfer functions - roll, pitch and yaw

In RIFLEX vessel roll, pitch and yaw are given as rotation per wave slope; i.e. dimensionless. If values are available as rotation per meter or foot of wave height, a conversion must be performed.

1.1. Conversion example:

1.2. Linux script for conversion of rao values:

##! /usr/bin/awk -f

##

##  Expects input as:    freq(rad/s)  trf(rad/m)     phase

##  and gives output as: freq(rad/s)  trf(rad/rad)   phase

##

##  Waterdepth may be given on the command line;

##      convert_trf 'd=100.0' <infile>

##

BEGIN { d = 310.0; g = 9.81}

  NF  { w = $1; i = 0;
          k0 = 0.0; k1 = w*w/g;

##       print i, k1;
        while ( (k1-k0) > 0.00005 || (k0-k1) > 0.00005 )
           { i++;
             k0   = k1;
             x    = k0*d;
             tanh = 1.0;
             if (x < 50.) tanh = (exp(x)-exp(-x))/(exp(x)+exp(-x))
             k1   = w*w/(g*tanh);

##            print i, k1
           }
        print $1,$2/k1,$3
      }

2. Example MATLAB script to generate a 3D seafloor grid

The MATLAB scripts iFundi.m and seafloor.m may be used to generate a regular spaced grid of 3D seafloor data. seafloor.m includes the set of (x,y,z) coordinates that define the 3D seafloor.

2.1. iFundi.m

%
%                                   iFundi
%                                   ______
%
% MATLAB script that generates a RIFLEX seafloor input file, on the basis of
% column based data.
%
% This script is a basis, which is expected to be modified by the user when needed.
%
% Philippe Maincon, MARINTEK, 28/6/2000
%
clear                                                % Clear MATLAB's memory, to
                                                     % avoid surprises
% Read the seafloor data

seafloor;                                            % call the script in file
                                                     % seafloor.m, which defines 3
                                                     % vectors x,y and z, of same
                                                     % size.

% Define the grid to be generated

Xsmin = 540;                                         % define the grid to be
DGX   = .5;                                          % generated
Xsmax = 650;                                         % x values on the grid to be
Ysmin = 80;                                          % between Xsmin and Xsmax, with
DGY   = .5;                                          % step DGX
Ysmax = 140;

% Create the interpolated grid

[b,a]=meshgrid(Ysmin:DGY:Ysmax,Xsmin:DGX:Xsmax);     % for the purpose of
                                                     % interpolation, generate the
                                                     % matrices a and b of x and y
                                                     % data respectively, for each
                                                     % point of the grid.
                                                     % DO NOT switch a and b, x and
                                                     % y. !!!
c=griddata(x,y,z,a,b,'linear');                      % interpolate z data to grid c

% Plot the result - for feedback to the user


figure(1); clf; hold on;axis equal;
mesh(a,b,c);                                         % plot the interpolated grid as
                                                     % a "mesh"
plot3(x,y,z,'k.','markersize',3);                    % plot the original data as
                                                     % black dots
grid;                                                % put a grid as background to
                                                     % the plot

% Write the RIFLEX seafloor input file

depth=round(c*100);
[NGX,NGY]=size(depth)
fnut=char(39);zero=0

file=fopen('bottom.rif','w');                        % You can change the name of
                                                     % the file here
fprintf(file,'%s\n','Sample seabed profile');        % the syntax here is that of
                                                     % C language
fprintf(file,'%s %s\n',fnut,'NGX NGY Xsmin Xsmax Ysmin Ysmax DGX DGY');
% Mind that a RIFLEX input file is never to have more than 80 columns...
fprintf(file,'%4d %4d %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n',...
              NGX,NGY,Xsmin,Xsmax,Ysmin,Ysmax,DGX,  DGY);
fprintf(file,'%s %s\n',fnut,'XOS YOS ANGOL');
fprintf(file,'%8.2f %8.2f %8.2f\n',zero,zero,zero);
fprintf(file,'%s %s\n',fnut,'Depth of seabed [ul*100]');
for col = 1:NGY
   for lin =1:NGX-1
      fprintf(file,'%8d %s\n',depth(lin,col),'&');
   end
   fprintf(file,'%8d \n',depth(NGX,col));
end
fclose(file);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2.2. seafloor.m

tmp=[  46318.500     62176.000    -134.0976
   46319.500     62176.000    -134.0722
   46320.500     62176.000    -134.0749
   46321.500     62176.000    -134.0644
.
..
.

46427.125 62283.000 -126.0274 46428.125 62283.000 -125.9467];

x = tmp(:,1)-tmp(1,1); y = tmp(:,2)-tmp(1,2); z = tmp(:,3); clear tmp;
r1 = x<400; r2 = x>400;