diff --git a/examples/UniformBox/makeIC.py b/examples/UniformBox/makeIC.py index 9865b6b0223f22645ec47e695146d1ffd4a86f38..fa8fb65b935001de02eb2c923ad53ea738bf0007 100644 --- a/examples/UniformBox/makeIC.py +++ b/examples/UniformBox/makeIC.py @@ -27,7 +27,7 @@ from numpy import * # Parameters periodic= 1 # 1 For periodic box boxSize = 1. -L = 100 # Number of particles along one axis +L = 1200 # Number of particles along one axis rho = 2. # Density P = 1. # Pressure gamma = 5./3. # Gas adiabatic index @@ -39,21 +39,6 @@ numPart = L**3 mass = boxSize**3 * rho / numPart internalEnergy = P / ((gamma - 1.)*rho) -#Generate particles -ids = linspace(0, numPart, numPart, endpoint=False, dtype='L').reshape((numPart,1)) -v = zeros((numPart, 3)) -m = full((numPart, 1), mass) -h = full((numPart, 1), 2.251 * boxSize / L) -u = full((numPart, 1), internalEnergy) - -x = ids % L; -y = ((ids - x) / L) % L; -z = (ids - x - L * y) / L**2; -coords = zeros((numPart, 3)) -coords[:,0] = z[:,0] * boxSize / L + boxSize / (2*L) -coords[:,1] = y[:,0] * boxSize / L + boxSize / (2*L) -coords[:,2] = x[:,0] * boxSize / L + boxSize / (2*L) - #-------------------------------------------------- #File @@ -77,17 +62,39 @@ grp.attrs["PeriodicBoundariesOn"] = periodic #Particle group grp = file.create_group("/PartType0") -ds = grp.create_dataset('Coordinates', (numPart, 3), 'd') -ds[()] = coords + +v = zeros((numPart, 3)) ds = grp.create_dataset('Velocities', (numPart, 3), 'f') ds[()] = v +v = zeros(1) + +m = full((numPart, 1), mass) ds = grp.create_dataset('Masses', (numPart,1), 'f') ds[()] = m +m = zeros(1) + +h = full((numPart, 1), 2.251 * boxSize / L) ds = grp.create_dataset('SmoothingLength', (numPart,1), 'f') ds[()] = h +h = zeros(1) + +u = full((numPart, 1), internalEnergy) ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f') ds[()] = u +u = zeros(1) + + +ids = linspace(0, numPart, numPart, endpoint=False, dtype='L').reshape((numPart,1)) ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L') ds[()] = ids +x = ids % L; +y = ((ids - x) / L) % L; +z = (ids - x - L * y) / L**2; +coords = zeros((numPart, 3)) +coords[:,0] = z[:,0] * boxSize / L + boxSize / (2*L) +coords[:,1] = y[:,0] * boxSize / L + boxSize / (2*L) +coords[:,2] = x[:,0] * boxSize / L + boxSize / (2*L) +ds = grp.create_dataset('Coordinates', (numPart, 3), 'd') +ds[()] = coords file.close()