I wish to run several instances of a simulation in parallel, but with each simulation having its own independent data set.
Currently I implement this as follows:
P = mp.Pool(ncpus) # Generate pool of workers
for j in range(nrun): # Generate processes
sim = MDF.Simulation(tstep, temp, time, writeout, boundaryxy, boundaryz, relax, insert, lat,savetemp)
lattice = MDF.Lattice(tstep, temp, time, writeout, boundaryxy, boundaryz, relax, insert, lat, kb, ks, kbs, a, p, q, massL, randinit, initvel, parangle,scaletemp,savetemp)
adatom1 = MDF.Adatom(tstep, temp, time, writeout, boundaryxy, boundaryz, relax, insert, lat, ra, massa, amorse, bmorse, r0, z0, name, lattice, samplerate,savetemp)
P.apply_async(run,(j,sim,lattice,adatom1),callback=After) # run simulation and ISF analysis in each process
P.close()
P.join() # start processes
where sim
, adatom1
and lattice
are objects passed to the function run
which initiates the simulation.
However, I recently found out that each batch I run simultaneously (that is, each ncpus
runs out of the total nrun
of simulations runs) gives the exact same results.
Can someone here enlighten how to fix this?
See Question&Answers more detail:
os