TB2J 0.9.5rc0__py3-none-any.whl → 0.9.7rc0__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.
Files changed (59) hide show
  1. TB2J/MAE.py +144 -27
  2. TB2J/MAEGreen.py +84 -0
  3. TB2J/anisotropy.py +672 -0
  4. TB2J/contour.py +8 -0
  5. TB2J/exchange.py +38 -172
  6. TB2J/exchangeCL2.py +11 -13
  7. TB2J/exchange_params.py +213 -0
  8. TB2J/green.py +62 -27
  9. TB2J/interfaces/__init__.py +12 -0
  10. TB2J/interfaces/abacus/__init__.py +4 -0
  11. TB2J/{abacus → interfaces/abacus}/abacus_api.py +3 -3
  12. TB2J/{abacus → interfaces/abacus}/abacus_wrapper.py +11 -8
  13. TB2J/{abacus → interfaces/abacus}/gen_exchange_abacus.py +5 -3
  14. TB2J/{abacus → interfaces/abacus}/orbital_api.py +4 -4
  15. TB2J/{abacus → interfaces/abacus}/stru_api.py +11 -11
  16. TB2J/{abacus → interfaces/abacus}/test_read_HRSR.py +0 -1
  17. TB2J/{abacus → interfaces/abacus}/test_read_stru.py +5 -3
  18. TB2J/interfaces/gpaw_interface.py +54 -0
  19. TB2J/interfaces/lawaf_interface.py +129 -0
  20. TB2J/interfaces/manager.py +23 -0
  21. TB2J/interfaces/siesta_interface.py +202 -0
  22. TB2J/interfaces/wannier90_interface.py +115 -0
  23. TB2J/io_exchange/io_exchange.py +21 -7
  24. TB2J/io_merge.py +2 -1
  25. TB2J/mathutils/fermi.py +11 -6
  26. TB2J/mathutils/lowdin.py +12 -2
  27. TB2J/mathutils/rotate_spin.py +222 -4
  28. TB2J/pauli.py +11 -3
  29. TB2J/symmetrize_J.py +120 -0
  30. TB2J/utils.py +82 -1
  31. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/abacus2J.py +5 -4
  32. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/siesta2J.py +21 -4
  33. TB2J-0.9.7rc0.data/scripts/wann2J.py +96 -0
  34. {TB2J-0.9.5rc0.dist-info → TB2J-0.9.7rc0.dist-info}/METADATA +5 -3
  35. {TB2J-0.9.5rc0.dist-info → TB2J-0.9.7rc0.dist-info}/RECORD +47 -46
  36. {TB2J-0.9.5rc0.dist-info → TB2J-0.9.7rc0.dist-info}/WHEEL +1 -1
  37. TB2J-0.9.7rc0.dist-info/entry_points.txt +3 -0
  38. TB2J/abacus/MAE.py +0 -320
  39. TB2J/abacus/__init__.py +0 -1
  40. TB2J/abacus/occupations.py +0 -278
  41. TB2J/cut_cell.py +0 -82
  42. TB2J/io_exchange/io_pickle.py +0 -0
  43. TB2J/manager.py +0 -445
  44. TB2J/mathutils.py +0 -12
  45. TB2J/patch.py +0 -50
  46. TB2J/spinham/h_matrix.py +0 -68
  47. TB2J/spinham/obtain_J.py +0 -79
  48. TB2J/supercell.py +0 -532
  49. TB2J-0.9.5rc0.data/scripts/wann2J.py +0 -194
  50. TB2J/{abacus → interfaces/abacus}/test_density_matrix.py +1 -1
  51. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_downfold.py +0 -0
  52. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_eigen.py +0 -0
  53. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_magnon.py +0 -0
  54. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_magnon_dos.py +0 -0
  55. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_merge.py +0 -0
  56. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_rotate.py +0 -0
  57. {TB2J-0.9.5rc0.data → TB2J-0.9.7rc0.data}/scripts/TB2J_rotateDM.py +0 -0
  58. {TB2J-0.9.5rc0.dist-info → TB2J-0.9.7rc0.dist-info}/LICENSE +0 -0
  59. {TB2J-0.9.5rc0.dist-info → TB2J-0.9.7rc0.dist-info}/top_level.txt +0 -0
TB2J/exchange.py CHANGED
@@ -1,91 +1,23 @@
1
- from collections import defaultdict, OrderedDict
2
1
  import os
3
- import numpy as np
4
2
  import pickle
5
- from dataclasses import dataclass
6
- import yaml
7
- from TB2J.green import TBGreen
8
- from TB2J.pauli import pauli_block_all, pauli_block_sigma_norm, pauli_mat
9
- from TB2J.utils import symbol_number, kmesh_to_R
10
- from TB2J.io_exchange import SpinIO
3
+ from collections import OrderedDict, defaultdict
4
+
5
+ import numpy as np
11
6
  from tqdm import tqdm
12
- from TB2J.external import p_map
7
+
13
8
  from TB2J.contour import Contour
14
- from TB2J.utils import simpson_nonuniform, trapezoidal_nonuniform, split_symbol_number
9
+ from TB2J.exchange_params import ExchangeParams
10
+ from TB2J.external import p_map
11
+ from TB2J.green import TBGreen
12
+ from TB2J.io_exchange import SpinIO
15
13
  from TB2J.orbmap import map_orbs_matrix
16
- from typing import List, Tuple
17
-
18
-
19
- @dataclass
20
- class ExchangeParams:
21
- """
22
- A class to store the parameters for exchange calculation.
23
- """
24
-
25
- efermi: float
26
- basis: list = None
27
- magnetic_elements: list = None
28
- include_orbs = {}
29
- _kmesh = [4, 4, 4]
30
- emin: float = -15
31
- emax: float = 0.05
32
- nz: int = 100
33
- exclude_orbs = []
34
- ne: int = None
35
- Rcut: float = None
36
- _use_cache: bool = False
37
- np: int = 1
38
- description: str = ""
39
- write_density_matrix: bool = False
40
- orb_decomposition: bool = False
41
- output_path: str = "TB2J_results"
42
- mae_angles = None
43
-
44
- def __init__(
45
- self,
46
- efermi=-10.0,
47
- basis=None,
48
- magnetic_elements=None,
49
- include_orbs=None,
50
- kmesh=[4, 4, 4],
51
- emin=-15,
52
- emax=0.05,
53
- nz=100,
54
- exclude_orbs=[],
55
- ne=None,
56
- Rcut=None,
57
- use_cache=False,
58
- np=1,
59
- description="",
60
- write_density_matrix=False,
61
- orb_decomposition=False,
62
- output_path="TB2J_results",
63
- ):
64
- self.efermi = efermi
65
- self.basis = basis
66
- self.magnetic_elements = magnetic_elements
67
- self.include_orbs = include_orbs
68
- self._kmesh = kmesh
69
- self.emin = emin
70
- self.emax = emax
71
- self.nz = nz
72
- self.exclude_orbs = exclude_orbs
73
- self.ne = ne
74
- self.Rcut = Rcut
75
- self._use_cache = use_cache
76
- self.np = np
77
- self.description = description
78
- self.write_density_matrix = write_density_matrix
79
- self.orb_decomposition = orb_decomposition
80
- self.output_path = output_path
81
-
82
- def set_params(self, **kwargs):
83
- for key, val in kwargs.items():
84
- setattr(self, key, val)
85
-
86
- def save_to_yaml(self, fname):
87
- with open(fname, "w") as myfile:
88
- yaml.dump(self.__dict__, myfile)
14
+ from TB2J.pauli import pauli_block_all, pauli_block_sigma_norm
15
+ from TB2J.utils import (
16
+ kmesh_to_R,
17
+ simpson_nonuniform,
18
+ symbol_number,
19
+ trapezoidal_nonuniform,
20
+ )
89
21
 
90
22
 
91
23
  class Exchange(ExchangeParams):
@@ -107,10 +39,7 @@ class Exchange(ExchangeParams):
107
39
  self._prepare_distance()
108
40
 
109
41
  # whether to calculate J and DMI with NJt method.
110
- self.calc_NJt = True
111
42
  # self._prepare_NijR()
112
- self.Ddict_NJT = None
113
- self.Jdict_NJT = None
114
43
  self._is_collinear = True
115
44
  self.has_elistc = False
116
45
  self._clean_tbmodels()
@@ -128,8 +57,9 @@ class Exchange(ExchangeParams):
128
57
  pass
129
58
 
130
59
  def _clean_tbmodels(self):
131
- del self.tbmodel
132
- del self.G.tbmodel
60
+ # del self.tbmodel
61
+ # del self.G.tbmodel
62
+ pass
133
63
 
134
64
  def _prepare_kmesh(self, kmesh):
135
65
  for k in kmesh:
@@ -219,9 +149,9 @@ class Exchange(ExchangeParams):
219
149
  raise ValueError(
220
150
  f"""The number of spin-orbitals for atom {iatom} is not even,
221
151
  {nsorb} spin-orbitals are found near this atom.
222
- which means the spin up/down does not have same number of orbitals.
152
+ which means the spin up/down does not have same number of orbitals.
223
153
  This is often because the Wannier functions are wrongly defined,
224
- or badly localized. Please check the Wannier centers in the Wannier90 output file.
154
+ or badly localized. Please check the Wannier centers in the Wannier90 output file.
225
155
  """
226
156
  )
227
157
  self._spin_dict = {}
@@ -330,13 +260,17 @@ class ExchangeNCL(Exchange):
330
260
  """
331
261
  self.tbmodel = tbmodels
332
262
  self.backend_name = self.tbmodel.name
263
+ print(self.kmesh)
333
264
  self.G = TBGreen(
334
- self.tbmodel,
335
- self.kmesh,
336
- self.efermi,
265
+ tbmodel=self.tbmodel,
266
+ kmesh=self.kmesh,
267
+ gamma=True,
268
+ efermi=self.efermi,
337
269
  use_cache=self._use_cache,
338
- nproc=self.np,
270
+ nproc=self.nproc,
339
271
  )
272
+ if self.efermi is None:
273
+ self.efermi = self.G.efermi
340
274
  self.norb = self.G.norb
341
275
  self.nbasis = self.G.nbasis
342
276
  # self.rho = np.zeros((self.nbasis, self.nbasis), dtype=complex)
@@ -344,7 +278,11 @@ class ExchangeNCL(Exchange):
344
278
  self.A_ijR_list = defaultdict(lambda: [])
345
279
  self.A_ijR = defaultdict(lambda: np.zeros((4, 4), dtype=complex))
346
280
  self.A_ijR_orb = dict()
347
- self.HR0 = self.G.H0
281
+ # self.HR0 = self.tbmodel.get_H0()
282
+ if hasattr(self.tbmodel, "get_H0"):
283
+ self.HR0 = self.tbmodel.get_H0()
284
+ else:
285
+ self.HR0 = self.G.H0
348
286
  self._is_collinear = False
349
287
  self.Pdict = {}
350
288
  if self.write_density_matrix:
@@ -477,7 +415,7 @@ class ExchangeNCL(Exchange):
477
415
  if self.orb_decomposition:
478
416
  for key, val in self.A_ijR_orb.items():
479
417
  R, iatom, jatom = key
480
- Rm = tuple(-x for x in R)
418
+ # Rm = tuple(-x for x in R)
481
419
  # valm = self.A_ijR_orb[(Rm, jatom, iatom)]
482
420
  ni = self.norb_reduced[iatom]
483
421
  nj = self.norb_reduced[jatom]
@@ -613,53 +551,6 @@ class ExchangeNCL(Exchange):
613
551
  self.rho_dict = rho
614
552
  return self.rho_dict
615
553
 
616
- def calculate_DMI_NJT(self):
617
- """
618
- calculate exchange and DMI with the
619
- This did not work and should be removed.
620
- """
621
- Ddict_NJT = {}
622
- Jdict_NJT = {}
623
- for R in self.short_Rlist:
624
- N = self.N[tuple(-np.array(R))] # density matrix
625
- t = self.tbmodel.get_hamR(R) # hopping parameter
626
- for iatom in self.ind_mag_atoms:
627
- orbi = self.iorb(iatom)
628
- ni = len(orbi)
629
- for jatom in self.ind_mag_atoms:
630
- orbj = self.iorb(jatom)
631
- nj = len(orbj)
632
- Nji = N[np.ix_(orbj, orbi)]
633
- tij = t[np.ix_(orbi, orbj)]
634
- D = np.zeros(3, dtype=float)
635
- J = np.zeros(3, dtype=float)
636
- for dim in range(3):
637
- # S_i = pauli_mat(ni, dim +
638
- # 1) #*self.rho[np.ix_(orbi, orbi)]
639
- # S_j = pauli_mat(nj, dim +
640
- # 1) #*self.rho[np.ix_(orbj, orbj)]
641
- # TODO: Note that rho is complex, not the imaginary part
642
- S_i = pauli_mat(ni, dim + 1) * self.rho[np.ix_(orbi, orbi)]
643
- S_j = pauli_mat(nj, dim + 1) * self.rho[np.ix_(orbj, orbj)]
644
-
645
- # [S, t]+ = Si tij + tij Sj, where
646
- # Si and Sj are the spin operator
647
- # Here we do not have L operator, so J-> S
648
- Jt = np.matmul(S_i, tij) + np.matmul(tij, S_j)
649
-
650
- Jtminus = np.matmul(S_i, tij) - np.matmul(tij, S_j)
651
- # D = -1/2 Tr Nji [J, tij]
652
- # Trace over spin and orb
653
- D[dim] = -0.5 * np.imag(np.trace(np.matmul(Nji, Jt)))
654
- J[dim] = -0.5 * np.imag(np.trace(np.matmul(Nji, Jtminus)))
655
- ispin = self.ispin(iatom)
656
- jspin = self.ispin(jatom)
657
- Ddict_NJT[(R, ispin, jspin)] = D
658
- Jdict_NJT[(R, ispin, jspin)] = J
659
- self.Jdict_NJT = Jdict_NJT
660
- self.Ddict_NJT = Ddict_NJT
661
- return Ddict_NJT
662
-
663
554
  def integrate(self, AijRs, AijRs_orb=None, method="simpson"):
664
555
  """
665
556
  AijRs: a list of AijR,
@@ -682,35 +573,14 @@ class ExchangeNCL(Exchange):
682
573
 
683
574
  def get_quantities_per_e(self, e):
684
575
  Gk_all = self.G.get_Gk_all(e)
685
- mae = self.get_mae_kspace(Gk_all)
576
+ # mae = self.get_mae_kspace(Gk_all)
577
+ mae = None
686
578
  # TODO: get the MAE from Gk_all
687
579
  GR = self.G.get_GR(self.short_Rlist, energy=e, get_rho=False, Gk_all=Gk_all)
688
580
  # TODO: define the quantities for one energy.
689
581
  AijR, AijR_orb = self.get_all_A(GR)
690
582
  return dict(AijR=AijR, AijR_orb=AijR_orb, mae=mae)
691
583
 
692
- def get_mae_kspace(self, Gk_all):
693
- """
694
- get the MAE from Gk_all
695
- TODO: This is only a place holder.
696
- """
697
- return None
698
- Hso_k = self.model.get_Hso_k(k)
699
- mae_e = np.zeros(len(self.mae_angles), dtype=complex)
700
- # rotate the Hso_k to angles
701
- for ik, k in enumerate(self.G.kpoints):
702
- Gk = Gk_all[ik]
703
- for i_angle, angle in enumerate(self.mae_angles):
704
- # TODO: implementa rotate_H
705
- Hso_k_rot = rotate_H(Hso_k, angle)
706
- mae_e[i_angle] = Gk @ Hso_k @ Gk @ Hso_k
707
- return mae_e
708
-
709
- def get_mae_rspace(self, GR):
710
- """
711
- get the MAE from GR
712
- """
713
-
714
584
  def save_AijR(self, AijRs, fname):
715
585
  result = dict(path=self.contour.path, AijRs=AijRs)
716
586
  with open(fname, "wb") as myfile:
@@ -734,9 +604,9 @@ class ExchangeNCL(Exchange):
734
604
  self.validate()
735
605
 
736
606
  npole = len(self.contour.path)
737
- if self.np > 1:
607
+ if self.nproc > 1:
738
608
  results = p_map(
739
- self.get_quantities_per_e, self.contour.path, num_cpus=self.np
609
+ self.get_quantities_per_e, self.contour.path, num_cpus=self.nproc
740
610
  )
741
611
  else:
742
612
  results = map(
@@ -799,8 +669,6 @@ class ExchangeNCL(Exchange):
799
669
  Jani_dict=self.Jani,
800
670
  DMI_orb=self.DMI_orb,
801
671
  Jani_orb=self.Jani_orb,
802
- NJT_Jdict=self.Jdict_NJT,
803
- NJT_ddict=self.Ddict_NJT,
804
672
  biquadratic_Jdict=self.B,
805
673
  debug_dict=self.debug_dict,
806
674
  description=self.description,
@@ -839,8 +707,6 @@ class ExchangeCL(ExchangeNCL):
839
707
  distance_dict=self.distance_dict,
840
708
  exchange_Jdict=self.exchange_Jdict,
841
709
  dmi_ddict=None,
842
- NJT_Jdict=None,
843
- NJT_ddict=None,
844
710
  biquadratic_Jdict=self.B,
845
711
  description=self.description,
846
712
  )
TB2J/exchangeCL2.py CHANGED
@@ -20,18 +20,18 @@ class ExchangeCL2(ExchangeCL):
20
20
  self.tbmodel_up, self.tbmodel_dn = tbmodels
21
21
  self.backend_name = self.tbmodel_up.name
22
22
  self.Gup = TBGreen(
23
- self.tbmodel_up,
24
- self.kmesh,
25
- self.efermi,
23
+ tbmodel=self.tbmodel_up,
24
+ kmesh=self.kmesh,
25
+ efermi=self.efermi,
26
26
  use_cache=self._use_cache,
27
- nproc=self.np,
27
+ nproc=self.nproc,
28
28
  )
29
29
  self.Gdn = TBGreen(
30
- self.tbmodel_dn,
31
- self.kmesh,
32
- self.efermi,
30
+ tbmodel=self.tbmodel_dn,
31
+ kmesh=self.kmesh,
32
+ efermi=self.efermi,
33
33
  use_cache=self._use_cache,
34
- nproc=self.np,
34
+ nproc=self.nproc,
35
35
  )
36
36
  if self.write_density_matrix:
37
37
  self.Gup.write_rho_R(
@@ -247,15 +247,15 @@ class ExchangeCL2(ExchangeCL):
247
247
  print("Green's function Calculation started.")
248
248
 
249
249
  npole = len(self.contour.path)
250
- if self.np == 1:
250
+ if self.nproc == 1:
251
251
  results = map(
252
252
  self.get_quantities_per_e, tqdm(self.contour.path, total=npole)
253
253
  )
254
254
  else:
255
- # pool = ProcessPool(nodes=self.np)
255
+ # pool = ProcessPool(nodes=self.nproc)
256
256
  # results = pool.map(self.get_AijR_rhoR ,self.contour.path)
257
257
  results = p_map(
258
- self.get_quantities_per_e, self.contour.path, num_cpus=self.np
258
+ self.get_quantities_per_e, self.contour.path, num_cpus=self.nproc
259
259
  )
260
260
  for i, result in enumerate(results):
261
261
  Jorb_list = result["Jorb_list"]
@@ -265,8 +265,6 @@ class ExchangeCL2(ExchangeCL):
265
265
  key = (R, iatom, jatom)
266
266
  self.Jorb_list[key].append(Jorb_list[key])
267
267
  self.JJ_list[key].append(JJ_list[key])
268
- if self.np > 1:
269
- pass
270
268
  self.integrate()
271
269
  self.get_rho_atom()
272
270
  self.A_to_Jtensor()
@@ -0,0 +1,213 @@
1
+ import argparse
2
+ from dataclasses import dataclass
3
+
4
+ import yaml
5
+
6
+ __all__ = ["ExchangeParams", "add_exchange_args_to_parser", "parser_argument_to_dict"]
7
+
8
+
9
+ @dataclass
10
+ class ExchangeParams:
11
+ """
12
+ A class to store the parameters for exchange calculation.
13
+ """
14
+
15
+ efermi: float
16
+ basis = []
17
+ magnetic_elements = []
18
+ include_orbs = {}
19
+ _kmesh = [4, 4, 4]
20
+ emin: float = -15
21
+ emax: float = 0.05
22
+ nz: int = 100
23
+ exclude_orbs = []
24
+ ne: int = 0
25
+ Rcut: float = None
26
+ _use_cache: bool = False
27
+ nproc: int = 1
28
+ description: str = ""
29
+ write_density_matrix: bool = False
30
+ orb_decomposition: bool = False
31
+ output_path: str = "TB2J_results"
32
+ mae_angles = None
33
+ orth = False
34
+
35
+ def __init__(
36
+ self,
37
+ efermi=-10.0,
38
+ basis=None,
39
+ magnetic_elements=None,
40
+ include_orbs=None,
41
+ kmesh=[4, 4, 4],
42
+ emin=-15,
43
+ emax=0.05,
44
+ nz=100,
45
+ ne=None,
46
+ Rcut=None,
47
+ use_cache=False,
48
+ nproc=1,
49
+ description="",
50
+ write_density_matrix=False,
51
+ orb_decomposition=False,
52
+ output_path="TB2J_results",
53
+ exclude_orbs=[],
54
+ mae_angles=None,
55
+ orth=False,
56
+ ):
57
+ self.efermi = efermi
58
+ self.basis = basis
59
+ self.magnetic_elements = magnetic_elements
60
+ self.include_orbs = include_orbs
61
+ self._kmesh = kmesh
62
+ self.emin = emin
63
+ self.emax = emax
64
+ self.nz = nz
65
+ self.exclude_orbs = exclude_orbs
66
+ self.ne = ne
67
+ self.Rcut = Rcut
68
+ self._use_cache = use_cache
69
+ self.nproc = nproc
70
+ self.description = description
71
+ self.write_density_matrix = write_density_matrix
72
+ self.orb_decomposition = orb_decomposition
73
+ self.output_path = output_path
74
+ self.mae_angles = mae_angles
75
+ self.orth = orth
76
+
77
+ def set_params(self, **kwargs):
78
+ for key, val in kwargs.items():
79
+ setattr(self, key, val)
80
+
81
+ def save_to_yaml(self, fname):
82
+ with open(fname, "w") as myfile:
83
+ yaml.dump(self.__dict__, myfile)
84
+
85
+
86
+ def add_exchange_args_to_parser(parser: argparse.ArgumentParser):
87
+ parser.add_argument(
88
+ "--elements",
89
+ help="elements to be considered in Heisenberg model",
90
+ default=None,
91
+ type=str,
92
+ nargs="*",
93
+ )
94
+ parser.add_argument(
95
+ "--rcut",
96
+ help="cutoff of spin pair distance. The default is to calculate all commensurate R point to the k mesh.",
97
+ default=None,
98
+ type=float,
99
+ )
100
+ parser.add_argument("--efermi", help="Fermi energy in eV", default=None, type=float)
101
+ parser.add_argument(
102
+ "--ne",
103
+ help="number of electrons in the unit cell. If not given, TB2J will use the fermi energy to compute it.",
104
+ )
105
+ parser.add_argument(
106
+ "--kmesh",
107
+ help="kmesh in the format of kx ky kz",
108
+ type=int,
109
+ nargs="*",
110
+ default=[5, 5, 5],
111
+ )
112
+ parser.add_argument(
113
+ "--emin",
114
+ help="energy minimum below efermi, default -14 eV",
115
+ type=float,
116
+ default=-14.0,
117
+ )
118
+ parser.add_argument(
119
+ "--emax",
120
+ help="energy maximum above efermi, default 0.0 eV",
121
+ type=float,
122
+ default=0.0,
123
+ )
124
+ parser.add_argument(
125
+ "--nz",
126
+ help="number of steps for semicircle contour, default: 100",
127
+ default=100,
128
+ type=int,
129
+ )
130
+ parser.add_argument(
131
+ "--cutoff",
132
+ help="The minimum of J amplitude to write, (in eV), default is 1e-5 eV",
133
+ default=1e-5,
134
+ type=float,
135
+ )
136
+ parser.add_argument(
137
+ "--exclude_orbs",
138
+ help="the indices of wannier functions to be excluded from magnetic site. counting start from 0",
139
+ default=[],
140
+ type=int,
141
+ nargs="+",
142
+ )
143
+
144
+ parser.add_argument(
145
+ "--np",
146
+ "--nproc",
147
+ help="number of cpu cores to use in parallel, default: 1",
148
+ default=1,
149
+ type=int,
150
+ )
151
+
152
+ parser.add_argument(
153
+ "--use_cache",
154
+ help="whether to use disk file for temporary storing wavefunctions and hamiltonian to reduce memory usage. Default: False",
155
+ action="store_true",
156
+ default=False,
157
+ )
158
+
159
+ parser.add_argument(
160
+ "--description",
161
+ help="add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.",
162
+ type=str,
163
+ default="Calculated with TB2J.",
164
+ )
165
+
166
+ parser.add_argument(
167
+ "--orb_decomposition",
168
+ default=False,
169
+ action="store_true",
170
+ help="whether to do orbital decomposition in the non-collinear mode.",
171
+ )
172
+
173
+ parser.add_argument(
174
+ "--output_path",
175
+ help="The path of the output directory, default is TB2J_results",
176
+ type=str,
177
+ default="TB2J_results",
178
+ )
179
+ parser.add_argument(
180
+ "--write_dm",
181
+ help="whether to write density matrix",
182
+ action="store_true",
183
+ default=False,
184
+ )
185
+
186
+ parser.add_argument(
187
+ "--orth",
188
+ help="whether to use lowdin orthogonalization before diagonalization (for testing only)",
189
+ action="store_true",
190
+ default=False,
191
+ )
192
+ return parser
193
+
194
+
195
+ def parser_argument_to_dict(args) -> dict:
196
+ return {
197
+ "efermi": args.efermi,
198
+ "magnetic_elements": args.elements,
199
+ "kmesh": args.kmesh,
200
+ "emin": args.emin,
201
+ "emax": args.emax,
202
+ "nz": args.nz,
203
+ "exclude_orbs": args.exclude_orbs,
204
+ "ne": args.ne,
205
+ "Rcut": args.rcut,
206
+ "use_cache": args.use_cache,
207
+ "nproc": args.np,
208
+ "description": args.description,
209
+ "write_density_matrix": args.write_dm,
210
+ "orb_decomposition": args.orb_decomposition,
211
+ "output_path": args.output_path,
212
+ "orth": args.orth,
213
+ }