Stability is a simple concept but is extremely complicated in practice. To simplify assessing stability, MOSES has two commands **STAB_OK** and **KG_ALLOW**. What they do is
compute several things from the basic results reported by the **RARM** command; and if you ask it to, it will check to see if the value computed is greater than a
specified value. These checks are given by the stability criteria of the different regulatory bodies.

All angles (except the equilibrium angle) defined below are relative to the equilibrium position. First, let us define the symbols:

- R(a) = The righting arm at the angle a.
- H(a) = The wind heeling arm at the angle a.
- RA(a) = The area under the righting arm at the angle a.
- HA(a) = The area under the wind heeling arm at the angle a.
- DWT = The smallest angle at which a WT point goes below the water.
- DNWT = The smallest angle at which a NWT point goes below the water.

The angles are shown in the figure below.

Now, the macros compute:

- GM = The distance from the metacenter to the center of gravity.
- DOWN_H = The down-flooding height at equilibrium.
- ZCROSS = The equilibrium angle without wind.
- THETA1 = The first angle, T, at which R(T) = H(T).
- THETA2 = The second angle, T, at which R(T) = H(T).
- RANGE = (of stability) Is the second angle, T, at which R(T) = 0.
- R_M_EQUI = The RANGE - FACTOR * ZCROSS. Here, FACTOR is specified on the option.
- DANG = DNWT.
- DANG_T1 = DNWT - THETA1.
- DWT_T1 = DWT - THETA1.
- ANG_DIFF = THETA2 - THETA1.
- ANG@MARM = The angle at which the RA peaks.
- AR_RATIO = The ratio of the RA/HA with both measured at the minimum of DANG and THETA2.
- ARR@30 = The ratio of the RA/HA with both measured at the minimum of THETA2, DANG, or 30 degrees.
- AR_RESID = RA(T) - RA(THETA1) - [ HA(T) -HA(THETA1) ] where T is the smallest of the down flooding angle, or the second intercept.
- RARM@30 = R(30).
- ARM_AR = RA(THETA2).
- ARE@DFLD = min ( RA(DANG), RA(THETA2 )
- ARE@MARM = RA(M) where M is the angle where R is a maximum.
- ARE@30 = RA(T) where T is minimum of 30 degrees, DANG, or THETA2.
- ARE@40 = RA(40d), where 40d is the minimum of 40 degrees, DANG, or THETA2. degrees.
- AREBTW = RA(40d) - RA(30), where 40d is the minimum of 40 degrees, DANG, or THETA2.
- ARM_RATIO = R(M)/H(M) where M is the minimum of DANG, THETA2, or the angle of maximum righting arm.
- AR_WRATIO = [ RA(TW) - RA(MANG) ] / AD, Here the heeling arm is assumed to be a constant HAW = 1.5 * HA(0). Now, TW is the second intercept of the constant wind arm and the righting arm, AD = HAW * [TW + TT], and TT = MANG - T1. Here we use the RA at a positive MANG even though the angle is drawn as negative on the figure. This is equivalent to assuming that RAA is skew symmetric about the origin.

For checking intact stability, the two commands discussed below will accept the following options.

-I_GM, IGM-I_AR_RATIO, IARATIO-I_RARM@M30, IRARM@M30-I_AR_WRATIO, IAWRATIO, MANG-I_ARM_RATIO, IARMRAT-I_DOWN_H, I_DOWNH-I_ARE@MARM, IARE@MARM-I_ARE@DFLD, IARE@DFLD-I_ARE@30, IARE@30-I_ARE@40, IARE@40-I_AREBTW, IAREBTW-I_ARM_AR, IARMARE-I_AR_RESID, IARRESID-I_ZCROSS, IZCROSS-I_THETA1, ITHETA1-I_RANGE, IRANGE-I_R_M_EQUI, IRMEQUI, FACTOR-I_ANG_DIFF, IANGDIF-I_DANG_T1, IDANGT1-I_DANG, IDANG-I_ANG@MARM, IANG@MARM

Here, what follows the -I_ is the quantity defined above and the second thing is which will be compared to the computed quantity. Two of the options require a second value. AR_WRATIO needs MANG, the nominal roll due to waves, and R_M_EQUI needs the FACTOR to multiply THETA1. These options will be used to check intact stability. There is a second set of option which begin with -D_ which are used to check damaged stability. For example:

-I_GM, 5,-D_GM1

will demand that the GM exceed 5 for an intact case and 1 for a damaged case.

**STAB_OK** produces the righting arm, heeling arm, and area ratio curves for the draft specified. Since the righting arm is based on the equilibrium of the buoyancy and
weight of the vessel, the vessel weight must have been previously defined. This can be accomplished with the stanza:

$ $********************************* set transit condition $ &INSTATE -CONDITION 7 $ $********************************* compute weight for condition $ &WEIGHT -COMPUTE 5 32 85 85

Now, stability checks with the commands of the form:

$ $************************************** check one intact $ hystat stab_ok 5 2.5 10 -wind 100 -yaw 0 $ $************************************** check one damaged $ stab_ok 5 2.5 10 -wind 100 -yaw 0 -damage 5p

These two checks are identical, except that the first one checks intact stability for a draft of 5 feet, while the second one checks stability with compartment 5p damaged.

When using STAB_OK (or KG_ALLOW discussed below), the NWT_DOWN points are used to check intact stability, and both the NWT_DOWN and WT_DOWN points are used to check damaged stability. The general form of the command is:

STAB_OK, DRAFT, RANG_INC, NR_ANGLES, -OPTIONS

where the options are:

-R_TOLERANCE, HE, RO, PI-YAW, Y_ANGLE-DAMAGE, DAM_CMP-WIND, WIND-THWAV, ANGLE_WAVE-CEN_LATERAL, XC, YC, ZC-U_CURRENT-COEF_WIND, W_COEF-COEF_RARM, R_COEF-WIND_MAC-RARM_MAC+ any of the options discussed above.

The variable DRAFT sets the draft for which stability will be checked. When the command is invoked, it will rotate the vessel NR_ANGLES times adding RANG_INC to the roll angle. For each increment, the program will iterate an equilibrium position for the other degrees of freedom and then compute the righting and wind heeling arms.

The **-R_TOLERANCE** option is the same as the one on the **RARM** command. The values specified here will be passed to **RARM** whenever it is called.
Likewise the **-YAW** is analogous to the same option on the **RARM** command and is used to compute righting arms about a skewed axis. The **-DAMAGE** option is used to select tanks that will be damaged for damaged stability. If one does not wish to check damaged stability then this option
should not be used.

The next set of options control the computation of wind heeling. The **-WIND** option is used to define the wind which will be considered. The **-CEN_LATERAL**, **-U_CURRENT**, **-COEF_WIND** and **-COEF_RARM** options simply pass their data
directly to the RARM command, so that their data is the same as that for the option to the RARM command of the same name.

To include the roll owing to wave action, a wave angle can be included with **-THWAV**. The righting and wind arm calculations will begin at the angle
ANGLE_WAVE to windward.

Alternatively, the **-WIND_MAC** option will call the macro

COEF_SET yaw draft

and the **-RARM_MAC** option will call the macro

COEF_RSET yaw draft

immediately before each invocation of RARM. If you use this option, then you must write the macro, COEF_SET or COEF_RSET. It takes the two arguments and set a variable. An example is:

&MACRO COEF_SET YAW DRAFT &SET COE_WIN = -W_COEF A B C D &ENDMACRO &M_ACT COEF_SET RARM &MACRO COEF_RSET YAW DRAFT &SET COE_WIN = -R_COEF A B C D &ENDMACRO &M_ACT COEF_RSET RARM

One can add any logical he wishes here to change the coefficients based on draft and yaw. The values A, B, and C are numbers depending upon the situation.

By default, righting arms are computed about the equilibrium position which is computed before starting. If the **-NO_EQUI** option is used, the basic position is used.
Notice that the GM may not be defined when using this option.

The results of this command are plots of the righting arm, heeling arm, area ratio curves, and two reports. The first report is the standard stability report. The second presents: the condition, the allowables, and the results for each stability criterion along with a statement of "PASS" or "FAIL".

We apologize for the complexity here, but we tried to make these commands applicable to as many rules as possible. Only the checks which are specified will be checked and reported.

We compute the maximum allowable KG for a set of drafts, intact wind speed, and a damage wind speed with the command:

KG_ALLOW

where the options are:

-WIND, I_WIND, D_WIND-YAW, Y_ANGLE(1), .....-DAMAGE, DAM_CMP(1), .....-DRAFTS, D1, D2, ......-KG_TOL, KG_TOL-KG_MIN, KG_MIN-KG_MAX, KG_MAX-CEN_LATERAL, XC, YC, ZC-U_CURRENT-COEF_WIND, W_COEF-WIND_MAC+ any of the options discussed above.

The options here are "the same as" those for the **STAB_OK** command, *except* that one should specify wind speeds for both intact and damaged cases with **-WIND** and one can specify more that one thing with **-YAW** and **-DAMAGE**. The only new options are **-KG_TOL**
which define the tolerance (feet or meters) for the computation of the allowable KG, **-DRAFTS** which defines the drafts to be considered, **-KG_MIN**, and **-KG_MAX**. The last two of these are used in setting the limits which will be searched and normally should not be needed.
**KG_MIN** has a default of 0 and thus it is assumed the vessel has been coded up according to the documentation or that if the KG is at the keel, the vessel will pass
the stability requirements. If you get a message that "LOWER BOUND FAILS", then you need to use this option with some negative KG so that the message goes away. The
**-KG_MAX** value defaults a value which yields zero GM. If you have a partial run which establishes an upper bound on the allowable KG, you can use it here to minimize
the computational effort.

For each draft specified, the command will find an "allowable KG" for the set of damages and yaw angles specified. By allowable, we mean that any KG greater than (to
within KG_TOL) that found will fail one of the stability requirements for some damage and yaw angle. Basically, this command simply incorporates an iterative
algorithm and repeatedly calls **STAB_OK** to find the allowable. The command uses the following search technique:

- It first sets a lower bound, KL, to MIN_KG and checks to make sure that this passes all cases (intact and all damages for all yaws).
- It then sets the upper bound, KU, to about where the GM is MIN_GM or that specified with
**-MAX_KG**. - An estimate of the KG, KC, is obtained as a*KL+b*KU, and each cases is considered; i.e. for each intact and damaged condition, each yaw angle is considered until one fails or all pass. Here, a and b are chosen based on the number of cases to be considered (number of damage compartments + 1 times the number of yaw angles). The reason for doing this is that it costs much more to check a condition that passes than it does to check one that fails! Thus, the coefficients are chosen to minimize the total cost of the search.
- If all pass, the KL is replaced by KC and the above process is repeated.
- If one fails, KU is replaced by KC and the process is repeated.
- This continues until KU - KL is less than TOL and the allowable is taken to be KL.
- All of the above was done with no reporting. After an allowable KG has been found, all of the cases are again considered and a report of the stability are printed.

If more than one draft was specified, a plot of the allowable KG vs draft will be made. Since the algorithm favors failure, it is much more efficient if you order the data "properly". In particular, you should input the damage cases in order of most likely failure. The same can be said of the yaw angles.