Hydrostat Exercises 2D&3D
Hydrostat Exercises 2D&3D
Hydrostat Exercises 2D&3D
Tutorial in Matlab
Version 7
JAKOB KUTTENKEULER
This tutorial contains a set of exercises designed guide through the implementation,
validation and verification of numerical hydrostatic calculations in the Matlab environment.
The exercises guides the active reader though the basic implementation of sections and the
numerical representation to analyze hydrostatic properties through to similar calculations on
the full 3D hull. The exercises are in sequential order so that the reader simply starts at the
beginning and work through the exercises.
The code is supposed to form the foundation on which special tailored analysis of equilibrium
of flotation can be build. As an example, all rule-based assessment of the stability is left out
but can easily be included.
through
2D Sections
The first step is to handle two-dimensional (2D) sections. By 2D section we here mean a
slice of the hull where no changes in properties occurs in the x-direction. We can thus in the
2D world express the hull as a cross section geometry and maybe a scalar value for the xextension. No pitch is thus considered here.
Fundamental calculations
We start by defining an example section to practice on before attacking a more complex hull.
For simplicity we use a rectangular section. The term section here refers to a length-wise
portion of a hull with assumed constant geometry. This means that all sections are treated as
prismatic with nicely cut front and back edges all in the y-z-plane. The code below defines the
section geometry completely where our assumption is that all offset-points (also called
nodes) are in the same y-z plane, i.e. having the same x coordinate.
offsets
Exercise 1. Plot the section with dots at the offset-points and lines in between. Hint:
You can modify the prepared script plot_section.m if you like.
Exercise 2. Heel your section by use of the function heel_offsets (which you write)
which rotates your section offsets around the x-axis. Your call of the
function shall look like this:
heeled_offsets = heel_offsets(offsets,heel)
Hint: A simple matrix multiplication does the job pretty easily. Note: Make
sure that the rotation is done in the correct direction. A positive heel angle
will turn the ship clockwise when looking from behind. Plot your heeled
section. This is what I get when I heel the section +15.
Exercise 3. Compute and cut the submerged (wet) part of your section by using
the prepared function cut_wet_section which also have the
parameter zwl which defines the z-coordinate of the water surface. Your
call shall look like this
wet_offsets
= cut_wet_section(heeled_offsets,zwl)
Plot your wet section in the same plot as your heeled section. Hint: the
command hold on might be useful. In short, the function
Exercise 4. Calculate the center of buoyancy CB and wet area Aw for the
submerged part of your section by using the prepared functions as shown
here:
CB_global
= polygonCentroid(wet_offsets)
Aw
= abs(polygonArea(wet_offsets))
Note that polygonArea calcs the signed area!! Read the script header.
I get CB=[-0.2079, -0.4749] and Aw=4.4141.
Exercise 5. Add the position of CB to your plot.
Exercise 6. Verify CB and AW. Play around with the powerful tool you just created
and e.g. verify that you get the same results as I do:
Case
Heel
Zwl
CB y/z
Aw
2
[deg]
[m]
[m]
[m ]
1
0
0.0
0.0000/-0.5000
4.0000
2
5
0.1
-0.0668/-0.4527
4.4015
3
10
-0.1
-0.1661/-0.5651
3.5938
4
15
0.0
-0.2281/-0.5292
4.0000
Exercise 7. Are there any limitations regarding the heel angle or are you capable of
calculating the hydrostatics for all heel angles [- to ]?
Exercise 8. Investigate how your code reacts inputs where the waterline is at
extreme values, i.e. when your section is 100% out of water and 100%
submerged. Does everything work?
Exercise 9. Verify that the center of buoyancy CB is calculated correctly for
various combinations of zwl and heel.
offsets = [-2.0,
-1.7.
0.0,
1.7,
2.0,
1.5
0.5
0.0
0.5
1.5];
Play around and get confident with your search for zwl. I get that the
equilibrium zwl for the V-shaped section with m=3000kg, heel=10 and
dL=2.0m is zwl= 0.6656m, do you agree? Do not forget to plot!
Transverse stability
So far we have been studying the single degree of freedom of vertical equilibrium, the heel
has been locked. Now we (you that is :-) will add the degree of freedom of heel in the
calculations. As we add a degree of freedom in the model we need to also add an equation to
solve the problem. This new equation is naturally the issue of transverse stability. Transverse
stability can be expressed as the restoring (rightning) moment created by the transverse
distance between the two forces active. All you need to do to is thus to keep track of the
center of buoyancy (CB which you already have in your code) and center of gravity (CG) of
the section itself actually dead simple. Just remember that the center of gravity moves
when section is rotated. In your main program do the following:
Exercise 13. Learn to calculate the new position of CG after heel in the global
coordinate system as function of heel angle (called CG_global). Plot the
position of CG in the graph of the heeled section as a visual verification. To
do this, you assume the center of gravity CG (in the un-heeled condition) is
given by the transverse center of gravity TCG and vertical center of gravity
above keel KG in the hull-fixed un-healed local coordinate system.
Exercise 14. Add the calculation of the restoring lever arm, called GZ (i.e. horizontal
(y-wise) distance between CB and CG in global coords) for your section.
After calculating the equilibrium zwl for the V-shaped section with
m=3000kg, heel=10 and dL=2.0m, TCG=-0.1 and KG=1.2 m I get zwl=
0.6656m and GZ= 0.1798m, do you agree? When I change to heel= 20 I
get zwl= 0.5699m and GZ= 0.3530m, you too? When I change to
heel= -20 I get zwl= 0.5699m and GZ= -0.5410m, you too? Plot your
results. Is it sound that GZ differs between the cases of heel= 20 and
heel= -20?
Exercise 15. Plot the curve of GZ as function of heel in the interval [-50,50]. Use
your 1D automated calculation of zwl (residual_2D_H) to ensure that all
plotted GZ corresponds to a section in vertical equilibrium. For V-shaped
section with m=3000, dL=2.0, TCG=-0.1, KG=1.2 I get the following plot,
do you agree?
3D Hulls
So far we have probably been occupied with the 2D problems in the form of single sections.
Now we will take the step into the world of 3D so that we can calculate the hydrostatics of a
full hull with shapes changing with x-coordinate. The code will build on what you did earlier.
There are some things to consider though. For example we need to load geometries from file
and we need to include the third degree of freedom, trim (rotation around y-axis). Let me
guide you J
Exercise 1. Start with a new empty Matlab script to not mess up your earlier 2D code
now when we need to make some changes.
Exercise 2. Read hull geometries from file. I have prepared a script that loads the hull
geometry from Britfair type file formats. The Britfair format is basically a
structured syntax storing sectional offsets in a text file, see appendix A for
more details. Right now you do not have to worry about the format, just run
the
script
by
typing
in
this
command
[sections,name]=Read_Britfair('AxelJohnson.bri'); which
loads the geometry of the container ship hull called AxelJohnsson. You now
got two data variables, sections and name. Lets have a look at the variable
sections. If you first type sections in the Matlab command line you will see
that this is an array of structured variables called section. This simply
means that if you type sections(1) you get the first of the 19 sections in
sections. You also saw that the structured variable section contains 2
variables, x and offsets. x is simply the x-location of the section and offsets
is the y & z coordinates of the section. Thus, you can look at the offset
points of section #5 by typing sections(5).offsets. You can also create a
list of the x-coordinates of all sections by typing [sections.x].
Exercise 3. Plot all sections of the hull in one plot by looping through all sections
and using the line line plot_section(sections(ii).offsets),
where ii is the counter.
Exercise 4. Plot the entire hull in 3D with heel by calling the script plotHull.m. Try
feeding the plotHull function with a heel angle. Use your old function
heel_offsets.m.
Exercise 5. Plot the entire hull in 3D with trim by feeding the function plotHull.m
with a trim angle It crashes right?! It looks like you need to create a
function (trimming one section) with the following call
trimmed_offsets = trim_offsets(heeled_offsets,x,trim);
where x is the x-coordinate of the section and trim is the trim angle. Hint:
Implement the trim as a rotation around the y-axis at x=0 and assume small
trim angles by only letting the trim subroutine only affect the z-coordinates
of the sections. Thus, x and y coordinates are to be left as before. Also, if
this function contains more than 4 lines of code you are likely on the wrong
track Remember that positive trim should be nose-down according to our
definition of coordinate system.
Exercise 6. Calculate the wet area and CB of each sections by looping through the
sections and use your old known functions by adding the following lines
wet_offsets
= cut_wet_section(trimmed_offsets,zwl);
Aw(isec)
= polygonArea(wet_offsets);
CB_global(isec,:) = polygonCentroid(wet_offsets);
which will produce vectors with data you need. Reflect on your results.
Exercise 7. Secure the situation where Aw=0. The problem here is that the function
polygonCentroid has problems when Aw(isec)=0. You can solve this with
a conditional if-statement that sets CB_global(isec) = [0 0] if Aw=0,
Exercise 8. Calculate the total displacement V by summing up (integrating) the
section displacements. The hint is to use trapezoidal numerical integration
by using the matlab function trapz on the vectors of sectional xcoordinates and wet areas Aw. When I use zwl=8m, heel = 10 and trim =
2, I get Aw = [0.6373 5.7032 28.8845 61.1443 100.9885 142.2518
215.0586 248.1260 266.7087 248.8315 203.0536 139.8171 108.7790
77.6559 50.3250 30.4761 9.2519 2.0492 0] and V =2.5618e+04. Do you
agree?
Exercise 9. Calculate the LCB, TCB and KB in global coordinates. Each calculation is
most easilly written as a one-liner using the trapz-command for trapezoidal
integration. I used the following lines to calculate the displacement and the
LCB:
V = trapz(x,Aw); LCB = trapz(x,x.*Aw)/V
When I use zwl=8m, heel = 10 and trim = 2, I get
CB_global = [80.1127 -2.0951 3.3066]. Do you agree? Hint: If
you have problems with the KB (the third position of CB_global) then you
might have forgotten the effect of the trim angle
Exercise 10. Transform CG from local to global cords in two steps (one line each).
First you heel the local CG and calculate the vector CG_heeled, then you
trim the ship to calculate the vector CG_global. When I test-run with the
CG_local = [65,0.3,10], trim=2 and heel = 10 as an example I get
CG_global=[ 65.0000 -1.4410 7.6317]. Do you agree?
Exercise 11. Calculate the residuals in 3D, by adding 3 lines looking like this
jmv
gz_transverse
gz_longitudinal
= (rho*V-m)/m;
% [-]
= CB_global(2)-CG_global(2); % [m]
= CB_global(1)-CG(1);
% [m]
which naturally shall produce exact the same results as in the previous
excercise. This function shall contain around 60 lines of code, not much
more.
10
Exercise 13. Use residual_3DOF to manually find the equilibrium flotation for
m=14700000kg and CG_local = [65, 0.3, 10] by playing around with the
input. Easy?
Exercise 14. Use fsolve to automize the search for equilibrium flotation using your
residual_3DOF function. The call shall be a one-liner looking like this
zwl_heel_trim=fsolve(@(zwl_heel_trim)residual_3DOF(zwl_heel_tr
im,sections,m,CG_local),[2,0.0,0.0]). Make sure that fsolve
11
Data separation is usually done using blanks (mellanslag) and not tab.
The coordinate system is defined as x being the length coordinate from stern to bow, y is positive
to port and z from keel upwards, usually with the hull lower point as z=0. For sailboats, usually the
lowest point of the canoe-body is used as z=0.
Define each section with the offset points sequentially starting at the keel and then in counterclockwise direction.
You only need to define the right (starboard) side of the hull if the hull is symmetric.
You shall save your file as an ASCII text file with extension .txt or .bri (not .doc or similar).
The following is an example of a Britfair file with explanations:
File content :
Explanation :
Britta
1
8
-4.42
-4.42
0.00
0.00
0.04
0.00
0.04
9.20
3.52
9.88
6.28
10.68
8.84
12.08
10.32
13.76
11.12
16.24
0
11
0
0
0.00
0.00
0.16
0.00
0.24
5.00
0.56
7.20
1.40
8.12
2.68
8.72
6.52
10.04
8.76
11.16
10.52
12.76
11.56
14.60
11.96
16.20
0
...
...
...
...
0
8
162
162
0.0
3.5
0.0
4.0
0.0
6.0
0.0
8.0
0.0
10.0
0.0
12.0
0.0
14.0
1.0
16.44
0
0
0
0
S
E
C
T
I
O
N
1
End of section 1.
No of section offsets
y z
y z
etc ...
section x-coord.
section x-coord.
S
E
C
T
I
O
N
2
End of section 2.
Section nr 3
etc...
...
...
End of section xx.
No of section offsets
y z
y z
osv...
E
T
C
section x-coord.
section x-coord.
S
E
C
T
I
O
N
n
End of section
End of file indicator.
12
13