Bateman equation using dsolve

조회 수: 9 (최근 30일)
Derek Haws
Derek Haws 2016년 7월 7일
댓글: Star Strider 2016년 7월 8일
I am attempting to use the bateman equation to follow a decay series. When I have a non-zero initial concentration in isotope 2 and/or 3 the program fails to function. It also appears to "instantly" decay isotope 1 when 2 and 3 are zero. Any ideas what I did wrong with applying dsolve and diff(eqn) in q1:q3?
Code Below::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
clear all;
clc;
%start the symbolic solver variables
syms N1(t) N2(t) N3(t) l1 l2 l3 l4 l5 N0 N20 N30
%Constants & initial values
tmax =40;
N0=1e6;
N20=0;
N30=0;
% *I should be able to change these values to the IBV problem and still get a solution*
tmax = 40;
%set up the differential equations
*I should be able to solve each individually. See Wikipedia <https://en.wikipedia.org/wiki/Bateman_Equation bateman equation> *
q1=dsolve(diff(N1)==-l1*N1, N1(0) == N0);
q2=dsolve(diff(N2)==-l2*N2+l1*q1, N2(0) == N20);
q3=dsolve(diff(N3)==l2*q2, N3(0)==N30);
%the time interval is so short this does not start to decay- simplification to calculation
*%below this line everything works as intended*
t1 = (1.2e-4);
t2 = (37);
t3 = (12*24*60*60);
% change to lamba values
k1=log(2)/t1;
k2=log(2)/t2;
k3=0;
N0val = 1; % value for N1(0)
% Substitutions
eq1=subs(q1, [l1,l2,l3, N0], [k1,k2,k3, N0val]);
eq2=subs(q2, [l1,l2,l3, N0], [k1,k2,k3, N0val]);
eq3=subs(q3, [l1,l2,l3, N0], [k1,k2,k3, N0val]);
% Set graph limits
tmin=0;
ymin=0;
ymax=1;
% Plot easily via ezplot
figure
hold on;
h1=ezplot(char(eq1), [tmin,tmax,ymin,ymax]);
h2=ezplot(char(eq2), [tmin,tmax,ymin,ymax]);
h3=ezplot(char(eq3), [tmin,tmax,ymin,ymax]);
title('Isotope fraction')
legend('N1', 'N2','N3')
xlabel('t in seconds')
set(gca, 'XScale', 'log');

채택된 답변

Star Strider
Star Strider 2016년 7월 7일
Formatting your code would have helped for a start. See: TUTORIAL: how to format your question with markup.
I’m not familiar with the Bateman equations, so doing a bit of research (see Introduction to Nuclear Science - GSI, slides 23-4), it seems to me that these equations:
h1=ezplot(char(eq1), [tmin,tmax,ymin,ymax]);
h2=ezplot(char(eq2), [tmin,tmax,ymin,ymax]);
h3=ezplot(char(eq3), [tmin,tmax,ymin,ymax]);
need to be solved and then summed rather than plotted individually. (It doesn’t appear that they be solved as a system.) See if that works for you.
I’ve not done anything with radioactive decay since undergraduate physical chemistry, so a relevant free reference on the Bateman equations would help.
  댓글 수: 11
Derek Haws
Derek Haws 2016년 7월 8일
편집: Derek Haws 2016년 7월 8일
Thank you, I was working with my advisor on this today. Trouble shooting the code showed that the code was solving correctly and that the problem was in the ezplot. We also used the matlabFunciton and plot to see that it was doing the calculations correctly. Sorry I was not able to pose the question correctly. I appreciate your help. Your code will also solve the problem and produces the same results.
Star Strider
Star Strider 2016년 7월 8일
My pleasure.
Once I understood your system you’re studying, I knew the problem was that you needed to integrate it as a system, and not as individual equations.
The easiest way would be to create one anonymous function from the equations in your system, and then use ode15s to solve it. (It’s a ‘stiff’ system because the magnitudes of the parameters vary across a wide range.) The anonymous function will pick up the values of the parameters from your workspace, so you could probably integrate and plot your equations in at most a couple dozen lines of code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by