diff --git a/examples/ConstantCosmoVolume/README b/examples/ConstantCosmoVolume/README new file mode 100644 index 0000000000000000000000000000000000000000..5f9b4789d8d7893159368191cd2b63416a09d864 --- /dev/null +++ b/examples/ConstantCosmoVolume/README @@ -0,0 +1,5 @@ +This test is a small cosmological volume with constant density and internal energy. +The ICs are generated from a glass file to minimize the build-up of peculiar velocities +over time. + +The solution script plots the expected solution both in comoving and physical frames. diff --git a/examples/ConstantCosmoVolume/constant_volume.yml b/examples/ConstantCosmoVolume/constant_volume.yml index ad31fd1972565b0d7683711a20db78e854c3dc5f..fe154140600a381d48e4cc2f48d4666be6363038 100644 --- a/examples/ConstantCosmoVolume/constant_volume.yml +++ b/examples/ConstantCosmoVolume/constant_volume.yml @@ -17,7 +17,7 @@ Cosmology: # Parameters governing the time integration TimeIntegration: dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units). - dt_max: 5e-3 # The maximal time-step size of the simulation (in internal units). + dt_max: 2e-3 # The maximal time-step size of the simulation (in internal units). # Parameters governing the snapshots Snapshots: diff --git a/examples/ConstantCosmoVolume/getGlass.sh b/examples/ConstantCosmoVolume/getGlass.sh new file mode 100755 index 0000000000000000000000000000000000000000..01b4474ac21666c843b7abedfa39a76948934911 --- /dev/null +++ b/examples/ConstantCosmoVolume/getGlass.sh @@ -0,0 +1,2 @@ +#!/bin/bash +wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/gravity_glassCube_32.hdf5 diff --git a/examples/ConstantCosmoVolume/makeIC.py b/examples/ConstantCosmoVolume/makeIC.py index 970f197400129d2ca3f3a7b6ff2cfdd5a7f53f3f..84ba2a55bdc5eb07a7c041e8255f7a5fec0cff07 100644 --- a/examples/ConstantCosmoVolume/makeIC.py +++ b/examples/ConstantCosmoVolume/makeIC.py @@ -25,7 +25,7 @@ T_i = 100. # Initial temperature of the gas (in K) z_i = 100. # Initial redshift gamma = 5./3. # Gas adiabatic index numPart_1D = 32 -#glassFile = "glassCube_32.hdf5" +glassFile = "gravity_glassCube_32.hdf5" fileName = "constantBox.hdf5" @@ -56,17 +56,16 @@ unit_u_in_si = unit_v_in_si**2 #--------------------------------------------------- # Read the glass file -#glass = h5py.File(glassFile, "r" ) +glass = h5py.File(glassFile, "r" ) # Read particle positions and h from the glass -#pos = glass["/PartType0/Coordinates"][:,:] -#h = glass["/PartType0/SmoothingLength"][:] * 0.3 -#glass.close() +pos = glass["/PartType1/Coordinates"][:,:] +glass.close() # Total number of particles -#numPart = size(h) -#if numPart != numPart_1D**3: -# print "Non-matching glass file" +numPart = size(pos)/3 +if numPart != numPart_1D**3: + print "Non-matching glass file" numPart = numPart_1D**3 # Set box size and interparticle distance @@ -78,9 +77,7 @@ a_i = 1. / (1. + z_i) m_i = boxSize**3 * rho_0 / numPart # Build the arrays -#pos *= boxSize -#h *= boxSize -coords = zeros((numPart, 3)) +pos *= boxSize v = zeros((numPart, 3)) ids = linspace(1, numPart, numPart) m = zeros(numPart) @@ -92,9 +89,9 @@ for i in range(numPart_1D): for j in range(numPart_1D): for k in range(numPart_1D): index = i * numPart_1D**2 + j * numPart_1D + k - coords[index,0] = (i + 0.5) * delta_x - coords[index,1] = (j + 0.5) * delta_x - coords[index,2] = (k + 0.5) * delta_x + #coords[index,0] = (i + 0.5) * delta_x + #coords[index,1] = (j + 0.5) * delta_x + #coords[index,2] = (k + 0.5) * delta_x u[index] = kB_in_SI * T_i / (gamma - 1.) / mH_in_kg h[index] = 1.2348 * delta_x m[index] = m_i @@ -103,7 +100,7 @@ for i in range(numPart_1D): v[index,2] = 0. # Unit conversion -coords /= unit_l_in_si +pos /= unit_l_in_si v /= unit_v_in_si m /= unit_m_in_si h /= unit_l_in_si @@ -140,7 +137,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', compression="gzip", shuffle=True) +grp.create_dataset('Coordinates', data=pos, dtype='d', compression="gzip", shuffle=True) grp.create_dataset('Velocities', data=v, dtype='f',compression="gzip", shuffle=True) grp.create_dataset('Masses', data=m, dtype='f', compression="gzip", shuffle=True) grp.create_dataset('SmoothingLength', data=h, dtype='f', compression="gzip", shuffle=True) diff --git a/examples/ConstantCosmoVolume/run.sh b/examples/ConstantCosmoVolume/run.sh index 521659b26d6e4d3c07a8322ba92fa3d52f0ba2cf..a2d9cdc63fbef6208caa44e05f91e94a27c4ff20 100755 --- a/examples/ConstantCosmoVolume/run.sh +++ b/examples/ConstantCosmoVolume/run.sh @@ -1,6 +1,11 @@ #!/bin/bash # Generate the initial conditions if they are not present. +if [ ! -e gravity_glassCube_32.hdf5 ] +then + echo "Fetching initial grvity glass file for the constant cosmological box example..." + ./getGlass.sh +fi if [ ! -e constantBox.hdf5 ] then echo "Generating initial conditions for the uniform cosmo box example..."