quant-met 0.0.17__py3-none-any.whl → 0.0.18__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.
quant_met/cli/scf.py CHANGED
@@ -7,6 +7,8 @@
7
7
  import logging
8
8
  from pathlib import Path
9
9
 
10
+ import h5py
11
+
10
12
  from quant_met import mean_field
11
13
  from quant_met.parameters import Parameters
12
14
 
@@ -28,12 +30,13 @@ def scf(parameters: Parameters) -> None:
28
30
  result_path.mkdir(exist_ok=True, parents=True)
29
31
 
30
32
  h = _hamiltonian_factory(parameters=parameters.model, classname=parameters.model.name)
33
+ k_space_grid = h.lattice.generate_bz_grid(
34
+ ncols=parameters.k_points.nk1, nrows=parameters.k_points.nk2
35
+ )
31
36
 
32
37
  solved_h = mean_field.self_consistency_loop(
33
38
  h=h,
34
- k_space_grid=h.lattice.generate_bz_grid(
35
- ncols=parameters.k_points.nk1, nrows=parameters.k_points.nk2
36
- ),
39
+ k_space_grid=k_space_grid,
37
40
  epsilon=parameters.control.conv_treshold,
38
41
  max_iter=parameters.control.max_iter,
39
42
  )
@@ -44,3 +47,24 @@ def scf(parameters: Parameters) -> None:
44
47
  result_file = result_path / f"{parameters.control.prefix}.hdf5"
45
48
  solved_h.save(filename=result_file)
46
49
  logger.info("Results saved to %s", result_file)
50
+
51
+ if parameters.control.calculate_additional is True:
52
+ logger.info("Calculating additional things.")
53
+ current = solved_h.calculate_current_density(k=k_space_grid)
54
+ free_energy = solved_h.calculate_free_energy(k=k_space_grid)
55
+ sf_weight_conv, sf_weight_geom = solved_h.calculate_superfluid_weight(k=k_space_grid)
56
+
57
+ with h5py.File(result_file, "a") as f:
58
+ f.attrs["current_x"] = current[0]
59
+ f.attrs["current_y"] = current[1]
60
+ f.attrs["free_energy"] = free_energy
61
+ f.attrs["sf_weight_conv_xx"] = sf_weight_conv[0, 0]
62
+ f.attrs["sf_weight_conv_xy"] = sf_weight_conv[0, 1]
63
+ f.attrs["sf_weight_conv_yx"] = sf_weight_conv[1, 0]
64
+ f.attrs["sf_weight_conv_yy"] = sf_weight_conv[1, 1]
65
+ f.attrs["sf_weight_geom_xx"] = sf_weight_geom[0, 0]
66
+ f.attrs["sf_weight_geom_xy"] = sf_weight_geom[0, 1]
67
+ f.attrs["sf_weight_geom_yx"] = sf_weight_geom[1, 0]
68
+ f.attrs["sf_weight_geom_yy"] = sf_weight_geom[1, 1]
69
+
70
+ logger.info("Additional results saved to %s", result_file)
@@ -32,12 +32,10 @@ from quant_met.mean_field import hamiltonians
32
32
  from .quantum_metric import quantum_metric
33
33
  from .search_crit_temp import search_crit_temp
34
34
  from .self_consistency import self_consistency_loop
35
- from .superfluid_weight import superfluid_weight
36
35
 
37
36
  __all__ = [
38
37
  "hamiltonians",
39
38
  "quantum_metric",
40
39
  "search_crit_temp",
41
40
  "self_consistency_loop",
42
- "superfluid_weight",
43
41
  ]
@@ -493,7 +493,7 @@ class BaseHamiltonian(Generic[GenericParameters], ABC):
493
493
  ),
494
494
  ]
495
495
  )
496
- density_of_states = np.zeros(shape=energies.shape, dtype=np.floating)
496
+ density_of_states = np.zeros(shape=energies.shape, dtype=np.float64)
497
497
 
498
498
  for i, energy in enumerate(energies):
499
499
  density_of_states[i] = np.sum(
@@ -612,10 +612,119 @@ class BaseHamiltonian(Generic[GenericParameters], ABC):
612
612
 
613
613
  current[0] = np.sum(matrix_x, axis=None)
614
614
  current[1] = np.sum(matrix_y, axis=None)
615
- assert np.allclose(np.imag(current), 0, atol=1e-14)
615
+ assert np.allclose(np.imag(current), 0, atol=1e-12)
616
616
 
617
617
  return (2 * np.real(current)) / len(k)
618
618
 
619
+ def calculate_superfluid_weight(
620
+ self,
621
+ k: npt.NDArray[np.floating],
622
+ ) -> tuple[npt.NDArray[np.complexfloating], npt.NDArray[np.complexfloating]]:
623
+ """Calculate the superfluid weight.
624
+
625
+ Parameters
626
+ ----------
627
+ h : :class:`~quant_met.mean_field.Hamiltonian`
628
+ Hamiltonian.
629
+ k : :class:`numpy.ndarray`
630
+ List of k points.
631
+
632
+ Returns
633
+ -------
634
+ :class:`numpy.ndarray`
635
+ Conventional contribution to the superfluid weight.
636
+ :class:`numpy.ndarray`
637
+ Geometric contribution to the superfluid weight.
638
+
639
+ """
640
+ s_weight_conv = np.zeros(shape=(2, 2), dtype=np.complex128)
641
+ s_weight_geom = np.zeros(shape=(2, 2), dtype=np.complex128)
642
+
643
+ c_mnpq_cache = {}
644
+
645
+ for i, direction_1 in enumerate(["x", "y"]):
646
+ for j, direction_2 in enumerate(["x", "y"]):
647
+ for k_point in k:
648
+ k_tuple = tuple(k_point)
649
+
650
+ if k_tuple not in c_mnpq_cache:
651
+ c_mnpq_cache[k_tuple] = self._c_factor(k_point)
652
+ c_mnpq = c_mnpq_cache[k_tuple]
653
+
654
+ j_up = self._current_operator(direction_1, k_point)
655
+ j_down = self._current_operator(direction_2, -k_point)
656
+
657
+ for m in range(self.number_of_bands):
658
+ for n in range(self.number_of_bands):
659
+ for p in range(self.number_of_bands):
660
+ for q in range(self.number_of_bands):
661
+ s_weight = c_mnpq[m, n, p, q] * j_up[m, n] * j_down[q, p]
662
+ if m == n and p == q:
663
+ s_weight_conv[i, j] += s_weight
664
+ else:
665
+ s_weight_geom[i, j] += s_weight
666
+
667
+ return s_weight_conv, s_weight_geom
668
+
669
+ def _current_operator(
670
+ self, direction: str, k: npt.NDArray[np.floating]
671
+ ) -> npt.NDArray[np.complexfloating]:
672
+ j = np.zeros(shape=(self.number_of_bands, self.number_of_bands), dtype=np.complex128)
673
+
674
+ _, bloch = self.diagonalize_nonint(k=k)
675
+
676
+ for m in range(self.number_of_bands):
677
+ for n in range(self.number_of_bands):
678
+ j[m, n] = (
679
+ bloch[:, m].conjugate()
680
+ @ self.hamiltonian_derivative(direction=direction, k=k)
681
+ @ bloch[:, n]
682
+ )
683
+
684
+ return j
685
+
686
+ def _c_factor(self, k: npt.NDArray[np.floating]) -> npt.NDArray[np.complexfloating]:
687
+ bdg_energies, bdg_functions = self.diagonalize_bdg(k)
688
+ c_mnpq = np.zeros(
689
+ shape=(
690
+ self.number_of_bands,
691
+ self.number_of_bands,
692
+ self.number_of_bands,
693
+ self.number_of_bands,
694
+ ),
695
+ dtype=np.complex128,
696
+ )
697
+
698
+ for m in range(self.number_of_bands):
699
+ for n in range(self.number_of_bands):
700
+ for p in range(self.number_of_bands):
701
+ for q in range(self.number_of_bands):
702
+ c_tmp: float = 0
703
+ for i in range(2 * self.number_of_bands):
704
+ for j in range(2 * self.number_of_bands):
705
+ if bdg_energies[i] != bdg_energies[j]:
706
+ c_tmp += (
707
+ fermi_dirac(bdg_energies[i], self.beta)
708
+ - fermi_dirac(bdg_energies[j], self.beta)
709
+ ) / (bdg_energies[i] - bdg_energies[j])
710
+ else:
711
+ c_tmp -= _fermi_dirac_derivative()
712
+
713
+ c_tmp *= (
714
+ bdg_functions[i, m].conjugate()
715
+ * bdg_functions[j, n]
716
+ * bdg_functions[j, p].conjugate()
717
+ * bdg_functions[i, q].conjugate()
718
+ )
719
+
720
+ c_mnpq[m, n, p, q] = 2 * c_tmp
721
+
722
+ return c_mnpq
723
+
724
+
725
+ def _fermi_dirac_derivative() -> float:
726
+ return 0
727
+
619
728
 
620
729
  def _gaussian(x: npt.NDArray[np.floating], sigma: float) -> npt.NDArray[np.floating]:
621
730
  gaussian: npt.NDArray[np.floating] = np.exp(-(x**2) / (2 * sigma**2)) / np.sqrt(
@@ -26,7 +26,7 @@ class DressedGraphene(BaseHamiltonian[DressedGrapheneParameters]):
26
26
  self.hubbard_int_orbital_basis = parameters.hubbard_int_orbital_basis
27
27
  self.chemical_potential = parameters.chemical_potential
28
28
  if parameters.delta is not None:
29
- self.delta_orbital_basis = parameters.delta.astype(np.complexfloating)
29
+ self.delta_orbital_basis = parameters.delta.astype(np.complex128)
30
30
 
31
31
  def setup_lattice(self, parameters: DressedGrapheneParameters) -> BaseLattice: # noqa: D102
32
32
  return GrapheneLattice(lattice_constant=parameters.lattice_constant)
@@ -43,7 +43,7 @@ def quantum_metric(
43
43
 
44
44
  number_k_points = len(k)
45
45
 
46
- quantum_geom_tensor = np.zeros(shape=(2, 2), dtype=np.complexfloating)
46
+ quantum_geom_tensor = np.zeros(shape=(2, 2), dtype=np.complex128)
47
47
 
48
48
  for band in bands:
49
49
  for i, direction_1 in enumerate(["x", "y"]):
@@ -39,6 +39,7 @@ class Control(BaseModel):
39
39
  conv_treshold: float
40
40
  max_iter: int = 1000
41
41
  n_temp_points: int = 50
42
+ calculate_additional: bool = False
42
43
 
43
44
 
44
45
  class KPoints(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quant-met
3
- Version: 0.0.17
3
+ Version: 0.0.18
4
4
  Summary: Calculate superconductivity in flat-band systems.
5
5
  Author-email: Tjark Sievers <tsievers@physnet.uni-hamburg.de>
6
6
  License-File: LICENSE.txt
@@ -4,32 +4,31 @@ quant_met/cli/__init__.py,sha256=nGFXhK8zWyEKQtsQTyJWfEOLFOHTCjZnfEcrVb2dARc,254
4
4
  quant_met/cli/_utils.py,sha256=n_aP8_4sZXgPwBxngDcKozfdgYJL6VTwOn9qFLKrnzY,941
5
5
  quant_met/cli/crit_temp.py,sha256=t9sPZKORl6dpa1UNAOMH2gDmeQxf80iFH7p_L3FI5q8,2027
6
6
  quant_met/cli/main.py,sha256=lVAPGPUZtzyX6QKPEFYyDKFWYhQ30dMXjOEq5VdTa7I,1871
7
- quant_met/cli/scf.py,sha256=wHilJRBk7_8nOheJpGk1ZeBOWu4UF9oDVI4SjHptQgY,1464
7
+ quant_met/cli/scf.py,sha256=3_rwtQHwypFjAwjrsO2r2sqjJKpNiDLAj6svU52CCcU,2613
8
8
  quant_met/geometry/__init__.py,sha256=2N8l0-2-PhEOQxaUO7e8Dqy5oaxt2y9343XENDTCGPE,592
9
9
  quant_met/geometry/base_lattice.py,sha256=OJNDMyzJB-0hK1BLgF-SV4jUYfOSUksIv1XG1bH-zyY,2649
10
10
  quant_met/geometry/bz_path.py,sha256=vwN5RxyrgFkHTSqm_6cWuOigICgxa-FX5NZ7SkgKScw,2503
11
11
  quant_met/geometry/graphene.py,sha256=ZLE55wV1E-jRCkGxW66pca2y5VWaNtMmXiXi-HB6bgs,1627
12
12
  quant_met/geometry/square.py,sha256=17XZH79lK9TeeDtXiBBa8rd2d9kv5yt2S9F6te0YZPU,1565
13
- quant_met/mean_field/__init__.py,sha256=fCPMFKoYh47aa5Aa0wSQ3cZWMgUdGQqqjfeXO6OzB-E,736
13
+ quant_met/mean_field/__init__.py,sha256=dO7ATRQyes96tr2WMvmPPqr_S90WL2RCHquRdXWaSjU,662
14
14
  quant_met/mean_field/_utils.py,sha256=7hr0DDSdIqjft5Jjluvbw_HGoNLWgYJTxyuPJJvhBnc,356
15
- quant_met/mean_field/quantum_metric.py,sha256=YDvCsn1W-NBd0PdxyNUpsaO0GPIpIL20LElP-S-HmYY,2588
15
+ quant_met/mean_field/quantum_metric.py,sha256=aiZLdUsWmoBLunv-aJr_BCQVfhD7t0GHbeYrT60s3cI,2583
16
16
  quant_met/mean_field/search_crit_temp.py,sha256=Lp6iJEyXnLwfZQ3549J3s9HYQo6OgakzT_FJRRZ5oM0,8661
17
17
  quant_met/mean_field/self_consistency.py,sha256=YY_zhCurxOK3RLkK-Hglfkx33uhsvqpoAKOP4FuPdfo,3371
18
- quant_met/mean_field/superfluid_weight.py,sha256=XiJ6wFZkxFoGtIzy2NCMoznothqrMkvIvYU_0_29mUc,4321
19
18
  quant_met/mean_field/hamiltonians/__init__.py,sha256=r-8TaLqRnRbAro-TMIyxzCCZHwVqyKrausODpQJb2tw,681
20
- quant_met/mean_field/hamiltonians/base_hamiltonian.py,sha256=WA3WKb34xi0m78WRmIsyjJ_skq7OsndiI3YsUOCvx8I,22624
21
- quant_met/mean_field/hamiltonians/dressed_graphene.py,sha256=99HCr1VXv_9sQpp5Mn51ijdnBOsN-y4s8n7YSyBXWJE,4053
19
+ quant_met/mean_field/hamiltonians/base_hamiltonian.py,sha256=2UlTckCHyBDujzKQk-GvWXJSqUE_2WEZ9D-m6W0TWuY,26880
20
+ quant_met/mean_field/hamiltonians/dressed_graphene.py,sha256=Q5LiA3rgK88ZZV1V7JflgjlkEpve7uNZFzFCIoQND-w,4048
22
21
  quant_met/mean_field/hamiltonians/graphene.py,sha256=sa3H8jVq9Fkc_qcz5gJTCMgN8YD3N18JWLRBImhLyxo,3276
23
22
  quant_met/mean_field/hamiltonians/one_band_tight_binding.py,sha256=DZXaD95yWv1VZSMqgxkqEZv3PGihNGy7PuqupnN75ew,2512
24
23
  quant_met/mean_field/hamiltonians/three_band_tight_binding.py,sha256=g8XNImzCn_6CRYKDYI6sy3q6_TBYUDxDmQZ-AqenXTE,3295
25
24
  quant_met/mean_field/hamiltonians/two_band_tight_binding.py,sha256=DMySc94YQ1M2nPIKZjfc-Ax5Ysf7inwSuVKyd6dfqr0,2865
26
25
  quant_met/parameters/__init__.py,sha256=9yu7i0J-O3QxSicnLEh2ci7FSMwB8bPW0pbl8KWHJUs,1007
27
26
  quant_met/parameters/hamiltonians.py,sha256=PiWVV-miCdT4Z9GWloDVvIU_1QpRHHV-zVOga7DWwCw,6046
28
- quant_met/parameters/main.py,sha256=hGcJvRixkXuUk9MytAs0S1L2VvcJlT8qVG1g7NZOjlE,2126
27
+ quant_met/parameters/main.py,sha256=bHf3Ixjg7nkr_kDihZUXC1egmXo7LecxmVsqBS-eOAA,2165
29
28
  quant_met/plotting/__init__.py,sha256=VypHrLAGmCiQaQggGh5Cs4EF4YAjRiETddf_7mOX9MQ,544
30
29
  quant_met/plotting/plotting.py,sha256=4ZYclWJH3hlE8S7b7bL_JJlP3CKaCGcVzdIsqolCAaM,6592
31
- quant_met-0.0.17.dist-info/METADATA,sha256=9Vz7cCEp8RC9i3YphnvG6WNmCoWxtUMJGDmD5Qv4BHo,1949
32
- quant_met-0.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
33
- quant_met-0.0.17.dist-info/entry_points.txt,sha256=1Al3Kt-cMeQxwMp84ZSNL0qFwlbOVBu1o8A19MH8lEU,48
34
- quant_met-0.0.17.dist-info/licenses/LICENSE.txt,sha256=QO_duPQihSJlaxSLxPAXo52X3esROP5wBkhxqBd1Z4E,1104
35
- quant_met-0.0.17.dist-info/RECORD,,
30
+ quant_met-0.0.18.dist-info/METADATA,sha256=t4UafmOjpoGKF8s6dqo3J_kKQA2kZhtSZiZaNaFAgHs,1949
31
+ quant_met-0.0.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
+ quant_met-0.0.18.dist-info/entry_points.txt,sha256=1Al3Kt-cMeQxwMp84ZSNL0qFwlbOVBu1o8A19MH8lEU,48
33
+ quant_met-0.0.18.dist-info/licenses/LICENSE.txt,sha256=QO_duPQihSJlaxSLxPAXo52X3esROP5wBkhxqBd1Z4E,1104
34
+ quant_met-0.0.18.dist-info/RECORD,,
@@ -1,126 +0,0 @@
1
- # SPDX-FileCopyrightText: 2024 Tjark Sievers
2
- #
3
- # SPDX-License-Identifier: MIT
4
-
5
- """Functions to calculate the superfluid weight."""
6
-
7
- import numpy as np
8
- import numpy.typing as npt
9
-
10
- from quant_met.mean_field.hamiltonians.base_hamiltonian import BaseHamiltonian
11
- from quant_met.parameters import GenericParameters
12
- from quant_met.utils import fermi_dirac
13
-
14
-
15
- def superfluid_weight(
16
- h: BaseHamiltonian[GenericParameters],
17
- k: npt.NDArray[np.floating],
18
- ) -> tuple[npt.NDArray[np.complexfloating], npt.NDArray[np.complexfloating]]:
19
- """Calculate the superfluid weight.
20
-
21
- Parameters
22
- ----------
23
- h : :class:`~quant_met.mean_field.Hamiltonian`
24
- Hamiltonian.
25
- k : :class:`numpy.ndarray`
26
- List of k points.
27
-
28
- Returns
29
- -------
30
- :class:`numpy.ndarray`
31
- Conventional contribution to the superfluid weight.
32
- :class:`numpy.ndarray`
33
- Geometric contribution to the superfluid weight.
34
-
35
- """
36
- s_weight_conv = np.zeros(shape=(2, 2), dtype=np.complexfloating)
37
- s_weight_geom = np.zeros(shape=(2, 2), dtype=np.complexfloating)
38
-
39
- c_mnpq_cache = {}
40
-
41
- for i, direction_1 in enumerate(["x", "y"]):
42
- for j, direction_2 in enumerate(["x", "y"]):
43
- for k_point in k:
44
- k_tuple = tuple(k_point)
45
-
46
- if k_tuple not in c_mnpq_cache:
47
- c_mnpq_cache[k_tuple] = _c_factor(h, k_point)
48
- c_mnpq = c_mnpq_cache[k_tuple]
49
-
50
- j_up = _current_operator(h, direction_1, k_point)
51
- j_down = _current_operator(h, direction_2, -k_point)
52
-
53
- for m in range(h.number_of_bands):
54
- for n in range(h.number_of_bands):
55
- for p in range(h.number_of_bands):
56
- for q in range(h.number_of_bands):
57
- s_weight = c_mnpq[m, n, p, q] * j_up[m, n] * j_down[q, p]
58
- if m == n and p == q:
59
- s_weight_conv[i, j] += s_weight
60
- else:
61
- s_weight_geom[i, j] += s_weight
62
-
63
- return s_weight_conv, s_weight_geom
64
-
65
-
66
- def _current_operator(
67
- h: BaseHamiltonian[GenericParameters], direction: str, k: npt.NDArray[np.floating]
68
- ) -> npt.NDArray[np.complexfloating]:
69
- j = np.zeros(shape=(h.number_of_bands, h.number_of_bands), dtype=np.complexfloating)
70
-
71
- _, bloch = h.diagonalize_nonint(k=k)
72
-
73
- for m in range(h.number_of_bands):
74
- for n in range(h.number_of_bands):
75
- j[m, n] = (
76
- bloch[:, m].conjugate()
77
- @ h.hamiltonian_derivative(direction=direction, k=k)
78
- @ bloch[:, n]
79
- )
80
-
81
- return j
82
-
83
-
84
- def _c_factor(
85
- h: BaseHamiltonian[GenericParameters], k: npt.NDArray[np.floating]
86
- ) -> npt.NDArray[np.complexfloating]:
87
- bdg_energies, bdg_functions = h.diagonalize_bdg(k)
88
- c_mnpq = np.zeros(
89
- shape=(
90
- h.number_of_bands,
91
- h.number_of_bands,
92
- h.number_of_bands,
93
- h.number_of_bands,
94
- ),
95
- dtype=np.complexfloating,
96
- )
97
-
98
- for m in range(h.number_of_bands):
99
- for n in range(h.number_of_bands):
100
- for p in range(h.number_of_bands):
101
- for q in range(h.number_of_bands):
102
- c_tmp: float = 0
103
- for i in range(2 * h.number_of_bands):
104
- for j in range(2 * h.number_of_bands):
105
- if bdg_energies[i] != bdg_energies[j]:
106
- c_tmp += (
107
- fermi_dirac(bdg_energies[i], h.beta)
108
- - fermi_dirac(bdg_energies[j], h.beta)
109
- ) / (bdg_energies[i] - bdg_energies[j])
110
- else:
111
- c_tmp -= _fermi_dirac_derivative()
112
-
113
- c_tmp *= (
114
- bdg_functions[i, m].conjugate()
115
- * bdg_functions[j, n]
116
- * bdg_functions[j, p].conjugate()
117
- * bdg_functions[i, q].conjugate()
118
- )
119
-
120
- c_mnpq[m, n, p, q] = 2 * c_tmp
121
-
122
- return c_mnpq
123
-
124
-
125
- def _fermi_dirac_derivative() -> float:
126
- return 0