MECH 5315M - Engineering Computational Methods
Engineering Computational Methods
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
MECH 5315M - Engineering Computational Methods
Your report should not be longer than 4 pages in total. Please use at least a font size of 11pt
and 2cm margins on all sides. All MATLAB code should be attached to the report as an
appendix. The appendix does not count towards the 4 page limit. All figures in the report
must have captions, properly labelled axes, legends where necessary and must be
described and analysed in the text.
Problem. An algorithm not yet studied in the lectures to solve the linear mass-spring system
̇() = () (1)
̇() = −
() (2)
is the so-called symplectic or semi-implicit Euler method
+1 = − ∆ (
) (3a)
+1 = + ∆+1 (3b)
For all simulations in MATLAB for this exercise, please use values of k = 5.0 and m = 0.5
and initial values 0 = 1.0 and 0 = 0.1. All simulations should run until a final time T = 10.0.
Task 1. (25 marks)
1. (10 marks) Implement the algorithm given by equation (3) as a function in MATLAB.
The function should accept as arguments the initial values 0, 0, the number of time
steps N, the final time T and the parameters k and m. It should return an array that
contains all values , , = 0, … , generated by the method.
2. (15 marks) Write a program in MATLAB that produces a figure for your report that
convincingly demonstrates that the semi-implicit Euler method is convergent with
order p = 1. Explain what the figure shows and why it demonstrates that the method
is first order convergent.
Task 2. (20 marks)
1. (15 marks) Using your function from Task 1, write a program in MATLAB that
produces a figure for your report that shows the discrete energy
=
1
2
()2 +
1
2
()2 (4)
of the solution generated by semi-implicit Euler over time for N = 100 and N = 1000
time steps. Include this figure in your report.
2. (5 marks) Describe what you observe and compare your observations to what you
know about the performance of explicit and implicit Euler.
2
Task 3. (25 marks)
1. (10 marks) Without the aid of computational tools, show mathematically that semi-
implicit Euler conserves the modified discrete energy
̃ =
1
2
(()2 + ()2 − ∆ )
Note: For the sake of simplicity, you can do this calculation for m = k = 1. It is
recommended that you use an equation editor to do this rather than simply writing your
solution by hand to ensure your analysis is tidy and therefore easy to follow.
2. (10 marks) Write a program in MATLAB that produces a figure that shows both the
energy E(t) of the continuous system and the modified discrete energy ̃ of the
approximate solution produced by semi-implicit Euler for N = 100 and N = 1000 time
steps. Put this figure in your report.
3. (5 marks) Describe your result and contrast the result to what we know from the
lectures about the explicit Euler method.
Task 4. (30 marks)
1. (5 marks) For a general second order Initial Value Problem
̇() = () (5a)
̇() = (()) (5b)
the symplectic Euler method reads
+1 = + ∆() (6a)
+1 = + ∆+1 (6b)
Write down the method for the nonlinear spring-mass system:
̇() = () (7a)
̇() = −
(() + 3()) (7b)
2. (5 marks) Write a MATLAB function that implements the symplectic Euler method for
the nonlinear system. The function should have the same form as the function in
Task 1, except for an additional input variable β.
3. (20 marks) Write a MATLAB program that plots the approximate solution to the
nonlinear system (7) produced by symplectic Euler with N = 100 time steps and
MATLAB's ode45 using the same parameters as for the linear case with k = 5.0, m =
0.5 and initial values 0 = 1.0 and 0 = 0.1.and β = 3.0. Include the plot in your report
and describe your result.