-
Notifications
You must be signed in to change notification settings - Fork 2
/
Sprott_control.m
152 lines (121 loc) · 3.72 KB
/
Sprott_control.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
%--------------------------------------------------------------------------
% Stabilizing unstable periodic orbits
% -------------------------------------------------------------------------
% Application to the Sprott system:
%
% x' = y
% y' = z
% z' = -x - mu*z + y^2
%
% Here mu is a bifurcation parameter.
%
% This code is associated with the paper "Data-driven stabilization of
% periodic orbits" by Jason J. Bramburger, Steven L. Brunton, and J. Nathan
% Kutz (2020).
% This script is used to obtain the results in Section 4.4.
%--------------------------------------------------------------------------
% Clean workspace
clear all
close all
clc
% Bifurcation parameter
% mu | attractor
%--------------------
% 2.1 | period 2
% 2.06 | period 8
% 2.05 | chaos
% Focal parameter value
mustar = 2.1;
% Fixed points and control parameters
if mustar == 2.1 %period 2 attractor
xstar = 5.7043017234010953671686660124944;
zstar = -2.1277967294786117471720413603295;
K1 = 0.110819928078272;
K2 = 0.007751757966128;
eta = 0.1; %Control threshold
elseif mustar == 2.06 %period 8 attractor
xstar = 5.5228289900518593829233011814354;
zstar = -2.1876744347263052494716106772812;
K1 = 0.194809772172555;
K2 = 0.191733226951754;
eta = 0.3;
elseif mustar == 2.05 %chaos
xstar = 5.480258227468076353024595563924;
zstar = -2.1189223192701897434337694750347;
K1 = 0.205797184099887;
K2 = 0.182799384910813;
eta = 0.1;
end
% Controlled trajectory
m = 3; %Dimension of ODE
dt = 0.005;
tspan = 0:dt:100;
options = odeset('RelTol',1e-12,'AbsTol',1e-12*ones(1,m));
% Initial condition close to unstable orbit
x0(1,:) = [xstar+0.01; 0; zstar];
% Controlled parameter
if abs(x0(1,1) - xstar) + abs(x0(1,3) - zstar) <= eta
mu(1) = mustar + K1*(x0(1,1) - xstar) + K2*(x0(1,3) - zstar);
else
mu(1) = Astar;
end
% Initialize trajectory
[~,sol] = ode45(@(t,x) Sprott(x,mu(1)),tspan,x0(1,:));
% Initialize Controlled Solution
xc = [];
yc = [];
zc = [];
% Controlled orbit
kfinal = 100;
for k = 2:kfinal
for j = 1:length(sol(:,1))-1
if (sol(j,2) >= 0 && sol(j+1,2) < 0)
ind = j+1;
% Controlled solution
xc = [xc; sol(1:ind,1)];
yc = [yc; sol(1:ind,2)];
zc = [zc; sol(1:ind,3)];
break
end
end
x0(k,:) = [sol(ind,1); sol(ind,2); sol(ind,3)];
if abs(x0(k,1) - xstar) + abs(x0(k,3) - zstar) <= eta
mu(k) = mustar + K1*(x0(k,1) - xstar) + K2*(x0(k,3) - zstar);
else
mu(k) = mustar;
end
[~,sol] = ode45(@(t,x) Sprott(x,mu(k)),tspan,x0(k,:));
end
% Last Iteration of Controlled solution
xc = [xc; sol(1:ind,1)];
yc = [yc; sol(1:ind,2)];
zc = [zc; sol(1:ind,3)];
%plot(xc,yc)
% Compare with uncontrolled orbit
tspan = 1:dt:10*kfinal;
y0(1,:) = [xstar; 0; zstar];
[~,solu] = ode45(@(t,x) Sprott(x,mustar),tspan,y0(1,:),options);
% Extract the attractor
xu = solu(100000:end,1);
yu = solu(100000:end,2);
zu = solu(100000:end,3);
% Plot Solutions
figure(1)
plot(xu,yu,'k','LineWidth',1)
hold on
plot(xc(10000:end),yc(10000:end),'b','LineWidth',2)
set(gca,'FontSize',16)
xlabel('$x(t)$','Interpreter','latex','FontSize',20,'FontWeight','Bold')
ylabel('$y(t)$','Interpreter','latex','FontSize',20,'FontWeight','Bold')
% Plot Solutions
figure(2)
plot(yu,zu,'k','LineWidth',1)
hold on
plot(yc(10000:end),zc(10000:end),'b','LineWidth',2)
set(gca,'FontSize',16)
xlabel('$y(t)$','Interpreter','latex','FontSize',20,'FontWeight','Bold')
ylabel('$z(t)$','Interpreter','latex','FontSize',20,'FontWeight','Bold')
%% Sprott system right-hand-side
function dx = Sprott(x,mu)
dx = [x(2); x(3); -x(1) + x(2)^2 - mu*x(3)];
end