求一个一维瞬态热传导的有限元matlab代码,应用第一类边界条件的 一维热传导方程matlab
求一个一维瞬态热传导的有限元matlab代码
是transient 1D heat conduction的离散化求解导热微分方程吗?如果是的话,先追加150币采纳答案再发给你。
求高手给出一维热传导方程解的图形的matlab代码
function main
%热传导方程的差分解法
lda=0.000015;%lad即为a^2
l=50;
h=0.05;%空间步长
alpha=0.5;
tao=alpha*h^2/lda; %时间步长
N=l/h;%空间步数
M=100;%时间步数,由于你条件没有限制,所以我随便取了个值
for i=1:N+1
u(1,i)=fai((i-1)*h);
end
for k=1:M
u(k,1)=g1(k*tao);
u(k,N+1)=g2(k*tao);
end
for k=1:M
for i=2:N
u(k+1,i)=alpha*u(k,i+1)+(1-2*alpha)*u(k,i)+alpha*u(k,i-1);
end
plot([0:h:l],u(k+1,:));
hold on; pause(0.05);
end
function u=fai(x)
u=100;
function u=g1(x)
u=0;
function u=g2(x)
u=0;
就这个拉,你试试看行不,不行的话在联系我吧!!
热传导问题与有限元matlab计算
%2D HeatEquation.
clear; close all; clc
%grid has n - 2 interior pointsper dimension (overlapping)
n=5;
m=6;
p=m*n
x =linspace(0,1,n); dx = x(2)-x(1);
y =linspace(0,1,m); dy = dx;
TOL = 1e-6;
T = zeros(p);
T(1,1:n) = 20; %TOP
T(m,1:n) =10; %BOTTOM
T(1:m,1) =35; %LEFT
T(1:m,n) =25; %RIGHT
dt = dx^2/4;
error = 1; k =0;
while error > TOL
k = k+1;
Told = T;
for i = 2:m-1
for j = 2:n-1
T(i,j) =dt*((Told(i+1,j)-2*Told(i,j)+Told(i-1,j))/dx^2 ...
+(Told(i,j+1)-2*Told(i,j)+Told(i,j-1))/dy^2) ...
+ Told(i,j);
end
end
error = max(max(abs(Told-T)));
end
Tmax=max(T);
Tmin=min(T);
Tx22=T(5,2);
%subplot(2,1,1),contour(x,y,T),
%title('Temperature(Steady State)'),xlabel('x'),ylabel('y'),colorbar
%subplot(2,1,2),pcolor(x,y,T),shadinginterp,
%title('Temperature(Steady State)'),xlabel('x'),ylabel('y'),colorbar
用matlab编程:pde工具箱在热传导,静电学等方面的应用
template<class Type>
Type Stack<Type>::popDataOutOfStack()
{
Type value=0;
if(isEmputy())
{
cout<<"栈中数据已经清空!"<<endl;
return value;
}
count--;
value=*(data+count);
return value;
}