def test2(self): instance = AarsethZare() particles = datamodel.Particles(3) particles.mass = 1.0 | nbody_system.mass particles.position = [ [-10.0, 0.0, 0.0], [0.0, 0.0, 0.0], [10.0, 0.0, 0.0], ] | nbody_system.length particles.velocity = [0.0, 0.0, 0.0] | nbody_system.speed instance.particles.add_particles(particles) instance.evolve_model(1.0 | nbody_system.time) self.assertAlmostRelativeEquals(instance.particles.y, [0, 0, 0] | nbody_system.length) self.assertAlmostRelativeEquals(instance.particles.z, [0, 0, 0] | nbody_system.length) self.assertAlmostRelativeEquals(instance.particles.x[-1], -instance.particles.x[0], 10) self.assertAlmostRelativeEquals(instance.particles.x[1], 0 | nbody_system.length, 10) self.assertAlmostRelativeEquals(instance.particles.vx[-1], -instance.particles.vx[0], 10) self.assertAlmostRelativeEquals(instance.particles.vx[1], 0 | nbody_system.speed, 10) self.assertAlmostRelativeEquals(instance.particles.vy, [0, 0, 0] | nbody_system.speed) self.assertAlmostRelativeEquals(instance.particles.vz, [0, 0, 0] | nbody_system.speed)
def test3(self): instance = AarsethZare( nbody_system.nbody_to_si(1.0 | units.yr, 1.0 | units.MSun)) particles = self.new_system_of_sun_and_earth_and_moon() instance.particles.add_particles(particles) earth = instance.particles[1] position_at_start = earth.position[0] instance.evolve_model(365.0 | units.day) position_after_full_rotation = earth.position[0] self.assertAlmostRelativeEquals(position_at_start, position_after_full_rotation, 4) instance.evolve_model(1.5 | units.yr) position_after_half_a_rotation = earth.position[0] self.assertAlmostRelativeEquals(-position_at_start, position_after_half_a_rotation, 2) instance.evolve_model(1.75 | units.yr) position_after_quarter_a_rotation = earth.position[1] self.assertAlmostRelativeEquals(position_at_start, position_after_quarter_a_rotation, 2) instance.stop()
def test3(self): instance = AarsethZare(nbody_system.nbody_to_si(1.0 | units.yr, 1.0 | units.MSun)) particles = self.new_system_of_sun_and_earth_and_moon() instance.particles.add_particles(particles) earth = instance.particles[1] position_at_start = earth.position[0] instance.evolve_model(365.0 | units.day) position_after_full_rotation = earth.position[0] self.assertAlmostRelativeEquals(position_at_start, position_after_full_rotation, 4) instance.evolve_model(1.5 | units.yr) position_after_half_a_rotation = earth.position[0] self.assertAlmostRelativeEquals(-position_at_start, position_after_half_a_rotation, 2) instance.evolve_model(1.75 | units.yr) position_after_quarter_a_rotation = earth.position[1] self.assertAlmostRelativeEquals(position_at_start, position_after_quarter_a_rotation, 2) instance.stop()
def test1(self): instance = AarsethZare() time, x, y, z, vx, vy, vz = instance.evolve_triple( [0, 0, 0] | nbody_system.time, [1, 1, 1] | nbody_system.mass, [-10, 0, 10] | nbody_system.length, [0, 0, 0] | nbody_system.length, [0, 0, 0] | nbody_system.length, [0, 0, 0] | nbody_system.speed, [0, 0, 0] | nbody_system.speed, [0, 0, 0] | nbody_system.speed, [1.0, 1.0, 1.0] | nbody_system.time) self.assertAlmostRelativeEquals(y, [0, 0, 0] | nbody_system.length) self.assertAlmostRelativeEquals(z, [0, 0, 0] | nbody_system.length) self.assertAlmostRelativeEquals(x[-1], -x[0], 10) self.assertAlmostRelativeEquals(x[1], 0 | nbody_system.length, 10) self.assertAlmostRelativeEquals(vx[-1], -vx[0], 10) self.assertAlmostRelativeEquals(vx[1], 0 | nbody_system.speed, 10) self.assertAlmostRelativeEquals(vy, [0, 0, 0] | nbody_system.speed) self.assertAlmostRelativeEquals(vz, [0, 0, 0] | nbody_system.speed)
def test1(self): instance = AarsethZare() time, x, y, z, vx, vy, vz = instance.evolve_triple( [0,0,0] | nbody_system.time, [1,1,1] | nbody_system.mass, [-10, 0, 10] | nbody_system.length, [0,0,0] | nbody_system.length, [0,0,0] | nbody_system.length, [0,0,0] | nbody_system.speed, [0,0,0] | nbody_system.speed, [0,0,0] | nbody_system.speed, [1.0,1.0,1.0]| nbody_system.time ) self.assertAlmostRelativeEquals(y, [0,0,0] | nbody_system.length) self.assertAlmostRelativeEquals(z, [0,0,0] | nbody_system.length ) self.assertAlmostRelativeEquals(x[-1], -x[0], 10 ) self.assertAlmostRelativeEquals(x[1], 0 | nbody_system.length , 10) self.assertAlmostRelativeEquals(vx[-1], -vx[0], 10) self.assertAlmostRelativeEquals(vx[1], 0 | nbody_system.speed, 10) self.assertAlmostRelativeEquals(vy, [0,0,0] | nbody_system.speed) self.assertAlmostRelativeEquals(vz, [0,0,0] | nbody_system.speed)
def test2(self): instance = AarsethZare() particles = datamodel.Particles(3) particles.mass = 1.0 | nbody_system.mass particles.position = [ [-10.0, 0.0, 0.0], [0.0, 0.0, 0.0], [10.0, 0.0, 0.0], ] | nbody_system.length particles.velocity = [0.0, 0.0, 0.0] | nbody_system.speed instance.particles.add_particles(particles) instance.evolve_model(1.0 | nbody_system.time) self.assertAlmostRelativeEquals(instance.particles.y, [0,0,0] | nbody_system.length) self.assertAlmostRelativeEquals(instance.particles.z, [0,0,0] | nbody_system.length ) self.assertAlmostRelativeEquals(instance.particles.x[-1], -instance.particles.x[0], 10 ) self.assertAlmostRelativeEquals(instance.particles.x[1], 0 | nbody_system.length , 10) self.assertAlmostRelativeEquals(instance.particles.vx[-1], -instance.particles.vx[0], 10) self.assertAlmostRelativeEquals(instance.particles.vx[1], 0 | nbody_system.speed, 10) self.assertAlmostRelativeEquals(instance.particles.vy, [0,0,0] | nbody_system.speed) self.assertAlmostRelativeEquals(instance.particles.vz, [0,0,0] | nbody_system.speed)
def test0(self): instance = AarsethZare() instance.stop()