在Matlab中通过更改域来数值求解pde

时间:2017-10-16 21:13:16

标签: matlab pde

我正在尝试将更改域实现到我的Matlab代码中,该代码以数字方式解决了pde。在给定的问题中,我正在模拟面包的烘焙。这是一个问题,其中有一个来自上面的热源。我正在使用热扩散方程,对于固定域,我提供了下面的代码来解决它。但是,我还需要模拟面包的上升,所以随着时间的推移我的域名,' L'在我的代码中,更改。我被告知我可以假设它在一小时内线性变化,而面包最初填充了80%的锡。你们对我如何应对崛起有什么建议?

close all
clear all
clc


Tend = 3600; %Time to end after
dt = 1; %Time step size
Nstep = (Tend/dt)+1; %Number of time points
M = 1000; %Number of x points
dx = 1/M; %Size of the x steps
L = 1; %Length of domain
x = [0:dx:L]; %Creating the x points
kdiff = 2.7e-4; %Diffusion constant value
R = kdiff*dt/(dx*dx);

for i = 1:M+1
  u(i,1) = 20;
end 

for n = 1:Nstep
    DIG(1) = 1;
    b(1) = 200; %Boundry condition
    DIG(M+1) = 1;
    LF(1) = 0;
    RT(1) = 0; 
    LF(M+1) = -1; %Insulated boundry
    RT(M+1) = 0;
    b(M+1) = 0; %Boundry condition
    for m = 2:M
        DIG(m) = 2+(2/R);
        LF(m) = -1;
        RT(m) = -1;
        b(m) = u(m+1,n) + u(m-1,n) + (-2 + (2/R))*u(m,n);
    end
    u(:,n+1) = tdma(LF,DIG,RT,b,M+1);
end

plot(x,u(:,1:600:end)

0 个答案:

没有答案