In [1]:
import numpy as np
import scipy.interpolate as interpolate
import scipy.optimize as optimize
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['figure.figsize'] = (16, 9)
import sys
import imp
import os
import polymesh.mesh as mesh
import polymesh.hydrostatic as hydrostatic
import time
In [11]:
# Import the test geoemtry, which is a full size version of the ship KCS
shipMesh = mesh.importObj('KCS.obj')
# The keel is located at z=0 in the geometry file. Translate it downwards to right depth
T = 10.8
shipMesh.translate(0, 0, -T)
In [12]:
startTime = time.time()
wetMesh = hydrostatic.extractWetSurface(shipMesh)
stopTime = time.time()
print(stopTime - startTime)
wetMesh.exportObj('wetMesh.obj')
In [16]:
rho = 1025
Volume = hydrostatic.calculateVolume(wetMesh)
Surface = hydrostatic.calculateSurface(wetMesh)
volumeCentroid = hydrostatic.calculateVolumeCentroid(wetMesh)
Dimensions = hydrostatic.calculateDimensions(wetMesh)
Mass = Volume*rho
print('Volume:', np.round(Volume, decimals=3), 'm^3')
print('Surface:', np.round(Surface, decimals=3), 'm^2')
print('Volume centroid:', np.round(volumeCentroid[0], decimals=4), np.round(volumeCentroid[1], decimals=4), np.round(volumeCentroid[2], decimals=4))
print('Dimensions:', Dimensions)
print('Mass:', Mass/1e3, 'tonnes')