Dear KWANT team, I am currently trying to write a program to try to calculate the spin Hall angle in a 4-terminal normal metal using Kwant 1.3 and the conservation law module. The scattering region is a square 40x40. I run in to a problem when trying to run it. The error message I get is: *** Error in `python3': malloc(): memory corruption: 0x00000000034f0de0 *** ======= Backtrace: ========= and then a bunch of stuff, and in the end [Finished in 29.6s with exit code -6] It seems to crash when I make the system too big or for too many energies. But, I don't understand why it doesn't work to solve the problem at one energy, store the result (which is just one number), and then for another. It seems the results from the other runs are somehow stored? I am not that experienced when it comes to programming, so I don't know if the problem is at my end or not. Thanks in advance, Camilla ------------------------------ Here is my code as well: import kwant import tinyarray as ta import numpy as np from scipy import sparse import matplotlib from matplotlib import pyplot s0 = ta.array([[1, 0], [0, 1]]) sx = ta.array([[0, 1], [1, 0]]) sy = ta.array([[0, -1j], [1j, 0]]) sz = ta.array([[1, 0], [0, -1]]) def calculate_sh_conductance(smatrix, leadIn, leadOut): con = -smatrix.transmission((leadOut, 0),(leadIn, 0)) + smatrix.transmission((leadOut, 1),(leadIn, 1)) return con def make_system(t=1.0, W=40, L=40, lead_W = 40): # Now we must specify the number of orbitals per site. lat = kwant.lattice.square(norbs=2) syst = kwant.Builder() """ We define the system below. The s-parameters are site parameters. The onsite has 1 site-parameter, while the hopping has two. The form of the functions must be like this, because Kwant requires it. """ syst[(lat(x, y) for x in range(L) for y in range(W))] = \ lambda s, alpha, phi: 0*4 * t * s0 # The last term here is the AF onsite coupling. syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = \ lambda s1, s2, alpha, phi: -t * s0 - 1j * alpha * sy syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = \ lambda s1, s2, alpha, phi: -t * s0 + 1j * alpha * sx ### Make the leads ### # Side leads lead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0)), conservation_law=-sz, time_reversal=s0) lead[(lat(0, j) for j in range(W))] =0* 4 * t * s0 lead[lat.neighbors()] = -t * s0 # Note: no spin-orbit in the lead. # Top/bottom leads lead_tb = kwant.Builder(kwant.TranslationalSymmetry((0,-1)), conservation_law =-sz, time_reversal=s0) # We define the start and end fo the lead start = int(L/2 - lead_W/2) end = int(L/2 + lead_W/2) lead_tb[(lat(j,0) for j in range(start,end))] = 0*4 * t * s0 lead_tb[lat.neighbors()] = -t * s0 syst.attach_lead(lead) syst.attach_lead(lead.reversed()) syst.attach_lead(lead_tb) syst.attach_lead(lead_tb.reversed()) syst = syst.finalized() return syst def main(): syst = make_system(t=1.0, W=40, L=40, lead_W = 40) energies = np.linspace(-4,4, 200) socos = 0.5 fig = pyplot.figure(figsize=(13,8)) ax = fig.add_subplot(1, 1, 1) print("Starting spin calculation") conductance = [] # Calculate spin Hall conductance for energy in energies: smatrix= kwant.smatrix(syst, energy=energy, args=(socos, 0)) addi = calculate_sh_conductance(smatrix, 0, 3) conductance.append(addi) print(energy) ax.plot(energies, conductance, label="SOC %s" % socos) ax.legend(fontsize='x-large'); pyplot.show() if __name__ == '__main__': main()