Exemplo n.º 1
0
 def new_particle(self, index_of_the_particle,
                  mass, radius, x, y, z, vx, vy, vz):
     ps = ParticleSystem(nstars=1)
     ps.mass[0] = mass
     ps.radius[0] = radius
     ps.rx[0] = x
     ps.ry[0] = y
     ps.rz[0] = z
     ps.vx[0] = vx
     ps.vy[0] = vy
     ps.vz[0] = vz
     self.particles.append(ps)
     index_of_the_particle.value = len(self.particles)-1
     return 0
Exemplo n.º 2
0
def set_particles(n):
    import numpy as np
    from tupan.particles.allparticles import ParticleSystem
    ps = ParticleSystem(n - n // 2, n // 2)
    ps.mass[...] = np.random.random((ps.n, ))
    ps.eps2[...] = np.zeros((ps.n, ))
    ps.rx[...], ps.ry[...], ps.rz[...] = np.random.random((ps.n, 3)).T * 10
    ps.vx[...], ps.vy[...], ps.vz[...] = np.random.random((ps.n, 3)).T * 10
    return ps
Exemplo n.º 3
0
 def commit_particles(self):
     num = len(self.particles)
     ps = ParticleSystem(nstars=num)
     for (i, p) in enumerate(self.particles):
         ps.id[i] = i
         ps.mass[i] = p.mass
         ps.radius[i] = p.radius   # XXX: 'radius' is not yet used in Tupan.
         ps.eps2[i] = self.eps2/2
         ps.rx[i] = p.rx
         ps.ry[i] = p.ry
         ps.rz[i] = p.rz
         ps.vx[i] = p.vx
         ps.vy[i] = p.vy
         ps.vz[i] = p.vz
     self.integrator = Integrator(self.eta,
                                  self.time_begin,
                                  ps,
                                  method=self.integrator_method,
                                  pn_order=self.pn_order,
                                  clight=self.clight)
     return 0