-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkura1.m
51 lines (42 loc) · 913 Bytes
/
kura1.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
% Get order parameter 'r' as a function of time
clear all
N = 500;
K = 4.0;
D = 1.0;
dt = 0.1;
tmax = 20;
nt = floor(tmax/dt) + 1;
for i = 1:N;
theta(i) = rand*2.0*pi;
end
for i = 1:N;
omegaNtr(i) = 0.0;
end
r = [];
t = [];
for i = 1:nt;
for j = 1:N;
% first calc coupling interaction
int = 0.0;
for k = 1:N;
int = int + sin( theta(k) - theta(j));
end
int = K * int / N;
theta(j) = theta(j) + (omegaNtr(j) + int)*dt + sqrt(dt)*randn;
end
% calc order parameter
if mod(i*dt, 5*dt) == 0
rc = 0.0;
rs = 0.0;
for j = 1:N;
rc = rc + cos( theta(j));
rs = rs + sin( theta(j));
end
r = [r ; sqrt( rc^2 + rs^2) / N];
t = [t ; i*dt];
end
end
plot(t,r)
title('Time Evolution of Synchronization')
xlabel('time (s)')
ylabel('Order parameter, r')