(*Phase Plane Plot of the Van der Pol Differential Equation
by Nasser M. Abbasi
April 12 2009
*)
Manipulate[process[\[Lambda], k, pt],
Row[{Control[ {{\[Lambda], .2, Style["\[Lambda]"]}, 0, 2, .1, Appearance -> "Labeled", ImageSize -> Normal}],
Control[{{k, 1, Style["k", Italic]}, .1, 3, .1, Appearance -> "Labeled", ImageSize -> Normal}] }],
{{pt, {1, 3}}, {-5, -5}, {5, 5}, ControlType -> Locator},
ControlPlacement -> {Top},
Initialization :> {
process[\[Lambda]_, k_, pt_] :=
Module[{eq, x, t, tmax = 100, sol, paramPlot, solPlot, vData, x0, v0, lableSize = 14, initialConditionsString},
eq = x''[t] - \[Lambda] (1 - x[t]^2) x'[t] + k x[t] == 0;
sol = First[NDSolve[{eq, x[0] == pt[[1]], x'[0] == pt[[2]]}, x, {t, 0, tmax}]];
initialConditionsString =
Style[Row[{Style["x", Italic], "(0) = ", NumberForm[pt[[1]], {3, 2}, NumberSigns -> {"-", "+"}], " ", Style["x", Italic]',
"(0) = ", NumberForm[pt[[2]], {3, 2}, NumberSigns -> {"-", "+"}]
}], lableSize, TextAlignment -> Center];
paramPlot = ParametricPlot[Evaluate[{x[t], x'[t]} /. sol], {t, 0, tmax},
AspectRatio -> Automatic,
PlotRange -> {{-5, 5}, {-5, 5}},
PlotPoints -> 100,
Frame -> True,
FrameLabel -> {
{Style[Row[{Style["x", Italic]', "(", Style["t", Italic], ")"}], lableSize],
None}, {Style[Row[{Style["x", Italic], "(", Style["t", Italic], ")"}], lableSize],
Column[ { Style["phase plane plot", lableSize], initialConditionsString
}, Alignment -> Center]}},
ImageSize -> {270, 220},
ImagePadding -> 40,
PlotStyle -> Red];
solPlot = Plot[Evaluate[x[t] /. sol], {t, 0, tmax},
PlotRange -> All,
FrameLabel -> {
{Style[Row[{Style["x", Italic], "(", Style["t", Italic], ")"}], lableSize], None},
{Style["time", lableSize], Style[Row[{Style["x", Italic], "(", Style["t", Italic], ") versus time"}], lableSize]}},
AspectRatio -> 1,
Frame -> True,
ImageSize -> {270, 220},
ImagePadding -> 40,
PlotStyle -> Red];
Grid[{ {paramPlot, solPlot }}, Frame -> None, Spacings -> 0]
]}
]