kill(all)$

maxima : fvm : 2D convection-diffusion (start : general 1D transport equation), part 1, version 1.0
peter.vlasschaert@gmail.com.13/12/2022

ref:
maxima : fvm :convection -diffusion relation peclet cell number (max :limit),version 1.0

1e) 1d transport equation :
----------------------------------

unsteady (=depent on time),with S as source term

p1:'diff(ρ*Φ,t)+'diff(u*ρ*Φ,x) = 'diff(Γ*'diff(Φ,x),x)+S;

ρ                = density
u                = velocity x-direction 
Φ                =  function ( see below ,Φ(x))
Γ                = diffusion coef.
S                = source term
'diff(ρ*Φ,t) = time depent term ( = unsteady part)

2e) 1d : convection-diffusion,unsteady , S =0
-----------------------------------------------------------

→ find : unsteady term in "p1"

p1a : lhs(p1);

p1b:makelist(part(p1a,i),i,1,length(p1a));

p1b1:makelist(args(p1b[i]),i,1,length(p1b));

p1b2:makelist(p1b1[i][2],i,1,length(p1b1));

t : second element , p1b[2] of list p1b.

member(t,p1b2);

for i:1 thru length(p1b1) do(
if t = p1b2[i] then sa1:i
)$

second element:

sa1;

for i:1 thru length(p1b1) do(
if member (t, [p1b2[i]])  then sa2:i
)$

sa2;

myfindelement(t1,ll1):=block(
for i:1 thru length(ll1) do(
if member (t1, [ll1[i]])  then sa3:i        
), return(sa3)
)$

→  optimized : code.

grind(myfindelement)$

rem : member (t1, [ll1[i]])  = true then [1]
[1] ={sa3:i}

p1b3:myfindelement(t,p1b2);

p1b4:[S=0,p1b[myfindelement(t,p1b2)]=0];

final : 1D diffusion-convection equation, steady,S=0
-----------------------------------------------------------------------

p2:subst(p1b4,p1);

assume : Γ : constant , 1D "dimension =" : Φ =Φ(x)

p2a:declare([Γ],constant)$
p2b:depends([Φ,u],x)$

p2b:lhs(p2) =ev(rhs(p2),nouns);

3e) 2D :diffision-convection equation,steady,S=0
-----------------------------------------------------------------
u : velocity  → x-direction
v : velocity   → y-direction
2D "dimension =" :Φ = Φ(x,y)

p3:subst([x=y,u=v],p2b);

→ final : 2D :diffision-convection equation

p3a:p2b+p3;

p3b:lhs(p3a) = collectterms(rhs(p3a) ,Γ);

→  convection = diffusion 

we need :Φ :Φ(x,y), u :u(x) , v:v(y)
---------------------------------------------
see : 3e)

dependencies;

kill(Φ)$

rem :remove(Φ,dependency)

dependencies;

depends(v,y,Φ,[x,y]);

dependencies;

general : evaluation
---------------------------

p3c1:ev(p3b,nouns);

specefic : evaluation
---------------------------

p3c2:ev(p3b,diff);

dependencies;

display2d:false$

p3c3:p3c2;

kill(dependencies)$
dependencies;

rem : declare "above".

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

keywords : "maxima = " :member,dependencies,depends,declare,display2d .
-------------------------------------------------------------------------------------------------
option : display2d  → true or false
-------------------------------------------------------------------------------------------------
use :

---------------------------------------------------
definition :     myfindelement(t1,ll1)
---------------------------------------------------
? : t1 ∈ ll1 → true : ll1[position in ll1 ].
---------------------------------------------------
-------------------------------------------------------------------------------------------------------------------