-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlammps_run_01B.py
91 lines (51 loc) · 2.14 KB
/
lammps_run_01B.py
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
import numpy as np
import hotspot_file_01
import multiprocessing
import pymp
import tensorflow as tf
import matplotlib.pyplot as plt
def compute_total_pe(df_list):
pe = pymp.shared.array((len(df_list),), dtype='float64')
with pymp.Parallel(multiprocessing.cpu_count()) as p:
for t in p.range(0, len(df_list)):
df = df_list[t]
pe[t] = np.sum(np.asarray(df['c_poteng']), axis=0)
T = np.arange(0, len(pe), 1, dtype=float)
plt.plot(T, pe, 'k-')
plt.show()
return None
def compute_distance(cnt_array, cnt_other_array):
dist_list = []
points = cnt_array
for j in range(0, len(cnt_other_array)):
single_point = cnt_other_array[j, :]
dist = np.sum(((points - single_point)**2), axis=1)
dist = np.sqrt(dist)
dist_list.append(dist)
return np.asarray(dist_list)
def compute_local_pe(df_list, cnt_id, threshold=3.0):
pe = pymp.shared.array((len(df_list),), dtype='float64')
with pymp.Parallel(multiprocessing.cpu_count()) as p:
for t in p.range(0, len(df_list)):
df = df_list[t]
#locate cnt atom
df_select = df.loc[df['id']==cnt_id]
mat_select = df_select.loc[:, ['x', 'y', 'z']].as_matrix()
mat_other = df.loc[:, ['x', 'y', 'z']].as_matrix()
pe_all = df.loc[:, ['c_poteng']].as_matrix()
dist = compute_distance(mat_select, mat_other)
idx = np.where(dist < threshold)
pe_select = pe_all[idx[0]]
pe[t] = np.sum(pe_select)
#dist = compute_distance(mat_select, mat_other)
T = np.arange(0, len(pe), 1, dtype=float)
plt.plot(T, pe, 'k-')
plt.show()
return None
peratom_files = './cnt.pe.1126/dump.pe1epo.*'
param_list = {'channel_size': np.array([8.0, 8.0, 15.0]), 'delta': np.array([4.0, 4.0, 2.0]), 'tol': np.array([5.0, 5.0, 5.0]), 'Radius': 3.0, 'epsilon': 3.0}
#prop_lookup = ['c_ppa']
prop_lookup = ['c_poteng']
dprocess_1 = hotspot_file_01.dump_files(2, prop_lookup, 10, param_list, peratom_files)
compute_total_pe(df_list=dprocess_1.df_list)
compute_local_pe(df_list=dprocess_1.df_list, cnt_id=1978)