Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10934 > unrolled thread
| Started by | W Craig Carter <ccarter@MIT.EDU> |
|---|---|
| First post | 2012-07-15 08:30 +0000 |
| Last post | 2012-07-17 05:32 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Could someone else verify that an example from the Numerical Solutions to Differential Equations isn't working. W Craig Carter <ccarter@MIT.EDU> - 2012-07-15 08:30 +0000
Re: Could someone else verify that an example from the Numerical Roland Franzius <roland.franzius@uos.de> - 2012-07-16 03:45 +0000
Re: Could someone else verify that an example from the Numerical "Nasser M. Abbasi" <nma@12000.org> - 2012-07-16 09:00 +0000
Re: Could someone else verify that an example from the Numerical W Craig Carter <ccarter@MIT.EDU> - 2012-07-17 05:32 +0000
| From | W Craig Carter <ccarter@MIT.EDU> |
|---|---|
| Date | 2012-07-15 08:30 +0000 |
| Subject | Could someone else verify that an example from the Numerical Solutions to Differential Equations isn't working. |
| Message-ID | <jttv31$gut$1@smc.vnet.net> |
I am looking at the example on page 348 of the tutorial for a numerical solution to the Sine-Gordon equation.
(http://www.wolfram.com/learningcenter/tutorialcollection/AdvancedNumericalDifferentialEquationSolvingInMathematica/).
It doesn't work for me for M8.0.4, MacBook, MacOs 10.7.4. Can someone else verify that this doesn't work?
Here is the example:
L = 10; (*the tutorial has L=-10, but I think that is a typo. In any case, the example doesn't work with + or - *)
state = First[NDSolve`ProcessEquations[{D[u[t, x, y], t, t] ==
D[u[t, x, y], x, x] + D[u[t, x, y], y, y] - Sin[u[t, x, y]],
u[0, x, y] == Exp[-(x^2 + y^2)],
Derivative[1, 0, 0][u][0, x, y] == 0,
u[t, -L, y] == u[t, L, y], u[t, x, -L] == u[t, x, L]}, u,
t, {x, -L, L},
{y, -L, L},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> "Pseudospectral"}}]]
GraphicsGrid[Partition[Table[
NDSolve`Iterate[state, tau];
Plot3D[
Evaluate[
u[tau, x, y] /.
NDSolve`ProcessSolutions[state, "Forward"]], {x, -L, L}, {y, -L,
L}, PlotRange -> {-1/4, 1/4}],
{tau, 0, 20, 5}], 2]]
Thanks, Craig
W Craig Carter
Professor of Materials Science, MIT
[toc] | [next] | [standalone]
| From | Roland Franzius <roland.franzius@uos.de> |
|---|---|
| Date | 2012-07-16 03:45 +0000 |
| Subject | Re: Could someone else verify that an example from the Numerical |
| Message-ID | <ju02oe$48k$1@smc.vnet.net> |
| In reply to | #10934 |
Am 15.07.2012 10:30, schrieb W Craig Carter:
> I am looking at the example on page 348 of the tutorial for a numerical solution to the Sine-Gordon equation.
> (http://www.wolfram.com/learningcenter/tutorialcollection/AdvancedNumericalDifferentialEquationSolvingInMathematica/).
> It doesn't work for me for M8.0.4, MacBook, MacOs 10.7.4. Can someone else verify that this doesn't work?
>
> Here is the example:
>
> L = 10; (*the tutorial has L=-10, but I think that is a typo. In any case, the example doesn't work with + or - *)
>
> state = First[NDSolve`ProcessEquations[{D[u[t, x, y], t, t] ==
> D[u[t, x, y], x, x] + D[u[t, x, y], y, y] - Sin[u[t, x, y]],
> u[0, x, y] == Exp[-(x^2 + y^2)],
> Derivative[1, 0, 0][u][0, x, y] == 0,
> u[t, -L, y] == u[t, L, y], u[t, x, -L] == u[t, x, L]}, u,
> t, {x, -L, L},
> {y, -L, L},
> Method -> {"MethodOfLines",
> "SpatialDiscretization" -> {"TensorProductGrid",
> "DifferenceOrder" -> "Pseudospectral"}}]]
>
> GraphicsGrid[Partition[Table[
> NDSolve`Iterate[state, tau];
> Plot3D[
> Evaluate[
> u[tau, x, y] /.
> NDSolve`ProcessSolutions[state, "Forward"]], {x, -L, L}, {y, -L,
> L}, PlotRange -> {-1/4, 1/4}],
> {tau, 0, 20, 5}], 2]]
The graphics constructs have changed in vs8 and I encounter an internal
error in the replacement procedure above resulting in empty solution
lists except the last element.
Consider the following alternative
(* you can skip the << lines *)
<<"DifferentialEquations`NDSolveProblems`";
<<"DifferentialEquations`NDSolveUtilities`";
<<"FunctionApproximations`";
L=10;
state=First@NDSolve`ProcessEquations[
{D[u[t,x,y],t,t]==D[u[t,x,y],x,x]+D[u[t,x,y],y,y]-Sin[u[t,x,y]],
u[0,x,y]==Exp[-(x^2+y^2)],
Derivative[1,0,0]u][0,x,y]==0,
u[t,-L,y]==u[t,L,y],
u[t,x,-L]==u[t,x,L]},
u,t,{x,-L,L},{y,-L,L},
Method->{
"MethodOfLines",
"SpatialDiscretization"->{"TensorProductGrid","DifferenceOrder"Ž"Pseudospectral"}}]
Generate the time table of the interpolation functions of solutions and
time derivatives
pl=Flatten@Table[(NDSolve`Iterate[state,t];NDSolve`ProcessSolutions[state,"Forward"]),{t,0.0,1.0,0.25}
]
Map the Plot3D into table of solutions u
Partition[Plot3D[#,{x,-10,10},{y,-10,10}]&/@
(Table[u[t,x,y],{t,0,1,0.25}]/.pl),2]
Hope it helps
--
Roland Franzius
[toc] | [prev] | [next] | [standalone]
| From | "Nasser M. Abbasi" <nma@12000.org> |
|---|---|
| Date | 2012-07-16 09:00 +0000 |
| Subject | Re: Could someone else verify that an example from the Numerical |
| Message-ID | <ju0l7t$kvt$1@smc.vnet.net> |
| In reply to | #10934 |
On 7/15/2012 3:30 AM, W Craig Carter wrote:
<snip>
Ah! But you changed the code from the pdf file !
You wrote
> GraphicsGrid[Partition[Table[
> NDSolve`Iterate[state, tau];
> Plot3D[
> Evaluate[
> u[tau, x, y] /.
> NDSolve`ProcessSolutions[state, "Forward"]], {x, -L, L}, {y, -L,
> L}, PlotRange -> {-1/4, 1/4}],
> {tau, 0, 20, 5}], 2]]
>
Notice the limit you have on the tau. You wrote
{tau, 0, 20, 5}
while it should be
{tau, 0, 20., 5.}
This is very important here, due to the replacement rule above
that wants to pattern match a solution obtained from NDSolve`ProcessSolutions
which will be numeric! Hence, what happened is that no match was
found and that is why the plots were coming out empty.
If you just change this line and put a "." there, it will work :)
regards,
--Nasser
[toc] | [prev] | [next] | [standalone]
| From | W Craig Carter <ccarter@MIT.EDU> |
|---|---|
| Date | 2012-07-17 05:32 +0000 |
| Subject | Re: Could someone else verify that an example from the Numerical |
| Message-ID | <ju2tde$s5n$1@smc.vnet.net> |
| In reply to | #10934 |
Thank you Nasser, Syd, and Roland,
I had to type it in---I couldn't copy and paste from the pdf.
However, I don't think it would *ever* occurred to me that the problem =
was that the Integer tau had to be a Real. I'm happy to have the =
resolution, but very surprised by the nature of the resolution!
W Craig Carter
Professor of Materials Science, MIT
On Jul 16, , at Mon Jul 16, 12 @5:00 AM, Nasser M. Abbasi wrote:
> On 7/15/2012 3:30 AM, W Craig Carter wrote:
>
>
> Ah! But you changed the code from the pdf file !
>
> You wrote
>
>> {tau, 0, 20, 5}], 2]]
>>
>
> Notice the limit you have on the tau. You wrote
>
> {tau, 0, 20, 5}
>
> while it should be
>
> {tau, 0, 20., 5.}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web