TB2J 0.9.6rc0__tar.gz → 0.9.8rc0__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.
Files changed (99) hide show
  1. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/PKG-INFO +1 -1
  2. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/MAE.py +41 -7
  3. tb2j-0.9.8rc0/TB2J/MAEGreen.py +84 -0
  4. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/exchange.py +8 -82
  5. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/green.py +1 -1
  6. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/siesta_interface.py +90 -62
  7. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J.egg-info/PKG-INFO +1 -1
  8. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J.egg-info/SOURCES.txt +1 -0
  9. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/setup.py +1 -1
  10. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/LICENSE +0 -0
  11. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/README.md +0 -0
  12. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/Jdownfolder.py +0 -0
  13. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/Jtensor.py +0 -0
  14. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/Oiju.py +0 -0
  15. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/Oiju_epc.py +0 -0
  16. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/__init__.py +0 -0
  17. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/anisotropy.py +0 -0
  18. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/basis.py +0 -0
  19. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/citation.py +0 -0
  20. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/contour.py +0 -0
  21. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/density_matrix.py +0 -0
  22. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/epc.py +0 -0
  23. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/exchangeCL2.py +0 -0
  24. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/exchange_params.py +0 -0
  25. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/exchange_pert.py +0 -0
  26. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/exchange_qspace.py +0 -0
  27. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/external/__init__.py +0 -0
  28. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/external/p_tqdm.py +0 -0
  29. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/gpaw_wrapper.py +0 -0
  30. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/greentest.py +0 -0
  31. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/__init__.py +0 -0
  32. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/__init__.py +0 -0
  33. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/abacus_api.py +0 -0
  34. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/abacus_wrapper.py +0 -0
  35. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/gen_exchange_abacus.py +0 -0
  36. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/orbital_api.py +0 -0
  37. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/stru_api.py +0 -0
  38. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/test_density_matrix.py +0 -0
  39. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/test_read_HRSR.py +0 -0
  40. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/abacus/test_read_stru.py +0 -0
  41. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/gpaw_interface.py +0 -0
  42. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/lawaf_interface.py +0 -0
  43. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/manager.py +0 -0
  44. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/interfaces/wannier90_interface.py +0 -0
  45. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/__init__.py +0 -0
  46. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/io_exchange.py +0 -0
  47. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/io_multibinit.py +0 -0
  48. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/io_tomsasd.py +0 -0
  49. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/io_txt.py +0 -0
  50. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/io_uppasd.py +0 -0
  51. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_exchange/io_vampire.py +0 -0
  52. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/io_merge.py +0 -0
  53. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/kpoints.py +0 -0
  54. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/mathutils/__init__.py +0 -0
  55. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/mathutils/fermi.py +0 -0
  56. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/mathutils/kR_convert.py +0 -0
  57. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/mathutils/lowdin.py +0 -0
  58. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/mathutils/rotate_spin.py +0 -0
  59. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/myTB.py +0 -0
  60. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/orbmap.py +0 -0
  61. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/pauli.py +0 -0
  62. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/pert.py +0 -0
  63. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/plot.py +0 -0
  64. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/rotate_atoms.py +0 -0
  65. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/rotate_siestaDM.py +0 -0
  66. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/sisl_wrapper.py +0 -0
  67. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/__init__.py +0 -0
  68. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/base_parser.py +0 -0
  69. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/constants.py +0 -0
  70. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/hamiltonian.py +0 -0
  71. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/hamiltonian_terms.py +0 -0
  72. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/plot.py +0 -0
  73. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/qsolver.py +0 -0
  74. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/spin_api.py +0 -0
  75. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/spin_xml.py +0 -0
  76. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/spinham/supercell.py +0 -0
  77. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/symmetrize_J.py +0 -0
  78. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/tensor_rotate.py +0 -0
  79. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/utest.py +0 -0
  80. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/utils.py +0 -0
  81. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/versioninfo.py +0 -0
  82. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/wannier/__init__.py +0 -0
  83. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/wannier/w90_parser.py +0 -0
  84. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J/wannier/w90_tb_parser.py +0 -0
  85. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J.egg-info/dependency_links.txt +0 -0
  86. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J.egg-info/entry_points.txt +0 -0
  87. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J.egg-info/requires.txt +0 -0
  88. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/TB2J.egg-info/top_level.txt +0 -0
  89. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_downfold.py +0 -0
  90. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_eigen.py +0 -0
  91. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_magnon.py +0 -0
  92. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_magnon_dos.py +0 -0
  93. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_merge.py +0 -0
  94. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_rotate.py +0 -0
  95. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/TB2J_rotateDM.py +0 -0
  96. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/abacus2J.py +0 -0
  97. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/siesta2J.py +0 -0
  98. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/scripts/wann2J.py +0 -0
  99. {tb2j-0.9.6rc0 → tb2j-0.9.8rc0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TB2J
3
- Version: 0.9.6rc0
3
+ Version: 0.9.8rc0
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
@@ -35,12 +35,25 @@ def get_density_matrix(evals=None, evecs=None, kweights=None, nel=None, width=0.
35
35
 
36
36
 
37
37
  class MAE:
38
- def __init__(self, model, kmesh, gamma=True, width=0.1, nel=None):
38
+ def __init__(
39
+ self,
40
+ model,
41
+ kmesh=None,
42
+ gamma=True,
43
+ kpts=None,
44
+ kweights=None,
45
+ width=0.1,
46
+ nel=None,
47
+ ):
39
48
  self.model = model
40
49
  if nel is not None:
41
50
  self.model.nel = nel
42
- self.kpts = monkhorst_pack(kmesh, gamma_center=gamma)
43
- self.kweights = np.ones(len(self.kpts), dtype=float) / len(self.kpts)
51
+ if kpts is None:
52
+ self.kpts = monkhorst_pack(kmesh, gamma_center=gamma)
53
+ self.kweights = np.ones(len(self.kpts), dtype=float) / len(self.kpts)
54
+ else:
55
+ self.kpts = kpts
56
+ self.kweights = kweights
44
57
  self.width = width
45
58
 
46
59
  def get_band_energy(self):
@@ -94,8 +107,27 @@ class MAE:
94
107
 
95
108
 
96
109
  class MAEGreen(MAE):
97
- def __init__(self, model, kmesh, gamma=True, nel=None, width=0.1, **kwargs):
98
- super().__init__(model, kmesh, gamma=gamma, nel=nel, width=width)
110
+ def __init__(
111
+ self,
112
+ model,
113
+ kmesh=None,
114
+ gamma=True,
115
+ kpts=None,
116
+ kweights=None,
117
+ nel=None,
118
+ width=0.1,
119
+ **kwargs,
120
+ ):
121
+ self.model = model
122
+ if nel is not None:
123
+ self.model.nel = nel
124
+ if kpts is None:
125
+ self.kpts = monkhorst_pack(kmesh, gamma_center=gamma)
126
+ self.kweights = np.ones(len(self.kpts), dtype=float) / len(self.kpts)
127
+ else:
128
+ self.kpts = kpts
129
+ self.kweights = kweights
130
+ self.width = width
99
131
  model.set_so_strength(0.0)
100
132
  evals, evecs = model.solve_all(self.kpts)
101
133
  occ = Occupations(
@@ -103,8 +135,9 @@ class MAEGreen(MAE):
103
135
  )
104
136
  # occ.occupy(evals)
105
137
  efermi = occ.efermi(evals)
138
+ print(f"{efermi=}")
106
139
  self.G = TBGreen(model, kmesh, efermi=efermi, gamma=gamma, **kwargs)
107
- self.emin = -18
140
+ self.emin = -12
108
141
  self.emax = 0
109
142
  self.nz = 50
110
143
  self._prepare_elist()
@@ -143,7 +176,8 @@ class MAEGreen(MAE):
143
176
  for i, dHk in enumerate(Hsoc_k):
144
177
  dHi = rotate_spinor_matrix(dHk, theta, phi)
145
178
  GdH = G0K[i] @ dHi
146
- dE += np.trace(GdH @ G0K[i].T.conj() @ dHi) * self.kweights[i]
179
+ # dE += np.trace(GdH @ G0K[i].T.conj() @ dHi) * self.kweights[i]
180
+ dE += np.trace(GdH @ GdH) * self.kweights[i]
147
181
  dE_ang.append(dE)
148
182
  return np.array(dE_ang)
149
183
 
@@ -0,0 +1,84 @@
1
+ from pathlib import Path
2
+
3
+ import numpy as np
4
+ import tqdm
5
+
6
+ # from TB2J.abacus.abacus_wrapper import AbacusSplitSOCParser
7
+ from TB2J.exchange import ExchangeNCL
8
+
9
+ # from HamiltonIO.model.rotate_spin import rotate_Matrix_from_z_to_axis, rotate_Matrix_from_z_to_sperical
10
+ # from TB2J.abacus.abacus_wrapper import AbacusWrapper, AbacusParser
11
+ from TB2J.mathutils.rotate_spin import (
12
+ rotate_spinor_matrix,
13
+ )
14
+
15
+
16
+ class MAEGreen(ExchangeNCL):
17
+ def __init__(self, angles=None, **kwargs):
18
+ super().__init__(**kwargs)
19
+ self.es = None
20
+ self.natoms = len(self.atoms)
21
+ if angles is None or angles == "axis":
22
+ self.set_angles_axis()
23
+ elif angles == "scan":
24
+ self.set_angles_scan()
25
+
26
+ def set_angles_axis(self):
27
+ """theta and phi are defined as the x, y, z, axis."""
28
+ self.thetas = [0, np.pi / 2, np.pi / 2, np.pi / 2]
29
+ self.phis = [0, 0, np.pi / 2, np.pi / 4]
30
+
31
+ def set_angles_scan(self, step=15):
32
+ self.thetas = []
33
+ self.phis = []
34
+ for i in range(0, 181, step):
35
+ for j in range(0, 181, step):
36
+ self.thetas.append(i * np.pi / 180)
37
+ self.phis.append(j * np.pi / 180)
38
+
39
+ def get_perturbed(self, e, thetas, phis):
40
+ self.tbmodel.set_so_strength(0.0)
41
+ G0K = self.G.get_Gk_all(e)
42
+ Hsoc_k = self.tbmodel.get_Hk_soc(self.G.kpts)
43
+ na = len(thetas)
44
+ dE_angle = np.zeros(na, dtype=complex)
45
+ dE_angle_atoms = np.zeros((na, self.natoms), dtype=complex)
46
+ for iangle, (theta, phi) in enumerate(zip(thetas, phis)):
47
+ for ik, dHk in enumerate(Hsoc_k):
48
+ dHi = rotate_spinor_matrix(dHk, theta, phi)
49
+ GdH = G0K[ik] @ dHi
50
+ # dE += np.trace(GdH @ G0K[i].T.conj() @ dHi) * self.kweights[i]
51
+ # diagonal of second order perturbation.
52
+ dG2diag = np.diag(GdH @ GdH)
53
+ # dG2diag = np.diag(GdH @G0K[i].T.conj() @ dHi)
54
+ dE_angle[iangle] += np.sum(dG2diag) * self.G.kweights[ik]
55
+ for iatom in range(self.natoms):
56
+ dE_atom = np.sum(dG2diag[self.iorb(iatom)]) * self.G.kweights[ik]
57
+ dE_angle_atoms[iangle, iatom] += dE_atom
58
+ return dE_angle, dE_angle_atoms
59
+
60
+ def get_band_energy_vs_angles(self, thetas, phis):
61
+ nangles = len(thetas)
62
+ self.es = np.zeros(nangles, dtype=float)
63
+ self.es_atoms = np.zeros((nangles, self.natoms), dtype=float)
64
+ for ie, e in enumerate(tqdm.tqdm(self.contour.path)):
65
+ dE_angle, dE_angle_atoms = self.get_perturbed(e, thetas, phis)
66
+ self.es -= np.imag(dE_angle * self.contour.weights[ie]) / np.pi
67
+ self.es_atoms -= np.imag(dE_angle_atoms * self.contour.weights[ie]) / np.pi
68
+
69
+ def output(self, output_path="TB2J_anisotropy"):
70
+ Path(output_path).mkdir(exist_ok=True)
71
+ fname = f"{output_path}/MAE.dat"
72
+ with open(fname, "w") as f:
73
+ f.write("# theta phi MAE, MAEatom1, atom2, ...\n")
74
+ for i, (theta, phi, e, es) in enumerate(
75
+ zip(self.thetas, self.phis, self.es, self.es_atoms)
76
+ ):
77
+ f.write(f"{theta:.5f} {phi:.5f} {e:.8f} ")
78
+ for ea in es:
79
+ f.write(f"{ea:.8f} ")
80
+ f.write("\n")
81
+
82
+ def run(self, output_path="TB2J_anisotropy"):
83
+ self.get_band_energy_vs_angles(self.thetas, self.phis)
84
+ self.output(output_path=output_path)
@@ -11,7 +11,7 @@ from TB2J.external import p_map
11
11
  from TB2J.green import TBGreen
12
12
  from TB2J.io_exchange import SpinIO
13
13
  from TB2J.orbmap import map_orbs_matrix
14
- from TB2J.pauli import pauli_block_all, pauli_block_sigma_norm, pauli_mat
14
+ from TB2J.pauli import pauli_block_all, pauli_block_sigma_norm
15
15
  from TB2J.utils import (
16
16
  kmesh_to_R,
17
17
  simpson_nonuniform,
@@ -39,10 +39,7 @@ class Exchange(ExchangeParams):
39
39
  self._prepare_distance()
40
40
 
41
41
  # whether to calculate J and DMI with NJt method.
42
- self.calc_NJt = True
43
42
  # self._prepare_NijR()
44
- self.Ddict_NJT = None
45
- self.Jdict_NJT = None
46
43
  self._is_collinear = True
47
44
  self.has_elistc = False
48
45
  self._clean_tbmodels()
@@ -60,8 +57,9 @@ class Exchange(ExchangeParams):
60
57
  pass
61
58
 
62
59
  def _clean_tbmodels(self):
63
- del self.tbmodel
64
- del self.G.tbmodel
60
+ # del self.tbmodel
61
+ # del self.G.tbmodel
62
+ pass
65
63
 
66
64
  def _prepare_kmesh(self, kmesh):
67
65
  for k in kmesh:
@@ -262,9 +260,11 @@ class ExchangeNCL(Exchange):
262
260
  """
263
261
  self.tbmodel = tbmodels
264
262
  self.backend_name = self.tbmodel.name
263
+ print(self.kmesh)
265
264
  self.G = TBGreen(
266
265
  tbmodel=self.tbmodel,
267
266
  kmesh=self.kmesh,
267
+ gamma=True,
268
268
  efermi=self.efermi,
269
269
  use_cache=self._use_cache,
270
270
  nproc=self.nproc,
@@ -551,53 +551,6 @@ class ExchangeNCL(Exchange):
551
551
  self.rho_dict = rho
552
552
  return self.rho_dict
553
553
 
554
- def calculate_DMI_NJT(self):
555
- """
556
- calculate exchange and DMI with the
557
- This did not work and should be removed.
558
- """
559
- Ddict_NJT = {}
560
- Jdict_NJT = {}
561
- for R in self.short_Rlist:
562
- N = self.N[tuple(-np.array(R))] # density matrix
563
- t = self.tbmodel.get_hamR(R) # hopping parameter
564
- for iatom in self.ind_mag_atoms:
565
- orbi = self.iorb(iatom)
566
- ni = len(orbi)
567
- for jatom in self.ind_mag_atoms:
568
- orbj = self.iorb(jatom)
569
- nj = len(orbj)
570
- Nji = N[np.ix_(orbj, orbi)]
571
- tij = t[np.ix_(orbi, orbj)]
572
- D = np.zeros(3, dtype=float)
573
- J = np.zeros(3, dtype=float)
574
- for dim in range(3):
575
- # S_i = pauli_mat(ni, dim +
576
- # 1) #*self.rho[np.ix_(orbi, orbi)]
577
- # S_j = pauli_mat(nj, dim +
578
- # 1) #*self.rho[np.ix_(orbj, orbj)]
579
- # TODO: Note that rho is complex, not the imaginary part
580
- S_i = pauli_mat(ni, dim + 1) * self.rho[np.ix_(orbi, orbi)]
581
- S_j = pauli_mat(nj, dim + 1) * self.rho[np.ix_(orbj, orbj)]
582
-
583
- # [S, t]+ = Si tij + tij Sj, where
584
- # Si and Sj are the spin operator
585
- # Here we do not have L operator, so J-> S
586
- Jt = np.matmul(S_i, tij) + np.matmul(tij, S_j)
587
-
588
- Jtminus = np.matmul(S_i, tij) - np.matmul(tij, S_j)
589
- # D = -1/2 Tr Nji [J, tij]
590
- # Trace over spin and orb
591
- D[dim] = -0.5 * np.imag(np.trace(np.matmul(Nji, Jt)))
592
- J[dim] = -0.5 * np.imag(np.trace(np.matmul(Nji, Jtminus)))
593
- ispin = self.ispin(iatom)
594
- jspin = self.ispin(jatom)
595
- Ddict_NJT[(R, ispin, jspin)] = D
596
- Jdict_NJT[(R, ispin, jspin)] = J
597
- self.Jdict_NJT = Jdict_NJT
598
- self.Ddict_NJT = Ddict_NJT
599
- return Ddict_NJT
600
-
601
554
  def integrate(self, AijRs, AijRs_orb=None, method="simpson"):
602
555
  """
603
556
  AijRs: a list of AijR,
@@ -620,37 +573,14 @@ class ExchangeNCL(Exchange):
620
573
 
621
574
  def get_quantities_per_e(self, e):
622
575
  Gk_all = self.G.get_Gk_all(e)
623
- mae = self.get_mae_kspace(Gk_all)
576
+ # mae = self.get_mae_kspace(Gk_all)
577
+ mae = None
624
578
  # TODO: get the MAE from Gk_all
625
579
  GR = self.G.get_GR(self.short_Rlist, energy=e, get_rho=False, Gk_all=Gk_all)
626
580
  # TODO: define the quantities for one energy.
627
581
  AijR, AijR_orb = self.get_all_A(GR)
628
582
  return dict(AijR=AijR, AijR_orb=AijR_orb, mae=mae)
629
583
 
630
- def get_mae_kspace(self, Gk_all):
631
- """
632
- get the MAE from Gk_all
633
- TODO: This is only a place holder.
634
- """
635
- return None
636
-
637
- # mae_e = np.zeros(len(self.mae_angles), dtype=complex)
638
- # # rotate the Hso_k to angles
639
- # for ik, k in enumerate(self.G.kpoints):
640
- # Hso_k = self.model.get_Hso_k(k)
641
- # Gk = Gk_all[ik]
642
- # for i_angle, angle in enumerate(self.mae_angles):
643
- # # TODO: implementa rotate_H
644
- # Hso_k_rot = rotate_H(Hso_k, angle)
645
- # mae_e[i_angle] = Gk @ Hso_k @ Gk @ Hso_k
646
- # return mae_e
647
-
648
- def get_mae_rspace(self, GR):
649
- """
650
- get the MAE from GR
651
- """
652
- raise NotImplementedError("Not yet implemented.")
653
-
654
584
  def save_AijR(self, AijRs, fname):
655
585
  result = dict(path=self.contour.path, AijRs=AijRs)
656
586
  with open(fname, "wb") as myfile:
@@ -739,8 +669,6 @@ class ExchangeNCL(Exchange):
739
669
  Jani_dict=self.Jani,
740
670
  DMI_orb=self.DMI_orb,
741
671
  Jani_orb=self.Jani_orb,
742
- NJT_Jdict=self.Jdict_NJT,
743
- NJT_ddict=self.Ddict_NJT,
744
672
  biquadratic_Jdict=self.B,
745
673
  debug_dict=self.debug_dict,
746
674
  description=self.description,
@@ -779,8 +707,6 @@ class ExchangeCL(ExchangeNCL):
779
707
  distance_dict=self.distance_dict,
780
708
  exchange_Jdict=self.exchange_Jdict,
781
709
  dmi_ddict=None,
782
- NJT_Jdict=None,
783
- NJT_ddict=None,
784
710
  biquadratic_Jdict=self.B,
785
711
  description=self.description,
786
712
  )
@@ -166,7 +166,7 @@ class TBGreen:
166
166
  print("Calculating Fermi energy from eigenvalues")
167
167
  print(f"Number of electrons: {self.tbmodel.nel} ")
168
168
  occ = Occupations(
169
- nel=self.tbmodel.nel, width=0.05, wk=self.kweights, nspin=2
169
+ nel=self.tbmodel.nel, width=0.1, wk=self.kweights, nspin=2
170
170
  )
171
171
  self.efermi = occ.efermi(copy.deepcopy(self.evals))
172
172
  print(f"Fermi energy found: {self.efermi}")
@@ -4,6 +4,7 @@ import numpy as np
4
4
 
5
5
  from TB2J.exchange import ExchangeNCL
6
6
  from TB2J.exchangeCL2 import ExchangeCL2
7
+ from TB2J.MAEGreen import MAEGreen
7
8
 
8
9
  try:
9
10
  from HamiltonIO.siesta import SislParser
@@ -12,28 +13,70 @@ except ImportError:
12
13
  "Cannot import SislWrapper from HamiltonIO.siesta. Please install HamiltonIO first."
13
14
  )
14
15
 
15
- np.seterr(all="raise", under="ignore")
16
16
 
17
+ def siesta_anisotropy(**kwargs):
18
+ pass
17
19
 
18
- def gen_exchange_siesta(
19
- fdf_fname,
20
- read_H_soc=False,
21
- magnetic_elements=[],
22
- include_orbs=None,
23
- kmesh=[5, 5, 5],
24
- emin=-12.0,
25
- emax=0.0,
26
- nz=100,
27
- exclude_orbs=[],
28
- Rcut=None,
29
- ne=None,
30
- nproc=1,
31
- use_cache=False,
32
- output_path="TB2J_results",
33
- orb_decomposition=False,
34
- orth=False,
35
- description="",
36
- ):
20
+
21
+ def gen_exchange_siesta(fdf_fname, read_H_soc=False, **kwargs):
22
+ """
23
+ parameters:
24
+ fdf_fname: str
25
+ The fdf file for the calculation.
26
+ read_H_soc: bool
27
+ Whether to read the SOC Hamiltonian. Default is False.
28
+
29
+ parameters in **kwargs:
30
+ magnetic_elements: list of str
31
+ The magnetic elements to calculate the exchange. e.g. ["Fe", "Co", "Ni"]
32
+ include_orbs: dict
33
+ The included orbitals for each magnetic element. e.g. {"Fe": ["d"]}. Default is None.
34
+ kmesh: list of int
35
+ The k-point mesh for the calculation. e.g. [5, 5, 5]. Default is [5, 5, 5].
36
+ emin: float
37
+ The minimum energy for the calculation. Default is -12.0.
38
+ emax: float
39
+ The maximum energy for the calculation. Default is 0.0.
40
+ nz: int
41
+ The number of points for the energy mesh. Default is 100.
42
+ exclude_orbs: list of str
43
+ The excluded orbitals for the calculation. Default is [].
44
+ Rcut: float
45
+ The cutoff radius for the exchange calculation in angstrom. Default is None.
46
+ ne: int
47
+ The number of electrons for the calculation. Default is None.
48
+ nproc: int
49
+ The number of processors for the calculation. Default is 1.
50
+ use_cache: bool
51
+ Whether to use the cache for the calculation. Default is False.
52
+ output_path: str
53
+ The output path for the calculation. Default is "TB2J_results".
54
+ orb_decomposition: bool
55
+ Whether to calculate the orbital decomposition. Default is False.
56
+ orth: bool
57
+ Whether to orthogonalize the orbitals. Default is False.
58
+ description: str
59
+ The description for the calculation. Default is "".
60
+ """
61
+
62
+ exargs = dict(
63
+ magnetic_elements=[],
64
+ include_orbs=None,
65
+ kmesh=[5, 5, 5],
66
+ emin=-12.0,
67
+ emax=0.0,
68
+ nz=100,
69
+ exclude_orbs=[],
70
+ Rcut=None,
71
+ ne=None,
72
+ nproc=1,
73
+ use_cache=False,
74
+ output_path="TB2J_results",
75
+ orb_decomposition=False,
76
+ orth=False,
77
+ description="",
78
+ )
79
+ exargs.update(kwargs)
37
80
  try:
38
81
  import sisl
39
82
  except ImportError:
@@ -46,7 +89,8 @@ def gen_exchange_siesta(
46
89
  f"sisl version is {sisl.__version__}, but should be larger than 0.10.0."
47
90
  )
48
91
 
49
- include_orbs = {}
92
+ magnetic_elements = exargs.pop("magnetic_elements")
93
+ include_orbs = exargs.pop("include_orbs")
50
94
  if isinstance(magnetic_elements, str):
51
95
  magnetic_elements = [magnetic_elements]
52
96
  for element in magnetic_elements:
@@ -57,13 +101,10 @@ def gen_exchange_siesta(
57
101
  else:
58
102
  include_orbs[element] = None
59
103
  magnetic_elements = list(include_orbs.keys())
104
+ output_path = exargs.pop("output_path")
60
105
 
61
- # fdf = sisl.get_sile(fdf_fname)
62
- # geom = fdf.read_geometry()
63
- # H = fdf.read_hamiltonian()
64
- # geom = H.geometry
65
106
  parser = SislParser(
66
- fdf_fname=fdf_fname, ispin=None, read_H_soc=read_H_soc, orth=orth
107
+ fdf_fname=fdf_fname, ispin=None, read_H_soc=read_H_soc, orth=exargs["orth"]
67
108
  )
68
109
  if parser.spin.is_colinear:
69
110
  print("Reading Siesta hamiltonian: colinear spin.")
@@ -83,17 +124,7 @@ def gen_exchange_siesta(
83
124
  efermi=0.0,
84
125
  magnetic_elements=magnetic_elements,
85
126
  include_orbs=include_orbs,
86
- kmesh=kmesh,
87
- emin=emin,
88
- emax=emax,
89
- nz=nz,
90
- exclude_orbs=exclude_orbs,
91
- Rcut=Rcut,
92
- ne=ne,
93
- nproc=nproc,
94
- use_cache=use_cache,
95
- output_path=output_path,
96
- description=description,
127
+ **exargs,
97
128
  )
98
129
  exchange.run(path=output_path)
99
130
  print("\n")
@@ -111,28 +142,17 @@ Warning: The DMI component parallel to the spin orientation, the Jani which has
111
142
  e.g. if the spins are along z, the xz, yz, zz, zx, zy components and the z component of DMI.
112
143
  If you need these component, try to do three calculations with spin along x, y, z, or use structure with z rotated to x, y and z. And then use TB2J_merge.py to get the full set of parameters.
113
144
  \n"""
145
+ exargs["description"] = description
114
146
  if not model.split_soc:
115
147
  exchange = ExchangeNCL(
116
148
  tbmodels=model,
117
149
  atoms=model.atoms,
118
150
  basis=basis,
119
151
  efermi=0.0,
120
- # FIXME:
121
- # efermi=None,
122
152
  magnetic_elements=magnetic_elements,
123
153
  include_orbs=include_orbs,
124
- kmesh=kmesh,
125
- emin=emin,
126
- emax=emax,
127
- nz=nz,
128
- exclude_orbs=exclude_orbs,
129
- Rcut=Rcut,
130
- ne=ne,
131
- nproc=nproc,
132
- use_cache=use_cache,
133
- description=description,
134
154
  output_path=output_path,
135
- orb_decomposition=orb_decomposition,
155
+ **exargs,
136
156
  )
137
157
  exchange.run(path=output_path)
138
158
  print("\n")
@@ -140,6 +160,25 @@ Warning: The DMI component parallel to the spin orientation, the Jani which has
140
160
  f"All calculation finished. The results are in {output_path} directory."
141
161
  )
142
162
  else:
163
+ print("Starting to calculate MAE.")
164
+ model.set_so_strength(0.0)
165
+ MAE = MAEGreen(
166
+ tbmodels=model,
167
+ atoms=model.atoms,
168
+ basis=basis,
169
+ efermi=None,
170
+ magnetic_elements=magnetic_elements,
171
+ include_orbs=include_orbs,
172
+ **exargs,
173
+ )
174
+ # thetas = [0, np.pi / 2, np.pi, 3 * np.pi / 2]
175
+ # phis = [0, 0, 0, 0]
176
+ # MAE.set_angles(thetas=thetas, phis=phis)
177
+ MAE.run(output_path=f"{output_path}_anisotropy")
178
+ print(
179
+ f"MAE calculation finished. The results are in {output_path} directory."
180
+ )
181
+
143
182
  angle = {"x": (np.pi / 2, 0), "y": (np.pi / 2, np.pi / 2), "z": (0, 0)}
144
183
  for key, val in angle.items():
145
184
  # model = parser.get_model()
@@ -154,18 +193,7 @@ Warning: The DMI component parallel to the spin orientation, the Jani which has
154
193
  efermi=None, # set to None, compute from efermi.
155
194
  magnetic_elements=magnetic_elements,
156
195
  include_orbs=include_orbs,
157
- kmesh=kmesh,
158
- emin=emin,
159
- emax=emax,
160
- nz=nz,
161
- exclude_orbs=exclude_orbs,
162
- Rcut=Rcut,
163
- ne=ne,
164
- nproc=nproc,
165
- use_cache=use_cache,
166
- description=description,
167
- output_path=output_path_full,
168
- orb_decomposition=orb_decomposition,
196
+ **exargs,
169
197
  )
170
198
  exchange.run(path=output_path_full)
171
199
  print("\n")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TB2J
3
- Version: 0.9.6rc0
3
+ Version: 0.9.8rc0
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
@@ -4,6 +4,7 @@ setup.py
4
4
  TB2J/Jdownfolder.py
5
5
  TB2J/Jtensor.py
6
6
  TB2J/MAE.py
7
+ TB2J/MAEGreen.py
7
8
  TB2J/Oiju.py
8
9
  TB2J/Oiju_epc.py
9
10
  TB2J/__init__.py
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  from setuptools import find_packages, setup
3
3
 
4
- __version__ = "0.9.6_pre"
4
+ __version__ = "0.9.8_pre"
5
5
 
6
6
  long_description = """TB2J is a Python package aimed to compute automatically the magnetic interactions (superexchange and Dzyaloshinskii-Moriya) between atoms of magnetic crystals from DFT Hamiltonian based on Wannier functions or Linear combination of atomic orbitals. It uses the Green's function method and take the local rigid spin rotation as a perturbation. The package can take the output from Wannier90, which is interfaced with many density functional theory codes or from codes based on localised orbitals. A minimal user input is needed, which allows for an easily integration into a high-throughput workflows. """
7
7
 
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
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
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
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
File without changes
File without changes