Skip to main content

A shoebox approximation for a marine hydrodynamics model

Project description

shoeboxpy

shoeboxpy

Installation

pip install git+https://github.com/incebellipipo/shoeboxpy.git

Theory

The shoeboxpy package provides simulation models for vessels with 3 and 6 degrees of freedom (DOF). These models are based on rigid-body dynamics, including added mass, damping, Coriolis/centripetal effects, and restoring forces.

6-DOF Model

The 6-DOF model represents a rectangular "shoebox" vessel with the following states:

  • Position and orientation in the inertial frame: $\eta = [x, y, z, \phi, \theta, \psi]$
  • Velocities in the body frame: $\nu = [u, v, w, p, q, r]$

3-DOF Model

The 3-DOF model simplifies the dynamics to planar motion (surge, sway, yaw) with states:

  • Position and orientation in the inertial frame: $\eta = [x, y, \psi]$
  • Velocities in the body frame: $\nu = [u, v, r]$

Dynamics

Dynamics for both models are governed by:

$$ \begin{aligned} & \dot{\eta} = J(\eta)\nu\ & (M_{RB} + M_A)\dot{\nu} + (C_{RB}(\nu) + C_A(\nu))\nu + D\nu = \tau + \tau_{\mathrm{ext}} + g_{\mathrm{restoring}}(\eta) \end{aligned} $$

where:

  • $M_{RB}$ and $M_A$ are the rigid-body and added mass matrices.
  • $C_{RB}(\nu)$ and $C_A(\nu)$ are the Coriolis/centripetal matrices.
  • $D$ is the linear damping matrix.
  • $\tau$ and $\tau_{\mathrm{ext}}$ are control and external forces/moments.
  • $g_{\mathrm{restoring}}(\eta)$ represents restoring forces in roll and pitch.

Both models use a 4th-order Runge-Kutta method for numerical integration, allowing for accurate simulation of vessel dynamics under various forces and moments.

Read the theory for more details.

Example

Here is an example of how to use the shoeboxpy package to simulate a 6-DOF vessel:

import numpy as np
from shoeboxpy.model6dof import Shoebox
from shoeboxpy.animate import animate_history

# Initialize the shoebox model
shoebox = Shoebox(
    L=1.0,  # Length (m)
    B=0.3,  # Width (m)
    T=0.03,  # Height (m)
    eta0=np.array([0.0, 0.0, 0.0, 0.1, 0.1, 0.1]),  # Initial position and orientation
    nu0=np.zeros(6),  # Initial velocities
    GM_phi=0.2,  # Metacentric height in roll
    GM_theta=0.2,  # Metacentric height in pitch
)

# Simulate for 10 seconds with a time step of 0.01 seconds
dt = 0.01
eta_history = []
for _ in range(int(10 / dt)):
    shoebox.step(tau=np.array([1.0, 0.2, 0.0, 0.0, 0.0, 0.1]), dt=dt)  # Apply control forces
    eta_history.append(shoebox.get_states()[0])  # Store position and orientation

# Convert history to a NumPy array for analysis or visualization
eta_history = np.array(eta_history)

animate_history(eta_history, dt=dt, L=1.0, B=0.3, T=0.2)  # Animate the results

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shoeboxpy-0.0.3.tar.gz (413.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shoeboxpy-0.0.3-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file shoeboxpy-0.0.3.tar.gz.

File metadata

  • Download URL: shoeboxpy-0.0.3.tar.gz
  • Upload date:
  • Size: 413.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for shoeboxpy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7adc6a37d734b43e0e8760a443365529dda1f4be4cd5f05d70856c24d1a97bcb
MD5 a1333780ae7f7c9dbff7798ceb9f5ed4
BLAKE2b-256 7093160ddfd8735021425b80249a67c62e655f0bc931dbb9148db7fef5d7da8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for shoeboxpy-0.0.3.tar.gz:

Publisher: publish.yml on incebellipipo/shoeboxpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shoeboxpy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: shoeboxpy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for shoeboxpy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba09c6102f21396a0bf9952aeac788cb08b0709d783a46b9b79d3e68d500d20
MD5 aeff9f67907e1525657946f0429a0352
BLAKE2b-256 bd3d5eaa8eba20bb92752f613c40ce5c2180c0082428eb4407afae3ed2b8a5ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for shoeboxpy-0.0.3-py3-none-any.whl:

Publisher: publish.yml on incebellipipo/shoeboxpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page