From c51391a4b6e16eca848b4e1ca01336bc7b20bf21 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 18 Nov 2019 11:30:35 -0600 Subject: 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! --- utils/gen-dark-matter | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/gen-dark-matter') 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)) -- cgit