Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2 ) It is asked to solve for the dynamics of the model in part 1 with respect to time, using both analytical and

Part 2)
It is asked to solve for the dynamics of the model in part 1 with respect to time, using both analytical and numerical approaches, and a comparison between the two approaches be offered.
Numerical Solution:
A modular and flexible programming approach is adopted in this assignment, and students will be encouraged to continue using this approach throughout the course. When designing a numerical implementation of the proposed solution, first an architecture should be decided upon. We would like this architecture to be modular, i.e. consisting of separate modules that performs unrelated tasks. This will prove to be useful for later assignments, when the student needs a module that just does the task.
& main program
handle variable assignment
discretize the solution interval
set up time loop (for loop)
plot results in a graph
main.m
8 main
call
function ck1=euler(h,tk,ck)
ck1=ck+h+deriv(tk,ck)
call
euler.m
function f=deriv(tk,ck)
f=96 your derivative function
deriv.m
Figure 2. Schematic diagram of the model
Take the architecture proposed in Figure 2 for example, the main program (main.m) that takes care of input/output, assignment of variables, discretization of solution interval, and setting up an incremental solution scheme (a loop over time that starts from t=0 to t=tf where tf denotes the final solution time). The presentation of results in graphical and/or tabular formats is also done here. Within the loop over time inside this main program, certain tasks need to be performed each step, such as calculation of the state derivative, f(t,c), or the integration performed according to Euler's formula,
ck+1=ck+hf(tk,ck)
where h refers to the step size between two increments in time.
Now let's investigate how these this task will be performed.
First consider the computing of the state derivative. This task may be taken independently from the rest of the program, and a separate module (e.g. deriv.m) may be used to do the calculation. The module will accept a value of time, and the corresponding value of the state at that time instant, and will return the state derivative.
Second independent task is the integration step, using Euler's formula. A similar module (e.g. euler.m) can be assigned to do this task. The required inputs to this module are the previous state information, the step size, and the computed state derivative (indeed the state derivative module can directly accessed by this module). Thus the architecture described above can be illustrated in the figure below:
In the lab, you are expected to complete the following list of TASKS: (for YOUR REPORT)
PLOT cexact(t) so that your numerical solution and this can be compared in one plot.
Complete the programs described in Figure 2.
For a step size of h=10, run your code for 50 minutes and plot the concentration vs time on
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What would you do?

Answered: 1 week ago