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

doc: update continuum tutorial to match changes to API

parent 3f675e33
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@
def lattice_spacing():
@@ -158,7 +171,7 @@
@@ -159,7 +172,7 @@
plot(ax1, a=1)
plot(ax2, a=.25)
......@@ -67,8 +67,8 @@
def substitutions():
@@ -171,14 +184,20 @@
sympify('k_x**2 * sz + alpha * k_x * sx', substitutions=subs),
@@ -172,14 +185,20 @@
sympify('k_x**2 * sz + alpha * k_x * sx', subs=subs),
)
- print(e[0] == e[1] == e[2])
......@@ -77,10 +77,10 @@
+ print(e[0] == e[1] == e[2])
subs = {'A': 'A(x) + B', 'V': 'V(x) + V_0', 'C': 5}
- print(sympify('k_x * A * k_x + V + C', substitutions=subs))
- print(sympify('k_x * A * k_x + V + C', subs=subs))
+ with open('discretizer_subs_2.txt', 'w') as f:
+ with redirect_stdout(f):
+ print(sympify('k_x * A * k_x + V + C', substitutions=subs))
+ print(sympify('k_x * A * k_x + V + C', subs=subs))
def main():
......
......@@ -143,7 +143,7 @@ def lattice_spacing():
def plot(ax, a=1):
#HIDDEN_BEGIN_ls_hk_cont
h_k = kwant.continuum.lambdify(hamiltonian, substitutions=params)
h_k = kwant.continuum.lambdify(hamiltonian, subs=params)
k_cont = np.linspace(-4, 4, 201)
e_cont = [scipy.linalg.eigvalsh(h_k(k_x=ki)) for ki in k_cont]
#HIDDEN_END_ls_hk_cont
......@@ -190,7 +190,7 @@ def substitutions():
e = (
sympify('[[k_x**2, alpha * k_x], [k_x * alpha, -k_x**2]]'),
sympify('k_x**2 * sigma_z + alpha * k_x * sigma_x'),
sympify('k_x**2 * sz + alpha * k_x * sx', substitutions=subs),
sympify('k_x**2 * sz + alpha * k_x * sx', subs=subs),
)
print(e[0] == e[1] == e[2])
......@@ -198,7 +198,7 @@ def substitutions():
#HIDDEN_BEGIN_subs_2
subs = {'A': 'A(x) + B', 'V': 'V(x) + V_0', 'C': 5}
print(sympify('k_x * A * k_x + V + C', substitutions=subs))
print(sympify('k_x * A * k_x + V + C', subs=subs))
#HIDDEN_END_subs_2
......
......@@ -292,7 +292,7 @@ square ``[]`` brackets. For example, all following expressions are equivalent:
.. literalinclude:: ../images/discretizer_subs_1.txt
We can use the ``substitutions`` keyword parameter to substitute expressions
We can use the ``subs`` keyword parameter to substitute expressions
and numerical values:
.. literalinclude:: continuum_discretizer.py
......
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