Comparison of a linear and nonlinear phase portraits

Ex: The Liénard equation

Clear[diffX,diffY,difX,difY,ldiffX,ldiffY,ldifX,ldifY,x,y,lx,ly,μ]
imagesize=310;maxT=40;

Manipulate[
diffX=y;
diffY=(μ-(x^2))y-x;
difX=diffX/.{x->x[t],y->y[t]};
difY=diffY/.{x->x[t],y->y[t]};
region=RegionPlot[x^2+y^2<0.52,{x,-1,1},{y,-1,1},BoundaryStyle->None,LabelStyle->16];
splot=StreamPlot[{diffX,diffY},{x,-2,2.2},{y,-3,3},FrameLabel->{x[t],y[t]},ImageSize->imagesize,PlotLabel->Style["Nonlinear phase portrait",Blue,17],StreamStyle->LightGray,LabelStyle->16];
fixedpoints=Quiet[Solve[{diffX==0,diffY==0},{x,y}]];
coordinates={x,y}/.fixedpoints;
fixedp=Graphics[{PointSize[0.02],Blue,Point[coordinates]}];
ldiffX=ly;
ldiffY=-lx+μ ly;
ldifX=ly[t];
ldifY=-lx[t]+μ ly[t];
lsplot=StreamPlot[{ldiffX,ldiffY},{lx,-2,2.2},{ly,-3,3},FrameLabel->{x[t],y[t]},ImageSize->imagesize,PlotLabel->Style["Linear phase portrait",Black,17],StreamStyle->LightGray,LabelStyle->16];
lfixedp=Graphics[{PointSize[0.02],Black,Point[{0,0}]}];

integration=NDSolve[{
x'[t]==difX,
y'[t]==difY,
x[0]==point[[1]],y[0]==point[[2]]},
{x,y},{t,0,T}];
trajectory=ParametricPlot[
Evaluate[{x[t],y[t]}/.integration],
{t,0,T},PlotStyle->{Thick,Blue}];
solx=Plot[Evaluate[x[t]/.integration],
{t,0,T},PlotRange-> All,AxesLabel-> {t,x[t]},PlotLabel->Style["Displacement",17],ImageSize->imagesize,PlotStyle->Blue,LabelStyle->16];
soly=Plot[Evaluate[y[t]/.integration],
{t,0,T},PlotRange-> All,AxesLabel-> {t,y[t]},PlotLabel->Style["Velocity",17],ImageSize->imagesize,PlotStyle->Blue,LabelStyle->16];
lintegration=NDSolve[{
lx'[t]==ldifX,
ly'[t]==ldifY,
lx[0]==point[[1]],ly[0]==point[[2]]},
{lx,ly},{t,0,T}];
ltrajectory=ParametricPlot[Evaluate[{lx[t],ly[t]}/.lintegration],
{t,0,T},PlotStyle->Black];
lsolx=Plot[Evaluate[lx[t]/.lintegration],
{t,0,T},PlotRange-> All,AxesLabel-> {t,x[t]},PlotLabel->Style["Displacement",17],ImageSize->imagesize,PlotStyle->Black,LabelStyle->16];
lsoly=Plot[Evaluate[ly[t]/.lintegration],
{t,0,T},PlotRange-> All,AxesLabel-> {t,y[t]},PlotLabel->Style["Velocity",17],ImageSize->imagesize,PlotStyle->Black,LabelStyle->16];
Grid[{{Show[splot,trajectory,fixedp,region],Show[lsplot,ltrajectory,lfixedp,region]},
{Show[solx,lsolx],Show[soly,lsoly]}},Frame->All],
{{T,25,"Time t"},1,maxT},
{{μ,-0.33,"Parameter μ"},-0.4,0.5},
{{point,{0,3}},Locator}, SaveDefinitions->True,TrackedSymbols:>{T,μ,point}]

Creation of this notebook was supported by IT Academy program of Information Technology Foundation for Education (HITSA).