How to use ode23s to solve heat equation

8 ビュー (過去 30 日間)
Xiaoyan
Xiaoyan 2014 年 11 月 13 日
コメント済み: Torsten 2014 年 11 月 24 日
assume ut=D*uxx D is constant, x = [-5:0.1:5], with delta_x=0.1 initial condition u(x0,0) = derivative of x boundary condition if x=-5 or 5 u(x,t)=0
hence can i write ODE that satisfy u1 to u99? then use ODE23s solve heat equation with initial data u50=1 and uj=0 where j=/50?
thank you!!

採用された回答

Torsten
Torsten 2014 年 11 月 21 日
If you are still interested in a solution for your problem:
Choose
u(x)=1/eps*max(1-abs(x/eps),0)
for eps=0.001, e.g. as initial condition for your Problem (this is an approximation to the Dirac Delta function).
Choose a very fine grid around x=0 such that the initial guess function is sufficiently resolved.
Then write the usual ODEs that result from
ut=D*uxx
and solve them using ODE15s.
If needed, I could also give you the analytical solution for comparison.
Best wishes
Torsten.
  2 件のコメント
Xiaoyan
Xiaoyan 2014 年 11 月 21 日
Many thanks Torsten,
Yeah, I would like to see the analytical solution for comparison
Xiaoyan
Torsten
Torsten 2014 年 11 月 24 日
The analytical solution for the problem
ut=D*uxx
u(x,0)=delta(x)
u(-5,t)=u(5,t)=0
is given by
u(x,t)=sum_{n=-oo}^{n=+oo}1/sqrt(Pi*D*t)*(exp(-(x-20*n)^2/(4*D*t))-exp(-(x-20*n+10)^2/(4*D*t)))
Best wishes
Torsten.

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

その他の回答 (4 件)

Orion
Orion 2014 年 11 月 13 日
Xiaoyan,
You're problem is a partial differential equation (PDE), so ode23 won't work, it's meant to solves ordinary differential equation (ODE).
for this kind of problem, if you have it, use the PDE toolbox .
If you don't have it, then you're gonna have to code your own finite element method (such as finite difference). you could probably some opensource code on the web for those methods.
  1 件のコメント
Torsten
Torsten 2014 年 11 月 13 日
Xiaoyan wants to apply the method of lines to the heat equation and solve the resulting system of ODEs using ODE23.
But I don't understand which Initial and boundary conditions he/she wants to impose.
Best wishes
Torsten.

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


Xiaoyan
Xiaoyan 2014 年 11 月 13 日
Thank you both, Torsten is right about my approach. for my question
Initial condition is: u(x,0)=δ(x) Boundary condition is: u(-5,t)=u(5,t)=0
I hope this make the question clearer.
Many thanks, Xiaoyan

Torsten
Torsten 2014 年 11 月 13 日
I guess numerical methods are not adequate if Dirac-Delta function is used as initial condition.
You should look up the analytical solution for this problem.
Best wishes
Torsten.

Zoltán Csáti
Zoltán Csáti 2014 年 11 月 13 日
I would suggest an other way. A time-dependent differential equation can be solved not only by the method of lines, but also using the so-called Rothe's approach, ie. you discretize first in time and then is space. So use for example the forward Euler-method to prepare the semi-discrete equation that can be discretized by FDM/FEM or a spectral method.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by