TB2J 0.8.2.7__tar.gz → 0.8.2.8__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 (84) hide show
  1. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/PKG-INFO +1 -1
  2. TB2J-0.8.2.8/TB2J/__init__.py +1 -0
  3. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/green.py +16 -6
  4. TB2J-0.8.2.8/TB2J/spinham/h_matrix.py +68 -0
  5. TB2J-0.8.2.8/TB2J/spinham/obtain_J.py +79 -0
  6. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J.egg-info/PKG-INFO +1 -1
  7. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J.egg-info/SOURCES.txt +2 -0
  8. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/setup.py +1 -1
  9. TB2J-0.8.2.7/TB2J/__init__.py +0 -1
  10. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/LICENSE +0 -0
  11. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/README.md +0 -0
  12. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/Jdownfolder.py +0 -0
  13. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/Jtensor.py +0 -0
  14. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/Oiju.py +0 -0
  15. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/Oiju_epc.py +0 -0
  16. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/__init__.py +0 -0
  17. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/abacus_api.py +0 -0
  18. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/abacus_wrapper.py +0 -0
  19. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/gen_exchange_abacus.py +0 -0
  20. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/orbital_api.py +0 -0
  21. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/stru_api.py +0 -0
  22. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/test_read_HRSR.py +0 -0
  23. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/abacus/test_read_stru.py +0 -0
  24. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/basis.py +0 -0
  25. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/citation.py +0 -0
  26. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/contour.py +0 -0
  27. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/density_matrix.py +0 -0
  28. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/epc.py +0 -0
  29. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/exchange.py +0 -0
  30. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/exchangeCL2.py +0 -0
  31. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/exchange_pert.py +0 -0
  32. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/exchange_qspace.py +0 -0
  33. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/external/__init__.py +0 -0
  34. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/external/p_tqdm.py +0 -0
  35. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/gpaw_wrapper.py +0 -0
  36. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/greentest.py +0 -0
  37. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/__init__.py +0 -0
  38. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/io_exchange.py +0 -0
  39. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/io_multibinit.py +0 -0
  40. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/io_tomsasd.py +0 -0
  41. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/io_txt.py +0 -0
  42. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/io_uppasd.py +0 -0
  43. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_exchange/io_vampire.py +0 -0
  44. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/io_merge.py +0 -0
  45. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/kpoints.py +0 -0
  46. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/manager.py +0 -0
  47. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/mathutils.py +0 -0
  48. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/myTB.py +0 -0
  49. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/orbmap.py +0 -0
  50. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/pauli.py +0 -0
  51. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/pert.py +0 -0
  52. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/plot.py +0 -0
  53. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/rotate_atoms.py +0 -0
  54. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/sisl_wrapper.py +0 -0
  55. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/__init__.py +0 -0
  56. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/base_parser.py +0 -0
  57. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/constants.py +0 -0
  58. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/hamiltonian.py +0 -0
  59. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/hamiltonian_terms.py +0 -0
  60. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/plot.py +0 -0
  61. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/qsolver.py +0 -0
  62. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/spin_api.py +0 -0
  63. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/spin_xml.py +0 -0
  64. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/spinham/supercell.py +0 -0
  65. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/tensor_rotate.py +0 -0
  66. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/utest.py +0 -0
  67. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/utils.py +0 -0
  68. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/versioninfo.py +0 -0
  69. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/wannier/__init__.py +0 -0
  70. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/wannier/w90_parser.py +0 -0
  71. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J/wannier/w90_tb_parser.py +0 -0
  72. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J.egg-info/dependency_links.txt +0 -0
  73. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J.egg-info/requires.txt +0 -0
  74. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/TB2J.egg-info/top_level.txt +0 -0
  75. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/TB2J_downfold.py +0 -0
  76. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/TB2J_eigen.py +0 -0
  77. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/TB2J_magnon.py +0 -0
  78. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/TB2J_magnon_dos.py +0 -0
  79. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/TB2J_merge.py +0 -0
  80. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/TB2J_rotate.py +0 -0
  81. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/abacus2J.py +0 -0
  82. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/siesta2J.py +0 -0
  83. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/scripts/wann2J.py +0 -0
  84. {TB2J-0.8.2.7 → TB2J-0.8.2.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TB2J
3
- Version: 0.8.2.7
3
+ Version: 0.8.2.8
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
@@ -0,0 +1 @@
1
+ __version__ = "0.8.2.8"
@@ -225,12 +225,22 @@ class TBGreen:
225
225
 
226
226
  def get_density_matrix(self):
227
227
  rho = np.zeros((self.nbasis, self.nbasis), dtype=complex)
228
- for ik, _ in enumerate(self.kpts):
229
- rho += (
230
- (self.get_evecs(ik) * fermi(self.evals[ik], self.efermi))
231
- @ self.get_evecs(ik).T.conj()
232
- * self.kweights[ik]
233
- )
228
+ if self.is_orthogonal:
229
+ for ik, _ in enumerate(self.kpts):
230
+ rho += (
231
+ (self.get_evecs(ik) * fermi(self.evals[ik], self.efermi))
232
+ @ self.get_evecs(ik).T.conj()
233
+ * self.kweights[ik]
234
+ )
235
+ else:
236
+ for ik, _ in enumerate(self.kpts):
237
+ rho += (
238
+ (self.get_evecs(ik) * fermi(self.evals[ik], self.efermi))
239
+ @ self.get_evecs(ik).T.conj()
240
+ @ self.get_Sk(ik)
241
+ * self.kweights[ik]
242
+ )
243
+
234
244
  return rho
235
245
 
236
246
  def get_rho_R(self, Rlist):
@@ -0,0 +1,68 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import aiida
4
+ from aiida_tb2j.data import ExchangeData
5
+
6
+ def plot_dispersion(bands, kpoint_labels, color='blue', title=None):
7
+
8
+ fig, axs = plt.subplots(1, 1, constrained_layout=True)
9
+ fig.set_size_inches(6, 6/1.618)
10
+
11
+ '''
12
+ Plot the bands
13
+ '''
14
+ kpoints = np.arange(len(bands))
15
+ axs.plot(kpoints, bands, color=color, linewidth=1.5)
16
+
17
+ '''
18
+ Plot the symmetry points
19
+ '''
20
+ bmin = bands.min(); bmax = bands.max()
21
+ ymin = bmin - 0.05*np.abs(bmin-bmax); ymax = bmax + 0.05*np.abs(bmax-bmin);
22
+ axs.set_xticks(kpoint_labels[0], kpoint_labels[1], fontsize=10)
23
+ axs.vlines(x=kpoint_labels[0], ymin=ymin, ymax=ymax, color='black', linewidth=0.5)
24
+ axs.set_xlim([0, len(kpoints)])
25
+ axs.set_ylim([ymin, ymax])
26
+
27
+ if title is not None:
28
+ plt.title(title, fontsize=10)
29
+
30
+ plt.show()
31
+
32
+
33
+ if __name__ == "__main__":
34
+
35
+ from argparse import ArgumentParser
36
+
37
+ parser = ArgumentParser()
38
+ parser.add_argument('-f', '--pickle_filename', type=str, help="Path of the 'TB2J.pickle' file.", required=True)
39
+ args = parser.parse_args()
40
+
41
+ '''
42
+ Right now the implementation depends on AiiDA and so we must create and load an AiiDA profile,
43
+ even if we do not store any information on a data base.
44
+ '''
45
+ aiida.load_profile()
46
+ '''
47
+ Create an ExchangeData object with the informations from the TB2J.pickle file
48
+ '''
49
+ exchange = ExchangeData.load_tb2j(pickle_file=args.pickle_filename, isotropic=False, pbc=(True, True, True))
50
+ '''
51
+ Compute the magnon band structure along a high symmetry path generated with
52
+ the ASE package. The informations is stored in an AiiDA BandsData object.
53
+ Here tol is the symmetry tolerance to determine the space group of the system.
54
+ They are in units of eV
55
+ '''
56
+ magnon_data = exchange.get_magnon_bands(npoints=300, tol=1e-1, with_DMI=True, with_Jani=True)
57
+ magnon_bands = 1000*magnon_data.get_bands() # Convert to meV
58
+ raw_labels = [(k, '$\Gamma$') if s == 'GAMMA' else (k, s) for k, s in magnon_data.labels]
59
+ kpoint_labels = list( zip( *raw_labels ) )
60
+ plot_dispersion(magnon_bands, kpoint_labels, color='blue', title='Magnon Bands')
61
+ '''
62
+ We can also obtain the dynamical matrix h instead of the actual magnon bands. The result
63
+ is stored in a numpy array with shape (number of kpoints, 2*natoms, 2*natoms)
64
+ '''
65
+ kpoints = magnon_data.get_kpoints() # The shape of the kpoints must be (nkpoints, 3)
66
+ h_matrix = 1000*exchange._H_matrix(kpoints, with_DMI=True, with_Jani=True) # Convert to meV
67
+ h_dispersion = np.linalg.eigvalsh(h_matrix) # We can also get the eigenvectors with np.linalg.eigh
68
+ plot_dispersion(h_dispersion, kpoint_labels, color='red', title='h matrix dispersion')
@@ -0,0 +1,79 @@
1
+ import numpy as np
2
+ from aiida_tb2j.data import ExchangeData
3
+ from aiida_tb2j.data.exchange import get_rotation_arrays
4
+ from itertools import combinations_with_replacement
5
+
6
+ ux, uy, uz = np.eye(3).reshape((3, 1, 3))
7
+
8
+ def combine_arrays(u, v):
9
+
10
+ return np.concatenate([u*v, np.roll(u, -1, axis=-1)*v, np.roll(v, -1, axis=-1)*u], axis=-1)
11
+
12
+ def get_coefficients(magmoms, indices):
13
+
14
+ i, j = indices
15
+
16
+ U, V = zip(*[get_rotation_arrays(magmoms, u=u) for u in [ux, uy, uz]])
17
+ U = np.stack(U).swapaxes(0, 1)
18
+ V = np.stack(V).swapaxes(0, 1)
19
+
20
+ uc = combine_arrays(U[i], U[j].conj())
21
+ ur = combine_arrays(U[i], U[j])
22
+ uc2 = combine_arrays(U[i].conj(), U[j])
23
+ u = np.concatenate([uc, ur, uc2], axis=1)
24
+
25
+ return u, V
26
+
27
+ def get_C(H0, u, V):
28
+
29
+ n = int(H0.shape[-1]/2)
30
+ upi = np.triu_indices(n)
31
+ dig = np.diag_indices(n)
32
+
33
+ i, j = upi
34
+ AB0 = H0[:, [i, i, i+n], [j, j+n, j+n]]
35
+ AB0 = np.swapaxes(AB0, 0, 2).reshape(len(i), 9)
36
+ J0_flat = np.linalg.solve(u, AB0)
37
+
38
+ J0 = np.empty((n, n, 3, 3), dtype=complex)
39
+ J0[*upi] = J0_flat[:, [0, 6, 5, 3, 1, 7, 8, 4, 2]].reshape(-1, 3, 3)
40
+ J0 += J0.swapaxes(0, 1)
41
+ J0[*dig] = 0.0
42
+
43
+ C = np.array([np.diag(a) for a in np.einsum('imx,ijxy,jmy->mi', V, 2*J0, V)])
44
+
45
+ return C
46
+
47
+ def get_J(H, kpoints, exchange):
48
+
49
+ n = int(H.shape[-1]/2)
50
+ upi = np.triu_indices(n)
51
+ dig = np.diag_indices(n)
52
+ i, j = upi
53
+
54
+ magmoms = exchange.magmoms()[np.unique(exchange.pairs)]
55
+ magmoms /= np.linalg.norm(magmoms, axis=-1).reshape(-1, 1)
56
+ u, V = get_coefficients(magmoms, indices=upi)
57
+
58
+ H0 = np.stack([1000*exchange._H_matrix(kpoints=np.zeros((1, 3)), with_DMI=True, with_Jani=True, u=u) for u in [ux, uy, uz]])[:, 0, :, :]
59
+ C = get_C(H0, u, V)
60
+ H[:, :, :n, :n] += C.reshape(3, 1, n, n)
61
+ H[:, :, n:, n:] += C.reshape(3, 1, n, n)
62
+
63
+ AB = H[:, :, [i, i, i+n], [j, j+n, j+n]]
64
+ AB[:, :, 2, :] = AB[:, ::-1, 2, :]
65
+ AB = np.moveaxis(AB, [2, 3], [1, 0]).reshape(len(i), 9, -1)
66
+
67
+ vectors = exchange.get_vectors()
68
+ exp_summand = np.exp( -2j*np.pi*vectors @ kpoints.T )
69
+ nAB = np.einsum('nik,ndk->nid', AB, exp_summand) / len(kpoints)
70
+
71
+ ii = np.where(i == j)
72
+ i0 = np.where(np.linalg.norm(vectors, axis=-1) == 0.0)
73
+ J = np.linalg.solve(u, nAB).swapaxes(1, 2)
74
+ J = J[:, :, [0, 6, 5, 3, 1, 7, 8, 4, 2]].reshape(len(i), -1, 3, 3)
75
+ J *= -1
76
+ J[ii] *= 2
77
+ J[i0] *= 0
78
+
79
+ return J
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TB2J
3
- Version: 0.8.2.7
3
+ Version: 0.8.2.8
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
@@ -58,8 +58,10 @@ TB2J/io_exchange/io_vampire.py
58
58
  TB2J/spinham/__init__.py
59
59
  TB2J/spinham/base_parser.py
60
60
  TB2J/spinham/constants.py
61
+ TB2J/spinham/h_matrix.py
61
62
  TB2J/spinham/hamiltonian.py
62
63
  TB2J/spinham/hamiltonian_terms.py
64
+ TB2J/spinham/obtain_J.py
63
65
  TB2J/spinham/plot.py
64
66
  TB2J/spinham/qsolver.py
65
67
  TB2J/spinham/spin_api.py
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  from setuptools import setup, find_packages
3
3
 
4
- __version__ = "0.8.2.7"
4
+ __version__ = "0.8.2.8"
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
 
@@ -1 +0,0 @@
1
- __version__ = "0.8.2.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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes