kill(all)$

maxima : kinetics :reaction nA → productes, k,version 1.0
peter.vlasschaert@gmail.com,16/01/2023

reaction :                  nA → products 
--------------------------------------------
type : simple reaction , no complex
--------------------------------------------
==========================
model :'diff(CA(t),t,1)=-k*CA(t)^n
ic: @t=0, CA(t) =CA0
==========================

assume(n>0)$

declare(n,integer)$

p1:diff(CA(t),t) =-k*(CA(t))^n;

integrate('diff(CA(t),t,1)=-k*CA(t)^n, t);

p1a:listofvars(p1);

p1aa:args(p1)[1];

p1aaa:args(p1aa)[1];

→no solution : desolve

p2:desolve(p1,CA(t));

no : solution .

→ integration : ODE2

p3:args(lhs(p1)) =args(rhs(p1));

p3a:[CA(t) = y];

p3b:subst(p3a,p1);

→ if n=1 then

assume(equal(n,1));

p3b1:ode2(p3b,y,t);

→ method :ode2

method;

p3b11:sort(listofvars(p3b1));

solve : y , @t=0 ,then y=CA0

p3b1a:subst([t=0,y=CA0],p3b1);

→  p3b1a  into p3b1

p3b12aa:subst([reverse(p3b1a)],p3b1);

→ subst y =CA(t)

p3aa:subst([y =CA(t)],p3b12aa);

→ if n ≠ 1 then

forget(equal(n,1));

assume(n>1);

p3b2:ode2(p3b,y,t);

solve : y , @t=0 ,then y=CA0

p3b2a:subst([t=0,y=CA0],p3b2);

→  p3b2a  into p3b2

p3b12bb:subst([reverse(p3b2a)],p3b2);

→ subst y =CA(t)

p3bb:subst([y =CA(t)],p3b12bb);

find : k , rate reaction constant
----------------------------------------

→ if n=1 :p3aa

p4a:solve(p3aa,k)[1];

→ if n≠1 :p3bb

p4b:solve(p3bb,k)[1];

find : CA(t), concentration of A as function of time
---------------------------------------------------------------

→if n=1,use : p4a

p5a:solve(p4a,CA(t))[1];

check @t=0, CA(t)
-----------------------

p5a1:subst([t=0],p5a);

→ if n≠1 :p4b

p5b:solve(p4b,CA(t))[1];

check @t=0, CA(t)
-----------------------

p5b1:subst([t=0],p5b);

p5b2:ratsimp(p5b1);

p5b3:subst([n=2],p5b2);

-------------------------------------------------------------------------------------

integrate : p1

assume(CA0>0,CA>0);

assume(CA0>CA);

p6:integrate(y^(-n),y,CA0,CA) =-k*t;

p6a:expand(solve(p6,CA))[1];

p6b:lhs(p6a)=collectterms(rhs(p6a),(CA)^n);

p6c:part(rhs(p6b),1);

p6d:p6b/p6c;

p6e:solve(p6d,CA)[1];

check :rhs(p5b) and rhs(p6e)
-----------------------------------

p6f:is(rhs(p5b)=rhs(p6e));

---------------------------------------------------------------------------