# Can the code be modified and matched with the attached pdf

조회 수: 1 (최근 30일)
MINATI PATRA 2021년 8월 12일
댓글: MINATI PATRA 2021년 8월 19일
%% 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이전 댓글 5개 표시이전 댓글 5개 숨기기
Rik 2021년 8월 15일

Are you sure you are allowed to post the paper in the first place? This smells like a copyright violation.

You could try contacting the author.

Have a read here. It will greatly improve your chances of getting an answer.

MINATI PATRA 2021년 8월 19일
Dear RIK
Actually I dont know whether thisnis the right place or not to post.
But I am one of the Authors of the attached paper.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by