Example #1
0
 def new_particles_with_internal_structure_from_models(self):
     def get_internal_structure(set, particle=None):
         return self.models[(set.key == particle.key).nonzero()[0]]
     
     result = Particles(len(self.models))
     result.add_function_attribute("get_internal_structure", None, get_internal_structure)
     result.mass = [model.dmass.sum().as_quantity_in(self.mass_unit) for model in self.models]
     result.radius = [model.radius[-1].as_quantity_in(self.radius_unit) for model in self.models]
     result.position = (self.original_center_of_mass + self.stars_after_encounter.position).as_quantity_in(self.position_unit)
     result.velocity = (self.original_center_of_mass_velocity + self.stars_after_encounter.velocity).as_quantity_in(self.velocity_unit)
     return result
Example #2
0
 def new_particles_with_internal_structure_from_models(self):
     def get_internal_structure(set, particle=None):
         return self.models[(set.key == particle.key).nonzero()[0]]
     
     result = Particles(len(self.models))
     result.add_function_attribute("get_internal_structure", None, get_internal_structure)
     result.mass = [model.dmass.sum().as_quantity_in(self.mass_unit) for model in self.models]
     result.radius = [model.radius[-1].as_quantity_in(self.radius_unit) for model in self.models]
     result.position = (self.original_center_of_mass + self.stars_after_encounter.position).as_quantity_in(self.position_unit)
     result.velocity = (self.original_center_of_mass_velocity + self.stars_after_encounter.velocity).as_quantity_in(self.velocity_unit)
     return result
Example #3
0
 def handle_collision(self, primary, secondary, stellar_evolution_code=None):
     result = Particles(1)
     result.mass = self.next_mass.as_quantity_in(self.parameters.mass_unit)
     self.next_mass += 1 | units.kg
     
     if not stellar_evolution_code is None:
         se_colliders = (primary + secondary).get_intersecting_subset_in(stellar_evolution_code.particles)
         result.radius = se_colliders.radius.sum()
         
         def internal_structure(set, particle=None):
             return dict(mass=result.mass, radius=result.radius)
         
         result.add_function_attribute("internal_structure", None, internal_structure)
     
     return result
 def handle_collision(self, primary, secondary, stellar_evolution_code=None):
     result = Particles(1)
     result.mass = self.next_mass.as_quantity_in(self.parameters.mass_unit)
     self.next_mass += 1 | units.kg
     
     if not stellar_evolution_code is None:
         se_colliders = (primary + secondary).get_intersecting_subset_in(stellar_evolution_code.particles)
         result.radius = se_colliders.radius.sum()
         
         def get_internal_structure(set, particle=None):
             return dict(mass=result.mass, radius=result.radius)
         
         result.add_function_attribute("get_internal_structure", None, get_internal_structure)
     
     return result