Finds minimum GM according to 46 CFR 170.170.
Demonstration of the use of variables and variable arithmetic.

Assumes that the wind plane is geometrically modeled.
Works with GHS and BHS.
project reqgm170
part hull `a displacer part
`Point to be used for freeboard measurement:
refpt = 0, 12.27, 12.58
parts /displacer
`no fix trim
variable d `current draft
variable di `draft increment
variable hf `half freeboard
variable h `heel angle
variable dh `change to apply to heel angle
variable th `tangent of heel angle
variable ha `heeling arm
variable t `temporary
variable gm `gm required
`Macro to be used for the heel iteration to find angle of half freeboard:
`(Note: This is simple and inefficient, but it runs quickly enough.)
macro tryheel
fix heel | solve | vary heel `
if {HEIGHT}>{hf} then set h={h} plus {dh} else set h={h} minus {dh}
set dh={dh} mult 0.6
macro reqgm `Takes trim as a parameter
 \\ Draft: {d} Trim: %1
hmmt off
heel = 0
trim = %1 `
 draft = {d}
solve weight, tcg
set hf = {HEIGHT} div 2
 \ Freeboard: {HEIGHT} Half freeboard: {hf}
set dh = 7
set h = {dh}
.tryheel (12)
if {HEEL}>14 then heel = 14 `
\ Heel angle to half freeboard or 14 degrees: {HEEL} `
set th = tan {HEEL}
\ Using heel angle: {HEEL} tangent: {th}
heel = 0
hmmt wind
set t = {FTCG} `save original tcg
 fix heel | solve | vary heel `
solve tcg `
set ha = {t} minus {FTCG}
\ Heeling arm: {ha}
set gm = {ha} div {th}
\ ----> Required GM: {gm}
set d = {d} plus {di}
`------ Run the calculations -------
wind (pressure) = 0.005
`fix trim `
set di = 1 `draft increment
set d = 6 `initial draft
.reqgm (4), 0 `(number of drafts), trim
set d = 6
.reqgm (4) 1
report off

 Previous document Back