mdkits 0.1.5__tar.gz → 0.1.7__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.

Files changed (42) hide show
  1. {mdkits-0.1.5 → mdkits-0.1.7}/PKG-INFO +2 -1
  2. {mdkits-0.1.5 → mdkits-0.1.7}/pyproject.toml +2 -1
  3. mdkits-0.1.7/src/mdkits/cli/adsorbate.py +47 -0
  4. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/build_cli.py +2 -0
  5. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/build_surface.py +4 -3
  6. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/convert.py +3 -4
  7. mdkits-0.1.7/src/mdkits/util/arg_type.py +86 -0
  8. mdkits-0.1.7/src/mdkits/util/cp2k_input_parsing.py +47 -0
  9. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/util/encapsulated_ase.py +12 -0
  10. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/util/os_operation.py +5 -0
  11. mdkits-0.1.7/src/mdkits/util/out_err.py +8 -0
  12. mdkits-0.1.5/src/mdkits/cli/adsorbate.py +0 -93
  13. mdkits-0.1.5/src/mdkits/util/arg_type.py +0 -52
  14. mdkits-0.1.5/src/mdkits/util/cp2k_input_parsing.py +0 -46
  15. {mdkits-0.1.5 → mdkits-0.1.7}/LICENSE +0 -0
  16. {mdkits-0.1.5 → mdkits-0.1.7}/README.md +0 -0
  17. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/__init__.py +0 -0
  18. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/,hb_distribution_down.py +0 -0
  19. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/build_bulk.py +0 -0
  20. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/build_interface.py +0 -0
  21. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/cube.py +0 -0
  22. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/cut_surface.py +0 -0
  23. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/data.py +0 -0
  24. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/density.py +0 -0
  25. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/extract.py +0 -0
  26. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/hartree_potential.py +0 -0
  27. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/hartree_potential_ave.py +0 -0
  28. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/hb.py +0 -0
  29. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/hb_distribution.py +0 -0
  30. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/packmol_input.py +0 -0
  31. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/pdos.py +0 -0
  32. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/plot.py +0 -0
  33. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/supercell.py +0 -0
  34. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/cli/wrap.py +0 -0
  35. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/config/__init__.py +0 -0
  36. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/config/settings.yml +0 -0
  37. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/mdkits.py +0 -0
  38. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/util/__init__.py +0 -0
  39. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/util/encapsulated_mda.py +0 -0
  40. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/util/fig_operation.py +0 -0
  41. {mdkits-0.1.5 → mdkits-0.1.7}/src/mdkits/util/numpy_geo.py +0 -0
  42. {mdkits-0.1.5 → mdkits-0.1.7}/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.5
3
+ Version: 0.1.7
4
4
  Summary: kits for md or dft
5
5
  License: MIT
6
6
  Keywords: molecular dynamics,density functional theory
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Dist: Cp2kData (>=0.7.2,<0.8.0)
16
17
  Requires-Dist: MDAnalysis (>=2.8.0,<3.0.0)
17
18
  Requires-Dist: ase (>=3.22.1,<4.0.0)
18
19
  Requires-Dist: click (>=8.1.3,<9.0.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mdkits"
3
- version = "0.1.5"
3
+ version = "0.1.7"
4
4
  description = "kits for md or dft"
5
5
  readme = "README.md"
6
6
  authors = ["jxxcr <jixxcr@qq.com>"]
@@ -20,6 +20,7 @@ MDAnalysis = "^2.8.0"
20
20
  ase = "^3.22.1"
21
21
  matplotlib = "^3.9.0"
22
22
  pyyaml = "^6.0.1"
23
+ Cp2kData = "^0.7.2"
23
24
  numpy = "^1.26.4"
24
25
 
25
26
  [tool.poetry.group.dev.dependencies]
@@ -0,0 +1,47 @@
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
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('--select', type=str, help="select adsorbate position")
15
+ @click.option('--height', type=float, help='height above the surface')
16
+ @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)
17
+ @click.option('--offset', type=click.Tuple([float, float]), help='adjust site', default=(0, 0), show_default=True)
18
+ @click.option("--cover", type=int, help='cover the surface with adsorbate randomly')
19
+ def main(atoms, adsorbate, select, height, rotate, offset, cover):
20
+ offset = np.array(offset)
21
+ u = encapsulated_ase.atoms_to_u(atoms)
22
+
23
+ molecule = build.molecule(adsorbate)
24
+ molecule.rotate(rotate[0], 'x')
25
+ molecule.rotate(rotate[1], 'y')
26
+ molecule.rotate(rotate[2], 'z')
27
+
28
+ output_filename = f"{atoms.filename.split('.')[0]}_{adsorbate}.cif"
29
+
30
+ s = u.select_atoms(select)
31
+ positions = s.positions[:, 0:2] + offset
32
+ if cover:
33
+ for index in np.random.choice(positions.shape[0], cover, replace=False):
34
+ build.add_adsorbate(atoms, molecule, height, position=positions[index])
35
+ else:
36
+ for position in positions:
37
+ build.add_adsorbate(atoms, molecule, height, position=position)
38
+
39
+
40
+ atoms.write(output_filename, format='cif')
41
+
42
+ print(os.path.abspath(output_filename))
43
+
44
+
45
+ if __name__ == '__main__':
46
+ main()
47
+
@@ -2,6 +2,7 @@ import click
2
2
  from mdkits.cli import (
3
3
  build_bulk,
4
4
  build_surface,
5
+ adsorbate,
5
6
  )
6
7
 
7
8
 
@@ -14,6 +15,7 @@ def cli_build(ctx):
14
15
 
15
16
  cli_build.add_command(build_bulk.main)
16
17
  cli_build.add_command(build_surface.main)
18
+ cli_build.add_command(adsorbate.main)
17
19
 
18
20
  if __name__ == '__main__':
19
21
  cli_build()
@@ -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, adsorbate):
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]}_{adsorbate}.cif"
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__':
@@ -7,6 +7,7 @@ from mdkits.util import encapsulated_ase, 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,12 @@ 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 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)
18
+ @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')
18
19
  @click.option('-o', type=str, help='specify the output file name without suffix', default='out', show_default=True)
19
- @click.argument('file_name', type=click.Path(exists=True))
20
- def main(c, x, d, v, coord, cp2k, center, cell, o, file_name):
20
+ def main(atoms, c, x, d, v, coord, cp2k, center, cell, o):
21
21
  """
22
22
  convet structure file in some formats
23
23
  """
24
- atoms = encapsulated_ase.atoms_read_with_cell(file_name, cell=cell, coord_mode=coord)
25
24
 
26
25
  if center:
27
26
  atoms.center()
@@ -0,0 +1,86 @@
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
+ if ',' not in value:
14
+ cell = cp2k_input_parsing.parse_cell()
15
+ return cell
16
+ else:
17
+ cell = [float(x) for x in value.split(',')]
18
+
19
+ if len(cell) == 3:
20
+ cell += [90, 90, 90]
21
+ out_err.cell_output(cell)
22
+ return cell
23
+ elif len(cell) == 6:
24
+ out_err.cell_output(cell)
25
+ return cell
26
+ else:
27
+ self.fail(f"{value} is not a valid cell parameter", param, ctx)
28
+
29
+
30
+ class FrameRangeType(click.ParamType):
31
+ name = "frame range"
32
+ def convert(self, value, param, ctx):
33
+ if isinstance(value, str):
34
+ parts = value.split(':')
35
+
36
+ range_list = [int(x) if x else None for x in parts]
37
+
38
+ if len(range_list) > 0 and len(range_list) <= 3:
39
+ return range_list
40
+ else:
41
+ self.fail(f"{value} is not a valid frame range", param, ctx)
42
+
43
+
44
+ class StructureType(click.ParamType):
45
+ name = "structure file type"
46
+ def convert(self, value, param, ctx):
47
+ no_cell=np.array([0., 0., 0., 90., 90., 90.])
48
+ if isinstance(value, str):
49
+ if os.path.exists(value):
50
+ try:
51
+ atoms = read(value)
52
+ except:
53
+ self.fail(f"{value} is not a valid structure file", param, ctx)
54
+
55
+ if np.array_equal(atoms.cell.cellpar(), no_cell):
56
+ cell = cp2k_input_parsing.parse_cell()
57
+ atoms.set_cell(cell)
58
+
59
+ atoms.filename = value.replace('./', '').replace('.\\', '')
60
+ return atoms
61
+ else:
62
+ self.fail(f"{value} is not exists", param, ctx)
63
+
64
+
65
+
66
+ class MoleculeType(click.Choice):
67
+ name = "mocular type"
68
+ def __init__(self):
69
+ super().__init__(self)
70
+ g2.names.append(click.Path(exists=True))
71
+ self.choices = tuple(g2.names)
72
+
73
+ class AdsSiteType(click.Choice):
74
+ name = "adsorption site"
75
+ def __init__(self):
76
+ super().__init__(self)
77
+ site = ['ontop', 'hollow','fcc', 'hcp', 'bridge', 'shortbridge', 'longbridge']
78
+ self.choices = tuple(site)
79
+
80
+
81
+
82
+ Cell = CellType()
83
+ FrameRange = FrameRangeType()
84
+ Molecule = MoleculeType()
85
+ AdsSite = AdsSiteType()
86
+ 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
+ sys.exit(f"cant parse cell information from {','.join(os_operation.default_input())}, assign a cell")
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,8 @@
1
+ """
2
+ output and error for cli
3
+ """
4
+
5
+
6
+ def cell_output(cell: list):
7
+ 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")
8
+
@@ -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,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