diff --git a/examples/SedovBlast_3D/getGlass.sh b/examples/SedovBlast_3D/getGlass.sh
new file mode 100755
index 0000000000000000000000000000000000000000..d5c5f590ac37c9c9431d626a2ea61b0c12c1513c
--- /dev/null
+++ b/examples/SedovBlast_3D/getGlass.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/glassCube_64.hdf5
diff --git a/examples/SedovBlast_3D/plotSolution.py b/examples/SedovBlast_3D/plotSolution.py
new file mode 100644
index 0000000000000000000000000000000000000000..f86ce17206ae1d15ff846fb14c61bbb6926e03bf
--- /dev/null
+++ b/examples/SedovBlast_3D/plotSolution.py
@@ -0,0 +1,281 @@
+###############################################################################
+ # This file is part of SWIFT.
+ # Copyright (c) 2015 Bert Vandenbroucke (bert.vandenbroucke@ugent.be)
+ #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ # 
+ # This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU Lesser General Public License as published
+ # by the Free Software Foundation, either version 3 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU Lesser General Public License
+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ # 
+ ##############################################################################
+
+# Computes the analytical solution of the 2D Sedov blast wave.
+# The script works for a given initial box and dumped energy and computes the solution at a later time t.
+
+# Parameters
+rho_0 = 1.          # Background Density
+P_0 = 1.e-6         # Background Pressure
+E_0 = 1.            # Energy of the explosion
+gas_gamma = 5./3.   # Gas polytropic index
+
+
+# ---------------------------------------------------------------
+# Don't touch anything after this.
+# ---------------------------------------------------------------
+
+import matplotlib
+matplotlib.use("Agg")
+from pylab import *
+import h5py
+
+# Plot parameters
+params = {'axes.labelsize': 10,
+'axes.titlesize': 10,
+'font.size': 12,
+'legend.fontsize': 12,
+'xtick.labelsize': 10,
+'ytick.labelsize': 10,
+'text.usetex': True,
+ 'figure.figsize' : (9.90,6.45),
+'figure.subplot.left'    : 0.045,
+'figure.subplot.right'   : 0.99,
+'figure.subplot.bottom'  : 0.05,
+'figure.subplot.top'     : 0.99,
+'figure.subplot.wspace'  : 0.15,
+'figure.subplot.hspace'  : 0.12,
+'lines.markersize' : 6,
+'lines.linewidth' : 3.,
+'text.latex.unicode': True
+}
+rcParams.update(params)
+rc('font',**{'family':'sans-serif','sans-serif':['Times']})
+
+
+snap = int(sys.argv[1])
+
+
+# Read the simulation data
+sim = h5py.File("sedov_%03d.hdf5"%snap, "r")
+boxSize = sim["/Header"].attrs["BoxSize"][0]
+time = sim["/Header"].attrs["Time"][0]
+scheme = sim["/HydroScheme"].attrs["Scheme"]
+kernel = sim["/HydroScheme"].attrs["Kernel function"]
+neighbours = sim["/HydroScheme"].attrs["Kernel target N_ngb"]
+eta = sim["/HydroScheme"].attrs["Kernel eta"]
+git = sim["Code"].attrs["Git Revision"]
+
+pos = sim["/PartType0/Coordinates"][:,:]
+x = pos[:,0] - boxSize / 2
+y = pos[:,1] - boxSize / 2
+z = pos[:,2] - boxSize / 2
+vel = sim["/PartType0/Velocities"][:,:]
+r = sqrt(x**2 + y**2 + z**2)
+v_r = (x * vel[:,0] + y * vel[:,1] + z * vel[:,2]) / r
+u = sim["/PartType0/InternalEnergy"][:]
+S = sim["/PartType0/Entropy"][:]
+P = sim["/PartType0/Pressure"][:]
+rho = sim["/PartType0/Density"][:]
+
+
+# Now, work our the solution....
+
+from scipy.special import gamma as Gamma
+from numpy import *
+
+def calc_a(g,nu=3):
+    """ 
+    exponents of the polynomials of the sedov solution
+    g - the polytropic gamma
+    nu - the dimension
+    """
+    a = [0]*8
+   
+    a[0] = 2.0 / (nu + 2)
+    a[2] = (1-g) / (2*(g-1) + nu)
+    a[3] = nu / (2*(g-1) + nu)
+    a[5] = 2 / (g-2)
+    a[6] = g / (2*(g-1) + nu)
+   
+    a[1] = (((nu+2)*g)/(2.0+nu*(g-1.0)) ) * ( (2.0*nu*(2.0-g))/(g*(nu+2.0)**2) - a[2])
+    a[4] = a[1]*(nu+2) / (2-g)
+    a[7] = (2 + nu*(g-1))*a[1]/(nu*(2-g))
+    return a
+
+def calc_beta(v, g, nu=3):
+    """ 
+    beta values for the sedov solution (coefficients of the polynomials of the similarity variables) 
+    v - the similarity variable
+    g - the polytropic gamma
+    nu- the dimension
+    """
+
+    beta = (nu+2) * (g+1) * array((0.25, (g/(g-1))*0.5,
+            -(2 + nu*(g-1))/2.0 / ((nu+2)*(g+1) -2*(2 + nu*(g-1))),
+     -0.5/(g-1)), dtype=float64)
+
+    beta = outer(beta, v)
+
+    beta += (g+1) * array((0.0,  -1.0/(g-1),
+                           (nu+2) / ((nu+2)*(g+1) -2.0*(2 + nu*(g-1))),
+                           1.0/(g-1)), dtype=float64).reshape((4,1))
+
+    return beta
+
+
+def sedov(t, E0, rho0, g, n=1000, nu=3):
+    """ 
+    solve the sedov problem
+    t - the time
+    E0 - the initial energy
+    rho0 - the initial density
+    n - number of points (10000)
+    nu - the dimension
+    g - the polytropic gas gamma
+    """
+    # the similarity variable
+    v_min = 2.0 / ((nu + 2) * g)
+    v_max = 4.0 / ((nu + 2) * (g + 1))
+
+    v = v_min + arange(n) * (v_max - v_min) / (n - 1.0)
+
+    a = calc_a(g, nu)
+    beta = calc_beta(v, g=g, nu=nu)
+    lbeta = log(beta)
+    
+    r = exp(-a[0] * lbeta[0] - a[2] * lbeta[1] - a[1] * lbeta[2])
+    rho = ((g + 1.0) / (g - 1.0)) * exp(a[3] * lbeta[1] + a[5] * lbeta[3] + a[4] * lbeta[2])
+    p = exp(nu * a[0] * lbeta[0] + (a[5] + 1) * lbeta[3] + (a[4] - 2 * a[1]) * lbeta[2])
+    u = beta[0] * r * 4.0 / ((g + 1) * (nu + 2))
+    p *= 8.0 / ((g + 1) * (nu + 2) * (nu + 2))
+
+    # we have to take extra care at v=v_min, since this can be a special point.
+    # It is not a singularity, however, the gradients of our variables (wrt v) are.
+    # r -> 0, u -> 0, rho -> 0, p-> constant
+
+    u[0] = 0.0; rho[0] = 0.0; r[0] = 0.0; p[0] = p[1]
+
+    # volume of an n-sphere
+    vol = (pi ** (nu / 2.0) / Gamma(nu / 2.0 + 1)) * power(r, nu)
+
+    # note we choose to evaluate the integral in this way because the
+    # volumes of the first few elements (i.e near v=vmin) are shrinking 
+    # very slowly, so we dramatically improve the error convergence by 
+    # finding the volumes exactly. This is most important for the
+    # pressure integral, as this is on the order of the volume.
+
+    # (dimensionless) energy of the model solution
+    de = rho * u * u * 0.5 + p / (g - 1)
+    # integrate (trapezium rule)
+    q = inner(de[1:] + de[:-1], diff(vol)) * 0.5
+
+    # the factor to convert to this particular problem
+    fac = (q * (t ** nu) * rho0 / E0) ** (-1.0 / (nu + 2))
+
+    # shock speed
+    shock_speed = fac * (2.0 / (nu + 2))
+    rho_s = ((g + 1) / (g - 1)) * rho0                                                                            
+    r_s = shock_speed * t * (nu + 2) / 2.0
+    p_s = (2.0 * rho0 * shock_speed * shock_speed) / (g + 1)
+    u_s = (2.0 * shock_speed) / (g + 1)
+    
+    r *= fac * t
+    u *= fac
+    p *= fac * fac * rho0
+    rho *= rho0
+    return r, p, rho, u, r_s, p_s, rho_s, u_s, shock_speed
+
+
+# The main properties of the solution
+r_s, P_s, rho_s, v_s, r_shock, _, _, _, _ = sedov(time, E_0, rho_0, gas_gamma, 1000, 3)
+
+# Append points for after the shock
+r_s = np.insert(r_s, np.size(r_s), [r_shock, r_shock*1.5])
+rho_s = np.insert(rho_s, np.size(rho_s), [rho_0, rho_0])
+P_s = np.insert(P_s, np.size(P_s), [P_0, P_0])
+v_s = np.insert(v_s, np.size(v_s), [0, 0])
+
+# Additional arrays
+u_s = P_s / (rho_s * (gas_gamma - 1.))  #internal energy
+s_s = P_s / rho_s**gas_gamma # entropic function
+
+
+
+# Plot the interesting quantities
+figure()
+
+# Velocity profile --------------------------------
+subplot(231)
+plot(r, v_r, '.', color='r', ms=1.)
+plot(r_s, v_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Radius}}~r$", labelpad=0)
+ylabel("${\\rm{Radial~velocity}}~v_r$", labelpad=0)
+xlim(0, 1.3 * r_shock)
+ylim(-0.2, 3.8)
+
+# Density profile --------------------------------
+subplot(232)
+plot(r, rho, '.', color='r', ms=1.)
+plot(r_s, rho_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Radius}}~r$", labelpad=0)
+ylabel("${\\rm{Density}}~\\rho$", labelpad=2)
+xlim(0, 1.3 * r_shock)
+ylim(-0.2, 5.2)
+
+# Pressure profile --------------------------------
+subplot(233)
+plot(r, P, '.', color='r', ms=1.)
+plot(r_s, P_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Radius}}~r$", labelpad=0)
+ylabel("${\\rm{Pressure}}~P$", labelpad=0)
+xlim(0, 1.3 * r_shock)
+ylim(-1, 12.5)
+
+# Internal energy profile -------------------------
+subplot(234)
+plot(r, u, '.', color='r', ms=1.)
+plot(r_s, u_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Radius}}~r$", labelpad=0)
+ylabel("${\\rm{Internal~Energy}}~u$", labelpad=0)
+xlim(0, 1.3 * r_shock)
+ylim(-2, 22)
+
+# Entropy profile ---------------------------------
+subplot(235)
+plot(r, S, '.', color='r', ms=1.)
+plot(r_s, s_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Radius}}~r$", labelpad=0)
+ylabel("${\\rm{Entropy}}~S$", labelpad=0)
+xlim(0, 1.3 * r_shock)
+ylim(-5, 50)
+
+# Information -------------------------------------
+subplot(236, frameon=False)
+
+text(-0.49, 0.9, "Sedov blast with  $\\gamma=%.3f$ in 2D at $t=%.2f$"%(gas_gamma,time), fontsize=10)
+text(-0.49, 0.8, "Background $\\rho_0=%.2f$"%(rho_0), fontsize=10)
+text(-0.49, 0.7, "Energy injected $E_0=%.2f$"%(E_0), fontsize=10)
+plot([-0.49, 0.1], [0.62, 0.62], 'k-', lw=1)
+text(-0.49, 0.5, "$\\textsc{Swift}$ %s"%git, fontsize=10)
+text(-0.49, 0.4, scheme, fontsize=10)
+text(-0.49, 0.3, kernel, fontsize=10)
+text(-0.49, 0.2, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10)
+xlim(-0.5, 0.5)
+ylim(0, 1)
+xticks([])
+yticks([])
+
+
+savefig("Sedov.png", dpi=200)
+
+
+
+
diff --git a/examples/SodShock_1D/plotSolution.py b/examples/SodShock_1D/plotSolution.py
index 57f66fe29b9be86a3c4de0d90eafe615d0cb2dbb..0a7720f4a6cf26e5a8acda1101bd438850d8d553 100644
--- a/examples/SodShock_1D/plotSolution.py
+++ b/examples/SodShock_1D/plotSolution.py
@@ -22,8 +22,6 @@
 
 # Generates the analytical  solution for the Sod shock test case
 # The script works for a given left (x<0) and right (x>0) state and computes the solution at a later time t.
-# The code writes five files rho.dat, P.dat, v.dat, u.dat and s.dat with the density, pressure, internal energy and
-# entropic function on N points between x_min and x_max.
 # This follows the solution given in (Toro, 2009)
 
 
diff --git a/examples/SodShock_2D/plotSolution.py b/examples/SodShock_2D/plotSolution.py
index e74651c567bb711b3190662cf78d421a66134775..99ba7e9a6e9ae4b6d50688a1428f07e9a08b3b85 100644
--- a/examples/SodShock_2D/plotSolution.py
+++ b/examples/SodShock_2D/plotSolution.py
@@ -22,8 +22,6 @@
 
 # Generates the analytical  solution for the Sod shock test case
 # The script works for a given left (x<0) and right (x>0) state and computes the solution at a later time t.
-# The code writes five files rho.dat, P.dat, v.dat, u.dat and s.dat with the density, pressure, internal energy and
-# entropic function on N points between x_min and x_max.
 # This follows the solution given in (Toro, 2009)
 
 
diff --git a/examples/SodShock_3D/getGlass.sh b/examples/SodShock_3D/getGlass.sh
new file mode 100755
index 0000000000000000000000000000000000000000..f61b61d4e6c51b44576fd7cdd6242cb9f0133039
--- /dev/null
+++ b/examples/SodShock_3D/getGlass.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/glassCube_64.hdf5
+wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/glassCube_32.hdf5
diff --git a/examples/SodShock_3D/glass_001.hdf5 b/examples/SodShock_3D/glass_001.hdf5
deleted file mode 100644
index a371826c2ef4c1d53ad5f50a6bc7eb590017220e..0000000000000000000000000000000000000000
Binary files a/examples/SodShock_3D/glass_001.hdf5 and /dev/null differ
diff --git a/examples/SodShock_3D/glass_002.hdf5 b/examples/SodShock_3D/glass_002.hdf5
deleted file mode 100644
index dffb8d343157a9ae8318e9572fc752eecd8955fb..0000000000000000000000000000000000000000
Binary files a/examples/SodShock_3D/glass_002.hdf5 and /dev/null differ
diff --git a/examples/SodShock_3D/makeIC.py b/examples/SodShock_3D/makeIC.py
index 28c2cfd82640c9d3a040d8d58ba31154c0719075..84283732afc497825417546be8bc25e183ecb1cb 100644
--- a/examples/SodShock_3D/makeIC.py
+++ b/examples/SodShock_3D/makeIC.py
@@ -1,7 +1,6 @@
 ###############################################################################
  # This file is part of SWIFT.
- # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
- #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ # Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
  # 
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Lesser General Public License as published
@@ -21,84 +20,75 @@
 import h5py
 from numpy import *
 
-# Generates a swift IC file for the Sod Shock in a periodic box
+# Generates a swift IC file for the 3D Sod Shock in a periodic box
 
 # Parameters
-periodic= 1      # 1 For periodic box
-factor = 8
-boxSize = [ 1.0 , 1.0/factor , 1.0/factor ]
-L = 100           # Number of particles along one axis
-P1 = 1.           # Pressure left state
-P2 = 0.1795       # Pressure right state
-gamma = 5./3.     # Gas adiabatic index
+gamma = 5./3.          # Gas adiabatic index
+x_min = -1.
+x_max = 1.
+rho_L = 1.             # Density left state
+rho_R = 0.125          # Density right state
+v_L = 0.               # Velocity left state
+v_R = 0.               # Velocity right state
+P_L = 1.               # Pressure left state
+P_R = 0.1              # Pressure right state
 fileName = "sodShock.hdf5" 
-vol = boxSize[0] * boxSize[1] * boxSize[2]
 
 
 #---------------------------------------------------
-
-#Read in high density glass
-# glass1 = h5py.File("../Glass/glass_200000.hdf5")
-glass1 = h5py.File("glass_001.hdf5")
-pos1 = glass1["/PartType0/Coordinates"][:,:]
-pos1 = pos1 / factor # Particles are in [0:0.25, 0:0.25, 0:0.25]
-glass_h1 = glass1["/PartType0/SmoothingLength"][:] / factor
-
-#Read in high density glass
-# glass2 = h5py.File("../Glass/glass_50000.hdf5")
-glass2 = h5py.File("glass_002.hdf5")
-pos2 = glass2["/PartType0/Coordinates"][:,:]
-pos2 = pos2 / factor # Particles are in [0:0.25, 0:0.25, 0:0.25]
-glass_h2 = glass2["/PartType0/SmoothingLength"][:] / factor
-
-#Generate high density region
-rho1 = 1.
-coord1 = append(pos1, pos1 + [0.125, 0, 0], 0)
-coord1 = append(coord1, coord1 + [0.25, 0, 0], 0)
-# coord1 = append(pos1, pos1 + [0, 0.5, 0], 0)
-# coord1 = append(coord1, pos1 + [0, 0, 0.5], 0)
-# coord1 = append(coord1, pos1 + [0, 0.5, 0.5], 0)
-N1 = size(coord1)/3
-v1 = zeros((N1, 3))
-u1 = ones(N1) * P1 / ((gamma - 1.) * rho1)
-m1 = ones(N1) * vol * 0.5 * rho1 / N1
-h1 = append(glass_h1, glass_h1, 0)
-h1 = append(h1, h1, 0)
-
-#Generate low density region
-rho2 = 0.25
-coord2 = append(pos2, pos2 + [0.125, 0, 0], 0)
-coord2 = append(coord2, coord2 + [0.25, 0, 0], 0)
-# coord2 = append(pos2, pos2 + [0, 0.5, 0], 0)
-# coord2 = append(coord2, pos2 + [0, 0, 0.5], 0)
-# coord2 = append(coord2, pos2 + [0, 0.5, 0.5], 0)
-N2 = size(coord2)/3
-v2 = zeros((N2, 3))
-u2 = ones(N2) * P2 / ((gamma - 1.) * rho2)
-m2 = ones(N2) * vol * 0.5 * rho2 / N2
-h2 = append(glass_h2, glass_h2, 0)
-h2 = append(h2, h2, 0)
-
-#Merge arrays
-numPart = N1 + N2
-coords = append(coord1, coord2+[0.5, 0., 0.], 0)
-v = append(v1, v2,0)
-h = append(h1, h2,0)
-u = append(u1, u2,0)
-m = append(m1, m2,0)
-ids = zeros(numPart, dtype='L')
-for i in range(1, numPart+1):
-    ids[i-1] = i
-
-#Final operation since we come from Gadget-2 cubic spline ICs
-h /= 1.825752
+boxSize = (x_max - x_min)
+
+glass_L = h5py.File("glassCube_64.hdf5", "r")
+glass_R = h5py.File("glassCube_32.hdf5", "r")
+
+pos_L = glass_L["/PartType0/Coordinates"][:,:] * 0.5
+pos_R = glass_R["/PartType0/Coordinates"][:,:] * 0.5
+h_L = glass_L["/PartType0/SmoothingLength"][:] * 0.5
+h_R = glass_R["/PartType0/SmoothingLength"][:] * 0.5
+
+# Merge things
+aa = pos_L - array([0.5, 0., 0.])
+pos_LL = append(pos_L, pos_L + array([0.5, 0., 0.]), axis=0)
+pos_RR = append(pos_R, pos_R + array([0.5, 0., 0.]), axis=0)
+pos = append(pos_LL - array([1.0, 0., 0.]), pos_RR, axis=0)
+h_LL = append(h_L, h_L)
+h_RR = append(h_R, h_R)
+h = append(h_LL, h_RR)
+
+numPart_L = size(h_LL)
+numPart_R = size(h_RR)
+numPart = size(h)
+
+vol_L = 0.25
+vol_R = 0.25
+
+# Generate extra arrays
+v = zeros((numPart, 3))
+ids = linspace(1, numPart, numPart)
+m = zeros(numPart)
+u = zeros(numPart)
+
+for i in range(numPart):
+    x = pos[i,0]
+
+    if x < 0: #left
+        u[i] = P_L / (rho_L * (gamma - 1.))
+        m[i] = rho_L * vol_L / numPart_L
+        v[i,0] = v_L
+    else:     #right
+        u[i] = P_R / (rho_R * (gamma - 1.))
+        m[i] = rho_R * vol_R / numPart_R
+        v[i,0] = v_R
+        
+# Shift particles
+pos[:,0] -= x_min
 
 #File
 file = h5py.File(fileName, 'w')
 
 # Header
 grp = file.create_group("/Header")
-grp.attrs["BoxSize"] = boxSize
+grp.attrs["BoxSize"] = [boxSize, 0.5, 0.5]
 grp.attrs["NumPart_Total"] =  [numPart, 0, 0, 0, 0, 0]
 grp.attrs["NumPart_Total_HighWord"] = [0, 0, 0, 0, 0, 0]
 grp.attrs["NumPart_ThisFile"] = [numPart, 0, 0, 0, 0, 0]
@@ -109,7 +99,7 @@ grp.attrs["Flag_Entropy_ICs"] = 0
 
 #Runtime parameters
 grp = file.create_group("/RuntimePars")
-grp.attrs["PeriodicBoundariesOn"] = periodic
+grp.attrs["PeriodicBoundariesOn"] = 1
 
 #Units
 grp = file.create_group("/Units")
@@ -121,7 +111,7 @@ grp.attrs["Unit temperature in cgs (U_T)"] = 1.
 
 #Particle group
 grp = file.create_group("/PartType0")
-grp.create_dataset('Coordinates', data=coords, dtype='d')
+grp.create_dataset('Coordinates', data=pos, dtype='d')
 grp.create_dataset('Velocities', data=v, dtype='f')
 grp.create_dataset('Masses', data=m, dtype='f')
 grp.create_dataset('SmoothingLength', data=h, dtype='f')
@@ -130,5 +120,3 @@ grp.create_dataset('ParticleIDs', data=ids, dtype='L')
 
 
 file.close()
-
-
diff --git a/examples/SodShock_3D/plotSolution.py b/examples/SodShock_3D/plotSolution.py
new file mode 100644
index 0000000000000000000000000000000000000000..23a16e6aed73a7281cf78a215940ccdcff722a79
--- /dev/null
+++ b/examples/SodShock_3D/plotSolution.py
@@ -0,0 +1,288 @@
+###############################################################################
+ # This file is part of SWIFT.
+ # Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
+ # 
+ # This program is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU Lesser General Public License as published
+ # by the Free Software Foundation, either version 3 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU Lesser General Public License
+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ # 
+ ##############################################################################
+
+# Computes the analytical solution of the Sod shock and plots the SPH answer
+ 
+
+# Generates the analytical  solution for the Sod shock test case
+# The script works for a given left (x<0) and right (x>0) state and computes the solution at a later time t.
+# This follows the solution given in (Toro, 2009)
+
+
+# Parameters
+gas_gamma = 5./3.      # Polytropic index
+rho_L = 1.             # Density left state
+rho_R = 0.125          # Density right state
+v_L = 0.               # Velocity left state
+v_R = 0.               # Velocity right state
+P_L = 1.               # Pressure left state
+P_R = 0.1              # Pressure right state
+
+
+import matplotlib
+matplotlib.use("Agg")
+from pylab import *
+import h5py
+
+# Plot parameters
+params = {'axes.labelsize': 10,
+'axes.titlesize': 10,
+'font.size': 12,
+'legend.fontsize': 12,
+'xtick.labelsize': 10,
+'ytick.labelsize': 10,
+'text.usetex': True,
+ 'figure.figsize' : (9.90,6.45),
+'figure.subplot.left'    : 0.045,
+'figure.subplot.right'   : 0.99,
+'figure.subplot.bottom'  : 0.05,
+'figure.subplot.top'     : 0.99,
+'figure.subplot.wspace'  : 0.15,
+'figure.subplot.hspace'  : 0.12,
+'lines.markersize' : 6,
+'lines.linewidth' : 3.,
+'text.latex.unicode': True
+}
+rcParams.update(params)
+rc('font',**{'family':'sans-serif','sans-serif':['Times']})
+
+
+snap = int(sys.argv[1])
+
+
+# Read the simulation data
+sim = h5py.File("sodShock_%03d.hdf5"%snap, "r")
+boxSize = sim["/Header"].attrs["BoxSize"][0]
+time = sim["/Header"].attrs["Time"][0]
+scheme = sim["/HydroScheme"].attrs["Scheme"]
+kernel = sim["/HydroScheme"].attrs["Kernel function"]
+neighbours = sim["/HydroScheme"].attrs["Kernel target N_ngb"]
+eta = sim["/HydroScheme"].attrs["Kernel eta"]
+git = sim["Code"].attrs["Git Revision"]
+
+x = sim["/PartType0/Coordinates"][:,0]
+v = sim["/PartType0/Velocities"][:,0]
+u = sim["/PartType0/InternalEnergy"][:]
+S = sim["/PartType0/Entropy"][:]
+P = sim["/PartType0/Pressure"][:]
+rho = sim["/PartType0/Density"][:]
+
+N = 1000  # Number of points
+x_min = -1.
+x_max = 1.
+
+x += x_min
+
+# ---------------------------------------------------------------
+# Don't touch anything after this.
+# ---------------------------------------------------------------
+
+c_L = sqrt(gas_gamma * P_L / rho_L)   # Speed of the rarefaction wave
+c_R = sqrt(gas_gamma * P_R / rho_R)   # Speed of the shock front
+
+# Helpful variable
+Gama = (gas_gamma - 1.) / (gas_gamma + 1.)
+beta = (gas_gamma - 1.) / (2. * gas_gamma)
+
+# Characteristic function and its derivative, following Toro (2009)
+def compute_f(P_3, P, c):
+    u = P_3 / P
+    if u > 1:
+        term1 = gas_gamma*((gas_gamma+1.)*u + gas_gamma-1.)
+        term2 = sqrt(2./term1)
+        fp = (u - 1.)*c*term2
+        dfdp = c*term2/P + (u - 1.)*c/term2*(-1./term1**2)*gas_gamma*(gas_gamma+1.)/P
+    else:
+        fp = (u**beta - 1.)*(2.*c/(gas_gamma-1.))
+        dfdp = 2.*c/(gas_gamma-1.)*beta*u**(beta-1.)/P
+    return (fp, dfdp)
+
+# Solution of the Riemann problem following Toro (2009) 
+def RiemannProblem(rho_L, P_L, v_L, rho_R, P_R, v_R):
+    P_new = ((c_L + c_R + (v_L - v_R)*0.5*(gas_gamma-1.))/(c_L / P_L**beta + c_R / P_R**beta))**(1./beta)
+    P_3 = 0.5*(P_R + P_L)
+    f_L = 1.
+    while fabs(P_3 - P_new) > 1e-6:
+        P_3 = P_new
+        (f_L, dfdp_L) = compute_f(P_3, P_L, c_L)
+        (f_R, dfdp_R) = compute_f(P_3, P_R, c_R)
+        f = f_L + f_R + (v_R - v_L)
+        df = dfdp_L + dfdp_R
+        dp =  -f/df
+        prnew = P_3 + dp
+    v_3 = v_L - f_L
+    return (P_new, v_3)
+
+
+# Solve Riemann problem for post-shock region
+(P_3, v_3) = RiemannProblem(rho_L, P_L, v_L, rho_R, P_R, v_R)
+
+# Check direction of shocks and wave
+shock_R = (P_3 > P_R)
+shock_L = (P_3 > P_L)
+
+# Velocity of shock front and and rarefaction wave
+if shock_R:
+    v_right = v_R + c_R**2*(P_3/P_R - 1.)/(gas_gamma*(v_3-v_R))
+else:
+    v_right = c_R + 0.5*(gas_gamma+1.)*v_3 - 0.5*(gas_gamma-1.)*v_R
+
+if shock_L:
+    v_left = v_L + c_L**2*(P_3/p_L - 1.)/(gas_gamma*(v_3-v_L))
+else:
+    v_left = c_L - 0.5*(gas_gamma+1.)*v_3 + 0.5*(gas_gamma-1.)*v_L
+
+# Compute position of the transitions
+x_23 = -fabs(v_left) * time
+if shock_L :
+    x_12 = -fabs(v_left) * time
+else:
+    x_12 = -(c_L - v_L) * time
+
+x_34 = v_3 * time
+
+x_45 = fabs(v_right) * time
+if shock_R:
+    x_56 = fabs(v_right) * time
+else:
+    x_56 = (c_R + v_R) * time
+
+
+# Prepare arrays
+delta_x = (x_max - x_min) / N
+x_s = arange(x_min, x_max, delta_x)
+rho_s = zeros(N)
+P_s = zeros(N)
+v_s = zeros(N)
+
+# Compute solution in the different regions
+for i in range(N):
+    if x_s[i] <= x_12:
+        rho_s[i] = rho_L
+        P_s[i] = P_L
+        v_s[i] = v_L
+    if x_s[i] >= x_12 and x_s[i] < x_23:
+        if shock_L:
+            rho_s[i] = rho_L*(Gama + P_3/P_L)/(1. + Gama * P_3/P_L)
+            P_s[i] = P_3
+            v_s[i] = v_3
+        else:
+            rho_s[i] = rho_L*(Gama * (0. - x_s[i])/(c_L * time) + Gama * v_L/c_L + (1.-Gama))**(2./(gas_gamma-1.))
+            P_s[i] = P_L*(rho_s[i] / rho_L)**gas_gamma
+            v_s[i] = (1.-Gama)*(c_L -(0. - x_s[i]) / time) + Gama*v_L
+    if x_s[i] >= x_23 and x_s[i] < x_34:
+        if shock_L:
+            rho_s[i] = rho_L*(Gama + P_3/P_L)/(1+Gama * P_3/p_L)
+        else:
+            rho_s[i] = rho_L*(P_3 / P_L)**(1./gas_gamma)
+        P_s[i] = P_3
+        v_s[i] = v_3
+    if x_s[i] >= x_34 and x_s[i] < x_45:
+        if shock_R:
+            rho_s[i] = rho_R*(Gama + P_3/P_R)/(1. + Gama * P_3/P_R)
+        else:
+            rho_s[i] = rho_R*(P_3 / P_R)**(1./gas_gamma)
+        P_s[i] = P_3
+        v_s[i] = v_3
+    if x_s[i] >= x_45 and x_s[i] < x_56:
+        if shock_R:
+            rho_s[i] = rho_R
+            P_s[i] = P_R
+            v_s[i] = v_R
+        else:
+            rho_s[i] = rho_R*(Gama*(x_s[i])/(c_R*time) - Gama*v_R/c_R + (1.-Gama))**(2./(gas_gamma-1.))
+            P_s[i] = p_R*(rho_s[i]/rho_R)**gas_gamma
+            v_s[i] = (1.-Gama)*(-c_R - (-x_s[i])/time) + Gama*v_R
+    if x_s[i] >= x_56:
+        rho_s[i] = rho_R
+        P_s[i] = P_R
+        v_s[i] = v_R
+
+
+# Additional arrays
+u_s = P_s / (rho_s * (gas_gamma - 1.))  #internal energy
+s_s = P_s / rho_s**gas_gamma # entropic function
+        
+
+# Plot the interesting quantities
+figure()
+
+# Velocity profile --------------------------------
+subplot(231)
+plot(x, v, '.', color='r', ms=0.5)
+plot(x_s, v_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Position}}~x$", labelpad=0)
+ylabel("${\\rm{Velocity}}~v_x$", labelpad=0)
+xlim(-0.5, 0.5)
+ylim(-0.1, 0.95)
+
+# Density profile --------------------------------
+subplot(232)
+plot(x, rho, '.', color='r', ms=0.5)
+plot(x_s, rho_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Position}}~x$", labelpad=0)
+ylabel("${\\rm{Density}}~\\rho$", labelpad=0)
+xlim(-0.5, 0.5)
+ylim(0.05, 1.1)
+
+# Pressure profile --------------------------------
+subplot(233)
+plot(x, P, '.', color='r', ms=0.5)
+plot(x_s, P_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Position}}~x$", labelpad=0)
+ylabel("${\\rm{Pressure}}~P$", labelpad=0)
+xlim(-0.5, 0.5)
+ylim(0.01, 1.1)
+
+# Internal energy profile -------------------------
+subplot(234)
+plot(x, u, '.', color='r', ms=0.5)
+plot(x_s, u_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Position}}~x$", labelpad=0)
+ylabel("${\\rm{Internal~Energy}}~u$", labelpad=0)
+xlim(-0.5, 0.5)
+ylim(0.8, 2.2)
+
+# Entropy profile ---------------------------------
+subplot(235)
+plot(x, S, '.', color='r', ms=0.5)
+plot(x_s, s_s, '--', color='k', alpha=0.8, lw=1.2)
+xlabel("${\\rm{Position}}~x$", labelpad=0)
+ylabel("${\\rm{Entropy}}~S$", labelpad=0)
+xlim(-0.5, 0.5)
+ylim(0.8, 3.8)
+
+# Information -------------------------------------
+subplot(236, frameon=False)
+
+text(-0.49, 0.9, "Sod shock with  $\\gamma=%.3f$ in 3D at $t=%.2f$"%(gas_gamma,time), fontsize=10)
+text(-0.49, 0.8, "Left:~~ $(P_L, \\rho_L, v_L) = (%.3f, %.3f, %.3f)$"%(P_L, rho_L, v_L), fontsize=10)
+text(-0.49, 0.7, "Right: $(P_R, \\rho_R, v_R) = (%.3f, %.3f, %.3f)$"%(P_R, rho_R, v_R), fontsize=10)
+plot([-0.49, 0.1], [0.62, 0.62], 'k-', lw=1)
+text(-0.49, 0.5, "$\\textsc{Swift}$ %s"%git, fontsize=10)
+text(-0.49, 0.4, scheme, fontsize=10)
+text(-0.49, 0.3, kernel, fontsize=10)
+text(-0.49, 0.2, "$%.2f$ neighbours ($\\eta=%.3f$)"%(neighbours, eta), fontsize=10)
+xlim(-0.5, 0.5)
+ylim(0, 1)
+xticks([])
+yticks([])
+
+
+savefig("SodShock.png", dpi=200)
diff --git a/examples/SodShock_3D/rhox.py b/examples/SodShock_3D/rhox.py
deleted file mode 100644
index 70493be3728cdeb27409a79f616fa3ec5bb9cdfd..0000000000000000000000000000000000000000
--- a/examples/SodShock_3D/rhox.py
+++ /dev/null
@@ -1,115 +0,0 @@
-###############################################################################
- # This file is part of SWIFT.
- # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
- #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
- # 
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Lesser General Public License as published
- # by the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- # 
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- # GNU General Public License for more details.
- # 
- # You should have received a copy of the GNU Lesser General Public License
- # along with this program.  If not, see <http://www.gnu.org/licenses/>.
- # 
- ##############################################################################
-
-import h5py
-import random
-import sys
-import math
-from numpy import *
-
-# Reads the HDF5 output of SWIFT and generates a radial density profile
-# of the different physical values.
-
-# Input values?
-if len(sys.argv) < 3 :
-    print "Usage: " , sys.argv[0] , " <filename> <nr. bins>"
-    exit()
-    
-# Get the input arguments
-fileName = sys.argv[1];
-nr_bins = int( sys.argv[2] );
-
-
-# Open the file
-fileName = sys.argv[1];
-file = h5py.File( fileName , 'r' )
-
-# Get the space dimensions.
-grp = file[ "/Header" ]
-boxsize = grp.attrs[ 'BoxSize' ]
-boxsize = boxsize[0]
-
-# Get the particle data
-grp = file.get( '/PartType0' )
-ds = grp.get( 'Coordinates' )
-coords = ds[...]
-ds = grp.get( 'Velocities' )
-v = ds[...]
-# ds = grp.get( 'Mass' )
-# m = ds[...]
-ds = grp.get( 'SmoothingLength' )
-h = ds[...]
-ds = grp.get( 'InternalEnergy' )
-u = ds[...]
-ds = grp.get( 'ParticleIDs' )
-ids = ds[...]
-ds = grp.get( 'Density' )
-rho = ds[...]
-
-# Get the maximum radius
-r_max = boxsize
-
-# Init the bins
-nr_parts = coords.shape[0]
-bins_v = zeros( nr_bins )
-bins_m = zeros( nr_bins )
-bins_h = zeros( nr_bins )
-bins_u = zeros( nr_bins )
-bins_rho = zeros( nr_bins )
-bins_count = zeros( nr_bins )
-bins_P = zeros( nr_bins )
-
-# Loop over the particles and fill the bins.
-for i in range( nr_parts ):
-
-    # Get the box index.
-    r = coords[i,0]
-    ind = floor( r / r_max * nr_bins )
-    
-    # Update the bins
-    bins_count[ind] += 1
-    bins_v[ind] += v[i,0] # sqrt( v[i,0]*v[i,0] + v[i,1]*v[i,1] + v[i,2]*v[i,2] )
-    # bins_m[ind] += m[i]
-    bins_h[ind] += h[i]
-    bins_u[ind] += u[i]
-    bins_rho[ind] += rho[i]
-    bins_P[ind] += (2.0/3)*u[i]*rho[i]
-    
-# Loop over the bins and dump them
-print "# bucket left right count v m h u rho"
-for i in range( nr_bins ):
-
-    # Normalize by the bin volume.
-    r_left = r_max * i / nr_bins
-    r_right = r_max * (i+1) / nr_bins
-    vol = 4/3*math.pi*(r_right*r_right*r_right - r_left*r_left*r_left)
-    ivol = 1.0 / vol
-
-    print "%i %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e" % \
-        ( i , r_left , r_right , \
-          bins_count[i] * ivol , \
-          bins_v[i] / bins_count[i] , \
-          bins_m[i] * ivol , \
-          bins_h[i] / bins_count[i] , \
-          bins_u[i] / bins_count[i] , \
-          bins_rho[i] / bins_count[i] ,
-          bins_P[i] / bins_count[i] )
-    
-    
diff --git a/examples/SodShock_3D/run.sh b/examples/SodShock_3D/run.sh
index b8141e51543f348d6ec6be505d136aed7d803b2e..0f9e63be334475d98196189c49b95fc46982704a 100755
--- a/examples/SodShock_3D/run.sh
+++ b/examples/SodShock_3D/run.sh
@@ -1,10 +1,18 @@
 #!/bin/bash
 
 # Generate the initial conditions if they are not present.
+if [ ! -e glassCube_64.hdf5 ]
+then
+    echo "Fetching initial glass file for the Sod shock example..."
+    ./getGlass.sh
+fi
 if [ ! -e sodShock.hdf5 ]
 then
-    echo "Generating initial conditions for the SodShock example..."
+    echo "Generating initial conditions for the Sod shock example..."
     python makeIC.py
 fi
 
-../swift -s -t 16 sodShock.yml
+# Run SWIFT
+../swift -s -t 4 sodShock.yml
+
+python plotSolution.py 1
diff --git a/examples/SodShock_3D/sodShock.yml b/examples/SodShock_3D/sodShock.yml
index a46d521511e9885ba2e5425ce1aa730403be533a..1ab6eb626db09678f66322e8f0e8674c0931ddb6 100644
--- a/examples/SodShock_3D/sodShock.yml
+++ b/examples/SodShock_3D/sodShock.yml
@@ -9,15 +9,15 @@ InternalUnitSystem:
 # Parameters governing the time integration
 TimeIntegration:
   time_begin: 0.    # The starting time of the simulation (in internal units).
-  time_end:   1.    # The end time of the simulation (in internal units).
+  time_end:   0.2   # The end time of the simulation (in internal units).
   dt_min:     1e-7  # The minimal time-step size of the simulation (in internal units).
   dt_max:     1e-2  # The maximal time-step size of the simulation (in internal units).
 
 # Parameters governing the snapshots
 Snapshots:
-  basename:            sod # Common part of the name of output files
-  time_first:          0.  # Time of the first output (in internal units)
-  delta_time:          0.05 # Time difference between consecutive outputs (in internal units)
+  basename:            sodShock # Common part of the name of output files
+  time_first:          0.       # Time of the first output (in internal units)
+  delta_time:          0.2      # Time difference between consecutive outputs (in internal units)
 
 # Parameters governing the conserved quantities statistics
 Statistics:
@@ -27,7 +27,7 @@ Statistics:
 SPH:
   resolution_eta:        1.2348   # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
   delta_neighbours:      0.1      # The tolerance for the targetted number of neighbours.
-  max_smoothing_length:  0.01     # Maximal smoothing length allowed (in internal units).
+  max_smoothing_length:  0.05     # Maximal smoothing length allowed (in internal units).
   CFL_condition:         0.1      # Courant-Friedrich-Levy condition for time integration.
 
 # Parameters related to the initial conditions
diff --git a/examples/SodShock_3D/solution.py b/examples/SodShock_3D/solution.py
deleted file mode 100644
index 39f25c625232eee9bae0300339955f775f3b46ed..0000000000000000000000000000000000000000
--- a/examples/SodShock_3D/solution.py
+++ /dev/null
@@ -1,186 +0,0 @@
-###############################################################################
- # This file is part of SWIFT.
- # Copyright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
- #                    Matthieu Schaller (matthieu.schaller@durham.ac.uk)
- # 
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Lesser General Public License as published
- # by the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- # 
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- # GNU General Public License for more details.
- # 
- # You should have received a copy of the GNU Lesser General Public License
- # along with this program.  If not, see <http://www.gnu.org/licenses/>.
- # 
- ##############################################################################
-
-import random
-from numpy import *
-
-# Generates the analytical  solution for the Sod shock test case
-# The script works for a given left (x<0) and right (x>0) state and computes the solution at a later time t.
-# The code writes five files rho.dat, P.dat, v.dat, u.dat and s.dat with the density, pressure, internal energy and
-# entropic function on N points between x_min and x_max.
-# This follows the solution given in (Toro, 2009)
-
-
-# Parameters
-rho_L = 1
-P_L = 1
-v_L = 0.
-
-rho_R = 0.25
-P_R = 0.1795
-v_R = 0.
-
-gamma = 5./3. # Polytropic index
-
-t = 0.12  # Time of the evolution
-
-N = 1000  # Number of points
-x_min = -0.25
-x_max = 0.25
-
-
-# ---------------------------------------------------------------
-# Don't touch anything after this.
-# ---------------------------------------------------------------
-
-c_L = sqrt(gamma * P_L / rho_L)   # Speed of the rarefaction wave
-c_R = sqrt(gamma * P_R / rho_R)   # Speed of the shock front
-
-# Helpful variable
-Gama = (gamma - 1.) / (gamma + 1.)
-beta = (gamma - 1.) / (2. * gamma)
-
-# Characteristic function and its derivative, following Toro (2009)
-def compute_f(P_3, P, c):
-    u = P_3 / P
-    if u > 1:
-        term1 = gamma*((gamma+1.)*u + gamma-1.)
-        term2 = sqrt(2./term1)
-        fp = (u - 1.)*c*term2
-        dfdp = c*term2/P + (u - 1.)*c/term2*(-1./term1**2)*gamma*(gamma+1.)/P
-    else:
-        fp = (u**beta - 1.)*(2.*c/(gamma-1.))
-        dfdp = 2.*c/(gamma-1.)*beta*u**(beta-1.)/P
-    return (fp, dfdp)
-
-# Solution of the Riemann problem following Toro (2009) 
-def RiemannProblem(rho_L, P_L, v_L, rho_R, P_R, v_R):
-    P_new = ((c_L + c_R + (v_L - v_R)*0.5*(gamma-1.))/(c_L / P_L**beta + c_R / P_R**beta))**(1./beta)
-    P_3 = 0.5*(P_R + P_L)
-    f_L = 1.
-    while fabs(P_3 - P_new) > 1e-6:
-        P_3 = P_new
-        (f_L, dfdp_L) = compute_f(P_3, P_L, c_L)
-        (f_R, dfdp_R) = compute_f(P_3, P_R, c_R)
-        f = f_L + f_R + (v_R - v_L)
-        df = dfdp_L + dfdp_R
-        dp =  -f/df
-        prnew = P_3 + dp
-    v_3 = v_L - f_L
-    return (P_new, v_3)
-
-
-# Solve Riemann problem for post-shock region
-(P_3, v_3) = RiemannProblem(rho_L, P_L, v_L, rho_R, P_R, v_R)
-
-# Check direction of shocks and wave
-shock_R = (P_3 > P_R)
-shock_L = (P_3 > P_L)
-
-# Velocity of shock front and and rarefaction wave
-if shock_R:
-    v_right = v_R + c_R**2*(P_3/P_R - 1.)/(gamma*(v_3-v_R))
-else:
-    v_right = c_R + 0.5*(gamma+1.)*v_3 - 0.5*(gamma-1.)*v_R
-
-if shock_L:
-    v_left = v_L + c_L**2*(P_3/p_L - 1.)/(gamma*(v_3-v_L))
-else:
-    v_left = c_L - 0.5*(gamma+1.)*v_3 + 0.5*(gamma-1.)*v_L
-
-# Compute position of the transitions
-x_23 = -fabs(v_left) * t
-if shock_L :
-    x_12 = -fabs(v_left) * t
-else:
-    x_12 = -(c_L - v_L) * t
-
-x_34 = v_3 * t
-
-x_45 = fabs(v_right) * t
-if shock_R:
-    x_56 = fabs(v_right) * t
-else:
-    x_56 = (c_R + v_R) * t 
-
-
-# Prepare arrays
-delta_x = (x_max - x_min) / N
-x_s = arange(x_min, x_max, delta_x)
-rho_s = zeros(N)
-P_s = zeros(N)
-v_s = zeros(N)
-
-# Compute solution in the different regions
-for i in range(N):
-    if x_s[i] <= x_12:
-        rho_s[i] = rho_L
-        P_s[i] = P_L
-        v_s[i] = v_L
-    if x_s[i] >= x_12 and x_s[i] < x_23:
-        if shock_L:
-            rho_s[i] = rho_L*(Gama + P_3/P_L)/(1. + Gama * P_3/P_L)
-            P_s[i] = P_3
-            v_s[i] = v_3
-        else:
-            rho_s[i] = rho_L*(Gama * (0. - x_s[i])/(c_L * t) + Gama * v_L/c_L + (1.-Gama))**(2./(gamma-1.))
-            P_s[i] = P_L*(rho_s[i] / rho_L)**gamma
-            v_s[i] = (1.-Gama)*(c_L -(0. - x_s[i]) / t) + Gama*v_L
-    if x_s[i] >= x_23 and x_s[i] < x_34:
-        if shock_L:
-            rho_s[i] = rho_L*(Gama + P_3/P_L)/(1+Gama * P_3/p_L)
-        else:
-            rho_s[i] = rho_L*(P_3 / P_L)**(1./gamma)
-        P_s[i] = P_3
-        v_s[i] = v_3
-    if x_s[i] >= x_34 and x_s[i] < x_45:
-        if shock_R:
-            rho_s[i] = rho_R*(Gama + P_3/P_R)/(1. + Gama * P_3/P_R)
-        else:
-            rho_s[i] = rho_R*(P_3 / P_R)**(1./gamma)
-        P_s[i] = P_3
-        v_s[i] = v_3
-    if x_s[i] >= x_45 and x_s[i] < x_56:
-        if shock_R:
-            rho_s[i] = rho_R
-            P_s[i] = P_R
-            v_s[i] = v_R
-        else:
-            rho_s[i] = rho_R*(Gama*(x_s[i])/(c_R*t) - Gama*v_R/c_R + (1.-Gama))**(2./(gamma-1.))
-            P_s[i] = p_R*(rho_s[i]/rho_R)**gamma
-            v_s[i] = (1.-Gama)*(-c_R - (-x_s[i])/t) + Gama*v_R
-    if x_s[i] >= x_56:
-        rho_s[i] = rho_R
-        P_s[i] = P_R
-        v_s[i] = v_R
-
-
-# Additional arrays
-u_s = P_s / (rho_s * (gamma - 1.))  #internal energy
-s_s = P_s / rho_s**gamma # entropic function
-        
-#---------------------------------------------------------------
-# Print arrays
-
-savetxt("rho.dat", column_stack((x_s, rho_s)))
-savetxt("P.dat", column_stack((x_s, P_s)))
-savetxt("v.dat", column_stack((x_s, v_s)))
-savetxt("u.dat", column_stack((x_s, u_s)))
-savetxt("s.dat", column_stack((x_s, s_s)))