DifferentiableUniverseInitiative / flowpm

Particle Mesh simulation in TensorFlow
https://flowpm.readthedocs.io/
MIT License
90 stars 20 forks source link

Adds support for non cubic simulations #59

Closed EiffL closed 4 years ago

EiffL commented 4 years ago

This small PR generalizes the single GPU TensorFlow FlowPM to support non cubic volumes, for instance with one dimension far more extended than the other, for reasons ;-)

The changes are minimal, to create a rectangular simulation simply do the following:

initial_conditions = flowpm.linear_field([32,32,320],     # size of the cube
                                         [100,100,1000],  # Physical size of the cube
                                         ipklin,          # Initial powerspectrum
                                         batch_size=1)
state = flowpm.lpt_init(initial_conditions, a0=0.1)   
final_state = flowpm.nbody(state, stages, [32,32,320])    

and you get this pretty picture: image

It's tested against python_fastpm so should be good to go