[关闭]
@ShixingWang 2016-04-02T21:38:30.000000Z 字数 11908 阅读 1549

First written with Jupyter.
The differential equation codes can be found here and the subplot codes here.

Exercise 4 - Double Decay

Abstract

Although it has been the ultimate goal for scientists to find the analytical solution of the nature, some complicated sysyems still hinder people from this dream in which circumstances numerical methods are necessary. Ordinary differential equations are good practice for us to get familiar with the numerical methods, for we can compare our result with the known analytical solution. In this problem, we consider a system in which The errors for ingoring high rank differentiation may sometimes make such methods invalid, so various initial conditions and parameters are discussed to examine the sensitivity of the parameters and the rubustness of the method.

Background

Ordinary Differential Equation [1]

The categories of equations are based on the type of known quantities and the calculation on the unknown quantities. The equations are called algebraic equtions or transcedent equations if the unknown quantities are numbers. An equation is called a function equation if the unknown quantity is a function. It is called a differential equation if there are derivative or differential in an equation, among which the ones containing functions with only one variables are called the ordinary differential equations.

And as is proven, the theorem about the existence and uniqueness of the solution says for a differential equation
with the boundary condition , the solution exists and is unique if in the region


(1) f(x,y) is continuous.
(2) f(x,y) satisfies the Lipschitz condition about y, which means for any pair of points and , there exists N such that

This theorem provides us with confidence about the solution we find. Once it satisfys the differential conditions of thq equation, it much be the correct and the only correct solution.

Euler Methods

As we know, any real or complex function that can be differentiated to infinite orders at point can be represented as an infinite sum of about the differentials like


This theorem has provided us with a way to approximate a function in forms of a poynomial function, which can be easily calculated in computers. [2][3]Especially, if we ignore the differentials greater than the second order, which means

This method to figure out the approximate solution is called the Euler method.
Suppose the function is continuous and bounded in the region ,then determines a direction field. To get the approximate solution of the ordinary equation with boundary condition

divide the interval into n equal pieces,and the dividing points are


Because the tangent of the solution at the point should be f(x_0,y_0), we use the straight line passing (x_0,y_0) with the tangent f(x_0,y_0) as an approximaiton of the curve. The function of the straight line is

And the y-coordinate of the straight line at the point should be

If is very small, then , thus the point is fairly close to the point on the solution curve. If is continuous, then the straight line starting from approximates the solution curve, with the function

And the y-coordinate of the end of this straight line is

And the rest can be done in the same manner,

Since the function of every straight line is known, so for every point in the interval , we can figure out the approxiamtion of the solution . And the fold line as the approximation of the solution is called the Euler Fold Line. It can be proven that when approaches infinity and approaches zero, the Euler fold line approaches the solution. [1]

Sensitivity and Robustness of Parameters [4]

What we have and will be doing in this exercise has little to do with first principles of physics. Rather, they are just methematical modelling problems. As a result, it is necessary to discuss the sensitivity and robustness, two of the essential concepts in mathematical modelling.

To set up a model describing a phenomenon, parameters play an important role in the final results of the model. These parameters are obtained from measurements, observations, and sometimes even by guess. So the inaccuracy of the data must be taken into consideration. Usually, for a certain extent of change of a parameter, the variable will change correspondingly. For the parameter and the variable ,


And we call this limit the sensitivity of about

A mathematical model is called robust if the result is still correct even if the model is not absolutely accurate. Sensitivity is a kind of index to evaluate the robustness of the model based on the data. Other assumptions will also be examined to ensure the robustness.

In most questions after Chapter 1 of our textbook, we have been informed of the models to use and only have to realize the model through Python and cast the parameters into the program. So the sensitivity and robustness of our parameters become important.

Imaging with Python

It is convenient to draw plots with Python, since there have been the powerful packages numpy and matplotlib.

numpy is a package that can deal with the discrete calculations that will be used in the ploting. Not only can it create number lists with the function arrange and linspace, it also contains the general math functions like the triangluar function sin cos.[5]

matplotlib is the package that deal with the representation of plots. [6] Through the internal functions we can easily And other information about this package and the rebellish of pots can be found here.

Program

Problem 1.5

Consider again a decay problem with two types of nuclei A and B, but now suppose that nuclei of typw A decay into type B, while nuclei of type B decay into type A. Strictly speaking, this is not a "decay" process, since it is possible for the type B nuclei to turn back into type A. A better analogy would be a resonance in which a system can tunnel or move back and forth between two states A and B which have equal energies. The corresponding rate equations are



where for simplicity we have assumed that the two types of decay are characterized by the same time constant . Solve the system of equations for the numbers of nuclei, as functions of time. Consider different initial confitions, such as etc, and take . Show that your numerical results are consistent with the idea that the system reaches a steady state in which are constant. In such a steady state, the time derivatives should vanish.

Declear and Initialize Variables and Parameters

Apparently the decay constants of A and B are important parameters. Here we have assumed that the two parameters equal. However, they do not necessarily have to be, so we declear $\tau_A$ and $\tau_B$ as separate parameters and initialize them with the same quantity.
Another parameter is the time interval for the Euler fold line to approximate the "true" solution of the equations. Apparently the smaller this parameter dt is, the closer our numerical solution will approach the true solution, but the slower the program will be. For convenience we set and will examine the effect of it value in the Discussion section.
And as an intuition, the system will become stable after certain amount of time. So we need a parameter timescale to control the time we want the system to develop.

As for the variables, the solutions are the function and . So we need two lists to store the value of and and a time list which has the same length of and . The initial conditions are initialized as the first element of the lists.

Calculation

The algorithm of the problem is straightforward. We set up a cycle in which the new and value is obtained from the value of and before the time interval plus the product of the time interval and the derivative of and versus time.

Represent and Restore the Results

Since the function and has been stored into the lists, we can plot them with the help of package matplotlib

4_1

The curve cannot be seen because it is below the x-axis. And it should be the mirror refelction of (the proof is shown below).

Discussion

Comparasion with Analytical Solution

According to the eigenvector mathod we can solve such ordinary differential equations fairly easily. For the equations with the boundary conditions


The analytical solution would be

Our numerical solution show a exponential feature and the derivative about time vanish as time approaches infinity. And the

This means the tendency of and depends on which of the two quantities and is greater. If the former is greater, then decreases and increases, and vice versa. And remind that at every time So this process can also be treated as an exchange of states for a certain matter.

4_2

To draw several figures in the same picture we need the function subplot, and the settings of the ticks and limits of x-axis and y-axis are slightly different with plot function.

Sensitivity Analysis: How Will the Curve Shifts as Parameters Change?

Sensitivity of the Final Number about the Decay Constant

According to the analytical solution, the number of A and B at the final state



The effect of the initial number of both matter is obviously linear, and the sensitivity will increase a little bit as and increase. This is because the respond of the final number is always smaller than the change of initial state.

Here we choose the same decay constant () and fix , to get the effect of different

4_3

According to the Reference [4], the sensitivity of A and B about and




This means the sensitivities can never be over 1, and are independent with the initial number.

Here we fix and use various and

4_4

Robustness Analysis: Does Time Steplength Matter?

As is introduced in the Background section, the validity of Euler method depends on the Euler fold line as the approximation of the true solution curve. Specifically, it depends on the fact that the iterating interval is ralatively small comparing to the system of interest. But how big can this interval be? We tried several length of interval and the resluts are shown below.

4_5

Acknowledgement

All the codes and report are written by myself.
I must give my appreciation to FC Bayern Munchen club for their exciting victory in Allianz Arena against Juventus. They gave me an excellent weekend so that I can finish this exercise joyfully! Really looking forward to their highlight performance in Milan!

MIA SAN MIA!

Reference

[1] Differential Equation Group of Northeast University. Ordinary Differential Equation, Second Edition. Higher Education Press, April 2005.

[2] Qi, Minyou et al. Advanced Mathematics. Wuhan University Press, August 2008.

[3] Wikipedia contributors. "Taylor series." Wikipedia, The Free Encyclopedia. Wikipedia, The Free Encyclopedia, 20 Mar. 2016. Web. 22 Mar. 2016.

[4] Meerschaert, Mark M. Mathematical Modelling,Fourth Edition. China Machine Press, Janurary 1, 2015.

[5] "lectery", a Baidu user. Maypoltlib Guidebook.
http://wenku.baidu.com/link?url=haYK7EyFYYblwual6X1lAihWbvIFvYWx2MvEclbgARNn76kNJO9kU0Fb6R40YPuA71iHk60fD7HX_9PCaDTTuulVSRLcQwopIngL6uZjNpW

[6] Nicolas P. Rougier. Matplotlib Tutorial. http://www.labri.fr/perso/nrougier/teaching/matplotlib/

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注