コード例 #1
0
ファイル: main.py プロジェクト: nordam/PyPPT
# set all particles initially to rank 0, so the other ranks will load empty arrays
# id_init, active_init, XY_init = IO.create_grid_of_particles(N = 10**2, w = 0.1)
# if rank == 0:
    # IO.save_grid_of_particles(id_init, active_init, XY_init, t_0, rank, input = True)
# else:
    # IO.save_empty_grid_to_input(t_0, rank)

# then load the particle grid for the given rank

ids, active, XY = IO.load_grid_of_particles(rank, time = 0, input = True)
if rank == 0:
    Nparticles = np.sum(active)

# start at initial time
t = t_0
IO.save_grid_of_particles(ids, active, XY, t, rank)
#plot.plot(rank, XY[:,active], t, dt)

# main loop
print('\nstart time = %s' % t)

# Communicating, to avoid bad load balancing at the beginning
print('This is rank %s, communicating before mainloop' % (rank))
ids, XY, active = communication.exchange(comm, mpi_size, rank, ids, XY[0,:], XY[1,:], active)

while t + dt <= t_max:
    # Take Ndt timesteps
        
    # only take active particles into transport function
    # non-active particles should be in the end of the arrays,
    # so if we want we can use the index as XY[:,:np.sum(active)] instead