MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: PDE with RecurrenceTable

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124766] Re: PDE with RecurrenceTable
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 4 Feb 2012 06:33:42 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jgg1es$bph$1@smc.vnet.net>

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 at iee.lu<mailto:alexei.boulbitch at 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



  • Prev by Date: Re: Funny Behavior of Module
  • Next by Date: Re: Funny Behavior of Module
  • Previous by thread: Re: PDE with RecurrenceTable
  • Next by thread: Re: PDE with RecurrenceTable