Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
kwant
kwant
Commits
4413cb95
Verified
Commit
4413cb95
authored
Aug 30, 2020
by
Anton Akhmerov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix multiple warnings (mostly deprecations)
Closes
#386
parent
f6b04814
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
19 deletions
+28
-19
doc/source/conf.py
doc/source/conf.py
+1
-1
kwant/continuum/discretizer.py
kwant/continuum/discretizer.py
+3
-2
kwant/plotter.py
kwant/plotter.py
+12
-5
kwant/qsymm.py
kwant/qsymm.py
+4
-1
kwant/solvers/common.py
kwant/solvers/common.py
+7
-9
kwant/tests/test_qsymm.py
kwant/tests/test_qsymm.py
+1
-1
No files found.
doc/source/conf.py
View file @
4413cb95
...
...
@@ -38,7 +38,7 @@ sys.path.insert(0, os.path.abspath('../sphinxext'))
extensions
=
[
'sphinx.ext.autodoc'
,
'sphinx.ext.autosummary'
,
'sphinx.ext.todo'
,
'sphinx.ext.mathjax'
,
'numpydoc'
,
'kwantdoc'
,
'sphinx.ext.linkcode'
,
'jupyter_sphinx
.execute
'
,
'kwantdoc'
,
'sphinx.ext.linkcode'
,
'jupyter_sphinx'
,
'sphinxcontrib.rsvgconverter'
]
# Add any paths that contain templates here, relative to this directory.
...
...
kwant/continuum/discretizer.py
View file @
4413cb95
...
...
@@ -15,6 +15,7 @@ import numpy as np
import
tinyarray
as
ta
import
sympy
from
sympy.matrices.matrices
import
MatrixBase
from
sympy.utilities.lambdify
import
lambdastr
from
sympy.printing.lambdarepr
import
LambdaPrinter
from
sympy.printing.precedence
import
precedence
...
...
@@ -211,7 +212,7 @@ def discretize_symbolic(hamiltonian, coords=None, *, locals=None):
onsite_zeros
=
(
0
,)
*
len
(
coords
)
if
not
isinstance
(
hamiltonian
,
sympy
.
matrices
.
MatrixBase
):
if
not
isinstance
(
hamiltonian
,
MatrixBase
):
hamiltonian
=
sympy
.
Matrix
([
hamiltonian
])
_input_format
=
'expression'
else
:
...
...
@@ -574,7 +575,7 @@ def _return_string(expr, coords):
expr
=
expr
.
subs
(
map_func_calls
)
if
isinstance
(
expr
,
sympy
.
matrices
.
MatrixBase
):
if
isinstance
(
expr
,
MatrixBase
):
# express matrix return values in terms of sums of known matrices,
# which will be assigned to '_cache_n' in the function body.
mons
=
monomials
(
expr
,
expr
.
atoms
(
sympy
.
Symbol
))
...
...
kwant/plotter.py
View file @
4413cb95
...
...
@@ -2179,9 +2179,11 @@ def _spectrum_matplotlib(syst, x, y=None, params=None, mask=None, file=None,
# plot_surface cannot directly handle rank-3 values, so we
# explicitly loop over the last axis
grid
=
np
.
meshgrid
(
*
array_values
)
for
i
in
range
(
spectrum
.
shape
[
-
1
]):
spec
=
spectrum
[:,
:,
i
].
transpose
()
# row-major to x-y ordering
ax
.
plot_surface
(
*
(
grid
+
[
spec
]),
cstride
=
1
,
rstride
=
1
)
with
warnings
.
catch_warnings
():
warnings
.
filterwarnings
(
'ignore'
,
message
=
'Z contains NaN values'
)
for
i
in
range
(
spectrum
.
shape
[
-
1
]):
spec
=
spectrum
[:,
:,
i
].
transpose
()
# row-major to x-y ordering
ax
.
plot_surface
(
*
(
grid
+
[
spec
]),
cstride
=
1
,
rstride
=
1
)
_maybe_output_fig
(
fig
,
file
=
file
,
show
=
show
)
...
...
@@ -2324,8 +2326,13 @@ def _interpolate_field(dim, elements, discrete_field, bbox, width,
# Coordinates of the grid points that are within range of the current
# hopping.
coords
=
np
.
meshgrid
(
*
[
region
[
d
][
field_slice
[
d
]]
for
d
in
range
(
dim
)],
sparse
=
True
,
indexing
=
'ij'
)
coords
=
np
.
array
(
np
.
meshgrid
(
*
[
region
[
d
][
field_slice
[
d
]]
for
d
in
range
(
dim
)],
sparse
=
True
,
indexing
=
'ij'
),
dtype
=
object
)
# Convert "coords" into scaled distances from pos_offset
coords
-=
pos_offsets
[
i
]
...
...
kwant/qsymm.py
View file @
4413cb95
...
...
@@ -18,12 +18,15 @@ import scipy.linalg as la
try
:
import
sympy
import
sympy.matrices.matrices
import
qsymm
from
qsymm.model
import
Model
,
BlochModel
,
BlochCoeff
from
qsymm.groups
import
PointGroupElement
,
ContinuousGroupGenerator
from
qsymm.symmetry_finder
import
bravais_point_group
from
qsymm.linalg
import
allclose
from
qsymm.hamiltonian_generator
import
hamiltonian_from_family
one
=
sympy
.
S
.
One
except
ImportError
as
error
:
msg
=
(
"'kwant.qsymm' is not available because one or more of its "
"dependencies is not installed."
)
...
...
@@ -346,7 +349,7 @@ def model_to_builder(model, norbs, lat_vecs, atom_coords, *, coeffs=None):
for
atom
in
atoms
:
if
atom
not
in
onsites_dict
:
onsites_dict
[
atom
]
=
Model
(
{
sympy
.
numbers
.
One
()
:
np
.
zeros
((
norbs
[
atom
],
norbs
[
atom
]))},
{
one
:
np
.
zeros
((
norbs
[
atom
],
norbs
[
atom
]))},
momenta
=
momenta
)
# Make the Kwant system, and set all onsites and hoppings.
...
...
kwant/solvers/common.py
View file @
4413cb95
...
...
@@ -841,12 +841,10 @@ class SMatrix(BlockResult):
block_offsets
.
append
(
block_offset
)
# Symmetry block offsets for all leads - or None if lead does not have
# blocks.
self
.
block_offsets
=
block_offsets
block_offsets
=
np
.
array
(
block_offsets
,
dtype
=
object
)
# Pick out symmetry block offsets for in and out leads
self
.
in_block_offsets
=
\
np
.
array
(
self
.
block_offsets
)[
list
(
self
.
in_leads
)]
self
.
out_block_offsets
=
\
np
.
array
(
self
.
block_offsets
)[
list
(
self
.
out_leads
)]
self
.
_in_block_offsets
=
block_offsets
[
list
(
self
.
in_leads
)]
self
.
_out_block_offsets
=
block_offsets
[
list
(
self
.
out_leads
)]
# Block j of in lead i starts at in_block_offsets[i][j]
def
out_block_coords
(
self
,
lead_out
):
...
...
@@ -860,9 +858,9 @@ class SMatrix(BlockResult):
lead_ind
,
block_ind
=
lead_out
lead_ind
=
self
.
out_leads
.
index
(
lead_ind
)
return
slice
(
self
.
out_offsets
[
lead_ind
]
+
self
.
out_block_offsets
[
lead_ind
][
block_ind
],
self
.
_
out_block_offsets
[
lead_ind
][
block_ind
],
self
.
out_offsets
[
lead_ind
]
+
self
.
out_block_offsets
[
lead_ind
][
block_ind
+
1
])
self
.
_
out_block_offsets
[
lead_ind
][
block_ind
+
1
])
def
in_block_coords
(
self
,
lead_in
):
"""
...
...
@@ -876,9 +874,9 @@ class SMatrix(BlockResult):
lead_ind
,
block_ind
=
lead_in
lead_ind
=
self
.
in_leads
.
index
(
lead_ind
)
return
slice
(
self
.
in_offsets
[
lead_ind
]
+
self
.
in_block_offsets
[
lead_ind
][
block_ind
],
self
.
_
in_block_offsets
[
lead_ind
][
block_ind
],
self
.
in_offsets
[
lead_ind
]
+
self
.
in_block_offsets
[
lead_ind
][
block_ind
+
1
])
self
.
_
in_block_offsets
[
lead_ind
][
block_ind
+
1
])
def
_transmission
(
self
,
lead_out
,
lead_in
):
return
np
.
linalg
.
norm
(
self
.
submatrix
(
lead_out
,
lead_in
))
**
2
...
...
kwant/tests/test_qsymm.py
View file @
4413cb95
...
...
@@ -180,7 +180,7 @@ def test_graphene_to_kwant():
assert
allclose
(
hamiltonian2
,
hamiltonian3
)
# Include random onsites as well
one
=
sympy
.
numbers
.
One
()
one
=
sympy
.
S
.
One
onsites
=
[
Model
({
one
:
np
.
array
([[
1
,
0
],
[
0
,
0
]])},
momenta
=
family
[
0
].
momenta
),
Model
({
one
:
np
.
array
([[
0
,
0
],
[
0
,
1
]])},
momenta
=
family
[
0
].
momenta
)]
family
=
family
+
onsites
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment