Construct body-joint system
Constructing the body-joint system requires filling in a lot of detailed information, like body-joint hierarchy information, body inertia, joint degree of freedoms type etc. In this section we introduce the construction of the system in two aspects:
User-oriented set up(front end)
Code-oriented construction(back end)
User-oriented set up
To set up a body-joint system, one needs to know how to set body properties and joint properties, also the hierarchy information. In this section we introduce how to set up the body-joint system, together with other information needed to enclosure the problem we're interested in.
The set up of the problem generally has 3 parts: set up body, set up joint, and set up system information like the dimension of this problem, gravity, numerical parameters etc. We will use these information provided by the user to construct every single body, every single joint, and finally connect them with hierarchy information. Some examples of providing user-set-up information are listed in src/config_files
for user convenience. Here we take the 2dFall.jl
as an example to show the procedure of setting up the problem.
ConfigDataType
Code-oriented construction
Before running any dynamics, we need to construct the body-joint system, connecting bodies by joints in the correct hierarchy using supplied configuration information. In order to do that, three key functions are used:
which is responsible for add a body to the body system, add a joint to the joint system and assemble the body-joint system and fill in extra hierarchy information. These three functions are also bundled in the correct sequential order in
In order to solve for the rigid body-joint chain system, we choose body velocity $v$ and joint displacement $qJ$ as main variables in the time marching scheme. We also need to construct a structure that stores and updates the body-joint chain's intermediate variables such as all kinds of transformation matrices $X$, body position in the inertial space $x_i$ and so on. All information of the body-joint system is bundled into a BodyDyn
structure.
Methods
Dyn3d.ConfigDataType.ConfigBody
— Type.ConfigBody(nbody::Int,nverts::Int,verts::Matrix{Float64},ρ::Float64)
Set up configuration information for the a single body in the body system. Here we assume that all bodies has the same shape if more than one body exists. A single body is an infinitely thin body in y direction. It must have polygon shape and is described in z-x space. For example if we describe a rectangle in z-x space, for 3d problem it's just fine. For 2d problem in x-y space, this rectangle has a projection of a line in x-y space. The vertices local coordinates are described in clockwise direction as a convention.
Fields
nbody
: Number of bodies in totalnverts
: Number of vertices for one bodyverts
: Polygon vertices coordinates starting from the left bottom vert and going in clockwise direction. Each line describes the (z,x) coordinate of this vertice. Usually the z-dimesion has unit length 1 for 2-d problem.ρ
: Density of this body in mass per area
Body setup
^(y)
|
|----->(x)
/
(-z)
Dyn3d.ConfigDataType.ConfigJoint
— Type.ConfigJoint(njoint,joint_type,shape1,shape2,body1,joint_dof,qJ_init)
Set up configuration information for a single joint. A joint allows one/multiple degree of freedoms from 1 to 6.
Fields
njoint
: Int, total number of joints for this body-joint systemjoint_type
: String, allows "revolute", "prismatic", "cylindrical", "planar", "spherical", "free" and "custom". Detailed information is described inJointType
sectionshape1
: Vector{Float64} with 6 elements. It describes the location of this joint in its parent body coordinate. If shape1 is used on the first joint, then it's the orientation of this first joint to inertial system. It is written with [θx, θy, θz, x, y, z].shape2
: Vector{Float64} with 6 elements. It describes the location of this joint in its child body coordinate. Normally, shape2 is zeros(Float64,6) if there's no distance gap or angle gap between two adjacent bodies.body1
: the parent body id of this jointjoint_dof
: Vector{Float64}. The size of joint_dof depends on the number of specified dof, refers to typeDof
.qJ_init
: Vector{Float64}. It is the initial angle/displacement of this joint with respect to its parent body. The size should be the same as the number of dof specified.
ConfigSystem(ndim::Int,gravity::Vector{Float64},num_params::NumParams)
Additional system information to define this problem.
Fields
ndim
: Dimension of this problem. Choices are 2 or 3gravity
: Non-dimensional gravity. It is in [x,y,z] direction. So if we're describing a 2d problem with gravity pointing downward, it should be [0.,-1.,0.]num_params
: Refer to typeNumParams
Dyn3d.ConfigDataType.Dof
— Type.Dof(dof_id::Int,dof_type::String,stiff::Float64,damp::Float64,motion::Motions)
Set up a single degree of freedom(dof) information in a joint. A joint may have a maximum 6 dofs and minimum 1 dof(either active or passive). Here we don't allow it to have 0 since there's no reason to do this. If we want the parent body and child body to have no relative motion(i.e. they're rigidly connected together), we can set the second joint has only one dof and this dof has active "hold" motion.
Fields
dof_id
: Choose from 1 to 6 and is corresponding to [Ox, Oy, Oz, x, y, z].dof_type
: "passive" or "active"stiff
: Non-dimensional stiffness of a string associated with this degree of freedom. Only has effect on solving the system when this dof is passive.damp
: Similar to stiff, this assigns the damping coefficient of this dof.motion
: Defines the motion of this dof. Refer to typeMotion
Dyn3d.ConfigDataType.Motions
— Type.Motions(type::String, parameters::Vector{Float64})
A structure representing active motion of a joint, allowing different types of motion, can be time-dependent.
Fields
motion_type
: Allow choices of "hold", "velocity", "oscillatory", "ramp_1", "ramp_2"motion_params
: Numerical parameters provided to describe the motion
Constructors
Motions(): Provide no active motion
Motions("hold", [qJ])
: Hold the joint at constant qJ and vJ=0Motions("velocity",[qJ,vJ])
: Specify constant vJ of this joint with initial angle qJMotions("oscillatory",[amp,freq,phase])
specify a oscillatory motion through $qJ = amp*cos(2π*freq*t+phase)$Motions("ramp_1",[a,t₁,t₂,t₃,t₄])
: Describes a ramp motion in [1]Motions("ramp_2",[a])
: Describes a decelerating motion with an initial velocity
Eldredge, Jeff, Chengjie Wang, and Michael Ol. "A computational study of a canonical pitch-up,
pitch-down wing maneuver." In 39th AIAA fluid dynamics conference, p. 3687. 2009.
Functions
(m::Motions)(t)
: Evalutes the motion type at time t, return joint angle qJ and velocity vJ
Dyn3d.ConfigDataType.NumParams
— Type.NumParams(tf::Float64,dt::Float64,scheme::String,st::Int,tol::Float64)
Numerical parameters needed for the time marching scheme.
Fields
tf
: The end time of this rundt
: Time step sizescheme
: Applies the implicit Runge-kutta method of different coefficient, choices are "Liska"(2nd order), "BH3"(3rd order), "BH5"(4th order), "Euler"(1st order), "RK2"(2nd order), "RK22"(2nd order).st
: The number of stages of this RK schemetol
: Tolerance used in time marching for adptive time step
Dyn3d.ConstructSystem.Soln
— Type.This module construct the body-joint system by: 1. AddBody 2. AddJoint 3. AssembleSystem
Dyn3d.ConstructSystem.AddBody
— Method.AddBody(id::Int, cf::ConfigBody)
Using ConfigBody information, add one body to the body system bs
Dyn3d.ConstructSystem.AddJoint
— Method.AddJoint(id::Int, cf::ConfigJoint)
Using ConfigJoint information, add one joint to the joint system js
Dyn3d.ConstructSystem.AssembleSystem
— Method.AssembleSystem(bs::Vector{SingleBody}, js::Vector{SingleJoint}, sys::System)
With body system bs and joint system js, fill in extra hierarchy information about the whole system, connects bodies and joints.
Dyn3d.ConstructSystem.BuildChain
— Method.BuildChain(cbs::Vector{ConfigBody}, cjs::Vector{ConfigJoint}, csys::ConfigSystem)
Put AddBody, AddJoint and AssembleSystem in sequential order in a single function
Index
Dyn3d.ConfigDataType.ConfigBody
Dyn3d.ConfigDataType.ConfigJoint
Dyn3d.ConfigDataType.ConfigSystem
Dyn3d.ConfigDataType.Dof
Dyn3d.ConfigDataType.Motions
Dyn3d.ConfigDataType.NumParams
Dyn3d.ConstructSystem.Soln
Dyn3d.ConstructSystem.AddBody
Dyn3d.ConstructSystem.AddJoint
Dyn3d.ConstructSystem.AssembleSystem
Dyn3d.ConstructSystem.BuildChain