TB2J 0.9.12.6__py3-none-any.whl → 0.9.12.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of TB2J might be problematic. Click here for more details.

@@ -0,0 +1,276 @@
1
+ import os
2
+
3
+ import numpy as np
4
+
5
+
6
+ def _get_shell_index(cls, key):
7
+ """Determine shell index based on distance grouping.
8
+
9
+ Parameters
10
+ ----------
11
+ cls : SpinIO
12
+ SpinIO instance
13
+ key : tuple
14
+ (R, i, j) key for exchange parameter
15
+
16
+ Returns
17
+ -------
18
+ int
19
+ Shell index (1 for nearest neighbors, 2 for next nearest, etc.)
20
+ """
21
+ if not hasattr(cls, "_distance_shells"):
22
+ # Calculate all distances and group into shells
23
+ distances = []
24
+ for k in cls.exchange_Jdict:
25
+ if cls.distance_dict and k in cls.distance_dict:
26
+ distances.append(cls.distance_dict[k][1])
27
+
28
+ if distances:
29
+ # Sort distances and group by rounding to nearest 0.01 Å
30
+ sorted_distances = sorted(set(round(d * 100) for d in distances))
31
+ cls._distance_shells = {}
32
+ for shell_idx, dist_int in enumerate(sorted_distances, 1):
33
+ cls._distance_shells[dist_int / 100] = shell_idx
34
+ else:
35
+ cls._distance_shells = {}
36
+
37
+ if cls.distance_dict and key in cls.distance_dict:
38
+ distance = cls.distance_dict[key][1]
39
+ rounded_dist = round(distance * 100)
40
+ return cls._distance_shells.get(rounded_dist / 100, 1)
41
+
42
+ return 1
43
+
44
+
45
+ def write_espins(cls, path="TB2J_results/ESPInS"):
46
+ """Write ESPInS format input files.
47
+
48
+ Parameters
49
+ ----------
50
+ cls : SpinIO
51
+ SpinIO instance containing exchange parameters
52
+ path : str
53
+ Output directory path
54
+ """
55
+ if not os.path.exists(path):
56
+ os.makedirs(path)
57
+
58
+ write_espins_input(cls, os.path.join(path, "espins.in"))
59
+
60
+
61
+ def write_espins_input(cls, fname):
62
+ """Write the main ESPInS input file.
63
+
64
+ Parameters
65
+ ----------
66
+ cls : SpinIO
67
+ SpinIO instance
68
+ fname : str
69
+ Output filename
70
+ """
71
+ with open(fname, "w") as myfile:
72
+ # Write unit cell
73
+ myfile.write("! ESPInS input file generated by TB2J\n")
74
+ # myfile.write("! Compatible with ESPInS version > 1.0 \n")
75
+ myfile.write("! The unit cell in angstrom\n")
76
+ myfile.write("Begin Unit_Cell_Cart\n")
77
+ cell = cls.atoms.get_cell()
78
+ for i in range(3):
79
+ myfile.write(" " + " ".join(f"{x:12.8f}" for x in cell[i]) + "\n")
80
+ myfile.write("End Unit_Cell_Cart\n\n")
81
+
82
+ # Write atomic positions
83
+ myfile.write("! Atomic positions in reduced coordinates\n")
84
+ myfile.write("Begin Atoms_Frac\n")
85
+ scaled_positions = cls.atoms.get_scaled_positions()
86
+ symbols = cls.atoms.get_chemical_symbols()
87
+
88
+ for i, (symbol, pos) in enumerate(zip(symbols, scaled_positions)):
89
+ if cls.index_spin[i] >= 0: # Only magnetic atoms
90
+ myfile.write(
91
+ f" {symbol:<8} {pos[0]:10.7f} {pos[1]:10.7f} {pos[2]:10.7f} 1.00\n"
92
+ )
93
+ myfile.write("End Atoms_Frac\n\n\n")
94
+
95
+ # Write temperature settings (default values)
96
+ myfile.write("tem_start = 1\n")
97
+ myfile.write("tem_end = 30\n")
98
+ myfile.write("tems_num = 30\n")
99
+ # myfile.write("!! tems_mode = man\n")
100
+ # myfile.write("!! tems = 5.00 10.00 15.00 20.00\n\n")
101
+
102
+ # Write Monte Carlo parameters (default values)
103
+ myfile.write("! Pt = .True.\n")
104
+ myfile.write("! Pt_steps_swap = 40\n\n")
105
+
106
+ myfile.write("steps_warmup = 100000\n")
107
+ myfile.write("steps_mc = 100000\n")
108
+ myfile.write("steps_measure = 2\n\n")
109
+
110
+ myfile.write("initial_sconfig = ferro\n")
111
+ myfile.write("mcarlo_mode = random\n\n")
112
+
113
+ myfile.write("supercell_size = 10 10 1\n\n")
114
+
115
+ # Write Hamiltonian settings
116
+ myfile.write(" ## Hamiltonian\n")
117
+ myfile.write("Ham_bij = .False.\n")
118
+ myfile.write("Ham_jij_matrix = .True.\n")
119
+ myfile.write("! We don't have single ion anisotropy, put it to .False.\n")
120
+ myfile.write("Ham_singleion_matrix = .False.\n\n\n")
121
+
122
+ # Write single ion anisotropy matrix if available
123
+ # if cls.has_uniaxial_anistropy:
124
+ # myfile.write("! Don't put this block\n")
125
+ # myfile.write("!Begin SingleIon_Matrix\n")
126
+ # # Placeholder for single ion anisotropy
127
+ # myfile.write("@Axx=0.000 , Axy=-1.65e-07 , Axz=6e-08 , Ayx=-1.65e-07 , Ayy=7.73e-05 , Ayz=-1.5e-05 , Azx=6e-08 , Azz= 6.8e-05\n")
128
+ # myfile.write("!End SingleIon_Matrix\n\n")
129
+
130
+ # Write exchange parameters
131
+ myfile.write(
132
+ """! f1 is the fractional coordinate of atom i, and f2 is of atom j (rj+Rj). Then jij in eV, sh is index of shell, t1 is index of i, t2 is index of j (counting from 1). \n
133
+ !The convention of the Hamiltonian is H = - sum_<ij> Jij Si Sj, and i, j are ordererd so that there is no double counting (ij and ji). To convert from TB2J exchange.out (which has both ij and ji), multiply Jij by 2. \n
134
+ \n"""
135
+ )
136
+
137
+ if cls.has_exchange:
138
+ myfile.write("Begin Jij_parameters\n")
139
+
140
+ # Create a list of unique exchange parameters sorted by distance
141
+ exchange_list = []
142
+ # written_keys = set()
143
+
144
+ for key, jval in cls.exchange_Jdict.items():
145
+ R, i, j = key
146
+
147
+ # Skip if this is the symmetric counterpart of an already written pair
148
+ # symmetric_key = (tuple(-np.array(R)), j, i)
149
+ # if symmetric_key in written_keys:
150
+ # continue
151
+
152
+ # Get distance for sorting
153
+ distance = (
154
+ cls.distance_dict[key][1]
155
+ if cls.distance_dict and key in cls.distance_dict
156
+ else 0.0
157
+ )
158
+
159
+ exchange_list.append((distance, key, jval))
160
+ # written_keys.add(key)
161
+
162
+ # Sort by distance
163
+ exchange_list.sort(key=lambda x: x[0])
164
+
165
+ for distance, key, jval in exchange_list:
166
+ R, i, j = key
167
+ iatom = cls.iatom(i)
168
+ jatom = cls.iatom(j)
169
+
170
+ # Get fractional coordinates
171
+ pos_i = cls.atoms.get_scaled_positions()[iatom]
172
+ pos_j = cls.atoms.get_scaled_positions()[jatom]
173
+
174
+ # Calculate fractional coordinates for j+R
175
+ pos_jR = pos_j + R
176
+ # Determine shell index based on distance
177
+ shell = _get_shell_index(cls, key)
178
+
179
+ myfile.write(
180
+ f" f1= {pos_i[0]:10.6f}, {pos_i[1]:10.6f}, {pos_i[2]:10.6f}:f2= {pos_jR[0]:10.6f}, {pos_jR[1]:10.6f}, {pos_jR[2]:10.6f}:jij= {jval*2:10.8f}!:sh= {shell}!:t1= {i+1}:t2= {j+1}\n"
181
+ )
182
+
183
+ myfile.write("End Jij_parameters\n\n")
184
+
185
+ # Write exchange matrix if available
186
+ if cls.has_exchange:
187
+ myfile.write(
188
+ "! Each matrix element is corresponding to the previous block. The J tensor include the isotropic, anisotropic exchange and DMI. \n"
189
+ )
190
+ myfile.write("Begin Jij_matrix\n")
191
+
192
+ # Create a list of unique exchange parameters sorted by distance
193
+ exchange_list = []
194
+ # written_keys = set()
195
+
196
+ for key in cls.exchange_Jdict:
197
+ R, i, j = key
198
+
199
+ # Skip if this is the symmetric counterpart of an already written pair
200
+ # symmetric_key = (tuple(-np.array(R)), j, i)
201
+ # if symmetric_key in written_keys:
202
+ # continue
203
+
204
+ # Get distance for sorting
205
+ distance = (
206
+ cls.distance_dict[key][1]
207
+ if cls.distance_dict and key in cls.distance_dict
208
+ else 0.0
209
+ )
210
+
211
+ exchange_list.append((distance, key))
212
+ # written_keys.add(key)
213
+
214
+ # Sort by distance
215
+ exchange_list.sort(key=lambda x: x[0])
216
+
217
+ for distance, key in exchange_list:
218
+ R, i, j = key
219
+ # Get full J tensor
220
+ J_tensor = cls.get_J_tensor(i, j, R, Jiso=True, Jani=True, DMI=True) * 2
221
+
222
+ # Format matrix elements exactly as in the example
223
+ myfile.write(
224
+ f"Jxx={J_tensor[0, 0]:.8f}, Jxy={J_tensor[0, 1]:.8f}, Jxz={J_tensor[0, 2]:.8f}, Jyx={J_tensor[1, 0]:.8f}, Jyy={J_tensor[1, 1]:.8f}, Jyz={J_tensor[1, 2]:.8f}, Jzx={J_tensor[2, 0]:.8f}, Jzy={J_tensor[2, 1]:.8f}, Jzz={J_tensor[2, 2]:.8f}\n"
225
+ )
226
+
227
+ myfile.write("End Jij_matrix\n\n")
228
+
229
+ # Write biquadratic exchange if available
230
+ # if cls.has_biquadratic and cls.biquadratic_Jdict:
231
+ if False:
232
+ myfile.write("! Biquadratic, don't put it. \n")
233
+ myfile.write("Begin Bij_parameters\n")
234
+
235
+ # Create a list of unique biquadratic parameters sorted by distance
236
+ biquadratic_list = []
237
+ written_keys = set()
238
+
239
+ for key, bval in cls.biquadratic_Jdict.items():
240
+ R, i, j = key
241
+
242
+ # Skip if this is the symmetric counterpart of an already written pair
243
+ symmetric_key = (tuple(-np.array(R)), j, i)
244
+ if symmetric_key in written_keys:
245
+ continue
246
+
247
+ # Get distance for sorting
248
+ distance = (
249
+ cls.distance_dict[key][1]
250
+ if cls.distance_dict and key in cls.distance_dict
251
+ else 0.0
252
+ )
253
+
254
+ biquadratic_list.append((distance, key, bval))
255
+ written_keys.add(key)
256
+
257
+ # Sort by distance
258
+ biquadratic_list.sort(key=lambda x: x[0])
259
+
260
+ for distance, key, bval in biquadratic_list:
261
+ R, i, j = key
262
+ iatom = cls.iatom(i)
263
+ jatom = cls.iatom(j)
264
+
265
+ # Get fractional coordinates
266
+ pos_i = cls.atoms.get_scaled_positions()[iatom]
267
+ pos_j = cls.atoms.get_scaled_positions()[jatom]
268
+
269
+ # Calculate fractional coordinates for j+R
270
+ pos_jR = pos_j + np.dot(R, np.linalg.inv(cls.atoms.get_cell()))
271
+
272
+ myfile.write(
273
+ f" f1= {pos_i[0]:10.6f}, {pos_i[1]:10.6f}, {pos_i[2]:10.6f}:f2= {pos_jR[0]:10.6f}, {pos_jR[1]:10.6f}, {pos_jR[2]:10.6f}:bij= {bval:10.6f} !t1= {i+1}:t2= {j+1}\n"
274
+ )
275
+
276
+ myfile.write("End Bij_parameters\n")
@@ -18,12 +18,12 @@ from datetime import datetime
18
18
  import matplotlib.pyplot as plt
19
19
  import numpy as np
20
20
 
21
- from TB2J import __version__
22
21
  from TB2J.io_exchange.io_txt import write_Jq_info
23
22
  from TB2J.Jtensor import combine_J_tensor
24
23
  from TB2J.kpoints import monkhorst_pack
25
24
  from TB2J.spinham.spin_api import SpinModel
26
25
  from TB2J.utils import symbol_number
26
+ from TB2J.versioninfo import __version__
27
27
 
28
28
 
29
29
  class SpinIO(object):
@@ -149,6 +149,7 @@ class SpinIO(object):
149
149
  self.has_biquadratic = not (
150
150
  biquadratic_Jdict == {} or biquadratic_Jdict is None
151
151
  )
152
+
152
153
  self.biquadratic_Jdict = biquadratic_Jdict
153
154
 
154
155
  if NJT_ddict is not None:
@@ -459,9 +460,10 @@ Generation time: {now.strftime("%y/%m/%d %H:%M:%S")}
459
460
  if asr:
460
461
  iR0 = np.argmin(np.linalg.norm(self.Rlist, axis=1))
461
462
  assert np.linalg.norm(self.Rlist[iR0]) == 0
462
- sum_JR = np.sum(np.sum(Jmat, axis=0))
463
+ sum_JR = np.sum(np.sum(Jmat, axis=0), axis=0)
464
+ print(sum_JR)
463
465
  for i in range(n3):
464
- Jmat[iR0][i, i] -= sum_JRi[i]
466
+ Jmat[iR0][i, i] -= sum_JR[i]
465
467
  elif order == "ij":
466
468
  Jmat = np.zeros((nR, n, n), dtype=float)
467
469
  for iR, R in enumerate(self.Rlist):
@@ -521,6 +523,7 @@ Generation time: {now.strftime("%y/%m/%d %H:%M:%S")}
521
523
  self.write_multibinit(path=os.path.join(path, "Multibinit"))
522
524
  self.write_tom_format(path=os.path.join(path, "TomASD"))
523
525
  self.write_vampire(path=os.path.join(path, "Vampire"))
526
+ self.write_espins(path=os.path.join(path, "ESPInS"))
524
527
 
525
528
  self.plot_all(savefile=os.path.join(path, "JvsR.pdf"))
526
529
  # self.write_Jq(kmesh=[9, 9, 9], path=path)
@@ -684,6 +687,11 @@ Generation time: {now.strftime("%y/%m/%d %H:%M:%S")}
684
687
 
685
688
  write_uppasd(self, path=path)
686
689
 
690
+ def write_espins(self, path):
691
+ from TB2J.io_exchange.io_espins import write_espins
692
+
693
+ write_espins(self, path=path)
694
+
687
695
 
688
696
  def gen_distance_dict(ind_mag_atoms, atoms, Rlist):
689
697
  distance_dict = {}
@@ -63,7 +63,6 @@ def write_uppasd_exchange(cls, fname):
63
63
  d = np.dot(np.array(R), cls.atoms.get_cell()) + pos[j] - pos[i]
64
64
  myfile.write(
65
65
  "{i} {j} {Rx} {Ry} {Rz} {Jij}\n".format(
66
- IID=counter,
67
66
  i=i + 1,
68
67
  j=j + 1,
69
68
  Rx=d[0],
@@ -66,7 +66,7 @@ def write_vampire_unitcell_file(cls, fname):
66
66
 
67
67
  def write_vampire_mat_file(cls, fname):
68
68
  mat_tmpl = """#---------------------------------------------------
69
- # Material {id}
69
+ # Material {id}
70
70
  #---------------------------------------------------
71
71
  material[{id}]:material-name={name}
72
72
  material[{id}]:damping-constant={damping}
@@ -75,6 +75,8 @@ material[{id}]:uniaxial-anisotropy-constant={k1}
75
75
  material[{id}]:material-element={name}
76
76
  material[{id}]:initial-spin-direction = {spinat}
77
77
  material[{id}]:uniaxial-anisotropy-direction = {k1dir}
78
+ # The following line is required for vampire 5 and later.
79
+ material[{id}]:unit-cell-category = {id}
78
80
  #---------------------------------------------------
79
81
  """
80
82
  with open(fname, "w") as myfile:
TB2J/myTB.py CHANGED
@@ -1,15 +1,17 @@
1
- import os
2
- import numpy as np
3
1
  import copy
4
- from scipy.linalg import eigh
5
- from scipy.sparse import csr_matrix
6
- from scipy.io import netcdf_file
2
+ import os
7
3
  from collections import defaultdict
8
4
 
5
+ import numpy as np
6
+
9
7
  # from tbmodels import Model
10
8
  from ase.atoms import Atoms
9
+ from scipy.io import netcdf_file
10
+ from scipy.linalg import eigh
11
+ from scipy.sparse import csr_matrix
12
+
11
13
  from TB2J.utils import auto_assign_basis_name
12
- from TB2J.wannier import parse_ham, parse_xyz, parse_atoms, parse_tb
14
+ from TB2J.wannier import parse_atoms, parse_ham, parse_tb, parse_xyz
13
15
 
14
16
 
15
17
  class AbstractTB:
@@ -187,9 +189,7 @@ class MyTB(AbstractTB):
187
189
  if os.path.exists(tb_fname):
188
190
  xcart, nbasis, data, R_degens = parse_tb(fname=tb_fname)
189
191
  else:
190
- nbasis, data, R_degens = parse_ham(
191
- fname=os.path.join(path, prefix + "_hr.dat")
192
- )
192
+ nbasis, data, R_degens = parse_ham(fname=hr_fname)
193
193
  xcart, _, _ = parse_xyz(fname=os.path.join(path, prefix + "_centres.xyz"))
194
194
 
195
195
  if atoms is None:
@@ -237,7 +237,7 @@ class MyTB(AbstractTB):
237
237
  return m
238
238
 
239
239
  def gen_ham(self, k, convention=2):
240
- """
240
+ r"""
241
241
  generate hamiltonian matrix at k point.
242
242
  H_k( i, j)=\sum_R H_R(i, j)^phase.
243
243
  There are two conventions,
@@ -451,7 +451,7 @@ class MyTB(AbstractTB):
451
451
  nbasis = root.dimensions["nbasis"]
452
452
  nspin = root.dimensions["nspin"]
453
453
  ndim = root.dimensions["ndim"]
454
- natom = root.dimensions["natom"]
454
+ _natom = root.dimensions["natom"]
455
455
  Rlist = root.variables["R"][:]
456
456
  mdata_real = root.variables["data_real"][:]
457
457
  mdata_imag = root.variables["data_imag"][:]
TB2J/pauli.py CHANGED
@@ -59,7 +59,7 @@ def pauli_decomp2(M):
59
59
  )
60
60
 
61
61
 
62
- def pauli_sigma_norm(M):
62
+ def pauli_sigma_norm_old(M):
63
63
  MI, Mx, My, Mz = pauli_decomp2(M)
64
64
  return np.linalg.norm([Mx, My, Mz])
65
65
 
@@ -134,7 +134,7 @@ def pauli_block(M, idim):
134
134
  return tmp
135
135
 
136
136
 
137
- def pauli_block_all(M):
137
+ def pauli_block_all_old(M):
138
138
  MI = (M[::2, ::2] + M[1::2, 1::2]) / 2.0
139
139
  Mx = (M[::2, 1::2] + M[1::2, ::2]) / 2.0
140
140
  # Note that this is not element wise product with sigma_y but dot product
@@ -143,6 +143,28 @@ def pauli_block_all(M):
143
143
  return MI, Mx, My, Mz
144
144
 
145
145
 
146
+ def pauli_block_all(array):
147
+ A00 = array[..., ::2, ::2]
148
+ A01 = array[..., ::2, 1::2]
149
+ A10 = array[..., 1::2, ::2]
150
+ A11 = array[..., 1::2, 1::2]
151
+ n2 = array.shape[-1] // 2
152
+
153
+ out_dtype = np.result_type(array.dtype, np.complex64)
154
+ block = np.empty((*array.shape[:-2], 4, n2, n2), dtype=out_dtype)
155
+
156
+ np.add(A00, A11, out=block[..., 0, :, :])
157
+ block[..., 0, :, :] *= 0.5
158
+ np.add(A01, A10, out=block[..., 1, :, :])
159
+ block[..., 1, :, :] *= 0.5
160
+ np.subtract(A01, A10, out=block[..., 2, :, :])
161
+ block[..., 2, :, :] *= 0.5j
162
+ np.subtract(A00, A11, out=block[..., 3, :, :])
163
+ block[..., 3, :, :] *= 0.5
164
+
165
+ return block
166
+
167
+
146
168
  def gather_pauli_blocks(MI, Mx, My, Mz, coeffs=[1.0, 1.0, 1.0, 1.0]):
147
169
  """
148
170
  Gather the I, x, y, z component of a matrix.
@@ -212,3 +234,11 @@ def pauli_block_sigma_norm(M):
212
234
  evec = np.array((ex, ey, ez))
213
235
  evec = evec / np.linalg.norm(evec)
214
236
  return Mx * evec[0] + My * evec[1] + Mz * evec[2]
237
+
238
+
239
+ def pauli_sigma_norm(array):
240
+ block = pauli_block_all(array)[..., 1:, :, :]
241
+ E = np.trace(block, axis1=-2, axis2=-1)
242
+ E /= np.linalg.norm(E, axis=-1, keepdims=True)
243
+ np.multiply(block, E[..., None, None], out=block)
244
+ return block.sum(axis=-3)
TB2J/plot.py CHANGED
@@ -1,11 +1,12 @@
1
+ import argparse
2
+ import os
3
+
1
4
  import matplotlib.pyplot as plt
2
- from TB2J.spinham.spin_api import SpinModel
3
- from TB2J.io_exchange.io_exchange import SpinIO
4
5
  import numpy as np
5
- from TB2J import __version__
6
+
7
+ from TB2J.io_exchange.io_exchange import SpinIO
6
8
  from TB2J.spinham.qsolver import QSolverASEWrapper
7
- import argparse
8
- import os
9
+ from TB2J.spinham.spin_api import SpinModel
9
10
 
10
11
 
11
12
  def write_eigen(qmesh, gamma=True, path="./", output_fname="EigenJq.txt", **kwargs):
@@ -25,7 +26,7 @@ def plot_magnon_band(
25
26
  Jq=False,
26
27
  kpath_fname="exchange_kpth.txt",
27
28
  ax=None,
28
- **kwargs
29
+ **kwargs,
29
30
  ):
30
31
  m = SpinModel(fname=fname, sc_matrix=None)
31
32
  m.set_ham(**kwargs)
@@ -57,7 +58,7 @@ def plot_magnon_dos(
57
58
  txt_filename="magnon_dos.txt",
58
59
  Jq=False,
59
60
  ax=None,
60
- **kwargs
61
+ **kwargs,
61
62
  ):
62
63
  ffname = os.path.join(path, "exchange.xml")
63
64
  if not (os.path.exists(ffname) and os.path.isfile(ffname)):
TB2J/rotate_atoms.py CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env python3
2
2
  import copy
3
- from ase.io import read, write
3
+
4
4
  import numpy as np
5
- from TB2J.tensor_rotate import Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz
5
+ from ase.io import read, write
6
+ from TB2J.tensor_rotate import Rzx, Rzy, Rzz
6
7
 
7
8
 
8
9
  def rotate_atom_xyz(atoms, noncollinear=False):
@@ -15,14 +16,16 @@ def rotate_atom_xyz(atoms, noncollinear=False):
15
16
  will be generated.
16
17
  """
17
18
 
19
+ yield atoms
18
20
  rotation_axes = [(1, 0, 0), (0, 1, 0)]
19
21
  if noncollinear:
20
22
  rotation_axes += [(1, 1, 0), (1, 0, 1), (0, 1, 1)]
21
-
23
+
22
24
  for axis in rotation_axes:
23
25
  rotated_atoms = copy.deepcopy(atoms)
24
26
  rotated_atoms.rotate(90, axis, rotate_cell=True)
25
27
  yield rotated_atoms
28
+ yield atoms
26
29
 
27
30
 
28
31
  def rotate_atom_spin_one_rotation(atoms, Rotation):
@@ -109,7 +112,7 @@ def rotate_xyz(fname, ftype="xyz", noncollinear=False):
109
112
  rotated = rotate_atom_xyz(atoms, noncollinear=noncollinear)
110
113
 
111
114
  for i, rotated_atoms in enumerate(rotated):
112
- write(f"atoms_{i+1}.{ftype}", rotated_atoms)
113
- write(f"atoms_0.{ftype}", atoms)
114
-
115
- print(f"The output has been written to the atoms_i.{ftype} files. atoms_0.{ftype} contains the reference structure.")
115
+ write(f"atoms_{i}.{ftype}", rotated_atoms)
116
+ print(
117
+ f"The output has been written to the atoms_i.{ftype} files. atoms_0.{ftype} contains the reference structure."
118
+ )
@@ -19,7 +19,6 @@ from .plot import group_band_path
19
19
  from ase.cell import Cell
20
20
  from .qsolver import QSolver
21
21
  import json
22
- import os
23
22
 
24
23
 
25
24
  class NumpyEncoder(json.JSONEncoder):
TB2J/symmetrize_J.py CHANGED
@@ -33,7 +33,7 @@ class TB2JSymmetrizer:
33
33
  print("Symmetry found:")
34
34
  print(finder.spacegroup)
35
35
  print("-" * 30)
36
- self.pgdict = finder.get_symmetry_pair_group_dict()
36
+ self.pgdict = finder.get_symmetry_pair_list_dict()
37
37
  self.exc = exc
38
38
  self.new_exc = copy.deepcopy(exc)
39
39
  self.Jonly = Jonly
@@ -48,7 +48,7 @@ class TB2JSymmetrizer:
48
48
  symJdict = {}
49
49
  # Jdict = self.exc.exchange_Jdict
50
50
  # ngroup = self.pgdict
51
- for pairgroup in self.pgdict.groups:
51
+ for pairgroup in self.pgdict.pairlists:
52
52
  ijRs = pairgroup.get_all_ijR()
53
53
  ijRs_spin = [self.exc.ijR_index_atom_to_spin(*ijR) for ijR in ijRs]
54
54
  Js = [self.exc.get_J(*ijR_spin) for ijR_spin in ijRs_spin]
TB2J/tensor_rotate.py CHANGED
@@ -1,7 +1,6 @@
1
1
  import numpy as np
2
- import scipy as sp
3
2
  from scipy.spatial.transform import Rotation
4
- from numpy.linalg import norm, det
3
+ from numpy.linalg import norm
5
4
 
6
5
 
7
6
  # Rotation from a to b
@@ -2,10 +2,8 @@
2
2
  parse the tb files in Wannier90
3
3
  """
4
4
 
5
- import os
6
5
  import re
7
6
  import numpy as np
8
- from typing import List, Tuple, Dict
9
7
 
10
8
 
11
9
  def ssrline(file):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TB2J
3
- Version: 0.9.12.6
3
+ Version: 0.9.12.17
4
4
  Summary: TB2J: First principle to Heisenberg exchange J using tight-binding Green function method
5
5
  Author-email: Xu He <mailhexu@gmail.com>
6
6
  Maintainer-email: Xu He <mailhexu@gmail.com>
@@ -23,30 +23,30 @@ Classifier: Intended Audience :: Science/Research
23
23
  Classifier: Topic :: Scientific/Engineering :: Chemistry
24
24
  Classifier: Topic :: Scientific/Engineering :: Physics
25
25
  Classifier: License :: OSI Approved :: BSD License
26
- Requires-Python: >=3.6
27
26
  Description-Content-Type: text/markdown
28
27
  License-File: LICENSE
29
- Requires-Dist: numpy<2.0
28
+ Requires-Dist: numpy
30
29
  Requires-Dist: scipy
31
30
  Requires-Dist: matplotlib
32
31
  Requires-Dist: ase>=3.19
33
32
  Requires-Dist: tqdm
34
33
  Requires-Dist: pathos
35
34
  Requires-Dist: packaging>=20.0
36
- Requires-Dist: HamiltonIO>=0.2.4
35
+ Requires-Dist: HamiltonIO>=0.2.8
37
36
  Requires-Dist: pre-commit
38
- Requires-Dist: sympair>0.1.0
37
+ Requires-Dist: sympair>0.1.1
39
38
  Requires-Dist: tomli>=2.0.0
40
39
  Requires-Dist: tomli-w>=1.0.0
40
+ Requires-Dist: typing_extensions
41
41
  Provides-Extra: siesta
42
42
  Requires-Dist: sisl>=0.9.0; extra == "siesta"
43
43
  Requires-Dist: netcdf4; extra == "siesta"
44
44
  Provides-Extra: lawaf
45
- Requires-Dist: lawaf==0.2.3; extra == "lawaf"
45
+ Requires-Dist: lawaf>=0.2.3; extra == "lawaf"
46
46
  Provides-Extra: all
47
47
  Requires-Dist: sisl>=0.9.0; extra == "all"
48
48
  Requires-Dist: netcdf4; extra == "all"
49
- Requires-Dist: lawaf==0.2.3; extra == "all"
49
+ Requires-Dist: lawaf>=0.2.3; extra == "all"
50
50
  Dynamic: license-file
51
51
 
52
52
  [![Python application](https://github.com/mailhexu/TB2J/actions/workflows/python-app.yml/badge.svg)](https://github.com/mailhexu/TB2J/actions/workflows/python-app.yml)