mdkits 0.1a4__py3-none-any.whl → 0.1a6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mdkits might be problematic. Click here for more details.
- mdkits/cli/density.py +51 -18
- mdkits/mdkits.py +2 -1
- mdkits/util/numpy_geo.py +3 -2
- {mdkits-0.1a4.dist-info → mdkits-0.1a6.dist-info}/METADATA +1 -1
- {mdkits-0.1a4.dist-info → mdkits-0.1a6.dist-info}/RECORD +8 -8
- {mdkits-0.1a4.dist-info → mdkits-0.1a6.dist-info}/LICENSE +0 -0
- {mdkits-0.1a4.dist-info → mdkits-0.1a6.dist-info}/WHEEL +0 -0
- {mdkits-0.1a4.dist-info → mdkits-0.1a6.dist-info}/entry_points.txt +0 -0
mdkits/cli/density.py
CHANGED
|
@@ -5,13 +5,18 @@ import click
|
|
|
5
5
|
import MDAnalysis
|
|
6
6
|
from MDAnalysis import Universe
|
|
7
7
|
from MDAnalysis.analysis.base import AnalysisBase
|
|
8
|
-
from mdkits.util import
|
|
8
|
+
from mdkits.util import (
|
|
9
|
+
arg_type,
|
|
10
|
+
numpy_geo,
|
|
11
|
+
encapsulated_mda,
|
|
12
|
+
os_operation,
|
|
13
|
+
)
|
|
9
14
|
import warnings
|
|
10
15
|
warnings.filterwarnings("ignore")
|
|
11
16
|
|
|
12
17
|
|
|
13
18
|
class Density_distribution(AnalysisBase):
|
|
14
|
-
def __init__(self, filename, cell, o, distance_judg, angle_judg, dt=0.001, bin_size=0.2, return_index=False):
|
|
19
|
+
def __init__(self, filename, cell, o, element, density, update_water, distance_judg, angle_judg, surface, dt=0.001, bin_size=0.2, return_index=False):
|
|
15
20
|
u = Universe(filename)
|
|
16
21
|
u.trajectory.ts.dt = dt
|
|
17
22
|
u.dimensions = cell
|
|
@@ -25,21 +30,31 @@ class Density_distribution(AnalysisBase):
|
|
|
25
30
|
self.bin_size = bin_size
|
|
26
31
|
self.frame_count = 0
|
|
27
32
|
self.return_index = return_index
|
|
33
|
+
self.surface = surface
|
|
34
|
+
self.element = element
|
|
35
|
+
self.density = density
|
|
36
|
+
self.update_water = update_water
|
|
37
|
+
|
|
38
|
+
if surface is not None:
|
|
39
|
+
self.surface_group = self.atomgroup.select_atoms(f"{surface}")
|
|
40
|
+
else:
|
|
41
|
+
self.surface_group = False
|
|
28
42
|
|
|
29
43
|
super(Density_distribution, self).__init__(self.atomgroup.universe.trajectory, verbose=True)
|
|
30
44
|
|
|
31
45
|
def _prepare(self):
|
|
32
46
|
self.bin_num = int(self.u.dimensions[2] / self.bin_size) + 2
|
|
33
47
|
self.density_distribution = np.zeros(self.bin_num, dtype=np.float64)
|
|
34
|
-
if self.
|
|
35
|
-
self.surface_pos = ()
|
|
48
|
+
if self.surface_group:
|
|
49
|
+
self.surface_pos = np.zeros(2)
|
|
36
50
|
|
|
37
51
|
def _append(self, z):
|
|
38
52
|
bins = np.floor(z / self.bin_size).astype(int) + 1
|
|
39
53
|
np.add.at(self.density_distribution, bins, 1)
|
|
40
54
|
|
|
55
|
+
|
|
41
56
|
def _single_frame(self):
|
|
42
|
-
if self.
|
|
57
|
+
if self.update_water:
|
|
43
58
|
o_group = self.atomgroup.select_atoms("name O")
|
|
44
59
|
h_group = self.atomgroup.select_atoms("name H")
|
|
45
60
|
|
|
@@ -48,40 +63,58 @@ class Density_distribution(AnalysisBase):
|
|
|
48
63
|
self._append(o.positions[:, 2])
|
|
49
64
|
|
|
50
65
|
else:
|
|
51
|
-
group = self.atomgroup.select_atoms(f"
|
|
66
|
+
group = self.atomgroup.select_atoms(f"{self.element}")
|
|
52
67
|
self._append(group.positions[:, 2])
|
|
53
68
|
|
|
54
|
-
self.
|
|
69
|
+
if self.surface_group:
|
|
70
|
+
lower_z, upper_z = numpy_geo.find_surface(self.surface_group.positions[:, 2], layer_tolerance=1, surface_tolerance=5)
|
|
71
|
+
self.surface_pos[0] += lower_z
|
|
72
|
+
self.surface_pos[1] += upper_z
|
|
73
|
+
|
|
55
74
|
self.frame_count += 1
|
|
56
75
|
|
|
57
76
|
def _conclude(self):
|
|
58
77
|
if self.frame_count > 0:
|
|
59
78
|
V = self.u.dimensions[0] * self.u.dimensions[1] * self.bin_size
|
|
60
79
|
|
|
61
|
-
if self.
|
|
62
|
-
density_distribution = (self.density_distribution *
|
|
80
|
+
if self.density:
|
|
81
|
+
density_distribution = (self.density_distribution * self.density * 1.660539 / V) / self.frame_count
|
|
63
82
|
else:
|
|
64
83
|
density_distribution = (self.density_distribution * (10000/6.02) / V) / self.frame_count
|
|
65
84
|
|
|
66
85
|
bins_z = np.arange(len(self.density_distribution)) * self.bin_size
|
|
67
86
|
|
|
68
|
-
|
|
87
|
+
if self.surface:
|
|
88
|
+
lower_z = self.surface_pos[0] / self.frame_count
|
|
89
|
+
upper_z = self.surface_pos[1] / self.frame_count
|
|
69
90
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
91
|
+
mask = (bins_z >= lower_z) & (bins_z <= upper_z)
|
|
92
|
+
filtered_bins_z = bins_z[mask] - lower_z
|
|
93
|
+
filtered_density_distribution = density_distribution[mask]
|
|
94
|
+
|
|
95
|
+
conbined_data = np.column_stack((filtered_bins_z, filtered_density_distribution))
|
|
96
|
+
else:
|
|
97
|
+
conbined_data = np.column_stack((bins_z, density_distribution))
|
|
75
98
|
|
|
76
99
|
np.savetxt(self.o, conbined_data, header="Z\tdensity", fmt='%.5f', delimiter='\t')
|
|
77
100
|
|
|
78
101
|
@click.command(name='density')
|
|
79
102
|
@click.argument('filename', type=click.Path(exists=True), default=os_operation.default_file_name('*-pos-1.xyz', last=True))
|
|
80
|
-
@click.option('--cell', type=arg_type.Cell, help='set xyz file cell, --cell x,y,z,a,b,c')
|
|
81
103
|
@click.option('--cell', type=arg_type.Cell, help='set cell from cp2k input file or a list of lattice: --cell x,y,z or x,y,z,a,b,c', default='input.inp', show_default=True)
|
|
104
|
+
@click.option('--element', type=str, help='element to analysis')
|
|
105
|
+
@click.option('--density', type=float, help='output density unit (g/cm3), should give atomic mass of element, else is concentration unit (mol/L)')
|
|
82
106
|
@click.option('-o', type=str, help='output file name', default='density.dat', show_default=True)
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
@click.option('--update_water', is_flag=True, help='update water with distance or angle judgment')
|
|
108
|
+
@click.option('--distance', type=float, help='update water distance judgment', default=1.2, show_default=True)
|
|
109
|
+
@click.option('--angle', type=(float), help='update water angle judgment')
|
|
110
|
+
@click.option('--surface', type=str, help='surface element')
|
|
111
|
+
def main(filename, cell, o, element, density, update_water, distance, angle, surface):
|
|
112
|
+
"""
|
|
113
|
+
analysis density or concentration of element in a trajectory file
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
density_dist = Density_distribution(filename, cell, o=o, distance_judg=distance, angle_judg=angle, element=element, density=density, update_water=update_water, surface=surface)
|
|
117
|
+
|
|
85
118
|
density_dist.run()
|
|
86
119
|
|
|
87
120
|
|
mdkits/mdkits.py
CHANGED
|
@@ -5,6 +5,7 @@ from mdkits.cli import (
|
|
|
5
5
|
extract,
|
|
6
6
|
data,
|
|
7
7
|
plot,
|
|
8
|
+
density
|
|
8
9
|
)
|
|
9
10
|
|
|
10
11
|
|
|
@@ -12,7 +13,6 @@ from mdkits.cli import (
|
|
|
12
13
|
@click.pass_context
|
|
13
14
|
@click.version_option()
|
|
14
15
|
def cli(ctx):
|
|
15
|
-
print(ctx)
|
|
16
16
|
"""tools for md or dft"""
|
|
17
17
|
pass
|
|
18
18
|
|
|
@@ -22,6 +22,7 @@ cli.add_command(wrap.main)
|
|
|
22
22
|
cli.add_command(extract.main)
|
|
23
23
|
cli.add_command(data.main)
|
|
24
24
|
cli.add_command(plot.main)
|
|
25
|
+
cli.add_command(density.main)
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
if __name__ == '__main__':
|
mdkits/util/numpy_geo.py
CHANGED
|
@@ -97,7 +97,7 @@ def unwrap(atom1, atom2, coefficients, max=0, total=False):
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
def find_surface(surface_group:np.ndarray, layer_tolerance=1, surface_tolerance=5):
|
|
100
|
-
sort_group =
|
|
100
|
+
sort_group = np.sort(surface_group)
|
|
101
101
|
layer_mean = []
|
|
102
102
|
current_layer = [sort_group[0]]
|
|
103
103
|
for i in range(1, len(sort_group)):
|
|
@@ -106,6 +106,7 @@ def find_surface(surface_group:np.ndarray, layer_tolerance=1, surface_tolerance=
|
|
|
106
106
|
else:
|
|
107
107
|
layer_mean.append(np.mean(current_layer))
|
|
108
108
|
current_layer = [sort_group[i]]
|
|
109
|
+
layer_mean.append(np.mean(current_layer))
|
|
109
110
|
|
|
110
111
|
if len(current_layer) == 1:
|
|
111
112
|
return layer_mean[0]
|
|
@@ -115,4 +116,4 @@ def find_surface(surface_group:np.ndarray, layer_tolerance=1, surface_tolerance=
|
|
|
115
116
|
index = np.argmax(diff > 5)
|
|
116
117
|
return (layer_mean[index], layer_mean[index + 1])
|
|
117
118
|
else:
|
|
118
|
-
return layer_mean[-1]
|
|
119
|
+
return (layer_mean[-1], layer_mean[0])
|
|
@@ -11,7 +11,7 @@ mdkits/cli/cp2k_input.py,sha256=EskBUSaAOLmrrUYGruTwZjEy9EksdEhWwR5ys9juIbg,1113
|
|
|
11
11
|
mdkits/cli/cube.py,sha256=XcJfsJ5Y2d5MQfD45p06_gV1fTJbDSrNhCnZ3Sz2Vb0,2233
|
|
12
12
|
mdkits/cli/cut_surface.py,sha256=D1naCWj0QJE3AiInzy3SeGO37butothE3BS1rZsZ5MU,1425
|
|
13
13
|
mdkits/cli/data.py,sha256=FGA4S9Cfo6WUJBSPWKOJrrZXHo_Qza-jNG1P_Dw7yi4,3262
|
|
14
|
-
mdkits/cli/density.py,sha256=
|
|
14
|
+
mdkits/cli/density.py,sha256=Icxj-IMvUEFe15VKT13TrX5sHDmyczMnqo-VP46gPlI,5030
|
|
15
15
|
mdkits/cli/density2.py,sha256=I1OtC7s979Ks7GOH47hTKUGE1h6tUFYvNZQ7Qbifs6I,3458
|
|
16
16
|
mdkits/cli/extract.py,sha256=bqqJBmSaVyPYyEseGpUJcMBufIfDLTNRdmUfJ0txE5E,2498
|
|
17
17
|
mdkits/cli/hartree_potential.py,sha256=XcJfsJ5Y2d5MQfD45p06_gV1fTJbDSrNhCnZ3Sz2Vb0,2233
|
|
@@ -26,18 +26,18 @@ mdkits/cli/supercell.py,sha256=r5iddLw1NNzj7NTFlR2j_jpD1AMfrsxhA08bPwQvVvg,2059
|
|
|
26
26
|
mdkits/cli/wrap.py,sha256=AUxGISuiCfEjdMYl-TKc2VMCPHSybWKrMIOTn_6kSp0,1043
|
|
27
27
|
mdkits/config/__init__.py,sha256=ZSwmnPK02LxJLMgcYmNb-tIOk8fEuHf5jpqD3SDHWLg,1039
|
|
28
28
|
mdkits/config/settings.yml,sha256=PY7u0PbFLuxSnd54H5tI9oMjUf-mzyADqSZtm99BwG0,71
|
|
29
|
-
mdkits/mdkits.py,sha256=
|
|
29
|
+
mdkits/mdkits.py,sha256=sBA61-E1lk-RJlOr_WcTkd7GjfxcHlBW_ASyg01s5os,471
|
|
30
30
|
mdkits/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
mdkits/util/arg_type.py,sha256=YUFhYShTYfUe7xajgUCiCuaeNLH-wxMXvlcMRax4zRM,1469
|
|
32
32
|
mdkits/util/cp2k_input_parsing.py,sha256=6BFVsbBYxdauaUPrjr5h8JXk_R0bu7V3cbG2DEWWFlQ,1291
|
|
33
33
|
mdkits/util/encapsulated_ase.py,sha256=dZU1i9Kw8rIyiQCCSDEXOs3q_z4dCMIo6bf5ooY9u0c,4089
|
|
34
34
|
mdkits/util/encapsulated_mda.py,sha256=td3H24u3eHOIS2nwPucfIaMxeaVxI77oFI8nnNhw7vo,2217
|
|
35
35
|
mdkits/util/fig_operation.py,sha256=FwffNUtXorMl6qE04FipgzcVljEQii7wrNJUCJMyY3E,1045
|
|
36
|
-
mdkits/util/numpy_geo.py,sha256=
|
|
36
|
+
mdkits/util/numpy_geo.py,sha256=1Op8THoQeyqybSZAi7hVxohYCr4SzY6ndZC8_gAGXDA,3619
|
|
37
37
|
mdkits/util/os_operation.py,sha256=tNRjniDwFqARMy5Rf6MUNmaQGpJlyifCpuN16r8aB2g,828
|
|
38
38
|
mdkits/util/structure_parsing.py,sha256=mRPMJeih3O-ST7HeETDvBEkfV-1psT-XgxyYgDadV0U,4152
|
|
39
|
-
mdkits-0.
|
|
40
|
-
mdkits-0.
|
|
41
|
-
mdkits-0.
|
|
42
|
-
mdkits-0.
|
|
43
|
-
mdkits-0.
|
|
39
|
+
mdkits-0.1a6.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
|
|
40
|
+
mdkits-0.1a6.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
|
|
41
|
+
mdkits-0.1a6.dist-info/METADATA,sha256=OM9IB6t1RlnqX5CM007d5oWafnkVTVpMGUrfOnxbjtA,4284
|
|
42
|
+
mdkits-0.1a6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
43
|
+
mdkits-0.1a6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|