mdkits 0.1.7__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.

Files changed (43) hide show
  1. {mdkits-0.1.7 → mdkits-0.1.8}/PKG-INFO +2 -1
  2. {mdkits-0.1.7 → mdkits-0.1.8}/pyproject.toml +2 -1
  3. {mdkits-0.1.7/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/adsorbate.py +7 -2
  4. {mdkits-0.1.7/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_cli.py +8 -1
  5. mdkits-0.1.8/src/mdkits/build_cli/build_solution.py +84 -0
  6. mdkits-0.1.8/src/mdkits/build_cli/water.xyz +5 -0
  7. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/convert.py +6 -4
  8. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/mdkits.py +1 -1
  9. mdkits-0.1.8/src/mdkits/util/__init__.py +0 -0
  10. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/arg_type.py +9 -13
  11. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/cp2k_input_parsing.py +1 -1
  12. mdkits-0.1.8/src/mdkits/util/out_err.py +17 -0
  13. mdkits-0.1.7/src/mdkits/util/out_err.py +0 -8
  14. {mdkits-0.1.7 → mdkits-0.1.8}/LICENSE +0 -0
  15. {mdkits-0.1.7 → mdkits-0.1.8}/README.md +0 -0
  16. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/__init__.py +0 -0
  17. {mdkits-0.1.7/src/mdkits/util → mdkits-0.1.8/src/mdkits/build_cli}/__init__.py +0 -0
  18. {mdkits-0.1.7/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_bulk.py +0 -0
  19. {mdkits-0.1.7/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_interface.py +0 -0
  20. {mdkits-0.1.7/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/build_surface.py +0 -0
  21. {mdkits-0.1.7/src/mdkits/cli → mdkits-0.1.8/src/mdkits/build_cli}/cut_surface.py +0 -0
  22. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/,hb_distribution_down.py +0 -0
  23. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/cube.py +0 -0
  24. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/data.py +0 -0
  25. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/density.py +0 -0
  26. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/extract.py +0 -0
  27. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/hartree_potential.py +0 -0
  28. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/hartree_potential_ave.py +0 -0
  29. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/hb.py +0 -0
  30. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/hb_distribution.py +0 -0
  31. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/packmol_input.py +0 -0
  32. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/pdos.py +0 -0
  33. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/plot.py +0 -0
  34. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/supercell.py +0 -0
  35. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/cli/wrap.py +0 -0
  36. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/config/__init__.py +0 -0
  37. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/config/settings.yml +0 -0
  38. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/encapsulated_ase.py +0 -0
  39. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/encapsulated_mda.py +0 -0
  40. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/fig_operation.py +0 -0
  41. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/numpy_geo.py +0 -0
  42. {mdkits-0.1.7 → mdkits-0.1.8}/src/mdkits/util/os_operation.py +0 -0
  43. {mdkits-0.1.7 → 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.7
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.7"
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"
@@ -5,18 +5,23 @@ import os
5
5
  import click
6
6
  import numpy as np
7
7
  import MDAnalysis
8
- from mdkits.util import arg_type, encapsulated_ase
8
+ from mdkits.util import arg_type, encapsulated_ase, out_err
9
9
 
10
10
 
11
11
  @click.command(name='adsorbate')
12
12
  @click.argument('atoms', type=arg_type.Structure)
13
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')
14
15
  @click.option('--select', type=str, help="select adsorbate position")
15
16
  @click.option('--height', type=float, help='height above the surface')
16
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)
17
18
  @click.option('--offset', type=click.Tuple([float, float]), help='adjust site', default=(0, 0), show_default=True)
18
19
  @click.option("--cover", type=int, help='cover the surface with adsorbate randomly')
19
- def main(atoms, adsorbate, select, height, rotate, offset, cover):
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)
20
25
  offset = np.array(offset)
21
26
  u = encapsulated_ase.atoms_to_u(atoms)
22
27
 
@@ -1,8 +1,14 @@
1
1
  import click
2
- from mdkits.cli import (
2
+ #from mdkits.cli.build import (
3
+ # build_bulk,
4
+ # build_surface,
5
+ # adsorbate,
6
+ #)
7
+ from mdkits.build_cli import (
3
8
  build_bulk,
4
9
  build_surface,
5
10
  adsorbate,
11
+ build_solution,
6
12
  )
7
13
 
8
14
 
@@ -16,6 +22,7 @@ def cli_build(ctx):
16
22
  cli_build.add_command(build_bulk.main)
17
23
  cli_build.add_command(build_surface.main)
18
24
  cli_build.add_command(adsorbate.main)
25
+ cli_build.add_command(build_solution.main)
19
26
 
20
27
  if __name__ == '__main__':
21
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()
@@ -0,0 +1,5 @@
1
+ 3
2
+ water
3
+ O 10.203012 7.603800 12.673000
4
+ H 9.625597 8.420323 12.673000
5
+ H 9.625597 6.787278 12.673000
@@ -3,7 +3,7 @@
3
3
  from ase.io import write
4
4
  import click
5
5
  import os
6
- from mdkits.util import encapsulated_ase, arg_type
6
+ from mdkits.util import out_err, arg_type
7
7
 
8
8
 
9
9
  @click.command(name='convert')
@@ -15,12 +15,14 @@ from mdkits.util import encapsulated_ase, arg_type
15
15
  @click.option('--coord', help='coord format', is_flag=True)
16
16
  @click.option('--cp2k', help='convert to cp2k format(coord + cell)', is_flag=True)
17
17
  @click.option('--center', help='center atoms', is_flag=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')
19
- @click.option('-o', type=str, help='specify the output file name without suffix', default='out', show_default=True)
20
- def main(atoms, c, x, d, v, coord, cp2k, center, cell, o):
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
  """
23
+ out_err.check_cell(atoms, cell)
24
+ o = atoms.filename.split('.')[-2]
25
+
24
26
 
25
27
  if center:
26
28
  atoms.center()
@@ -1,4 +1,5 @@
1
1
  import click
2
+ from mdkits.build_cli import build_cli
2
3
  from mdkits.cli import (
3
4
  convert,
4
5
  wrap,
@@ -8,7 +9,6 @@ from mdkits.cli import (
8
9
  density,
9
10
  cube,
10
11
  pdos,
11
- build_cli,
12
12
  )
13
13
 
14
14
 
File without changes
@@ -10,21 +10,17 @@ class CellType(click.ParamType):
10
10
 
11
11
  def convert(self, value, param, ctx):
12
12
  if isinstance(value, str):
13
- if ',' not in value:
14
- cell = cp2k_input_parsing.parse_cell()
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)
15
21
  return cell
16
22
  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)
23
+ self.fail(f"{value} is not a valid cell parameter", param, ctx)
28
24
 
29
25
 
30
26
  class FrameRangeType(click.ParamType):
@@ -33,7 +33,7 @@ def parse_cell():
33
33
  out_err.cell_output(cell)
34
34
  return cell
35
35
  except FileNotFoundError:
36
- sys.exit(f"cant parse cell information from {','.join(os_operation.default_input())}, assign a cell")
36
+ return [0., 0., 0., 90., 90., 90.]
37
37
 
38
38
 
39
39
  #def get_cell(cp2k_input_file, cell=None):
@@ -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,8 +0,0 @@
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
-
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