matlab and numerical methods assignment 2022 23 problem the formation
Search for question
Question
MATLAB & Numerical methods - Assignment (2022/23)
Problem: The formation of biodiesel through the methanolysis of
triglycerides is of great interest due to its ability to produce renewable,
environmentally friendly fuel from potentially waste materials. As a
significant amount of research continues in the field, a vast literature is
available concerning the kinetics of the process under different conditions
and using different raw materials. A basic kinetic scheme is¹,
MeOH+TG → BD+DG, k, =0,4526m².kmol.day
MeOH+DG-BD+MG,
k=0.3958 m², kmolday
MeOH+MG - BD+GL, k₂=0.3523m².kmol ¹.day
In this reaction scheme, the reactant species methanol (MeOH) and
triglyceride (TG) react to form biodiesel (BD) and glycerol (GL), along with
diglyceride (DG) and monoglyceride (MG), which appear as intermediates.
If the reactions take place in a batch chemical reactor, assumed to
operate isothermally, then the set of differential equations that describe
the change in concentration of each of the chemical species is given by.
d MeOH
dt
d TG
dt
dBD
dt
----
=-₁
=r₁tr₂tr₂
The respective reaction rates being:
r₁=k, MeOH||TG|; r₂=k, MeOH DG;
d DG
dt
d MG
dr
=r₁₂-₂
d Gl=rs
dt
r₂=k, MeOH||MG).
If the initial concentrations of the reactant species are
MeOH=3kmol.m³ and [TG]=1kmol.m (and the initial concentration of all
other species is zero)
¹ Note: the reactions are normally considered to be reversible but to
simplify our problem we have not considered this./nObjective: Your task is to solve this system of differential equations by
hand using the Euler's method and in using both Simulink and MATLAB.
(a) Solve the first 2 time points, given a step size of 0.1, for each of the
differential equations using the Euler's method calculation that you
were shown you how to do by hand in Semester 1. These will need
to be solved sequentially in the order presented in the table below
(i.e. You will first need to solve [MeOH] @ t=0.1 and then go on to
solve of [TG] @ t=0.1 etc.. Once you have completed this task you
should be able to complete the first 2 empty rows of the table
below.
t
0
0.1
0.2
60
[MeOH] [TG] [BD]
1
0
3
[DG] [MG]
0
0
[GL]
0
(b) Performing the hand calculations in part (a) should've demonstrated
to you that for a complex linked system of differentials it quickly
becomes inefficient to perform hand calculations. Develop a
Simulink model to simulate the system of equations and plot the
concentration of each species over time. You should use a Fixed-
step Solver: ode1 (Euler); with a Fixed-step size 0.1.
(c) The next task is to write the MATLAB code to solve this problem
using the odes45 function. This will require you to generate a script
file and a function file containing the system of ODEs to pass to the
ode45 function in your script (similar to the example in slide pack
5).
(d) The final part of the assignment will be to write the MATLAB code to
store the outputs of your solved ODEs in a structured array, along
with the output of a simulation with the initial conditions:
MeOH=4 kmol. m¹ and [TG]=2 kmol.m. This should result in a/nstructured array with a minimum of 6 fields (one for each species,
however you may choose to include additional fields to describe
things such as the simulation conditions, date of simulation etc) and
a minimum of 2 'batches' (each simulation run being stored as a
separate batch).
This is an individual project. The maximum report length is 5 pages
(the report should be typed with size 12 font, single line spacing, and any
graphs that are included should be of high quality; i.e. not in the default
dark colours of the scope object, they can be changed in scope settings)
and details of the required work and marking criteria are given below. The
Simulink model file and MATLAB files created should be uploaded in a zip
folder using the dedicated upload box for the code.
The required work, structure of the report and marking criteria are as
follows,
1. Provide Euler's hand calculations (typed) for the first 2 rows of the
table. Any 2 example calculations will be sufficient to include in the
report alongside the completed tables and will ensure unique
reports.
[10 marks]
2. Use Simulink to solve the ODES. Include the Simulink block diagram
on a full side of A4 (signals labelled) in the main body of the report
along with the output plot of the 6 species. Provide the 1* 5 and last
5 rows of the matrix of concentrations in a table.
[15 marks]
3. Develop the code to solve to problem an provide the annotated
(commented) script and function file that you developed in the main
body of the report along with a single output plot of the 6 species.
Provide the 1¹t 5 and last 5 rows of the matrix of concentrations in a
table from the variable step size solver ode45. [15 marks]
4. Develop the code to store a structured array of the output data and
provide the annotated (commented) script you used to do so in the
main body of the report.
[15 marks]
5. Provide 3 bullet points on your learning outcomes from this report.
Marks will also be awarded in this section for presentation and
layout of the report to a professional standard and ability to follow
instructions.
[10 marks]