Commits

remosu committed 4a10612

refactoring Simulation attributes

Comments (0)

Files changed (1)

 
 
 class CollisionRules(object):
-    def __init__(self, box, eps=1.0):
+    def __init__(self, box=None, eps=1.0):
         self.tolerance = 10.0e-10
         self.eps = eps
         self.radius = 1.0
-        self.box = box
+        self.box = box if box else Box()
 
     def collide(self, particle_i, particle_j):
         x_ij = particle_i.x - particle_j.x
 
 
 class Simulation(object):
-    def __init__(self, particles, box=None, collision_rules=None, nprint=1):
+    def __init__(self, particles, collision_rules=None, nprint=1):
         self.particles = particles
-        self.box = box if box else Box()
         if collision_rules is None:
-            collision_rules = CollisionRules(self.box)
+            collision_rules = CollisionRules()
         self.collision_rules = collision_rules
         self.events = dict()
         self.time = 0
 
 def create_simulation_from_files(coords_filename, vels_filename, **kwargs):
     particles = load_initial_particles(coords_filename, vels_filename)
-    return Simulation(particles, box=Box(kwargs['box_size']))
+    rules = CollisionRules(box=Box(kwargs['box_size']))
+    return Simulation(particles, rules)
 
 
 if __name__ == '__main__':