NumericalIntegration
NumericalIntegration
Introduction
A damped structural system subjected to dynamic forces and possibly experiencing
nonlinear material behavior is modeled by
Given values for accelerations, velocities, displacements, and applied forces at time ti , if we
can extrapolate the velocities and displacements forward in time by a time step h to time
ti+1 = ti + h, then we may compute the acceleration ẍ(ti+1 ) using equation 2. The various
numerical integration algorithms described in this document1 2 differ primarily in the manner
in which x(ti+1 ) and ẋ(ti+1 ) are computed from x(ti ), ẋ(ti ), ẍ(ti ), f ext (ti ), and f ext (ti+1 ).
There are two general classifications of numerical integration methods: explicit and
implicit. In explicit methods, displacements and velocities at ti+1 can be determined in
closed form from displacements, velocities, accelerations, at ti , and from external forcing at
ti and, potentially, ti+1 . For structural systems with linear elastic stiffness and linear viscous
damping, such discrete-time systems may be written
" # " #
x(ti+1 ) x(ti )
=A + B f ext (ti ) (3)
ẋ(ti+1 ) ẋ(ti )
1. Input the mass, M , damping, C, stiffness, K, matrices and the time step interval h.
h2
2. Initialize x0 , ẋ0 , ẍ0 and compute x1 = x0 − hẋ0 + 2 0
ẍ .
3. Form the matrices A0 , A1 and A2 , and triangularize A0 using LDLT factorization.
4. for i = 1 to N
(a) solve A0 xi+1 = A1 xi + A2 xi−1 + fiext for xi+1 using LDLT back-substitution.
(b) calculate ẋi and ẍi using equations (4) and (5), if required.
(c) write results (ti , xi , ẋi , ẍi ) to a data file.
3
K.J. Bathe, Finite Element Procedures in Engineering Analysis, Prentice-Hall, 1982, pp. 439–449, 499–
506.
h2 h3 ... h4 ....
x(ti+1 ) = xi+1 = xi + hẋi + ẍi + xi+ x i + ··· (7)
2! 3! 4!
h2 ... h3 ....
ẋ(ti+1 ) = ẋi+1 = ẋi + hẍi + xi+ x i + ··· (8)
2! 3!
... h2 ....
ẍ(ti+1 ) = ẍi+1 = ẍi + h x i + x i + ··· (9)
2!
Rearranging equation (9),
... h2 ....
h x i = ẍi+1 − ẍi − x i − ··· , (10)
2!
and substituting equation (10) into equations (7) and (8) results in
!
h2 h2 h2 .... h4 ....
xi+1 = xi + hẋi + ẍi + ẍi+1 − ẍi − x i − ··· + x i + ··· , (11)
2 6 2! 4!
!
h h2 .... h3 ....
ẋi+1 = ẋi + hẍi + ẍi+1 − ẍi − x i − ··· + x i + ··· (12)
2 2! 3!
Under the assumption that acceleration ẍ(t) varies linearly in time between times ti and
time ti + h the fourth and higher time-derivatives are zero. The resulting finite difference
relations are precisely
h2
xi+1 = xi + hẋi + (ẍi+1 + 2ẍi ), (13)
6
and
h
ẋi+1 = ẋi + (ẍi+1 + ẍi ). (14)
2
These relationships are implicit because ẍi+1 needs to be determined in order to find xi+1 and
ẋi+1 , but ẍi+1 can not be found without knowing xi+1 and ẋi+1 . Note that the substitutions
above, have eliminated the third time-derivative of x, and that the method is accurate to
....
within h4 x (which is zero if ẍ is linear in time).
This is called the linear acceleration method because the third time derivative of x has
been eliminated. If the rate of change of acceleration within a time-step is truly constant,
then the approximation of truncating the Taylor series at the fourth-order term does not
affect the accuracy of the solution.
M ẍi+1 + C{ẋi + (h/2)(ẍi + ẍi+1 )} + K{xi + hẋi + (h2 /6)(ẍi+1 + 2ẍi )} = fi+1
ext
, (15)
where any nonlinearities, R(x, ẋ), are assumed to be negligible. Collecting similar derivatives
of x, " # " #
h h2 ext h h2
M + C + K ẍi+1 = fi+1 − Kxi − [C + hK]ẋi − C + K ẍi . (16)
2 6 2 3
and re-arranging,
" # " #
h h2 h h2 ext
M + C + K ẍi+1 = − C − K ẍi − Kxi − C ẋi − hK ẋi + fi+1 . (17)
2 6 2 3
Substituting equation (18) into (17), we obtain the closed-form linear acceleration recurrence
relations for structural dynamics simulation.
" # " #
h h2 h h2 ext
M + C + K ẍi+1 = M − C − K ẍi − hK ẋi + fi+1 − fiext . (19)
2 6 2 3
h
ẋi+1 = ẋi + [ẍi+1 + ẍi ] . (20)
2
and
h2
xi+1 = xi + hẋi + [ẍi+1 + 2ẍi ] . (21)
6
These relationships are now explicit because ẍi+1 can be determined from the current response
values (xi and ẋi ), the current dynamic load fiext , and the next dynamic load fi+1
ext
. Note
that within each time step, the dynamic equations of equilibrium are satisfied both at time
ti and at time ti+1 .
Equation (31) is analogous to equation (26) with the added condition that the acceleration
is constant within the interval t ∈ [ti ti+1 ). If
0 ≤ α ≤ 1/3 (32)
β = (1 + α)2 /4 , and (33)
γ = 1/2 + α , (34)
the HHT-α method is at least second-order accurate and unconditionally stable. The HHT-α
method is useful in structural dynamics simulations incorporating many degrees of freedom,
and in which it is desirable to numerically attenuate (or dampen-out) the response at high
frequencies. Increasing α decreases the response at frequencies above 1/(2h), provided that
β and γ are defined as above.
Substituting the Newmark-β finite difference relationships into equation (31),
These are a set of linear equations for ẍi+1 in terms of ẍi , ẋi , xi , the external dynamic load,
and the structure’s mass, damping, and stiffness. Equations (22), (23), and (36) provide the
recurrence relationship for the HHT-α method.
5
Hughes, T.J.R., Analysis of Transient Algorithms with Particular Reference to Stability Behavior. in
Computational Methods for Transient Analysis, North-Holland, 1983, pp. 67–155.
M δ ẍi +(1−α)Cδ ẋi +αCδ ẋi−1 +(1−α)Kδxi +αKδxi−1 +(1−α)δRi +αδRi−1 = (1−α)δfiext +αδfi−1
ext
.
(37)
Now, substituting in expressions for δ ẋ and δẍ at times ti and ti−1 , and grouping terms
results in
" # " #
1 γ 1 γ
2
M + (1 − α) C + (1 − α)K δxi = M + (1 − α) C ẋi
βh βh βh β
" ! #
1 γ
+ M − (1 − α)h 1 − C ẍi
2β 2β
" #
γ
− α C + K δxi−1
βh
!
γ γ
+ α C ẋi−1 − αh 1 − C ẍi−1
β 2β
− (1 − α)δRi − αδRi−1
+ (1 − α)δfi + αδfi−1 . (38)
If R(x, ẋ) = 0, these are a set of linear equations for δxi in terms of ẋi , ẍi , δxi−1 , ẋi−1 ,
ẍi−1 , δxi−1 , the external dynamic load, and the structure’s mass, damping, and stiffness.
Equations (22), (23), and (38) provide the recurrence relationship for the HHT-α method
in incremental form. Solving this linear system of equations6 for δxi , the displacements are
updated with,
xi+1 = xi + δxi , (39)
the velocities are updated with
! !
γ γ γ
ẋi+1 = 1− ẋi + δxi + h 1 − ẍi . (40)
β βh 2β
and the accelerations satisfy the HHT-α form of the equations of motion,
h i
ẍi+1 = −M −1 (1 − α)C ẋi+1 + αC ẋi + (1 − α)Kxi+1 + αKxi − (1 − α)fi+1
ext
− αfiext . (41)
6
If the incremental nonlinear restoring forces δRi are not negligible, equation (38) is solved using the
Newton-Raphson method, equation (48).
Numerical Example
The simple linear structural model shown below
111
000
000
111
1 2 3 111
000
000
111
000 200 kN/mm
111
000
111 200 kN/mm 200 kN/mm 000
111
000
111
000
111 000
111
000
111
000
111 000
111
000
111
000
111 000
111
000
111
000
111 000
111
000
111
000
111 1 Mt 1 Mt 1 Mt 000
111
000
111
000
111 000
111
000
111
000
111 000
111
000
111 000
111
000
111
000
111 000
111
000
111
000
111 000
111
000
111 0.15 kN/mm/s 111
000
000 0.35 kN/mm/s
111 0.20 kN/mm/s 0.20 kN/mm/s 000
111
is described by the following stiffness, damping, and mass matrices (units kN,mm,s):
400 −200 0 1 0 0 0.55 −0.20 0
K = −200 400 −200 C = −0.20
M = 0 1 0 0.40 −0.20
0 −200 200 0 0 1 0 −0.20 0.35
(42)
This system has natural periods of 1.00 s, 0.36 s, and 0.25 s, with about 1.5% critical damp-
ing in each mode. Free acceleration responses to initial conditions of x(0) = [0, 0, 0]T and
ẋ(0) = [1, 1, 1]T using the HHT-α method with time steps of 0.001 s (black solid) and 0.1 s
(blue dash-dot), and values of α of 0.0 (left) and 0.1 (right) are shown below.
10 10
α = 0.00 α = 0.10
5 5
accel #1, mm/s2
0 0
-5 -5
-10 -10
0 2 4 6 8 10 0 2 4 6 8 10
time, s time, s
For the α = 0 cases, the response computed with h = 0.1 s has a magnified short-period
response as compared to the h = 0.001 s case. For α = 0.1 and h = 0.1 s, the response
is more heavily damped especially the response at the shorter periods. Also, the responses
simulated with α = 0.1 and h = 0.1 s has a longer period than the system’s true fundamental
period of 1.0 s. Note that the linear acceleration method (α = 0, β = 1/6, γ = 1/2) would
be numerically unstable for this system with a time step of 0.1 s.
A more formal analysis of numerical damping, stability, and period lengthening effects
in explicit numerical integration methods can be carried out by examining the eigenvalues
of the discrete time dynamics matrix, A, in equation (3).
1. Initialize K using the pre-yield stiffness Khi . Initialize x0 , ẋ0 , ẍ0 , f0ext , and d to be zero
at time t0 = 0. The value d is the equilibrium displacement of the bilinear hysteretic
system.
ext
2. At time t = ti+1 , read the value of the external forcing fi+1 , solve equation (27) for
δxi , and calculate xi+1 and ẋi+1 using equations (28) and (29).
3. Compute the next acceleration ẍi+1 from equilibrium
ẍi+1 = −M −1 [C ẋi+1 + K(xi+1 − d) − fi+1
ext
]. (43)
4. Compute the yielding force level from
f yield (xi+1 , ẋi+1 ) = Klo xi+1 + (Khi − Klo ) xy sgn(ẋi+1 ) (44)
5. Check for yielding:
(a) If K = Khi and ẋi+1 > 0 and K(xi+1 − d) > f yield ,
then the system has just exceeded its positive yield force level.
Set K = Klo and d = (1 − Khi /Klo )xy .
(b) If K = Khi and ẋi+1 < 0 and K(xi+1 − d) < f yield ,
then the system has just exceeded it’s negative yield force level.
Set K = Klo and d = (Khi /Klo − 1)xy .
6. Check for load reversal:
The convergence of this form of the Newton-Raphson method depends on the local
smoothness of R(x, ẋ). Convergence can be improved, for a particular time step, by making
h smaller.
Note that K̃ is strongly positive definite; it does not depend on δxi ; and it is inverted
or factorized only once at the beginning of the simulation. If convergence is problematic,
then a set of K̃ matrices may be formed, some with small time steps, and factorized prior
to the simulation.
As an alternative to Newton-Raphson iterations, the approximation δRi ≈ δRi−1 re-
sults in an explicit formulation for the simulation of the response of nonlinear systems, and
can significantly reduce computational time, but with some loss of accuracy.
7
Press, W.H., et al., Numerical Recipes, Cambridge Univ. Press, 1993. http://www.nr.com/
The vector [rT ṙT ]T is called the state vector; along with the external forces, it can completely
describe the state of the system at any point in time. State-space models are conventionally
written as
ẋ = Ax + g(x) + Bu, (53)
where x is the state vector, A is the dynamics matrix, g(x) contains any nonlinear terms in
the equations of state, B is the input matrix, and u is the input to the system. For a linear
systems, g(x) = 0 and the eigenvalues of A contain the complex poles of the system. For
under-damped dynamic systems the poles are complex-valued. The imaginary part of the
pole is the damped natural frequency, and the real part of the pole is the negative of the
natural frequency times the damping ratio.
A convenient feature of state-variable formulations is that first order systems can be
easily combined. If components of the structural system have first-order dynamics (for
example, visco-elasticity or Bouc-Wen hysteresis), then the first order dynamics of those
components can be appended to the state vector, and the simulation of the second order
structural system coupled with the first order structural components can proceed in parallel.
The state variable formulation is the most general description of a dynamic system,
and many methods exist for the simulation of state-variable models. A set of these methods
has been implemented in Matlab. See, for example, the Matlab command ode45 .
For large second-order systems (n > 1000), however, the HHT-α method is typically
more efficient in terms of memory and speed.
from time t to time t+∆t. Given the state vector x(t), we endeavor to find the state x(t+∆t).
The solution scheme is illustrated in Figure 1. Within each time-step, the algorithm evaluates
. .
x2 = f ( t+dt/2, x(t)+x1 (dt/2) , u(t+dt/2) )
. . . .
x(t+dt) = x(t) + ( x1 + 2(x2+x3) + x4) (dt/6)
x(t+dt)
. .
x3 = f ( t+dt/2, x(t)+x2 (dt/2) , u(t+dt/2) )
x(t)
. . .
x1 = f ( t, x(t) , u(t) ) x4 = f (t+dt, x(t)+x3 dt , u(t+dt) )
t t + dt/2 t+dt
ẋ four times.
The desired solution, x(t + ∆t), is computed from the four state derivatives
∆t
x(t + ∆t) = x(t) + (ẋ1 + 2(ẋ2 + ẋ3 ) + ẋ4 ) , (59)
6
time is incremented, t = t + ∆t, and the solution marches on. The solution scheme is
implemented in the Matlab function ode4u.m9 . As long as ∆t is shorter than 0.45Tn where
Tn is the shortest natural period in the system, this constant time-step Runge-Kutta method
is stable.
9
http://www.duke.edu/∼hpgavin/ode4u.m
71 end
72 % −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ODE4U
73 % 2014 , 2022−04−29, 2023−01−21
The fourth order predictor at time t + ∆t, is x4 (t + ∆t), and the fifth order predictor at time
t + ∆t, is x5 (t + ∆t).
x4 (t + ∆t) = x(t) + (ẋ1 c41 + ẋ3 c43 + ẋ4 c44 + ẋ5 c45 + ẋ6 c46 )∆t (66)
x5 (t + ∆t) = x(t) + (ẋ1 c51 + ẋ3 c53 + ẋ4 c54 + ẋ6 c56 )∆t (67)
The coefficients ai , bij , and cij are provided in Cash and Karp’s paper. If every term of the
truncation error vector, ϵ = |x4 − x5 |/|x5 | is less than the required tolerance, ϵtol , then the
solution x5 is considered sufficiently accurate. In this case, x(t + ∆t) is assigned to x5 , t is
assigned to t + ∆t, and the solution marches on. Otherwise, the time step is divided into
Nss sub-steps,11 where
l h im
Nss = Nss max max (ϵ/ϵtol )1/4 , 1.1 , (68)
10
Cash, J.R. and Karp, A.H., “A Variable Order Runge-Kutta Method for Initial Value Problems with
Rapidly Varying Right-Hand Sides,” ACM Transactions on Mathematical Software, vol 16, no 3, pp 201-222
(1990). http://www.duke.edu/∼hpgavin/cee541/Cash+Karp-ACMTMS-1990.pdf
11
Press, W.H., et al., Numerical Recipes, Cambridge Univ. Press, 1993. Section 16.2 http://www.nr.com/
12
http://www.duke.edu/∼hpgavin/ode45u.m
ode45u.m
1 % [ time , x , x d o t , y ] = ode45u ( d x d t , time , x0 , u , params , t o l e r a n c e , d i s p l a y )
2 %
3 % S o l v e a sy s te m o f nonhomogeneous o r d i n a r y d i f f e r e n t i a l e q u a t i o n s
4 % u s i n g t h e embedded Runge−Kutta f o r m u l a s o f J .R. Cash and A.H. Karp , and
5 % u s i n g l i n e a r i n t e r p o l a t i o n o f e x t e r n a l f o r c i n g w i t h i n time−s t e p s .
6 %
7 % Input Variable Description
8 % −−−−−−−−−−−−−− −−−−−−−−−−−
9 % dxdt : a f u n c t i o n o f t h e form [ x d o t , y ] = d x d t ( t , x , u , params )
10 % which p r o v i d e s t h e s t a t e d e r i v a t i v e g i v e n t h e time , t ,
11 % t h e s t a t e , x , e x t e r n a l f o r c i n g , u , and p a r a m e t e r s
12 % a v e c t o r s y st e m o u t p u t s , y , may a l s o be r e t u r n e d .
13 % time : 1−by−p v e c t o r o f time v a l u e s , u n i f o r m l y i n c r e a s i n g
14 % ( or d e c r e a s i n g ) , a t which t h e s o l u t i o n i s computed .
15 % x0 : n−by−1 v e c t o r o f i n i t i a l s t a t e v a l u e s , a t time ( 1 ) .
16 % u : m−by−p m a t r i x o f s y st e m f o r c i n g d a t a f o r t h e ode ,
17 % sampled a t p o i n t s i n t h e 1−by−p v e c t o r time .
18 % params : o p t i o n a l p a r a m e t e r s used i n t h e f u n c t i o n d x d t
19 % tolerance : the desired tolerance constant ( d e f a u l t 0.001)
20 % may be a v e c t o r o f t h e l e n g t h o f x0 , or a s c a l a r
21 % display : 3= d i s p l a y l o t s o f r e s u l t s ; 2= d i s p l a y l e s s ; 1= even l e s s
22 %
23 % Output V a r i a b l e Description
24 % −−−−−−−−−−−−−−− −−−−−−−−−−−
25 % time : i s r e t u r n e d , un−changed
26 % x : the s o l u t i o n to the d i f f e r e n t i a l equation at times
27 % x dot : the d e r i v a t i v e to the d i f f e r e n t i a l equation at times
28 % y : the output of the d i f f e r e n t i a l equation at times
29 %
Numerical Example
In this example ode4u.m is used to solve the transient response of an inelastic system
forced by ground accelerations ẅ(t), as described by the equations:
r̈(t) + 2ζωn ṙ(t) + µz(t) = −ẅ(t) (69)
3
ż(t) = 1 − z sgn(ṙ(t)) ṙ(t)/dy . (70)
with initial conditions r(0) = 0, ṙ(0) = 0, z(0) = 0. The paramter µ is a plastic force
level divided by the mass (µ = fp /m), and the paramter dy is a yield displacement. The
external forcing is ground acceleration, −ẅ(t), given by a single full-period sinusoidal pulse
of amplitude Ap and period Tp ,
(
−Ap sin(2πt/Tp ) 0 ≤ t ≤ Tp
ẅ(t) = (71)
0 otherwise
In state space, these equations may be expressed as ẋ = f (t, x, u, p)
r(t) ṙ(t)
d
ṙ(t)
=
−2ζω n ṙ(t) − µz(t) − ẅ(t) (72)
dt
z(t) (1 − z 3 sgn(ṙ(t))) ṙ(t)/dy .
These ordinary differential equations are computed in the short .m-file inelasSys.m
6
relative displacement response, cm
relative velocity response, m/s
4 total acceleration response, m/s/s
2
responses
-2
-4
-6
0 1 2 3 4 5
time, t, s
1
2
inelastic force / mass, µ z(t) / m, m/s
0.5
0
(r(0), µz(0))
-0.5
-1
-6 -4 -2 0 2 4 6
relative displacement, r(t), cm