Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import os
  2. import numpy as np
  3. import readdy
  4.  
  5.  
  6. system = readdy.ReactionDiffusionSystem(box_size=[10., 10., 10.])
  7.  
  8. system.add_species("A", 1.0)
  9.  
  10. sim = system.simulation("SingleCPU")
  11.  
  12. sim.output_file = "out.h5"
  13.  
  14. if os.path.exists("checkpoints/"):
  15. # load checkpoint
  16. sim.load_particles_from_latest_checkpoint("checkpoints/")
  17. else:
  18. # new positions
  19. init_pos = np.random.uniform(size=(100, 3)) * 10. - 5.
  20. sim.add_particles("A", init_pos)
  21.  
  22. # this also creates the directory, if it does not exist
  23. sim.make_checkpoints(100, output_directory="checkpoints/", max_n_saves=5)
  24.  
  25. if os.path.exists(sim.output_file):
  26. os.remove(sim.output_file)
  27.  
  28. sim.run(1000, 0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement