Bateman equation using dsolve
10 views (last 30 days)
Show older comments
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');
0 Comments
Accepted Answer
Star Strider
on 7 Jul 2016
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 Comments
Star Strider
on 8 Jul 2016
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.
More Answers (0)
See Also
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!