Skip to content
Snippets Groups Projects
Commit 7c802539 authored by Joseph Weston's avatar Joseph Weston
Browse files

correct closed system example

Previously, an erroneous current was shown at *zero* magnetic field,
which was due to a choice of degenerate eigenvalue. Now we evaluate
the current and density at finite magnetic field, to demonstrate
the intended effect.

Closes #150.
parent c0b21712
No related branches found
No related tags found
No related merge requests found
@@ -1,140 +1,157 @@ @@ -1,144 +1,162 @@
# Tutorial 2.4.2. Closed systems # Tutorial 2.4.2. Closed systems
# ============================== # ==============================
# #
...@@ -94,14 +94,19 @@ ...@@ -94,14 +94,19 @@
+ fig.savefig("closed_system_result." + extension, dpi=_defs.dpi) + fig.savefig("closed_system_result." + extension, dpi=_defs.dpi)
#HIDDEN_END_yvri #HIDDEN_END_yvri
def sorted_eigs(ev):
evals, evecs = ev
- evals, evecs = map(np.array, zip(*sorted(zip(evals, evecs.transpose())))
+ evals, evecs = map(np.array, zip(*sorted(zip(evals, evecs.transpose()))))
return evals, evecs.transpose()
#HIDDEN_BEGIN_wave #HIDDEN_BEGIN_wave
def plot_wave_function(syst): def plot_wave_function(syst, B=0.001):
+ size = (_defs.figwidth_in, _defs.figwidth_in) + size = (_defs.figwidth_in, _defs.figwidth_in)
+ +
# Calculate the wave functions in the system. # Calculate the wave functions in the system.
ham_mat = syst.hamiltonian_submatrix(sparse=True) ham_mat = syst.hamiltonian_submatrix(sparse=True, args=[B])
evecs = sla.eigsh(ham_mat, k=20, which='SM')[1] evals, evecs = sorted_eigs(sla.eigsh(ham_mat, k=20, which='SM'))
# Plot the probability density of the 10th eigenmode. # Plot the probability density of the 10th eigenmode.
- kwant.plotter.map(syst, np.abs(evecs[:, 9])**2, - kwant.plotter.map(syst, np.abs(evecs[:, 9])**2,
...@@ -115,16 +120,16 @@ ...@@ -115,16 +120,16 @@
#HIDDEN_BEGIN_current #HIDDEN_BEGIN_current
def plot_current(syst): def plot_current(syst, B=0.001):
+ size = (_defs.figwidth_in, _defs.figwidth_in) + size = (_defs.figwidth_in, _defs.figwidth_in)
+ +
# Calculate the wave functions in the system. # Calculate the wave functions in the system.
ham_mat = syst.hamiltonian_submatrix(sparse=True) ham_mat = syst.hamiltonian_submatrix(sparse=True, args=[B])
evecs = sla.eigsh(ham_mat, k=20, which='SM')[1] evals, evecs = sorted_eigs(sla.eigsh(ham_mat, k=20, which='SM'))
# Calculate and plot the local current of the 10th eigenmode. # Calculate and plot the local current of the 10th eigenmode.
J = kwant.operator.Current(syst) J = kwant.operator.Current(syst)
current = J(evecs[:, 9]) current = J(evecs[:, 9], args=[B])
- kwant.plotter.current(syst, current, colorbar=False) - kwant.plotter.current(syst, current, colorbar=False)
+ for extension in ('pdf', 'png'): + for extension in ('pdf', 'png'):
+ kwant.plotter.current( + kwant.plotter.current(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment