Simulation code accompanying manuscript