Change the period/frequency of a Van der Pol Oscillator
Show older comments
Hello everyone,
I'm having a trouble/issue changing the frequency of a van der Pol oscillator and getting an specific shape of the plot.
I'm using a pedestrian lateral forces model that walkers apply to bridges while walking and it uses a van der Pol oscillator as follows.
Setting the parameters (lambda = 3, a = 1, omega = 0.8, initial condition x0 = [3 -1]) I can get the acceleration of the system using the following code:
%% Init
clear variables
close all
clc
%% Code
% define parameters
lambda = 3; % damping coefficient
% f = 0.8; % [hz] % Frequency
% w = 2*pi*f; % ~ 5[rad/sec] % natural frequency
w = 0.8; % natural frequency
a = 1; % nonlinearity parameter
y = @(t) 0;
m = 90;
% define equation
f = @(t,x) [x(2); -lambda*(x(2)^2 + x(1)^2 - a)*x(2) - w^2*x(1) + y(t)];
% initial conditions
x0 = [3;-1];
% time span
tspan = [0 100];
% solve using ode45
[t,x] = ode45(f, tspan, x0);
% compute acceleration
xpp = -lambda*(x(:,2).^2 + x(:,1).^2 - a).*x(:,2) - w^2.*x(:,1) + y(t);
% plot solution
figure;
plot(t, xpp(:,1), 'b', 'LineWidth', 1.5);
xlim([40 50])
xlabel('t');
ylabel('xpp');
title('Acceleration of a Van der Pol Oscillator');
grid on

The shape looks like to the way a pedestrian applies lateral forces while walking according to multiple researches, BUT, the waves are far from each other. So my problem is that I want the waves come closer each other because the pedestrian frequency is approx f = 0.8[hz] or w = 2*pi*f = 5 [rad/sec] and as soon as I change the frequency the shape changes. I've been trying for hours to find a combination of parameters that produces exactly the same shape but the waves come closer to each other. Here is what I get (not the same shape, but I have the frequency)

Any help or recomendation to find the parameters?
Accepted Answer
More Answers (1)
Mathieu NOE
on 22 Mar 2023
hello
seems to me your code actually generates the correct frequency signal at 0.8 Hz , as soon as you stick with
f = 0.8; % [hz] % Frequency
w = 2*pi*f; % ~ 5[rad/sec] % natural frequency
and not
% w = 0.8; % natural frequency

minor tweaks / complements in your code
%% Init
clear variables
close all
clc
%% Code
% define parameters
lambda = 3; % damping coefficient
f = 0.8; % [hz] % Frequency
w = 2*pi*f; % ~ 5[rad/sec] % natural frequency
% w = 0.8; % natural frequency
a = 1; % nonlinearity parameter
y = @(t) 0;
% m = 90; % what for ?
% define equation
f = @(t,x) [x(2); -lambda*(x(2)^2 + x(1)^2 - a)*x(2) - w^2*x(1) + y(t)];
% initial conditions
x0 = [3;-1];
% time span
tspan = [0 20];
% solve using ode45
[t,x] = ode45(f, tspan, x0);
% compute acceleration
xpp = -lambda*(x(:,2).^2 + x(:,1).^2 - a).*x(:,2) - w^2.*x(:,1) + y(t);
% remove first seconds (transient)
ind = (t>10);
t = t(ind);
xpp = xpp(ind);
% find signal frequency by measuring "zero" (or any other value crossing
% time index
threshold = 0; %
t0_pos1 = find_zc(t,xpp,threshold);
period = diff(t0_pos1); % delta time of crossing points
freq = 1./period; % signal frequency
figure(1)
subplot(2,1,1),plot(t,xpp,'b-',t0_pos1,threshold*ones(size(t0_pos1)),'.r','linewidth',2,'markersize',20);grid on
xlim([min(t) max(t)]);
legend('signal','signal positive slope crossing points');
xlabel('Time (s)');
ylabel('xpp');
title('Acceleration of a Van der Pol Oscillator');
subplot(2,1,2),plot(t0_pos1(2:end),freq,'b.-','linewidth',2,'markersize',12);grid on
xlim([min(t) max(t)]);
ylim([0 1]);
legend('signal rate (frequency)');
xlabel('Time (s)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Zx] = find_zc(x,y,threshold)
% positive slope "zero" crossing detection, using linear interpolation
y = y - threshold;
zci = @(data) find(diff(sign(data))>0); %define function: returns indices of +ZCs
ix=zci(y); %find indices of + zero crossings of x
ZeroX = @(x0,y0,x1,y1) x0 - (y0.*(x0 - x1))./(y0 - y1); % Interpolated x value for Zero-Crossing
Zx = ZeroX(x(ix),y(ix),x(ix+1),y(ix+1));
end
5 Comments
The following is not a solution, but I think OP wants to preserve the shape of the wave and the wave should oscillates at a higher frequency. Something like the plot generated below (which I manipulated using time for illustration purposes only.)
%% Init
clear variables
close all
clc
%% Code
% define parameters
lambda = 3; % damping coefficient
% f = 0.8; % [hz] % Frequency
% w = 2*pi*f; % ~ 5[rad/sec] % natural frequency
w = 0.8; % natural frequency
a = 1; % nonlinearity parameter
y = @(t) 0;
m = 90;
% define equation
f = @(t,x) [x(2); -lambda*(x(2)^2 + x(1)^2 - a)*x(2) - w^2*x(1) + y(t)];
% initial conditions
x0 = [3;-1];
% time span
tspan = [0 100];
% solve using ode45
[t,x] = ode45(f, tspan, x0);
% compute acceleration
xpp = -lambda*(x(:,2).^2 + x(:,1).^2 - a).*x(:,2) - w^2.*x(:,1) + y(t);
% plot solution
figure;
plot(t/4, xpp(:,1), 'b', 'LineWidth', 1.5);
xlim([10 20]),
ylim([-2 2])
xlabel('t');
ylabel('xpp');
title('Acceleration of a Van der Pol Oscillator');
grid on
Mathieu NOE
on 22 Mar 2023
hello
why not digitize this picture and take that signal shape as "master curve"
simply define the time axis to make it the right frequency as you wish
that seems to be the simplest wat IMHO
Mathieu NOE
on 22 Mar 2023
ok I understand
Categories
Find more on Loop-Shaping Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

