sparse-ir 0.97.0__tar.gz → 1.1.0__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 (38) hide show
  1. sparse-ir-1.1.0/LICENSE.txt +20 -0
  2. sparse-ir-1.1.0/PKG-INFO +150 -0
  3. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/README.rst +2 -2
  4. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/setup.py +2 -2
  5. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/__init__.py +2 -2
  6. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/sampling.py +81 -13
  7. sparse-ir-1.1.0/src/sparse_ir.egg-info/PKG-INFO +150 -0
  8. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir.egg-info/SOURCES.txt +1 -0
  9. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_sampling.py +33 -0
  10. sparse-ir-0.97.0/PKG-INFO +0 -147
  11. sparse-ir-0.97.0/src/sparse_ir.egg-info/PKG-INFO +0 -147
  12. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/setup.cfg +0 -0
  13. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/_gauss.py +0 -0
  14. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/_roots.py +0 -0
  15. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/_util.py +0 -0
  16. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/abstract.py +0 -0
  17. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/adapter.py +0 -0
  18. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/augment.py +0 -0
  19. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/basis.py +0 -0
  20. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/basis_set.py +0 -0
  21. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/dlr.py +0 -0
  22. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/kernel.py +0 -0
  23. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/poly.py +0 -0
  24. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/svd.py +0 -0
  25. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir/sve.py +0 -0
  26. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir.egg-info/dependency_links.txt +0 -0
  27. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir.egg-info/requires.txt +0 -0
  28. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/src/sparse_ir.egg-info/top_level.txt +0 -0
  29. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_augment.py +0 -0
  30. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_basis_set.py +0 -0
  31. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_compare.py +0 -0
  32. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_dlr.py +0 -0
  33. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_gauss.py +0 -0
  34. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_kernel.py +0 -0
  35. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_poly.py +0 -0
  36. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_scipost_sample_code.py +0 -0
  37. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_sve.py +0 -0
  38. {sparse-ir-0.97.0 → sparse-ir-1.1.0}/test/test_whitespace.py +0 -0
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2020-2021 Markus Wallerberger and others
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.1
2
+ Name: sparse-ir
3
+ Version: 1.1.0
4
+ Summary: intermediate representation (IR) basis for electronic propagator
5
+ Home-page: https://github.com/SpM-lab/sparse-ir
6
+ Author: ['Markus Wallerberger', 'Hiroshi Shinaoka', 'Kazuyoshi Yoshimi', 'Junya Otsuki', 'Chikano Naoya']
7
+ Author-email: markus.wallerberger@tuwien.ac.at
8
+ License: UNKNOWN
9
+ Keywords: irbasis many-body propagator svd
10
+ Platform: UNKNOWN
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Physics
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Requires-Python: >=3
18
+ Description-Content-Type: text/x-rst
19
+ Provides-Extra: doc
20
+ Provides-Extra: test
21
+ Provides-Extra: xprec
22
+ License-File: LICENSE.txt
23
+
24
+ sparse-ir - A library for the intermediate representation of propagators
25
+ ========================================================================
26
+ This library provides routines for constructing and working with the
27
+ intermediate representation of correlation functions. It provides:
28
+
29
+ - on-the-fly computation of basis functions for arbitrary cutoff Λ
30
+ - basis functions and singular values are accurate to full precision
31
+ - routines for sparse sampling
32
+
33
+
34
+ Installation
35
+ ------------
36
+ Install via `pip <https://pypi.org/project/sparse-ir>`_::
37
+
38
+ pip install sparse-ir[xprec]
39
+
40
+ The above line is the recommended way to install `sparse-ir`. It automatically
41
+ installs the `xprec <https://github.com/tuwien-cms/xprec>`_ package, which
42
+ allows one to compute the IR basis functions with greater accuracy. If you do
43
+ not want to do this, simply remove the string ``[xprec]`` from the above command.
44
+
45
+ Install via `conda <https://anaconda.org/spm-lab/sparse-ir>`_::
46
+
47
+ conda install -c spm-lab sparse-ir xprec
48
+
49
+ Other than the optional xprec dependency, sparse-ir requires only
50
+ `numpy <https://numpy.org/>`_ and `scipy <https://scipy.org/>`_.
51
+
52
+ To manually install the current development version, you can use the following::
53
+
54
+ # Only recommended for developers - no automatic updates!
55
+ git clone https://github.com/SpM-lab/sparse-ir
56
+ pip install -e sparse-ir/[xprec]
57
+
58
+ Documentation and tutorial
59
+ --------------------------
60
+ Check out our `comprehensive tutorial`_, where we self-contained
61
+ notebooks for several many-body methods - GF(2), GW, Eliashberg equations,
62
+ Lichtenstein formula, FLEX, ... - are presented.
63
+
64
+ Refer to the `API documentation`_ for more details on how to work
65
+ with the python library.
66
+
67
+ There is also a `Julia library`_ and (currently somewhat restricted)
68
+ `Fortran library`_ available for the IR basis and sparse sampling.
69
+
70
+ .. _comprehensive tutorial: https://spm-lab.github.io/sparse-ir-tutorial
71
+ .. _API documentation: https://sparse-ir.readthedocs.io
72
+ .. _Julia library: https://github.com/SpM-lab/SparseIR.jl
73
+ .. _Fortran library: https://github.com/SpM-lab/sparse-ir-fortran
74
+
75
+ Getting started
76
+ ---------------
77
+ Here is a full second-order perturbation theory solver (GF(2)) in a few
78
+ lines of Python code::
79
+
80
+ # Construct the IR basis and sparse sampling for fermionic propagators
81
+ import sparse_ir, numpy as np
82
+ basis = sparse_ir.FiniteTempBasis('F', beta=10, wmax=8, eps=1e-6)
83
+ stau = sparse_ir.TauSampling(basis)
84
+ siw = sparse_ir.MatsubaraSampling(basis, positive_only=True)
85
+
86
+ # Solve the single impurity Anderson model coupled to a bath with a
87
+ # semicircular states with unit half bandwidth.
88
+ U = 1.2
89
+ def rho0w(w):
90
+ return np.sqrt(1-w.clip(-1,1)**2) * 2/np.pi
91
+
92
+ # Compute the IR basis coefficients for the non-interacting propagator
93
+ rho0l = basis.v.overlap(rho0w)
94
+ G0l = -basis.s * rho0l
95
+
96
+ # Self-consistency loop: alternate between second-order expression for the
97
+ # self-energy and the Dyson equation until convergence.
98
+ Gl = G0l
99
+ Gl_prev = 0
100
+ while np.linalg.norm(Gl - Gl_prev) > 1e-6:
101
+ Gl_prev = Gl
102
+ Gtau = stau.evaluate(Gl)
103
+ Sigmatau = U**2 * Gtau**3
104
+ Sigmal = stau.fit(Sigmatau)
105
+ Sigmaiw = siw.evaluate(Sigmal)
106
+ G0iw = siw.evaluate(G0l)
107
+ Giw = 1/(1/G0iw - Sigmaiw)
108
+ Gl = siw.fit(Giw)
109
+
110
+ You may want to start with reading up on the `intermediate representation`_.
111
+ It is tied to the analytic continuation of bosonic/fermionic spectral
112
+ functions from (real) frequencies to imaginary time, a transformation mediated
113
+ by a kernel ``K``. The kernel depends on a cutoff, which you should choose to
114
+ be ``lambda_ >= beta * W``, where ``beta`` is the inverse temperature and ``W``
115
+ is the bandwidth.
116
+
117
+ One can now perform a `singular value expansion`_ on this kernel, which
118
+ generates two sets of orthonormal basis functions, one set ``v[l](w)`` for
119
+ real frequency side ``w``, and one set ``u[l](tau)`` for the same obejct in
120
+ imaginary (Euclidean) time ``tau``, together with a "coupling" strength
121
+ ``s[l]`` between the two sides.
122
+
123
+ By this construction, the imaginary time basis can be shown to be *optimal* in
124
+ terms of compactness.
125
+
126
+ .. _intermediate representation: https://arxiv.org/abs/2106.12685
127
+ .. _singular value expansion: https://w.wiki/3poQ
128
+
129
+ License and citation
130
+ --------------------
131
+ This software is released under the MIT License. See LICENSE.txt for details.
132
+
133
+ If you find the intermediate representation, sparse sampling, or this software
134
+ useful in your research, please consider citing the following papers:
135
+
136
+ - Hiroshi Shinaoka et al., `Phys. Rev. B 96, 035147`_ (2017)
137
+ - Jia Li et al., `Phys. Rev. B 101, 035144`_ (2020)
138
+ - Markus Wallerberger et al., `SoftwareX 21, 101266`_ (2023)
139
+
140
+ If you are discussing sparse sampling in your research specifically, please
141
+ also consider citing an independently discovered, closely related approach, the
142
+ MINIMAX isometry method (Merzuk Kaltak and Georg Kresse,
143
+ `Phys. Rev. B 101, 205145`_, 2020).
144
+
145
+ .. _Phys. Rev. B 96, 035147: https://doi.org/10.1103/PhysRevB.96.035147
146
+ .. _Phys. Rev. B 101, 035144: https://doi.org/10.1103/PhysRevB.101.035144
147
+ .. _SoftwareX 21, 101266: https://doi.org/10.1016/j.softx.2022.101266
148
+ .. _Phys. Rev. B 101, 205145: https://doi.org/10.1103/PhysRevB.101.205145
149
+
150
+
@@ -112,7 +112,7 @@ useful in your research, please consider citing the following papers:
112
112
 
113
113
  - Hiroshi Shinaoka et al., `Phys. Rev. B 96, 035147`_ (2017)
114
114
  - Jia Li et al., `Phys. Rev. B 101, 035144`_ (2020)
115
- - Markus Wallerberger et al., `arXiv 2206.11762`_ (2022)
115
+ - Markus Wallerberger et al., `SoftwareX 21, 101266`_ (2023)
116
116
 
117
117
  If you are discussing sparse sampling in your research specifically, please
118
118
  also consider citing an independently discovered, closely related approach, the
@@ -121,5 +121,5 @@ MINIMAX isometry method (Merzuk Kaltak and Georg Kresse,
121
121
 
122
122
  .. _Phys. Rev. B 96, 035147: https://doi.org/10.1103/PhysRevB.96.035147
123
123
  .. _Phys. Rev. B 101, 035144: https://doi.org/10.1103/PhysRevB.101.035144
124
- .. _arXiv 2206.11762: https://doi.org/10.48550/arXiv.2206.11762
124
+ .. _SoftwareX 21, 101266: https://doi.org/10.1016/j.softx.2022.101266
125
125
  .. _Phys. Rev. B 101, 205145: https://doi.org/10.1103/PhysRevB.101.205145
@@ -34,10 +34,10 @@ setup(
34
34
  long_description=LONG_DESCRIPTION,
35
35
  long_description_content_type='text/x-rst',
36
36
  keywords=' '.join([
37
- 'irbasis'
37
+ 'irbasis', 'many-body', 'propagator', 'svd'
38
38
  ]),
39
39
  classifiers=[
40
- 'Development Status :: 4 - Beta',
40
+ 'Development Status :: 5 - Production/Stable',
41
41
  'Intended Audience :: Developers',
42
42
  'Intended Audience :: Science/Research',
43
43
  'Topic :: Scientific/Engineering :: Physics',
@@ -10,9 +10,9 @@ intermediate representation of correlation functions. It provides:
10
10
  - basis functions and singular values are accurate to full precision
11
11
  - routines for sparse sampling
12
12
  """
13
- __copyright__ = "2020-2022 Markus Wallerberger, Hiroshi Shinaoka, and others"
13
+ __copyright__ = "2020-2024 Markus Wallerberger, Hiroshi Shinaoka, and others"
14
14
  __license__ = "MIT"
15
- __version__ = "0.97.0"
15
+ __version__ = "1.1.0"
16
16
 
17
17
  from .kernel import RegularizedBoseKernel, LogisticKernel
18
18
  from .sve import compute as compute_sve, SVEResult
@@ -20,13 +20,70 @@ class AbstractSampling:
20
20
  |________________| fit |___________________|
21
21
 
22
22
  """
23
- def evaluate(self, al, axis=None):
24
- """Evaluate the basis coefficients at the sparse sampling points"""
23
+ def evaluate(self, al, axis=None, *, points=None):
24
+ """Evaluate the basis coefficients at sampling points.
25
+
26
+ Arguments:
27
+ al (array):
28
+ Array where the `l`-th item along `axis` corresponds to the
29
+ `l`-th basis coefficient
30
+ axis (integer):
31
+ Axis or dimension of `al` along which to evaluate the function.
32
+ Defaults to the last, i.e., rightmost axis.
33
+ points (vector):
34
+ Points on which the results should be evaluated. Defaults
35
+ to the sampling points for which the sampling objects was
36
+ created.
37
+
38
+ Return:
39
+ Array where the `n`-th item along `axis` corresponds to the
40
+ value on the `n`-th sampling point (or value on `point[n]`, if
41
+ given.)
42
+
43
+ Note:
44
+ If `points` is given, a new sampling is created at each invocation,
45
+ which can result in a performance hit. Consider caching sampling
46
+ objects or simply using the `.u()` and `.uhat()` methods of the
47
+ underlying basis.
48
+ """
49
+ if points is not None:
50
+ return self._for_sampling_points(points).evaluate(al, axis)
51
+
25
52
  return self.matrix.matmul(al, axis)
26
53
 
27
- def fit(self, ax, axis=None):
28
- """Fit basis coefficients from the sparse sampling points"""
29
- return self.matrix.lstsq(ax, axis)
54
+ def fit(self, ax, axis=None, *, points=None):
55
+ """Fit the basis coefficients from the sampling points.
56
+
57
+ Arguments:
58
+ ax (array):
59
+ Array where the `n`-th item along `axis` corresponds to the
60
+ value on the `n`-th sampling point (or value on `point[n]`, if
61
+ given.)
62
+ axis (integer):
63
+ Axis or dimension of `ax` along which to fit the function.
64
+ Defaults to the last, i.e., rightmost axis.
65
+ points (vector):
66
+ Points on which the `ax` is given. Defaults to the sampling
67
+ points for which the sampling objects was created.
68
+
69
+ Return:
70
+ Array where the `l`-th item along `axis` corresponds to the
71
+ `l`-th basis coefficient
72
+
73
+ Note:
74
+ If `points` is given, a new sampling is created at each invocation,
75
+ which can result in a performance hit. Consider caching sampling
76
+ objects.
77
+ """
78
+ if points is not None:
79
+ return self._for_sampling_points(points).fit(ax, axis)
80
+
81
+ matrix = self.matrix
82
+ if self.basis.is_well_conditioned and not (matrix.cond <= 1e8):
83
+ warn(f"Sampling matrix is poorly conditioned "
84
+ f"(kappa = {matrix.cond:.2g})", ConditioningWarning)
85
+
86
+ return matrix.lstsq(ax, axis)
30
87
 
31
88
  @property
32
89
  def cond(self):
@@ -48,6 +105,9 @@ class AbstractSampling:
48
105
  """Basis instance"""
49
106
  raise NotImplementedError()
50
107
 
108
+ def _for_sampling_points(self, x):
109
+ raise RuntimeError("Changing sampling points is not possible")
110
+
51
111
 
52
112
  class TauSampling(AbstractSampling):
53
113
  """Sparse sampling in imaginary time.
@@ -68,10 +128,6 @@ class TauSampling(AbstractSampling):
68
128
  self._sampling_points = sampling_points
69
129
  self._matrix = DecomposedMatrix(matrix)
70
130
 
71
- if basis.is_well_conditioned and self._matrix.cond > 1e8:
72
- warn(f"Sampling matrix is poorly conditioned "
73
- f"(kappa = {self._matrix.cond:.2g})", ConditioningWarning)
74
-
75
131
  @property
76
132
  def basis(self): return self._basis
77
133
 
@@ -86,6 +142,10 @@ class TauSampling(AbstractSampling):
86
142
  """Sampling points in (reduced) imaginary time"""
87
143
  return self._sampling_points
88
144
 
145
+ def _for_sampling_points(self, x):
146
+ x = np.asarray(x)
147
+ return TauSampling(self._basis, x)
148
+
89
149
 
90
150
  class MatsubaraSampling(AbstractSampling):
91
151
  """Sparse sampling in Matsubara frequencies.
@@ -125,10 +185,6 @@ class MatsubaraSampling(AbstractSampling):
125
185
  else:
126
186
  self._matrix = DecomposedMatrix(matrix)
127
187
 
128
- if basis.is_well_conditioned and self._matrix.cond > 1e8:
129
- warn(f"Sampling matrix is poorly conditioned "
130
- f"(kappa = {self._matrix.cond:.2g})", ConditioningWarning)
131
-
132
188
  @property
133
189
  def basis(self): return self._basis
134
190
 
@@ -148,6 +204,11 @@ class MatsubaraSampling(AbstractSampling):
148
204
  """Sampling points as (reduced) Matsubara frequencies"""
149
205
  return self._sampling_points
150
206
 
207
+ def _for_sampling_points(self, x):
208
+ x = np.asarray(x)
209
+ return MatsubaraSampling(self._basis, x,
210
+ positive_only=self._positive_only)
211
+
151
212
 
152
213
  class DecomposedMatrix:
153
214
  """Matrix in SVD decomposed form for fast and accurate fitting.
@@ -314,6 +375,13 @@ class SplitDecomposedMatrix:
314
375
 
315
376
 
316
377
  class ConditioningWarning(RuntimeWarning):
378
+ """Warns about a poorly conditioned problem.
379
+
380
+ This warning is issued if the library detects a poorly conditioned fitting
381
+ problem. This essentially means there is a high degree of ambiguity in how
382
+ to choose the solution. One must therefore expect to lose significant
383
+ precision in the parameter values.
384
+ """
317
385
  pass
318
386
 
319
387
 
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.1
2
+ Name: sparse-ir
3
+ Version: 1.1.0
4
+ Summary: intermediate representation (IR) basis for electronic propagator
5
+ Home-page: https://github.com/SpM-lab/sparse-ir
6
+ Author: ['Markus Wallerberger', 'Hiroshi Shinaoka', 'Kazuyoshi Yoshimi', 'Junya Otsuki', 'Chikano Naoya']
7
+ Author-email: markus.wallerberger@tuwien.ac.at
8
+ License: UNKNOWN
9
+ Keywords: irbasis many-body propagator svd
10
+ Platform: UNKNOWN
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Physics
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Requires-Python: >=3
18
+ Description-Content-Type: text/x-rst
19
+ Provides-Extra: doc
20
+ Provides-Extra: test
21
+ Provides-Extra: xprec
22
+ License-File: LICENSE.txt
23
+
24
+ sparse-ir - A library for the intermediate representation of propagators
25
+ ========================================================================
26
+ This library provides routines for constructing and working with the
27
+ intermediate representation of correlation functions. It provides:
28
+
29
+ - on-the-fly computation of basis functions for arbitrary cutoff Λ
30
+ - basis functions and singular values are accurate to full precision
31
+ - routines for sparse sampling
32
+
33
+
34
+ Installation
35
+ ------------
36
+ Install via `pip <https://pypi.org/project/sparse-ir>`_::
37
+
38
+ pip install sparse-ir[xprec]
39
+
40
+ The above line is the recommended way to install `sparse-ir`. It automatically
41
+ installs the `xprec <https://github.com/tuwien-cms/xprec>`_ package, which
42
+ allows one to compute the IR basis functions with greater accuracy. If you do
43
+ not want to do this, simply remove the string ``[xprec]`` from the above command.
44
+
45
+ Install via `conda <https://anaconda.org/spm-lab/sparse-ir>`_::
46
+
47
+ conda install -c spm-lab sparse-ir xprec
48
+
49
+ Other than the optional xprec dependency, sparse-ir requires only
50
+ `numpy <https://numpy.org/>`_ and `scipy <https://scipy.org/>`_.
51
+
52
+ To manually install the current development version, you can use the following::
53
+
54
+ # Only recommended for developers - no automatic updates!
55
+ git clone https://github.com/SpM-lab/sparse-ir
56
+ pip install -e sparse-ir/[xprec]
57
+
58
+ Documentation and tutorial
59
+ --------------------------
60
+ Check out our `comprehensive tutorial`_, where we self-contained
61
+ notebooks for several many-body methods - GF(2), GW, Eliashberg equations,
62
+ Lichtenstein formula, FLEX, ... - are presented.
63
+
64
+ Refer to the `API documentation`_ for more details on how to work
65
+ with the python library.
66
+
67
+ There is also a `Julia library`_ and (currently somewhat restricted)
68
+ `Fortran library`_ available for the IR basis and sparse sampling.
69
+
70
+ .. _comprehensive tutorial: https://spm-lab.github.io/sparse-ir-tutorial
71
+ .. _API documentation: https://sparse-ir.readthedocs.io
72
+ .. _Julia library: https://github.com/SpM-lab/SparseIR.jl
73
+ .. _Fortran library: https://github.com/SpM-lab/sparse-ir-fortran
74
+
75
+ Getting started
76
+ ---------------
77
+ Here is a full second-order perturbation theory solver (GF(2)) in a few
78
+ lines of Python code::
79
+
80
+ # Construct the IR basis and sparse sampling for fermionic propagators
81
+ import sparse_ir, numpy as np
82
+ basis = sparse_ir.FiniteTempBasis('F', beta=10, wmax=8, eps=1e-6)
83
+ stau = sparse_ir.TauSampling(basis)
84
+ siw = sparse_ir.MatsubaraSampling(basis, positive_only=True)
85
+
86
+ # Solve the single impurity Anderson model coupled to a bath with a
87
+ # semicircular states with unit half bandwidth.
88
+ U = 1.2
89
+ def rho0w(w):
90
+ return np.sqrt(1-w.clip(-1,1)**2) * 2/np.pi
91
+
92
+ # Compute the IR basis coefficients for the non-interacting propagator
93
+ rho0l = basis.v.overlap(rho0w)
94
+ G0l = -basis.s * rho0l
95
+
96
+ # Self-consistency loop: alternate between second-order expression for the
97
+ # self-energy and the Dyson equation until convergence.
98
+ Gl = G0l
99
+ Gl_prev = 0
100
+ while np.linalg.norm(Gl - Gl_prev) > 1e-6:
101
+ Gl_prev = Gl
102
+ Gtau = stau.evaluate(Gl)
103
+ Sigmatau = U**2 * Gtau**3
104
+ Sigmal = stau.fit(Sigmatau)
105
+ Sigmaiw = siw.evaluate(Sigmal)
106
+ G0iw = siw.evaluate(G0l)
107
+ Giw = 1/(1/G0iw - Sigmaiw)
108
+ Gl = siw.fit(Giw)
109
+
110
+ You may want to start with reading up on the `intermediate representation`_.
111
+ It is tied to the analytic continuation of bosonic/fermionic spectral
112
+ functions from (real) frequencies to imaginary time, a transformation mediated
113
+ by a kernel ``K``. The kernel depends on a cutoff, which you should choose to
114
+ be ``lambda_ >= beta * W``, where ``beta`` is the inverse temperature and ``W``
115
+ is the bandwidth.
116
+
117
+ One can now perform a `singular value expansion`_ on this kernel, which
118
+ generates two sets of orthonormal basis functions, one set ``v[l](w)`` for
119
+ real frequency side ``w``, and one set ``u[l](tau)`` for the same obejct in
120
+ imaginary (Euclidean) time ``tau``, together with a "coupling" strength
121
+ ``s[l]`` between the two sides.
122
+
123
+ By this construction, the imaginary time basis can be shown to be *optimal* in
124
+ terms of compactness.
125
+
126
+ .. _intermediate representation: https://arxiv.org/abs/2106.12685
127
+ .. _singular value expansion: https://w.wiki/3poQ
128
+
129
+ License and citation
130
+ --------------------
131
+ This software is released under the MIT License. See LICENSE.txt for details.
132
+
133
+ If you find the intermediate representation, sparse sampling, or this software
134
+ useful in your research, please consider citing the following papers:
135
+
136
+ - Hiroshi Shinaoka et al., `Phys. Rev. B 96, 035147`_ (2017)
137
+ - Jia Li et al., `Phys. Rev. B 101, 035144`_ (2020)
138
+ - Markus Wallerberger et al., `SoftwareX 21, 101266`_ (2023)
139
+
140
+ If you are discussing sparse sampling in your research specifically, please
141
+ also consider citing an independently discovered, closely related approach, the
142
+ MINIMAX isometry method (Merzuk Kaltak and Georg Kresse,
143
+ `Phys. Rev. B 101, 205145`_, 2020).
144
+
145
+ .. _Phys. Rev. B 96, 035147: https://doi.org/10.1103/PhysRevB.96.035147
146
+ .. _Phys. Rev. B 101, 035144: https://doi.org/10.1103/PhysRevB.101.035144
147
+ .. _SoftwareX 21, 101266: https://doi.org/10.1016/j.softx.2022.101266
148
+ .. _Phys. Rev. B 101, 205145: https://doi.org/10.1103/PhysRevB.101.205145
149
+
150
+
@@ -1,3 +1,4 @@
1
+ LICENSE.txt
1
2
  README.rst
2
3
  setup.py
3
4
  src/sparse_ir/__init__.py
@@ -100,3 +100,36 @@ def test_wn_noise(sve_logistic, stat, lambda_, positive_only):
100
100
  Gl_n = smpl.fit(Giw_n)
101
101
  np.testing.assert_allclose(Gl, Gl_n,
102
102
  atol=12 * np.sqrt(1 + positive_only) * noise * Gl_magn, rtol=0)
103
+
104
+
105
+ @pytest.mark.parametrize("stat, lambda_", [('F', 42)])
106
+ @pytest.mark.parametrize("positive_only", [False, True])
107
+ def test_wn_eval_other(sve_logistic, stat, lambda_, positive_only):
108
+ basis = sparse_ir.FiniteTempBasis(stat, 1, lambda_,
109
+ sve_result=sve_logistic[lambda_])
110
+ smpl = sparse_ir.MatsubaraSampling(basis, positive_only=positive_only)
111
+
112
+ n2 = [1, 3, 7]
113
+ smpl2 = sparse_ir.MatsubaraSampling(basis, sampling_points=n2)
114
+
115
+ rhol = basis.v([+.998, -.01, .5]) @ [0.8, -.2, 0.5]
116
+ Gl = basis.s * rhol
117
+ Gl_magn = np.linalg.norm(Gl)
118
+ np.testing.assert_allclose(smpl.evaluate(Gl, points=n2), smpl2.evaluate(Gl),
119
+ rtol=1e-15 * Gl_magn)
120
+
121
+
122
+ @pytest.mark.parametrize("stat, lambda_", [('F', 42)])
123
+ def test_tau_eval_other(sve_logistic, stat, lambda_):
124
+ basis = sparse_ir.FiniteTempBasis(stat, 1, lambda_,
125
+ sve_result=sve_logistic[lambda_])
126
+ smpl = sparse_ir.TauSampling(basis)
127
+
128
+ n2 = (0.1, 0.4)
129
+ smpl2 = sparse_ir.TauSampling(basis, sampling_points=n2)
130
+
131
+ rhol = basis.v([+.998, -.01, .5]) @ [0.8, -.2, 0.5]
132
+ Gl = basis.s * rhol
133
+ Gl_magn = np.linalg.norm(Gl)
134
+ np.testing.assert_allclose(smpl.evaluate(Gl, points=n2), smpl2.evaluate(Gl),
135
+ rtol=1e-15 * Gl_magn)
sparse-ir-0.97.0/PKG-INFO DELETED
@@ -1,147 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: sparse-ir
3
- Version: 0.97.0
4
- Summary: intermediate representation (IR) basis for electronic propagator
5
- Home-page: https://github.com/SpM-lab/sparse-ir
6
- Author: ['Markus Wallerberger', 'Hiroshi Shinaoka', 'Kazuyoshi Yoshimi', 'Junya Otsuki', 'Chikano Naoya']
7
- Author-email: markus.wallerberger@tuwien.ac.at
8
- License: UNKNOWN
9
- Description: sparse-ir - A library for the intermediate representation of propagators
10
- ========================================================================
11
- This library provides routines for constructing and working with the
12
- intermediate representation of correlation functions. It provides:
13
-
14
- - on-the-fly computation of basis functions for arbitrary cutoff Λ
15
- - basis functions and singular values are accurate to full precision
16
- - routines for sparse sampling
17
-
18
-
19
- Installation
20
- ------------
21
- Install via `pip <https://pypi.org/project/sparse-ir>`_::
22
-
23
- pip install sparse-ir[xprec]
24
-
25
- The above line is the recommended way to install `sparse-ir`. It automatically
26
- installs the `xprec <https://github.com/tuwien-cms/xprec>`_ package, which
27
- allows one to compute the IR basis functions with greater accuracy. If you do
28
- not want to do this, simply remove the string ``[xprec]`` from the above command.
29
-
30
- Install via `conda <https://anaconda.org/spm-lab/sparse-ir>`_::
31
-
32
- conda install -c spm-lab sparse-ir xprec
33
-
34
- Other than the optional xprec dependency, sparse-ir requires only
35
- `numpy <https://numpy.org/>`_ and `scipy <https://scipy.org/>`_.
36
-
37
- To manually install the current development version, you can use the following::
38
-
39
- # Only recommended for developers - no automatic updates!
40
- git clone https://github.com/SpM-lab/sparse-ir
41
- pip install -e sparse-ir/[xprec]
42
-
43
- Documentation and tutorial
44
- --------------------------
45
- Check out our `comprehensive tutorial`_, where we self-contained
46
- notebooks for several many-body methods - GF(2), GW, Eliashberg equations,
47
- Lichtenstein formula, FLEX, ... - are presented.
48
-
49
- Refer to the `API documentation`_ for more details on how to work
50
- with the python library.
51
-
52
- There is also a `Julia library`_ and (currently somewhat restricted)
53
- `Fortran library`_ available for the IR basis and sparse sampling.
54
-
55
- .. _comprehensive tutorial: https://spm-lab.github.io/sparse-ir-tutorial
56
- .. _API documentation: https://sparse-ir.readthedocs.io
57
- .. _Julia library: https://github.com/SpM-lab/SparseIR.jl
58
- .. _Fortran library: https://github.com/SpM-lab/sparse-ir-fortran
59
-
60
- Getting started
61
- ---------------
62
- Here is a full second-order perturbation theory solver (GF(2)) in a few
63
- lines of Python code::
64
-
65
- # Construct the IR basis and sparse sampling for fermionic propagators
66
- import sparse_ir, numpy as np
67
- basis = sparse_ir.FiniteTempBasis('F', beta=10, wmax=8, eps=1e-6)
68
- stau = sparse_ir.TauSampling(basis)
69
- siw = sparse_ir.MatsubaraSampling(basis, positive_only=True)
70
-
71
- # Solve the single impurity Anderson model coupled to a bath with a
72
- # semicircular states with unit half bandwidth.
73
- U = 1.2
74
- def rho0w(w):
75
- return np.sqrt(1-w.clip(-1,1)**2) * 2/np.pi
76
-
77
- # Compute the IR basis coefficients for the non-interacting propagator
78
- rho0l = basis.v.overlap(rho0w)
79
- G0l = -basis.s * rho0l
80
-
81
- # Self-consistency loop: alternate between second-order expression for the
82
- # self-energy and the Dyson equation until convergence.
83
- Gl = G0l
84
- Gl_prev = 0
85
- while np.linalg.norm(Gl - Gl_prev) > 1e-6:
86
- Gl_prev = Gl
87
- Gtau = stau.evaluate(Gl)
88
- Sigmatau = U**2 * Gtau**3
89
- Sigmal = stau.fit(Sigmatau)
90
- Sigmaiw = siw.evaluate(Sigmal)
91
- G0iw = siw.evaluate(G0l)
92
- Giw = 1/(1/G0iw - Sigmaiw)
93
- Gl = siw.fit(Giw)
94
-
95
- You may want to start with reading up on the `intermediate representation`_.
96
- It is tied to the analytic continuation of bosonic/fermionic spectral
97
- functions from (real) frequencies to imaginary time, a transformation mediated
98
- by a kernel ``K``. The kernel depends on a cutoff, which you should choose to
99
- be ``lambda_ >= beta * W``, where ``beta`` is the inverse temperature and ``W``
100
- is the bandwidth.
101
-
102
- One can now perform a `singular value expansion`_ on this kernel, which
103
- generates two sets of orthonormal basis functions, one set ``v[l](w)`` for
104
- real frequency side ``w``, and one set ``u[l](tau)`` for the same obejct in
105
- imaginary (Euclidean) time ``tau``, together with a "coupling" strength
106
- ``s[l]`` between the two sides.
107
-
108
- By this construction, the imaginary time basis can be shown to be *optimal* in
109
- terms of compactness.
110
-
111
- .. _intermediate representation: https://arxiv.org/abs/2106.12685
112
- .. _singular value expansion: https://w.wiki/3poQ
113
-
114
- License and citation
115
- --------------------
116
- This software is released under the MIT License. See LICENSE.txt for details.
117
-
118
- If you find the intermediate representation, sparse sampling, or this software
119
- useful in your research, please consider citing the following papers:
120
-
121
- - Hiroshi Shinaoka et al., `Phys. Rev. B 96, 035147`_ (2017)
122
- - Jia Li et al., `Phys. Rev. B 101, 035144`_ (2020)
123
- - Markus Wallerberger et al., `arXiv 2206.11762`_ (2022)
124
-
125
- If you are discussing sparse sampling in your research specifically, please
126
- also consider citing an independently discovered, closely related approach, the
127
- MINIMAX isometry method (Merzuk Kaltak and Georg Kresse,
128
- `Phys. Rev. B 101, 205145`_, 2020).
129
-
130
- .. _Phys. Rev. B 96, 035147: https://doi.org/10.1103/PhysRevB.96.035147
131
- .. _Phys. Rev. B 101, 035144: https://doi.org/10.1103/PhysRevB.101.035144
132
- .. _arXiv 2206.11762: https://doi.org/10.48550/arXiv.2206.11762
133
- .. _Phys. Rev. B 101, 205145: https://doi.org/10.1103/PhysRevB.101.205145
134
-
135
- Keywords: irbasis
136
- Platform: UNKNOWN
137
- Classifier: Development Status :: 4 - Beta
138
- Classifier: Intended Audience :: Developers
139
- Classifier: Intended Audience :: Science/Research
140
- Classifier: Topic :: Scientific/Engineering :: Physics
141
- Classifier: License :: OSI Approved :: MIT License
142
- Classifier: Programming Language :: Python :: 3
143
- Requires-Python: >=3
144
- Description-Content-Type: text/x-rst
145
- Provides-Extra: doc
146
- Provides-Extra: test
147
- Provides-Extra: xprec
@@ -1,147 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: sparse-ir
3
- Version: 0.97.0
4
- Summary: intermediate representation (IR) basis for electronic propagator
5
- Home-page: https://github.com/SpM-lab/sparse-ir
6
- Author: ['Markus Wallerberger', 'Hiroshi Shinaoka', 'Kazuyoshi Yoshimi', 'Junya Otsuki', 'Chikano Naoya']
7
- Author-email: markus.wallerberger@tuwien.ac.at
8
- License: UNKNOWN
9
- Description: sparse-ir - A library for the intermediate representation of propagators
10
- ========================================================================
11
- This library provides routines for constructing and working with the
12
- intermediate representation of correlation functions. It provides:
13
-
14
- - on-the-fly computation of basis functions for arbitrary cutoff Λ
15
- - basis functions and singular values are accurate to full precision
16
- - routines for sparse sampling
17
-
18
-
19
- Installation
20
- ------------
21
- Install via `pip <https://pypi.org/project/sparse-ir>`_::
22
-
23
- pip install sparse-ir[xprec]
24
-
25
- The above line is the recommended way to install `sparse-ir`. It automatically
26
- installs the `xprec <https://github.com/tuwien-cms/xprec>`_ package, which
27
- allows one to compute the IR basis functions with greater accuracy. If you do
28
- not want to do this, simply remove the string ``[xprec]`` from the above command.
29
-
30
- Install via `conda <https://anaconda.org/spm-lab/sparse-ir>`_::
31
-
32
- conda install -c spm-lab sparse-ir xprec
33
-
34
- Other than the optional xprec dependency, sparse-ir requires only
35
- `numpy <https://numpy.org/>`_ and `scipy <https://scipy.org/>`_.
36
-
37
- To manually install the current development version, you can use the following::
38
-
39
- # Only recommended for developers - no automatic updates!
40
- git clone https://github.com/SpM-lab/sparse-ir
41
- pip install -e sparse-ir/[xprec]
42
-
43
- Documentation and tutorial
44
- --------------------------
45
- Check out our `comprehensive tutorial`_, where we self-contained
46
- notebooks for several many-body methods - GF(2), GW, Eliashberg equations,
47
- Lichtenstein formula, FLEX, ... - are presented.
48
-
49
- Refer to the `API documentation`_ for more details on how to work
50
- with the python library.
51
-
52
- There is also a `Julia library`_ and (currently somewhat restricted)
53
- `Fortran library`_ available for the IR basis and sparse sampling.
54
-
55
- .. _comprehensive tutorial: https://spm-lab.github.io/sparse-ir-tutorial
56
- .. _API documentation: https://sparse-ir.readthedocs.io
57
- .. _Julia library: https://github.com/SpM-lab/SparseIR.jl
58
- .. _Fortran library: https://github.com/SpM-lab/sparse-ir-fortran
59
-
60
- Getting started
61
- ---------------
62
- Here is a full second-order perturbation theory solver (GF(2)) in a few
63
- lines of Python code::
64
-
65
- # Construct the IR basis and sparse sampling for fermionic propagators
66
- import sparse_ir, numpy as np
67
- basis = sparse_ir.FiniteTempBasis('F', beta=10, wmax=8, eps=1e-6)
68
- stau = sparse_ir.TauSampling(basis)
69
- siw = sparse_ir.MatsubaraSampling(basis, positive_only=True)
70
-
71
- # Solve the single impurity Anderson model coupled to a bath with a
72
- # semicircular states with unit half bandwidth.
73
- U = 1.2
74
- def rho0w(w):
75
- return np.sqrt(1-w.clip(-1,1)**2) * 2/np.pi
76
-
77
- # Compute the IR basis coefficients for the non-interacting propagator
78
- rho0l = basis.v.overlap(rho0w)
79
- G0l = -basis.s * rho0l
80
-
81
- # Self-consistency loop: alternate between second-order expression for the
82
- # self-energy and the Dyson equation until convergence.
83
- Gl = G0l
84
- Gl_prev = 0
85
- while np.linalg.norm(Gl - Gl_prev) > 1e-6:
86
- Gl_prev = Gl
87
- Gtau = stau.evaluate(Gl)
88
- Sigmatau = U**2 * Gtau**3
89
- Sigmal = stau.fit(Sigmatau)
90
- Sigmaiw = siw.evaluate(Sigmal)
91
- G0iw = siw.evaluate(G0l)
92
- Giw = 1/(1/G0iw - Sigmaiw)
93
- Gl = siw.fit(Giw)
94
-
95
- You may want to start with reading up on the `intermediate representation`_.
96
- It is tied to the analytic continuation of bosonic/fermionic spectral
97
- functions from (real) frequencies to imaginary time, a transformation mediated
98
- by a kernel ``K``. The kernel depends on a cutoff, which you should choose to
99
- be ``lambda_ >= beta * W``, where ``beta`` is the inverse temperature and ``W``
100
- is the bandwidth.
101
-
102
- One can now perform a `singular value expansion`_ on this kernel, which
103
- generates two sets of orthonormal basis functions, one set ``v[l](w)`` for
104
- real frequency side ``w``, and one set ``u[l](tau)`` for the same obejct in
105
- imaginary (Euclidean) time ``tau``, together with a "coupling" strength
106
- ``s[l]`` between the two sides.
107
-
108
- By this construction, the imaginary time basis can be shown to be *optimal* in
109
- terms of compactness.
110
-
111
- .. _intermediate representation: https://arxiv.org/abs/2106.12685
112
- .. _singular value expansion: https://w.wiki/3poQ
113
-
114
- License and citation
115
- --------------------
116
- This software is released under the MIT License. See LICENSE.txt for details.
117
-
118
- If you find the intermediate representation, sparse sampling, or this software
119
- useful in your research, please consider citing the following papers:
120
-
121
- - Hiroshi Shinaoka et al., `Phys. Rev. B 96, 035147`_ (2017)
122
- - Jia Li et al., `Phys. Rev. B 101, 035144`_ (2020)
123
- - Markus Wallerberger et al., `arXiv 2206.11762`_ (2022)
124
-
125
- If you are discussing sparse sampling in your research specifically, please
126
- also consider citing an independently discovered, closely related approach, the
127
- MINIMAX isometry method (Merzuk Kaltak and Georg Kresse,
128
- `Phys. Rev. B 101, 205145`_, 2020).
129
-
130
- .. _Phys. Rev. B 96, 035147: https://doi.org/10.1103/PhysRevB.96.035147
131
- .. _Phys. Rev. B 101, 035144: https://doi.org/10.1103/PhysRevB.101.035144
132
- .. _arXiv 2206.11762: https://doi.org/10.48550/arXiv.2206.11762
133
- .. _Phys. Rev. B 101, 205145: https://doi.org/10.1103/PhysRevB.101.205145
134
-
135
- Keywords: irbasis
136
- Platform: UNKNOWN
137
- Classifier: Development Status :: 4 - Beta
138
- Classifier: Intended Audience :: Developers
139
- Classifier: Intended Audience :: Science/Research
140
- Classifier: Topic :: Scientific/Engineering :: Physics
141
- Classifier: License :: OSI Approved :: MIT License
142
- Classifier: Programming Language :: Python :: 3
143
- Requires-Python: >=3
144
- Description-Content-Type: text/x-rst
145
- Provides-Extra: doc
146
- Provides-Extra: test
147
- Provides-Extra: xprec
File without changes
File without changes
File without changes
File without changes
File without changes