Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set COG and calc moments of inertia #22

Merged
merged 3 commits into from
May 4, 2021
Merged

Conversation

ryancoe
Copy link
Contributor

@ryancoe ryancoe commented Mar 6, 2021

Allows user to set the location of the center of gravity (gravity_center) and use this for calculating the moments of inertia.

For example

import meshmagick.mmio as mmio
from meshmagick.mesh import Mesh
from math import pi, fabs
import pytest

# analytic solution
vertices, faces = mmio.load_VTP('meshmagick/tests/data/Cylinder.vtp')
cylinder = Mesh(vertices, faces)
xmin, xmax, ymin, ymax, zmin, zmax = cylinder.axis_aligned_bbox
R = (xmax-xmin)/2.
h = zmax-zmin
V = pi*R**2*h
Ixx = Iyy = V*(R**2+h**2/3)/4
Izz = V*R**2/2

# parallel axis theorem to find MOI at base of cylinder
Ixx_base = Ixx + V*(h/2)**2             

# use meshmagick to find moments of inertia
inertia = cylinder.eval_plain_mesh_inertias(rho_medium=1.)

# shift calculation to new cog (at base of cylinder)
inertia.set_cog((0,0,-h/2))
inertia.shift_at_cog()

assert pytest.approx(Ixx_base, rel=1e-1) == inertia.xx
image

@ryancoe
Copy link
Contributor Author

ryancoe commented Mar 6, 2021

All tests passed

$ pytest meshmagick/tests -q --disable-pytest-warnings
..............................                                                                                                                                       [100%]
30 passed, 3408 warnings in 13.29s

@frongere frongere merged commit 21dbd5b into LHEEA:master May 4, 2021
@frongere
Copy link
Member

frongere commented May 4, 2021

Hi Ryan,

Thank you for this PR! That was indeed needed. And my apologies for the late action (quite busy)
For your information, I worked the last few days on a far much better implementation for the hydrostatics module. Now data of the hydrostatics report are expressed in the initial vessel frame, not in a frame obtained after successive iterations to the Newton-Raphson solver. The hydrostatic stiffness matrix is well expressed with respect to COG/buoyancy centre and no more with respect to a frame origin.

BR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants