Van der Polye oscillator¶
In this example, we show how to create a dynamics model in Engee that works according to the second order Van der Polye equation.
Introduction¶
The van der Pol oscillator demonstrates the dynamics of a non-conservative system with a nonlinear damping character.
This system can be described by the following equation:
$$\frac{d^2 x}{dt^2} - \mu \left( 1- x^2 \right) \frac{dx}{dt} + x = 0$$
where $x$ is a coordinate (for example, the position of the oscillator), $\mu$ is the damping coefficient. This model is used to study a wide variety of processes in biology and physics, including radio engineering and electronics.
We will model this system using blocks on the canvas for graphical modelling in Engee. The file van_der_pol_oscillator.engee
contains a model of the following form:
It has two separate integrators that are responsible for calculating the signals x1
(coordinate) and x2
(velocity).
Running the model with μ = 1¶
If we run this model with the argument $\mu = 1$, we see an auto-oscillating mode of operation with nonlinear damping. Let's load the model:
if "van_der_pol_oscillator" in [m.name for m in engee.get_all_models()]
m = engee.open( "van_der_pol_oscillator" );
else
m = engee.load( "/user/start/examples/edu/van_der_pol_oscillator/van_der_pol_oscillator.engee" );
end
Let's run the model in the original version and plot the graph:
data = engee.run( m );
using Plots
plot( data["x1"].value, data["x2"].value )
We can choose different starting points by changing the initial value of each integrator, but the system will always arrive at the limit cycle.
The graph can also be plotted for each signal separately.
plot( data["x1"].time, data["x1"].value, label="x1" )
plot!( data["x2"].time, data["x2"].value, label="x2" )
Running the model with μ = 0¶
In this regime, the system equation is reduced to the equation of an ordinary harmonic oscillator:
$$\frac{d^2 x}{dt^2} + x = 0$$
Let's set the $\mu$ coefficient to zero and run the model.
engee.set_param!( "van_der_pol_oscillator/Mu", "Gain"=>0 )
data = engee.run( m );
data = engee.run( m );
using Plots
plot( data["x1"].value, data["x2"].value )
Let's build another graph for this system:
plot( data["x1"].time, data["x1"].value, label="x1" )
plot!( data["x2"].time, data["x2"].value, label="x2" )
Conclusion¶
We have seen that graphical modelling in Engee is a convenient way to experiment with system topology, to complicate the model or to use it as part of a complex demonstration.