mdkits 1.0.0__py3-none-any.whl → 1.0.2__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/extract.py CHANGED
@@ -47,7 +47,7 @@ def write_to_xyz_s(u, frames, select, cut=None):
47
47
  @click.argument('input_file_name', type=click.Path(exists=True), default=os_operation.default_file_name('*-pos-1.xyz', last=True))
48
48
  @click.option('-r', type=arg_type.FrameRange, help='frame range to slice', default='-1', show_default=True)
49
49
  @click.option('-c', help='output a coord.xyz', is_flag=True)
50
- @click.option("--select", type=str, help="select atoms to extract")
50
+ @click.option("--select", type=str, help="select atoms to extract", default="all", show_default=True)
51
51
  def main(input_file_name, r, c, select):
52
52
  """
53
53
  extract frames in trajectory file
@@ -30,7 +30,11 @@ def parse_cell():
30
30
  if len(cell) == 3:
31
31
  cell.extend([90.0, 90.0, 90.0])
32
32
 
33
- out_err.cell_output(cell)
33
+ if len(cell) == 0:
34
+ print("parse failed")
35
+ return [0., 0., 0., 90., 90., 90.]
36
+ else:
37
+ print(f"parsed cell: x = {cell[0]}, y = {cell[1]}, z = {cell[2]}, a = {cell[3]}\u00B0, b = {cell[4]}\u00B0, c = {cell[5]}\u00B0")
34
38
  return cell
35
39
  except FileNotFoundError:
36
40
  return [0., 0., 0., 90., 90., 90.]
@@ -0,0 +1,365 @@
1
+ Metadata-Version: 2.3
2
+ Name: mdkits
3
+ Version: 1.0.2
4
+ Summary: kits for md or dft
5
+ License: MIT
6
+ Keywords: molecular dynamics,density functional theory
7
+ Author: jxxcr
8
+ Author-email: jixxcr@qq.com
9
+ Requires-Python: >=3.11,<4.0
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Dist: Cp2kData (>=0.7.2,<0.8.0)
17
+ Requires-Dist: MDAnalysis (>=2.8.0,<3.0.0)
18
+ Requires-Dist: ase (>=3.22.1,<4.0.0)
19
+ Requires-Dist: click (>=8.1.3,<9.0.0)
20
+ Requires-Dist: julia (>=0.6.2,<0.7.0)
21
+ Requires-Dist: matplotlib (>=3.9.0,<4.0.0)
22
+ Requires-Dist: numpy (>=1.26.4,<2.0.0)
23
+ Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
24
+ Requires-Dist: tidynamics (>=1.1.2,<2.0.0)
25
+ Project-URL: Repository, https://github.com/jxxcr/mdkits
26
+ Description-Content-Type: text/markdown
27
+
28
+ # mdkits
29
+ [中文文档](README_zh.md)
30
+
31
+ `mdkits` provides a variety of tools. Installation script:
32
+ ```bash
33
+ pip install mdkits --upgrade
34
+ ```
35
+
36
+ ## General Option Parameter Types
37
+
38
+ 1. `CELL TYPE`: Specifies lattice cell parameters, e.g., `10,10,10`, `10,10,10,90,90,90`, etc.
39
+ 2. `FRAME RANGE`: Specifies the frame range, e.g., `1`, `1:10:2`, etc.
40
+ 3. `--group` and `--surface`: Select analysis objects using [selection language](https://userguide.mdanalysis.org/stable/selections.html).
41
+ 4. `--update_water`, `--distance`, and `--angle`: Enable dynamic update of water molecule positions during trajectory analysis.
42
+
43
+ ## Trajectory File Processing Scripts
44
+
45
+ `md` is the trajectory file processing tool, which includes several processing utilities.
46
+
47
+ ### Density Distribution
48
+
49
+ `density` is used to analyze the density distribution of a specific element along the z-axis in a system. For example, to analyze the density distribution of the `O` element along the z-axis:
50
+ ```bash
51
+ mdkits md density [FILENAME] --group="name H" --cell [FILENAME]
52
+ ```
53
+ This will output a file named `density_name_H.dat`, where the first column is the z-axis coordinate and the second column is the density distribution in units of mol/L. To output the density distribution in units of $g/cm^3$, you can specify the `--atomic_mass` option, for example:
54
+ ```bash
55
+ mdkits md density [FILENAME] --group="name H" --cell [FILENAME] --atomic_mass=1.00784
56
+ ```
57
+ This will output the density distribution in units of $g/cm^3$. You can specify surface atoms to normalize the density distribution to the surface, for example:
58
+ ```bash
59
+ mdkits md density [FILENAME] --group="name O" --cell 10,10,10 --atomic_mass=18.01528 --surface="name Pt and name Ru"
60
+ ```
61
+ This will normalize the density distribution to the surface and analyze the density distribution of water molecules using the positions of O atoms as the reference for water molecules. For systems with $OH^-$ ions, you can use the `--update_water` option to update the positions of water molecules in each frame, without needing to specify an element explicitly, for example:
62
+ ```bash
63
+ mdkits md density [FILENAME] --update_water --cell 10,10,10 --atomic_mass=18.01528 --surface="name Pt and name Ru"
64
+ ```
65
+ The output file will be named `density_water.dat`.
66
+
67
+ ### Hydrogen Bonds
68
+
69
+ `hb` is used to analyze hydrogen bonds in a system, for example, to analyze the distribution of hydrogen bonds along the z-axis:
70
+ ```bash
71
+ mdkits md hb [FILENAME] --cell 10,10,40 --surface "prop z < 10" --update_water
72
+ ```
73
+ Or to analyze hydrogen bonds of a single water molecule:
74
+ ```bash
75
+ mdkits md hb [FILENAME] --cell 10,10,40 --index 15
76
+ ```
77
+
78
+ ### Angle
79
+
80
+ `angle` is used to analyze the abundance distribution of the angle between the bisector vector of a water molecule's OH bond and the surface normal. For example, to analyze the angle abundance distribution of water molecules within 5 Å of the surface:
81
+ ```bash
82
+ mdkits md angle [FILENAME] --cell 10,10,40 --surface "name Pt" --water_height 5
83
+ ```
84
+
85
+ ### Dipole Distribution
86
+
87
+ `diople` is used to analyze the dipole ($\cos \phi \rho_{H_2 O}$) distribution in a system. For example, to analyze the $\cos \phi \rho_{H_2 O}$ distribution in the system:
88
+ ```bash
89
+ mdkits md diople [FILENAME] --cell 10,10,40 --surface "name Pt"
90
+ ```
91
+
92
+ ### Radial Distribution Function (RDF)
93
+
94
+ `rdf` is used to analyze the radial distribution function between two `group`s. For example, to analyze the radial distribution function between `O` and `H` elements in the system:
95
+ ```bash
96
+ mdkits md rdf [FILENAME] --group "name O" "name H" --cell 10,10,40 --range 0.1 5
97
+ ```
98
+
99
+ ### Mean Squared Displacement (MSD)
100
+
101
+ `msd` is used to analyze the mean squared displacement of certain atoms in a system. For example, to analyze the MSD of `Li` atoms along the z-axis:
102
+ ```bash
103
+ mdkits md msd [FILENAME] z "name Li"
104
+ ```
105
+
106
+ ### Monitor
107
+
108
+ `monitor` is used to monitor changes in atom height, bond length, and bond angle in a system. For example, to monitor the height of the atom with `index` 0:
109
+ ```bash
110
+ mdkits md monitor [FILENAME] --cell 10,10,40 --surface "name Pt" -i 0
111
+ ```
112
+ This will output the height from the surface as a function of each frame. To monitor the bond length between atoms 0 and 1:
113
+ ```bash
114
+ mdkits md monitor [FILENAME] --cell 10,10,40 --surface "name Pt" -i 0 -i 1
115
+ ```
116
+ This will output the heights from the surface for atoms 0 and 1, and the bond length between 0 and 1 as a function of each frame. To monitor the bond angle of 1-0-2:
117
+ ```bash
118
+ mdkits md monitor [FILENAME] --cell 10,10,40 --surface "name Pt" -i 1 -i 0 -i 2
119
+ ```
120
+ This will output the heights from the surface for atoms 1, 0, and 2, the bond lengths between 1-0 and 0-2, and the bond angle 1-0-2 as a function of each frame. Note that atoms at the vertex of an angle should be placed in the middle.
121
+
122
+ ### Position Normalization
123
+
124
+ `wrap` is used to normalize the atomic positions in a trajectory file. For example, to normalize the atomic positions in `[FILENAME]` within the unit cell and output it as `wrapped.xyz`. By default, it reads `ABC` and `ALPHA_BETA_GAMMA` information from the `cp2k` output file `input_inp` as lattice cell parameters:
125
+ ```bash
126
+ mdkits md wrap [FILENAME]
127
+ ```
128
+ Or specify the `cp2k` input file:
129
+ ```bash
130
+ mdkits md wrap [FILENAME] --cp2k_input_file setting.inp
131
+ ```
132
+ Or specify the lattice cell parameters:
133
+ ```bash
134
+ mdkits md wrap [FILENAME] --cell 10,10,10
135
+ ```
136
+ The default `[FILENAME]` is `*-pos-1.xyz`.
137
+
138
+ ### Vibrational Density of States (VDOS)
139
+
140
+ `vac` is used to analyze the velocity autocorrelation function of a trajectory and compute the Fourier transform of the velocity autocorrelation function, which is the vibrational density of states (VDOS). For example, to analyze the VDOS of the system:
141
+ ```bash
142
+ mdkits md vac h2o-vel-1.xyz
143
+ ```
144
+ The default `[FILENAME]` is `*-vel-1.xyz`.
145
+
146
+ ## DFT Property Analysis Scripts
147
+
148
+ `dft` is the DFT property analysis tool, which includes several analysis utilities.
149
+
150
+ ### PDOS
151
+
152
+ `pdos` is used to analyze the PDOS of a system. To analyze the d-orbital DOS of `[FILENAME]`:
153
+ ```bash
154
+ mdkits dft pdos [FILENAME] -t d
155
+ ```
156
+
157
+ ### CUBE Files
158
+
159
+ `cube` is used to process files in [`cube` format](https://paulbourke.net/dataformats/cube/), averaging them along the z-axis:
160
+ ```bash
161
+ mdkits dft cube [FILENAME]
162
+ ```
163
+ The processed data will be output to `cube.out`. You can also calculate the average value within a specific region:
164
+ ```bash
165
+ mdkits dft cube [FILENAME] -b 1 2
166
+ ```
167
+ This will print the average value to the screen and also record it in the comment line of `cube.out`.
168
+
169
+ ## Modeling
170
+
171
+ `build` is the modeling tool, which includes several modeling utilities.
172
+
173
+ ### Building Bulk Models
174
+
175
+ `bulk` is used to build bulk models. For example, to build an `fcc` bulk model of `Pt`:
176
+ ```bash
177
+ mdkits build bulk Pt fcc
178
+ ```
179
+ To build as a conventional cell model:
180
+ ```bash
181
+ mdkits build bulk Pt fcc --cubic
182
+ ```
183
+ To build a `Caesium chloride` structure model:
184
+ ```bash
185
+ mdkits build bulk CsCl cesiumchloride -a 4.123
186
+ ```
187
+ To build a `fluorite` structure model:
188
+ ```bash
189
+ mdkits build bulk BaF2 fluorite -a 6.196
190
+ ```
191
+
192
+ ### Building Surface Models
193
+
194
+ `surface` is used to build common surface models. Usage:
195
+ ```bash
196
+ mdkits build surface [ELEMENT] [SURFACE_TYPE] [SIZE]
197
+ ```
198
+ For example, to build an `fcc111` surface model of `Pt`:
199
+ ```bash
200
+ mdkits build surface Pt fcc111 2 2 3 --vacuum 15
201
+ ```
202
+ To build a graphene surface:
203
+ ```bash
204
+ mdkits build surface C2 graphene 3 3 1 --vacuum 15
205
+ ```
206
+
207
+ ### Building Surface Models from Existing Structures
208
+
209
+ `cut` is used to build surface models from existing structures (the structure must be in a conventional cell). For example, to build an `fcc331` surface model from `Pt_fcc.cif`:
210
+ ```bash
211
+ mdkits build cut Pt_fcc.cif --face 3 3 1 --size 3 3 5 --vacuum 15
212
+ ```
213
+
214
+ ### Adding Adsorbates to Surface Structures
215
+
216
+ `adsorbate` is used to add adsorbates to surface structures. For example, to add an `H` atom to `surface.cif`:
217
+ ```bash
218
+ mdkits build adsorbate surface.cif H --select "index 0" --height 1
219
+ ```
220
+ Or to add an `H` atom with a coverage of 5 to `Pt_fcc111_335.cif`:
221
+ ```bash
222
+ mdkits build adsorbate Pt_fcc111_335.cif H --select "prop z > 16" --height 2 --cover 5
223
+ ```
224
+
225
+ ### Building Solution Phase Models
226
+
227
+ `solution` is used to build solution phase models. When using for the first time, you should install `juliaup`:
228
+ ```bash
229
+ mdkits build solution --install_julia
230
+ ```
231
+ Then install `Packmol`:
232
+ ```bash
233
+ mdkits build solution --install_packmol
234
+ ```
235
+ After successful installation, you can use the `solution` functionality. For example, to build a water box with 32 water molecules:
236
+ ```bash
237
+ mdkits build solution --water_number 32 --cell 9.86,9.86,9.86
238
+ ```
239
+ Or to build a solution containing ions:
240
+ ```bash
241
+ mdkits build solution li.xyz k.xyz --water_number 64 --tolerance 2.5 -n 25 -n 45 --cell 15,15,15
242
+ ```
243
+ Here, the number of `-n` arguments must match the number of specified solvent molecule types, used to specify the number of solvents to add, respectively. Alternatively, build a solution phase model from `packmol` input files:
244
+ ```bash
245
+ mdkits build solution input.pm input2.pm --infile
246
+ ```
247
+
248
+ ### Building Interface Models
249
+
250
+ `interface` is used to build interface models. For example, to build an interface model without vacuum:
251
+ ```bash
252
+ mdkits build interface --slab Pt_fcc100_555.cif --sol water_160.cif
253
+ ```
254
+ Or to build an interface with a gas phase model:
255
+ ```bash
256
+ mdkits build interface --slab Pt_fcc100_555.cif --sol water_160.cif --cap ne --vacuum 20
257
+ ```
258
+
259
+ ### Building Supercell Models
260
+
261
+ `supercell` is used to build supercell models:
262
+ ```bash
263
+ mdkits build supercell Li3PO4.cif 2 2 2
264
+ ```
265
+
266
+ ## Others
267
+
268
+ ### Trajectory Extraction
269
+
270
+ `extract` is used to extract specific frames from a trajectory file. For example, to extract frames from the 1000th to the 2000th frame from `frames.xyz` and output them to `1000-2000.xyz`. The parameters for the `-r` option are consistent with Python's slicing syntax:
271
+ ```bash
272
+ mdkits extract frames.xyz -r 1000:2000 -o 1000-2000.xyz
273
+ ```
274
+ Or to extract the last frame from the default trajectory file `*-pos-1.xyz` generated by `cp2k` and output it as `frames_-1.xyz` (which is the default behavior of `extract`):
275
+ ```bash
276
+ mdkits extract
277
+ ```
278
+ Or to output a structure every 50 frames into the `./coord` directory, while adjusting the output format to `cp2k`'s `@INCLUDE coord.xyz` format:
279
+ ```bash
280
+ mdkits extract -cr ::50
281
+ ```
282
+ To extract the positions of specific elements, for example, to extract the positions of `O` and `H` elements:
283
+ ```bash
284
+ mdkits extract --select "name O or name H"
285
+ ```
286
+
287
+ ### Structure File Conversion
288
+
289
+ `convert` is used to convert structure files from one format to another. For example, to convert `structure.xyz` to `out.cif` (default filename is `out`). For files that do not store periodic boundary conditions, you can use the `--cell` option to specify `PBC`:
290
+ ```bash
291
+ mdkits convert -c structure.xyz --cell 10,10,10
292
+ ```
293
+ To convert `structure.cif` to `POSCAR`:
294
+ ```bash
295
+ mdkits convert -v structure.cif
296
+ ```
297
+ To convert `structure.cif` to `structure_xyz.xyz`:
298
+ ```bash
299
+ mdkits convert -c structure.cif -o structure_xyz
300
+ ```
301
+
302
+ ### Data Processing
303
+
304
+ `data` is used for data processing, such as:
305
+ 1. `--nor`: Normalizes the data.
306
+ 2. `--gaus`: Applies Gaussian filtering to the data.
307
+ 3. `--fold`: Folds and averages stacked data.
308
+ 4. `--err`: Calculates error bars for the data.
309
+ And so on.
310
+
311
+ ### Plotting Tool
312
+
313
+ `plot` is used for plotting data. `plot` requires reading a YAML format configuration file for plotting. The YAML file format is as follows:
314
+ ```yaml
315
+ # plot mode 1
316
+ figure1:
317
+ data:
318
+ legend1: ./data1.dat
319
+ legend2: ./data2.dat
320
+ x:
321
+ 0: x-axis
322
+ y:
323
+ 1: y-axis
324
+ x_range:
325
+ - 5
326
+ - 15
327
+
328
+ # plot mode 2
329
+ figure2:
330
+ data:
331
+ y-xais: ./data.dat
332
+ x:
333
+ 0: x-axis
334
+ y:
335
+ 1: legend1
336
+ 2: legend2
337
+ 3: legend3
338
+ 4: legend4
339
+ 5: legend5
340
+ y_range:
341
+ - 0.5
342
+ - 6
343
+ legend_fontsize: 12
344
+
345
+ # plot mode error
346
+ 12_dp_e_error:
347
+ data:
348
+ legend: ./error.dat
349
+ x:
350
+ 0: x-axis
351
+ y:
352
+ 1: y-axis
353
+ fold: dp
354
+ legend_fontsize: 12
355
+ ```
356
+ The above illustrates three plotting modes supported by `plot`: `mode 1`, `mode 2`, and `mode error`. `mode 1` is used for comparing the same column data from multiple data files, `mode 2` is used for comparing different column data from the same data file, and `mode error` is used for plotting mean squared error plots.
357
+
358
+ `plot` can process multiple YAML files simultaneously. Each YAML file can contain multiple plotting configurations. Plotting configurations for `mode 1` and `mode 2` can be automatically recognized, but the `error` mode requires explicit specification, for example:
359
+ ```bash
360
+ mdkits plot *.yaml
361
+ ```
362
+ and:
363
+ ```bash
364
+ mdkits plot *.yaml --error
365
+ ```
@@ -11,7 +11,7 @@ mdkits/build_cli/supercell.py,sha256=3iTTt3DHaERWDFonhBRS0oqWhjFh6pbS5SpIR-O1gYg
11
11
  mdkits/build_cli/water.xyz,sha256=ByLDz-rYhw_wLPBU78lIQHe4s4Xf5Ckjft-Dus3czIc,171
12
12
  mdkits/cli/convert.py,sha256=OmQ-7hmw0imgfgCJaWFEy3ePixsU7VKf0mGuJ6jRpn0,1795
13
13
  mdkits/cli/data.py,sha256=FGA4S9Cfo6WUJBSPWKOJrrZXHo_Qza-jNG1P_Dw7yi4,3262
14
- mdkits/cli/extract.py,sha256=JUDqASPcI0PJy6h0tyOBA1vL1AIgFo5ldpoIsYNU2M8,2910
14
+ mdkits/cli/extract.py,sha256=dNf05CZuir98Z0EOjE33JrYK5_YBYLzuOauIt2Lwoh0,2944
15
15
  mdkits/cli/plot.py,sha256=1yh5dq5jnQDuyWlxV_9g5ztsnuFHVu4ouYQ9VJYSrUU,8938
16
16
  mdkits/config/__init__.py,sha256=ZSwmnPK02LxJLMgcYmNb-tIOk8fEuHf5jpqD3SDHWLg,1039
17
17
  mdkits/config/settings.yml,sha256=PY7u0PbFLuxSnd54H5tI9oMjUf-mzyADqSZtm99BwG0,71
@@ -33,7 +33,7 @@ mdkits/mdkits.py,sha256=EiAt7dxGTaHuuj7bCNxgAqZbX0i3sldO0mBxOG-aMnY,595
33
33
  mdkits/util/.fig_operation.py.swp,sha256=iZYqdYMj4UKS1rmbXv8Ve2FcVBcNljX7Y43-neMdPSk,12288
34
34
  mdkits/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  mdkits/util/arg_type.py,sha256=_WmcFKUeOvG5LmQwzcL8-xBQgdwIxUP3gMqEqU7FYNU,2428
36
- mdkits/util/cp2k_input_parsing.py,sha256=7NMVOYEGycarokLJlhLoWWilciM7sd8MWp5FVTF7hqI,1223
36
+ mdkits/util/cp2k_input_parsing.py,sha256=IAZ2fF-s_atiqdrePRkKG1_EQYB195TFdxHUuB3uYtE,1485
37
37
  mdkits/util/encapsulated_ase.py,sha256=uhqIhsALxzwJYuFrfOYGGC6U0QLm_dcZNridvfl_XGc,4339
38
38
  mdkits/util/encapsulated_mda.py,sha256=m3i-XrcscMcM5V7JzLnor3JtAOfuDx3LLMl0tZt0n-w,2325
39
39
  mdkits/util/fig_operation.py,sha256=FwffNUtXorMl6qE04FipgzcVljEQii7wrNJUCJMyY3E,1045
@@ -41,8 +41,8 @@ mdkits/util/numpy_geo.py,sha256=B2QVADl1M8iixZrIOre2UUhHqvAeghvM8Q2woEQsH3Q,3880
41
41
  mdkits/util/os_operation.py,sha256=ErN2ExjX9vZRfPe3ypsj4eyoQTEePqzlEX0Xm1N4lL4,980
42
42
  mdkits/util/out_err.py,sha256=7vGDI7wVoJWe1S0BDbcq-UC2KAhblCzg-NAYZKBZ4lo,900
43
43
  mdkits/util/structure_parsing.py,sha256=mRPMJeih3O-ST7HeETDvBEkfV-1psT-XgxyYgDadV0U,4152
44
- mdkits-1.0.0.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
45
- mdkits-1.0.0.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
46
- mdkits-1.0.0.dist-info/METADATA,sha256=Z2GyGDkAg9qgs7DmgDwA2mcgkA6aXOZHAiHlIFwRcSs,11351
47
- mdkits-1.0.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
48
- mdkits-1.0.0.dist-info/RECORD,,
44
+ mdkits-1.0.2.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
45
+ mdkits-1.0.2.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
46
+ mdkits-1.0.2.dist-info/METADATA,sha256=NoNCXVMUI1qGY6aXW6Hs9h2QKEIoLb6NLI-pUsGwcLM,13539
47
+ mdkits-1.0.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
48
+ mdkits-1.0.2.dist-info/RECORD,,
@@ -1,333 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: mdkits
3
- Version: 1.0.0
4
- Summary: kits for md or dft
5
- License: MIT
6
- Keywords: molecular dynamics,density functional theory
7
- Author: jxxcr
8
- Author-email: jixxcr@qq.com
9
- Requires-Python: >=3.11,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Dist: Cp2kData (>=0.7.2,<0.8.0)
17
- Requires-Dist: MDAnalysis (>=2.8.0,<3.0.0)
18
- Requires-Dist: ase (>=3.22.1,<4.0.0)
19
- Requires-Dist: click (>=8.1.3,<9.0.0)
20
- Requires-Dist: julia (>=0.6.2,<0.7.0)
21
- Requires-Dist: matplotlib (>=3.9.0,<4.0.0)
22
- Requires-Dist: numpy (>=1.26.4,<2.0.0)
23
- Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
24
- Requires-Dist: tidynamics (>=1.1.2,<2.0.0)
25
- Project-URL: Repository, https://github.com/jxxcr/mdkits
26
- Description-Content-Type: text/markdown
27
-
28
- # mdkits
29
- `mdkits` 提供了多种工具, 安装脚本:
30
- ```bash
31
- pip install mdkits --upgrade
32
- ```
33
- ## 通用的选项参数类型
34
- 1. `CELL TYPE`: 指定晶胞参数, 如`10,10,10`, `10,10,10,90,90,90`等
35
- 2. `FRAME RANGE`: 指定帧范围, 如`1`, `1:10:2`等
36
- 3. `--group`和`--surface`: 按[选择语言](https://userguide.mdanalysis.org/stable/selections.html)选取分析对象
37
- 4. `--update_water`, `--distance` 和 `--angle`: 在分析轨迹的过程中开启动态更新水分子的功能
38
-
39
- ## 轨迹文件处理脚本
40
- `md`为轨迹文件处理工具, 其中包含多个处理工具
41
- ### 密度分布
42
- `density`用于分析体系中的某种元素沿z轴的密度分布, 如分析体系中的`O`元素沿z轴的密度分布:
43
- ```bash
44
- mdkits md density [FILENAME] --group="name H" --cell [FILENAME]
45
- ```
46
- 这样会输出一个文件名为`density_name_H.dat`的文件, 第一列为z轴坐标, 第二列为浓度分布, 单位为 mol/L. 如果想输出为单位为 $g/cm^3$ 的密度分布, 可以指定`--atomic_mass` 选项, 如:
47
- ```bash
48
- mdkits md density [FILENAME] --group="name H" --cell [FILENAME] --atomic_mass=1.00784
49
- ```
50
- 则输出单位为 $g/cm^3$ 的密度分布. 可以指定表面原子来将密度分布归一化到表面, 如:
51
- ```bash
52
- mdkits md density [FILENAME] --group="name O" --cell 10,10,10 --atomic_mass=18.01528 --surface="name Pt and name Ru"
53
- ```
54
- 这样会将密度分布归一化到表面, 同时以O原子的位置作为水分子的位置分析处理水分子的密度分布. 对于体系中存在 $OH^-$ 离子的体系可以使用`--update_water`的选项在每一帧更新水分子的位置, 不需要额外指定元素, 如:
55
- ```bash
56
- mdkits md density [FILENAME] --update_water --cell 10,10,10 --atomic_mass=18.01528 --surface="name Pt and name Ru"
57
- ```
58
- 输出的文件名为`density_water.dat`.
59
-
60
- ### 氢键
61
- `hb`用于分析体系中的氢键, 如分析体系中的氢键在z轴上的分布:
62
- ```bash
63
- mdkits md hb [FILENAME] --cell 10,10,40 --surface "prop z < 10" --update_water
64
- ```
65
- 或分析单个水分子的氢键:
66
- ```bash
67
- mdkits md hb [FILENAME] --cell 10,10,40 --index 15
68
- ```
69
-
70
- ### 角度
71
- `angel`用于分析水分子中的二分向量和OH向量与表面法向量的夹角的丰度分布, 如分析距离表面 5 Å 的水分子的角度丰度分布:
72
- ```bash
73
- mdkits md angle [FILENAME] --cell 10,10,40 --surface "name Pt" --water_height 5
74
- ```
75
-
76
- ### 偶极分布
77
- `diople`用于分析体系中的偶极($\cos \phi \rho_{H_2 O}$)分布, 如分析体系中的 $\cos \phi \rho_{H_2 O}$ 分布:
78
- ```bash
79
- mdkits md diople [FILENAME] --cell 10,10,40 --surface "name Pt"
80
- ```
81
-
82
- ### 径向分布函数(RDF)
83
- `rdf`用于分析两个`group`之间的径向分布函数, 如分析体系中的`O`元素与`H`元素之间的径向分布函数:
84
- ```bash
85
- mdkits md rdf [FILENAME] --group "name O" "name H" --cell 10,10,40 --range 0.1 5
86
- ```
87
-
88
- ### 均方位移(MSD)
89
- `msd`用于分析体系中某些原子的均方位移, 如分析体系中`Li`原子在z轴上的均方位移:
90
- ```bash
91
- mdkits md msd [FILENAME] z "name Li"
92
- ```
93
-
94
- ### 监控
95
- `monitor`用于监控体系中原子高度, 键长和键角的变化, 如监控`index`为0的原子的高度:
96
- ```bash
97
- mdkits md monitor [FILENAME] --cell 10,10,40 --surface "name Pt" -i 0
98
- ```
99
- 会输出0距离表面的高度随每一帧的变化, 如监控0-1的键长:
100
- ```bash
101
- mdkits md monitor [FILENAME] --cell 10,10,40 --surface "name Pt" -i 0 -i 1
102
- ```
103
- 会输出0和1距离表面的高度和0-1之间的键长随每一帧的变化, 如监控1-0-2的键角:
104
- ```bash
105
- mdkits md monitor [FILENAME] --cell 10,10,40 --surface "name Pt" -i 1 -i 0 -i 2
106
- ```
107
- 会输出1, 0, 2距离表面的高度, 1-0和0-2的键长和1-0-2的键角随每一帧的变化, 注意位于角上的原子应该放在中间
108
-
109
- ### 位置归一化
110
- `wrap`用于将轨迹文件中的原子位置进行归一化处理, 如将`[FILENAME]`中的原子位置归一化到晶胞中, 并输出为`wrapped.xyz`, 默认从`cp2k`的输出文件`input_inp`中读取`ABC`和`ALPHA_BETA_GAMMA`信息作为晶胞参数:
111
- ```bash
112
- mdkits md wrap [FILENAME]
113
- ```
114
- 或指定`cp2k`的输入文件:
115
- ```bash
116
- mdkits md wrap [FILENAME] --cp2k_input_file setting.inp
117
- ```
118
- 或指定晶胞参数:
119
- ```bash
120
- mdkits md wrap [FILENAME] --cell 10,10,10
121
- ```
122
- 默认的`[FILENAME]`为`*-pos-1.xyz`
123
-
124
- ### 振动态密度(VDOS)
125
- `vac`用于分析轨迹的速度自相关函数, 同时计算速度自相关函数的傅里叶变换, 即振动动态密度(VDOS), 如分析体系中的VDOS:
126
- ```bash
127
- mdkits md vac h2o-vel-1.xyz
128
- ```
129
- 默认的`[FILENAME]`为`*-vel-1.xyz`
130
-
131
- ## DFT 性质分析脚本
132
- `dft`为DFT性质分析工具, 其中包含多个分析工具
133
- ### PDOS
134
- `pdos`用于分析体系中的pdos, 分析[FILENAME]的d轨道的dos:
135
- ```bash
136
- mdkits dft pdos [FILENAME] -t d
137
- ```
138
-
139
- ### CUBE 文件
140
- `cube`用于处理[`cube`格式](https://paulbourke.net/dataformats/cube/)的文件, 将其在z轴上进行平均:
141
- ```bash
142
- mdkits dft cube [FILENAME]
143
- ```
144
- 分析好的数据会输出为`cube.out`, 可以同时计算一个区域内的平均值:
145
- ```bash
146
- mdkits dft cube [FILENAME] -b 1 2
147
- ```
148
- 会将平均值打印在屏幕上, 同时记录在`cube.out`中的注释行.
149
-
150
- ## 建模
151
- `build`为建模的工具, 其中包含多个建模工具
152
-
153
- ### 构建体相模型
154
- `bulk`用于构建体相模型, 如构建`Pt`的`fcc`体相模型:
155
- ```bash
156
- mdkits build bulk Pt fcc
157
- ```
158
- 构建为常胞模型:
159
- ```bash
160
- mdkits build bulk Pt fcc --cubic
161
- ```
162
- 构建一个`Caesium chloride`结构的模型:
163
- ```bash
164
- mdkits build bulk CsCl cesiumchloride -a 4.123
165
- ```
166
- 构建一个`fluorite `结构的模型:
167
- ```bash
168
- mdkits build bulk BaF2 fluorite -a 6.196
169
- ```
170
-
171
- ### 构建表面模型
172
- `surface`用于构建常见的表面模型, 骑用法为:
173
- ```bash
174
- mdkits build surface [ELEMENT] [SURFACE_TYPE] [SIZE]
175
- ```
176
- 如构建`Pt`的`fcc111`表面模型:
177
- ```bash
178
- mdkits build surface Pt fcc111 2 2 3 --vacuum 15
179
- ```
180
- 构建石墨烯表面:
181
- ```bash
182
- mdkits build surface C2 graphene 3 3 1 --vacuum 15
183
- ```
184
-
185
- ### 从现有结构中构建表面模型
186
- `cut`用于从现有的结构中构建表面模型(模型必须为常胞模型), 如从`Pt_fcc.cif`中构建`fcc331`表面模型:
187
- ```bash
188
- mdkits build cut Pt_fcc.cif --face 3 3 1 --size 3 3 5 --vacuum 15
189
- ```
190
-
191
- ### 在表面结构上添加吸附物
192
- `adsorbate`用于在表面结构上添加吸附物, 如在`surface.cif`上添加`H`原子:
193
- ```bash
194
- mdkits build adsorbate surface.cif H --select "index 0" --height 1
195
- ```
196
- 或在`Pt_fcc111_335.cif`上添加覆盖度为5的`H`原子:
197
- ```bash
198
- mdkits build adsorbate Pt_fcc111_335.cif H --select "prop z > 16" --height 2 --cover 5
199
- ```
200
-
201
- ### 构建溶液相模型
202
- `solution`用于构建溶液相模型, 初次使用时应先安装`juliaup`:
203
- ```bash
204
- mdkits build solution --install_julia
205
- ```
206
- 然后安装`Packmol`:
207
- ```bash
208
- mdkits build solution --install_packmol
209
- ```
210
- 成功安装后就可以使用`solution`功能了, 如构建一个32个水分子的水盒子:
211
- ```bash
212
- mdkits build solution --water_number 32 --cell 9.86,9.86,9.86
213
- ```
214
- 或构建一个含有离子的溶液:
215
- ```bash
216
- mdkits build solution li.xyz k.xyz --water_number 64 --tolerance 2.5 -n 25 -n 45 --cell 15,15,15
217
- ```
218
- 其中`-n`的个数必须与指定的溶剂分子种类数量一致, 用于分别指定添加的溶剂的数量. 或者从`packmol`的输入文件中构建溶液相模型:
219
- ```bash
220
- mdkits build solution input.pm input2.pm --infile
221
- ```
222
-
223
- ### 构建界面模型
224
- `interface`用于构建界面模型, 如构建一个没有真空的界面模型:
225
- ```bash
226
- mdkits build interface --slab Pt_fcc100_555.cif --sol water_160.cif
227
- ```
228
- 或构建一个带有气相模型的界面:
229
- ```bash
230
- mdkits build interface --slab Pt_fcc100_555.cif --sol water_160.cif --cap ne --vacuum 20
231
- ```
232
-
233
- ### 构建超胞模型
234
- `supercell`用于构建超胞模型:
235
- ```bash
236
- mdkits build supercell Li3PO4.cif 2 2 2
237
- ```
238
-
239
- ## 其他
240
- ### 轨迹提取
241
- `extract`用于提取轨迹文件中的特定的帧, 如从`frames.xyz`中提取第 1000 帧到第 2000 帧的轨迹文件, 并输出为`1000-2000.xyz`, `-r`选项的参数与`Python`的切片语法一致:
242
- ```bash
243
- mdkits extract frames.xyz -r 1000:2000 -o 1000-2000.xyz
244
- ```
245
- 或从`cp2k`的默认输出的轨迹文件`*-pos-1.xyz`文件中提取最后一帧输出为`frames_-1.xyz`(`extract`的默认行为):
246
- ```bash
247
- mdkits extract
248
- ```
249
- 或每50帧输出一个结构到`./coord`目录中, 同时调整输出格式为`cp2k`的`@INCLUDE coord.xyz`的形式:
250
- ```bash
251
- mdkits extract -cr ::50
252
- ```
253
- 提取部分元素的位置, 如提取`O`元素和`H`元素的位置:
254
- ```bash
255
- mdkits extract --select "name O or name H"
256
- ```
257
-
258
- ### 结构文件转换
259
- `convert`用于将结构文件从一种格式转换为另一种格式, 如将`structure.xyz`转换为`out.cif`(默认文件名为`out`), 对于不储存周期性边界条件的文件, 可以使用`--cell`选项指定`PBC`:
260
- ```bash
261
- mdkits convert -c structure.xyz --cell 10,10,10
262
- ```
263
- 将`structure.cif`转换为`POSCAR`:
264
- ```bash
265
- mdkits convert -v structure.cif
266
- ```
267
- 将`structure.cif`转换为`structure_xyz.xyz`:
268
- ```bash
269
- mdkits convert -c structure.cif -o structure_xyz
270
- ```
271
-
272
- ### 数据处理
273
- `data`用于对数据进行处理如:
274
- 1. `--nor`: 对数据进行归一化处理
275
- 2. `--gaus`: 对数据进行高斯过滤
276
- 3. `--fold`: 堆数据进行折叠平均
277
- 4. `--err`: 计算数据的误差棒
278
-
279
-
280
- ### 绘图工具
281
- `plot`用于绘制数据图, `plot`需要读取`yaml`格式的配置文件进行绘图, `yaml`文件的形式如下:
282
- ```yaml
283
- # plot mode 1
284
- figure1:
285
- data:
286
- legend1: ./data1.dat
287
- legend2: ./data2.dat
288
- x:
289
- 0: x-axis
290
- y:
291
- 1: y-axis
292
- x_range:
293
- - 5
294
- - 15
295
-
296
- # plot mode 2
297
- figure2:
298
- data:
299
- y-xais: ./data.dat
300
- x:
301
- 0: x-axis
302
- y:
303
- 1: legend1
304
- 2: legend2
305
- 3: legend3
306
- 4: legend4
307
- 5: legend5
308
- y_range:
309
- - 0.5
310
- - 6
311
- legend_fontsize: 12
312
-
313
- # plot mode error
314
- 12_dp_e_error:
315
- data:
316
- legend: ./error.dat
317
- x:
318
- 0: x-axis
319
- y:
320
- 1: y-axis
321
- fold: dp
322
- legend_fontsize: 12
323
- ```
324
- 如上`plot`支持三种绘图模式, `mode 1`, `mode 2`和`mode error`. `mode 1`用于绘制多组数据文件的同一列数据对比, `mode 2`用于绘制同一数据文件的不同列数据对比, `mode error`用于绘制均方根误差图.
325
-
326
- `plot`可以同时处理多个`yaml`文件, 每个`yaml`文件可以包含多个绘图配置, `mode 1`和`mode 2`的绘图配置可以自动识别, 但是`error`模式需要而外指定, 如:
327
- ```bash
328
- mdkits plot *.yaml
329
- ```
330
- 和:
331
- ```bash
332
- mdkits plot *.yaml --error
333
- ```
File without changes