Examples

Duffing and Van Der Pol oscillator examples.

Copyright 2012, Lance Larsen
Licensed under the MIT license

Uses GMAmode.js, Animate.js, flot/jquery.js, and flot/jquery.flot.js

Summary
ExamplesDuffing and Van Der Pol oscillator examples.
Properties
colorsA set of colors used for plotting curves.
colorSetsDifferent color sets.
canvasesThis is an object that is used to hold the list of current plot canvases.
Functions
EllipseGet a parameteric function that produces the points for an ellipse.
DuffingEqnThis generate a Duffing Equation ODE vector field function.
DuffingSolverFunction to solve the Duffing equation.
DuffingPlotPlot the Duffing generalized 1-D mode and/or some of the solution curves.
VanDerPolEqnThis generate a VanDer Pol Equation ODE vector field function.
VanDerPolSolverFunction to solve the Duffing equation.
VanDerPolPlotPlot the VanDer Pol generalized 1-D mode and/or some of the solution curves.

Properties

colors

A set of colors used for plotting curves.

colorSets

Different color sets.  This is used to switch the solution plots between a set of colors (when no contours are plotted, and grey (when mode contours are plotted).

canvases

This is an object that is used to hold the list of current plot canvases.

Functions

Ellipse

function Ellipse(a,
excentricity,
angle)

Get a parameteric function that produces the points for an ellipse.  This is used to generate an initial modal curve in the region of an ODE is oscillatory and approximately linear.

PARAMETERS

athe amplitude along the widest axis of the ellipse (the x axis).
excentricityThe ratio of the small axis amplitude to the large axis amplitude.
angleThe rotation angle of the ellipse from the x axis.

RETURNS

A parametric function for an ellipse of the form func(t) which returns an [x,y] pt.  The parameter t should go from 0 to 2*pi.

DuffingEqn

function DuffingEqn(eps,
c)

This generate a Duffing Equation ODE vector field function.  The duffing equation has the form x’’+2*c*x’+x+eps*x^3=0.

PARMAETERS

epsThe cubic nonlinearity coefficient
cThe damping coefficient

RETURNS

An Duffing ODE function of the form ‘V(t,pt)’ that returns the ODE vector [x’,x’’].  ‘t’ is the independent value, and ‘pt’ is [x,x’].

DuffingSolver

function DuffingSolver()

Function to solve the Duffing equation.

PARAMETERS

stepsThe number of ODE steps to take when solving the Duffing equation.  Note that this solves backwards from a solution near the equilibrium point with step sizes of -0.05.

RETURNS

A GMAmode object for the Duffing oscillator.

DuffingPlot

function DuffingPlot(canvas,
showMode,
showSolns,
animate)

Plot the Duffing generalized 1-D mode and/or some of the solution curves.  The plot is animated, showing the time progress of the solution.

PARAMETERS

canvasThe canvas the the solution is plotted onto.
showModeFlag to indicate whether the modal contours should be plotted.
showSolnsFlag to indicate whether the ODE solutions should be plotted.
animateFlag to show whether the plot should be animated.

VanDerPolEqn

function VanDerPolEqn(c)

This generate a VanDer Pol Equation ODE vector field function.  The Van Der Pol equation has the form x’’-c*(1-x^2)*x’+x=0.

PARMAETERS

cThe (negative) damping coefficient

RETURNS

An Van Der Pol ODE function of the form ‘V(t,pt)’ that returns the ODE vector [x’,x’’].  ‘t’ is the independent value, and ‘pt’ is [x,x’].

VanDerPolSolver

function VanDerPolSolver()

Function to solve the Duffing equation.

PARAMETERS

istepsThe number of ODE steps to take solving the Van Der Pol equation from inside the limit cycle.  The initial curve is an Ellipse near the unstable equilibrium.  This solution is disabled at present.
ostepsThe number of ODE steps to take solveing the Van Der Pol equation from outside the limit cycle.  The initial curve is a slightly expanded limit cycle curve.  The solution is solved backwards (away from the limit cycle, with a step size of -0.05.

RETURNS

A GMAmode object for the Van Der Pol oscillator.

VanDerPolPlot

function VanDerPolPlot(canvas,
showModeIn,
showModeOut,
showSolnIn,
showSolnOut,
animate)

Plot the VanDer Pol generalized 1-D mode and/or some of the solution curves.  The plot is animated, showing the time progress of the solution.

PARAMETERS

canvasThe canvas the the solution is plotted onto.
showModeInFlag to indicate whether the modal contours inside the limit cycle should be plotted.
showModeOutFlag to indicate whether the modal contours outside the limit cycle should be plotted.
showSolnInFlag to indicate whether the ODE solutions inside the limit cycle should be plotted.
showSolnOutFlag to indicate whether the ODE solutions outside the limit cycle should be plotted.
animateFlag to indicate whether the plot should be animated.
function Ellipse(a,
excentricity,
angle)
Get a parameteric function that produces the points for an ellipse.
function DuffingEqn(eps,
c)
This generate a Duffing Equation ODE vector field function.
function DuffingSolver()
Function to solve the Duffing equation.
function DuffingPlot(canvas,
showMode,
showSolns,
animate)
Plot the Duffing generalized 1-D mode and/or some of the solution curves.
function VanDerPolEqn(c)
This generate a VanDer Pol Equation ODE vector field function.
function VanDerPolSolver()
Function to solve the Duffing equation.
function VanDerPolPlot(canvas,
showModeIn,
showModeOut,
showSolnIn,
showSolnOut,
animate)
Plot the VanDer Pol generalized 1-D mode and/or some of the solution curves.
Close