limit cycle oscillator

Scilab: phase response curve for a limit cycle oscillator


clear;
a=1;
b=1;
c=1;
pi2=2*%pi;
function ydot=f(t,y),
ydot(1,:)=y(2,:),
ydot(2,:)=-b*(y(1,:)^2-c)*y(2,:) -a*y(1,:),
endfunction
//=====Determine the points on the limit cycle
y0=[2;0]; //start at a known point on the limit cycle
t0=0;
n=10;
dt=0.001;
t=0:dt:n*pi2;
nt=size(t,2);
//=====Determine the period of the limit cycle
y=ode(y0,t0,t,f);
fy=fft(y(2,:));
fx=(1/dt)*(0:(nt/2))/nt;
nf=size(fx,2);
xm=0;
for i=1:nf,
x1=abs(fy(i));
if x1>xm then
xm=x1;
fm=i;
end
end
tau=1/fx(fm);
dy=0.5; //perturbation in y
q=128;
for i=1:q,
t1=round((i/q)*tau/dt);
z0=y(:,t1);
z=ode(z0+[0;-dy],t0,t,f);
z1=y(:,t1+0.8*nt);
z2=z(:,0.8*nt);
r1=sqrt(z1'*z1);
r2=sqrt(z2'*z2);
ph1=asin(z1(2)/r1);
if z1(1)<0 then ph1=pi2/2-ph1;
elseif z1(2)<0 then ph1=ph1+pi2;
end
phd=acos((z1(1)*z2(1)+z1(2)*z2(2))/(r1*r2));
if z1(1)*z2(2) ph(1,i)=ph1;
ph(2,i)=phd;
end
scf(1);
plot(ph(1,:),ph(2,:),'rx');
a=gca();
a.box="off";
a.data_bounds=[0 -1; pi2 1];
a.x_location="middle";

Scilab: period of a limit cycle


clear;
a=1;
b=1;
c=1;
function ydot=f(t,y),
ydot(1,:)=y(2,:),
ydot(2,:)=-b*(y(1,:)^2-c)*y(2,:) -a*y(1,:),
endfunction
//=====Determine the period tau of the oscillator (using fft)
y0=[2;0];
t0=0;
n=10;
dt=0.001;
t=0:dt:n*2*%pi;
nt=size(t,2);
y=ode("stiff",y0,t0,t,f);
x=fft(y(1,:));
fr=(1/dt)*(0:(nt/2))/nt;
nf=size(fr,2);
plot(fr,abs(x(1:nf)));
xm=0;
fm=1;
for i=1:nf,
x1=abs(x(i));
if x1>xm then
xm=x1;
fm=i;
end
end
tau=1/fr(fm)


The period is 6.9813333.

Another limit cycle art

Pag medyo nakatanga na ako sa kakacompute at kakaisip, ganito ang kadalasang nagagawa.

Limit cycle oscillator

Perhaps you've seen a waving cat in many chinese stores, those that really move their hand back and forth. This type of oscillations is an example of a limit cycle. When you start the hand at a vertical position, it will slowly increase its amplitude until a fixed amplitude of oscillation is attained. However, if you start the cat's hand at a horizontal position, it will slowly decrease to the same fixed amplitude.

Syndicate content