Commit 61d30d8f authored by Joseph Weston's avatar Joseph Weston

Merge branch 'stable'

parents 351fcf5e 843ee6d2
Pipeline #18900 passed with stages
in 35 minutes and 32 seconds
...@@ -202,7 +202,7 @@ energy eigenstates: ...@@ -202,7 +202,7 @@ energy eigenstates:
ham = syst.hamiltonian_submatrix(params=dict(V=potential), sparse=True) ham = syst.hamiltonian_submatrix(params=dict(V=potential), sparse=True)
evecs = scipy.sparse.linalg.eigsh(ham, k=10, which='SM')[1] evecs = scipy.sparse.linalg.eigsh(ham, k=10, which='SM')[1]
kwant.plotter.map(syst, abs(evecs[:, n])**2, show=False) kwant.plotter.density(syst, abs(evecs[:, n])**2, show=False)
.. jupyter-execute:: .. jupyter-execute::
:hide-code: :hide-code:
...@@ -281,7 +281,7 @@ and plot its dispersion using `kwant.plotter.bands`: ...@@ -281,7 +281,7 @@ and plot its dispersion using `kwant.plotter.bands`:
pyplot.show() pyplot.show()
In the above we see the edge states of the quantum spin Hall effect, which In the above we see the edge states of the quantum spin Hall effect, which
we can visualize using `kwant.plotter.map`: we can visualize using `kwant.plotter.density`:
.. jupyter-execute:: .. jupyter-execute::
...@@ -298,8 +298,8 @@ we can visualize using `kwant.plotter.map`: ...@@ -298,8 +298,8 @@ we can visualize using `kwant.plotter.map`:
rho_sz = sum(spin_density(psi) for psi in wf(0)) # states from left lead rho_sz = sum(spin_density(psi) for psi in wf(0)) # states from left lead
fig, (ax1, ax2) = pyplot.subplots(1, 2, sharey=True, figsize=(16, 4)) fig, (ax1, ax2) = pyplot.subplots(1, 2, sharey=True, figsize=(16, 4))
kwant.plotter.map(syst, wf_sqr, ax=ax1) kwant.plotter.density(syst, wf_sqr, ax=ax1)
kwant.plotter.map(syst, rho_sz, ax=ax2) kwant.plotter.density(syst, rho_sz, ax=ax2)
ax = ax1 ax = ax1
im = [obj for obj in ax.get_children() im = [obj for obj in ax.get_children()
......
...@@ -196,7 +196,7 @@ object that represents the density of states for this system. ...@@ -196,7 +196,7 @@ object that represents the density of states for this system.
fsyst = make_syst().finalized() fsyst = make_syst().finalized()
spectrum = kwant.kpm.SpectralDensity(fsyst) spectrum = kwant.kpm.SpectralDensity(fsyst, rng=0)
The `~kwant.kpm.SpectralDensity` can then be called like a function to obtain a The `~kwant.kpm.SpectralDensity` can then be called like a function to obtain a
sequence of energies in the spectrum of the Hamiltonian, and the corresponding sequence of energies in the spectrum of the Hamiltonian, and the corresponding
...@@ -319,7 +319,8 @@ and plot their respective local density of states. ...@@ -319,7 +319,8 @@ and plot their respective local density of states.
# 'num_vectors' can be unspecified when using 'LocalVectors' # 'num_vectors' can be unspecified when using 'LocalVectors'
local_dos = kwant.kpm.SpectralDensity(fsyst_staggered, num_vectors=None, local_dos = kwant.kpm.SpectralDensity(fsyst_staggered, num_vectors=None,
vector_factory=vector_factory, vector_factory=vector_factory,
mean=False) mean=False,
rng=0)
energies, densities = local_dos() energies, densities = local_dos()
.. jupyter-execute:: .. jupyter-execute::
...@@ -346,7 +347,7 @@ The simplest way to obtain a more accurate solution is to use the ...@@ -346,7 +347,7 @@ The simplest way to obtain a more accurate solution is to use the
.. jupyter-execute:: .. jupyter-execute::
:hide-code: :hide-code:
spectrum = kwant.kpm.SpectralDensity(fsyst) spectrum = kwant.kpm.SpectralDensity(fsyst, rng=0)
original_dos = spectrum() original_dos = spectrum()
.. jupyter-execute:: .. jupyter-execute::
...@@ -399,7 +400,7 @@ shape as the system Hamiltonian. ...@@ -399,7 +400,7 @@ shape as the system Hamiltonian.
# identity matrix # identity matrix
matrix_op = scipy.sparse.eye(len(fsyst.sites)) matrix_op = scipy.sparse.eye(len(fsyst.sites))
matrix_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=matrix_op) matrix_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=matrix_op, rng=0)
Or, to do the same calculation using `kwant.operator.Density`: Or, to do the same calculation using `kwant.operator.Density`:
...@@ -407,7 +408,7 @@ Or, to do the same calculation using `kwant.operator.Density`: ...@@ -407,7 +408,7 @@ Or, to do the same calculation using `kwant.operator.Density`:
# 'sum=True' means we sum over all the sites # 'sum=True' means we sum over all the sites
kwant_op = kwant.operator.Density(fsyst, sum=True) kwant_op = kwant.operator.Density(fsyst, sum=True)
operator_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=kwant_op) operator_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=kwant_op, rng=0)
Spectral density with random vectors Spectral density with random vectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -420,7 +421,7 @@ sum over all the sites of the system: ...@@ -420,7 +421,7 @@ sum over all the sites of the system:
# 'sum=False' is the default, but we include it explicitly here for clarity. # 'sum=False' is the default, but we include it explicitly here for clarity.
kwant_op = kwant.operator.Density(fsyst, sum=False) kwant_op = kwant.operator.Density(fsyst, sum=False)
local_dos = kwant.kpm.SpectralDensity(fsyst, operator=kwant_op) local_dos = kwant.kpm.SpectralDensity(fsyst, operator=kwant_op, rng=0)
`~kwant.kpm.SpectralDensity` will properly handle this vector output, `~kwant.kpm.SpectralDensity` will properly handle this vector output,
and will average the local density obtained with random vectors. and will average the local density obtained with random vectors.
...@@ -499,11 +500,13 @@ vectors ...@@ -499,11 +500,13 @@ vectors
# component 'xx' # component 'xx'
s_factory = kwant.kpm.LocalVectors(fsyst_topo, where) s_factory = kwant.kpm.LocalVectors(fsyst_topo, where)
cond_xx = kwant.kpm.conductivity(fsyst_topo, alpha='x', beta='x', mean=True, cond_xx = kwant.kpm.conductivity(fsyst_topo, alpha='x', beta='x', mean=True,
num_vectors=None, vector_factory=s_factory) num_vectors=None, vector_factory=s_factory,
rng=0)
# component 'xy' # component 'xy'
s_factory = kwant.kpm.LocalVectors(fsyst_topo, where) s_factory = kwant.kpm.LocalVectors(fsyst_topo, where)
cond_xy = kwant.kpm.conductivity(fsyst_topo, alpha='x', beta='y', mean=True, cond_xy = kwant.kpm.conductivity(fsyst_topo, alpha='x', beta='y', mean=True,
num_vectors=None, vector_factory=s_factory) num_vectors=None, vector_factory=s_factory,
rng=0)
energies = cond_xx.energies energies = cond_xx.energies
cond_array_xx = np.array([cond_xx(e, temperature=0.01) for e in energies]) cond_array_xx = np.array([cond_xx(e, temperature=0.01) for e in energies])
...@@ -528,7 +531,8 @@ the random vectors. ...@@ -528,7 +531,8 @@ the random vectors.
s_factory = kwant.kpm.LocalVectors(fsyst_topo, where) s_factory = kwant.kpm.LocalVectors(fsyst_topo, where)
spectrum = kwant.kpm.SpectralDensity(fsyst_topo, num_vectors=None, spectrum = kwant.kpm.SpectralDensity(fsyst_topo, num_vectors=None,
vector_factory=s_factory) vector_factory=s_factory,
rng=0)
plot_dos_and_curves( plot_dos_and_curves(
(spectrum.energies, spectrum.densities * 8), (spectrum.energies, spectrum.densities * 8),
...@@ -570,7 +574,8 @@ and which returns a vector in that Hilbert space: ...@@ -570,7 +574,8 @@ and which returns a vector in that Hilbert space:
yield np.rint(np.random.random_sample(n)) * 2 - 1 yield np.rint(np.random.random_sample(n)) * 2 - 1
custom_factory = kwant.kpm.SpectralDensity(fsyst, custom_factory = kwant.kpm.SpectralDensity(fsyst,
vector_factory=binary_vectors()) vector_factory=binary_vectors(),
rng=0)
Aditionally, a `~kwant.kpm.LocalVectors` generator is also available, that Aditionally, a `~kwant.kpm.LocalVectors` generator is also available, that
returns local vectors that correspond to the sites passed. Note that returns local vectors that correspond to the sites passed. Note that
...@@ -613,8 +618,8 @@ methods for computing the local density of states, one using ...@@ -613,8 +618,8 @@ methods for computing the local density of states, one using
def rho_alt(bra, ket): def rho_alt(bra, ket):
return np.vdot(bra, ket) return np.vdot(bra, ket)
rho_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=rho) rho_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=rho, rng=0)
rho_alt_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=rho_alt) rho_alt_spectrum = kwant.kpm.SpectralDensity(fsyst, operator=rho_alt, rng=0)
__ operator_spectral_density_ __ operator_spectral_density_
......
...@@ -165,7 +165,7 @@ inside the scattering region. The z component is shown by the color scale: ...@@ -165,7 +165,7 @@ inside the scattering region. The z component is shown by the color scale:
def plot_densities(syst, densities): def plot_densities(syst, densities):
fig, axes = plt.subplots(1, len(densities), figsize=(13, 10)) fig, axes = plt.subplots(1, len(densities), figsize=(13, 10))
for ax, (title, rho) in zip(axes, densities): for ax, (title, rho) in zip(axes, densities):
kwant.plotter.map(syst, rho, ax=ax, a=4) kwant.plotter.density(syst, rho, ax=ax)
ax.set_title(title) ax.set_title(title)
plt.show() plt.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment