Can the code be modified and matched with the attached pdf
Afficher commentaires plus anciens
%% Can someone modify the code to run and match figs in the attached pdf AND also want to draw some surf plot
% u_t(x,t) = u_{xx}(x,t) + Gr*T + Gc*C - Q*u, T_t(x,t) = (1/Pr)*T_{xx}(x,t) - phi*T, C_t(x,t) = (1/Sc)*C_{xx}(x,t) - Kc*C,
% u(x,0) = 0,T(x,0) = 0,C(x,0) = 0, x,t <=0
% u(0,t) = a*t, T(0,t) = t, C(0,t) = exp(t),
% u(Inf,t) = 0, T(Inf,t) = 0, C(Inf,t) = 0.
Gr = 4; Gc = 4; phi = 0.2; Pr = 0.71; Sc = 0.22; Kc =1; M = 2; Kp = 0.5; Q = M + (1/Kp);
xl = 0; xr = 1; J = 100; dx = (xr-xl)/ J; tf = 0.1; Nt = 50; dt = tf/Nt; mu = dt/(dx)^2;
%%% To consider below 3 LINES, take J = 10;
% if mu > 0.5 % make sure dt satisy stability condition
% error('mu should < 0.5!')
% end
x = xl : dx : xr;
% f = zeros(2,J); g = zeros(2,J); h = zeros(2,J);
f = 0; g = 0; h = 0; u = zeros(J+1,Nt); v = zeros(J+1,Nt); w = zeros(J+1,Nt);
for n = 1:Nt
t = n*dt;
% boundary condition at left side and right side
a = 0.2; gl = [a*t; t; exp(t)]; gr = [0; 0; 0];
if n == 1 % first time step
for j = 2:J % interior nodes
% u(j,n) = f(j) + mu*( f(j+1) - 2* f(j) + f(j-1) - Gr * g(j) + Gc * h(j) - Q * f(j) );
% v(j,n) = g(j) + (mu/Pr) *( g(j+1) - 2* g(j) + g(j-1) - phi * g(j) );
% w(j,n) = h(j) + (mu/Sc) *( h(j+1) - 2* h(j) + h(j-1) - Kc * h(j) );
u(j,n) = exp(t);v(j,n) = 0; w(j,n) = 0;
end
u(1,n) = gl(1); v(1,n) = gl(2); w(1,n) = gl(3); % the left-end point
u(J+1,n) = gr(1); v(J+1,n) = gr(2); w(J+1,n) = gr(3); % the right-end point
else
for j = 2:J % interior nodes
u(j,n) = u(j,n-1) + mu*(u(j+1,n-1) - 2*u(j,n-1) + u(j-1,n-1) + Gr* v(j,n-1) + Gc* w(j,n-1) - Q* u(j,n-1) );
v(j,n) = v(j,n-1) + (mu / Pr)*(v(j+1,n-1) - 2*v(j,n-1) + v(j-1,n-1) - phi* v(j,n-1) );
w(j,n) = w(j,n-1) + (mu / Sc)*( w(j+1,n-1) - 2* w(j,n-1) + w(j-1,n-1) - Kc* w(j,n-1) );
end
end
end
% Plot the results
tt = dt : dt : Nt*dt;
figure(1),surf(x,tt, u'); hold on, xlabel('x'),ylabel('t'),zlabel('u'),title('Numerical solution of 1-D parabolic equation')
figure(2),plot(x,u(:,1)); hold on, xlabel('x'),ylabel('u')
7 commentaires
Adam Danz
le 13 Août 2021
> Can the code be modified and matched with the attached pdf
Yes.
Any code can be modified (which includes being completely rewritten) to represent a valid function.
MINATI PATRA
le 13 Août 2021
Modifié(e) : MINATI PATRA
le 13 Août 2021
I enjoy helping others learn Matlab (that's how I learned it, too). But I try to refrain from doing other people's work for them. It would take a significant amount of time to study the paper and map it into your code and then find the errors.
Wan Ji
le 14 Août 2021
I can't agree with you more!@Adam Danz
MINATI PATRA
le 14 Août 2021
MINATI PATRA
le 19 Août 2021
Réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!