capytaine.bodies.bodies module¶
Floating bodies to be used in radiation-diffraction problems.
- class capytaine.bodies.bodies.FloatingBody(mesh=None, dofs=None, mass=None, center_of_mass=None, name=None, *, lid_mesh=None)[source]¶
Bases:
_HydrostaticsMixin,ClippableMixin,Abstract3DObjectA floating body described as a mesh and some degrees of freedom.
The mesh structure is stored as a Mesh from capytaine.mesh.mesh or a CollectionOfMeshes from capytaine.mesh.meshes_collection.
The degrees of freedom (dofs) are stored as a dict associating a name to a complex-valued array of shape (nb_faces, 3). To each face of the body (as indexed in the mesh) corresponds a complex-valued 3d vector, which defines the displacement of the center of the face in frequency domain.
- Parameters:
mesh (MeshLike, optional) – the mesh describing the geometry of the hull of the floating body. If none is given, a empty one is created.
lid_mesh (MeshLike or None, optional) – a mesh of an internal lid for irregular frequencies removal. Unlike the mesh of the hull, no dof is defined on the lid_mesh. If none is given, none is used when solving the Boundary Integral Equation.
dofs (dict, optional) – the degrees of freedom of the body. If none is given, a empty dictionary is initialized.
mass (float or None, optional) – the mass of the body in kilograms. Required only for some hydrostatics computation. If None, the mass is implicitly assumed to be the mass of displaced water.
center_of_mass (3-element array, optional) – the position of the center of mass. Required only for some hydrostatics computation.
name (str, optional) – a name for the body. If none is given, the one of the mesh is used.
- add_dofs_labels_to_matrix(matrix)[source]¶
Helper function turning a bare matrix into a matrix labelled by the name of the dofs of the body, to be used for instance for the computation of RAO.
- add_dofs_labels_to_vector(vector)[source]¶
Helper function turning a bare vector into a vector labelled by the name of the dofs of the body, to be used for instance for the computation of RAO.
- add_rotation_dof(axis=None, name=None, amplitude=1.0) None[source]¶
Add a new rotation dof (in place). If no axis is given, the code tries to infer it from the name.
- Parameters:
axis (Axis, optional) – the axis of the rotation
name (str, optional) – a name for the degree of freedom
amplitude (float, optional) – amplitude of the dof (default: 1.0)
- add_translation_dof(direction=None, name=None, amplitude=1.0) None[source]¶
Add a new translation dof (in place). If no direction is given, the code tries to infer it from the name.
- Parameters:
direction (array of shape (3,), optional) – the direction of the translation
name (str, optional) – a name for the degree of freedom
amplitude (float, optional) – amplitude of the dof (default: 1.0 m/s)
- animate(motion, *args, **kwargs)[source]¶
Display a motion as a 3D animation.
- Parameters:
motion (dict or pd.Series or str) – A dict or series mapping the name of the dofs to its amplitude. If a single string is passed, it is assumed to be the name of a dof and this dof with a unit amplitude will be displayed.
- assemble_regular_array(distance, nb_bodies)[source]¶
Create an regular array of identical bodies.
- Parameters:
distance (float) – Center-to-center distance between objects in the array
nb_bodies (couple of ints) – Number of objects in the x and y directions.
- Return type:
- clip(*args, inplace=True, name=None, **kwargs)¶
- copy(name=None) FloatingBody[source]¶
Return a deep copy of the body.
- Parameters:
name (str, optional) – a name for the new copy
- extract_faces(id_faces_to_extract, return_index=False)[source]¶
Create a new FloatingBody by extracting some faces from the mesh. The dofs evolve accordingly. The lid_mesh, center_of_mass, mass and hydrostatics data are discarded.
- first_irregular_frequency_estimate(*, g=9.81)[source]¶
Estimates the angular frequency of the lowest irregular frequency. This is based on the formula for the lowest irregular frequency of a parallelepiped of size \(L \times B\) and draft \(H\):
(11)¶\[\omega = \sqrt{ \frac{\pi g \sqrt{\frac{1}{B^2} + \frac{1}{L^2}}} {\tanh\left(\pi H \sqrt{\frac{1}{B^2} + \frac{1}{L^2}} \right)} }\]The formula is applied to all shapes to get an estimate that is usually conservative. The definition of a lid (supposed to be fully covering and horizontal) is taken into account.
- static from_file(filename: str, file_format=None, name=None) FloatingBody[source]¶
Create a FloatingBody from a mesh file using meshmagick. Kinda deprecated, use cpt.load_mesh instead.
- static from_meshio(mesh, name=None) FloatingBody[source]¶
Create a FloatingBody from a meshio mesh object. Kinda deprecated, use cpt.load_mesh instead.
- join_bodies(*, name=None) FloatingBody[source]¶
- keep_only_dofs(*args, inplace=True, name=None, **kwargs)¶
- property minimal_computable_wavelength¶
For accuracy of the resolution, wavelength should not be smaller than this value.
- mirror(*args, inplace=True, name=None, **kwargs)¶
- property nb_dofs: int¶
Number of degrees of freedom.
- rotate(*args, inplace=True, name=None, **kwargs)¶
- translate(*args, inplace=True, name=None, **kwargs)¶