4 from random
import uniform
6 def sphericalToCartesian(r,theta, phi = 0):
7 return [ r*cos(theta)*cos(phi), r*sin(theta)*cos(phi), r*sin(phi) ]
10 class CollisionCourseTest(abstract.IntegrationTest):
13 integrator=
"hermite_cpu",
14 time_step_factor=0.017,
18 deactivate_on_collision=1,
22 def createEnsemble(self):
26 orbit_velocity = sqrt(1/orbit_radius)
30 for i,s
in enumerate(ens):
37 phi_base = uniform(0,2*pi)
39 for j,b
in enumerate(s):
47 phi = phi_base + (j-1)*2*pi/(ens.nbod-1)
49 b.pos = sphericalToCartesian(orbit_radius, phi)
50 b.vel = sphericalToCartesian( -1**j * orbit_velocity, phi+ pi/2)
56 self.assertEqual(s.state, -1)