Dear Adel thanks a lot. very useful.
Best

Garanti sans virus. www.avast.com

Le lun. 7 sept. 2020 à 16:17, Abbout Adel <abbout.adel@gmail.com> a écrit :
Dear Adel,

The post by Christoph you are referring to is just a reflection and an invitation to think about parallelization in kwant.
It is not implemented in kwant. As the error message suggests, there is no argument  "comm=MPI.COMM_WORLD" in the scattering matrix.

If you want to run your code in parallel, you can do a simple change in your code as follows:




import numpy as np
import kwant
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
nprocessor = comm.size


def make_sys():
      .....
      .....
      return sys.finalized()


sys=make_sys()
energies=np.arange(k/nprocessor,(k+1)/nprocessor,20)

T=[]
for energy in energies:
         Sm=kwant.smatrix(sys,energy=energy)
         T.append(Sm.transmission(0,1))

np.save("Transmission"+str(k)+".npy",np.array(T))



##########
So, your code will return a number  "nprocessor" .npy files of the transmission, each one of them is for a range of energies.


I hope this helps
Adel




On Sun, Sep 6, 2020 at 2:43 PM Adel Belayadi <adelphys@gmail.com> wrote:
Dear user
I hope you are doing well.
I am having troubles when using parallel distribution to run my python script using kwant.

I  went through kwant discuss mailing list and tried to read about similar issues. I have red for instance the comment made by hristoph Groth Mon, 08 Aug 2016 08:12:46 -0700.
add "from mpi4py import MPI" in the preamble,
• substitute kwant.smatrix(…) -> kwant.smatrix(…, comm=MPI.COMM_WORLD), • execute the script using "mpiexec",

I have got an error while using kwant.smatrix(comm=MPI.COMM_WORLD).
kwant does not recognize comm
TypeError: got an unexpected keyword argument 'comm'

I have also tried without comm but with the following command
OMP_NUM_THREADS=1
mpiexec -n 4 python file.py
or
mpirun.openmpi -n 4 -x OMP_NUM_THREADS=1 python file.py

but I got the result 4 times

Regards
BELAYADI


--
Abbout Adel