Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dennis Heffels
kwant
Commits
b8646cb6
Commit
b8646cb6
authored
4 years ago
by
Pablo Piskunow
Committed by
Anton Akhmerov
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix pyflakes failure and lint
parent
7d354180
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kwant/kpm.py
+10
-3
10 additions, 3 deletions
kwant/kpm.py
with
10 additions
and
3 deletions
kwant/kpm.py
+
10
−
3
View file @
b8646cb6
...
@@ -27,7 +27,8 @@ __all__ = ['SpectralDensity', 'Correlator', 'conductivity',
...
@@ -27,7 +27,8 @@ __all__ = ['SpectralDensity', 'Correlator', 'conductivity',
'
RandomVectors
'
,
'
LocalVectors
'
,
'
jackson_kernel
'
,
'
lorentz_kernel
'
,
'
RandomVectors
'
,
'
LocalVectors
'
,
'
jackson_kernel
'
,
'
lorentz_kernel
'
,
'
fermi_distribution
'
]
'
fermi_distribution
'
]
SAMPLING
=
2
# number of sampling points to number of moments ratio
SAMPLING
=
2
# number of sampling points to number of moments ratio
class
SpectralDensity
:
class
SpectralDensity
:
r
"""
Calculate the spectral density of an operator.
r
"""
Calculate the spectral density of an operator.
...
@@ -211,7 +212,7 @@ class SpectralDensity:
...
@@ -211,7 +212,7 @@ class SpectralDensity:
num_moments
=
100
num_moments
=
100
if
num_moments
<=
0
or
num_moments
!=
int
(
num_moments
):
if
num_moments
<=
0
or
num_moments
!=
int
(
num_moments
):
raise
ValueError
(
"'
num_moments
'
must be a positive integer
"
)
raise
ValueError
(
"'
num_moments
'
must be a positive integer
"
)
if
vector_factory
is
None
:
if
vector_factory
is
None
:
self
.
_vector_factory
=
_VectorFactory
(
self
.
_vector_factory
=
_VectorFactory
(
...
@@ -248,6 +249,7 @@ class SpectralDensity:
...
@@ -248,6 +249,7 @@ class SpectralDensity:
def
energies
(
self
):
def
energies
(
self
):
return
(
self
.
_a
*
_chebyshev_nodes
(
SAMPLING
*
self
.
num_moments
)
return
(
self
.
_a
*
_chebyshev_nodes
(
SAMPLING
*
self
.
num_moments
)
+
self
.
_b
)
+
self
.
_b
)
@property
@property
def
num_vectors
(
self
):
def
num_vectors
(
self
):
return
len
(
self
.
_moments_list
)
return
len
(
self
.
_moments_list
)
...
@@ -733,6 +735,7 @@ class Correlator:
...
@@ -733,6 +735,7 @@ class Correlator:
e_scaled
=
(
self
.
energies
-
self
.
_b
)
/
self
.
_a
e_scaled
=
(
self
.
energies
-
self
.
_b
)
/
self
.
_a
m_array
=
np
.
arange
(
n_moments
)
m_array
=
np
.
arange
(
n_moments
)
def
_integral_factor
(
e
):
def
_integral_factor
(
e
):
# arrays for faster calculation
# arrays for faster calculation
sqrt_e
=
np
.
sqrt
(
1
-
e
**
2
)
sqrt_e
=
np
.
sqrt
(
1
-
e
**
2
)
...
@@ -956,6 +959,7 @@ class LocalVectors:
...
@@ -956,6 +959,7 @@ class LocalVectors:
must be a list of integers with the indices where column vectors
must be a list of integers with the indices where column vectors
are nonzero.
are nonzero.
"""
"""
def
__init__
(
self
,
syst
,
where
=
None
,
*
args
):
def
__init__
(
self
,
syst
,
where
=
None
,
*
args
):
self
.
tot_norbs
,
self
.
orbs
=
_normalize_orbs_where
(
syst
,
where
)
self
.
tot_norbs
,
self
.
orbs
=
_normalize_orbs_where
(
syst
,
where
)
self
.
_idx
=
0
self
.
_idx
=
0
...
@@ -976,6 +980,7 @@ class LocalVectors:
...
@@ -976,6 +980,7 @@ class LocalVectors:
# ### Auxiliary functions
# ### Auxiliary functions
def
fermi_distribution
(
energy
,
mu
,
temperature
):
def
fermi_distribution
(
energy
,
mu
,
temperature
):
"""
Returns the Fermi distribution f(e, µ, T) evaluated at
'
e
'
.
"""
Returns the Fermi distribution f(e, µ, T) evaluated at
'
e
'
.
...
@@ -997,6 +1002,7 @@ def fermi_distribution(energy, mu, temperature):
...
@@ -997,6 +1002,7 @@ def fermi_distribution(energy, mu, temperature):
else
:
else
:
return
1
/
(
1
+
np
.
exp
((
energy
-
mu
)
/
temperature
))
return
1
/
(
1
+
np
.
exp
((
energy
-
mu
)
/
temperature
))
def
_from_where_to_orbs
(
syst
,
where
):
def
_from_where_to_orbs
(
syst
,
where
):
"""
Returns a list of slices of the orbitals in
'
where
'"""
"""
Returns a list of slices of the orbitals in
'
where
'"""
assert
isinstance
(
syst
,
system
.
System
)
assert
isinstance
(
syst
,
system
.
System
)
...
@@ -1021,7 +1027,7 @@ def _normalize_orbs_where(syst, where):
...
@@ -1021,7 +1027,7 @@ def _normalize_orbs_where(syst, where):
tot_norbs
=
csr_matrix
(
syst
).
shape
[
0
]
tot_norbs
=
csr_matrix
(
syst
).
shape
[
0
]
except
TypeError
:
except
TypeError
:
raise
TypeError
(
"'
syst
'
is neither a matrix
"
raise
TypeError
(
"'
syst
'
is neither a matrix
"
"
nor a Kwant system.
"
)
"
nor a Kwant system.
"
)
orbs
=
(
range
(
tot_norbs
)
if
where
is
None
orbs
=
(
range
(
tot_norbs
)
if
where
is
None
else
np
.
asarray
(
where
,
int
))
else
np
.
asarray
(
where
,
int
))
return
tot_norbs
,
orbs
return
tot_norbs
,
orbs
...
@@ -1174,6 +1180,7 @@ def _rescale(hamiltonian, eps, v0, bounds):
...
@@ -1174,6 +1180,7 @@ def _rescale(hamiltonian, eps, v0, bounds):
return
rescaled_ham
,
(
a
,
b
)
return
rescaled_ham
,
(
a
,
b
)
def
_chebyshev_nodes
(
n_sampling
):
def
_chebyshev_nodes
(
n_sampling
):
"""
Return an array of
'
n_sampling
'
points in the interval (-1,1)
"""
"""
Return an array of
'
n_sampling
'
points in the interval (-1,1)
"""
raw
,
step
=
np
.
linspace
(
np
.
pi
,
0
,
n_sampling
,
raw
,
step
=
np
.
linspace
(
np
.
pi
,
0
,
n_sampling
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment