In [1]:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt'bmh')
from numba import jit

The big picture idea of how to implement parallel transport calculations

In [5]:
# Dummy functions

def timestep(X, dt, t):
    # Use double gyre and RK4 to calculate new functions
    return X

def exchange(X):
    # Handle all the communication stuff here
    # return the updated particle arrays
    # (which may be of a different length now)
    return X

def save(X, filename):
    # save some data to disk, for example particle positions
    # (each rank can save its own particles to a separate file)

In [2]:
# Some parameters
# Number of particles
Np = 10000
# Integrator timestep
dt = 0.1
# Number of timesteps between each communication event
Ndt = 10
# Time to run simulation
Tmax = 10
t    = 0

# Get initial positions, from file or random or other
X = np.random.random((2, Np))

# Main loop
while t < Tmax:
    # Take Ndt timesteps
    for i in range(Ndt):
        X  = timestep(X, dt, t)
        t += dt
    # Then communicate
    X = exchange(X)
    # Then calculate concentration

In [ ]: