FMBD fem exercises

advertisement
Flexible multibody dynamics — Exercises
A Finite Element Approach
R.G.K.M. Aarts
Edition 2021/2022
© 2020–2022. Copyright R.G.K.M. Aarts, Universiteit Twente, Enschede.
All rights reserved. No part of this work may be reproduced, in any form or by any means,
without the explicit and prior permission from the author. Permission to print a hardcopy of this
document is granted to students participating in courses of the University of Twente.
The cover image shows a model of a 2-DOF manipulator with compliant joints and is © S.E. Boer.
1
General remarks about “template” files
For the following exercises MATLAB scripts can be downloaded in which a considerable part
of the code has already been typed, such that you can focus on implementing the final parts
after studying and understanding the relevant theory. These files are called “template” files and
-TEMPLATE is included in the filename.
It is strongly advised to make a copy of the file or at least rename it. In fact, you have to remove
the -TEMPLATE part from the filename as it can’t be run in MATLAB otherwise. This procedure
is imposed to avoid that you may overwrite your own files if you download these “template”
files once more in the future.
Note that it is also advised to remove the first comment, lines 2–10, as the line numbers mentioned in the exercises are incorrect with this comment included.
1
Sliding rigid bar
Consider Example 3.2.1 in the reader, see also Fig. 1. In this example the motion of a rigid
bar is analysed of which one end p moves horizontally and the other end q vertically. In that
example the horizontal velocity of point p is prescribed. The angle of the bar doesn’t play a role
and hence a (rigid) planar truss is well suited for the analysis. In this exercise we consider two
cases: First the motion is described as above, Fig. 1(a). Next the motion will be prescribed by
defining the angle β(t) as a function of time instead, Fig. 1(b).
y
y
q
β
p
q
β
1
1
p
v
x
√
x
√
3
(a) Prescribed position xp (t)
3
(b) Prescribed rotation β = βp = ϕp (t)
Figure 1: Example of a sliding bar in an arbitrary configuration.
Prescribed position xp (t)
First we would like to reformulate the analysis in the reader somewhat. Consider the system
shown in Fig. 1(a), so with a horizontal velocity v prescribed in node p. More precisely, the
position xp is prescribed as
xp (t) = −l0 + v t,
(1)
2
with length l0 = 2 m and velocity v = 4 m/s in numerical simulations. The time t is limited to
the range t ∈< 0, 2l0 /v >.
This system is modelled with a sliding truss, so the list of coordinates x is given in Eq. (3.2.1)
and there is a single deformation being the elongation ε1 of Eq. (3.2.2). Its deformation function
can be written as
q
ε1 = D1 (x) = (xq − xp )2 + (yq − yp )2 − l0 ,
(2)
where the actual length of the element according to Eq. (3.2.3) has been substituted. The superscript (k) has been omitted for readability. An expression for the first derivative D1,x , the
Jacobian, of this function is given in Eq. (3.2.4)
To align with the notation that is used in reader from Sect. 3.3 onwards, we reorder the nodal
coordinates. The fixed coordinate(s) are collected in x(o) , the dependent coordinate(s) in x(c)
and the independent coordinate(s) in x(m) . The vector with all coordinates is then

x(o)



x =  x(c)  ,
(3)
x(m)
see e.g. Eq. (3.3.4).
Similarly also the deformations are ordered, but that is simple in this example as only a rigid
deformation is considered which is denoted as ε(o) . The associated deformation function is then
also written as D (o) . Obviously rigid deformations are always zero, so D (o) = 0 by definition.
Next also the derivative of the deformation function is split into parts similar to the coordinate
vector, so
h
i
(o)
(o)
(o)
D,x(o) = D,x(o) D,x(c) D,x(m) .
(4)
Position analysis
In the kinetic analysis the fixed coordinate(s) x(o) and independent coordinate(s) x(m) are
known. Hence the goal of the position analysis is to compute the dependent coordinate(s) x(c) ,
so yq of the truss in this exercise. For this we need to solve the non-linear constraint equation
for the rigid deformations D (o) (x) = 0.
A numerical solution can be found with the iterative Newton–Raphson procedure. We start with
an initial guess x0 for the coordinates. In general, the constraint equation is not satisfied for this
solution, so D (o) (x0 ) ̸= 0. Next we use a Taylor series to estimate the change of the constraint
equation for a (small) change ∆x of the coordinates:
D (o) (x0 + ∆x) = D (o) (x0 ) + D,x(o) ∆x + t.o.h.
(5)
Ignoring the terms of higher order (t.o.h.) and using the partitioning of Eq. (4) we write
(o)
(o)
(o)
D (o) (x0 + ∆x) ≈ D (o) (x0 ) + D,x(o) ∆x(o) + D,x(c) ∆x(c) + D,x(m) ∆x(m) .
3
(6)
As only the dependent coordinates x(c) are unknown, the other parts don’t need to be updated
and hence ∆x(o) = 0. Furthermore, the goal is to make D (o) (x0 + ∆x) = 0 and hence we
obtain
(o)
D (o) (x0 ) + D,x(c) ∆x(c) ≈ 0.
(7)
Then the best linear approximation for the update of the dependent coordinates is
h
i−1
(o)
∆x(c) ≈ − D,x(c)
D (o) (x0 ).
(8)
This correction to the dependent coordinates x(c) can be applied iteratively until some tolerance
||D (o) (x)|| < ϵtol is met.
This position analysis will be done with the help of a MATLAB script sliding_truss.m. An
incomplete version of this script is provided that you can complete as outlined in the following
exercises. Don’t forget the remarks about these “template” files on page 2.
a. Check that you understand the description above about the position analysis with Newton–
Raphson iterations. Also download the template of the script sliding_truss.m and
try to understand the first parts. You should recognize that the coordinate vector x1
is defined for the truss element (line 34), but that the coordinates are also ordered into
a “system level” coordinate vector x (line 45). The term “system level” is somewhat
exaggerated for this simple system consisting of a single truss element, but is used in
agreement with the notation for more complex systems.
In lines 49 and 61 the deformation function, i.e. the truss elongation, and its Jacobian are
computed respectively. For these calculations two functions truss_D and truss_Dx
are defined near the end of the script file. You should recognize the expressions from the
reader.
In lines 73–75 the Jacobian is split into the three partitions of Eq. (4).
In lines 85–92 MATLAB functions are defined for the deformation function and the three
partitions of the Jacobian. In this way it is rather simple to use these functions in the
calculations to follow. Note that the functions can be called with symbolic as well as
numerical parameters.
In line 110 a loop starts where the time evolves in the interval specified before. The
prescribed coordinate xp is computed with Eq. (1).
Next you need to add a few steps to the script:
Line 116: Specify how to compute the estimated update ∆x(c) with Eq. (8). Consider
using one or more of the functions Do_fun, Doxo_fun, Doxc_fun and Doxm_fun
defined a few lines above.
Line 119: Update yq in variable yq_num.
If everything is correct, two figures will open when running the script. One shows the
moving truss. The second plot from line 131 should show only two curves as the Newton–
Raphson approximation should match the exact value of yq very well.
4
Velocity analysis
(k)
Using the expression for the derivative D1,x of Eq. (3.2.4) directly results in the velocity equation (3.2.7a) from which the unknown velocity ẏp follows easily in Eq. (3.2.7c). As already
used in the position analysis, the rigid deformations are always zero by definition, so D (o) = 0
and hence also for its time derivative applies that D,x(o) ẋ = 0, which is actually applied in
Eq. (3.2.7a). Combining this constraint equation for the derivative with the partitioning of
Eq. (4) gives
(o)
(o)
(o)
D,x(o) ẋ = D,x(o) ẋ(o) + D,x(c) ẋ(c) + D,x(m) ẋ(m) = 0.
(9)
The fixed coordinates don’t change, so ẋ(o) = 0. Then
(o)
(o)
D,x(c) ẋ(c) + D,x(m) ẋ(m) = 0,
(10)
so finally the velocities of the dependent coordinates ẋ(c) can be related to the independent
velocities ẋ(m) as
h
i−1
(o)
(o)
(c)
D,x(m) ẋ(m) ,
(11)
ẋ = − D,x(c)
h
i−1
(o)
assuming the inverse D,x(c)
exists. That should be true as the inverse is already used in
Eq. (8) of the Newton–Raphson procedure for the position analysis.
This velocity analysis will be done by checking the equations “manually” and with the help of
the MATLAB script sliding_truss.m already used for the position analysis.
b. Show that the same result for velocity ẏq is obtained as in Eq. (3.2.7c) when the equations
are rewritten as outlined above.
You can use the MATLAB script sliding_truss.m for this with a bit of editing:
Line 145: Complete the expression to compute ẋ(c) in xcdot from ẋ(m) in xmdot.
Consider using one or more parts of the Jacobian D,x(o) , see Doxo, Doxc and Doxm in the
position analysis section (lines 73–75).
Check the output from lines 162–163.
Acceleration analysis
Finally, the MATLAB script sliding_truss.m also offers a section for the acceleration analysis and a numerical simulations of the results so far.
c. Argue that with this reformulation the accelerations of the dependent coordinates ẍ(c) can
be related to the independent velocities ẍ(m) and previously computed velocities ẋ as
h
i−1 (o)
(o)
ẍ(c) = − D,x(c)
D,x(m) ẍ(m) + (D,xx ẋ) ẋ ,
(12)
from which the same analysis and results for ÿq as in Eqs. (3.2.8a) to (3.2.8e) follow.
You can again use the MATLAB script sliding_truss.m for this. As programming
with the Hessian can be quite confusing, you get this “for free” in this exercise.
Check the output from lines 201-202.
5
d. Running the MATLAB script sliding_truss.m completely will open a plot showing
a simulation of the bar with constant velocity ẋp = v. If the variable createmovie
is true the plot of the simulation is stored in a movie file that can be opened with your
favourite media player. You can change some of the parameters if you like. One set of
arrows indicate the velocities at the ends of the bar; the other arrows are the accelerations.
Do you have an idea why the simulation doesn’t begin and end with a horizontal bar?
Do you agree with the direction of ẏq and ÿq ?
To reuse the functions truss_D, truss_Dx and truss_Dxx in future scripts, consider
storing these in a private subfolder of the folder in which you write your scripts.
Prescribed rotation β = βp = ϕp (t) (β0 = 0)
Next we consider the system in which the motion is prescribed by defining the angle β(t) as a
function of time instead.
e. Argue that in this case a model with a planar truss element is less suited for the analysis,
but that a rigid or flexible beam element would be a better choice. Which of these options
is then preferable?
In the remaining of this exercise the sliding bar will be modelled with a rigid beam element.
For a rigid beam element the coordinates are defined in Eq. (3.2.11) of the reader as


rp
T
(k)
.
(13)
xrigid beam =  ϕp  = xp , yp | ϕp | xq , yq
rq
There are two deformations that are written in Eq. (3.2.14) as
q
(k)
(k)
(k)
(k)
ε1 = D1 (x ) = (xq − xp )2 + (yq − yp )2 − l0 = 0 ,
(k)
(k)
ε2 = D2 (x(k) ) = −(xq − xp ) sin βp + (yq − yp ) cos βp = 0 ,
(14a)
(14b)
with βp = βo + ϕp as defined in Eq. (3.2.15). The initial configuration of the bar is β0 =
0 rad. The rotation is defined with a constant angular velocity ω by prescribing the rotational
coordinate as
ϕp (t) = ωt .
(15)
Expressions for first and second derivatives of the deformation functions are given in Eqs. (3.2.16).
A MATLAB script sliding_rbeam.m is provided to get started. In the exercise it is outlined
what you have to add or modify in this script. Don’t forget the remarks about these “template”
files on page 2.
The script basically proceeds similar to the previous case with the truss, with one main difference: The position analysis is now integrated in the simulation and visualisation loop. Then all
equations for the position, velocity and acceleration analysis are defined first after which these
are all used in the right order in the loop.
6
f. Again set up a model of the sliding bar with a rigid beam element and split the coordinates
again in the three parts x(o) , x(c) and x(m) .
In MATLAB script sliding_rbeam.m:
Lines 41 and 43: Specify the respective nodal coordinates. See also the example in line
39.
g. Argue that both deformations are rigid such that D (o) is now a vector function that gives
(k)
(k)
two results, i.e. ε1 and ε2 .
In MATLAB script sliding_rbeam.m:
Lines 50–59 and function rbeam_D towards the end of the script: Verify that this has
already been implemented correctly.
h. Continue the velocity analysis to compute all velocities and verify that you can redo the
analysis in the first part for the configuration and motion specified in Example 3.2.1 in
the reader.
In MATLAB script sliding_rbeam.m:
Lines 76–78: Specify the respective indices. Instead of using numerical values, consider
using the variables ind_xo, ind_xc ad ind_xm introduced a few lines before.
Lines 96–98: Check that the velocities are computed correctly.
Line 117: Specify the correct value for omega expressed in v. For this purpose you have
to figure out for which ẋ(m) = ϕ̇p = ω node p moves with a horizontal velocity v as in
the reader. Then you can check the output from lines 119–120.
i. Continue with the acceleration analysis to compute all accelerations and verify once more
that you can redo the analysis in the first part for the configuration and motion specified
in Example 3.2.1 in the reader.
In MATLAB script sliding_rbeam.m:
Line 137: Check that the indices in index_x are in the correct order.
Lines 139–140 and function rbeam_Dxx: You get the code with the Hessian “for free”.
Lines 143–149: Check that the accelerations are computed correctly.
Lines 160 and 162: Specify the correct value for omega (see above) and omega_dot.
For this purpose you have to figure out for which ẍ(m) = ϕ̈p = omega
˙ node p moves with
a constant horizontal velocity v as in the reader. Then you can check the output from
lines 164–165.
j. The final part of the MATLAB script sliding_rbeam.m will open a plot showing a
simulation of the bar with constant angular velocity ϕ̇p = β̇. Before it runs, you should
complete the position analysis.
In MATLAB script sliding_rbeam.m:
Lines 223 and 224: Update the coordinates xp_num and yq_num making use of previously computed results.
If the variable createmovie is true the plot of the simulation is stored in a movie
file that can be opened with your favourite media player. You can change some of the
parameters if you like. As before, one set of arrows indicate the velocities at the ends of
the bar; the other arrows are the accelerations.
7
To reuse the functions rbeam_D, rbeam_Dx and rbeam_Dxx in future scripts, consider
storing these in a private subfolder of the folder in which you write your scripts.
2
Slider crank – Kinematic analysis on system level
Reconsider Example 3.4.2 in the reader, see also Fig. 2. In the reader we didn’t care about
the angle of the connecting rod, β34 in the reader, that was just used to simplify some of the
equations. In this exercise this angle is explicitly included in the list with coordinates.
y
↶
⃗3 4
1
Ω
↶
⃗1 2
2
ϕ2 = 60◦
ϕ4 = −30◦
⃗5
x
Figure 2: Finite element model of the slider-crank mechanism.
a. Argue that the model in the reader with one rigid beam for the crank and one truss for the
connecting rod is not suited for the analysis as proposed above. Reason that a model with
two ridig beams instead is well-suited for this purpose.
In the remainder of this exercise this model with two rigid beams will be set up. Hence the
numbering of the coordinates in Fig. 2 is also somewhat different compared to the reader. More
specifically, the translational node of the slider is now number 5. That is caused by the introduction of a rotational node, number 4, that describes the angle of the connecting rod. This was
β34 in the reader, but is denoted with coordinate ϕ4 in this exercise.
For getting started it is advised to study and understand the model of Example 3.4.2 in the reader
first. Note that you can also download a MATLAB script to check that kinematic analysis. It is
not needed for this exercise. Instead an incomplete MATLAB script slider_crank_kin.m
is provided that you can complete as outlined in the following exercises. Don’t forget the
remarks about these “template” files on page 2.
In addition,the functions rbeam_D, rbeam_Dx and rbeam_Dxx for the rigid beam element
defined in the previous exercise are assumed to be available from the Matlab path or a private
subfolder.
b. The slider-crank mechanism is driven by prescribing the angle ϕ2 (t) of the crank as a
function of time. More specifically, the initial angle ϕ2 (0) = 0 and its initial velocity
8
ϕ̇2 (0) and (constant) acceleration ϕ̈2 are known. Use this information to classify the
coordinates in fixed x(o) , dependent x(c) , and independent coordinates x(m) .
In the MATLAB script slider_crank_kin.m edit:
Lines 52, 54 and 56: Specify the respective nodal coordinates.
Lines 67–79: Check the deformation functions. Are there indeed 4 deformations?
c. Complete the system level Jacobian D,x , split it into parts and use these to compute all
velocities ẋ.
In the MATLAB script slider_crank_kin.m edit:
Lines 104–106: Check that you get meaningful results for the three parts of D,x .
Line 126: Edit to compute ẋ(c) .
Do you get the correct output in lines 136–139?
d. Alternatively we can use the first-order geometric transfer functions F,q (and E,q ) to compute ẋ (and ε̇) directly from q̇ as
ẋ = F,q q̇ ,
(16)
ε̇ = E,q q̇ ,
(17)
and
where the independent coordinates and deformations have been collected in vector q.
In the MATLAB script slider_crank_kin.m edit:
Line 148: Edit to compute the matrix D(c) as defined in the reader.
Line 149: Edit to compute F,q(c) .
Do you get the correct output in lines 160–162?
Argue that E,q is trivial for this system.
e. A similar procedure is followed for the accelerations ẍ. First these are computed directly,
using the known velocities.
In the MATLAB script slider_crank_kin.m:
Lines 170–184: Once more you get the equations with the Hessians “for free”. Check
that you understand what is going on here.
Line 189: Edit to compute ẍ(c) .
Do you get the correct output in lines 199–203?
f. Next the second-order geometric transfer functions F,qq (and E,qq ) are used to compute ẍ
(and ε̈) directly
ẍ = F,q q̈ + (F,qq q̇) q̇ ,
(18)
ε̈ = E,q q̈ + (E,qq q̇) q̇ .
(19)
and
In the MATLAB script slider_crank_kin.m edit:
(c)
Line 214: Edit to compute F,qq
.
Do you get the correct output in lines 225–227?
Argue that E,qq is trivial for this system.
9
g. Running the MATLAB script slider_crank_kin.m completely will open a plot showing a simulation of the mechanism driven with a constant angular velocity of the crank
ϕ̇2 . If the variable createmovie is true the plot of the simulation is stored in a movie
file that can be opened with your favourite media player. You can change some of the
parameters if you like. As before, one set of arrows indicate the velocities at the ends of
the bar; the other arrows are the accelerations. Do you agree with the direction of these
velocities and accelerations?
Some concluding remarks about the script. In this exercise all equations are set up symbolically
which includes the computations of some matrix inverses. It is not recommended to do that for
more complicated systems, so in future exercises this will be arranged differently. One may
also note that the interface to various functions is somewhat “unhandy” as all coordinates need
to be specified (in the correct order), whereas interfacing with e.g. the global coordinate vector
x would be more logical. Also this will be taken care of in future exercises.
Furthermore, note that in this and the previous exercises 1-DOF systems have been investigated.
For such systems, the second order geometric transfer functions F,qq and E,qq are relatively easy
to handle as two of the three dimensions are just 1, such that these expressions effectively look
like a vector. For a thorough understanding it is essential to practice with a more complicated
system as well. The 2-DOF systems presented in the reader can be a good starting point for
this. One can try to understand the analysis presented there first and next consider extensions or
variations of those systems, such as using different elements (if possible). In these exercises a
multi-DOF will appear when flexibility is introduced for the connecting rod in the slider-crank
mechanism.
The following exercises are from course year 2020/2021
and have not been updated yet.
3
Slider crank – Dynamic analysis on system level
Reconsider Example 4.7.2 in the reader, see also Fig. 3. In the reader we didn’t care about
the angle of the connecting rod, β34 in the reader, that was just used to simplify some of the
equations. In exercise 2 this angle was explicitly included in the list with coordinates.
In the reader a dynamic analysis is presented to compute the driving torque τ2 and constraint
forces for a prescribed rotation of the crank. In that model a rigid beam and a truss are used.
Mass m5 is assumed to be concentrated in node 5 (according to the numbering in this exerise)
and mass m2 is distributed homogeneously along the connecting rod 2 . In this exercise we
continue the analysis using the model from exercise 2, so with two rigid beams.
For getting started it is once more advised to study and understand the model of Example 4.7.2 in
the reader first. Note that you can also download a MATLAB script to check that dynamic analysis. It is not needed for this exercise. Instead an incomplete MATLAB script slider_crank_dyn.m
is provided that you can complete as outlined in the following exercises. Don’t forget the remarks about these “template” files on page 2.
For the final part of this exercise two additional files are supplied: A SIMULINK model slider_crank_simul.
10
y
↶
⃗3 4
1
Ω, τ2
↶
⃗1 2
2
m2
β2 = 60◦
⃗5
β4 = −30◦
x
m5
Figure 3: Finite element model of the slider-crank mechanism with masses m2 of the connecting
rod and m5 of the slider.
Scope phi2
PD(s)
phi2 reference
PD Controller
Interpreted
MATLAB Fcn
slider_crank_phi2ddot
Figure 4:
SIMULINK
Interpreted
MATLAB Fcn
phi2dot
phi2
slider_crank_plot
model to simulate the rigid slider-crank system.
(suited for SIMULINK versions R2018a and newer), which calls a MATLAB function slider_crank_plo
for visualisation, see also Fig. 4.
a. It is assumed that you completed the kinematic analysis of exercise 2 before starting the
following dynamic analysis.
In the MATLAB script slider_crank_dyn.m:
In lines 10–17 it is checked that the results from the kinematic analysis are still available
in the current MATLAB session. If needed the kinematic analysis is redone. It is not
advisable to clear all variables in your workspace after each test.
b. Indicate which forces (or torques) contribute to the force vector f , or more specifically
its parts f (o) , f (c) and f (m) . Outline how e.g. gravity could be added to the force vector.
In the MATLAB script slider_crank_dyn.m:
In lines 35 only f (c) is initialised to zero which can be changed if desired, but then the
outcome will differ from the analysis in the reader.
c. In in the reader mass m2 is modelled with the consistent mass formalism. Argue that a
lumped description is indeed not possible in Example 4.7.2.
Argue that for the model is this exercise both mass modelling approaches can be used and
derive the resulting mass matrices for both approaches. Also show how the total system
mass matrix M is obtained then.
11
In the MATLAB script slider_crank_dyn.m:
In lines 46 and 52 add expressions to compute the element mass matrix M (2) for the connecting rod. Use m2l for the lumped approach and m2c for the consistent formulation,
respectively.
In lines 62 and 63 show how the mass m5 can be added to the system mass matrix. Note
that Mc and Ml refer to the system mass matrices that are obtained with the consistent or
lumped approach, respectively, but refers to mass m2 , see lines 67 and 68. For mass m5
only one approach is used, so both additions to lines 62 and 63 are identical.
In lines 71 and 72 show how Mcbar and Mlbar can be computed which refer to the
reduced mass matrix M̄ which is obtained either from the system mass matrix with the
consistent or lumped approach, respectively. Consider using a simplify in your MATLAB expression.
In line 77 the difference between the reducers mass matrices according to both methods
is evaluated. Should this be zero (or not) and do you get the expected result?
Finally, in lines 90–92 the result is compared to the reduced mass given in the reader for
the specific configuration shown in Fig. 3 as well.
d. The equation of motion for this example is shown in Eq. (4.7.25) of the reader:
h
i
(c)
(c)
M̄ q̈ = F,q(c)T f (c) − M (c,c) (F,qq
q̇) q̇ + f (m) − M (m,c) (F,qq
q̇) q̇ ,
(20)
Use it to compute the driving torque τ2 . Check your results with those in the reader.
In the MATLAB script slider_crank_dyn.m:
In line 108 add an expression to compute f (m) .
Do you get the correct output in lines 122–124?
e. The constraint forces in the supports are calculated in the reader by first determining the
stress resultant vector σ (o) in Eq. (4.7.34):
i−1 h
(o)T
(o)
σ = D,x(c)
f (c) − M (c,c) ẍ(c) − M (c,m) ẍ(m) ,
(21)
and with this result the vector of reaction forces f (o) is obtained in Eq. (4.7.37):
(o)T
f (o) = D,x(o) σ (o) + M (o,c) ẍ(c) + M (o,m) ẍ(m) ,
(22)
Use these expressions to compute the support forces f (o) . Check your results with those
in the reader.
In the MATLAB script slider_crank_dyn.m:
In lines 147 and 159 add an expressions to compute σ (o) and f (o) .
Do you get the correct output in lines 155–157 and 167–169?
f. Finally, the equation of motion can be reconsidered to simulate the system with a prescribed force/moment instead of prescribed motion. In this example Eq. (20) can be
rewritten as
h
h
i
i
(c)T
(c)
(c)
−1
(c)
(c,c)
(m)
(m,c)
q̈ = M̄
F,q
f −M
(F,qq q̇) q̇ + f
−M
(F,qq q̇) q̇ , (23)
from which the acceleration q̈ can be computed for a prescribed driving force/moment
f (m) and know configuration q and velocity q̇.
12
In the MATLAB script slider_crank_dyn.m:
In line 184 add an expressions to compute q̈.
To simulate the motion of the slider-crank, we have to solve the ordinary differential equation (ODE) (23) by integrating q̈ twice as a function of time. Instead of writing our own
ODE solver, we can also use one of MATLABś options, e.g. the general purpose ode45.
The ODE can be solved in MATLAB or alternatively with a SIMULINK model. The
latter is offered in the file slider_crank_simul.slx available for download and
suited for SIMULINK versions R2018a and newer. This model calls a MATLAB function
slider_crank_phi2ddot.m to compute q̈ = ϕ̈2 . This function is generated in lines
193–197 of slider_crank_dyn.m. For visualisation slider_crank_plot.m
which can be downloaded. It assumes the dimensions as defned before in this exercise,
but these can be modified in the script if needed.
In the simulation the motion of the crank is controlled with a PD-controller that should
have correct settings for dimensions of the links and masses as defined before in this
exercise. The “Scope” window shows the desired and realised angle ϕ2 and the driving
torque τ2 as generated by the PD-controller.
As for the kinematic analysis, it is strongly recommended to consider at least one 2-DOF example as well.
4
Flexible slider crank
Reconsider Example 4.10.1 in the reader, see also Fig. 5. To simulate the bending of the connecting rod, this part of the system will now be modelled with one or more flexible planar beam
elements.
y
(a)
A
v
Ω
B
O
x
y
lc
(b)
O
lr
B
A
x
Figure 5: (a) Slider–crank mechanism with a flexible connecting rod. (b) Initial configuration.
13
Interpreted
MATLAB Fcn
phi2(0)
slider_crank_plot
Scope bending
phi2
Interpreted
MATLAB Fcn
phi2dot(0)
phi2dot
slider_crank_flex_qd_ddot
qd_dot
qd
phi2(d(d)ot)
phi2ddot
Figure 6:
SIMULINK
model to simulate the flexible slider-crank system (one flexible beam).
Length crank
l1
Length connecting rod
l2
Constant angular speed crank ϕ̇2
Total mass connecting rod m2
Total mass slider m5
Bending stiffness parameter connecting rod EI
0.15
0.30
150
0.06676
m2 /2
12.72
m
m
rad/s
kg
kg
N m2
Table 1: Dimensions, mass and stiffness properties of the flexible slider-crank mechanisms.
Part 1: One flexible beam
The simple deformations as introduced initially in the reader will be used, i.e. Eqs. (3.2.28).
Only flexibility due to bending in one flexible (planar) beam element is considered, so deformations ϵ2 and ϵ3 . In other words, the elongation ϵ1 is considered to be rigid. Mass and stiffness
properties are also taken from the reader. Note that these are different from the previous exercises and summarised in Table 1.
For getting started it is advised to look at Example 4.10.1 in the reader first. Note that you can
also download a MATLAB MATLABscript to redo that dynamic analysis. It is not needed for this
exercise. Instead an incomplete MATLAB script slider_crank_flex.m is provided that
you can complete as outlined in the following exercises. Don’t forget the remarks about these
“template” files on page 2.
In addition a SIMULINK model slider_crank_flex_simul.slx is provided (suited for
SIMULINK versions R2018a and newer), which calls the MATLAB function for visualisation
slider_crank_plot.m from the previous exercise.
If you have installed the SPACAR software already, you can compare your simulation results
with an analysis using the SPACAR input file slider_crank_flex.dat, but this is optionally.
a. At first the kinematic analysis is set up. Argue that there are 3 DOFs in case the crank
rotation is prescribed and flexibility is described by the bending modes of the connecting
rod modelled with one flexible planar beam element. In the remaining of this exercise the
(2)
(2)
angle ϕ2 of the crank and the bending deformations ε2 and ε3 of the connecting rod are
defined as the degrees of freedom.
In the MATLAB script slider_crank_flex.m:
14
Complete and check the kinematic analysis up to line 242.
In particular add the computation of F,q(c) in line 149 and ẍ(c) in line 239.
b. Continue with the dynamic analysis. First the force vector and mass matrix are defined.
In this case the consistent formulation for a flexible beam has to used. Next to the mass
matrix, also the velocity dependent inertia vector h has to be taken into account. The vector q with the degrees of freedom has to be split in the dynamic and rheonomic parts, i.e.
q d and q r . The latter is the prescribed motion and then the dynamic degrees of freedom
can be simulated from the ordinary differential equation (4.5.12) in the reader:
M̄dd q̈ d = fd − M̄dr q̈ r ,
(24)
where
M̄dd = F,qTd M F,qd ,
fd =
h
(c)T
F,qd
(m)T
F,qd
M̄dr = F,qTd M F,qr ,
(25a)
""
# " (c,c) #
#
"
#
i f (c) − h(c)
h
i σ (m)
M
(m)T
(c)T
(c)
−
(F,qq
q̇) q̇ − E,qd E,qd
.
(m)
(m)
(m,c)
f
−h
M
σ (c)
(25b)
In the MATLAB script slider_crank_flex.m:
Complete and check the dynamic analysis.
In particular generate the mass matrix in lines 282 and 286.
Compute fd in line 352 and q̈ d in line 355.
Note that the result is written to a file as a MATLAB function slider_crank_flex_qd_ddot.m
for use in the next part.
c. The ordinary differential equation of the flexible slider-crank is simulated in SIMULINK
model slider_crank_flex_simul.slx, see Fig. 6. A function slider_crank_flex_qd_
(2)
needs to be supplied which is called to compute ϕ̈4 and ϕ̈6 as functions of ϕ2 , ϕ̇2 , ϕ̈2 , ε2 ,
(2) (2) (2)
ε̇2 , ε3 , ε̇3 .
(2)
(2)
This simulation computes the deformations ε2 and ε3 from which the deflection v as
shown in Fig. 4.10.3 in the reader can be derived. For this purpose, the deformation along
the flexible beam can be computed with Eqs. (4.3.21a), (4.3.22a) and (4.3.22b) from the
reader. In Fig. 4.10.3 the relative deflection is computed in the middle of the beam which
equals
v̄( 12 ) = ε2 Nv̄p ( 12 ) + ε3 Nv̄q ( 12 ) = 81 (ε2 + ε3 ) ,
(26)
where shear deformation is neglected, i.e. Φ = 0. To obtain the same plot, the deformation
has to be scaled with the length l2 of the connecting rod.
In the MATLAB script slider_crank_flex.m:
The SIMULINK model is open and run. Afterwards the scaled deflection v/l2 is shown in
a graph as a function of angle ϕ2 using Eq. (26).
15
d. [Optional] If you have already installed the SPACAR software, you can check your simulation results by comparing it to the results from a SPACAR simulation with the input file
slider_crank_flex.dat.
In the MATLAB script slider_crank_flex.m:
SPACAR is called if installed correctly. Afterwards the scaled deflection v/l2 is shown in
a graph as a function of angle ϕ2 for both the previously obtained result and the SPACAR
output.
Part 2: One or more flexible beams, elongation rigid or flexible
Next, the model of the previous part is extended such that is can handle more than one flexible
beam element for the connecting rod. Also flexibility due to elongation ϵ1 may be taken into
account. Still the simple deformations as introduced initially in the reader will be used, i.e.
Eqs. (3.2.28). Mass and stiffness properties are not changed, see Table 1.
An important difference with the previous model is that for this more complicated model the
“cheat” solution for the non-linear constraint equations of the position problem is not readily available. Hence a numerical solution has to be implemented for this part, e.g. using the
Newton–Raphson scheme of Sect. 3.5 in the reader. The time integration is once more taken
care of by one of MATLAB’s standard ODE solvers, e.g. by using ode45 in SIMULINK.
qr
phi2(0)
phi2
qr_dot
qr_ddot
phi2dot
Scope bending
Flexible slider-crank
2 flexible beams
Only major timestep
slider_crank_num_plot
xplot
elongation rigid
qd
phi2dot(0)
Interpreted
MATLAB Fcn
vl
qd_ddot
qd_dot
qd_dot
Flexible slider-crank
qd
phi2ddot
Figure 7:
beamx).
SIMULINK
model to simulate the flexible slider-crank system (one or more flexible
A combination of MATLAB and
(partly) available for download:
SIMULINK
files are used to set up this simulation, which are
slider_crank_num_simul.slx is the main SIMULINK model (suited for SIMULINK
versions R2018a and newer), see Fig. 7. It can be used as provided, but it calls the next
two MATLAB functions which must be available.
slider_crank_num_plot.m takes care of a visualisation of the (flexible) slider crank.
The crank rotates about the origin O. Input of the function are the coordinates of the
connecting rod. For each node three coordinates must be specified, i.e. x, y and angle ϕ.
Note that in the SIMULINK model a RateTransition block is put in from of the block
that calls this function. In this way the visualisation is only called at so-called major time
steps during the simulation. Higher order ODE solvers with a variable time step like the
16
default ode45 employ intermediate time steps and may also step back in time before
obtaining a solution for one time step with specified accuracy. If all these intermediate
time steps are visualised, a very irregular motion may appear.
slider_crank_num_gw.m is a gateway function that takes care of most of the “bookkeeping” needed for SIMULINK. This is needed as in this model it has been chosen to
use a so-called S-function to program the model of the flexible beam. This S-function has
the advantage of more features in its interface, like multiple inputs and outputs as well
as passing additional parameters, however at the expense of being more complicated. To
separate the required “bookkeeping” from the “real” model, this gateway function takes
care of the first part. There should be no need to modify the provided script. It calls the
next function which does the actual computations. Just note that two parameters can be
modified in the SIMULINK block:
nbeams specifies the number of flexible beams in the connecting rod. It is a variable
of type double, but only integer values in the range from 1 to 10 (including these
limits) are accepted.
eps1flex is a logical variable that can be false or true to indicate whether the
elongation ϵ1 should be considered flexible or not.
slider_crank_num.m does the “real” job. The interface is defined as
function [ vl, xplot, qd_ddot ] = slider_crank_num( ...
qr,qr_dot,qr_ddot,qd,qd_dot,nbeams,eps1flex)
It should compute the outputs:
vl is the midpoint deflection v of the flexible connecting rod, scaled with its length l2 .
xplot is the vector with the coordinates that are required as inputs for the visualisation
function slider_crank_num_plot described above.
qd_ddot is the computed acceleration of the dynamic degrees of freedom q̈d , so the
outcome of the equations of motion. SIMULINK’s ODE solver integrates it twice to
compute q̇d and qd , see below.
The inputs are:
qr, qr_dot and qr_ddot specify the prescribed motion expressed in the rheonomic
degrees of freedom qr and its time derivatives q̇r , q̈r .
qd and qd_dot are the dynamic degrees of freedom qd and its time derivative q̇d that
(completely) describe the current configuration of the system.
nbeams and eps1flex are the two additional parameters introduced above.
For this file an incomplete “template” file is provided for which the remarks on page 2
apply. During this exercise the file will be completed to compute the outputs from the
inputs.
17
While programming the function slider_crank_num you may appreciate debugging the
provided and your own code. For this you can call the function directly from the MATLAB
command prompt or from another script, but then you have to assure all parameters are provided
with meaningful input. Alternatively, you can also use all debug options like breakpoints and
inspecting variables when you run the SIMULINK simulation. Just add a breakpoint in the script,
start the simulation and SIMULINK and see what happens.
e. Re-examine the kinematic analysis. Make an overview of the fixed, dependent and independent coordinates as well as the rigid, independent and dependent deformations. Assume that the crank angle ϕO is prescribed as a function of time. Note that the number
of DOFs depends on the parameters nbeams and eps1flex. Show that the correct
number of DOF is obtained when all flexible deformations are defined as dynamic DOF.
In the MATLAB script slider_crank_num.m:
In lines 23–42 check that the physical properties are defined correctly. In particular note
that m2 represents the total mass m2 of the connecting rod, but also m2pl is defined as in
some expressions the mass per unit length shows up. Note also the computation of scalar
S1 and 2 × 2 matrix S2 that represent the contributions to the element stiffness matrix S
as in Eqs.(4.3.19) in the reader when shear effects are neglected.
Lines 45+46 specify the criteria to stop the Newton–Raphson scheme for the position
problem.
In lines 48–139 the coordinates and deformations are set up. Check whether these agree
with your ideas about this. Note that for easy access in the rest of the code four index
arrays are defined that store the indices of coordinates and deformations in the global
vectors x and e for all elements:
indx_rbeam(1:5) coordinates rigid crank in x;
indx_flbeams(k,1:6) coordinates flexible beam k in x;
inde_rbeam(1:2) deformations rigid crank in e;
inde_flbeams(k,1:3) deformations flexible beam k in e.
In lines 142+143 the number of the degrees of freedom ndof is calculated and all DOF
are collected in vector q.
f. Next the non-linear constraints for the position analysis have to be solved. More specifically, Eqs. (3.3.5) and (3.3.6) from the reader have to be satisfied:
( (o)
D (x) = ε(o) = 0,
(27)
D (m) (x) = ε(m) (t).
In other words, the coordinates x have be determined such that the residuals
"
# " (o)
#
∆ε(o)
D (x)
=
,
∆ε(m)
D (m) (x) − ε(m) (t)
(28)
are zero or at least sufficiently small, see also Eqs. (3.5.6) and (3.5.7). As outlined
in Sect. 3.5 in the reader this can be accomplished with an iterative Newton–Raphson
(c)
scheme. In iteration n for estimate x(n) of the coordinates the residuals are computed by
substituting this estimate in Eq. (28). As long as the residuals are too large, the dependent
coordinates are updated in the next iteration n+1 as
(c)
(c)
(c)
x(n+1) = x(n) + ∆x(n) ,
(29)
18
with correction
"
(c)
(c)
∆x(n) = −(D(n) )−1
(o)
∆ε(n)
(m)
∆ε(n)
#
.
(30)
(c)
(c)
Matrix D(n) is the matrix D(c) well-known from the kinematic analysis, evaluated for x(n) .
Apply this procedure to the flexible slider-crank mechanism.
In the MATLAB script slider_crank_num.m:
Lines 145–187 implement the Newton–Raphson scheme. Note that now functions are defined at the end of the script to compute the deformations and their derivatives at element
level:
function D = rbeam_D(x,l0)
function D = flbeam_D(x,l0)
function Dx = rbeam_Dx(x)
function Dx = flbeam_Dx(x)
These functions all expect the coordinates x = x(k) for a specific rigid or flexible element
ordered as in the reader. Output are the deformations D = D (k) (x(k) ) or their derivatives
(k)
Dx = D,x(k) also in the order of the reader. Some functions also need the element’s reference length l0. The index arrays introduced before now make it easy to link element
coordinates and deformations to the global vectors and matrices.
In line 186 add the correction for the next iteration.
Towards the end of the file, check the functions for the deformations and the derivatives.
Can you check how many iterations are typically needed to obtain convergence?
g. Once the position problem has been solved, the first outputs of the function can already
be computed as these only depend on the coordinates. Can you identify these outputs and
indicate how these can be computed? Does it make a difference if there is an even or odd
number of flexible beam elements in the connecting rod?
In the MATLAB script slider_crank_num.m:
In lines 192–218 the deflection in the middle of the connecting rod is computed. For this
the coordinates of the mid point M are calculated. Then the deflection v is the length of
the vector connecting points M and A onto a normal vector perpendicular to the straight
connection of points A and B. Finally, v is scaled with l2 as this is the convention of plotting the deflection in Fig. 4.10.3 in the reader.
Lines 220–226 extract the right coordinates from vector x that are needed by the visualisation function.
h. The kinematic analysis continues with the velocity analysis. The system level derivative
D,x has already been computed in the Newton–Raphson scheme, so it can be reused.
In the MATLAB script slider_crank_num.m:
In lines 249 compute the first order geometric transfer function F,q(c) .
i. The kinematic analysis is completed with the acceleration analysis. The computation of
the (system level) second order geometric transfer function F,qq can be avoided as shown
in Eq. (3.3.45a) in the reader. Instead the quadratic velocity contributions (D,xx ẋ)ẋ are
then computed at element level.
19
In the MATLAB script slider_crank_num.m:
In lines 263 Dxx_xdot_xdot is initialised to zero. This variable will be used to collect
(k)
the (D i,xx ẋ)ẋ for each deformation. The second derivatives D i,xx are computed per
element with two additional functions towards the end of the script:
function [ D1xx, D2xx ] = rbeam_Dxx(x)
function [ D1xx, D2xx, D3xx ] = flbeam_Dxx(x)
These functions all expect the coordinates x = x(k) for a specific rigid or flexible element
ordered as in the reader. The second derivatives are separate output variables D1xx,
D2xx and for the flexible beam also D3xx. Each of these can be multiplied (twice) with
the correct subset ẋ(k) of the velocity vector x_dot. By implementing it in this way, the
use of three-dimensional arrays is avoided.
In lines 273–275 compute the relevant parts of Dxx_xdot_xdot for the flexible beams.
j. Continue with the dynamic analysis. This is basically similar to the analysis in the first
part of this exercise. In the end the accelerations of the dynamic degrees of freedom q̈ d
are obtained from Eq. (24).
In the MATLAB script slider_crank_num.m:
Complete and check the dynamic analysis.
In line 281 no additional forces are applied. This can be changed e.g. to include gravity,
but that is optional as it is also not included in the simulations in the reader.
Lines 293+294 take care of the rather straightforward implementation of the lumped formulation for the mass m5 of the slider.
More elaborate is the consistent mass of the flexible beams. For the computation of the
consistent mass matrix Mkc = M (k) and velocity dependent inertia vector hkc = h(k)
at element level, one final function is added at the end of the script:
function [ Mkc, hkc ] = flbeam_Mass(m, l, phip, phiq, ...
phip_dot, phiq_dot)
It is called in lines 301+302.
In lines 303+304 add how the element Mkc and hkc should be included in the system
mass matrix M and vector h.
In lines 339 and 342 add how to compute vectors fd and finally qd_ddot, respectively.
k. If there are no remaining errors you can run the simulation with the SIMULINK model
slider_crank_num_simul.slx. For the default setting that agree with the example in the reader, the deflection is only sightly visible in the visualisation, but the plot with
the scaled deflection should closely resemble Fig.4.10.3 in the reader even though in the
reader a somewhat more complicated model has been used, i.e. including elongation and
shear effects.
Elongation can be enabled quite easily in our SIMULINK model: Double click on the
block referring to our script and enable “Elongation flexible”. If the implementation is
indeed error-free, the increase in computational effort should be most notably and the
differences in the deflection are small.
More “spectacular” results can be obtained with higher rotational speeds of the crank.
The (initial) speed can be increased or the acceleration can be set to a non-zero value.
Then it is not difficult the “break” the connecting rod. If the deformations become too
large, the Newton–Raphson scheme will not converge anymore and the simulation will
end with an error for too many iterations.
20
Download