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

@@ -11,6 +11,7 @@ from mdkits.build_cli import (
11
11
  build_solution,
12
12
  cut_surface,
13
13
  supercell,
14
+ build_interface,
14
15
  )
15
16
 
16
17
 
@@ -27,6 +28,7 @@ cli_build.add_command(adsorbate.main)
27
28
  cli_build.add_command(build_solution.main)
28
29
  cli_build.add_command(cut_surface.main)
29
30
  cli_build.add_command(supercell.main)
31
+ cli_build.add_command(build_interface.main)
30
32
 
31
33
  if __name__ == '__main__':
32
34
  cli_build()
@@ -1,59 +1,44 @@
1
- from ase.io import write, read
2
- import argparse
3
- from ase.geometry import cell_to_cellpar, cellpar_to_cell
4
- import math
1
+ import click
2
+ from mdkits.util import arg_type, out_err
5
3
 
6
4
 
7
- def parse_argument():
8
- parser = argparse.ArgumentParser(description='combain solbox and surface to a interface')
9
- parser.add_argument('--surface', type=str, help='surface path')
10
- parser.add_argument('--sol', type=str, help='solbox path')
11
- parser.add_argument('--move', type=float, help='move at z, default = 0', default=0)
12
- parser.add_argument('--interval', type=float, help='interval between surface to sol, default is 2', default=2)
13
- parser.add_argument('--vacuum', type=float, help='vacuum of structure, default is 0', default=0)
14
- parser.add_argument('--symmetry', help='two side interface, default is false', action='store_true')
15
- parser.add_argument('--ne', help='two side interface, one side is Ne atom, default is false', action='store_true')
16
- parser.add_argument('-o', type=str, help='output file name', default='interface')
5
+ @click.command(name="interface")
6
+ @click.option('--slab', type=arg_type.Structure, help='surface')
7
+ @click.option('--sol', type=arg_type.Structure, help='solution')
8
+ @click.option('--interval', type=float, help='interval between surface and sol', default=2, show_default=True)
9
+ @click.option('--cap', type=click.Choice(['ne', 'slab']), help='build slab interface')
10
+ @click.option('--vacuum', type=float, help='vacuum length', default=0, show_default=True)
11
+ def main(slab, sol, interval, cap, vacuum):
12
+ """build interface"""
13
+ out_err.check_cell(slab)
14
+ out_err.check_cell(sol)
17
15
 
18
- return parser.parse_args()
16
+ o = f"{slab.filename.split('.')[-2]}_{sol.filename.split('.')[-2]}.cif"
19
17
 
18
+ slab.set_pbc(True)
19
+ slab.center()
20
+ slab_cell = slab.cell.cellpar()
21
+ init_slab_cell = slab.cell.cellpar()
22
+ if cap == 'slab':
23
+ slab_copy = slab.copy()
20
24
 
21
- def chformat(input_filename, output_filename, format):
22
- atoms = read(input_filename)
23
- write(output_filename, atoms, format=format)
25
+ sol_cell = sol.cell.cellpar()
26
+ sol.set_pbc(True)
27
+ sol.center()
28
+ sol.positions[:, 2] += slab_cell[2] + interval
24
29
 
30
+ slab.extend(sol)
31
+ slab_cell[2] += 2 * interval + sol_cell[2]
32
+ slab.set_cell(slab_cell)
33
+ slab.center()
25
34
 
26
- def main():
27
- args = parse_argument()
28
- surface = read(args.surface)
29
- surface.set_pbc(True)
30
- surface.center()
31
- sy_surface = surface.copy()
32
- cell = surface.get_cell()
33
- [lenx, leny, lenz, anga, angb, angc] = cell_to_cellpar(cell)
34
-
35
- solbox = read(args.sol)
36
- solbox_cell = solbox.cell.cellpar()
37
- solbox.set_pbc(True)
38
- solbox.center()
39
- tmp_list = solbox.get_positions()
40
- tmp_list[:, 2] += lenz + args.interval
41
- solbox.set_positions(tmp_list)
42
-
43
- surface.extend(solbox)
44
- surface.cell = [lenx, leny, (lenz + args.interval + solbox_cell[2] + args.interval), anga, angb, angc]
45
- surface.center()
46
-
47
- if args.symmetry:
48
- tmp_list = surface.get_positions()
49
- tmp_list[:, 2] += -(lenz + args.interval + solbox_cell[2] + args.interval)
50
- surface.set_positions(tmp_list)
51
- surface.extend(sy_surface)
52
- surface.cell = [lenx, leny, (lenz + args.interval + solbox_cell[2] + args.interval + lenz + args.vacuum), anga, angb, angc]
53
- surface.center()
54
- elif args.ne:
35
+ if cap is None:
36
+ slab.positions[:, 2] -= 0.5 * init_slab_cell[2]
37
+ elif cap == 'ne':
55
38
  from ase import Atoms
56
- ne_interval = 4 # adjust water density
39
+ ne_interval = 4
40
+ lenx = init_slab_cell[0]
41
+ leny = init_slab_cell[1]
57
42
  ne_cell = [lenx, leny, 2, 90, 90, 90]
58
43
  ne_position = []
59
44
  ne_symbols = []
@@ -64,23 +49,26 @@ def main():
64
49
  ne_symbols.append('Ne')
65
50
  ne_atoms = Atoms(symbols=ne_symbols, positions=ne_position, cell=ne_cell)
66
51
  ne_atoms.center()
67
- tmp_list = surface.get_positions()
68
- tmp_list[:, 2] += -(lenz + args.interval + solbox_cell[2])
69
- surface.set_positions(tmp_list)
70
- surface.extend(ne_atoms)
71
- surface.cell = [lenx, leny, (lenz + args.interval + solbox_cell[2] + args.interval + 2 + args.vacuum), anga, angb, angc]
72
- surface.center()
73
- else:
74
- surface.set_pbc(True)
75
- tmp_list = surface.get_positions()
76
- #tmp_list[:, 2] -= lenz
77
- tmp_list[:, 2] -= args.move
78
- surface.set_positions(tmp_list)
52
+
53
+ slab.positions[:, 2] += -(slab_cell[2] + interval)
54
+ slab.extend(ne_atoms)
55
+ slab_cell[2] += ne_cell[2]
56
+ slab.set_cell(slab_cell)
57
+ slab.center()
58
+ elif cap == 'slab':
59
+ slab.positions[:, 2] += -(slab_cell[2] + interval)
60
+ slab.extend(slab_copy)
61
+ slab_cell[2] += slab_copy.cell.cellpar()[2]
62
+ slab.set_cell(slab_cell)
63
+ slab.center()
64
+
65
+ if vacuum > 0:
66
+ slab_cell[2] += vacuum
67
+ slab.set_cell(slab_cell)
79
68
 
80
69
 
81
- write(args.o + '.xyz', surface, format='extxyz')
82
- write(args.o + '.cif', surface, format='cif')
83
- #chformat(args.o + '.cif', args.o + '.xyz', format='xyz')
70
+ slab.write(o)
71
+ out_err.path_output(o)
84
72
 
85
73
  if __name__ == '__main__':
86
- main()
74
+ main()
@@ -2,6 +2,7 @@ import click, os
2
2
  from julia import Pkg, Main
3
3
  from mdkits.util import arg_type
4
4
  from importlib import resources
5
+ from mdkits.cli import convert
5
6
  import tempfile
6
7
 
7
8
 
@@ -77,6 +78,10 @@ def main(filename, infile, install, water_number, n, tolerance, cell, gap):
77
78
  if os.path.exists(temp_file.name):
78
79
  os.remove(temp_file.name)
79
80
 
81
+ print("="*15)
82
+ print(total_input)
83
+ print("="*15)
84
+ convert.main([output_filename, "-c", "--cell", ",".join([str(a) for a in cell])], standalone_mode=False)
80
85
  Main.exit()
81
86
 
82
87
 
@@ -3,6 +3,7 @@
3
3
  import click, os
4
4
  from ase import build
5
5
  import numpy as np
6
+ from mdkits.util import out_err
6
7
 
7
8
 
8
9
  def surface_check(obj, surface_type):
@@ -19,7 +20,7 @@ def surface_check(obj, surface_type):
19
20
  @click.option('-c', type=float, help='extra hcp lattice constant. if specified, it overrides the expermental lattice constant of the element. Default is ideal ratio: sqrt(8/3)', default=np.sqrt(8/3), show_default=True)
20
21
  @click.option('--thickness', type=float, help='Thickness of the layer, for mx2 and graphene')
21
22
  @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
- @click.option('--vacuum', type=float, help='designate vacuum of surface, default is None', default=0.0, show_default=True)
23
+ @click.option('--vacuum', type=float, help='designate vacuum of surface, default is None', default=0.1, show_default=True)
23
24
  def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum):
24
25
  #if args.primitive:
25
26
  # a = args.a * 0.7071 * 2
@@ -29,6 +30,8 @@ def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum):
29
30
  vacuum = vacuum / 2
30
31
  build_surface = surface_check(build, surface)
31
32
  out_filename = f"{symbol}_{surface}_{size[0]}{size[1]}{size[2]}.cif"
33
+ if surface in ['fcc100']:
34
+ orth = True
32
35
 
33
36
  if surface in ['hcp0001', 'hcp10m10']:
34
37
  atoms = build_surface(symbol, size, a=a, c=c, vacuum=vacuum, orthogonal=orth)
@@ -48,6 +51,7 @@ def main(symbol, surface, size, kind, a, c, thickness, orth, vacuum):
48
51
  else:
49
52
  atoms = build_surface(symbol, size, a=a, vacuum=vacuum, orthogonal=orth)
50
53
 
54
+ out_err.check_cell(atoms)
51
55
  atoms.write(out_filename)
52
56
  print(os.path.abspath(out_filename))
53
57
 
@@ -4,6 +4,35 @@ from ase import build
4
4
  import click, os
5
5
  from mdkits.util import arg_type, out_err
6
6
  from mdkits.build_cli import supercell
7
+ import numpy as np
8
+ import ase.visualize
9
+
10
+
11
+ def find_vector(atoms):
12
+ position = atoms.positions
13
+ max_z = np.max(position[:, 2])
14
+ highest_points = position[position[:, 2] == max_z]
15
+
16
+ shortest_vector = None
17
+ min_distance = float('inf')
18
+ x_axis = np.array([1, 0, 0])
19
+
20
+ for i in range(len(highest_points)):
21
+ for j in range(i + 1, len(highest_points)):
22
+ point1 = highest_points[i]
23
+ point2 = highest_points[j]
24
+ vector = point2 - point1
25
+
26
+ cos_angle = np.dot(vector, x_axis) / (np.linalg.norm(vector) * np.linalg.norm(x_axis))
27
+ angle = np.arccos(cos_angle)
28
+
29
+ if angle <= np.pi / 2:
30
+ distance = np.linalg.norm(vector)
31
+ if distance < min_distance:
32
+ min_distance = distance
33
+ shortest_vector = vector
34
+
35
+ return shortest_vector
7
36
 
8
37
 
9
38
  @click.command(name='cut')
@@ -12,16 +41,37 @@ from mdkits.build_cli import supercell
12
41
  @click.option('--size', type=click.Tuple([int, int, int]), help='surface size')
13
42
  @click.option('--vacuum', type=float, help='designate vacuum of surface, default is None', default=0.0, show_default=True)
14
43
  @click.option('--cell', type=arg_type.Cell, help='set xyz file cell, --cell x,y,z,a,b,c')
15
- def main(atoms, face, vacuum, size, cell):
44
+ @click.option('--orth', is_flag=True, help='orthogonalize cell')
45
+ def main(atoms, face, vacuum, size, cell, orth):
16
46
  """cut surface"""
17
47
  out_err.check_cell(atoms, cell)
48
+ o = f"{atoms.filename.split('.')[-2]}_{face[0]}{face[1]}{face[2]}_{size[0]}{size[1]}{size[2]}.cif"
18
49
 
19
50
  surface = build.surface(atoms, face, size[2], vacuum=vacuum/2)
51
+
52
+ if orth:
53
+ #vector = surface[-2].position - surface[-1].position
54
+ #vector = find_vector(surface)
55
+ surface_cell = surface.cell.cellpar()
56
+ ase.visualize.view(surface)
57
+ gamma = surface_cell[-1]
58
+ if gamma != 90:
59
+ a = np.sin(np.radians(gamma)) * surface_cell[0]
60
+ b = surface_cell[1]
61
+ surface_cell[1] = a
62
+ surface_cell[0] = b
63
+ surface_cell[-1] = 90
64
+ #surface.rotate(vector, np.array([1, 0, 0]))
65
+ surface.rotate(-gamma, 'z')
66
+ surface.set_cell(surface_cell)
67
+ surface.wrap()
68
+ o = f"{atoms.filename.split('.')[-2]}_{face[0]}{face[1]}{face[2]}_{size[0]}{size[1]}{size[2]}_orth.cif"
69
+
20
70
  super_surface = supercell.supercell(surface, size[0], size[1], 1)
21
71
 
22
- o = f"{atoms.filename.split('.')[-2]}_{face[0]}{face[1]}{face[2]}_{size[0]}{size[1]}{size[2]}.cif"
23
72
  super_surface.write(o)
24
- print(os.path.abspath(o))
73
+ out_err.cell_output(super_surface.cell.cellpar())
74
+ out_err.path_output(o)
25
75
 
26
76
 
27
77
  if __name__ == '__main__':
mdkits/util/out_err.py CHANGED
@@ -3,14 +3,17 @@ output and error for cli
3
3
  """
4
4
 
5
5
  import numpy as np
6
- import sys
6
+ import sys, os
7
7
 
8
8
 
9
- def cell_output(cell: list):
9
+ def cell_output(cell):
10
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
11
 
12
12
 
13
- def check_cell(atoms, cell):
13
+ def path_output(file: str):
14
+ print(os.path.abspath(file))
15
+
16
+ def check_cell(atoms, cell=None):
14
17
  if not np.array_equal(atoms.cell.cellpar(), np.array([0., 0., 0., 90., 90., 90.])):
15
18
  cell_output(atoms.cell.cellpar())
16
19
  elif np.array_equal(atoms.cell.cellpar(), np.array([0., 0., 0., 90., 90., 90.])) and cell is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mdkits
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: kits for md or dft
5
5
  License: MIT
6
6
  Keywords: molecular dynamics,density functional theory
@@ -17,7 +17,6 @@ Requires-Dist: Cp2kData (>=0.7.2,<0.8.0)
17
17
  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
- Requires-Dist: dynaconf (>=3.1.12,<4.0.0)
21
20
  Requires-Dist: julia (>=0.6.2,<0.7.0)
22
21
  Requires-Dist: matplotlib (>=3.9.0,<4.0.0)
23
22
  Requires-Dist: numpy (>=1.26.4,<2.0.0)
@@ -2,11 +2,11 @@ mdkits/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  mdkits/build_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  mdkits/build_cli/adsorbate.py,sha256=Zp21i-miFv5zQlYjZnZuVpMxvNVT-6RtdlaoWDMwaOg,1900
4
4
  mdkits/build_cli/build_bulk.py,sha256=o3SFov5Ggk-qKcy6-NBoIYKvZV24OhcH3-du1d0U6H4,1593
5
- mdkits/build_cli/build_cli.py,sha256=lQ2Nk360vTnTzU97dttugf-1_AVLM_eSQRdJknXP37I,658
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=iJ5oslhvh9R-hHBOswq07Vrq4Ts2PH53tWZo0aUKdMU,2682
9
- mdkits/build_cli/cut_surface.py,sha256=1XDoW73TwD3wUiIBuJWuDGvPzvuVU9UpvRT4d3i_g-g,1034
5
+ mdkits/build_cli/build_cli.py,sha256=sqjnq5aHWLYLbNzN5SORkEYeYaewLagFuSvspJxyh7E,725
6
+ mdkits/build_cli/build_interface.py,sha256=3EDxUb-vGHFuat1Ex_wojVsN8PtzHiGrnDQIEa9WZ60,2448
7
+ mdkits/build_cli/build_solution.py,sha256=r-2Yt62lEyPuPuQvjj3B7HXmAZ42cxVhzvGWhfjUj2Y,3563
8
+ mdkits/build_cli/build_surface.py,sha256=cBEQ-KR_6j-Mcsxrwvzyl6p1SiY_chIytrCu7MS3q08,2794
9
+ mdkits/build_cli/cut_surface.py,sha256=R0Snr-y23SYLfNhdBC5VgT4KFY1SOGn5hZlVvX5CUvw,2757
10
10
  mdkits/build_cli/supercell.py,sha256=3iTTt3DHaERWDFonhBRS0oqWhjFh6pbS5SpIR-O1gYg,1034
11
11
  mdkits/build_cli/water.xyz,sha256=ByLDz-rYhw_wLPBU78lIQHe4s4Xf5Ckjft-Dus3czIc,171
12
12
  "mdkits/cli/,hb_distribution_down.py",sha256=i3NguzGebqCgy4uuVBeFajZRZnXtjhsJBPDGDdumlWA,4733
@@ -34,10 +34,10 @@ mdkits/util/encapsulated_mda.py,sha256=td3H24u3eHOIS2nwPucfIaMxeaVxI77oFI8nnNhw7
34
34
  mdkits/util/fig_operation.py,sha256=FwffNUtXorMl6qE04FipgzcVljEQii7wrNJUCJMyY3E,1045
35
35
  mdkits/util/numpy_geo.py,sha256=1Op8THoQeyqybSZAi7hVxohYCr4SzY6ndZC8_gAGXDA,3619
36
36
  mdkits/util/os_operation.py,sha256=ErN2ExjX9vZRfPe3ypsj4eyoQTEePqzlEX0Xm1N4lL4,980
37
- mdkits/util/out_err.py,sha256=vQ3DB1M-Ce19uR9n6fr_jZnqcv7FcOB3Fy0jY7US7y8,625
37
+ mdkits/util/out_err.py,sha256=b4eFz9kqqNReK9UCHak9k5tBlEj9yHAIADDTRbaNaNk,693
38
38
  mdkits/util/structure_parsing.py,sha256=mRPMJeih3O-ST7HeETDvBEkfV-1psT-XgxyYgDadV0U,4152
39
- mdkits-0.1.9.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
40
- mdkits-0.1.9.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
41
- mdkits-0.1.9.dist-info/METADATA,sha256=UnvRvhhkPrJXquurP0DHimAVZUUmxzwBKBOMLPQ3Pz4,6948
42
- mdkits-0.1.9.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
43
- mdkits-0.1.9.dist-info/RECORD,,
39
+ mdkits-0.1.10.dist-info/entry_points.txt,sha256=xoWWZ_yL87S501AzCO2ZjpnVuYkElC6z-8J3tmuIGXQ,44
40
+ mdkits-0.1.10.dist-info/LICENSE,sha256=VLaqyB0r_H7y3hUntfpPWcE3OATTedHWI983htLftcQ,1081
41
+ mdkits-0.1.10.dist-info/METADATA,sha256=H4xU8A7CelB-t7-r7JVdDRlW_SnBRAxRNQUpbW_KZVo,6907
42
+ mdkits-0.1.10.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
43
+ mdkits-0.1.10.dist-info/RECORD,,