kill(all)$

maxima : simple reaction > a*A+b*B -> c*C+d*D,version 1.0
peter.vlasschaert@gmail.com,15/01/2023

print (a*A+b*B,"→",c*C+d*D)$

products      :c*C+d*D
reactantia    :a*A+b*B

r =-1/a*diff(CA(t),t) =-1/b*diff(CB(t),t) =1/c*diff(CB(t),t) =1/d*diff(CD(t),t)
r = k*(CA(t))^a*(CB(t))^a , "POWER LAW coef to power" > law of mass action

info :

a,b,c,d  =stiochiometric coefficient
r = reaction rate > 0
k = reaction rate constant

assume(a>0,b>0,c>0,d>0);

declare([a,b,c,d],integer);

find out : a

properties(a);

other : example : sum

properties(sum); /*"function from maxima"*/

declare(sum,linear);/* extra :properties */
properties(sum);

step 1:-1/a*diff(CA(t),t) =k*(CA(t))^a*(CB(t))^b
----------------------------------------------------------

p1:-1/a*diff(CA(t),t) =k*(CA(t))^a*(CB(t))^b;

p1a:(args(lhs(p1*a)))[1];

p1aa:args(p1a)[1];

p1b:solve(p1,p1a);

step 2:-1/b*diff(CB(t),t) =k*(CA(t))^a*(CB(t))^b
----------------------------------------------------------

p2:-1/b*diff(CB(t),t) =k*(CA(t))^a*(CB(t))^b;
p2a:(args(lhs(p2*b)))[1];
p2aa:args(p2a)[1];
p2b:solve(p2,p2a);

step 3: combine step 1 ,step 2
------------------------------------

→ differential equations

p3:flatten([p1b,p2b]);

→ variables

p3a:[p1aa,p2aa];

step 4:solve 
---------------

p4:desolve(p3,p3a);

step 5 : A+2*B → products
---------------------------------
example :overal reaction order  "a+b"
substance A :  reaction a order for A (example : a=1 ,first     order)
substance B :  reaction b order for B  (example : b=2 ,second order)

p5:[a=1,b=2];

p5a:subst(p5,p4);

→ initial :CA(0) = A0,CB(0) =B0 for concentration @t=0

assume(k>0);

p5b:[CA(0) = A0,CB(0) =B0];

p5b1:subst(p5b,p5a);

p5b2:subst([g534=s],p5b1);

set :F(s) =laplace(CA(t)·CB(t)^2,t,s)

p5b3:subst([laplace(CA(t)·CB(t)^2,t,s)=F(s)],p5b2);

laplace → function of s : time           domain > frequency domain 
ilt         → function of t :  frequency domain > time          domain 

rem : "see below" what is relation > s & frequency

simple example : f(t) =b*sin(t) , t =time
---------------------------------------------

principal :

→ lapace transform :

p6a:laplace(b*sin(a*t),t,s);

→ inverse laplace transform

p6b:ilt(p6a,s,t);

other example : f1(t) =a*exp(-k*t)

p6a1:laplace(a*exp(-k*t),t,s);
p6b1:ilt(p6a1,s,t);

other example : f2(t) =b*t*sin(a*t)*exp(-k*t)

p6a2:laplace(b*t*sin(a*t)*exp(-k*t),t,s);
p6a2a:print("(num)erator     = ",num(p6a2));
p6a2b:print("(denom)inator  =",denom(p6a2));
p6b2:ilt(p6a2,s,t);

rem :{(k*F(s)-A0)/s ,(2*k*F(s)-B0)/s} -> G(s) =M(s)/N(s) > ? solution,see "example"
==========================================================
result:            p6a2  =>  G(s)
---------------------------------------------------------------------------------------------------
s     → differentation
1/s  → integration
combine : fourier transform , s=i*ω , i=sqrt(-1), "complex number : z =aa*i+b",
s=2*pi*frequency =2*pi*ν , v =1/T , T = period " =TIME"
---------------------------------------------------------------------------------------------------

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