mdkits 0.1.7__py3-none-any.whl → 0.1.8__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.

File without changes
@@ -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
mdkits/cli/convert.py CHANGED
@@ -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()
mdkits/mdkits.py CHANGED
@@ -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
 
mdkits/util/arg_type.py CHANGED
@@ -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):
mdkits/util/out_err.py CHANGED
@@ -2,7 +2,16 @@
2
2
  output and error for cli
3
3
  """
4
4
 
5
+ import numpy as np
6
+ import sys
7
+
5
8
 
6
9
  def cell_output(cell: list):
7
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")
8
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,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,13 +1,16 @@
1
1
  mdkits/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mdkits/build_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ mdkits/build_cli/adsorbate.py,sha256=Zp21i-miFv5zQlYjZnZuVpMxvNVT-6RtdlaoWDMwaOg,1900
4
+ mdkits/build_cli/build_bulk.py,sha256=mOjoHHBui5fTYASabD96l6zBoKlQukT-LOyR2FZNzM4,1549
5
+ mdkits/build_cli/build_cli.py,sha256=pH9g6OonxxEpLTJCVwk_EwhLtFrmrL51jjyCjmIXU2o,544
6
+ mdkits/build_cli/build_interface.py,sha256=i1YE5iwazKVsTdQ_DXalNYeA8oflORWFePgJin1AJM4,3537
7
+ mdkits/build_cli/build_solution.py,sha256=jqbrrLopBn9LaTO7UELQTqxu0NTcg1PYkf5cdT1qZnc,3359
8
+ mdkits/build_cli/build_surface.py,sha256=LZtE3DMNgriOUb_sfPGbpYfZEf9b7sRWeKooaETsp2M,2663
9
+ mdkits/build_cli/cut_surface.py,sha256=D1naCWj0QJE3AiInzy3SeGO37butothE3BS1rZsZ5MU,1425
10
+ mdkits/build_cli/water.xyz,sha256=ByLDz-rYhw_wLPBU78lIQHe4s4Xf5Ckjft-Dus3czIc,171
2
11
  "mdkits/cli/,hb_distribution_down.py",sha256=i3NguzGebqCgy4uuVBeFajZRZnXtjhsJBPDGDdumlWA,4733
3
- mdkits/cli/adsorbate.py,sha256=rTj0oXkiUOboaxkfpbBoUicguMsB4-G-hJslsoUlbq0,1669
4
- mdkits/cli/build_bulk.py,sha256=mOjoHHBui5fTYASabD96l6zBoKlQukT-LOyR2FZNzM4,1549
5
- mdkits/cli/build_cli.py,sha256=5fFuq4VoW5sqbqKzRb5pWbNBlXBtuzHP68ur63o8WNo,380
6
- mdkits/cli/build_interface.py,sha256=i1YE5iwazKVsTdQ_DXalNYeA8oflORWFePgJin1AJM4,3537
7
- mdkits/cli/build_surface.py,sha256=LZtE3DMNgriOUb_sfPGbpYfZEf9b7sRWeKooaETsp2M,2663
8
- mdkits/cli/convert.py,sha256=yAMgxPvgKSB94W0PNnjIhXHwAxE8wynPdfnwjG7Fb4U,1871
12
+ mdkits/cli/convert.py,sha256=OmQ-7hmw0imgfgCJaWFEy3ePixsU7VKf0mGuJ6jRpn0,1795
9
13
  mdkits/cli/cube.py,sha256=G-QNup8W6J1-LCcEl1EHsV3nstd23byePDOcE_95t18,1176
10
- mdkits/cli/cut_surface.py,sha256=D1naCWj0QJE3AiInzy3SeGO37butothE3BS1rZsZ5MU,1425
11
14
  mdkits/cli/data.py,sha256=FGA4S9Cfo6WUJBSPWKOJrrZXHo_Qza-jNG1P_Dw7yi4,3262
12
15
  mdkits/cli/density.py,sha256=Y4grT8p7CsxggGYo_nGE9z_wlkJeQS5eYWKJQcoA014,5559
13
16
  mdkits/cli/extract.py,sha256=bqqJBmSaVyPYyEseGpUJcMBufIfDLTNRdmUfJ0txE5E,2498
@@ -22,19 +25,19 @@ mdkits/cli/supercell.py,sha256=r5iddLw1NNzj7NTFlR2j_jpD1AMfrsxhA08bPwQvVvg,2059
22
25
  mdkits/cli/wrap.py,sha256=AUxGISuiCfEjdMYl-TKc2VMCPHSybWKrMIOTn_6kSp0,1043
23
26
  mdkits/config/__init__.py,sha256=ZSwmnPK02LxJLMgcYmNb-tIOk8fEuHf5jpqD3SDHWLg,1039
24
27
  mdkits/config/settings.yml,sha256=PY7u0PbFLuxSnd54H5tI9oMjUf-mzyADqSZtm99BwG0,71
25
- mdkits/mdkits.py,sha256=ASOEhY94G_P902ojOobvqPYu1L3AOFTS_Ooh5LJAjX0,603
28
+ mdkits/mdkits.py,sha256=7yZHo13dn_Nn5K7BNIrEXFN44WoZoWD_MqgRQGhTJEU,627
26
29
  mdkits/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- mdkits/util/arg_type.py,sha256=AbjQpv4CEjJJVV2J34jRHOtUYcvwr0lyy5EI9Su7T0s,2728
28
- mdkits/util/cp2k_input_parsing.py,sha256=Hnp8QEMs3bGID2qusJX1OjXVq6cdVL-d24aAUIMji_U,1290
30
+ mdkits/util/arg_type.py,sha256=r744Q-Rau3F6BDRrS2Naygb4pLsOwcoSbVrAKIME6qc,2550
31
+ mdkits/util/cp2k_input_parsing.py,sha256=7NMVOYEGycarokLJlhLoWWilciM7sd8MWp5FVTF7hqI,1223
29
32
  mdkits/util/encapsulated_ase.py,sha256=uhqIhsALxzwJYuFrfOYGGC6U0QLm_dcZNridvfl_XGc,4339
30
33
  mdkits/util/encapsulated_mda.py,sha256=td3H24u3eHOIS2nwPucfIaMxeaVxI77oFI8nnNhw7vo,2217
31
34
  mdkits/util/fig_operation.py,sha256=FwffNUtXorMl6qE04FipgzcVljEQii7wrNJUCJMyY3E,1045
32
35
  mdkits/util/numpy_geo.py,sha256=1Op8THoQeyqybSZAi7hVxohYCr4SzY6ndZC8_gAGXDA,3619
33
36
  mdkits/util/os_operation.py,sha256=ErN2ExjX9vZRfPe3ypsj4eyoQTEePqzlEX0Xm1N4lL4,980
34
- mdkits/util/out_err.py,sha256=5ckrO2_wP5QObBeJ5SJ58u6OtvMii5NsXB6-plHrmpg,207
37
+ mdkits/util/out_err.py,sha256=K_vKJAfshamAeHIXcy3_mWYsuP5-DRjUO1ADeTn2D9Q,491
35
38
  mdkits/util/structure_parsing.py,sha256=mRPMJeih3O-ST7HeETDvBEkfV-1psT-XgxyYgDadV0U,4152
36
- mdkits-0.1.7.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
37
- mdkits-0.1.7.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
38
- mdkits-0.1.7.dist-info/METADATA,sha256=2g49Gv9xK-pjNm6S9xCormq10ppXLQQTaCl59y2uY0o,6910
39
- mdkits-0.1.7.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
40
- mdkits-0.1.7.dist-info/RECORD,,
39
+ mdkits-0.1.8.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
40
+ mdkits-0.1.8.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
41
+ mdkits-0.1.8.dist-info/METADATA,sha256=gpFmw5LOizLVQjlzU12d2--EF0gkvJxIQVJyKrhJ3n8,6948
42
+ mdkits-0.1.8.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
43
+ mdkits-0.1.8.dist-info/RECORD,,
File without changes
File without changes
File without changes
File without changes
File without changes