如何解决为一维渗透模型添加其他连接
我正在尝试模拟1D渗流模型,我想看看最大的簇如何随晶格长度缩放。晶格是一个闭环(周期性边界条件)。我已经编写了以下脚本,但这仅在群集为邻居(i-1)和(i + 1)时才计算群集。我想包括位于位置(i-2)和(i + 2)的站点。
我一直在研究Python的NetworkX软件包,该软件包似乎能够在站点之间创建链接,但是在实现它方面一直没有成功。如果您知道此程序包或执行此操作的任何其他方式,我将非常感谢您的帮助。
import matplotlib.pyplot as plt
import numpy as np
import numpy.random as npr
from scipy.ndimage import measurements
p = 0.8 #Probability of being occupied
for L in np.arange(10,100,10): #Loop over lattice length
z = npr.rand(L) #L random numbers [0,1]
m = z < p #Site occupied or not
lw,num = measurements.label(m) #Scipy's: returns connected clusters (same value = same cluster)
cluster_sizes = measurements.sum(m,lw,index = np.arange(lw.max() + 1)) #Returns the cluster size
max_cluster_size = np.max(cluster_sizes) #Returns the biggest cluster
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。