Commit e331b8f4 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'mesh_force_task' into 'master'

Periodic gravity calculation

Closes #439, #438, and #429

See merge request !566
parents 32f36685 29e820c5
......@@ -1281,10 +1281,10 @@ esac
# Gravity multipole order
AC_ARG_WITH([multipole-order],
[AS_HELP_STRING([--with-multipole-order=<order>],
[order of the multipole and gravitational field expansion @<:@ default: 5@:>@]
[order of the multipole and gravitational field expansion @<:@ default: 4@:>@]
)],
[with_multipole_order="$withval"],
[with_multipole_order="5"]
[with_multipole_order="4"]
)
AC_DEFINE_UNQUOTED([SELF_GRAVITY_MULTIPOLE_ORDER], [$with_multipole_order], [Multipole order])
......
......@@ -818,7 +818,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = *.md
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
......
###############################################################################
# This file is part of SWIFT.
# Copyright (c) 2015 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 urllib
import os.path
import numpy as np
import sys
outputName = "bigCosmoVolume.hdf5"
#--------------------------------------------------
if len(sys.argv) != 3:
print "Invalid number of arguments. Need to provide down-sampling factor [0.,1.] and number of copies (integer)"
print "Example: python makeIC.py 0.8 4"
exit()
downsample = float(sys.argv[1])
n_copy = int(sys.argv[2])
if n_copy < 1:
print "Number of copy must be >1"
exit()
if downsample > 1. or downsample <= 0.:
print "Down-sampling factor must be in [0,1]"
exit()
#--------------------------------------------------
# Download the tile
if (not os.path.isfile("tile.hdf5")):
print "Downloading initial tile..."
urllib.urlretrieve ("http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/tile.hdf5", "tile.hdf5")
print "Done."
else:
print "Tile already exists. No need to download..."
# Read in the tile
inputFile = h5py.File("tile.hdf5", 'r+')
grp = inputFile["/Header"]
boxSize = grp.attrs["BoxSize"]
numPart = grp.attrs["NumPart_Total"][0]
coords = inputFile["/PartType0/Coordinates"][:,:]
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') + 1
# Downsample
print "Downsampling..."
indices = np.array(range(np.size(ids)))
np.random.shuffle(indices)
numPart *= downsample
indices = indices < numPart
coords = coords[indices,:]
v = v[indices,:]
m = m[indices]
h = h[indices] / 1.825742 # Correct from Gadget defintion of h to physical definition
u = u[indices]
ids = ids[indices]
numPart = np.size(ids)
# Now replicate the tile
if n_copy > 1:
print "Tiling..."
coords_tile = np.copy(coords)
v_tile = np.copy(v)
m_tile = np.copy(m)
h_tile = np.copy(h)
u_tile = np.copy(u)
ids_tile = np.copy(ids)
coords = np.zeros((0,3))
v = np.zeros((0,3))
m = np.zeros(0)
h = np.zeros(0)
u = np.zeros(0)
ids = np.zeros(0, dtype='L')
count = 0
for i in range(n_copy):
for j in range(n_copy):
for k in range(n_copy):
coords = np.append(coords, coords_tile + np.array([ i * boxSize[0], j * boxSize[1], k * boxSize[2] ]), axis=0)
v = np.append(v, v_tile, axis=0)
m = np.append(m, m_tile)
h = np.append(h, h_tile)
u = np.append(u, u_tile)
ids = np.append(ids, ids_tile + count*numPart)
count+=1
numPart *= n_copy**3
boxSize *= n_copy
# Copy the tile out
file = h5py.File(outputName, 'w')
# Header
grp = file.create_group("/Header")
grp.attrs["BoxSize"] = boxSize
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]
grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
grp.attrs["PeriodicBoundariesOn"] = 1
#Particle group
grp = file.create_group("/PartType0")
grp.create_dataset('Coordinates', data=coords, 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')
grp.create_dataset('InternalEnergy', data=u, dtype='f')
grp.create_dataset('ParticleIDs', data=ids, dtype='L')
#!/bin/bash
wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/cosmoVolume.hdf5
###############################################################################
# This file is part of SWIFT.
# Copyright (c) 2013 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 sys
from numpy import *
# Generates a swift IC file containing a cartesian distribution of particles
# at a constant density and pressure in a cubic box
# Parameters
periodic= 1 # 1 For periodic box
boxSize = 1.
L = int(sys.argv[1]) # Number of particles along one axis
rho = 2. # Density
P = 1. # Pressure
gamma = 5./3. # Gas adiabatic index
eta = 1.2349 # 48 ngbs with cubic spline kernel
fileName = "uniformBox.hdf5"
#---------------------------------------------------
numPart = L**3
mass = boxSize**3 * rho / numPart
internalEnergy = P / ((gamma - 1.)*rho)
#--------------------------------------------------
#File
file = h5py.File(fileName, 'w')
# Header
grp = file.create_group("/Header")
grp.attrs["BoxSize"] = boxSize
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]
grp.attrs["Time"] = 0.0
grp.attrs["NumFilesPerSnapshot"] = 1
grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
grp.attrs["Flag_Entropy_ICs"] = 0
grp.attrs["Dimension"] = 3
#Runtime parameters
grp = file.create_group("/RuntimePars")
grp.attrs["PeriodicBoundariesOn"] = periodic
#Units
grp = file.create_group("/Units")
grp.attrs["Unit length in cgs (U_L)"] = 1.
grp.attrs["Unit mass in cgs (U_M)"] = 1.
grp.attrs["Unit time in cgs (U_t)"] = 1.
grp.attrs["Unit current in cgs (U_I)"] = 1.
grp.attrs["Unit temperature in cgs (U_T)"] = 1.
#Particle group
grp = file.create_group("/PartType0")
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), eta * 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).reshape((numPart,1))
ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L')
ds[()] = ids + 1
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()
......@@ -54,5 +54,7 @@ SPH:
# Parameters related to the initial conditions
InitialConditions:
file_name: ./EAGLE_ICs_100.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
file_name: ./EAGLE_ICs_100.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -23,8 +23,9 @@ TimeIntegration:
dt_max: 1e-4 # The maximal time-step size of the simulation (in internal units).
Scheduler:
max_top_level_cells: 15
max_top_level_cells: 8
cell_split_size: 50
# Parameters governing the snapshots
Snapshots:
basename: eagle # Common part of the name of output files
......@@ -42,9 +43,10 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 32
# Parameters for the hydrodynamics scheme
SPH:
......@@ -54,5 +56,7 @@ SPH:
# Parameters related to the initial conditions
InitialConditions:
file_name: ./EAGLE_ICs_12.hdf5 # The file to read
file_name: ./EAGLE_ICs_12.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -23,7 +23,8 @@ TimeIntegration:
dt_max: 1e-4 # The maximal time-step size of the simulation (in internal units).
Scheduler:
max_top_level_cells: 20
max_top_level_cells: 16
cell_split_size: 50
# Parameters governing the snapshots
Snapshots:
......@@ -41,9 +42,10 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 32
# Parameters for the hydrodynamics scheme
SPH:
......@@ -53,6 +55,8 @@ SPH:
# Parameters related to the initial conditions
InitialConditions:
file_name: ./EAGLE_ICs_25.hdf5 # The file to read
file_name: ./EAGLE_ICs_25.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -23,7 +23,8 @@ TimeIntegration:
dt_max: 1e-4 # The maximal time-step size of the simulation (in internal units).
Scheduler:
max_top_level_cells: 40
max_top_level_cells: 20
cell_split_size: 50
# Parameters governing the snapshots
Snapshots:
......@@ -31,7 +32,6 @@ Snapshots:
scale_factor_first: 0.92 # Scale-factor of the first snaphot (cosmological run)
time_first: 0.01 # Time of the first output (non-cosmological run) (in internal units)
delta_time: 1.10 # Time difference between consecutive outputs (in internal units)
compression: 1
# Parameters governing the conserved quantities statistics
Statistics:
......@@ -42,9 +42,10 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 64
# Parameters for the hydrodynamics scheme
SPH:
......@@ -56,4 +57,6 @@ SPH:
InitialConditions:
file_name: ./EAGLE_ICs_50.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -16,7 +16,8 @@ Cosmology:
Omega_b: 0.0455 # Baryon density parameter
Scheduler:
max_top_level_cells: 8
max_top_level_cells: 8
cell_split_size: 50
# Parameters governing the time integration
TimeIntegration:
......@@ -43,10 +44,11 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 16
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
......@@ -57,4 +59,6 @@ SPH:
InitialConditions:
file_name: ./EAGLE_ICs_6.hdf5 # The file to read
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -49,4 +49,6 @@ Gravity:
# Parameters related to the initial conditions
InitialConditions:
file_name: EAGLE_DMO_ICs_100.hdf5
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -23,7 +23,8 @@ TimeIntegration:
dt_max: 1e-3 # The maximal time-step size of the simulation (in internal units).
Scheduler:
max_top_level_cells: 15
max_top_level_cells: 8
cell_split_size: 50
# Parameters governing the snapshots
Snapshots:
......@@ -41,12 +42,16 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
mesh_side_length: 32
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 32
# Parameters related to the initial conditions
InitialConditions:
file_name: EAGLE_DMO_ICs_12.hdf5
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -23,7 +23,8 @@ TimeIntegration:
dt_max: 1e-3 # The maximal time-step size of the simulation (in internal units).
Scheduler:
max_top_level_cells: 20
max_top_level_cells: 16
cell_split_size: 50
# Parameters governing the snapshots
Snapshots:
......@@ -42,11 +43,14 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 32
# Parameters related to the initial conditions
InitialConditions:
file_name: EAGLE_DMO_ICs_25.hdf5
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
......@@ -23,7 +23,8 @@ TimeIntegration:
dt_max: 1e-3 # The maximal time-step size of the simulation (in internal units).
Scheduler:
max_top_level_cells: 40
max_top_level_cells: 20
cell_split_size: 50
# Parameters governing the snapshots
Snapshots:
......@@ -31,7 +32,6 @@ Snapshots:
scale_factor_first: 0.92 # Scale-factor of the first snaphot (cosmological run)
time_first: 0.01 # Time of the first output (non-cosmological run) (in internal units)
delta_time: 1.10 # Time difference between consecutive outputs (in internal units)
compression: 1
# Parameters governing the conserved quantities statistics
Statistics:
......@@ -42,11 +42,14 @@ Statistics:
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.85 # Opening angle (Multipole acceptance criterion)
theta: 0.7 # Opening angle (Multipole acceptance criterion)
comoving_softening: 0.0026994 # Comoving softening length (in internal units).
max_physical_softening: 0.0007 # Physical softening length (in internal units).
mesh_side_length: 64
# Parameters related to the initial conditions
InitialConditions:
file_name: EAGLE_DMO_ICs_50.hdf5
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget
cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget
Small LCDM cosmological simulation generated by C. Power. Cosmology
is WMAP9 and the box is 100Mpc/h in size with 64^3 particles.
We use a softening length of 1/25th of the mean inter-particle separation.
The ICs have been generated to run with Gadget-2 so we need to switch
on the options to cancel the h-factors and a-factors at reading time.
MD5 checksum of the ICs:
2a9c603ffb1f6d29f3d98a3ecb9d3238 small_cosmo_volume.hdf5
#!/bin/bash
wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/small_cosmo_volume.hdf5
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e cosmoVolume.hdf5 ]
if [ ! -e small_cosmo_volume.hdf5 ]
then
echo "Fetching initial conditions for the cosmo volume example..."
echo "Fetching initial conditions for the small cosmological volume example..."
./getIC.sh
fi
../swift -s -t 16 cosmoVolume.yml 2>&1 | tee output.log
../swift -a -c -G -t 16 small_cosmo_volume.yml 2>&1 | tee output.log
......@@ -6,44 +6,45 @@ InternalUnitSystem:
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# UnitMass_in_cgs: 1 # Grams
# UnitLength_in_cgs: 1 # Centimeters
# UnitVelocity_in_cgs: 1 # Centimeters per second
# UnitCurrent_in_cgs: 1 # Amperes
# UnitTemp_in_cgs: 1 # Kelvin
# WMAP9 cosmology
Cosmology:
Omega_m: 0.276
Omega_lambda: 0.724
Omega_b: 0.0455
h: 0.703
a_begin: 0.0196078
a_end: 1.0
# 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).
dt_min: 1e-6 # 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).
dt_min: 1e-6
dt_max: 1e-2
# Parameters for the self-gravity scheme
Gravity:
eta: 0.025
theta: 0.3
comoving_softening: 0.08
max_physical_softening: 0.08
mesh_side_length: 32
# Parameters governing the snapshots
Snapshots:
basename: uniformBox # Common part of the name of output files
time_first: 0. # Time of the first output (in internal units)
delta_time: 0.01 # Time difference between consecutive outputs (in internal units)
basename: snap
delta_time: 1.02
scale_factor_first: 0.02
# Parameters governing the conserved quantities statistics
Statistics:
delta_time: 1e-2 # Time between statistics output
# Parameters for the hydrodynamics scheme