Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8317 > unrolled thread
| Started by | Alexei Boulbitch <Alexei.Boulbitch@iee.lu> |
|---|---|
| First post | 2012-02-03 07:13 +0000 |
| Last post | 2012-02-04 11:40 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
PDE with RecurrenceTable Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-02-03 07:13 +0000
Re: PDE with RecurrenceTable Peter Pein <petsie@dordos.net> - 2012-02-04 11:38 +0000
Re: PDE with RecurrenceTable "Nasser M. Abbasi" <nma@12000.org> - 2012-02-04 11:40 +0000
| From | Alexei Boulbitch <Alexei.Boulbitch@iee.lu> |
|---|---|
| Date | 2012-02-03 07:13 +0000 |
| Subject | PDE with RecurrenceTable |
| Message-ID | <jgg1es$bph$1@smc.vnet.net> |
Dear Community,
I am trying to make a simple numeric FEM solution of parabolic PDE. It seems that RecurrenceTable function is designed exactly for such a job. Indeed, in the Help/RecurrenceTable/Scope/Partial Difference Equations one finds an example. My problem is that this example is only one, and I would say, it is not basic enough.
My question: do you know some other examples of the use of the RecurrenceTable for this sort of equations??
I would like to explain: I already went through the MathGroup archive and have seen numerous posts recommending various sophisticated FEM packages. My question is not about them. I want to learn to make simple programs of this sort myself to fast test an equation at hand.
For example, here is a classical equation of temperature conductivity:
(\[PartialD]u(x,t))/\[PartialD]t=a^2*(\[PartialD]^2u(x,t))/\[PartialD]x^2
with a=0.1, the boundary conditions: u[0,t]==1 and u[1,t]==0 and the initial condition u[x,0]== Cos[3 \[Pi]*x/2];
using the explicit method on the rectangular lattice, taken from a textbook:
u[j,k+1]=\[Sigma]*u[j+1,k]+(1-2*\[Sigma])*u[j,k]+\[Sigma]*u[j-1,k];
\[Sigma]=(a^2*\[Tau])/h^2;
Tau and h are temporal and spatial step sizes.
This is the code:
a = 0.1;
h = 0.1;
\[Tau] = 0.0001;
\[Sigma] = a^2*\[Tau]/h^2;
lst2 = RecurrenceTable[{u[j,
k + 1] == \[Sigma]*u[j + 1, k] + (1 - 2*\[Sigma])*
u[j, k] + \[Sigma]*u[j - 1, k], u[j, 0] == Cos[3 Pi*j/20.],
u[0, k] == 1, u[10, k] == 0}, u, {j, 0, 10}, {k, 0, 100}];
Show[{
ListPlot3D[lst2,
AxesLabel -> {Style["t", 16, Italic], Style["x", 16, Italic],
Style["u", 16, Italic]}, PlotStyle -> Blue],
Plot3D[0, {t, 0, 100}, {x, 0, 10},
PlotStyle -> {Yellow, Opacity[0.4]}]
}]
The solution obtained this way, however, does not show evolution. It is clear that with increasing t the temperature, u, should forget its initial form and approach to a straight line. What is wrong?
Thank you, Alexei
Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG
Office phone : +352-2454-2566
Office fax: +352-2454-3566
mobile phone: +49 151 52 40 66 44
e-mail: alexei.boulbitch@iee.lu<mailto:alexei.boulbitch@iee.lu>
[toc] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2012-02-04 11:38 +0000 |
| Message-ID | <jgj5as$n41$1@smc.vnet.net> |
| In reply to | #8317 |
Am 03.02.2012 08:13, schrieb Alexei Boulbitch:
> Dear Community,
>
>
>
> I am trying to make a simple numeric FEM solution of parabolic PDE. It seems that RecurrenceTable function is designed exactly for such a job. Indeed, in the Help/RecurrenceTable/Scope/Partial Difference Equations one finds an example. My problem is that this example is only one, and I would say, it is not basic enough.
>
>
>
> My question: do you know some other examples of the use of the RecurrenceTable for this sort of equations??
>
>
>
> I would like to explain: I already went through the MathGroup archive and have seen numerous posts recommending various sophisticated FEM packages. My question is not about them. I want to learn to make simple programs of this sort myself to fast test an equation at hand.
>
>
>
> For example, here is a classical equation of temperature conductivity:
>
>
>
> (\[PartialD]u(x,t))/\[PartialD]t=a^2*(\[PartialD]^2u(x,t))/\[PartialD]x^2
>
>
>
> with a=0.1, the boundary conditions: u[0,t]==1 and u[1,t]==0 and the initial condition u[x,0]== Cos[3 \[Pi]*x/2];
>
> using the explicit method on the rectangular lattice, taken from a textbook:
>
>
>
> u[j,k+1]=\[Sigma]*u[j+1,k]+(1-2*\[Sigma])*u[j,k]+\[Sigma]*u[j-1,k];
>
> \[Sigma]=(a^2*\[Tau])/h^2;
>
>
>
> Tau and h are temporal and spatial step sizes.
>
>
>
> This is the code:
>
>
>
> a = 0.1;
>
> h = 0.1;
>
> \[Tau] = 0.0001;
>
> \[Sigma] = a^2*\[Tau]/h^2;
>
> lst2 = RecurrenceTable[{u[j,
>
> k + 1] == \[Sigma]*u[j + 1, k] + (1 - 2*\[Sigma])*
>
> u[j, k] + \[Sigma]*u[j - 1, k], u[j, 0] == Cos[3 Pi*j/20.],
>
> u[0, k] == 1, u[10, k] == 0}, u, {j, 0, 10}, {k, 0, 100}];
>
>
>
>
>
> Show[{
>
> ListPlot3D[lst2,
>
> AxesLabel -> {Style["t", 16, Italic], Style["x", 16, Italic],
>
> Style["u", 16, Italic]}, PlotStyle -> Blue],
>
> Plot3D[0, {t, 0, 100}, {x, 0, 10},
>
> PlotStyle -> {Yellow, Opacity[0.4]}]
>
> }]
>
>
>
> The solution obtained this way, however, does not show evolution. It is clear that with increasing t the temperature, u, should forget its initial form and approach to a straight line. What is wrong?
>
>
>
> Thank you, Alexei
>
>
>
>
>
> Alexei BOULBITCH, Dr., habil.
>
> IEE S.A.
>
> ZAE Weiergewan,
>
> 11, rue Edmond Reuter,
>
> L-5326 Contern, LUXEMBOURG
>
>
>
> Office phone : +352-2454-2566
>
> Office fax: +352-2454-3566
>
> mobile phone: +49 151 52 40 66 44
>
>
>
> e-mail: alexei.boulbitch@iee.lu<mailto:alexei.boulbitch@iee.lu>
Hi Alexei,
it seems to me that your tau (delta-t) and/or maximum k is far too small
to observe the flattening.
I'll use ListConvolve, because it is much faster; the algorithm is still
the same:
a=1/10; h=1/10; \[Tau]=1/10000;
\[Sigma]=a^2*\[Tau]/h^2;
kmax=121000; (* just to get the zero of u[3/4,t] *)
To avoid memory problems when plotting the result, I'll take ~ 100 data
lines:
lst2 = NestList[
Flatten[{1, ListConvolve[{\[Sigma], 1 - 2*\[Sigma], \[Sigma]}, #1],
0}] & ,
Table[Cos[(3.*Pi*j)/20], {j, 0, 10}],
kmax][[1 ;; All ;; Floor[kmax/100]]];
Now the flattening is visible "to the naked eye":
Show[ListPlot3D[lst2, AxesLabel -> {Style["x", 16, Italic],
Style["t", 16, Italic], Style["u", 16, Italic]},
PlotStyle -> {Lighter[Blue], Specularity[White, 22]},
DataRange -> {{0, 1}, {0, kmax*\[Tau]}}, PlotRange -> All],
Plot3D[0, {x, 0, 1}, {t, 0, kmax*\[Tau]},
PlotStyle -> {Yellow, Opacity[0.4]}]]
Peter
[toc] | [prev] | [next] | [standalone]
| From | "Nasser M. Abbasi" <nma@12000.org> |
|---|---|
| Date | 2012-02-04 11:40 +0000 |
| Message-ID | <jgj5fk$n5g$1@smc.vnet.net> |
| In reply to | #8317 |
On 2/3/2012 1:13 AM, Alexei Boulbitch wrote: > Dear Community, > > > > I am trying to make a simple numeric FEM solution of parabolic PDE. I am actually now writing a demo on this, but have not yet finished the FEM solver to solve Poisson on 2D, so I'll let you know soon what I find and if get into the same problem as you have ;) meanwhile, I have a Mathematica demo solving the same problem you are solving but using finite difference (a little easier I think than FEM), and direct solver, may be we can compare results? I have an option to show the solution grid. here it is: http://12000.org/my_notes/mma_demos/KERNEL/KERNEL.htm #25 on the table. It is CDF. Will update this when I finish the FEM solver, or make a new one just for FEM, since that is more complicated. --Nasser
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web