diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-11-18 11:30:35 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-11-18 11:30:35 -0600 |
commit | c51391a4b6e16eca848b4e1ca01336bc7b20bf21 (patch) | |
tree | c1641296ea4461578dd760fc5fb2f94948599550 | |
parent | bf6b7fbdab8e3d3f025954fdb559310c452271e0 (diff) | |
download | sddm-c51391a4b6e16eca848b4e1ca01336bc7b20bf21.tar.gz sddm-c51391a4b6e16eca848b4e1ca01336bc7b20bf21.tar.bz2 sddm-c51391a4b6e16eca848b4e1ca01336bc7b20bf21.zip |
fix a bug in the position generation in gen-dark-matter
This commit fixes a bug in gen-dark matter which was causing the positions to
all be generated with positive x, y, and z values. Doh!
-rwxr-xr-x | utils/gen-dark-matter | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/utils/gen-dark-matter b/utils/gen-dark-matter index 007dde3..06b146f 100755 --- a/utils/gen-dark-matter +++ b/utils/gen-dark-matter @@ -145,12 +145,12 @@ MCPL_HEADER=""" class MyTemplate(string.Template): delimiter = '@' -def rand_sphere2(R): +def rand_ball(R): """ Generates a random point inside a sphere of radius R. """ while True: - pos = np.random.rand(3)*R + pos = (np.random.rand(3)*2-1)*R if np.linalg.norm(pos) < R: break @@ -323,7 +323,7 @@ if __name__ == '__main__': f.write("%i %i\n" % (args.n, 10)) for v1, v2 in islice(gen_decay(args.M,args.E,m1,m2),args.n): - pos = rand_sphere2(PSUP_RADIUS) + pos = rand_ball(PSUP_RADIUS) p1 = np.linalg.norm(v1[1:]) p2 = np.linalg.norm(v2[1:]) f.write(" %i %i %f %f %f %f %f %f %f %f\n" % (2,args.p1,pos[0], pos[1], pos[2],0.0, v1[0], v1[1]/p1, v1[2]/p1, v1[3]/p1)) |