Hi Alex,

The way Bas is doing it is one way of doing it - it acts on the template system combining it hopping functions with Peierls phase.
There is also another code out there that could be useful - it is however work in progress code so you need to check if it gives you what you want.

It requires you however to use the discretizer from continuum module introduced in Kwant 1.3.
This approach is based on three steps:

  1. Discretize symbolically continuous Hamitonian to the tight-binding form
  2. Modify hoppings with Peierls phase
  3. build discretized system.

You can find required codes here and example notebook here.

Please be aware that these method uses the same gauge (vector potential) for the whole system.

Just choose the approach that fits more your code.

Best,
Rafal

P.S. Please be aware that in current code there phi_0 is defined as h/(2e) instead of h/e.




On 20 September 2017 at 10:59, Bas Nijholt <basnijholt@gmail.com> wrote:

Hi Alex,

The trick is to add the Peierls phase after you discretized your Hamiltonian, I do it in the following way:

def apply_peierls_to_template(template, xyz_offset=(0, 0, 0)):
    template = deepcopy(template)  # Needed because kwant.Builder is mutable
    x0, y0, z0 = xyz_offset
    lat = template.lattice
    a = np.max(lat.prim_vecs)  # lattice contant

    def phase(site1, site2, B_x, B_y, B_z, orbital, e, hbar):
        x, y, z = site1.tag
        direction = site2.tag - site1.tag
        A = [B_y * (z - z0) - B_z * (y - y0), 0, B_x * (y - y0)]
        A = np.dot(A, direction) * a**2 * 1e-18 * e / hbar
        phase = np.exp(-1j * A)

        if lat.norbs == 2:  # No PH degrees of freedom
            return phase
        elif lat.norbs == 4:
            return np.array([phase, phase.conj(), phase, phase.conj()],
                            dtype='complex128')

    for (site1, site2), hop in template.hopping_value_pairs():
        template[site1, site2] = combine(hop, phase, operator.mul, 2)

    return template

You can apply this function to your template builder. In short, it does this combine(hop, phase, operator.mul, 2), which is creating a new function from the phase function and the hopping function and combining the arguments.

You would probably need to adjust the form of the vector potential, the units (this is using nm) and change the form of the phase function.

I have attached the combine.py script you will need to combine the functions.

Please let me know whether it works or not.


Best, Bas


On Tue, Sep 19, 2017 at 11:26 PM, Alex Currie <alexjcurrie95@gmail.com> wrote:
Dear All,

I have a Hamaltonian (BHZ hamiltonian) and i'm trying to introduce a magnetic field. I believe I have to use the Peierls phase, however i'm not sure how to implement this after I have finalized the BHZ hamiltonian. Any assistance is appreciated. I will paste the code i have to generate my hamiltonian. You can find more information about the BHZ hamiltonian here: arxiv:0801.0901

"""
import kwant
import numpy as np
import scipy.linalg as la
import scipy.sparse.linalg as sla

import sympy

import matplotlib.pyplot as plt

from ipywidgets import interact


Gamma_so = [[0, 0, 0, -1],
            [0, 0, +1, 0],
            [0, +1, 0, 0],
            [-1, 0, 0, 0]]

hamiltonian = """
   + M * kron(sigma_0, sigma_z)
   - B * (k_x**2 + k_y**2) * kron(sigma_0, sigma_z)
   - D * (k_x**2 + k_y**2) * kron(sigma_0, sigma_0)
   + A * k_x * kron(sigma_z, sigma_x)
   - A * k_y * kron(sigma_0, sigma_y)
   + Delta * Gamma_so
"""

params_bhz=dict(A=364.5, B=-686, D=-512, M=-10, Delta=1.6)

hamiltonian = kwant.continuum.sympify(hamiltonian, locals=dict(Gamma_so=Gamma_so))
hamiltonian

grid_spacing = 5
template = kwant.continuum.discretize(hamiltonian, grid_spacing=grid_spacing)

syst = kwant.wraparound.wraparound(template)
syst = syst.finalized()

"""

Best,

Alex