TB2J 0.9.9rc7__py3-none-any.whl → 0.9.9rc9__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.
TB2J/exchange.py CHANGED
@@ -96,78 +96,93 @@ class Exchange(ExchangeParams):
96
96
 
97
97
  def _prepare_orb_dict(self):
98
98
  """
99
- generate self.ind_mag_atoms and self.orb_dict
100
- """
101
- # adict: dictionary of {'Fe': ['dxy', 'dyz', ...], ...}
102
- adict = OrderedDict()
103
- # orb_dict: {ind_atom:[ind_orb,1,2], ...}
104
- self.orb_dict = {}
105
- # labels: {0:{dxy, ...}}
106
- self.labels = {}
107
- # magnetic atoms index
108
- self.ind_mag_atoms = []
109
-
110
- sdict = symbol_number(self.atoms)
111
-
112
- for i, base in enumerate(self.basis):
113
- if i not in self.exclude_orbs:
114
- # e.g. Fe2, dxy, _, _
115
- if isinstance(base, str):
116
- atom_sym, orb_sym = base.split("|")[:2]
117
- iatom = sdict[atom_sym]
118
- else:
119
- try:
120
- atom_sym, orb_sym = base[:2]
121
- iatom = sdict[atom_sym]
122
- except Exception:
123
- iatom = base.iatom
124
- atom_sym = base.iatom
125
- orb_sym = base.sym
126
-
127
- if atom_sym in adict:
128
- adict[atom_sym].append(orb_sym)
129
- else:
130
- adict[atom_sym] = [orb_sym]
131
- if iatom not in self.orb_dict:
132
- self.orb_dict[iatom] = [i]
133
- self.labels[iatom] = [orb_sym]
134
- else:
135
- self.orb_dict[iatom] += [i]
136
- self.labels[iatom] += [orb_sym]
99
+ Generate orbital and magnetic atom mappings needed for exchange calculations.
100
+
101
+ Creates:
102
+ - self.orb_dict: Maps atom indices to their orbital indices
103
+ - self.labels: Maps atom indices to their orbital labels
104
+ - self.ind_mag_atoms: List of indices of magnetic atoms
105
+ - self._spin_dict: Maps atom indices to spin indices
106
+ - self._atom_dict: Maps spin indices back to atom indices
107
+ """
108
+ self._create_orbital_mappings()
109
+ self._identify_magnetic_atoms()
110
+ self._validate_orbital_assignments()
111
+ self._create_spin_mappings()
112
+ self._prepare_orb_mmat()
137
113
 
138
- # index of magnetic atoms
139
- symbols = self.atoms.get_chemical_symbols()
140
- tags = self.atoms.get_tags()
141
- for i, (sym, tag) in enumerate(zip(symbols, tags)):
142
- if sym in self.magnetic_elements or f"{sym}{tag}" in self.magnetic_elements:
143
- self.ind_mag_atoms.append(i)
114
+ def _create_orbital_mappings(self):
115
+ """Create mappings between atoms and their orbitals."""
116
+ self.orb_dict = {} # {atom_index: [orbital_indices]}
117
+ self.labels = {} # {atom_index: [orbital_labels]}
118
+ atom_symbols = symbol_number(self.atoms)
119
+
120
+ for orb_idx, base in enumerate(self.basis):
121
+ if orb_idx in self.exclude_orbs:
122
+ continue
123
+
124
+ # Extract atom and orbital info
125
+ if isinstance(base, str):
126
+ atom_sym, orb_sym = base.split("|")[:2]
127
+ atom_idx = atom_symbols[atom_sym]
128
+ else:
129
+ try:
130
+ atom_sym, orb_sym = base[:2]
131
+ atom_idx = atom_symbols[atom_sym]
132
+ except Exception:
133
+ atom_idx = base.iatom
134
+ atom_sym = base.iatom
135
+ orb_sym = base.sym
136
+
137
+ # Update orbital mappings
138
+ if atom_idx not in self.orb_dict:
139
+ self.orb_dict[atom_idx] = [orb_idx]
140
+ self.labels[atom_idx] = [orb_sym]
141
+ else:
142
+ self.orb_dict[atom_idx].append(orb_idx)
143
+ self.labels[atom_idx].append(orb_sym)
144
144
 
145
- # sanity check to see if some magnetic atom has no orbital.
146
- for iatom in self.ind_mag_atoms:
147
- if iatom not in self.orb_dict:
145
+ def _identify_magnetic_atoms(self):
146
+ """Identify which atoms are magnetic based on elements/tags."""
147
+ if self.index_magnetic_atoms is not None:
148
+ self.ind_mag_atoms = self.index_magnetic_atoms
149
+ else:
150
+ self.ind_mag_atoms = []
151
+ symbols = self.atoms.get_chemical_symbols()
152
+ tags = self.atoms.get_tags()
153
+
154
+ for atom_idx, (sym, tag) in enumerate(zip(symbols, tags)):
155
+ if sym in self.magnetic_elements or f"{sym}{tag}" in self.magnetic_elements:
156
+ self.ind_mag_atoms.append(atom_idx)
157
+ print(f"Magnetic atoms: {self.ind_mag_atoms}")
158
+
159
+ def _validate_orbital_assignments(self):
160
+ """Validate that magnetic atoms have proper orbital assignments."""
161
+ # Check all magnetic atoms have orbitals
162
+ for atom_idx in self.ind_mag_atoms:
163
+ if atom_idx not in self.orb_dict:
148
164
  raise ValueError(
149
- f"""Cannot find any orbital for atom {iatom}, which is supposed to be magnetic. Please check the Wannier functions."""
165
+ f"Atom {atom_idx} is magnetic but has no orbitals assigned. "
166
+ "Check Wannier function definitions."
150
167
  )
168
+
169
+ # For non-collinear case, check spin-orbital pairing
151
170
  if not self._is_collinear:
152
- for iatom, orb in self.orb_dict.items():
153
- # print(f"iatom: {iatom}, orb: {orb}")
154
- nsorb = len(self.orb_dict[iatom])
155
- if nsorb % 2 != 0 and False:
171
+ for atom_idx, orbitals in self.orb_dict.items():
172
+ if len(orbitals) % 2 != 0:
156
173
  raise ValueError(
157
- f"""The number of spin-orbitals for atom {iatom} is not even,
158
- {nsorb} spin-orbitals are found near this atom.
159
- which means the spin up/down does not have same number of orbitals.
160
- This is often because the Wannier functions are wrongly defined,
161
- or badly localized. Please check the Wannier centers in the Wannier90 output file.
162
- """
174
+ f"Atom {atom_idx} has {len(orbitals)} spin-orbitals "
175
+ "(should be even). Check Wannier function localization."
163
176
  )
164
- self._spin_dict = {}
165
- self._atom_dict = {}
166
- for ispin, iatom in enumerate(self.ind_mag_atoms):
167
- self._spin_dict[iatom] = ispin
168
- self._atom_dict[ispin] = iatom
169
177
 
170
- self._prepare_orb_mmat()
178
+ def _create_spin_mappings(self):
179
+ """Create mappings between atom indices and spin indices."""
180
+ self._spin_dict = {} # {atom_index: spin_index}
181
+ self._atom_dict = {} # {spin_index: atom_index}
182
+
183
+ for spin_idx, atom_idx in enumerate(self.ind_mag_atoms):
184
+ self._spin_dict[atom_idx] = spin_idx
185
+ self._atom_dict[spin_idx] = atom_idx
171
186
 
172
187
  def _prepare_orb_mmat(self):
173
188
  self.mmats = {}
@@ -566,12 +581,23 @@ class ExchangeNCL(Exchange):
566
581
  AijRs: a list of AijR,
567
582
  wherer AijR: array of ((nR, n, n, 4,4), dtype=complex)
568
583
  """
584
+ # if method == "trapezoidal":
585
+ # integrate = trapezoidal_nonuniform
586
+ # elif method == "simpson":
587
+ # integrate = simpson_nonuniform
588
+ #
589
+
590
+ # self.rho = integrate(self.contour.path, rhoRs)
569
591
  for iR, R in enumerate(self.R_ijatom_dict):
570
592
  for iatom, jatom in self.R_ijatom_dict[R]:
571
593
  f = AijRs[(R, iatom, jatom)]
594
+ # self.A_ijR[(R, iatom, jatom)] = integrate(self.contour.path, f)
572
595
  self.A_ijR[(R, iatom, jatom)] = self.contour.integrate_values(f)
573
596
 
574
597
  if self.orb_decomposition:
598
+ # self.A_ijR_orb[(R, iatom, jatom)] = integrate(
599
+ # self.contour.path, AijRs_orb[(R, iatom, jatom)]
600
+ # )
575
601
  self.contour.integrate_values(AijRs_orb[(R, iatom, jatom)])
576
602
 
577
603
  def get_quantities_per_e(self, e):
TB2J/exchange_params.py CHANGED
@@ -15,6 +15,7 @@ class ExchangeParams:
15
15
  efermi: float
16
16
  basis = []
17
17
  magnetic_elements = []
18
+ index_magnetic_atoms = None
18
19
  include_orbs = {}
19
20
  _kmesh = [4, 4, 4]
20
21
  emin: float = -15
@@ -55,6 +56,7 @@ class ExchangeParams:
55
56
  mae_angles=None,
56
57
  orth=False,
57
58
  ibz=False,
59
+ index_magnetic_atoms=None,
58
60
  ):
59
61
  self.efermi = efermi
60
62
  self.basis = basis
@@ -79,6 +81,7 @@ class ExchangeParams:
79
81
  self.mae_angles = mae_angles
80
82
  self.orth = orth
81
83
  self.ibz = ibz
84
+ self.index_magnetic_atoms = index_magnetic_atoms
82
85
 
83
86
  def set_params(self, **kwargs):
84
87
  for key, val in kwargs.items():
@@ -229,6 +232,21 @@ def add_exchange_args_to_parser(parser: argparse.ArgumentParser):
229
232
  default=False,
230
233
  )
231
234
 
235
+ parser.add_argument(
236
+ "--mae_angles",
237
+ help="angles for computing MAE, default is 0 0 0",
238
+ type=float,
239
+ nargs="*",
240
+ default=[0.0, 0.0, 0.0],
241
+ )
242
+ parser.add_argument(
243
+ "--index_magnetic_atoms",
244
+ help="index of magnetic atoms in the unit cell, default is None. If specified, this will be used to determine the atoms to be considered as magnetic atoms, instead of determined from magnetic elements. Note that the index starts from 1 ",
245
+ type=int,
246
+ nargs="*",
247
+ default=None,
248
+ )
249
+
232
250
  return parser
233
251
 
234
252
 
@@ -250,4 +268,5 @@ def parser_argument_to_dict(args) -> dict:
250
268
  "orb_decomposition": args.orb_decomposition,
251
269
  "output_path": args.output_path,
252
270
  "orth": args.orth,
271
+ "index_magnetic_atoms": args.index_magnetic_atoms,
253
272
  }
@@ -338,12 +338,6 @@ Generation time: {now.strftime("%y/%m/%d %H:%M:%S")}
338
338
  )
339
339
  return Jtensor
340
340
 
341
- def get_J_tensor_dict(self):
342
- Jdict = {}
343
- for i, j, R in self.ijR_list():
344
- Jdict[(i, j, R)] = self.get_J_tensor(i, j, R)
345
- return Jdict
346
-
347
341
  def get_full_Jtensor_for_one_R(self, R, iso_only=False):
348
342
  """
349
343
  Return the full exchange tensor of all i and j for cell R.
@@ -411,7 +405,6 @@ Generation time: {now.strftime("%y/%m/%d %H:%M:%S")}
411
405
  self.write_multibinit(path=os.path.join(path, "Multibinit"))
412
406
  self.write_tom_format(path=os.path.join(path, "TomASD"))
413
407
  self.write_vampire(path=os.path.join(path, "Vampire"))
414
- self.write_matjes(path=os.path.join(path, "Matjes"))
415
408
 
416
409
  self.plot_all(savefile=os.path.join(path, "JvsR.pdf"))
417
410
  # self.write_Jq(kmesh=[9, 9, 9], path=path)
@@ -580,11 +573,6 @@ Generation time: {now.strftime("%y/%m/%d %H:%M:%S")}
580
573
 
581
574
  write_uppasd(self, path=path)
582
575
 
583
- def write_matjes(self, path):
584
- from TB2J.io_exchange.io_matjes import write_matjes
585
-
586
- write_matjes(self, path=path)
587
-
588
576
 
589
577
  def gen_distance_dict(ind_mag_atoms, atoms, Rlist):
590
578
  distance_dict = {}
@@ -600,21 +588,6 @@ def gen_distance_dict(ind_mag_atoms, atoms, Rlist):
600
588
  return distance_dict
601
589
 
602
590
 
603
- def get_ind_shell(distance_dict, symprec=1e-5):
604
- """
605
- return a dictionary of shell index for each pair of atoms.
606
- The index of shell is the ith shortest distances between all magnetic atom pairs.
607
- """
608
- shell_dict = {}
609
- distances = np.array([x[1] for x in distance_dict.values()])
610
- distances_int = np.round(distances / symprec).astype(int)
611
- dint = sorted(np.unique(distances_int))
612
- dintdict = dict(zip(dint, range(len(dint))))
613
- for key, val in enumerate(distances_int):
614
- shell_dict[key] = dintdict[val]
615
- return shell_dict
616
-
617
-
618
591
  def test_spin_io():
619
592
  import numpy as np
620
593
  from ase import Atoms
TB2J/mycfr.py CHANGED
@@ -64,6 +64,10 @@ class CFR:
64
64
  # zp = 1j / eigp * kb * self.T
65
65
  # Rp = 0.25 * np.diag(eigv)**2 * zp **2
66
66
 
67
+ # print the poles and the weights
68
+ for i in range(len(self.poles)):
69
+ print("Pole: ", self.poles[i], "Weight: ", self.weights[i])
70
+
67
71
  # add a point to the poles: 1e10j
68
72
  self.path = np.concatenate((self.path, [self.Rinf * 1j]))
69
73
  # self.path = np.concatenate((self.path, [0.0]))
TB2J/symmetrize_J.py CHANGED
@@ -9,7 +9,7 @@ from TB2J.versioninfo import print_license
9
9
 
10
10
 
11
11
  class TB2JSymmetrizer:
12
- def __init__(self, exc, symprec=1e-8, verbose=True, Jonly=True):
12
+ def __init__(self, exc, symprec=1e-8, verbose=True, Jonly=False):
13
13
  # list of pairs with the index of atoms
14
14
  ijRs = exc.ijR_list_index_atom()
15
15
  finder = SymmetryPairFinder(atoms=exc.atoms, pairs=ijRs, symprec=symprec)
@@ -25,12 +25,6 @@ class TB2JSymmetrizer:
25
25
  )
26
26
  print("-" * 30)
27
27
  if exc.has_dmi:
28
- # raise NotImplementedError(
29
- # "Symmetrization of DMI is not yet implemented."
30
- # )
31
- # raise Warning(
32
- # "WARNING: Symmetrization of DMI is not yet implemented."
33
- # )
34
28
  print(
35
29
  "WARNING: Currently only the isotropic exchange is symmetrized. Symmetrization of DMI and anisotropic exchange are not yet implemented."
36
30
  )
@@ -39,7 +33,7 @@ class TB2JSymmetrizer:
39
33
  print("Symmetry found:")
40
34
  print(finder.spacegroup)
41
35
  print("-" * 30)
42
- self.pldict = finder.get_symmetry_pair_list_dict()
36
+ self.pgdict = finder.get_symmetry_pair_group_dict()
43
37
  self.exc = exc
44
38
  self.new_exc = copy.deepcopy(exc)
45
39
  self.Jonly = Jonly
@@ -52,25 +46,21 @@ class TB2JSymmetrizer:
52
46
  Symmetrize the exchange parameters J.
53
47
  """
54
48
  symJdict = {}
55
- reduced_symJdict = {}
56
49
  # Jdict = self.exc.exchange_Jdict
57
- for ishell, pairlist in enumerate(self.pldict.pairlists):
58
- ijRs = pairlist.get_all_ijR()
50
+ # ngroup = self.pgdict
51
+ for pairgroup in self.pgdict.groups:
52
+ ijRs = pairgroup.get_all_ijR()
59
53
  ijRs_spin = [self.exc.ijR_index_atom_to_spin(*ijR) for ijR in ijRs]
60
54
  Js = [self.exc.get_J(*ijR_spin) for ijR_spin in ijRs_spin]
61
55
  Javg = np.average(Js)
62
56
  for i, j, R in ijRs_spin:
63
57
  symJdict[(R, i, j)] = Javg
64
- ijRs_ref = ijRs_spin[0]
65
- i, j, R = ijRs_ref
66
- reduced_symJdict[(R, i, j)] = Javg
67
58
  self.new_exc.exchange_Jdict = symJdict
68
59
  if self.Jonly:
69
60
  self.new_exc.has_dmi = False
70
61
  self.new_exc.dmi_ddict = None
71
62
  self.new_exc.has_bilinear = False
72
63
  self.new_exc.Jani_dict = None
73
- self.new_exc.reduced_exchange_Jdict = reduced_symJdict
74
64
  self.has_uniaxial_anisotropy = False
75
65
  self.k1 = None
76
66
  self.k1dir = None
@@ -134,12 +124,12 @@ def symmetrize_J_cli():
134
124
  help="precision for symmetry detection. default is 1e-5 Angstrom",
135
125
  )
136
126
 
137
- # parser.add_argument(
138
- # "--Jonly",
139
- # action="store_true",
140
- # help="symmetrize only the exchange parameters and discard the DMI and anisotropic exchange",
141
- # default=True,
142
- # )
127
+ parser.add_argument(
128
+ "--Jonly",
129
+ action="store_true",
130
+ help="symmetrize only the exchange parameters and discard the DMI and anisotropic exchange",
131
+ default=False,
132
+ )
143
133
 
144
134
  args = parser.parse_args()
145
135
  if args.inpath is None:
@@ -149,8 +139,7 @@ def symmetrize_J_cli():
149
139
  path=args.inpath,
150
140
  output_path=args.outpath,
151
141
  symprec=args.symprec,
152
- # Jonly=args.Jonly,
153
- Jonly=True,
142
+ Jonly=args.Jonly,
154
143
  )
155
144
 
156
145
 
TB2J/thetaphi.py ADDED
@@ -0,0 +1,16 @@
1
+ import numpy as np
2
+
3
+
4
+ def theta_phi_even_spaced(n):
5
+ """
6
+ Return n evenly spaced theta and phi values in the ranges [0, pi] and [0, 2*pi] respectively.
7
+ """
8
+ phis = []
9
+ thetas = []
10
+ for i in range(n):
11
+ phi = 2 * np.pi * i / n
12
+ phis.append(phi)
13
+ r = np.sin(np.pi * i / n)
14
+ theta = np.arccos(1 - 2 * r)
15
+ thetas.append(theta)
16
+ return thetas, phis
@@ -0,0 +1,59 @@
1
+ #!python
2
+ import argparse
3
+ import sys
4
+
5
+ from TB2J.interfaces import gen_exchange_abacus
6
+ from TB2J.versioninfo import print_license
7
+ from TB2J.exchange_params import add_exchange_args_to_parser
8
+
9
+
10
+ def run_abacus2J():
11
+ print_license()
12
+ parser = argparse.ArgumentParser(
13
+ description="abacus2J: Using magnetic force theorem to calculate exchange parameter J from abacus Hamiltonian in the LCAO mode"
14
+ )
15
+ # Add ABACUS specific arguments
16
+ parser.add_argument(
17
+ "--path", help="the path of the abacus calculation", default="./", type=str
18
+ )
19
+ parser.add_argument(
20
+ "--suffix",
21
+ help="the label of the abacus calculation. There should be an output directory called OUT.suffix",
22
+ default="abacus",
23
+ type=str,
24
+ )
25
+
26
+ # Add common exchange arguments
27
+ parser = add_exchange_args_to_parser(parser)
28
+
29
+
30
+ args = parser.parse_args()
31
+
32
+ if args.elements is None:
33
+ print("Please input the magnetic elements, e.g. --elements Fe Ni")
34
+ sys.exit()
35
+
36
+ # include_orbs = {}
37
+
38
+ gen_exchange_abacus(
39
+ path=args.path,
40
+ suffix=args.suffix,
41
+ kmesh=args.kmesh,
42
+ magnetic_elements=args.elements,
43
+ include_orbs={},
44
+ Rcut=args.rcut,
45
+ emin=args.emin,
46
+ nz=args.nz,
47
+ description=args.description,
48
+ output_path=args.output_path,
49
+ use_cache=args.use_cache,
50
+ nproc=args.nproc,
51
+ exclude_orbs=args.exclude_orbs,
52
+ orb_decomposition=args.orb_decomposition,
53
+ index_magnetic_atoms=args.index_magnetic_atoms,
54
+ cutoff=args.cutoff,
55
+ )
56
+
57
+
58
+ if __name__ == "__main__":
59
+ run_abacus2J()
@@ -0,0 +1,75 @@
1
+ #!python
2
+ import argparse
3
+ import sys
4
+
5
+ from TB2J.interfaces import gen_exchange_siesta
6
+ from TB2J.versioninfo import print_license
7
+ from TB2J.exchange_params import add_exchange_args_to_parser
8
+
9
+
10
+ def run_siesta2J():
11
+ print_license()
12
+ parser = argparse.ArgumentParser(
13
+ description="siesta2J: Using magnetic force theorem to calculate exchange parameter J from siesta Hamiltonian"
14
+ )
15
+ # Add siesta specific arguments
16
+ parser.add_argument(
17
+ "--fdf_fname", help="path of the input fdf file", default="./", type=str
18
+ )
19
+ parser.add_argument(
20
+ "--fname",
21
+ default="exchange.xml",
22
+ type=str,
23
+ help="exchange xml file name. default: exchange.xml",
24
+ )
25
+ parser.add_argument(
26
+ "--split_soc",
27
+ help="whether the SOC part of the Hamiltonian can be read from the output of siesta. Default: False",
28
+ action="store_true",
29
+ default=False,
30
+ )
31
+
32
+ # Add common exchange arguments
33
+ parser = add_exchange_args_to_parser(parser)
34
+
35
+
36
+ args = parser.parse_args()
37
+
38
+ if args.elements is None:
39
+ print("Please input the magnetic elements, e.g. --elements Fe Ni")
40
+ sys.exit()
41
+
42
+ # include_orbs = {}
43
+ # for element in args.elements:
44
+ # if "_" in element:
45
+ # elem = element.split("_")[0]
46
+ # orb = element.split("_")[1:]
47
+ # include_orbs[elem] = orb
48
+ # else:
49
+ # include_orbs[element] = None
50
+
51
+ gen_exchange_siesta(
52
+ fdf_fname=args.fdf_fname,
53
+ kmesh=args.kmesh,
54
+ # magnetic_elements=list(include_orbs.keys()),
55
+ # include_orbs=include_orbs,
56
+ magnetic_elements=args.elements,
57
+ include_orbs={},
58
+ Rcut=args.rcut,
59
+ emin=args.emin,
60
+ emax=args.emax,
61
+ nz=args.nz,
62
+ description=args.description,
63
+ output_path=args.output_path,
64
+ use_cache=args.use_cache,
65
+ nproc=args.np,
66
+ exclude_orbs=args.exclude_orbs,
67
+ orb_decomposition=args.orb_decomposition,
68
+ read_H_soc=args.split_soc,
69
+ orth=args.orth,
70
+ index_magnetic_atoms=args.index_magnetic_atoms,
71
+ )
72
+
73
+
74
+ if __name__ == "__main__":
75
+ run_siesta2J()
@@ -89,6 +89,7 @@ def run_wann2J():
89
89
  # qspace=args.qspace,
90
90
  write_density_matrix=args.write_dm,
91
91
  orb_decomposition=args.orb_decomposition,
92
+ index_magnetic_atoms=args.index_magnetic_atoms,
92
93
  )
93
94
 
94
95
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TB2J
3
- Version: 0.9.9rc7
3
+ Version: 0.9.9rc9
4
4
  Summary: TB2J: First principle to Heisenberg exchange J using tight-binding Green function method
5
5
  Author: Xu He
6
6
  Author-email: mailhexu@gmail.com
@@ -24,6 +24,7 @@ Requires-Dist: packaging>=20.0
24
24
  Requires-Dist: HamiltonIO>=0.1.9
25
25
  Requires-Dist: pre-commit
26
26
  Requires-Dist: sympair>0.1.0
27
+ Requires-Dist: sisl>=0.9.0
27
28
  Dynamic: author
28
29
  Dynamic: author-email
29
30
  Dynamic: classifier
@@ -11,9 +11,9 @@ TB2J/citation.py,sha256=gcQeyJZaT1Qrtsl8Y3s4neOH3-vvgmIcCvXeV2o3vj0,2891
11
11
  TB2J/contour.py,sha256=zLHQZZ3hhgLkLFPATCraLOJyLJKLC0fba_L_5sRz23o,3246
12
12
  TB2J/density_matrix.py,sha256=D5k8Oe21OCiLVORNYbo4TZOFG0slrQSbj91kJ3TMFjs,1514
13
13
  TB2J/epc.py,sha256=zLbtqZJhDr8DnnGN6YENcXwrMb3Qxu6KB08mLy9Pw20,3474
14
- TB2J/exchange.py,sha256=742vEE8DQJuWBTlq45RQoPy0-_n_TT6BZOb_DoTpDKI,25739
14
+ TB2J/exchange.py,sha256=eVZ2Prm9faSPZNUJELTsGbfOPCw3QqUKIy5E_7tL03s,27015
15
15
  TB2J/exchangeCL2.py,sha256=P7bklMXVYX_tn9DbjEPqeTir1SeZyfPBIP1fhWUzLmY,11419
16
- TB2J/exchange_params.py,sha256=AcGYYky27DXSF3yDZWVjksr_3rt6im6qeIzpOwvqssk,7141
16
+ TB2J/exchange_params.py,sha256=xw3STJlumf5tNhnfzICzWzAl7srOy-wnyLsi-rImdSQ,7883
17
17
  TB2J/exchange_pert.py,sha256=jmFMtQbYa_uczM4VAeS6TijkIHRFIqEzZJswzE9Wfuo,8523
18
18
  TB2J/exchange_qspace.py,sha256=ZL68qBGFUaQ9BsSPsJaaoWOr9RssPiqX34R_9I3nk_8,8436
19
19
  TB2J/gpaw_wrapper.py,sha256=aJ--9Dtyq7jOP1Hkh-Sh1nWcfXm6zKcljOCO0DNCAr0,6890
@@ -22,7 +22,7 @@ TB2J/greentest.py,sha256=2ISSfhor9ecSEOi_E6b4Cv26wEIQlwlzca0ru8z44_E,1603
22
22
  TB2J/io_merge.py,sha256=E1_GfAB2HGpW-ipaO2lqU9SvaslwkiLxssn4DqJpMT8,6899
23
23
  TB2J/kpoints.py,sha256=9L7tBarFBHoIhpuc9zuwA6HdnlgH834SQrPek4yRoWk,3191
24
24
  TB2J/myTB.py,sha256=ok_B4my29bOIghMSZfx0Es6G8FaXaIiLP4gPxTdSj00,17659
25
- TB2J/mycfr.py,sha256=Wgj6PpA-oVuxm8Hh32FVw_vthozVBrDJhRV1hA1ku44,3752
25
+ TB2J/mycfr.py,sha256=ZF1PEE2khlKd_4gPyMkoNXepX3XqwWAL2kDbRJNVX-Y,3908
26
26
  TB2J/orbital_magmom.py,sha256=JTwO9ZDgRRQndqR9aFIua4eTvwLMoGsTiY_HaIPMZ2I,889
27
27
  TB2J/orbmap.py,sha256=XLQjKMxCy2eADaM5eb2F_zG08V7lzpXJxp5uEtTeVYI,7194
28
28
  TB2J/pauli.py,sha256=ESpAhk6LG5ugzuW1YFUTqiDxcg-pQ7wNnzR2FtUnvKM,5295
@@ -31,8 +31,9 @@ TB2J/plot.py,sha256=AnFIFWE2vlmj7Z6f_7-dX_O1stJN-qbuiurPj43dUCM,4104
31
31
  TB2J/rotate_atoms.py,sha256=Dwptn-wdDW4zYzjYb95yxTzuZOe9WPuLjh3d3-YcSs0,3277
32
32
  TB2J/rotate_siestaDM.py,sha256=eR97rspdrRaK9YTwQwUKfobI0S9UnEcbEZ2f5IgR7Tk,1070
33
33
  TB2J/sisl_wrapper.py,sha256=A5x1-tt8efUSPeGY5wM5m6-pJYQFXTCzQHVqD6RBa2g,14792
34
- TB2J/symmetrize_J.py,sha256=gN6Y8zV4IrO5rPh0SG8KHkekrJjMQzNY4GGe2ZBtwbc,4993
34
+ TB2J/symmetrize_J.py,sha256=IypvLL0JxExq-cmqc4o0nLL8psE7OC9ijj9YMcsqJeA,4487
35
35
  TB2J/tensor_rotate.py,sha256=4-DfT_Mg5e40fbd74M5W0D5DqmUq-kVOOLDkkkI834A,8083
36
+ TB2J/thetaphi.py,sha256=Z7N3EOSM7rjHd7b9HxMYLPQO__uR0VwEiV9b471Yudc,399
36
37
  TB2J/utest.py,sha256=z_ahi7tpHQF9WlHNQihcQ7qzfezRJQXQt28eB1X_z64,3897
37
38
  TB2J/utils.py,sha256=DHkc7BK0KUGesfoAv1OxMgIw_iZzcFXh--3ybsFSd_c,12535
38
39
  TB2J/versioninfo.py,sha256=atoCpy6lEcGTCC3xahrxEJjoHgoYVtL41Q_3Ryvp76I,338
@@ -54,8 +55,7 @@ TB2J/interfaces/abacus/test_density_matrix.py,sha256=bMWWJYtDS57SpPZ-eZXZ9Hr_UK4
54
55
  TB2J/interfaces/abacus/test_read_HRSR.py,sha256=W1oO_yigT50Yb5_u-KB_IfTpM7kArGkBuMSMs0H4CTs,1235
55
56
  TB2J/interfaces/abacus/test_read_stru.py,sha256=hoKPHVco8vwzC7Gao4bOPCdAPhh29x-9DTJJqRr7AYM,788
56
57
  TB2J/io_exchange/__init__.py,sha256=KfGHum7B8E4G_KKfillqw0lErtoyKEuFUUttHLs-mg4,32
57
- TB2J/io_exchange/io_exchange.py,sha256=7-Xt7_K5FKVrFkFvBrHhJGCRrL2Sw7zY-93GRBBv2GM,21050
58
- TB2J/io_exchange/io_matjes.py,sha256=klM5Z_t2kk0y_1IoqIILLnhUgjHQmXXmsXiono2LeMU,8594
58
+ TB2J/io_exchange/io_exchange.py,sha256=gaT0fXD3EzPsMgE_VX9gvcf7nEGY3KVYN8xxTAPzxc0,20120
59
59
  TB2J/io_exchange/io_multibinit.py,sha256=8PDmWxzGuv-GwJosj2ZTmiyNY_duFVWJ4ekCuSqGdd8,6739
60
60
  TB2J/io_exchange/io_tomsasd.py,sha256=NqkAC1Fl-CUnFA21eBzSy_S5F_oeQFJysw4UukQbN8o,4173
61
61
  TB2J/io_exchange/io_txt.py,sha256=BMr1eSILlKpgtjvDx7uw2VMAkEKSvGEPNxpaT_zev0I,10547
@@ -80,19 +80,19 @@ TB2J/spinham/supercell.py,sha256=y17uUC6r3gQb278FhxIW4CABihfLTvKFj6flyXrCPR8,122
80
80
  TB2J/wannier/__init__.py,sha256=7ojCbM84PYv1X1Tbo4NHI-d3gWmQsZB_xiYqbfxVV1E,80
81
81
  TB2J/wannier/w90_parser.py,sha256=dbd63LuKyv2DVUzqRINGsbDzEsOxsQyE8_Ear_LQIRg,4620
82
82
  TB2J/wannier/w90_tb_parser.py,sha256=qt8pnuprmPp9iIAYwPkPbmEzk6ZPgMq2xognoQp7vwc,4610
83
- tb2j-0.9.9rc7.data/scripts/TB2J_downfold.py,sha256=i4BVqnpDdgrX_amookVWeLGefGBn-qeAutWiwuY9SfQ,2099
84
- tb2j-0.9.9rc7.data/scripts/TB2J_eigen.py,sha256=Qs9v2hnMm2Tpfoa4h53muUKty2dZjwx8948MBoQooNg,1128
85
- tb2j-0.9.9rc7.data/scripts/TB2J_magnon.py,sha256=q7UwAmorRcFNk4tfE7gl_ny05l6p7pbD9Wm_LkIpKEw,3101
86
- tb2j-0.9.9rc7.data/scripts/TB2J_magnon_dos.py,sha256=TMXQvD2dIbO5FZ4tUMmxJgCgH2O2hDAPUNfEKO4z-x4,110
87
- tb2j-0.9.9rc7.data/scripts/TB2J_merge.py,sha256=y834SF4rIRn1L1ptkhczvavQpC-8Px6DTmDOOSaq_DE,1854
88
- tb2j-0.9.9rc7.data/scripts/TB2J_rotate.py,sha256=zgiDFuYZNmzKK0rwDmTaYD2OpRlmKA_VGeBx83w2Xwc,873
89
- tb2j-0.9.9rc7.data/scripts/TB2J_rotateDM.py,sha256=kCvF7gotuqAX1VnJ06cwfVm7RrhrdtiV5v7d9P2Pn_E,567
90
- tb2j-0.9.9rc7.data/scripts/abacus2J.py,sha256=0HLXoJhAkiZ-ZM1cs26lncccxE8-TzC8JiDTba1h1uM,4163
91
- tb2j-0.9.9rc7.data/scripts/siesta2J.py,sha256=gp31LioqpPkDmMY0y_5gXIjOBPNnf080P37pRo0yjw8,4886
92
- tb2j-0.9.9rc7.data/scripts/wann2J.py,sha256=pTFDf6h72I_LN_NX5UivyCoJPgwvyAyHW175nSAJvLo,2987
93
- tb2j-0.9.9rc7.dist-info/licenses/LICENSE,sha256=CbZI-jyRTjiqIcWa244cRSHJdjjtUNqGR4HeJkgEwJw,1332
94
- tb2j-0.9.9rc7.dist-info/METADATA,sha256=H5g8ApE237zxKx8_mx0Fr1fUCz2m97VkgDY5LBFYzlg,1660
95
- tb2j-0.9.9rc7.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
96
- tb2j-0.9.9rc7.dist-info/entry_points.txt,sha256=Hdz1WC9waUzyFVmowKnbbZ6j-J4adHh_Ko6JpxGYAtE,131
97
- tb2j-0.9.9rc7.dist-info/top_level.txt,sha256=whYa5ByLYhl5XnTPBHSWr-IGD6VWmr5Ql2bye2qwV_s,5
98
- tb2j-0.9.9rc7.dist-info/RECORD,,
83
+ tb2j-0.9.9rc9.data/scripts/TB2J_downfold.py,sha256=i4BVqnpDdgrX_amookVWeLGefGBn-qeAutWiwuY9SfQ,2099
84
+ tb2j-0.9.9rc9.data/scripts/TB2J_eigen.py,sha256=Qs9v2hnMm2Tpfoa4h53muUKty2dZjwx8948MBoQooNg,1128
85
+ tb2j-0.9.9rc9.data/scripts/TB2J_magnon.py,sha256=q7UwAmorRcFNk4tfE7gl_ny05l6p7pbD9Wm_LkIpKEw,3101
86
+ tb2j-0.9.9rc9.data/scripts/TB2J_magnon_dos.py,sha256=TMXQvD2dIbO5FZ4tUMmxJgCgH2O2hDAPUNfEKO4z-x4,110
87
+ tb2j-0.9.9rc9.data/scripts/TB2J_merge.py,sha256=y834SF4rIRn1L1ptkhczvavQpC-8Px6DTmDOOSaq_DE,1854
88
+ tb2j-0.9.9rc9.data/scripts/TB2J_rotate.py,sha256=zgiDFuYZNmzKK0rwDmTaYD2OpRlmKA_VGeBx83w2Xwc,873
89
+ tb2j-0.9.9rc9.data/scripts/TB2J_rotateDM.py,sha256=kCvF7gotuqAX1VnJ06cwfVm7RrhrdtiV5v7d9P2Pn_E,567
90
+ tb2j-0.9.9rc9.data/scripts/abacus2J.py,sha256=n9sOFZvPMPSzyBJjfpX4dnn7ek4bbOUBrhcEABdYUR8,1635
91
+ tb2j-0.9.9rc9.data/scripts/siesta2J.py,sha256=yl43Hoz9XCmjiZ4P1w7UM1BtmJg-eSbMpAm-2_eEUlA,2160
92
+ tb2j-0.9.9rc9.data/scripts/wann2J.py,sha256=Z5MSAtS5i5OrPlwDURnPr87dtYF4GbH_NixUi6WYsA8,3043
93
+ tb2j-0.9.9rc9.dist-info/licenses/LICENSE,sha256=CbZI-jyRTjiqIcWa244cRSHJdjjtUNqGR4HeJkgEwJw,1332
94
+ tb2j-0.9.9rc9.dist-info/METADATA,sha256=52dNL8vQEWQYUP7KsQfqUGLmaK-y4nSY6MhN9f2j_Sc,1687
95
+ tb2j-0.9.9rc9.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
96
+ tb2j-0.9.9rc9.dist-info/entry_points.txt,sha256=Hdz1WC9waUzyFVmowKnbbZ6j-J4adHh_Ko6JpxGYAtE,131
97
+ tb2j-0.9.9rc9.dist-info/top_level.txt,sha256=whYa5ByLYhl5XnTPBHSWr-IGD6VWmr5Ql2bye2qwV_s,5
98
+ tb2j-0.9.9rc9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (77.0.3)
2
+ Generator: setuptools (80.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,225 +0,0 @@
1
- import os
2
-
3
- import numpy as np
4
-
5
- from TB2J.utils import symbol_number
6
- from ase.units import Bohr, nm
7
-
8
-
9
- def get_ind_shell(distance_dict, symprec=1e-5):
10
- """
11
- return a dictionary of shell index for each pair of atoms.
12
- The index of shell is the ith shortest distances between all magnetic atom pairs.
13
- """
14
- shell_dict = {}
15
- distances = np.array([x[1] for x in distance_dict.values()])
16
- distances_int = np.round(distances / symprec).astype(int)
17
- dint = sorted(np.unique(distances_int))
18
- dintdict = dict(zip(dint, range(len(dint))))
19
- for key, val in distance_dict.items():
20
- di = np.round(val[1] / symprec).astype(int)
21
- shell_dict[key] = dintdict[di]
22
- return shell_dict
23
-
24
-
25
- def _write_symmetry(cls, path, fname="symmetry.in", symmetry=True):
26
- fname = os.path.join(path, fname)
27
- if not symmetry:
28
- with open(fname, "w") as myfile:
29
- myfile.write("1 \n")
30
- myfile.write("\n")
31
- myfile.write("! identity operation\n")
32
- myfile.write("1.0000000000 0.0000000000 0.0000000000\n")
33
- myfile.write("0.0000000000 1.0000000000 0.0000000000\n")
34
- myfile.write("0.0000000000 0.0000000000 1.0000000000\n")
35
- myfile.write("0.0000000000 0.0000000000 0.0000000000\n")
36
- else:
37
- raise NotImplementedError("Symmetry not implemented yet")
38
-
39
-
40
- def write_matjes(cls, path="TB2J_results/Matjes", symmetry=False):
41
- if not os.path.exists(path):
42
- os.makedirs(path)
43
- inputfname = os.path.join(path, "input")
44
- with open(inputfname, "w") as myfile:
45
- _write_lattice_supercell(cls, myfile)
46
- _write_atoms(cls, myfile)
47
- _write_magnetic_interactions(cls, myfile)
48
- #_write_isotropic_exchange(cls, myfile, symmetry=symmetry)
49
- _write_magnetic_anisotropy(cls, myfile)
50
- # _write_dmi(cls, myfile)
51
- _write_exchange_tensor(cls, myfile, symmetry=symmetry)
52
- _write_parameters(cls, myfile, symmetry=symmetry)
53
- print(f"writting symmetries ")
54
- _write_symmetry(cls, path, fname="symmetries.in", symmetry=False)
55
-
56
- def _write_parameters(cls, myfile, symmetry=False):
57
- if symmetry:
58
- myfile.write("cal_sym T\n")
59
- myfile.write("sym_mode 2\n")
60
- else:
61
- myfile.write("cal_sym F \n")
62
- myfile.write("sym_mode 0\n")
63
-
64
- def _write_lattice_supercell(cls, myfile):
65
- myfile.write("# Lattice and supercell\n")
66
- myfile.write(
67
- "Periodic_log .T. .T. .T. # periodic boundary conditions along vector 1, 2 and 3\n"
68
- )
69
- myfile.write("Nsize 8 8 8 # size of the supercell\n")
70
- try:
71
- unitcell = cls.atoms.get_cell().reshape((3, 3))
72
- except Exception:
73
- unitcell = cls.atoms.get_cell().array.reshape((3, 3))
74
- uc_lengths = np.linalg.norm(unitcell, axis=1)
75
- unitcell /= uc_lengths[:, None]
76
- myfile.write(f"alat {uc_lengths[0]/nm} {uc_lengths[1]/nm} {uc_lengths[2]/nm} #lattice constant lengths\n")
77
- myfile.write(
78
- "lattice #lattice vector should be orthogonal or expressed in cartesian\n")
79
- myfile.write(
80
- f"{unitcell[0][0]} {unitcell[0][1]} {unitcell[0][2]} # a_11 a_12 a_1 first lattice vector in line (does not need to be normalize)\n"
81
- )
82
- myfile.write(
83
- f"{unitcell[1][0]} {unitcell[1][1]} {unitcell[1][2]} # a_21 a_22 a_23 second lattice vector in line (does not need to be normalize)\n"
84
- )
85
- myfile.write(
86
- f"{unitcell[2][0]} {unitcell[2][1]} {unitcell[2][2]} # a_31 a_32 a_33 third lattice vector in line\n"
87
- )
88
-
89
-
90
- def get_atoms_info(atoms, spinat, symmetry=False):
91
- if symmetry:
92
- raise NotImplementedError("Symmetry not implemented yet")
93
- else:
94
- symnum = symbol_number(atoms)
95
- atom_types = list(symnum.keys())
96
- magmoms = np.linalg.norm(spinat, axis=1)
97
- masses = atoms.get_masses()
98
- tags = [i for i in range(len(atom_types))]
99
- return atom_types, magmoms, masses, tags
100
-
101
-
102
- def _write_atoms(cls, myfile, symmetry=False):
103
- myfile.write("\n")
104
- myfile.write("# Atoms\n")
105
- atom_types, magmoms, masses, tags = get_atoms_info(
106
- cls.atoms, cls.spinat, symmetry=symmetry
107
- )
108
-
109
- myfile.write(f"atomtypes {len(atom_types)} #Number of types atom\n")
110
- for i, atom_type in enumerate(atom_types):
111
- m = magmoms[i]
112
- mass = masses[i]
113
- charge = 0
114
- myfile.write(
115
- f"{atom_type} {m} {mass} 0.0 F 0 # atom type: (name, mag. moment, mass, charge, displacement, number TB-orb.)\n"
116
- )
117
-
118
- myfile.write(
119
- f"\natoms {len(cls.atoms)} positions of the atom in the unit cell\n"
120
- )
121
- for i, atom in enumerate(cls.atoms):
122
- spos = cls.atoms.get_scaled_positions()[i]
123
- myfile.write(f"{atom_types[tags[i]]} {spos[0]}, {spos[1]}, {spos[2]} \n")
124
-
125
-
126
- def _write_magnetic_interactions(cls, myfile, symmetry=False):
127
- myfile.write("\nThe Hamiltonian\n")
128
- myfile.write("# Magnetic interactions\n")
129
-
130
-
131
- def _write_isotropic_exchange(cls, myfile, symmetry=False):
132
- myfile.write("\nmagnetic_J\n")
133
- shell_dict = get_ind_shell(cls.distance_dict)
134
- if symmetry:
135
- Jdict = cls.reduced_exchange_Jdict
136
- else:
137
- Jdict = cls.exchange_Jdict
138
- for key, val in Jdict.items():
139
- R, i, j = key
140
- ishell = shell_dict[(R, i, j)]
141
- myfile.write(
142
- f"{i+1} {j+1} {ishell} {val} # between atoms type {i+1} and {j+1}, shell {R}, amplitude in eV \n"
143
- )
144
- myfile.write(
145
- "\nc_H_J -1 apply 1/2 in front of the sum of the exchange energy - default is -1\n"
146
- )
147
-
148
-
149
- def _write_magnetic_anisotropy(cls, myfile):
150
- if cls.k1 is None:
151
- return
152
- else:
153
- myfile.write("\nmagnetic_anisotropy \n")
154
- for i, k1 in enumerate(cls.k1):
155
- myfile.write(
156
- f"{i+1} {cls.k1dir[i][0]} {cls.k1dir[i][1]} {cls.k1dir[i][2]} {k1} anisotropy of atoms type {i+1}, direction {cls.k1dir[i][0]} {cls.k1dir[i][1]} {cls.k1dir[i][2]} and amplitude in eV\n"
157
- )
158
- myfile.write("\nc_H_ani 1.0\n")
159
-
160
-
161
- def _write_dmi(cls, myfile):
162
- if cls.has_dmi:
163
- myfile.write("\nmagnetic_D\n")
164
- for key, val in cls.dmi_ddict.items():
165
- R, i, j = key
166
- myfile.write(
167
- f"{i+1} {j+1} {R[0]} {R[1]} {R[2]} {val} #between atoms type {i+1} and {j+1}, mediated by atom type {R}, shell {R}, amplitude in eV\n"
168
- )
169
- myfile.write(
170
- "\nc_H_D -1.0 # coefficients to put in from of the sum - default is -1\n"
171
- )
172
-
173
-
174
- def _write_exchange_tensor(cls, myfile, symmetry=False):
175
- myfile.write(
176
- "\nmagnetic_r2_tensor #Exchange tensor elements, middle 9 entries: xx, xy, xz, yx, etc. (in units of eV) and direction in which it should be applied\n"
177
- )
178
-
179
- Jtensor = cls.get_J_tensor_dict()
180
- shelldict = get_ind_shell(cls.distance_dict)
181
- unitcell = cls.atoms.get_cell().array.reshape((3, 3))
182
- uc_lengths = np.linalg.norm(unitcell, axis=1)
183
- if Jtensor is not None:
184
- for key, val in Jtensor.items():
185
- i, j, R = key
186
- # distance vector
187
- dvec = cls.distance_dict[(R, i, j)][0]/nm/uc_lengths
188
- dscalar = np.linalg.norm(dvec)
189
- val = np.real(val)
190
- ishell = shelldict[(R, i, j)]
191
- myfile.write(
192
- f"{i+1} {j+1} {ishell} {' '.join([str(x) for x in val.flatten()])} {dvec[0]} {dvec[1]} {dvec[2]} \n"
193
- #f"{i+1} {j+1} {dscalar} {' '.join([str(x) for x in val.flatten()])} {dvec[0]} {dvec[1]} {dvec[2]} \n"
194
- )
195
- myfile.write(
196
- "\nc_H_Exchten -1 apply 1/2 in front of the sum of the exchange tensor energy - default is -1\n"
197
- )
198
-
199
- def rattle_atoms_and_cell(atoms, stdev=0.001, cell_stdev=0.001):
200
- """
201
- Rattle both atomic positions and cell parameters.
202
-
203
- Parameters:
204
- -----------
205
- atoms: ASE atoms object
206
- The atoms to be rattled
207
- stdev: float
208
- Standard deviation for atomic displacement in Angstrom
209
- cell_stdev: float
210
- Standard deviation for cell parameter variation (fractional)
211
-
212
- Returns:
213
- --------
214
- None
215
- The atoms object is modified in-place
216
- """
217
- # Rattle atomic positions
218
- positions = atoms.get_positions()
219
- displacement = np.random.normal(0, stdev, positions.shape)
220
- atoms.set_positions(positions + displacement)
221
-
222
- # Rattle cell parameters
223
- cell = atoms.get_cell()
224
- cell_noise = np.random.normal(0, cell_stdev, cell.shape)
225
- atoms.set_cell(cell * (1 + cell_noise), scale_atoms=True)
@@ -1,146 +0,0 @@
1
- #!python
2
- import argparse
3
- import sys
4
-
5
- from TB2J.interfaces import gen_exchange_abacus
6
- from TB2J.versioninfo import print_license
7
-
8
-
9
- def run_abacus2J():
10
- print_license()
11
- parser = argparse.ArgumentParser(
12
- description="abacus2J: Using magnetic force theorem to calculate exchange parameter J from abacus Hamiltonian in the LCAO mode"
13
- )
14
-
15
- parser.add_argument(
16
- "--path", help="the path of the abacus calculation", default="./", type=str
17
- )
18
-
19
- parser.add_argument(
20
- "--suffix",
21
- help="the label of the abacus calculation. There should be an output directory called OUT.suffix",
22
- default="abacus",
23
- type=str,
24
- )
25
-
26
- parser.add_argument(
27
- "--elements",
28
- help="list of elements to be considered in Heisenberg model.",
29
- # , For each element, a postfixes can be used to specify the orbitals(Only with Siesta backend), eg. Fe_3d, or Fe_3d_4s ",
30
- default=None,
31
- type=str,
32
- nargs="*",
33
- )
34
- parser.add_argument(
35
- "--rcut",
36
- help="range of R. The default is all the commesurate R to the kmesh",
37
- default=None,
38
- type=float,
39
- )
40
- parser.add_argument(
41
- "--efermi", help="Fermi energy in eV. For test only. ", default=None, type=float
42
- )
43
- parser.add_argument(
44
- "--kmesh",
45
- 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",
46
- type=int,
47
- nargs="*",
48
- default=[5, 5, 5],
49
- )
50
- parser.add_argument(
51
- "--emin",
52
- help="energy minimum below efermi, default -14 eV",
53
- type=float,
54
- default=-14.0,
55
- )
56
-
57
- parser.add_argument(
58
- "--use_cache",
59
- help="whether to use disk file for temporary storing wavefunctions and hamiltonian to reduce memory usage. Default: False",
60
- action="store_true",
61
- default=False,
62
- )
63
-
64
- parser.add_argument(
65
- "--nz", help="number of integration steps. Default: 50", default=50, type=int
66
- )
67
-
68
- parser.add_argument(
69
- "--cutoff",
70
- help="The minimum of J amplitude to write, (in eV). Default: 1e-7 eV",
71
- default=1e-7,
72
- type=float,
73
- )
74
-
75
- parser.add_argument(
76
- "--exclude_orbs",
77
- help="the indices of wannier functions to be excluded from magnetic site. counting start from 0. Default is none.",
78
- default=[],
79
- type=int,
80
- nargs="+",
81
- )
82
-
83
- parser.add_argument(
84
- "--nproc",
85
- "--np",
86
- help="number of cpu cores to use in parallel, default: 1",
87
- default=1,
88
- type=int,
89
- )
90
-
91
- parser.add_argument(
92
- "--description",
93
- help="add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.",
94
- type=str,
95
- default="Calculated with TB2J.",
96
- )
97
-
98
- parser.add_argument(
99
- "--orb_decomposition",
100
- default=False,
101
- action="store_true",
102
- help="whether to do orbital decomposition in the non-collinear mode. Default: False.",
103
- )
104
-
105
- parser.add_argument(
106
- "--fname",
107
- default="exchange.xml",
108
- type=str,
109
- help="exchange xml file name. default: exchange.xml",
110
- )
111
-
112
- parser.add_argument(
113
- "--output_path",
114
- help="The path of the output directory, default is TB2J_results",
115
- type=str,
116
- default="TB2J_results",
117
- )
118
-
119
- args = parser.parse_args()
120
-
121
- if args.elements is None:
122
- print("Please input the magnetic elements, e.g. --elements Fe Ni")
123
- sys.exit()
124
-
125
- # include_orbs = {}
126
-
127
- gen_exchange_abacus(
128
- path=args.path,
129
- suffix=args.suffix,
130
- kmesh=args.kmesh,
131
- magnetic_elements=args.elements,
132
- include_orbs={},
133
- Rcut=args.rcut,
134
- emin=args.emin,
135
- nz=args.nz,
136
- description=args.description,
137
- output_path=args.output_path,
138
- use_cache=args.use_cache,
139
- nproc=args.nproc,
140
- exclude_orbs=args.exclude_orbs,
141
- orb_decomposition=args.orb_decomposition,
142
- )
143
-
144
-
145
- if __name__ == "__main__":
146
- run_abacus2J()
@@ -1,163 +0,0 @@
1
- #!python
2
- import argparse
3
- import sys
4
-
5
- from TB2J.interfaces import gen_exchange_siesta
6
- from TB2J.versioninfo import print_license
7
-
8
-
9
- def run_siesta2J():
10
- print_license()
11
- parser = argparse.ArgumentParser(
12
- description="siesta2J: Using magnetic force theorem to calculate exchange parameter J from siesta Hamiltonian"
13
- )
14
- parser.add_argument(
15
- "--fdf_fname", help="path of the input fdf file", default="./", type=str
16
- )
17
- parser.add_argument(
18
- "--elements",
19
- help="list of elements to be considered in Heisenberg model. For each element, a postfixes can be used to specify the orbitals(Only with Siesta backend), eg. Fe_3d, or Fe_3d_4s ",
20
- default=None,
21
- type=str,
22
- nargs="*",
23
- )
24
- parser.add_argument(
25
- "--rcut",
26
- help="range of R. The default is all the commesurate R to the kmesh",
27
- default=None,
28
- type=float,
29
- )
30
- parser.add_argument(
31
- "--efermi", help="Fermi energy in eV. For test only. ", default=None, type=float
32
- )
33
- parser.add_argument(
34
- "--kmesh",
35
- 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",
36
- type=int,
37
- nargs="*",
38
- default=[5, 5, 5],
39
- )
40
- parser.add_argument(
41
- "--emin",
42
- help="energy minimum below efermi, default -14 eV",
43
- type=float,
44
- default=-14.0,
45
- )
46
- parser.add_argument(
47
- "--emax",
48
- help="energy maximum above efermi. Default 0.0 eV",
49
- type=float,
50
- default=0.05,
51
- )
52
- parser.add_argument(
53
- "--use_cache",
54
- help="whether to use disk file for temporary storing wavefunctions and hamiltonian to reduce memory usage. Default: False",
55
- action="store_true",
56
- default=False,
57
- )
58
- parser.add_argument(
59
- "--nz", help="number of integration steps. Default: 50", default=50, type=int
60
- )
61
- parser.add_argument(
62
- "--cutoff",
63
- help="The minimum of J amplitude to write, (in eV). Default: 1e-5 eV",
64
- default=1e-5,
65
- type=float,
66
- )
67
-
68
- parser.add_argument(
69
- "--exclude_orbs",
70
- help="the indices of wannier functions to be excluded from magnetic site. counting start from 0. Default is none.",
71
- default=[],
72
- type=int,
73
- nargs="+",
74
- )
75
-
76
- parser.add_argument(
77
- "--np",
78
- help="number of cpu cores to use in parallel, default: 1",
79
- default=1,
80
- type=int,
81
- )
82
-
83
- parser.add_argument(
84
- "--description",
85
- help="add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.",
86
- type=str,
87
- default="Calculated with TB2J.",
88
- )
89
-
90
- parser.add_argument(
91
- "--orb_decomposition",
92
- default=False,
93
- action="store_true",
94
- help="whether to do orbital decomposition in the non-collinear mode. Default: False.",
95
- )
96
-
97
- parser.add_argument(
98
- "--fname",
99
- default="exchange.xml",
100
- type=str,
101
- help="exchange xml file name. default: exchange.xml",
102
- )
103
-
104
- parser.add_argument(
105
- "--output_path",
106
- help="The path of the output directory, default is TB2J_results",
107
- type=str,
108
- default="TB2J_results",
109
- )
110
-
111
- parser.add_argument(
112
- "--split_soc",
113
- help="whether the SOC part of the Hamiltonian can be read from the output of siesta. Default: False",
114
- action="store_true",
115
- default=False,
116
- )
117
-
118
- parser.add_argument(
119
- "--orth",
120
- help="whether to use orthogonalization before the diagonization of the electron Hamiltonian. Default: False",
121
- action="store_true",
122
- default=False,
123
- )
124
-
125
- args = parser.parse_args()
126
-
127
- if args.elements is None:
128
- print("Please input the magnetic elements, e.g. --elements Fe Ni")
129
- sys.exit()
130
-
131
- # include_orbs = {}
132
- # for element in args.elements:
133
- # if "_" in element:
134
- # elem = element.split("_")[0]
135
- # orb = element.split("_")[1:]
136
- # include_orbs[elem] = orb
137
- # else:
138
- # include_orbs[element] = None
139
-
140
- gen_exchange_siesta(
141
- fdf_fname=args.fdf_fname,
142
- kmesh=args.kmesh,
143
- # magnetic_elements=list(include_orbs.keys()),
144
- # include_orbs=include_orbs,
145
- magnetic_elements=args.elements,
146
- include_orbs={},
147
- Rcut=args.rcut,
148
- emin=args.emin,
149
- emax=args.emax,
150
- nz=args.nz,
151
- description=args.description,
152
- output_path=args.output_path,
153
- use_cache=args.use_cache,
154
- nproc=args.np,
155
- exclude_orbs=args.exclude_orbs,
156
- orb_decomposition=args.orb_decomposition,
157
- read_H_soc=args.split_soc,
158
- orth=args.orth,
159
- )
160
-
161
-
162
- if __name__ == "__main__":
163
- run_siesta2J()