Exemplo n.º 1
0
 def test7(self):
     convert_nbody = nbody_system.nbody_to_si(5.0 | units.kg, 10.0 | units.m)
 
     instance = FDPS(convert_nbody)
     instance.commit_parameters()
     
     particles = datamodel.Particles(2)
     self.assertEquals(len(instance.particles), 0)
     
     particles.mass = [15.0, 30.0] | units.kg
     particles.radius =  [10.0, 20.0] | units.m
     particles.position = [[10.0, 20.0, 30.0], [20.0, 40.0, 60.0]] | units.m
     particles.velocity = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] | units.m / units.s
 
     
     instance.particles.add_particles(particles)
     instance.commit_particles()
     
     self.assertEquals(instance.get_mass(0), 15.0| units.kg)
     self.assertAlmostRelativeEquals(instance.get_position(0)[2], 30.0| units.m)
     
     self.assertEquals(len(instance.particles), 2)
     
     
     self.assertAlmostRelativeEquals(instance.particles.mass[1], 30.0 | units.kg)
     self.assertAlmostRelativeEquals(instance.particles.position[1][2], 60.0 | units.m)   
     instance.cleanup_code()
     instance.stop()
Exemplo n.º 2
0
    def test5(self):

        instance = FDPS()
        instance.commit_parameters()
        
        index = instance.new_particle(
            15.0 | nbody_system.mass,
            10.0 | nbody_system.length, 20.0 | nbody_system.length, 30.0 | nbody_system.length,
            1.0 | nbody_system.speed, 1.0 | nbody_system.speed, 3.0 | nbody_system.speed,
            10.0 | nbody_system.length
        )
        instance.commit_particles()
        self.assertEquals(instance.get_mass(index), 15.0| nbody_system.mass)
        self.assertEquals(instance.get_radius(index), 10.0| nbody_system.length)
        
        instance.cleanup_code()
        instance.stop()
Exemplo n.º 3
0
    def test4(self):
        convert_nbody = nbody_system.nbody_to_si(5.0 | units.kg, 10.0 | units.m)

        instance = FDPS(convert_nbody)
        instance.commit_parameters()
        
        index = instance.new_particle(
            15.0 | units.kg,
            10.0 | units.m, 20.0 | units.m, 30.0 | units.m,
            #1.0 | units.m/units.s, 1.0 | units.m/units.s, 3.0 | units.m/units.s
            0.0 | units.m/units.s, 0.0 | units.m/units.s, 0.0 | units.m/units.s,
            10.0 | units.m
        )
        instance.commit_particles()
        self.assertEquals(instance.get_mass(index), 15.0| units.kg)
        self.assertEquals(instance.get_radius(index), 10.0| units.m)
        instance.cleanup_code()
        instance.stop()
Exemplo n.º 4
0
 def test6(self):
     convert_nbody = nbody_system.nbody_to_si(5.0 | units.kg, 10.0 | units.m)
     instance = FDPS(convert_nbody)
     instance.commit_parameters()
     
     indices = instance.new_particle(
         [15.0, 30.0] | units.kg,
         [10.0, 20.0] | units.m, [20.0, 40.0] | units.m, [30.0, 50.0] | units.m,
         #1.0 | units.m/units.s, 1.0 | units.m/units.s, 3.0 | units.m/units.s
         [0.0, 0.01] | units.m/units.s, [0.0, 0.01] | units.m/units.s, [0.0, 0.01] | units.m/units.s,
         [10.0, 20.0] | units.m
     )
     instance.commit_particles()
     
     self.assertEquals(instance.get_mass(indices[0]), 15.0| units.kg)
     self.assertEquals(instance.get_mass(indices)[0], 15.0| units.kg)
     
     self.assertRaises(AmuseException, instance.get_mass, [4,5], 
         expected_message = "Error when calling 'get_mass' of a 'FDPS', errorcode is -1")
     
     instance.cleanup_code()
     instance.stop()