LHEEA / meshmagick

A command line tool and a python package to manipulate hydrodynamics meshes
GNU General Public License v3.0
48 stars 27 forks source link

Stiffness matrix and translation #8

Open mancellin opened 6 years ago

mancellin commented 6 years ago

I'm not actually sure if this is a bug or a feature that I don't understand:

from meshmagick.mmio import load_mesh
from meshmagick.mesh import Mesh
from meshmagick.hydrostatics import Hydrostatics

reference_mesh = Mesh(*load_mesh("SEAREV.hst", 'hst'))

for shift in range(0, 100, 20):
    shifted_mesh = reference_mesh.copy()
    shifted_mesh.translate_x(shift)
    print shift
    print Hydrostatics(shifted_mesh, cog=(shift, 0, 0)).hs_data['stiffness_matrix'][2, 2]
    print Hydrostatics(shifted_mesh, cog=(shift, 0, 0)).hs_data['Iyy']

The inertia matrix is invariant when the body is translated in the x direction. I would have expected the same to be true for the stiffness matrix. Are the rotation dofs defined around the same axis in both cases ?

mancellin commented 6 years ago

Actually it seems that the x and y coordinates given in the cog argument have no influence on the results.

ryancoe commented 3 years ago

Looking at this a bit more, here's my current understanding:

stiffness: I think there was a bit of a problem here, which I've submitted a fix for with #22 (note however that what I've done is not yet propagated back to the Hydrostatics class; if you think it looks good we can finish doing this).

hydrostatics: these look like they are currently calculated relative to a point on a vertical line passing through origin but with the correct vertical position:

This section uses the x and y location of the origin (xi, yi = polyverts[0, :2]) https://github.com/LHEEA/meshmagick/blob/0d214f94d444c55cfc2ecce830e57de08793bf2f/meshmagick/hydrostatics.py#L605-L621

This section uses the vertical location of the cog (self.zg) https://github.com/LHEEA/meshmagick/blob/0d214f94d444c55cfc2ecce830e57de08793bf2f/meshmagick/hydrostatics.py#L653-L655

Thus, it might be appropriate to change this method so that it calculates based on COG, right?

https://github.com/LHEEA/meshmagick/blob/0d214f94d444c55cfc2ecce830e57de08793bf2f/meshmagick/hydrostatics.py#L599

This line would be changed to polyverts = clipper.clipped_crown_mesh.vertices[polygon] - self._gravity_center

ryancoe commented 3 years ago

related to #1

frongere commented 3 years ago

I just released v3.0 which should fix these issues.

Note however that I have totally refactored the hydrostatics module using only functions with no class. The code is far more simple and the number of lines of code has lowered.

The stiffness matrix and metacentric stuffs are now expressed on a line passing though COG/buoyancy centre.

Positions such as buoyancy centre are expressed in the initial frame. It allows to directly compare results to other commercial software such as Maat Hydro.