how to solve PDE with derivative boundary conditions ?

์กฐํšŒ ์ˆ˜: 22 (์ตœ๊ทผ 30์ผ)
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 1์ผ
๋Œ“๊ธ€: darova 2021๋…„ 4์›” 3์ผ
hey all
im trying to solve PDE with derivative boundary condition , so i tend to use the imaginary node method , could i have another way to solve it without any built in function
this is the qustion:
๐œ•๐‘‡๐œ•๐‘ก=๐œ•2๐‘‡๐œ•๐‘ฅ2+๐‘ž(๐‘ฅ) (1)
With ๐‘ž(๐‘ฅ)=100sin(๐œ‹๐‘ฅ) (2)
1)
๐‘‡(๐‘ฅ,0)=0 (3)
2)
๐œ•๐‘‡๐œ•๐‘ก(0,๐‘ก)=๐‘‡(0,๐‘ก)โˆ’10 (4)
3)
๐œ•๐‘‡๐œ•๐‘ก(1,๐‘ก)=10โˆ’๐‘‡(1,๐‘ก) (5)
clear all;
close all;
clc;
%% Demo program for parapolic pde
dt = 0.25;
dx = 0.1*dt;
alpha=1;
t = 0:dt:15;
x = 0:dx:4;
q_x=(100*sin(pi*x));
N = length(x)-1;
T=[]; %Dynamic size
T(1,:) = zeros(1,5) ; %Initial condition
for j=1:length(t)-1
T(1,N-1) = T(j+1,N) + (2*dx*(T(j+1,N+1)-10));
for i=2:N
T(j+1,i) = T(j,i)+alpha*(dt/(dx^2))*(T(j,i+1)+ T(j,i-1)-2*T(j,i))+q_x;
end
T(2,N+2) = T(j+1,N) + (2*dx*(10-T(j+1,N+1)));
end
mesh(t,x,T)
colorbar;
the code isn't evaluated , what is the proplem?
  ๋Œ“๊ธ€ ์ˆ˜: 3
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 2์ผ
...
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 2์ผ
...

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

darova
darova 2021๋…„ 4์›” 2์ผ
Try these corrections
T = zeros(length(t),length(x));
for j=1:length(t)-1
T(j+1,1) = T(j,1) + dt*(T(j,1)-10);
T(j+1,N) = T(j,N) + dt*(10-T(j,N));
for i=2:N-1 % changed
T(j+1,i) = T(j,i)+alpha*(dt/(dx^2))*(T(j,i+1)+ T(j,i-1)-2*T(j,i)) + q_x(i); % note: q_x(i)
end
end
mesh(t,x,T)
  ๋Œ“๊ธ€ ์ˆ˜: 2
Mohammad Adeeb
Mohammad Adeeb 2021๋…„ 4์›” 2์ผ
ํŽธ์ง‘: Mohammad Adeeb 2021๋…„ 4์›” 2์ผ
it's worked but the mesh result is totally wrong
darova
darova 2021๋…„ 4์›” 3์ผ
I made some change sto your code. Some notes:
  • should be larger than ( should be small )
  • should be small too
  • i changed boundary conditions ๐œ•๐‘‡๐œ•๐‘ก(0,๐‘ก)=๐‘‡(0,๐‘ก)โˆ’10 and ๐œ•๐‘‡๐œ•๐‘ก(1,๐‘ก)=10โˆ’๐‘‡(1,๐‘ก)
clc,clear
%% Demo program for parapolic pde
dt = 0.25;
dx = 5*dt;
alpha=1;
t = 0:dt:5;
x = 0:dx:20;
q_x = sin(pi*x/max(x));
N = length(x);
r = alpha*dt/dx^2;
T = zeros(length(t),length(x));
for j=1:length(t)-1
T(j+1,1) = T(j,1) + dt*(T(j,1)-1/10); % changed these
T(j+1,N) = T(j,N) + dt*(1/10-T(j,N));
for i=2:N-1 % changed
T(j+1,i) = T(j,i)+r*diff(T(j,i-1:i+1),2) + q_x(i); % note: q_x(i)
end
end
surf(x,t,T)

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ PDE Solvers์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by