Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MECH 5315M - Engineering Computational Methods

Assignment 1

Please submit electronically via Minerva before 12.00 noon Monday 21 November 2022.

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 so that you should only submit a single file (preferably .pdf). Your MATLAB code  should include comments explaining key steps in the code. 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

ẋ(t) = v(t)                        (1)


v̇(t) = − x(t)                      (2)


is the so-called symplectic or semi-implicit Euler method

vn+1  = vn  − ∆t () xn              (3a) 

xn+1  = xn  + ∆tvn+1                   (3b)


For all simulations in MATLAB for this exercise, please use values of k = 5.0 and m = 0.5     and initial values x0  = 1.0 and v0  = 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 x0 , v0 , 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 xn , vn , n = 0, … , N 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

En  =  m(vn )2  +  k(xn )2                       (4)                                                         

of the solution generated by the semi-implicit Euler method 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 methods.

Task 3. (25 marks)

1.   (10 marks) Without the aid of computational tools, show mathematically that semi- implicit Euler conserves the modified discrete energy

n  =  (m(vn )2  + k(Xn )2  kt Xn vn )

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 showing both the    energy E(t) of the analytical solution and the modified discrete energy n  of the    approximate solution produced by semi-implicit Euler method 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 you know from the lectures about the explicit Euler method.

Task 4. (30 marks)

The nonlinear mass-spring system is described by the second order differential equation :

m + k(X + FX 3 ) = 0,                                                    (5)

where m , k and F are constants and the displacement X is a function of time t .

1.   (5 marks) Write equation (5) as an equivalent system of first order equations .

2.   (5 marks) Write down the corresponding algorithmic equations for applying the symplectic Euler method to this system.

3.   (5 marks) Show how your MATLAB function from Task 1 can be adapted to account for the additional parameter F .

4.   (15 marks) Write a MATLAB program to create a plot comparing the displacement versus time calculated by (a) the symplectic Euler method with 100 time steps and (b) MATLAB's ode45 . Use the parameter values k = 5.0, m = 0.5 and F = 3.0 and the initial conditions X (0) = 1.0 and Ẋ (0) = 0.1 . Include the plot in your report and  describe your observations.

Formatting and submission

The format of your report should be based on the following. Create a word document with:        A one page front cover page with your name, SID and MECH5315M Assignment 1’ –

this will of course not count towards the 4 page limit.

    The 4 pages of your report that include everything apart from your MATLAB code.     Your MATLAB codes in an Appendix, with a clear indication of which part of the

assignment each piece of code relates to . There is no page limit to your Appendix.

    Save and submit this as a .pdf file to the assignment submission box.