Dear community:
I install `kwant-1.5.0` using `conda install -c conda-forge` both on my mac (M4 chip).
The install process goes fine, but it is not working properly.
The commands are:
```
mpirun -n 1 python test_kwant_mpi4py_v2.py
mpirun -n 10 python test_kwant_mpi4py_v2.py
```
The same code works fine on PC, and gives similar times (1.3s vs 1.8s). On mac, it is drastically different (0.4s vs 50s).
I can make it better by avoiding using mumps solver, the times are (1.2s vs 6.8s); while on windows they are 2.0s vs 4.1s.
Below is the code I used for test:
```
#!/usr/bin/env python
import time
from mpi4py import MPI
import kwant
# from kwant.solvers import sparse
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
def build_system(L=500, W=100, t=1.0):
lat = kwant.lattice.square(norbs=1)
syst = kwant.Builder()
for i in range(L):
for j in range(W):
syst[lat(i, j)] = 4 * t
if i > 0:
syst[lat(i, j), lat(i-1, j)] = -t
if j > 0:
syst[lat(i, j), lat(i, j-1)] = -t
sym = kwant.TranslationalSymmetry((-1, 0))
lead = kwant.Builder(sym)
for j in range(W):
lead[lat(0, j)] = 4 * t
lead[lat.neighbors()] = -t
syst.attach_lead(lead)
syst.attach_lead(lead.reversed())
return syst.finalized()
def compute_conductance(sys, energy=1.0):
smatrix = kwant.smatrix(sys, energy)
# smatrix = sparse.smatrix(sys, energy)
return smatrix.transmission(1, 0)
def main():
# Each rank builds its own system (no bcast)
sys = build_system()
comm.Barrier()
t0 = time.time()
g = compute_conductance(sys, energy=1.0)
comm.Barrier()
elapsed = time.time() - t0
# Gather results to rank 0
all_elapsed = comm.gather(elapsed, root=0)
all_g = comm.gather(g, root=0)
if rank == 0:
# print(f"Conductances: {all_g}")
# print(f"Elapsed times: {all_elapsed}")
print(f"Max elapsed time: {max(all_elapsed):.3f}s")
if __name__ == "__main__":
main()
```