代写 matlab MECH 5315M – Engineering Computational Methods

MECH 5315M – Engineering Computational Methods
Resit Exercise
Formalities. The report should be between 1 and 2 pages long, using at least font 11 and 2cm margins. Please attach any code you used to generate results described in the report as an appendix (the appendix does not count towards the 2 page limit).
Important: You may reuse any code that has been provided via Minerva, but you must clearly indicate where you have done so in the comments in the code!
Tasks.
1. Write a programme that solves the heat equation
u ̇(t,x) = uxx(t,x), 0 ≤ x ≤ 1.0
with boundary conditions u(0) = u(1.0) = 0, initial condition u(0,x) = sin(5πx) and centred finite differences with both explicit and implicit Euler.
2. Write a script that runs your code with different values of ∆t and ∆x. Vary the number of time steps from 75 to 500 and the number of finite difference nodes from 25 to 50. In each case, run both Euler methods with the given time step until t = 0.1 and store the logarithm of the maximum absolute value of the final result, that is log(max(abs(φ))), where φ is the vector containing all approximate point values ui from your finite difference formulation.
3. Use a mesh plot in Matlab to visualise how this value changes depending on ∆x and ∆t for implicit and explicit Euler.1 Your x-axis should show the width of your finite difference mesh ∆x and your y-axis the time step ∆t. Please include a Matlab script make figure.m in the appendix that generates these figures for both Euler methods without requiring additional input.
4. For your interpretation, write down the analytical solution to the problem. Us- ing it as a reference, argue in what range the value of log(max(abs(φ))) should be, considering the dynamics of the real solution and compare that to numerically computed values.
1If you like, you can add the command shading interp just after your plot command to make the plot look a bit nicer.
1

What you need to write in the report. Your report must be structured as described below. Only answers that are within the correct section will be awarded marks.
1. Section 1: Introduction
a) Description of the problem: Introduce the problem that you are solving.
b) Description of numerical methods: Introduce the numerical methods in your code. In particular, write down in detail how you incorporate the boundary condition in your finite difference formulation.
c) List of parameters: Give all information that is required to reproduce your results. This can be in form of a table.
2. Section 2: Results
a) Figures: Show the two figures emerging from your code. In case you want to include more figures to support your explanations (this is not necessary, but can be helpful), please include them here as well and make sure that it is clear what they show.
b) Description of results: Describe first what can be observed in each figure indi- vidually and then what the noticeable differences between them. No interpre- tation of results should be included here (no marks will be given).
Try to be as quantitative as possible: for example, if you observe something for specific values of ∆t and ∆x but not for others, make sure to include the values in your description.
3. Section 3: Interpretation
a) Explain results for forward Euler: Explain in detail what you observed in Section 2 for the forward Euler method.
b) Explain results for backward Euler: Explain in detail what you observed in Section 2 for the implicit Euler method.
In both cases, precise quantitative explanations will be awarded more marks than purely qualitative explanations. This section should also contain the analytical solution (Task 4).
2