Example07 / 11
度–频率关联导致的爆发式同步与滞后
在 BA 网络(N=500,m=3)上令固有频率等于度 omega_i = k_i(Gómez-Gardeñes 等 2011 的设定), 先逐步增大 K(每步沿用上一 K 的终态),再逐步减小 K,记录有效序参量 r。 对照组:把同一组频率随机打乱,破坏度–频率关联。 解读:关联存在时,前向与后向曲线明显分开(滞后环),r 在前向扫描中突然跳升;打乱后滞后基本消失。
Output输出图

Output文字输出
omega=k 前向 r: [0.04, 0.07, 0.07, 0.08, 0.15, 0.94, 0.96, 0.97, 0.97, 0.98, 0.98] omega=k 后向 r: [0.06, 0.04, 0.09, 0.15, 0.91, 0.94, 0.96, 0.97, 0.97, 0.98, 0.98] omega=k 滞后面积 sum|bwd-fwd|*dK = 0.22 shuffled 前向 r: [0.35, 0.58, 0.71, 0.78, 0.81, 0.84, 0.86, 0.87, 0.88, 0.89, 0.91] shuffled 后向 r: [0.36, 0.58, 0.71, 0.78, 0.82, 0.84, 0.86, 0.87, 0.88, 0.89, 0.9] shuffled 滞后面积 sum|bwd-fwd|*dK = 0.00
Code代码
# 在 BA 网络(N=500,m=3)上令固有频率等于度 omega_i = k_i(Gómez-Gardeñes 等 2011 的设定),
# 先逐步增大 K(每步沿用上一 K 的终态),再逐步减小 K,记录有效序参量 r。
# 对照组:把同一组频率随机打乱,破坏度–频率关联。
# 解读:关联存在时,前向与后向曲线明显分开(滞后环),r 在前向扫描中突然跳升;打乱后滞后基本消失。
import numpy as np
import networkx as nx
import scipy.sparse as sp
import matplotlib.pyplot as plt
G = nx.barabasi_albert_graph(500, 3, seed=4)
A = sp.csr_matrix(nx.to_scipy_sparse_array(G, nodelist=range(500)))
k = np.asarray(A.sum(axis=1)).ravel()
def sweep(omega, Ks, T=30.0, dt=0.01, seed=0):
theta = np.random.default_rng(seed).uniform(0, 2 * np.pi, omega.size)
out = []
for K in Ks:
rs = []
for n in range(int(T / dt)):
s, c = np.sin(theta), np.cos(theta)
theta = theta + dt * (omega + K * (c * (A @ s) - s * (A @ c)))
if n > int(T / dt) // 2:
rs.append(abs(np.exp(1j * theta).mean()))
out.append(np.mean(rs))
return np.array(out), theta
Ks = np.arange(0.5, 3.01, 0.25)
results = {}
for name, omega in [("omega=k", k.astype(float)),
("shuffled", np.random.default_rng(1).permutation(k).astype(float))]:
omega = omega - omega.mean() # 旋转参照系
fwd, _ = sweep(omega, Ks)
# 后向扫描从强同步态开始:先在最大 K 处跑一段,再逐步降低
th = np.zeros(500); bwd = []
for K in Ks[::-1]:
rs = []
for n in range(3000):
s, c = np.sin(th), np.cos(th)
th = th + 0.01 * (omega + K * (c * (A @ s) - s * (A @ c)))
if n > 1500:
rs.append(abs(np.exp(1j * th).mean()))
bwd.append(np.mean(rs))
bwd = np.array(bwd)[::-1]
results[name] = (fwd, bwd)
print(name, "前向 r:", np.round(fwd, 2).tolist())
print(name, "后向 r:", np.round(bwd, 2).tolist())
print(name, "滞后面积 sum|bwd-fwd|*dK = %.2f" % (np.abs(bwd - fwd).sum() * 0.25))
for name, (fwd, bwd) in results.items():
plt.plot(Ks, fwd, "o-", label=name + " forward")
plt.plot(Ks, bwd, "s--", label=name + " backward")
plt.xlabel("K"); plt.ylabel("r"); plt.legend(fontsize=8); plt.title("Explosive synchronization")
plt.show()Run在浏览器中运行
首次加载 Python 环境约需 20–40 秒;可以修改参数后重新运行。