Write My Paper Button

WhatsApp Widget

Implement the scheme in a function adams_bashforth_2 that takes appropriate parameters, so that it is easy to import and use whenever needed.

1.Differing from the single-step methods presented in this chapter, we have the multistep methods, for example the Adams-Bashforth methods. With the single-step methods, un+1 is computed by use of the solution from the previous time step, i.e. un. In multi-step methods, the computed solutions from several previous time steps, e.g., un, un−1 and un−2 are used to estimate un+1. How many time steps that are involved in the computing of un+1, and how the previous solutions are combined, depends on the method.11 With multi-step methods, more than one starting value is required to get the scheme started. Thus, apart from the given initial condition, the remaining starting values must be computed. This is done by some other appropriate scheme (in such a way that the convergence rate of the overall scheme is not reduced). Note that the Runge-Kutta methods are single-step methods, even if they use several intermediate steps (between tn and tn+1) when computing un+1, using no other previous solution than un. One of the simplest multi-step methods is the (second order) two-step AdamsBashforth method. The computational scheme reads: un+1 = un + Δt 2  3f (un, tn) − f (un−1, tn−1) , for n = 1, 2,…,Nt − 1, with u0 = U0.

a) Implement the scheme in a function adams_bashforth_2 that takes appropriate parameters, so that it is easy to import and use whenever needed. Use a Forward Euler scheme to compute the missing starting value.

b) Write a function compare_FE_AdamsBashforth2 that compares graphically the solutions produced by the Forward Euler and two-step Adams-Bashforth methods, when they solve the population growth model u
= 0.1u, with u(0) = 100. Let the total time span T = 20, and use a time step dt = 2. In the plot produced, include also the exact solution, so that the numerical solutions can be assessed.

c) Suggest a reasonable asymptotic error model before you write a proper test function test_convergence_rates that may be used to compute and check the convergence rates of the implemented AB2 method. However, the test function should take appropriate input parameters, so that it can be used also for other ODE solvers, in particular the ode_FE implemented previously (if you already have written this test function when doing Exercise 8.15, you may prefer to import the function). Include your test function in a program, together with the two functions you defined previously (AB2 and compare_FE_AdamsBashforth2). Write the code with a test block, so that it gets easy to either import functions from the module, or to run it as a program. Finally, run the program (so that compare_FE_AdamsBashforth2 gets called, as well as test_convergence_rates for both FE and AB2) and confirm that it works as expected. In particular, does the plot look good, and do you get the convergence rates you expected for Forward Euler and AB2?

find the cost of your paper

CLAIM YOUR 30% OFF TODAY

X
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?