This document contains the code for a numerical simulation of a reaction-diffusion process. It defines constants, grid parameters, and differential equations to model the diffusion and reaction of temperature and concentration over time and space in a 1D grid. The code sets up arrays to store temperature and concentration values at each grid point and time step. It then loops over time steps, calculating the new temperature and concentration at each interior grid point using finite difference approximations of the governing partial differential equations, with boundary conditions also defined.
This document contains the code for a numerical simulation of a reaction-diffusion process. It defines constants, grid parameters, and differential equations to model the diffusion and reaction of temperature and concentration over time and space in a 1D grid. The code sets up arrays to store temperature and concentration values at each grid point and time step. It then loops over time steps, calculating the new temperature and concentration at each interior grid point using finite difference approximations of the governing partial differential equations, with boundary conditions also defined.
This document contains the code for a numerical simulation of a reaction-diffusion process. It defines constants, grid parameters, and differential equations to model the diffusion and reaction of temperature and concentration over time and space in a 1D grid. The code sets up arrays to store temperature and concentration values at each grid point and time step. It then loops over time steps, calculating the new temperature and concentration at each interior grid point using finite difference approximations of the governing partial differential equations, with boundary conditions also defined.
eps=0.69;ros=904000;rog=508; lamda=5.64;u=0.3;Uw=0.1377;aw=272; Tc=323;del_H=802000;D=6.52*10^-6; Ea=9.629*10^4;R=8.3145; k_inf=7.34*10^7;kc=0.115;av=2000;nu=1; K=(1-eps)*ros+eps*rog a1=lamda/K;b1=u*rog/K;c1=Uw*aw/K;d1=del_H/K; a2=D;b2=u/eps;d2=1/eps; e1=-((u*rog)/lamda);e2=-(u/(eps*D)) L=0.25;tmax=60; del_z=0.001;del_t=0.01; Nz=(L/del_z)+1; Nt=(tmax/del_t)+1; r=del_t/del_z^2; s=del_t/del_z; for j=1:Nz z(j)=(j-1)*del_z; end for n=1:Nt t(n)=(n-1)*del_t; end Tc=323; A=0.1;B=0.07;w=0; T(1:Nz,1)=773; C(1:Nz,1)=0; Tin=323; for n=1:Nt-1 T(1,n+1)=T(1,n)+a1*r*2*(T(2,n)-T(1,n))-b1*s*(T(1,n)-T(2,n))- c1*del_t*(T(1,n)-Tc)+d1*del_t*g(T(1,n))*C(1,n); C(1,n+1)=C(1,n)+a2*r*2*(C(2,n)-C(1,n))-b2*s*(C(1,n)-C(2,n))- d2*del_t*g(T(1,n))*C(1,n); for j=2:Nz-1 T(j,n+1)=T(j,n)+a1*r*(T(j+1,n)-2*T(j,n)+T(j-1,n))-b1*s*(T(j,n)-T(j- 1,n))-c1*del_t*(T(j,n)-Tc)+d1*del_t*g(T(j,n))*C(j,n); C(j,n+1)=C(j,n)+a2*r*(C(j+1,n)-2*C(j,n)+C(j-1,n))-b2*s*(C(j,n)-C(j- 1,n))/2-d2*del_t*g(T(j,n))*C(j,n); end T(Nz,n+1)=T(Nz-1,n)+a1*r*(T(Nz-2,n)-T(Nz-1,n)+(Tin-T(Nz-1,n))*2*del_z*e1)- b1*s*(-(Tin-T(Nz-1,n))*2*del_z*e1)+c1*del_t*(T(Nz-1,n)-Tc)-d1*del_t*g(T(Nz- 1,n))*C(Nz-1,n); C(Nz,n+1)=C(Nz-1,n)+a2*r*(C(Nz-2,n)-C(Nz-1,n)+(Cin(t(n))-C(Nz- 1,n))*2*del_z*e2)-b2*s*(-(Cin(t(Nz-1))-C(Nz-1,n))*2*del_z*e2)-d2*del_t*g(T(Nz- 1,n))*C(Nz-1,n); end function gt=g(x) gt=nu*k_inf*kc*av*exp(-Ea/(R*x))/(kc*av+nu*k_inf*exp(-Ea/(R*x))); end function cint=Cin(t) cint=A+B*sin(w*t); end end