mdkits 0.1.6__tar.gz → 0.1.8__tar.gz
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-0.1.6 → mdkits-0.1.8}/PKG-INFO +2 -1
- {mdkits-0.1.6 → mdkits-0.1.8}/pyproject.toml +2 -1
- mdkits-0.1.8/src/mdkits/build_cli/adsorbate.py +52 -0
- mdkits-0.1.8/src/mdkits/build_cli/build_cli.py +28 -0
- mdkits-0.1.8/src/mdkits/build_cli/build_solution.py +84 -0
- {mdkits-0.1.6/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_surface.py +4 -3
- mdkits-0.1.8/src/mdkits/build_cli/water.xyz +5 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/convert.py +7 -6
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/mdkits.py +1 -1
- mdkits-0.1.8/src/mdkits/util/__init__.py +0 -0
- mdkits-0.1.8/src/mdkits/util/arg_type.py +82 -0
- mdkits-0.1.8/src/mdkits/util/cp2k_input_parsing.py +47 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/util/encapsulated_ase.py +12 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/util/os_operation.py +5 -0
- mdkits-0.1.8/src/mdkits/util/out_err.py +17 -0
- mdkits-0.1.6/src/mdkits/cli/adsorbate.py +0 -93
- mdkits-0.1.6/src/mdkits/cli/build_cli.py +0 -19
- mdkits-0.1.6/src/mdkits/util/arg_type.py +0 -52
- mdkits-0.1.6/src/mdkits/util/cp2k_input_parsing.py +0 -46
- {mdkits-0.1.6 → mdkits-0.1.8}/LICENSE +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/README.md +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/__init__.py +0 -0
- {mdkits-0.1.6/src/mdkits/util → mdkits-0.1.8/src/mdkits/build_cli}/__init__.py +0 -0
- {mdkits-0.1.6/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_bulk.py +0 -0
- {mdkits-0.1.6/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_interface.py +0 -0
- {mdkits-0.1.6/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/cut_surface.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/,hb_distribution_down.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/cube.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/data.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/density.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/extract.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/hartree_potential.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/hartree_potential_ave.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/hb.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/hb_distribution.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/packmol_input.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/pdos.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/plot.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/supercell.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/cli/wrap.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/config/__init__.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/config/settings.yml +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/util/encapsulated_mda.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/util/fig_operation.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/util/numpy_geo.py +0 -0
- {mdkits-0.1.6 → mdkits-0.1.8}/src/mdkits/util/structure_parsing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mdkits
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: kits for md or dft
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: molecular dynamics,density functional theory
|
|
@@ -18,6 +18,7 @@ Requires-Dist: MDAnalysis (>=2.8.0,<3.0.0)
|
|
|
18
18
|
Requires-Dist: ase (>=3.22.1,<4.0.0)
|
|
19
19
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
20
20
|
Requires-Dist: dynaconf (>=3.1.12,<4.0.0)
|
|
21
|
+
Requires-Dist: julia (>=0.6.2,<0.7.0)
|
|
21
22
|
Requires-Dist: matplotlib (>=3.9.0,<4.0.0)
|
|
22
23
|
Requires-Dist: numpy (>=1.26.4,<2.0.0)
|
|
23
24
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "mdkits"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "kits for md or dft"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = ["jxxcr <jixxcr@qq.com>"]
|
|
@@ -22,6 +22,7 @@ matplotlib = "^3.9.0"
|
|
|
22
22
|
pyyaml = "^6.0.1"
|
|
23
23
|
Cp2kData = "^0.7.2"
|
|
24
24
|
numpy = "^1.26.4"
|
|
25
|
+
julia = "^0.6.2"
|
|
25
26
|
|
|
26
27
|
[tool.poetry.group.dev.dependencies]
|
|
27
28
|
pylint = "^2.17.4"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from ase import build
|
|
4
|
+
import os
|
|
5
|
+
import click
|
|
6
|
+
import numpy as np
|
|
7
|
+
import MDAnalysis
|
|
8
|
+
from mdkits.util import arg_type, encapsulated_ase, out_err
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.command(name='adsorbate')
|
|
12
|
+
@click.argument('atoms', type=arg_type.Structure)
|
|
13
|
+
@click.argument('adsorbate', type=arg_type.Molecule)
|
|
14
|
+
@click.option('--cell', type=arg_type.Cell, help='set cell, a list of lattice: --cell x,y,z or x,y,z,a,b,c')
|
|
15
|
+
@click.option('--select', type=str, help="select adsorbate position")
|
|
16
|
+
@click.option('--height', type=float, help='height above the surface')
|
|
17
|
+
@click.option('--rotate', type=click.Tuple([float, float, float]), help='rotate adsorbate molcule around x, y, z axis', default=(0, 0, 0), show_default=True)
|
|
18
|
+
@click.option('--offset', type=click.Tuple([float, float]), help='adjust site', default=(0, 0), show_default=True)
|
|
19
|
+
@click.option("--cover", type=int, help='cover the surface with adsorbate randomly')
|
|
20
|
+
def main(atoms, adsorbate, cell, select, height, rotate, offset, cover):
|
|
21
|
+
if height is None:
|
|
22
|
+
raise ValueError("height is required")
|
|
23
|
+
|
|
24
|
+
out_err.check_cell(atoms, cell)
|
|
25
|
+
offset = np.array(offset)
|
|
26
|
+
u = encapsulated_ase.atoms_to_u(atoms)
|
|
27
|
+
|
|
28
|
+
molecule = build.molecule(adsorbate)
|
|
29
|
+
molecule.rotate(rotate[0], 'x')
|
|
30
|
+
molecule.rotate(rotate[1], 'y')
|
|
31
|
+
molecule.rotate(rotate[2], 'z')
|
|
32
|
+
|
|
33
|
+
output_filename = f"{atoms.filename.split('.')[0]}_{adsorbate}.cif"
|
|
34
|
+
|
|
35
|
+
s = u.select_atoms(select)
|
|
36
|
+
positions = s.positions[:, 0:2] + offset
|
|
37
|
+
if cover:
|
|
38
|
+
for index in np.random.choice(positions.shape[0], cover, replace=False):
|
|
39
|
+
build.add_adsorbate(atoms, molecule, height, position=positions[index])
|
|
40
|
+
else:
|
|
41
|
+
for position in positions:
|
|
42
|
+
build.add_adsorbate(atoms, molecule, height, position=position)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
atoms.write(output_filename, format='cif')
|
|
46
|
+
|
|
47
|
+
print(os.path.abspath(output_filename))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
main()
|
|
52
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import click
|
|
2
|
+
#from mdkits.cli.build import (
|
|
3
|
+
# build_bulk,
|
|
4
|
+
# build_surface,
|
|
5
|
+
# adsorbate,
|
|
6
|
+
#)
|
|
7
|
+
from mdkits.build_cli import (
|
|
8
|
+
build_bulk,
|
|
9
|
+
build_surface,
|
|
10
|
+
adsorbate,
|
|
11
|
+
build_solution,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@click.group(name='build')
|
|
16
|
+
@click.pass_context
|
|
17
|
+
def cli_build(ctx):
|
|
18
|
+
"""kits for building"""
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
cli_build.add_command(build_bulk.main)
|
|
23
|
+
cli_build.add_command(build_surface.main)
|
|
24
|
+
cli_build.add_command(adsorbate.main)
|
|
25
|
+
cli_build.add_command(build_solution.main)
|
|
26
|
+
|
|
27
|
+
if __name__ == '__main__':
|
|
28
|
+
cli_build()
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import click, os
|
|
2
|
+
from julia import Pkg, Main
|
|
3
|
+
from mdkits.util import arg_type
|
|
4
|
+
from importlib import resources
|
|
5
|
+
import tempfile
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.command(name="solution")
|
|
9
|
+
@click.argument("filename", type=click.Path(exists=True), nargs=-1)
|
|
10
|
+
@click.option('--infile', is_flag=True, help="read input mode")
|
|
11
|
+
@click.option('--install', is_flag=True, help="install julia and packmol")
|
|
12
|
+
@click.option('--water_number', type=int, help="number of water molecules", default=0, show_default=True)
|
|
13
|
+
@click.option('-n', type=int, multiple=True, help="number of molecules")
|
|
14
|
+
@click.option('--tolerance', type=float, help="tolerance of solution", default=3.5, show_default=True)
|
|
15
|
+
@click.option('--cell', type=arg_type.Cell, help="set cell, a list of lattice: --cell x,y,z or x,y,z,a,b,c")
|
|
16
|
+
@click.option('--gap', type=float, help="gap between solution and cell", default=1, show_default=True)
|
|
17
|
+
def main(filename, infile, install, water_number, n, tolerance, cell, gap):
|
|
18
|
+
"""
|
|
19
|
+
build solution model
|
|
20
|
+
"""
|
|
21
|
+
if install:
|
|
22
|
+
import julia
|
|
23
|
+
julia.install()
|
|
24
|
+
Pkg.activate("Packmol", shared=True)
|
|
25
|
+
Pkg.add("Packmol")
|
|
26
|
+
Main.exit()
|
|
27
|
+
|
|
28
|
+
if cell is None:
|
|
29
|
+
raise ValueError("cell should be provided")
|
|
30
|
+
|
|
31
|
+
if len(filename) == 0 and water_number == 0:
|
|
32
|
+
raise ValueError("at least one file should be provided, or water_number should be greater than 0")
|
|
33
|
+
|
|
34
|
+
while True:
|
|
35
|
+
try:
|
|
36
|
+
Main.using("Packmol")
|
|
37
|
+
break
|
|
38
|
+
except Exception:
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
if infile:
|
|
42
|
+
for file in filename:
|
|
43
|
+
Main.run_packmol(file)
|
|
44
|
+
else:
|
|
45
|
+
if len(n) != len(filename):
|
|
46
|
+
raise ValueError("number of -n should be equal to number of files")
|
|
47
|
+
|
|
48
|
+
temp_file = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
|
|
49
|
+
backslash = "\\"
|
|
50
|
+
|
|
51
|
+
structure_input = {}
|
|
52
|
+
output_filenames = []
|
|
53
|
+
if len(filename) > 0:
|
|
54
|
+
for index, file in enumerate(filename):
|
|
55
|
+
structure_input[file] = f"structure {os.path.join(os.getcwd(), file.replace(backslash, '/').replace('./', ''))}\n number {n[index]}\n inside box {gap} {gap} {gap} {cell[0]-gap} {cell[1]-gap} {cell[2]-gap}\nend structure\n"
|
|
56
|
+
|
|
57
|
+
output_filenames.append(f"{file.replace(backslash, '/').split('.')[-2].split('/')[-1]}_{n[index]}")
|
|
58
|
+
|
|
59
|
+
if water_number > 0:
|
|
60
|
+
water_path = resources.files('mdkits.build_cli').joinpath('water.xyz')
|
|
61
|
+
|
|
62
|
+
structure_input["water"] = f"structure {water_path}\n number {water_number}\n inside box {gap} {gap} {gap} {cell[0]-gap} {cell[1]-gap} {cell[2]-gap}\nend structure\n"
|
|
63
|
+
|
|
64
|
+
output_filenames.append(f"{str(water_path).replace(backslash, '/').split('.')[-2].split('/')[-1]}_{water_number}")
|
|
65
|
+
|
|
66
|
+
output_filename = "-".join(output_filenames) + ".xyz"
|
|
67
|
+
head_input = f"tolerance {tolerance}\nfiletype xyz\noutput {os.path.join(os.getcwd(), output_filename)}\npbc {cell[0]} {cell[1]} {cell[2]}\n"
|
|
68
|
+
|
|
69
|
+
total_input = head_input + "\n".join(structure_input.values())
|
|
70
|
+
|
|
71
|
+
temp_file.write(total_input)
|
|
72
|
+
temp_file.flush()
|
|
73
|
+
temp_file.close()
|
|
74
|
+
|
|
75
|
+
Main.run_packmol(temp_file.name)
|
|
76
|
+
|
|
77
|
+
if os.path.exists(temp_file.name):
|
|
78
|
+
os.remove(temp_file.name)
|
|
79
|
+
|
|
80
|
+
Main.exit()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
|
-
import click
|
|
3
|
+
import click, os
|
|
4
4
|
from ase import build
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ def surface_check(obj, surface_type):
|
|
|
20
20
|
@click.option('--thickness', type=float, help='Thickness of the layer, for mx2 and graphene')
|
|
21
21
|
@click.option('--orth', is_flag=True, help='if specified and true, forces the creation of a unit cell with orthogonal basis vectors. if the default is such a unit cell, this argument is not supported')
|
|
22
22
|
@click.option('--vacuum', type=float, help='designate vacuum of surface, default is None', default=0.0)
|
|
23
|
-
def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum
|
|
23
|
+
def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum):
|
|
24
24
|
#if args.primitive:
|
|
25
25
|
# a = args.a * 0.7071 * 2
|
|
26
26
|
#else:
|
|
@@ -28,7 +28,7 @@ def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum, adsorbate):
|
|
|
28
28
|
|
|
29
29
|
vacuum = vacuum / 2
|
|
30
30
|
build_surface = surface_check(build, surface)
|
|
31
|
-
out_filename = f"{symbol}_{surface}_{size[0]}{size[1]}{size[2]}
|
|
31
|
+
out_filename = f"{symbol}_{surface}_{size[0]}{size[1]}{size[2]}.cif"
|
|
32
32
|
|
|
33
33
|
if surface in ['hcp0001', 'hcp10m10']:
|
|
34
34
|
atoms = build_surface(symbol, size, a=a, c=c, vacuum=vacuum, orthogonal=orth)
|
|
@@ -49,6 +49,7 @@ def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum, adsorbate):
|
|
|
49
49
|
atoms = build_surface(symbol, size, a=a, vacuum=vacuum, orthogonal=orth)
|
|
50
50
|
|
|
51
51
|
atoms.write(out_filename)
|
|
52
|
+
print(os.path.abspath(out_filename))
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
if __name__ == '__main__':
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
from ase.io import write
|
|
4
4
|
import click
|
|
5
5
|
import os
|
|
6
|
-
from mdkits.util import
|
|
6
|
+
from mdkits.util import out_err, arg_type
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@click.command(name='convert')
|
|
10
|
+
@click.argument('atoms', type=arg_type.Structure)
|
|
10
11
|
@click.option('-c', help='covert to cif', is_flag=True)
|
|
11
12
|
@click.option('-x', help='covert to xyz', is_flag=True)
|
|
12
13
|
@click.option('-d', help='covert to lammps data file', is_flag=True)
|
|
@@ -14,14 +15,14 @@ from mdkits.util import encapsulated_ase, arg_type
|
|
|
14
15
|
@click.option('--coord', help='coord format', is_flag=True)
|
|
15
16
|
@click.option('--cp2k', help='convert to cp2k format(coord + cell)', is_flag=True)
|
|
16
17
|
@click.option('--center', help='center atoms', is_flag=True)
|
|
17
|
-
@click.option('--cell', type=arg_type.Cell, help='set cell
|
|
18
|
-
|
|
19
|
-
@click.argument('file_name', type=click.Path(exists=True))
|
|
20
|
-
def main(c, x, d, v, coord, cp2k, center, cell, o, file_name):
|
|
18
|
+
@click.option('--cell', type=arg_type.Cell, help='set cell, a list of lattice: --cell x,y,z or x,y,z,a,b,c')
|
|
19
|
+
def main(atoms, c, x, d, v, coord, cp2k, center, cell):
|
|
21
20
|
"""
|
|
22
21
|
convet structure file in some formats
|
|
23
22
|
"""
|
|
24
|
-
|
|
23
|
+
out_err.check_cell(atoms, cell)
|
|
24
|
+
o = atoms.filename.split('.')[-2]
|
|
25
|
+
|
|
25
26
|
|
|
26
27
|
if center:
|
|
27
28
|
atoms.center()
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import click, os
|
|
2
|
+
from ase.io import read
|
|
3
|
+
import numpy as np
|
|
4
|
+
from ase.collections import g2
|
|
5
|
+
from mdkits.util import os_operation, cp2k_input_parsing, out_err
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CellType(click.ParamType):
|
|
9
|
+
name = "pbc cell type"
|
|
10
|
+
|
|
11
|
+
def convert(self, value, param, ctx):
|
|
12
|
+
if isinstance(value, str):
|
|
13
|
+
cell = [float(x) for x in value.split(',')]
|
|
14
|
+
|
|
15
|
+
if len(cell) == 3:
|
|
16
|
+
cell += [90, 90, 90]
|
|
17
|
+
out_err.cell_output(cell)
|
|
18
|
+
return cell
|
|
19
|
+
elif len(cell) == 6:
|
|
20
|
+
out_err.cell_output(cell)
|
|
21
|
+
return cell
|
|
22
|
+
else:
|
|
23
|
+
self.fail(f"{value} is not a valid cell parameter", param, ctx)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class FrameRangeType(click.ParamType):
|
|
27
|
+
name = "frame range"
|
|
28
|
+
def convert(self, value, param, ctx):
|
|
29
|
+
if isinstance(value, str):
|
|
30
|
+
parts = value.split(':')
|
|
31
|
+
|
|
32
|
+
range_list = [int(x) if x else None for x in parts]
|
|
33
|
+
|
|
34
|
+
if len(range_list) > 0 and len(range_list) <= 3:
|
|
35
|
+
return range_list
|
|
36
|
+
else:
|
|
37
|
+
self.fail(f"{value} is not a valid frame range", param, ctx)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class StructureType(click.ParamType):
|
|
41
|
+
name = "structure file type"
|
|
42
|
+
def convert(self, value, param, ctx):
|
|
43
|
+
no_cell=np.array([0., 0., 0., 90., 90., 90.])
|
|
44
|
+
if isinstance(value, str):
|
|
45
|
+
if os.path.exists(value):
|
|
46
|
+
try:
|
|
47
|
+
atoms = read(value)
|
|
48
|
+
except:
|
|
49
|
+
self.fail(f"{value} is not a valid structure file", param, ctx)
|
|
50
|
+
|
|
51
|
+
if np.array_equal(atoms.cell.cellpar(), no_cell):
|
|
52
|
+
cell = cp2k_input_parsing.parse_cell()
|
|
53
|
+
atoms.set_cell(cell)
|
|
54
|
+
|
|
55
|
+
atoms.filename = value.replace('./', '').replace('.\\', '')
|
|
56
|
+
return atoms
|
|
57
|
+
else:
|
|
58
|
+
self.fail(f"{value} is not exists", param, ctx)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class MoleculeType(click.Choice):
|
|
63
|
+
name = "mocular type"
|
|
64
|
+
def __init__(self):
|
|
65
|
+
super().__init__(self)
|
|
66
|
+
g2.names.append(click.Path(exists=True))
|
|
67
|
+
self.choices = tuple(g2.names)
|
|
68
|
+
|
|
69
|
+
class AdsSiteType(click.Choice):
|
|
70
|
+
name = "adsorption site"
|
|
71
|
+
def __init__(self):
|
|
72
|
+
super().__init__(self)
|
|
73
|
+
site = ['ontop', 'hollow','fcc', 'hcp', 'bridge', 'shortbridge', 'longbridge']
|
|
74
|
+
self.choices = tuple(site)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
Cell = CellType()
|
|
79
|
+
FrameRange = FrameRangeType()
|
|
80
|
+
Molecule = MoleculeType()
|
|
81
|
+
AdsSite = AdsSiteType()
|
|
82
|
+
Structure = StructureType()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
filename: cp2k_input_parsing.py
|
|
3
|
+
function: prase cp2k file
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
from mdkits.util import os_operation, out_err
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def parse_cell():
|
|
12
|
+
"""
|
|
13
|
+
function: parse cell information from cp2k input file
|
|
14
|
+
parameter:
|
|
15
|
+
cp2k_input_file: filename of cp2k input
|
|
16
|
+
return:
|
|
17
|
+
cell: list with 6 number
|
|
18
|
+
"""
|
|
19
|
+
for file in os_operation.default_input():
|
|
20
|
+
try:
|
|
21
|
+
with open(file, 'r') as f:
|
|
22
|
+
cell = []
|
|
23
|
+
for line in f:
|
|
24
|
+
if "ABC" in line:
|
|
25
|
+
xyz = line.split()[-3:]
|
|
26
|
+
cell.extend(xyz)
|
|
27
|
+
if "ALPHA_BETA_GAMMA" in line:
|
|
28
|
+
abc = line.split()[-3:]
|
|
29
|
+
cell.extend(abc)
|
|
30
|
+
if len(cell) == 3:
|
|
31
|
+
cell.extend([90.0, 90.0, 90.0])
|
|
32
|
+
|
|
33
|
+
out_err.cell_output(cell)
|
|
34
|
+
return cell
|
|
35
|
+
except FileNotFoundError:
|
|
36
|
+
return [0., 0., 0., 90., 90., 90.]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
#def get_cell(cp2k_input_file, cell=None):
|
|
40
|
+
# if cell is None:
|
|
41
|
+
# cell = parse_cell(cp2k_input_file)
|
|
42
|
+
# else:
|
|
43
|
+
# cell = cell
|
|
44
|
+
# if len(cell) == 3:
|
|
45
|
+
# cell.extend([90.0, 90.0, 90.0])
|
|
46
|
+
#
|
|
47
|
+
# return cell
|
|
@@ -8,6 +8,7 @@ from ase.io import iread, read
|
|
|
8
8
|
import io
|
|
9
9
|
import numpy as np
|
|
10
10
|
from ase.io.cube import read_cube_data
|
|
11
|
+
import MDAnalysis
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def wrap_to_cell(chunk, cell, name, big=False):
|
|
@@ -132,3 +133,14 @@ def jread(filepath):
|
|
|
132
133
|
atom = read(filepath)
|
|
133
134
|
|
|
134
135
|
return atom
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def atoms_to_u(atoms):
|
|
139
|
+
virtual_file = io.StringIO()
|
|
140
|
+
cell = atoms.cell.cellpar()
|
|
141
|
+
atoms.write(virtual_file, format='xyz')
|
|
142
|
+
|
|
143
|
+
u = MDAnalysis.Universe(virtual_file, format='xyz')
|
|
144
|
+
u.dimensions = cell
|
|
145
|
+
|
|
146
|
+
return u
|
|
@@ -33,3 +33,8 @@ def sort_word_and_number(unsort_list):
|
|
|
33
33
|
sorted_list = sorted(unsort_list, key=fns)
|
|
34
34
|
|
|
35
35
|
return sorted_list
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def default_input():
|
|
39
|
+
default_input_name = os.environ.get("DEFAULT_INPUT", "input.inp,setup.inp,cell.inc").split(',')
|
|
40
|
+
return default_input_name
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""
|
|
2
|
+
output and error for cli
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def cell_output(cell: list):
|
|
10
|
+
print(f"system cell: x = {cell[0]}, y = {cell[1]}, z = {cell[2]}, a = {cell[3]}\u00B0, b = {cell[4]}\u00B0, c = {cell[5]}\u00B0")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def check_cell(atoms, cell):
|
|
14
|
+
if np.array_equal(atoms.cell.cellpar(), np.array([0., 0., 0., 90., 90., 90.])) and cell is not None:
|
|
15
|
+
atoms.set_cell(cell)
|
|
16
|
+
else:
|
|
17
|
+
raise ValueError("can't parse cell please use --cell set cell")
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
from ase import io, build
|
|
4
|
-
from ase.collections import g2
|
|
5
|
-
import argparse, os
|
|
6
|
-
import numpy as np
|
|
7
|
-
from util import encapsulated_ase
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def parse_size(s):
|
|
11
|
-
if s == None:
|
|
12
|
-
return None
|
|
13
|
-
return [float(x) for x in s.replace(',', ' ').split()]
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def parse_index(s):
|
|
17
|
-
return [int(x)-1 for x in s.replace(',', ' ').split()]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def parse_argument():
|
|
21
|
-
parser = argparse.ArgumentParser(description='add some adsorbate')
|
|
22
|
-
parser.add_argument('filename', type=str, help='init structure filename')
|
|
23
|
-
parser.add_argument('-m', type=str, help='atom or molecule to add')
|
|
24
|
-
parser.add_argument('--index', type=parse_index, help='index(list) of atom to add atom(top site)')
|
|
25
|
-
parser.add_argument('--offset', type=parse_size, help='adjust site, default is 0,0', default='0,0')
|
|
26
|
-
parser.add_argument('--height', type=float, help='designate vacuum of surface, default is None', default=0.0)
|
|
27
|
-
parser.add_argument('-x', type=float, help='rotate axis and angle')
|
|
28
|
-
parser.add_argument('-y', type=float, help='rotate axis and angle')
|
|
29
|
-
parser.add_argument('-z', type=float, help='rotate axis and angle')
|
|
30
|
-
parser.add_argument('-o', type=str, help='specify the output file name without suffix, default is "adsorbated.cif"', default='adsorbated.cif')
|
|
31
|
-
parser.add_argument('--coord', help='coord format', action='store_true')
|
|
32
|
-
parser.add_argument('--cell', type=parse_size, help='set xyz file cell, --cell x,y,z,a,b,c')
|
|
33
|
-
parser.add_argument('--cp2k', help='output cp2k format', action='store_true')
|
|
34
|
-
|
|
35
|
-
return parser.parse_args()
|
|
36
|
-
|
|
37
|
-
@click.option('--adsorbate', type=arg_type.Molecule, help='add adsorbate on surface')
|
|
38
|
-
@click.option('--site', type=click.Choice(['ontop', 'hollow','fcc', 'hcp', 'bridge', 'shortbridge', 'longbridge']))
|
|
39
|
-
@click.option('--height', type=float, help='height above the surface')
|
|
40
|
-
@click.option('--rotate', type=click.Tuple([float, float, float]), help='rotate adsorbate molcule around x, y, z axis', default=(0, 0, 0))
|
|
41
|
-
def main():
|
|
42
|
-
args = parse_argument()
|
|
43
|
-
atoms = encapsulated_ase.atoms_read_with_cell(args.filename, cell=args.cell, coord_mode=args.coord)
|
|
44
|
-
|
|
45
|
-
if len(args.offset) < 2:
|
|
46
|
-
args.offset.append(0)
|
|
47
|
-
offset = np.array(args.offset)
|
|
48
|
-
|
|
49
|
-
position_list = []
|
|
50
|
-
for atom in atoms:
|
|
51
|
-
if atom.index in args.index:
|
|
52
|
-
position_list.append(np.copy(atom.position[0:2])+offset)
|
|
53
|
-
|
|
54
|
-
molecule = build.molecule(adsorbate)
|
|
55
|
-
molecule.rotate(rotate[0], 'x')
|
|
56
|
-
molecule.rotate(rotate[1], 'y')
|
|
57
|
-
molecule.rotate(rotate[2], 'z')
|
|
58
|
-
build.add_adsorbate(atoms, molecule, position=site, height=height)
|
|
59
|
-
if args.m in g2.names:
|
|
60
|
-
molecule = build.molecule(args.m)
|
|
61
|
-
if args.x:
|
|
62
|
-
molecule.rotate(args.x, 'x')
|
|
63
|
-
if args.y:
|
|
64
|
-
molecule.rotate(args.y, 'y')
|
|
65
|
-
if args.z:
|
|
66
|
-
molecule.rotate(args.z, 'z')
|
|
67
|
-
for position in position_list:
|
|
68
|
-
build.add_adsorbate(atoms, molecule, args.height, position=position)
|
|
69
|
-
else:
|
|
70
|
-
for position in position_list:
|
|
71
|
-
build.add_adsorbate(atoms, args.m, args.height, position=position)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if args.cp2k:
|
|
75
|
-
args.o = 'coord.xyz'
|
|
76
|
-
atoms.write(args.o, format='xyz')
|
|
77
|
-
with open(args.o, 'r') as f:
|
|
78
|
-
lines = f.readlines()
|
|
79
|
-
with open(args.o, 'w') as f:
|
|
80
|
-
f.writelines(lines[2:])
|
|
81
|
-
with open('cell.inc', 'w') as f:
|
|
82
|
-
cell = atoms.get_cell().cellpar()
|
|
83
|
-
f.write('ABC [angstrom] ' + str(cell[0]) + ' ' + str(cell[1]) + ' ' + str(cell[2]) + ' ' + '\n')
|
|
84
|
-
f.write('ALPHA_BETA_GAMMA ' + str(cell[3]) + ' ' + str(cell[4]) + ' ' + str(cell[5]) + '\n')
|
|
85
|
-
else:
|
|
86
|
-
atoms.write(args.o, format='cif')
|
|
87
|
-
|
|
88
|
-
print(os.path.abspath(args.o))
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if __name__ == '__main__':
|
|
92
|
-
main()
|
|
93
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
from mdkits.cli import (
|
|
3
|
-
build_bulk,
|
|
4
|
-
build_surface,
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@click.group(name='build')
|
|
9
|
-
@click.pass_context
|
|
10
|
-
def cli_build(ctx):
|
|
11
|
-
"""kits for building"""
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
cli_build.add_command(build_bulk.main)
|
|
16
|
-
cli_build.add_command(build_surface.main)
|
|
17
|
-
|
|
18
|
-
if __name__ == '__main__':
|
|
19
|
-
cli_build()
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import click, os
|
|
2
|
-
from . import cp2k_input_parsing
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class CellType(click.ParamType):
|
|
6
|
-
name = "pbc cell type"
|
|
7
|
-
|
|
8
|
-
def convert(self, value, param, ctx):
|
|
9
|
-
if isinstance(value, str):
|
|
10
|
-
if ',' not in value:
|
|
11
|
-
cell = cp2k_input_parsing.parse_cell(value)
|
|
12
|
-
return cell
|
|
13
|
-
else:
|
|
14
|
-
cell = [float(x) for x in value.split(',')]
|
|
15
|
-
|
|
16
|
-
if len(cell) == 3:
|
|
17
|
-
click.echo(f"system cell: x = {cell[0]}, y = {cell[1]}, z = {cell[2]}, a = {90}\u00B0, b = {90}\u00B0, c = {90}\u00B0")
|
|
18
|
-
return cell + [90, 90, 90]
|
|
19
|
-
elif len(cell) == 6:
|
|
20
|
-
click.echo(f"system cell: x = {cell[0]}, y = {cell[1]}, z = {cell[2]}, a = {cell[3]}\u00B0, b = {cell[4]}\u00B0, c = {cell[5]}\u00B0")
|
|
21
|
-
return cell
|
|
22
|
-
else:
|
|
23
|
-
self.fail(f"{value} is not a valid cell parameter", param, ctx)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class FrameRangeType(click.ParamType):
|
|
27
|
-
name = "frame range"
|
|
28
|
-
def convert(self, value, param, ctx):
|
|
29
|
-
if isinstance(value, str):
|
|
30
|
-
parts = value.split(':')
|
|
31
|
-
|
|
32
|
-
range_list = [int(x) if x else None for x in parts]
|
|
33
|
-
|
|
34
|
-
if len(range_list) > 0 and len(range_list) <= 3:
|
|
35
|
-
return range_list
|
|
36
|
-
else:
|
|
37
|
-
self.fail(f"{value} is not a valid frame range", param, ctx)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
from ase.collections import g2
|
|
41
|
-
class MoleculeType(click.Choice):
|
|
42
|
-
name = "mocular type"
|
|
43
|
-
def __init__(self):
|
|
44
|
-
super().__init__(self)
|
|
45
|
-
g2.names.append(click.Path(exists=True))
|
|
46
|
-
self.choices = tuple(g2.names)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Cell = CellType()
|
|
51
|
-
FrameRange = FrameRangeType()
|
|
52
|
-
Molecule = MoleculeType()
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
filename: cp2k_input_parsing.py
|
|
3
|
-
function: prase cp2k file
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import sys
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def parse_cell(cp2k_input_file):
|
|
11
|
-
"""
|
|
12
|
-
function: parse cell information from cp2k input file
|
|
13
|
-
parameter:
|
|
14
|
-
cp2k_input_file: filename of cp2k input
|
|
15
|
-
return:
|
|
16
|
-
cell: list with 6 number
|
|
17
|
-
"""
|
|
18
|
-
try:
|
|
19
|
-
with open(cp2k_input_file, 'r') as f:
|
|
20
|
-
cell = []
|
|
21
|
-
for line in f:
|
|
22
|
-
if "ABC" in line:
|
|
23
|
-
xyz = line.split()[-3:]
|
|
24
|
-
cell.extend(xyz)
|
|
25
|
-
if "ALPHA_BETA_GAMMA" in line:
|
|
26
|
-
abc = line.split()[-3:]
|
|
27
|
-
cell.extend(abc)
|
|
28
|
-
if len(cell) == 3:
|
|
29
|
-
cell.extend([90.0, 90.0, 90.0])
|
|
30
|
-
|
|
31
|
-
print(f"system cell: x = {cell[0]}, y = {cell[1]}, z = {cell[2]}, a = {cell[3]}\u00B0, b = {cell[4]}\u00B0, c = {cell[5]}\u00B0")
|
|
32
|
-
return cell
|
|
33
|
-
except FileNotFoundError:
|
|
34
|
-
print(f'cp2k input file name "{cp2k_input_file}" is not found, assign a cp2k input file or assign a "cell"')
|
|
35
|
-
sys.exit(1)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
#def get_cell(cp2k_input_file, cell=None):
|
|
39
|
-
# if cell is None:
|
|
40
|
-
# cell = parse_cell(cp2k_input_file)
|
|
41
|
-
# else:
|
|
42
|
-
# cell = cell
|
|
43
|
-
# if len(cell) == 3:
|
|
44
|
-
# cell.extend([90.0, 90.0, 90.0])
|
|
45
|
-
#
|
|
46
|
-
# return cell
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|