Skip to content

Commit

Permalink
updated memory
Browse files Browse the repository at this point in the history
  • Loading branch information
mushroomfire committed Oct 27, 2022
1 parent cd6f00a commit 5a9e7ac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ mp.init("cpu")
## 更新记录
## 2022-10-27
1. 跟新cluster_analysis功能,使用fortran加速,使用预编译分发.
2. 版本号更新
2. 版本号更新0.5.2
3. 内存优化

## 2022-10-20
1. 增加了团簇分析功能,cluster_analysis,添加了numba加速,在一些特定场合numba也还是不错的.
Expand Down
51 changes: 28 additions & 23 deletions src/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ def write_data(self, output_name=None):
)

def build_neighbor(self, rc=5.0, max_neigh=80, exclude=True):
self.Neighbor = Neighbor(
self.pos, self.box, rc, self.boundary, max_neigh, exclude
Neigh = Neighbor(self.pos, self.box, rc, self.boundary, max_neigh, exclude)
Neigh.compute()

self.verlet_list, self.distance_list, self.neighbor_number, self.rc = (
Neigh.verlet_list,
Neigh.distance_list,
Neigh.neighbor_number,
rc,
)
self.Neighbor.compute()
self.if_neigh = True

def cal_atomic_temperature(self, amass, rc=5.0, units="metal", max_neigh=80):
Expand All @@ -127,14 +132,14 @@ def cal_atomic_temperature(self, amass, rc=5.0, units="metal", max_neigh=80):
"""
if not self.if_neigh:
self.build_neighbor(rc, max_neigh)
elif self.Neighbor.rc < rc:
elif self.rc < rc:
self.build_neighbor(rc, max_neigh)
atype_list = self.data["type"].values.astype(np.int32)
AtomicTemp = AtomicTemperature(
amass,
self.vel,
self.Neighbor.verlet_list,
self.Neighbor.distance_list,
self.verlet_list,
self.distance_list,
atype_list,
rc,
units,
Expand All @@ -148,36 +153,38 @@ def cal_centro_symmetry_parameter(self, N=12, rc=5.0):
"""
if not self.if_neigh:
self.build_neighbor(rc=rc, max_neigh=80)
elif self.Neighbor.rc < rc:
elif self.rc < rc:
self.build_neighbor(rc=rc, max_neigh=80)

CentroSymmetryPara = CentroSymmetryParameter(
self.pos,
np.array([self.lx, self.ly, self.lz]),
N,
self.boundary,
self.Neighbor.verlet_list,
self.Neighbor.distance_list,
self.Neighbor.neighbor_number,
self.verlet_list,
self.distance_list,
self.neighbor_number,
)
CentroSymmetryPara.compute()
self.data["csp"] = CentroSymmetryPara.csp

def cal_atomic_entropy(self, rc=5.0, sigma=0.25, use_local_density=False):
def cal_atomic_entropy(
self, rc=5.0, sigma=0.25, use_local_density=False, max_neigh=80
):

"""
sigma : 用来表征插值的精细程度类似于,不能太大, 默认使用0.25或者0.2就行.
use_local_density : 是否使用局部密度,俺也不咋懂.
"""

if not self.if_neigh:
self.build_neighbor(rc=rc, max_neigh=80)
elif self.Neighbor.rc < rc:
self.build_neighbor(rc=rc, max_neigh=80)
self.build_neighbor(rc=rc, max_neigh=max_neigh)
elif self.rc < rc:
self.build_neighbor(rc=rc, max_neigh=max_neigh)

AtomicEntro = AtomicEntropy(
self.vol,
self.Neighbor.distance_list,
self.distance_list,
rc,
sigma,
use_local_density,
Expand All @@ -188,22 +195,20 @@ def cal_atomic_entropy(self, rc=5.0, sigma=0.25, use_local_density=False):
def cal_pair_distribution(self, rc=5.0, nbin=200, max_neigh=80):
if not self.if_neigh:
self.build_neighbor(rc=rc, max_neigh=max_neigh)
elif self.Neighbor.rc < rc:
elif self.rc < rc:
self.build_neighbor(rc=rc, max_neigh=max_neigh)
rho = self.N / self.vol
self.PairDistribution = PairDistribution(
rc, nbin, rho, self.Neighbor.verlet_list, self.Neighbor.distance_list
rc, nbin, rho, self.verlet_list, self.distance_list
)
self.PairDistribution.compute()

def cal_cluster_analysis(self, rc=5.0, max_neigh=80):
if not self.if_neigh:
self.build_neighbor(rc=rc, max_neigh=max_neigh)
elif self.Neighbor.rc < rc:
elif self.rc < rc:
self.build_neighbor(rc=rc, max_neigh=max_neigh)

self.ClusterAnalysis = ClusterAnalysis(
rc, self.Neighbor.verlet_list, self.Neighbor.distance_list
)
self.ClusterAnalysis.compute()
self.data["cluster_id"] = self.ClusterAnalysis.particleClusters
ClusterAnalysi = ClusterAnalysis(rc, self.verlet_list, self.distance_list)
ClusterAnalysi.compute()
self.data["cluster_id"] = ClusterAnalysi.particleClusters

0 comments on commit 5a9e7ac

Please sign in to comment.