how to solve a 1d heat eqn with periodic BCs, u(0)=u(L) using implicit euler and finding the maximum error at Tend after comparing with the exact solution? obviously creating a finite difference matrix..i have done till finding the exact soln..

1 回表示 (過去 30 日間)
TJ
TJ 2016 年 11 月 19 日
回答済み: Sebastian K 2016 年 11 月 23 日
L = 1; %length of the rod
n = 2;
nu = 1; % thermal diffusivity nu=1
Nx = 50; %length steps
Nt = 100; %time steps
Tend = 0.1;
mesh = linspace(0,L,Nx); %mesh size
dt = linspace(0,Tend,Nt); %time step interval
dx = mesh(2)-mesh(1); %length step interval
f = @(t,u) nu*(1/dx^2*A)*u;
lam = (n*pi/L)^2;
u(:,1) = sin(sqrt(lam)*mesh(1:Nx-1)); %initial condition
u_exact = exp^(-lam*t)*sin(sqrt(lam)*mesh(1:Nx-1));
  4 件のコメント
TJ
TJ 2016 年 11 月 20 日
編集済み: Walter Roberson 2016 年 11 月 20 日
-2 1 0 0 1 0
1 -2 1 0 0 0
0 1 -2 1 0 0
0 0 1 -2 1 0
0 0 0 1 -2 1
0 1 0 0 1 -2
this is how my A matrix is looking since u(0-1)=u(Nx-1)
Walter Roberson
Walter Roberson 2016 年 11 月 20 日
Please be more specific about what your question is. What is it you are asking of us?

サインインしてコメントする。

回答 (1 件)

Sebastian K
Sebastian K 2016 年 11 月 23 日
For these types of computational problems, it is always a good idea to derive the mathematical equations first. This way you can split the problem into two parts:
1) Deriving the mathematical model.
2) Implementing your model in MATLAB.
I recommend that you first start with obtaining a clear form of the equations that you are trying to solve. It is important to understand the mathematics before you try to implement a code to solve a problem.
There are plenty of online course materials available regarding the solution of the 1-D heat equation using explicit and implicit methods. As an example consider the following slides:
Once you have a description of what equations you are trying to solve, people on this forum would be able to provide more useful recommendations.

カテゴリ

Help Center および File ExchangePhysics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by