Skip to content

Commit

Permalink
Merging python and numba versions of nbody/init.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rolanddenis committed Dec 1, 2017
1 parent 2da5b53 commit 017e452
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nbody/python/nbody/init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from .physics import gamma_1
from .physics import gamma_1, gamma_si

def init_solar_system():
bodies = np.array([[ 0, 0, 0, 0], #sun
Expand Down Expand Up @@ -33,7 +33,7 @@ def getOrbitalVelocity(xb, yb, mb, xs, ys):
dist = np.sqrt(r[0] * r[0] + r[1] * r[1])

# Based on the distance from the sun calculate the velocity needed to maintain a circular orbit
v = np.sqrt(gamma_1 * mb / dist)
v = np.sqrt(gamma_si * mb / dist)

# Calculate a suitable vector perpendicular to r for the velocity of the tracer
vxs = ( r[1] / dist) * v
Expand Down Expand Up @@ -65,7 +65,7 @@ def init_collisions(blackHole):

nstars = b['stars']
rad = b['radstars']
r = 0.1 + .8 * (rad * np.random.rand(nstars))
r = 0.3 + .8 * (rad * np.random.rand(nstars))
a = 2*np.pi*np.random.rand(nstars)
tmp_mass = 0.03 + 20*np.random.rand(nstars)
x = b['coord'][0] + r*np.sin(a)
Expand All @@ -75,8 +75,8 @@ def init_collisions(blackHole):

particles[ind:ind+nstars, 0] = x
particles[ind:ind+nstars, 1] = y
particles[ind:ind+nstars, 2] = 1e2 * (vx + vxb)
particles[ind:ind+nstars, 3] = 1e2 * (vy + vyb)
particles[ind:ind+nstars, 2] = vx + vxb
particles[ind:ind+nstars, 3] = vy + vyb
mass[ind:ind+nstars] = tmp_mass
ind += nstars

Expand Down

0 comments on commit 017e452

Please sign in to comment.