Fall 2008 ME2016 HW12: Solving ODEs & Spring-Mass-Damper Systems - Prof. Aldo Ferri, Assignments of Computer Science

A university homework assignment from the fall 2008 semester of the me2016 course. The assignment involves solving ordinary differential equations using euler integration, the 2nd-order runge-kutta method, and matlab's ode45 function. Additionally, students are asked to find the step response of a spring-mass-damper system using both numerical integration and the exact solution.

Typology: Assignments

Pre 2010

Uploaded on 08/04/2009

koofers-user-8u9-1
koofers-user-8u9-1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ME2016, Fall 2008, Dr. Ferri
Homework Assignment 12
Due Wednesday, December 3.
Problem 1. (5 points)
Consider the initial-value problem
2
2;(0)1ytyy
=
−= (1)
It can be shown that the exact solution to this nonlinear ode satisfying the initial condition is
2
() 1/( 1)yt t
=
+ (2)
(a) Perform Euler integration with h = 0.1 from 0 < t < 2 sec. Make a plot of the Euler solution and the
exact solution. Compute the maximum error over 0 < t < 2 sec.
(b) Repeat part (a) with h = 0.01. By what factor does the maximum error decrease? Does this match
your expectations?
(c) Integrate the solution to (1) using the 2nd-order Runge-Kutta method and h = 0.2. Plot the solution vs
the exact solution and vs the Euler answer from part (a). Based on the maximum error, which is more
accurate and by what factor?
(d) Integrate the solution to (1) from 0 < t < 2 using Matlab’s ode45 function (Type "help ode45" for
further info.) Plot the solution vs the exact solution. Compute the maximum error over 0 < t < 2 sec
and compare with the errors obtained using the methodology of parts (a) and ( c).
Problem 2. (5 points)
Find the step response of a spring-mass-damper system having
the following governing equation:
2
2()
dx dx
mckxFt
dt
dt ++=
; (0) (0) 0
dx
xdt
=
=
where F(t) is a unit step function given by
>
=00
01
t;
t;
)t(F
Note that the problem is second-order, since the highest derivative in x is 2. Before proceeding, we need
to write an equivalent set of 2 first-order equations. Define y1(t) = x(t) and y2(t) = dx/dt. Then the system
of equations is:
)y,t(fy
m/)cyky)t(F(y
yy =
=
=
212
21
(a) Find the step response from t = 0 to t = 50 seconds using the Matlab function ode45.m. Use the
parameter values m = 1kg, k = 1 N/m, c = 0.2 Ns/m. Your call will have the following form:
>> [T,X] = ode45(func,[0 50],[0 0]);
k
m
c
x(t)
F
pf2

Partial preview of the text

Download Fall 2008 ME2016 HW12: Solving ODEs & Spring-Mass-Damper Systems - Prof. Aldo Ferri and more Assignments Computer Science in PDF only on Docsity!

ME2016, Fall 2008, Dr. Ferri

Homework Assignment 12

Due Wednesday, December 3.

Problem 1. (5 points)

Consider the initial-value problem

2 y ′ = − 2 t y ; y (0) = 1 (1)

It can be shown that the exact solution to this nonlinear ode satisfying the initial condition is

2 y t ( ) = 1/( t + 1) (2)

(a) Perform Euler integration with h = 0.1 from 0 < t < 2 sec. Make a plot of the Euler solution and the

exact solution. Compute the maximum error over 0 < t < 2 sec.

(b) Repeat part (a) with h = 0.01. By what factor does the maximum error decrease? Does this match

your expectations?

(c) Integrate the solution to (1) using the 2

nd -order Runge-Kutta method and h = 0.2. Plot the solution vs the exact solution and vs the Euler answer from part (a). Based on the maximum error, which is more accurate and by what factor?

(d) Integrate the solution to (1) from 0 < t < 2 using Matlab’s ode45 function (Type "help ode45" for

further info.) Plot the solution vs the exact solution. Compute the maximum error over 0 < t < 2 sec and compare with the errors obtained using the methodology of parts (a) and ( c).

Problem 2. (5 points)

Find the step response of a spring-mass-damper system having

the following governing equation:

2

2

d x d x m c k x F t d t d t

dx x dt

where F(t) is a unit step function given by

; t

; t F(t)

Note that the problem is second-order, since the highest derivative in x is 2. Before proceeding, we need

to write an equivalent set of 2 first-order equations. Define y 1 (t) = x(t) and y 2 (t) = dx/dt. Then the system

of equations is:

y f(t,y ) y (F(t) ky cy )/m

y y ⇒ = = − −

2 1 2

1 2

(a) Find the step response from t = 0 to t = 50 seconds using the Matlab function ode45.m. Use the

parameter values m = 1kg, k = 1 N/m, c = 0.2 Ns/m. Your call will have the following form:

[T,X] = ode45(func,[0 50],[0 0]);

k

m

c

x(t)

F

where func is an anonymous function that returns the function f(t,y). Note that the outputs from ode45 are an Nx1 vector of times, T, and an Nx2 matrix of response, X. The first column of X is the displacement and the second is the velocity. Compare the displacement calculated with ode45 with the exact solution given by:

x( t) e sin dt cos dt nt

2 1

where ς = c / ( 2 k/m ), ω n = k/m ,

2

ω d = ω n 1 − ς

(b) Compare the answer from ode45 with one obtained using first-order Euler integration. Assuming that

the number of time steps used by ode45 is equal to N_RK = length(T)-1, use N_E = 4*N_RK steps in the Euler integration scheme. Note that this balances the number of calls to the derivative subroutine between the two methods.