DeformableBodies

Model

DeformableBodies.ModelType
Model

Fields

  • bodyframe – Function representing trajectory on reference frame rotating with the body.
  • timespan – Tuple containing starting and ending time of motion.
  • q_0 – Quaternion representing initial rotation.
  • L_cm – Vector of angular momentum in relation to center of mass.

Only Initialized after solve:

  • inertialframe – Function representing trajectory on inertial reference frame.
  • rotation – Rotations that exchange between bodyframe and inertialframe.
  • momentum – Internal angular momentum.

Store the data of a deformable body problem before and after solving.

source
DeformableBodies.solve!Function
solve!(m::Model; reltol=1e-8, abstol=1e-8, solver=Tsit5())

Receive a Model, calculate the trajectory of the body on an inertial frame and store it in the variable m.inertialframe.

source

Operators from mechanics

DeformableBodies.PointMassType
PointMass(m, x)

Wrapper over a mass and a position on $R^3$.

This type overloads Quaternions.rotate to rotate only its position.

julia> a = PointMass(10, [1., 0, 0])
PointMass{Float64}(10.0, [1.0, 0.0, 0.0])

julia> rotate(a; axis=[0., 0., 1.], angle=π/2)
PointMass{Float64}(10.0, [2.220446049250313e-16, 1.0, 0.0])
source
DeformableBodies.inertia_tensorFunction
inertia_tensor(xs)

Receive a system of PointMasses and return their inertia tensor through formula

\[I(x) = \sum m_i \Big( \langle x_i, x_i \rangle \mathrm{id} - x_i \otimes x_i \Big).\]

source
DeformableBodies.velocityFunction
velocity(xs, t; δ=1e-6)

Numerically approximate the velocity for a set xs of trajectories at time t. The variable δ denotes the step for the finite differences interval.

source

Plotting a model

DeformableBodies.plotmodelMethod
plotmodel(model, SoR; kw...)

Receive a Model and return a Plots.Animation from its data.

Arguments

  • SoR: means "system of reference" and accepts one of the following symbols: :bodyframe, :inertialframe, :both.
  • fps: frames per second. Default is 24.
  • duration: length of animation in seconds. Default is the total timespan stored in m.
  • saveas: filename to save animation, supported extensions are gif, mp4 or mov. If left blank, file is not saved.
  • bodylines: Array of points pairs. Stores the data who says which points should be linked. Default is empty.
  • markersize_is_mass: Says if attribute markersize should be weighted by the mass of each particle. Default is true.

Additionally, any keyword argument supported by Plots.plot is accepted and will be repassed to the plot.

Examples

julia> plotmodel(m, :both, fps=15, saveas="example.gif", color=:green,viewangle=(30,60))
source
DeformableBodies.saveanimationMethod
saveanimation(anime, saveas; fps=30)

Receive an Plots.Animation and save it as a file.

Supported formats are 'gif', 'mp4' and 'mov'. The extension is automatically detected from saveas and, in case of ambiguity, defaults to '.gif'.

source