From dde8809ab981e33baa03b6fc106d72518d0bc6f0 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Thu, 10 Mar 2016 19:03:57 +0000
Subject: [PATCH] Modified all IC generation scripts to make sure all IDs are
 >0

---
 examples/BigCosmoVolume/makeIC.py      | 2 +-
 examples/BigPerturbedBox/makeIC_fcc.py | 2 +-
 examples/GreshoVortex/makeIC.py        | 2 +-
 examples/PerturbedBox/makeIC.py        | 2 +-
 examples/SedovBlast/makeIC.py          | 2 +-
 examples/SedovBlast/makeIC_fcc.py      | 2 +-
 examples/SodShock/makeIC.py            | 2 +-
 examples/UniformBox/makeIC.py          | 2 +-
 examples/UniformBox/makeICbig.py       | 7 +++----
 9 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/examples/BigCosmoVolume/makeIC.py b/examples/BigCosmoVolume/makeIC.py
index 8b66828952..0994e1c95e 100644
--- a/examples/BigCosmoVolume/makeIC.py
+++ b/examples/BigCosmoVolume/makeIC.py
@@ -64,7 +64,7 @@ v = inputFile["/PartType0/Velocities"][:,:]
 m = inputFile["/PartType0/Masses"][:]
 h = inputFile["/PartType0/SmoothingLength"][:]
 u = inputFile["/PartType0/InternalEnergy"][:]
-ids = np.array(range(np.size(u)), dtype='L')
+ids = np.array(range(np.size(u)), dtype='L') + 1
 
 # Downsample
 print "Downsampling..."
diff --git a/examples/BigPerturbedBox/makeIC_fcc.py b/examples/BigPerturbedBox/makeIC_fcc.py
index dfe2a41b7d..13809b41b6 100644
--- a/examples/BigPerturbedBox/makeIC_fcc.py
+++ b/examples/BigPerturbedBox/makeIC_fcc.py
@@ -111,6 +111,6 @@ ds[()] = h
 ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f')
 ds[()] = u
 ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L')
-ds[()] = ids
+ds[()] = ids + 1
 
 file.close()
diff --git a/examples/GreshoVortex/makeIC.py b/examples/GreshoVortex/makeIC.py
index 533199869e..6aceeed559 100644
--- a/examples/GreshoVortex/makeIC.py
+++ b/examples/GreshoVortex/makeIC.py
@@ -82,7 +82,7 @@ for i in range(L):
             else:
                 P = P + 3. + 4.*log(2.)
             u[index] = P / ((gamma - 1.)*rho)
-            ids[index] = partId
+            ids[index] = partId + 1
             partId = partId + 1
 
 
diff --git a/examples/PerturbedBox/makeIC.py b/examples/PerturbedBox/makeIC.py
index a5e831eca0..69c1a69199 100644
--- a/examples/PerturbedBox/makeIC.py
+++ b/examples/PerturbedBox/makeIC.py
@@ -103,6 +103,6 @@ ds[()] = h
 ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f')
 ds[()] = u
 ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L')
-ds[()] = ids
+ds[()] = ids + 1
 
 file.close()
diff --git a/examples/SedovBlast/makeIC.py b/examples/SedovBlast/makeIC.py
index 04ff73a3cd..75ff81165d 100644
--- a/examples/SedovBlast/makeIC.py
+++ b/examples/SedovBlast/makeIC.py
@@ -69,7 +69,7 @@ for i in range(L):
             m[index] = mass
             h[index] = 1.1255 * boxSize / L
             u[index] = internalEnergy
-            ids[index] = index
+            ids[index] = index + 1
             if sqrt((x - boxSize/2.)**2 + (y - boxSize/2.)**2 + (z - boxSize/2.)**2) < 2.01 * boxSize/L:
                 u[index] = u[index] + E0 / (33. * mass)
                 print "Particle " , index , " set to detonate."
diff --git a/examples/SedovBlast/makeIC_fcc.py b/examples/SedovBlast/makeIC_fcc.py
index edff869b38..17f0744090 100644
--- a/examples/SedovBlast/makeIC_fcc.py
+++ b/examples/SedovBlast/makeIC_fcc.py
@@ -72,7 +72,7 @@ for i in range(L):
                 m[index] = mass
                 h[index] = 1.1255 * hbox
                 u[index] = internalEnergy
-                ids[index] = index
+                ids[index] = index + 1
                 if sqrt((x - boxSize/2.)**2 + (y - boxSize/2.)**2 + (z - boxSize/2.)**2) < 1.2 * hbox:
                     u[index] = u[index] + E0 / (28. * mass)
                     print "Particle " , index , " set to detonate."
diff --git a/examples/SodShock/makeIC.py b/examples/SodShock/makeIC.py
index 5bee473f06..a96aca432b 100644
--- a/examples/SodShock/makeIC.py
+++ b/examples/SodShock/makeIC.py
@@ -86,7 +86,7 @@ h = append(h1, h2,0)
 u = append(u1, u2,0)
 m = append(m1, m2,0)
 ids = zeros(numPart, dtype='L')
-for i in range(numPart):
+for i in range(1, numPart+1):
     ids[i] = i
 
 #Final operations
diff --git a/examples/UniformBox/makeIC.py b/examples/UniformBox/makeIC.py
index ea094e5a53..c175349e65 100644
--- a/examples/UniformBox/makeIC.py
+++ b/examples/UniformBox/makeIC.py
@@ -86,7 +86,7 @@ u = zeros(1)
 
 ids = linspace(0, numPart, numPart, endpoint=False).reshape((numPart,1))
 ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L')
-ds[()] = ids
+ds[()] = ids + 1
 x      = ids % L;
 y      = ((ids - x) / L) % L;
 z      = (ids - x - L * y) / L**2;
diff --git a/examples/UniformBox/makeICbig.py b/examples/UniformBox/makeICbig.py
index 28b4667ccc..e475fdcbd9 100644
--- a/examples/UniformBox/makeICbig.py
+++ b/examples/UniformBox/makeICbig.py
@@ -98,7 +98,7 @@ for n in range(n_iterations):
     u = zeros(1)
 
     ids = linspace(offset, offset+N, N, endpoint=False).reshape((N,1))
-    ds_id[offset:offset+N] = ids
+    ds_id[offset:offset+N] = ids + 1
     x      = ids % L;
     y      = ((ids - x) / L) % L;
     z      = (ids - x - L * y) / L**2;
@@ -130,10 +130,8 @@ u = full((remainder, 1), internalEnergy)
 ds_u[offset:offset+remainder] = u
 u = zeros(1)
 
-print "Done", offset+remainder,"/", numPart
-
 ids = linspace(offset, offset+remainder, remainder, endpoint=False).reshape((remainder,1))
-ds_id[offset:offset+remainder] = ids
+ds_id[offset:offset+remainder] = ids + 1
 x      = ids % L;
 y      = ((ids - x) / L) % L;
 z      = (ids - x - L * y) / L**2;
@@ -143,6 +141,7 @@ coords[:,1] = y[:,0] * boxSize / L + boxSize / (2*L)
 coords[:,2] = x[:,0] * boxSize / L + boxSize / (2*L)
 ds_x[offset:offset+remainder,:] = coords
 
+print "Done", offset+remainder,"/", numPart
 
 
 
-- 
GitLab