kill(all)$

ode : part2,intro: ricatti 
peter.vlasschaert@gmail.com,03/02/2017

# Theory Ricatti : ODE (reaction kinetics)

(dy/dx) = p(x)*y^2+q(x)*y+r(x)
Why: Consecutive Reactions and Ricatti
                      k1   k2
reaction kinetics : A -> B -> C
dCA/dt = - k1*CA^n          (1)
dCB/dt = k1*CA^n-k2*CB^m    (2)
dCC/dt = k2*CC^l            (3)
                                              
integer values :  n,m,l 
concentration  : CA,CB,CC

load('contrib_ode)$
assume(t>0,CA>0,CB>0)$

equation (2) n=1,m=1, by 't=0 -> CA=CA0'

eq1: CA = CA0*%e^(-k1*t);
eq2:'diff(CB,t)=k1*CA^1-k2*CB^1;

first order ODE : dCB/dt+g(t)*CB = f(t)

method1:

eq3:subst(rhs(eq1),CA,eq2);
eq4:part(eq3,2,2);
eq5: lhs(eq3)-eq4=rhs(eq3)-eq4;

eq6:contrib_ode(eq5,CB,t)[1];

assume CB=0 by 't=0 find %c'

eq7:ev(eq6,t=0,CB=0);
eq8:solve(eq7,%c)[1];

eq9:subst(rhs(eq8),%c,eq6);

eq10:radcan(eq9);

eq11:factor(part(eq10,2,1));

eq12:lhs(eq10)=eq11/part(eq10,2,2);

check : solution n=1,m=1

eq13:ratsubst(rhs(eq12),CB,eq3);

eq14:ev(part(eq13,1),nouns)=ev(part(eq13,2),nouns);

eq5:radcan(eq14);