Skip to content
Snippets Groups Projects
Commit 684b9aa1 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

More simplifications of script to generate ICs

parent cc2dfa53
Branches
Tags
No related merge requests found
...@@ -49,10 +49,10 @@ print 'G in internal units: ', const_G ...@@ -49,10 +49,10 @@ print 'G in internal units: ', const_G
# Parameters # Parameters
periodic= 1 # 1 For periodic box periodic = 1 # 1 For periodic box
boxSize = 100. # boxSize = 100. #
Radius = boxSize / 4. # maximum radius of particles max_radius = boxSize / 4. # maximum radius of particles
Mass = 1e10 Mass = 1e10
print "Mass at the centre: ", Mass print "Mass at the centre: ", Mass
numPart = int(sys.argv[1]) # Number of particles numPart = int(sys.argv[1]) # Number of particles
...@@ -95,22 +95,23 @@ grp.attrs["Unit temperature in cgs (U_T)"] = 1. ...@@ -95,22 +95,23 @@ grp.attrs["Unit temperature in cgs (U_T)"] = 1.
grp1 = file.create_group("/PartType1") grp1 = file.create_group("/PartType1")
#generate particle positions #generate particle positions
radius = Radius * (numpy.random.rand(numPart))**(1./3.) radius = max_radius * (numpy.random.rand(numPart))**(1./3.)
ctheta = -1. + 2 * numpy.random.rand(numPart) print '---------------------'
stheta = numpy.sqrt(1.-ctheta**2) print 'Radius: minimum = ',min(radius)
phi = 2 * math.pi * numpy.random.rand(numPart) print 'Radius: maximum = ',max(radius)
radius = numpy.sort(radius)
r = numpy.zeros((numPart, 3)) r = numpy.zeros((numPart, 3))
r[:,0] = radius r[:,0] = radius
#generate particle velocities #generate particle velocities
speed = numpy.sqrt(const_G * Mass / radius) speed = numpy.sqrt(const_G * Mass / radius)
v = numpy.zeros((numPart, 3))
omega = speed / radius omega = speed / radius
period = 2.*math.pi/omega period = 2.*math.pi/omega
print '---------------------' print '---------------------'
print 'Period: minimum = ',min(period) print 'Period: minimum = ',min(period)
print 'Period: maximum = ',max(period) print 'Period: maximum = ',max(period)
v = numpy.zeros((numPart, 3))
v[:,0] = -omega * r[:,1] v[:,0] = -omega * r[:,1]
v[:,1] = omega * r[:,0] v[:,1] = omega * r[:,0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment