MathematicalPhysicist
Apr5-10, 05:54 AM
OK, so I found something similar in Wolfram's site, here's the code for a nonlinear wave eqautions:
Manipulate[
If[ct, DensityPlot,
Plot3D] @@ {{##, PlotPoints -> 15, MaxRecursion -> 1},
{##, PerformanceGoal -> "Quality"}, {##, PlotPoints -> 30,
MaxRecursion -> 3}}[[q]] &[
Evaluate[u[If[ct, x0 - t, t], x] /.
Quiet[
NDSolve[Evaluate[{D[u[t, x], t, t] == D[u[t, x], x, x] +
a*u[t, x]^3 + b*u[t, x]^2 +
c*u[t, x] + d,
u[0, x] == E^(-(x - sep)^2) + E^(-(x + sep)^2),
D[u[t, x], t] == 0 /. t -> 0,
u[t, -x0] == u[t, x0]}], u,
{t, 0, x0}, {x, -x0, x0},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> "Pseudospectral",
"MinStepSize" ->
0.2}}]]], {x, -x0, x0}, {t, 0, x0},
MeshFunctions -> {#3 & }, ImageSize -> {475, 325},
Mesh -> mesh,
ColorFunction -> "Rainbow"],
"equation coefficients", {{a, -2.34, "cubic"}, -4, 0,
Appearance -> "Labeled"}, {{b, -3.65, "quadratic"}, -4, 0,
Appearance -> "Labeled"}, {{c, 0, "linear"}, -4, 1,
Appearance -> "Labeled"}, {{d, 1, "constant"}, -1, 1,
Appearance -> "Labeled"}, Delimiter,
{{sep, 2.5, "initial peak separation"}, 0, 10,
Appearance -> "Labeled"}, {{x0, 10, "solution range"}, 5, 20,
Appearance -> "Labeled"}, {{mesh, False, "show mesh"},
{False, Automatic}, ControlType -> Checkbox},
{{q, 2, "quality"}, {1 -> "low", 2 -> "medium", 3 -> "high"}},
{{ct, False, "plot type"}, {True -> "2D", False -> "3D"},
ControlType -> SetterBar}, ControlPlacement -> Top,
ContinuousAction -> False,
AutorunSequencing -> {1, 2, 3, 4, 5, 7, 9}]
Now naively I thought I could make some rudimentary changes to this code to make it appropiate for my problem, but it doesn't seem to work.
In values of constants I changed a and c to 1 and -1 respectively and the others 0, and I changed in the equation
D[u[t,x],x,x]
to D[(D[u[t,x],x])^3,x]
and I also changed the boundary conditions from the ones given there to:
u[t, Abs[x0]] == 0,
D[u[t, x], t] == 0 /. Abs[x] -> x0
I also changed the domain of the parameters: a,b,c,d appropiately.
Can someone explain to me what wrong here?
I get the next errors:
ReplaceAll::reps: {NDSolve[{(u^(2,0))[t,x]==-u[t,x]+u[t,x]^3+3 (<<1>>^(<<2>>))[<<2>>]^2 (u^(0,2))[t,x],u[t,10]==u[t,-10],(u^<<1>>)[t,10]==0,(u^(0,1))[t,-10]==0},<<4>>]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
NDSolve::dsvar: 0.000715` cannot be used as a variable. >>
ReplaceAll::reps: {NDSolve[{<<1>>},u,<<1>>,{<<1>>},Method->{MethodOfLines,SpatialDiscretization->{TensorProductGrid,Di\[Ellipsis] er->\[Ellipsis] ,MinStepSize->0.2}}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
NDSolve::dsvar: 0.000715` cannot be used as a variable. >>
ReplaceAll::reps: {NDSolve[<<1>>]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation. >>
there are more errors, here's also my code itself:
Manipulate[
If[ct, DensityPlot,
Plot3D] @@ {{##, PlotPoints -> 15, MaxRecursion -> 1},
{##, PerformanceGoal -> "Quality"}, {##, PlotPoints -> 30,
MaxRecursion -> 3}}[[q]] &[
Evaluate[u[If[ct, x0 - t, t], x] /.
Quiet[
NDSolve[Evaluate[{D[u[t, x], t, t] == D[(D[u[t, x], x])^3, x] +
a*u[t, x]^3 + b*u[t, x]^2 +
c*u[t, x] + d,
u[t, Abs[x0]] == 0,
D[u[t, x], t] == 0 /. Abs[x] -> x0,
}], u,
{t, 0, x0}, {x, -x0, x0},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"DifferenceOrder" -> "Pseudospectral",
"MinStepSize" ->
0.2}}]]], {x, -x0, x0}, {t, 0, x0},
MeshFunctions -> {#3 & }, ImageSize -> {475, 325},
Mesh -> mesh,
ColorFunction -> "Rainbow"],
"equation coefficients", {{a, 1, "cubic"}, -4, 2,
Appearance -> "Labeled"}, {{b, 0, "quadratic"}, -4, 2,
Appearance -> "Labeled"}, {{c, -1, "linear"}, -4, 2,
Appearance -> "Labeled"}, {{d, 0, "constant"}, -1, 1,
Appearance -> "Labeled"}, Delimiter,
{{sep, 2.5, "initial peak separation"}, 0, 10,
Appearance -> "Labeled"}, {{x0, 10, "solution range"}, 5, 20,
Appearance -> "Labeled"}, {{mesh, False, "show mesh"},
{False, Automatic}, ControlType -> Checkbox},
{{q, 2, "quality"}, {1 -> "low", 2 -> "medium", 3 -> "high"}},
{{ct, False, "plot type"}, {True -> "2D", False -> "3D"},
ControlType -> SetterBar}, ControlPlacement -> Top,
ContinuousAction -> False,
AutorunSequencing -> {1, 2, 3, 4, 5, 7, 9}]
Thanks in advance for any help on this matter.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.