TB2J 0.7.7.2__py3-none-any.whl → 0.8.0__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.
@@ -0,0 +1,44 @@
1
+ from abacus_api import read_HR_SR
2
+ import numpy as np
3
+
4
+
5
+ def main():
6
+ # nspin = 2 case
7
+ nspin = 2
8
+ binary = False
9
+ file_path = "../abacus_example/case_Sr2Mn2O6/1_no_soc/OUT.Sr2Mn2O6/"
10
+ HR_file = [
11
+ file_path + "data-HR-sparse_SPIN0.csr",
12
+ file_path + "data-HR-sparse_SPIN1.csr",
13
+ ]
14
+ SR_file = file_path + "data-SR-sparse_SPIN0.csr"
15
+
16
+ basis_num, R_direct_coor, HR_up, HR_dn, SR = read_HR_SR(
17
+ nspin, binary, HR_file, SR_file
18
+ )
19
+
20
+ print("basis_num =", basis_num)
21
+ print("R_direct_coor =", R_direct_coor)
22
+ print("HR_up[1, 0, 15:22] =", HR_up[1, 0, 15:22])
23
+ print("HR_dn[1, 0, 15:22] =", HR_dn[1, 0, 15:22])
24
+ print("SR[1, 0, 15:22] =", SR[1, 0, 15:22])
25
+
26
+ # nspin = 4 case
27
+ nspin = 4
28
+ binary = False
29
+ file_path = "../abacus_example/case_Sr2Mn2O6/2_soc/OUT.Sr2Mn2O6/"
30
+ HR_file = file_path + "data-HR-sparse_SPIN0.csr"
31
+ SR_file = file_path + "data-SR-sparse_SPIN0.csr"
32
+
33
+ basis_num, R_direct_coor, HR, SR = read_HR_SR(nspin, binary, HR_file, SR_file)
34
+
35
+ print("basis_num =", basis_num)
36
+ print("R_direct_coor =", R_direct_coor)
37
+ print("HR[1, 0, 30:37] =", HR[1, 0, 30:37])
38
+ print("SR[1, 0, 30:37] =", SR[1, 0, 30:37])
39
+
40
+ return
41
+
42
+
43
+ if __name__ == "__main__":
44
+ main()
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ @File : test_read_stru.py
5
+ @Time : 2024/02/02 09:52:23
6
+ @Author : Shen Zhen-Xiong
7
+ @Email : shenzx@iai.ustc.edu.cn
8
+ """
9
+ import os
10
+ from stru_api import read_abacus, write_abacus, read_input
11
+
12
+
13
+ def main():
14
+ stru_fe = read_abacus(os.path.join(os.getcwd(), "input/Fe.STRU"))
15
+ stru_sr2mn2o6 = read_abacus(
16
+ os.path.join(os.getcwd(), "input/Sr2Mn2O6.STRU"), verbose=True
17
+ )
18
+ write_abacus(
19
+ file=os.path.join(os.getcwd(), "STRU"),
20
+ atoms=stru_sr2mn2o6,
21
+ pp=stru_sr2mn2o6.info["pp"],
22
+ basis=stru_sr2mn2o6.info["basis"],
23
+ )
24
+ input_file = read_input(os.path.join(os.getcwd(), "input/INPUT"))
25
+ print(input_file["pseudo_dir"])
26
+ return
27
+
28
+
29
+ if __name__ == "__main__":
30
+ main()
TB2J/basis.py ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ class for basis set
5
+ """
6
+ from typing import Any
7
+ import numpy as np
8
+ import dataclasses
9
+ from TB2J.utils import symbol_number
10
+
11
+
12
+ @dataclasses.dataclass
13
+ class Basis:
14
+ iatom: int = 0
15
+ symbol: str = "unamed"
16
+ spin: int = 0
17
+
18
+ def __str__(self):
19
+ return f"{self.iatom}|{self.symbol}|{self.spin}"
20
+
21
+ def to_symnum_type(self, atoms=None, symbol_number=None):
22
+ if symbol_number is None:
23
+ symbol_number = symbol_number(atoms)
24
+ return f"{self.iatom}|{self.symbol}|{self.spin}"
25
+
26
+
27
+ @dataclasses.dataclass
28
+ class NAOBasis(Basis):
29
+ n: int = 0
30
+ l: int = 0
31
+ m: int = 0
32
+ zeta: int = 0
33
+ element: str = "unknown"
34
+
35
+ def __str__(self) -> str:
36
+ return super().__str__()
37
+
38
+
39
+ # @dataclasses.dataclass
40
+ # inherit from tuple, the elements are basis.
41
+
42
+
43
+ class BasisSet(list):
44
+ def set_atoms(self, atoms):
45
+ self._atoms = atoms
46
+
47
+ def get_iorbs_of_atom(self, iatom: int):
48
+ """
49
+ get the index of orbitals of an atom
50
+ """
51
+ return [i for i, basis in enumerate(self) if basis.iatom == iatom]
52
+
53
+ def get_iorbs_of_atom_spin(self, iatom: int, spin: int):
54
+ """
55
+ get the index of orbitals of an atom
56
+ """
57
+ return [
58
+ i
59
+ for i, basis in enumerate(self)
60
+ if basis.iatom == iatom and basis.spin == spin
61
+ ]
62
+
63
+ def find_iorbs(self, key=None):
64
+ """
65
+ find the index of orbitals of an atom
66
+ """
67
+ return [i for i, basis in enumerate(self) if key(basis)]
TB2J/exchange.py CHANGED
@@ -220,20 +220,6 @@ class Exchange(ExchangeParams):
220
220
  self.orb_dict[iatom] += [i]
221
221
  self.labels[iatom] += [orb_sym]
222
222
 
223
- # self.orb_slice = []
224
-
225
- # for iatom in range(len(self.atoms)):
226
- # if iatom in self.orb_dict:
227
- # self.orb_slice.append(
228
- # slice(
229
- # self.orb_dict[iatom][0],
230
- # self.orb_dict[iatom][-1] + 1,
231
- # ))
232
- # else:
233
- # self.orb_slice.append(slice(0, 0))
234
-
235
- # self.orb_slice = np.array(self.orb_slice)
236
-
237
223
  # index of magnetic atoms
238
224
  for i, sym in enumerate(self.atoms.get_chemical_symbols()):
239
225
  if sym in self.magnetic_elements:
@@ -302,6 +288,9 @@ or badly localized. Please check the Wannier centers in the Wannier90 output fil
302
288
  return self._atom_dict[ispin]
303
289
 
304
290
  def _prepare_distance(self):
291
+ """
292
+ prepare the distance between atoms.
293
+ """
305
294
  self.distance_dict = {}
306
295
  self.short_Rlist = []
307
296
  self.R_ijatom_dict = defaultdict(lambda: [])
TB2J/utils.py CHANGED
@@ -24,6 +24,11 @@ def symbol_number(symbols):
24
24
  return result
25
25
 
26
26
 
27
+ def symbol_number_list(symbols):
28
+ sdict = symbol_number(symbols)
29
+ return tuple(sdict.keys())
30
+
31
+
27
32
  def read_basis(fname):
28
33
  """
29
34
  return basis names from file (often named as basis.txt). Return a dict. key: basis name. value: basis index, from 0
@@ -0,0 +1,151 @@
1
+ #!python
2
+ from TB2J.abacus.gen_exchange_abacus import gen_exchange_abacus
3
+ from TB2J.versioninfo import print_license
4
+ import sys
5
+ import argparse
6
+
7
+
8
+ def run_abacus2J():
9
+ print_license()
10
+ parser = argparse.ArgumentParser(
11
+ description="abacus2J: Using magnetic force theorem to calculate exchange parameter J from abacus Hamiltonian in the LCAO mode"
12
+ )
13
+
14
+ parser.add_argument(
15
+ "--path", help="the path of the abacus calculation", default="./", type=str
16
+ )
17
+
18
+ parser.add_argument(
19
+ "--suffix",
20
+ help="the label of the abacus calculation. There should be an output directory called OUT.suffix",
21
+ default="abacus",
22
+ type=str,
23
+ )
24
+
25
+ parser.add_argument(
26
+ "--elements",
27
+ help="list of elements to be considered in Heisenberg model.",
28
+ # , For each element, a postfixes can be used to specify the orbitals(Only with Siesta backend), eg. Fe_3d, or Fe_3d_4s ",
29
+ default=None,
30
+ type=str,
31
+ nargs="*",
32
+ )
33
+ parser.add_argument(
34
+ "--rcut",
35
+ help="range of R. The default is all the commesurate R to the kmesh",
36
+ default=None,
37
+ type=float,
38
+ )
39
+ parser.add_argument(
40
+ "--efermi", help="Fermi energy in eV. For test only. ", default=None, type=float
41
+ )
42
+ parser.add_argument(
43
+ "--kmesh",
44
+ help="kmesh in the format of kx ky kz. Monkhorst pack. If all the numbers are odd, it is Gamma cenetered. (strongly recommended), Default: 5 5 5",
45
+ type=int,
46
+ nargs="*",
47
+ default=[5, 5, 5],
48
+ )
49
+ parser.add_argument(
50
+ "--emin",
51
+ help="energy minimum below efermi, default -14 eV",
52
+ type=float,
53
+ default=-14.0,
54
+ )
55
+
56
+ parser.add_argument(
57
+ "--use_cache",
58
+ help="whether to use disk file for temporary storing wavefunctions and hamiltonian to reduce memory usage. Default: False",
59
+ action="store_true",
60
+ default=False,
61
+ )
62
+
63
+ parser.add_argument(
64
+ "--nz", help="number of integration steps. Default: 50", default=50, type=int
65
+ )
66
+
67
+ parser.add_argument(
68
+ "--cutoff",
69
+ help="The minimum of J amplitude to write, (in eV). Default: 1e-7 eV",
70
+ default=1e-7,
71
+ type=float,
72
+ )
73
+
74
+ parser.add_argument(
75
+ "--exclude_orbs",
76
+ help="the indices of wannier functions to be excluded from magnetic site. counting start from 0. Default is none.",
77
+ default=[],
78
+ type=int,
79
+ nargs="+",
80
+ )
81
+
82
+ parser.add_argument(
83
+ "--np",
84
+ help="number of cpu cores to use in parallel, default: 1",
85
+ default=1,
86
+ type=int,
87
+ )
88
+
89
+ parser.add_argument(
90
+ "--description",
91
+ help="add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.",
92
+ type=str,
93
+ default="Calculated with TB2J.",
94
+ )
95
+
96
+ parser.add_argument(
97
+ "--orb_decomposition",
98
+ default=False,
99
+ action="store_true",
100
+ help="whether to do orbital decomposition in the non-collinear mode. Default: False.",
101
+ )
102
+
103
+ parser.add_argument(
104
+ "--fname",
105
+ default="exchange.xml",
106
+ type=str,
107
+ help="exchange xml file name. default: exchange.xml",
108
+ )
109
+
110
+ parser.add_argument(
111
+ "--output_path",
112
+ help="The path of the output directory, default is TB2J_results",
113
+ type=str,
114
+ default="TB2J_results",
115
+ )
116
+
117
+ args = parser.parse_args()
118
+
119
+ if args.elements is None:
120
+ print("Please input the magnetic elements, e.g. --elements Fe Ni")
121
+ sys.exit()
122
+
123
+ include_orbs = {}
124
+ for element in args.elements:
125
+ if "_" in element:
126
+ elem = element.split("_")[0]
127
+ orb = element.split("_")[1:]
128
+ include_orbs[elem] = orb
129
+ else:
130
+ include_orbs[element] = None
131
+
132
+ gen_exchange_abacus(
133
+ path=args.path,
134
+ suffix=args.suffix,
135
+ kmesh=args.kmesh,
136
+ magnetic_elements=list(include_orbs.keys()),
137
+ include_orbs=include_orbs,
138
+ Rcut=args.rcut,
139
+ emin=args.emin,
140
+ nz=args.nz,
141
+ description=args.description,
142
+ output_path=args.output_path,
143
+ use_cache=args.use_cache,
144
+ np=args.np,
145
+ exclude_orbs=args.exclude_orbs,
146
+ orb_decomposition=args.orb_decomposition,
147
+ )
148
+
149
+
150
+ if __name__ == "__main__":
151
+ run_abacus2J()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TB2J
3
- Version: 0.7.7.2
3
+ Version: 0.8.0
4
4
  Summary: TB2J: First principle to Heisenberg exchange J using tight-binding Green function method
5
5
  Home-page: UNKNOWN
6
6
  Author: Xu He
@@ -2,13 +2,14 @@ TB2J/Jdownfolder.py,sha256=Nw2ixvn2Uq-o1wficz6rdaYHjfRN3U_kQCvrNJGNb68,6980
2
2
  TB2J/Jtensor.py,sha256=0fhfOcfVQGu75gytEnApKWTJZfg9ksKJ0anJgco5wRQ,3179
3
3
  TB2J/Oiju.py,sha256=yQMfxQGnOSLbuTS22upkEFsJ9UAZk7wFaWynvg1NVdA,3595
4
4
  TB2J/Oiju_epc.py,sha256=sqjLIuWWT-d0uH2O7-6mobsUYQjHP5GyGlmdYqvkXFk,7332
5
- TB2J/__init__.py,sha256=LzfNa94z9kAEwsd_RdTtZG8uoRZQp5gjLMSdn6ypmpA,24
5
+ TB2J/__init__.py,sha256=iPlYCcIzuzW7T2HKDkmYlMkRI51dBLfNRxPPiWrfw9U,22
6
+ TB2J/basis.py,sha256=DFo6_QUwjBwisP6zGxvoO0lpGTMDPAOkiL9giNCjOjA,1558
6
7
  TB2J/citation.py,sha256=gcQeyJZaT1Qrtsl8Y3s4neOH3-vvgmIcCvXeV2o3vj0,2891
7
8
  TB2J/contour.py,sha256=aw8LX6wVFCRPhcpkzuI0jGnHisvk4cezvUhkF_6Yx94,2633
8
9
  TB2J/cut_cell.py,sha256=kr9WeQhBQLm8QXL2B3NcsSYmSw-OAtJk3f9wksAOZbs,2952
9
10
  TB2J/density_matrix.py,sha256=D5k8Oe21OCiLVORNYbo4TZOFG0slrQSbj91kJ3TMFjs,1514
10
11
  TB2J/epc.py,sha256=zLbtqZJhDr8DnnGN6YENcXwrMb3Qxu6KB08mLy9Pw20,3474
11
- TB2J/exchange.py,sha256=9iSbQCBKvfQ_wOmRx-nHTImsNnBiFqhEyCbmh2cDN1Q,30418
12
+ TB2J/exchange.py,sha256=AMR4fOS1OHD3Qh1AKt0RMDDUDSfCvr_zPPL39qMgHrk,30046
12
13
  TB2J/exchangeCL2.py,sha256=mODZU5KKWb2q5KzZAXoAt90vNjjFeLc8L_LySicWV3w,11350
13
14
  TB2J/exchange_pert.py,sha256=52XWeVW7JZ_JRUXEfqRfgia8NE_K1R9a0IrJZoLh8gY,8521
14
15
  TB2J/exchange_qspace.py,sha256=ZL68qBGFUaQ9BsSPsJaaoWOr9RssPiqX34R_9I3nk_8,8436
@@ -29,8 +30,16 @@ TB2J/sisl_wrapper.py,sha256=wk9tYfF9cPLYXAbs5Vs3Uf_wbPCtFSgH9CS0ClIhqvE,10580
29
30
  TB2J/supercell.py,sha256=4hgLGPBLRUDhtD-eF29v46ex7fHdkH-OENjS2wGLFww,19588
30
31
  TB2J/tensor_rotate.py,sha256=4-DfT_Mg5e40fbd74M5W0D5DqmUq-kVOOLDkkkI834A,8083
31
32
  TB2J/utest.py,sha256=z_ahi7tpHQF9WlHNQihcQ7qzfezRJQXQt28eB1X_z64,3897
32
- TB2J/utils.py,sha256=esEUiODLZPGDY7ego2z_1Yzp5M3Ew1TaFdm7yiK_j7U,9161
33
+ TB2J/utils.py,sha256=xIKX6p6ULoESWngDLSJsfQQewxsvIWI5l7Uwj_Y5H7U,9262
33
34
  TB2J/versioninfo.py,sha256=wZwS9QDFRVDe7rf8JyPDDI8UGdTQiO6Pb_sWv8GAegA,337
35
+ TB2J/abacus/__init__.py,sha256=5sHiDnF2L-Y80QeET9zOiS83a5T_TQAXvnIhcYB6wNU,56
36
+ TB2J/abacus/abacus_api.py,sha256=D_NyXW-Pno92d3RVHByx0l1HDPHQAvXsmQVt8cfIGR8,7267
37
+ TB2J/abacus/abacus_wrapper.py,sha256=-d0vYFi3IkTpSkiKyF_0_qkiYHIu2nqk46SWeNcmeTU,7832
38
+ TB2J/abacus/gen_exchange_abacus.py,sha256=dRDZWELfD209uNEyr-QscgYm3ZvGW-Lb9LoJFIbobxQ,2952
39
+ TB2J/abacus/orbital_api.py,sha256=l48Hn5z7TA0TH7Is4NDmz74b6B9L2ztYO4dRR37U4mQ,1562
40
+ TB2J/abacus/stru_api.py,sha256=uB_SGqcmYaj4zPGD_2eqSymcXWpu8paxXprFuJsowIQ,67790
41
+ TB2J/abacus/test_read_HRSR.py,sha256=cAT-e79jGjCBXLTJ9UYX0WvalG_yD4Awl79tTOUcwaQ,1254
42
+ TB2J/abacus/test_read_stru.py,sha256=CpK4zWhlCVAMCmYQmp9Hy-A40OblZQLFpo5JokpNcWQ,785
34
43
  TB2J/external/__init__.py,sha256=yD_ZIMi76H49rj6GAQpiB7UlKa3TgSaMkkLHT6M-8w8,137
35
44
  TB2J/external/p_tqdm.py,sha256=ug1jy3-43r8iW7bC37xzPSIe0EjYKH_GUluGzMiQiDw,5831
36
45
  TB2J/io_exchange/__init__.py,sha256=KfGHum7B8E4G_KKfillqw0lErtoyKEuFUUttHLs-mg4,32
@@ -53,16 +62,17 @@ TB2J/spinham/spin_xml.py,sha256=mneeZzkCE5andvIlur_6VK3XzWvoL-PVqSoWKXtDYTM,1103
53
62
  TB2J/spinham/supercell.py,sha256=y17uUC6r3gQb278FhxIW4CABihfLTvKFj6flyXrCPR8,12217
54
63
  TB2J/wannier/__init__.py,sha256=XGE3zbL2zI4CK08oNDOhOiAfF6aGl0lj3wE2VxswpYE,70
55
64
  TB2J/wannier/w90_parser.py,sha256=1MtVqOmMKwz4_jrkxyju9WfEBqzTXdgxpF6f0IGnAKo,4102
56
- TB2J-0.7.7.2.data/scripts/TB2J_downfold.py,sha256=F9oImXFysejCMP7eIBjbCX2jdHFOCvDW5beF1sG-UM8,1854
57
- TB2J-0.7.7.2.data/scripts/TB2J_eigen.py,sha256=Qs9v2hnMm2Tpfoa4h53muUKty2dZjwx8948MBoQooNg,1128
58
- TB2J-0.7.7.2.data/scripts/TB2J_magnon.py,sha256=q7UwAmorRcFNk4tfE7gl_ny05l6p7pbD9Wm_LkIpKEw,3101
59
- TB2J-0.7.7.2.data/scripts/TB2J_magnon_dos.py,sha256=TMXQvD2dIbO5FZ4tUMmxJgCgH2O2hDAPUNfEKO4z-x4,110
60
- TB2J-0.7.7.2.data/scripts/TB2J_merge.py,sha256=uZKLM__EyCHwxrQvx3Wd73dOEADp_SqfYC8KQvA-N9g,1622
61
- TB2J-0.7.7.2.data/scripts/TB2J_rotate.py,sha256=XPacPb7-DaFafBXFdWuNW_eNbjd5XPdNhBRNYhge_cg,634
62
- TB2J-0.7.7.2.data/scripts/siesta2J.py,sha256=Q_kvdgE34JJKVUMgBCSe07kARge0XULJ9B6z8hQFu6M,4706
63
- TB2J-0.7.7.2.data/scripts/wann2J.py,sha256=0g8Y5RbsYgV7iuoRQEeOnpaBy3oNpRfiw1dy6lWD13E,6520
64
- TB2J-0.7.7.2.dist-info/LICENSE,sha256=CbZI-jyRTjiqIcWa244cRSHJdjjtUNqGR4HeJkgEwJw,1332
65
- TB2J-0.7.7.2.dist-info/METADATA,sha256=Vd9nWfSCR4pr5j4Ie9ySe9psPkBwD7X7D4xWElnAjxk,1464
66
- TB2J-0.7.7.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
67
- TB2J-0.7.7.2.dist-info/top_level.txt,sha256=whYa5ByLYhl5XnTPBHSWr-IGD6VWmr5Ql2bye2qwV_s,5
68
- TB2J-0.7.7.2.dist-info/RECORD,,
65
+ TB2J-0.8.0.data/scripts/TB2J_downfold.py,sha256=F9oImXFysejCMP7eIBjbCX2jdHFOCvDW5beF1sG-UM8,1854
66
+ TB2J-0.8.0.data/scripts/TB2J_eigen.py,sha256=Qs9v2hnMm2Tpfoa4h53muUKty2dZjwx8948MBoQooNg,1128
67
+ TB2J-0.8.0.data/scripts/TB2J_magnon.py,sha256=q7UwAmorRcFNk4tfE7gl_ny05l6p7pbD9Wm_LkIpKEw,3101
68
+ TB2J-0.8.0.data/scripts/TB2J_magnon_dos.py,sha256=TMXQvD2dIbO5FZ4tUMmxJgCgH2O2hDAPUNfEKO4z-x4,110
69
+ TB2J-0.8.0.data/scripts/TB2J_merge.py,sha256=uZKLM__EyCHwxrQvx3Wd73dOEADp_SqfYC8KQvA-N9g,1622
70
+ TB2J-0.8.0.data/scripts/TB2J_rotate.py,sha256=XPacPb7-DaFafBXFdWuNW_eNbjd5XPdNhBRNYhge_cg,634
71
+ TB2J-0.8.0.data/scripts/abacus2J.py,sha256=M4B07lvTCDczTPTqvnDh_PERzCARAd09TLKv4aIdSQM,4408
72
+ TB2J-0.8.0.data/scripts/siesta2J.py,sha256=Q_kvdgE34JJKVUMgBCSe07kARge0XULJ9B6z8hQFu6M,4706
73
+ TB2J-0.8.0.data/scripts/wann2J.py,sha256=0g8Y5RbsYgV7iuoRQEeOnpaBy3oNpRfiw1dy6lWD13E,6520
74
+ TB2J-0.8.0.dist-info/LICENSE,sha256=CbZI-jyRTjiqIcWa244cRSHJdjjtUNqGR4HeJkgEwJw,1332
75
+ TB2J-0.8.0.dist-info/METADATA,sha256=vSK6t7OXXDLM_tpYrSBF-aTtmOTlBrhGhrV6_hpQnZo,1462
76
+ TB2J-0.8.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
77
+ TB2J-0.8.0.dist-info/top_level.txt,sha256=whYa5ByLYhl5XnTPBHSWr-IGD6VWmr5Ql2bye2qwV_s,5
78
+ TB2J-0.8.0.dist-info/RECORD,,
File without changes
File without changes
File without changes