shoeboxpy package
Submodules
shoeboxpy.model3dof module
- class shoeboxpy.model3dof.Shoebox(L, B, T, rho=1000.0, alpha_u=0.1, alpha_v=0.2, alpha_r=0.1, beta_u=0.05, beta_v=0.05, beta_r=0.05, eta0=array([0., 0., 0.]), nu0=array([0., 0., 0.]))[source]
Bases:
object
3-DOF planar ship model (surge, sway, yaw).
States:
\[\begin{split}\eta &= [x, y, \psi] \\ \nu &= [u, v, r]\end{split}\]Dynamics:
\[\begin{split}& \dot{\eta} = J(\psi)\nu \\ & (M_{RB}+M_A)\dot{\nu} + \Big(C_{RB}(\nu)+C_A(\nu)\Big)\nu + D\nu = \tau\end{split}\]where \(\tau\) is the control/input force/moment vector in surge, sway, and yaw.
- Parameters:
L (float) – Length of the vessel.
B (float) – Breadth of the vessel.
T (float) – Draft of the vessel.
rho (float) – Density of water (default is 1000.0).
alpha_u (float) – Added mass coefficient in surge (default is 0.1).
alpha_v (float) – Added mass coefficient in sway (default is 0.2).
alpha_r (float) – Added mass coefficient in yaw (default is 0.1).
beta_u (float) – Damping factor in surge (default is 0.05).
beta_v (float) – Damping factor in sway (default is 0.05).
beta_r (float) – Damping factor in yaw (default is 0.05).
eta0 (ndarray[tuple[Any, ...], dtype[float64]]) – Initial state vector for position and orientation, i.e. [x, y, psi]. Default is a zero array of length 3.
nu0 (ndarray[tuple[Any, ...], dtype[float64]]) – Initial state vector for velocities, i.e. [u, v, r]. Default is a zero array of length 3.
- dynamics(eta, nu, tau, tau_ext=None)[source]
Returns the time derivatives \((\dot{\eta}, \dot{\nu})\) for the 3DOF model:
External forces \(\tau_{ext}\) can be provided (default is zero).
shoeboxpy.model6dof module
- class shoeboxpy.model6dof.Shoebox(L, B, T, rho=1000.0, alpha_u=0.1, alpha_v=0.2, alpha_w=1.0, alpha_p=0.1, alpha_q=0.1, alpha_r=0.1, beta_u=0.25, beta_v=0.25, beta_w=0.25, beta_p=0.25, beta_q=0.25, beta_r=0.25, GM_phi=0.0, GM_theta=0.0, g=9.81, eta0=array([0., 0., 0., 0., 0., 0.]), nu0=array([0., 0., 0., 0., 0., 0.]))[source]
Bases:
object
- 6-DOF rectangular “shoebox” vessel with:
Rigid-body mass & inertia (diagonal) from geometry (L, B, T).
Added mass (diagonal) from user-chosen dimensionless factors.
Linear damping (diagonal).
Simple linear restoring in roll & pitch for small angles (metacentric method).
Coriolis & centripetal effects from both rigid-body and added mass.
States:
\[\eta = [x, y, z, \phi, \theta, \psi] \nu = [u, v, w, p, q, r]\]The dynamics are:
\[\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).\]- Parameters:
L (float) – Length of the shoebox (m)
B (float) – Width of the shoebox (m)
T (float) – Height of the shoebox (m)
rho (float) – Density of the fluid \((kg/m^3)\)
beta_* (alpha_*,) – Added mass & damping coefficients (dimensionless)
GM_theta (GM_phi,) – Metacentric heights for roll & pitch
g (float) – Gravitational acceleration \((m/s^2)\)
eta0 (ndarray[tuple[Any, ...], dtype[float64]]) – Initial \([x, y, z, \phi, \theta, \psi]\)
nu0 (ndarray[tuple[Any, ...], dtype[float64]]) – Initial \([u, v, w, p, q, r]\)
alpha_u (float)
alpha_v (float)
alpha_w (float)
alpha_p (float)
alpha_q (float)
alpha_r (float)
beta_u (float)
beta_v (float)
beta_w (float)
beta_p (float)
beta_q (float)
beta_r (float)
GM_phi (float)
- C_RB(nu)[source]
Rigid-body Coriolis/centripetal matrix for diagonal \(M_{RB}\). (assuming CG at origin, no product of inertia).
- J(eta)[source]
Computes the 6x6 transformation matrix J that maps body velocities to the inertial frame velocities \([\dot{x}, \dot{y}, \dot{y}, \dot{\phi}, \dot{\theta}, \dot{\psi}]\).
- dynamics(eta, nu, tau, tau_ext)[source]
Public API returning new arrays (kept for backward compatibility).