# Path: proptools/tank_structure.py
# def crown_thickness(p_t, R, stress, weld_eff):
# def knuckle_thickness(p_t, a, b, stress, weld_eff):
# def cylinder_thickness(p_t, a, stress, weld_eff):
# def sphere_thickness(p_t, a, stress, weld_eff):
# def max_axial_load(p_t, a, t_c, l_c, E):
# def cylinder_mass(a, t_c, l_c, rho):
# def sphere_mass(a, t, rho):
# def ellipse_mass(a, b, t, rho):
# def cr_ex_press_sphere(a, t, E, v):
# def cr_ex_press_sphere_end(a, t, E):
# def cr_ex_press_ellipse_end(a, b, t, E, C_b=0.05):
# def cr_ex_press_cylinder(a, t_c, l_c, E, v):
# def sphere_volume(a):
# def ellipse_volume(a, b):
# def cylinder_volume(a, l_c):
# def knuckle_factor(ellipse_ratio):
# def ellipse_design_factor(ellipse_ratio):
#     K = knuckle_factor(a / b)
# 
# Path: proptools/units.py
# def inch2meter(x):
#     return x * 0.0254
# 
# def psi2pascal(x):
#     return x * 6895
# 
# def lbf2newton(x):
#     return x * 4.448
# 
# def lbm2kilogram(x):
#     return x * 0.4536


import unittest
from proptools import tank_structure as ts
from proptools.units import inch2meter, psi2pascal, lbf2newton, lbm2kilogram
        v = 0.36
        weld_eff = 1.0
        p_to = psi2pascal(180) # Oxidizer max pressure 180 psi
        p_tf = psi2pascal(170) # fuel max pressure 170 psi
        rho = 0.101 * lbm2kilogram(1) / inch2meter(1)**3

        # knuckle factor K = 0.80
        self.assertAlmostEqual(0.8, ts.knuckle_factor(a / b), delta=0.02)

        # Ox tank knuckle 0.155 inch thick.
        self.assertAlmostEqual(inch2meter(0.155), ts.knuckle_thickness(
            p_to, a, b, stress, weld_eff), delta=inch2meter(0.005))

        # Ox tank crown 0.135 inch thick.
        self.assertAlmostEqual(inch2meter(0.135), ts.crown_thickness(
            p_to, (a / b) * a, stress, weld_eff), delta=inch2meter(0.005))
        
        # Fuel tank cylinder 0.183 inch thick.
        self.assertAlmostEqual(inch2meter(0.183), ts.cylinder_thickness(
            p_tf, a, stress, weld_eff), delta=inch2meter(0.005))

        # Ellipse design factor E' = 4.56
        self.assertAlmostEqual(4.56, ts.ellipse_design_factor(a / b), delta = 0.005)

        # Oxidizer tank end weighs 126.4 lmb
        self.assertAlmostEqual(2 * lbm2kilogram(126.4), ts.ellipse_mass(
            a, b, inch2meter(0.145), rho), delta=lbm2kilogram(0.2))

        # Cylindrical section weighs 223.3 lbm
        self.assertAlmostEqual(lbm2kilogram(223.3), ts.cylinder_mass(

# Path: proptools/tank_structure.py
# def crown_thickness(p_t, R, stress, weld_eff):
# def knuckle_thickness(p_t, a, b, stress, weld_eff):
# def cylinder_thickness(p_t, a, stress, weld_eff):
# def sphere_thickness(p_t, a, stress, weld_eff):
# def max_axial_load(p_t, a, t_c, l_c, E):
# def cylinder_mass(a, t_c, l_c, rho):
# def sphere_mass(a, t, rho):
# def ellipse_mass(a, b, t, rho):
# def cr_ex_press_sphere(a, t, E, v):
# def cr_ex_press_sphere_end(a, t, E):
# def cr_ex_press_ellipse_end(a, b, t, E, C_b=0.05):
# def cr_ex_press_cylinder(a, t_c, l_c, E, v):
# def sphere_volume(a):
# def ellipse_volume(a, b):
# def cylinder_volume(a, l_c):
# def knuckle_factor(ellipse_ratio):
# def ellipse_design_factor(ellipse_ratio):
#     K = knuckle_factor(a / b)
# 
# Path: proptools/units.py
# def inch2meter(x):
#     return x * 0.0254
# 
# def psi2pascal(x):
#     return x * 6895
# 
# def lbf2newton(x):
#     return x * 4.448
# 
# def lbm2kilogram(x):
#     return x * 0.4536


# Path: proptools/tank_structure_test.py
import unittest
from proptools import tank_structure as ts
from proptools.units import inch2meter, psi2pascal, lbf2newton, lbm2kilogram

        v = 0.36
        weld_eff = 1.0
        p_to = psi2pascal(180) # Oxidizer max pressure 180 psi
        p_tf = psi2pascal(170) # fuel max pressure 170 psi
        rho = 0.101 * lbm2kilogram(1) / inch2meter(1)**3

        # knuckle factor K = 0.80
        self.assertAlmostEqual(0.8, ts.knuckle_factor(a / b), delta=0.02)

        # Ox tank knuckle 0.155 inch thick.
        self.assertAlmostEqual(inch2meter(0.155), ts.knuckle_thickness(
            p_to, a, b, stress, weld_eff), delta=inch2meter(0.005))

        # Ox tank crown 0.135 inch thick.
        self.assertAlmostEqual(inch2meter(0.135), ts.crown_thickness(
            p_to, (a / b) * a, stress, weld_eff), delta=inch2meter(0.005))
        
        # Fuel tank cylinder 0.183 inch thick.
        self.assertAlmostEqual(inch2meter(0.183), ts.cylinder_thickness(
            p_tf, a, stress, weld_eff), delta=inch2meter(0.005))

        # Ellipse design factor E' = 4.56
        self.assertAlmostEqual(4.56, ts.ellipse_design_factor(a / b), delta = 0.005)

        # Oxidizer tank end weighs 126.4 lmb
        self.assertAlmostEqual(2 * lbm2kilogram(126.4), ts.ellipse_mass(
            a, b, inch2meter(0.145), rho), delta=lbm2kilogram(0.2))

        # Cylindrical section weighs 223.3 lbm
        self.assertAlmostEqual(lbm2kilogram(223.3), ts.cylinder_mass(

            a, inch2meter(0.183), l_c, rho), delta=lbm2kilogram(0.2))