Commit f4999392 authored by Folkert Nobels's avatar Folkert Nobels
Browse files

Merge master in the SFH_logger branch

parents c65b0f9c 23c14b33
......@@ -12,6 +12,7 @@ config.h.in
config.sub
ltmain.sh
libtool
build
src/version_string.h
swift*.tar.gz
......
### GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the
terms and conditions of version 3 of the GNU General Public License,
supplemented by the additional permissions listed below.
#### 0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the
GNU General Public License.
"The Library" refers to a covered work governed by this License, other
than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
#### 1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
#### 2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
- a) under this License, provided that you make a good faith effort
to ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
- b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
#### 3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a
header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
- a) Give prominent notice with each copy of the object code that
the Library is used in it and that the Library and its use are
covered by this License.
- b) Accompany the object code with a copy of the GNU GPL and this
license document.
#### 4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken
together, effectively do not restrict modification of the portions of
the Library contained in the Combined Work and reverse engineering for
debugging such modifications, if you also do each of the following:
- a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
- b) Accompany the Combined Work with a copy of the GNU GPL and this
license document.
- c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
- d) Do one of the following:
- 0) Convey the Minimal Corresponding Source under the terms of
this License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
- 1) Use a suitable shared library mechanism for linking with
the Library. A suitable mechanism is one that (a) uses at run
time a copy of the Library already present on the user's
computer system, and (b) will operate properly with a modified
version of the Library that is interface-compatible with the
Linked Version.
- e) Provide Installation Information, but only if you would
otherwise be required to provide such information under section 6
of the GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option
4d0, the Installation Information must accompany the Minimal
Corresponding Source and Corresponding Application Code. If you
use option 4d1, you must provide the Installation Information in
the manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.)
#### 5. Combined Libraries.
You may place library facilities that are a work based on the Library
side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
- a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities, conveyed under the terms of this License.
- b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
#### 6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
as you received it specifies that a certain numbered version of the
GNU Lesser General Public License "or any later version" applies to
it, you have the option of following the terms and conditions either
of that published version or of any later version published by the
Free Software Foundation. If the Library as you received it does not
specify a version number of the GNU Lesser General Public License, you
may choose any version of the GNU Lesser General Public License ever
published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
......@@ -11,7 +11,7 @@ as ``wget`` for grabbing the glass).
.. code-block:: bash
cd examples/SodShock_3D
cd examples/HydroTests/SodShock_3D
./getGlass.sh
python makeIC.py
../swift --hydro --threads=4 sodShock.yml
......
.. ANARCHY-SPH
Josh Borrow 5th April 2018
ANARCHY-PU SPH
==============
This scheme is similar to the one used in the EAGLE code. This scheme
includes:
+ Durier & Dalla Vecchia (2012) time-step limiter
+ Pressure-Energy SPH
+ Thermal diffusion following Price (2012)
+ A simplified version of the 'Inviscid SPH' artificial viscosity
(Cullen & Denhen 2010).
More information will be made available in a forthcoming publication.
The scheme as-implemented in SWIFT is slightly different to the one
implemented in the original EAGLE code:
+ Pressure-Energy SPH is used instead of Pressure-Entropy SPH
+ Artificial viscosity coefficients have changed -- from minimal
value of 0.1 to 0.0, and from length of 0.1 to 0.25. This
is based on performance of hydrodynamics tests in SWIFT and may
be to do with our choice of smoothing length definition.
+ Recommended kernel changed from Wendland-C2 (with 100 Ngb) to
Quintic Spline (with ~82 Ngb).
.. code-block:: bash
./configure --with-hydro=anarchy-pu --with-kernel=quintic-spline --disable-hand-vec
......@@ -17,6 +17,7 @@ schemes available in SWIFT, as well as how to implement your own.
minimal_sph
planetary
hopkins_sph
anarchy_sph
gizmo
adding_your_own
# Define the system of units to use internally.
InternalUnitSystem:
UnitMass_in_cgs: 1.98848e43 # 10^10 M_sun
UnitLength_in_cgs: 3.08567758e24 # 1 Mpc
UnitVelocity_in_cgs: 1e5 # 1 km/s
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Cosmological parameters
Cosmology:
h: 0.6777 # Reduced Hubble constant
a_begin: 0.5 # Initial scale-factor of the simulation (z = 1.0)
a_end: 0.5061559 # Final scale factor of the simulation (~ 100 myr)
Omega_m: 0.307 # Matter density parameter
Omega_lambda: 0.693 # Dark-energy density parameter
Omega_b: 0.0455 # Baryon density parameter
# Parameters governing the time integration
TimeIntegration:
dt_min: 1e-14
dt_max: 5e-3
# Parameters governing the snapshots
Snapshots:
basename: data/redshift_dependence_high_z
delta_time: 1.000122373748838
scale_factor_first: 0.5
compression: 4
# Parameters governing the conserved quantities statistics
Statistics:
scale_factor_first: 0.5
delta_time: 1.1
# 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).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # K
# Parameters related to the initial conditions
InitialConditions:
file_name: ./ics_high_z.hdf5 # The file to read
periodic: 1
# Parameters for the EAGLE chemistry
EAGLEChemistry: # Solar abundances
init_abundance_metal: 0.
init_abundance_Hydrogen: 0.752
init_abundance_Helium: 0.248
init_abundance_Carbon: 0.
init_abundance_Nitrogen: 0.
init_abundance_Oxygen: 0.
init_abundance_Neon: 0.
init_abundance_Magnesium: 0.
init_abundance_Silicon: 0.
init_abundance_Iron: 0.
# Parameters for the EAGLE cooling
EAGLECooling:
dir_name: ./coolingtables/
H_reion_z: 11.5
H_reion_eV_p_H: 2.0
He_reion_z_centre: 3.5
He_reion_z_sigma: 0.5
He_reion_eV_p_H: 2.0
# Parameters for the EAGLE "equation of state"
EAGLEEntropyFloor:
Jeans_density_threshold_H_p_cm3: 0.1 # Physical density above which the EAGLE Jeans limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
Jeans_over_density_threshold: 10. # Overdensity above which the EAGLE Jeans limiter entropy floor can kick in.
Jeans_temperature_norm_K: 8000 # Temperature of the EAGLE Jeans limiter entropy floor at the density threshold expressed in Kelvin.
Jeans_gamma_effective: 1.3333333 # Slope the of the EAGLE Jeans limiter entropy floor
Cool_density_threshold_H_p_cm3: 1e-5 # Physical density above which the EAGLE Cool limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
Cool_over_density_threshold: 10. # Overdensity above which the EAGLE Cool limiter entropy floor can kick in.
Cool_temperature_norm_K: 8000 # Temperature of the EAGLE Cool limiter entropy floor at the density threshold expressed in Kelvin.
Cool_gamma_effective: 1. # Slope the of the EAGLE Cool limiter entropy floor
LambdaCooling:
lambda_nH2_cgs: 2.13744785e-23 # Cooling rate divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
ConstCooling:
cooling_rate: 1. # Cooling rate (du/dt) (internal units)
min_energy: 1. # Minimal internal energy per unit mass (internal units)
cooling_tstep_mult: 1. # Dimensionless pre-factor for the time-step condition
\ No newline at end of file
# Define the system of units to use internally.
InternalUnitSystem:
UnitMass_in_cgs: 1.98848e33 # 10^10 M_sun
UnitLength_in_cgs: 3.08567758e21 # 1 kpc
UnitVelocity_in_cgs: 1 # 1 km/s
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Cosmological parameters
Cosmology:
h: 0.6777 # Reduced Hubble constant
a_begin: 0.99009 # Initial scale-factor of the simulation (z = 0.01)
a_end: 0.99700 # Final scale factor of the simulation (~ 100 myr)
Omega_m: 0.307 # Matter density parameter
Omega_lambda: 0.693 # Dark-energy density parameter
Omega_b: 0.0455 # Baryon density parameter
# Parameters governing the time integration
TimeIntegration:
dt_min: 1e-14
dt_max: 5e-3
# Parameters governing the snapshots
Snapshots:
basename: data/redshift_dependence_low_z
delta_time: 1.0000695206950205
scale_factor_first: 0.99009
compression: 4
# Parameters governing the conserved quantities statistics
Statistics:
scale_factor_first: 0.99009
delta_time: 1.1
# 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).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # K
# Parameters related to the initial conditions
InitialConditions:
file_name: ./ics_low_z.hdf5 # The file to read
periodic: 1
# Parameters for the EAGLE chemistry
EAGLEChemistry: # Primordial
init_abundance_metal: 0.
init_abundance_Hydrogen: 0.752
init_abundance_Helium: 0.248
init_abundance_Carbon: 0.
init_abundance_Nitrogen: 0.
init_abundance_Oxygen: 0.
init_abundance_Neon: 0.
init_abundance_Magnesium: 0.
init_abundance_Silicon: 0.
init_abundance_Iron: 0.
# Parameters for the EAGLE cooling
EAGLECooling:
dir_name: ./coolingtables/
H_reion_z: 11.5
H_reion_eV_p_H: 2.0
He_reion_z_centre: 3.5
He_reion_z_sigma: 0.5
He_reion_eV_p_H: 2.0
# Parameters for the EAGLE "equation of state"
EAGLEEntropyFloor:
Jeans_density_threshold_H_p_cm3: 0.1 # Physical density above which the EAGLE Jeans limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
Jeans_over_density_threshold: 10. # Overdensity above which the EAGLE Jeans limiter entropy floor can kick in.
Jeans_temperature_norm_K: 8000 # Temperature of the EAGLE Jeans limiter entropy floor at the density threshold expressed in Kelvin.
Jeans_gamma_effective: 1.3333333 # Slope the of the EAGLE Jeans limiter entropy floor
Cool_density_threshold_H_p_cm3: 1e-5 # Physical density above which the EAGLE Cool limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
Cool_over_density_threshold: 10. # Overdensity above which the EAGLE Cool limiter entropy floor can kick in.
Cool_temperature_norm_K: 8000 # Temperature of the EAGLE Cool limiter entropy floor at the density threshold expressed in Kelvin.
Cool_gamma_effective: 1. # Slope the of the EAGLE Cool limiter entropy floor
LambdaCooling:
lambda_nH2_cgs: 2.13744785e-23 # Cooling rate divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
ConstCooling:
cooling_rate: 1. # Cooling rate (du/dt) (internal units)
min_energy: 1. # Minimal internal energy per unit mass (internal units)
cooling_tstep_mult: 1. # Dimensionless pre-factor for the time-step condition
# Define the system of units to use internally.
InternalUnitSystem:
UnitMass_in_cgs: 1.98848e43 # 10^10 M_sun
UnitLength_in_cgs: 3.08567758e24 # 1 Mpc
UnitVelocity_in_cgs: 1e5 # 1 km/s
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters governing the time integration
TimeIntegration:
time_begin: 0.
time_end: 1.02e-4 # ~ 100 myr
dt_min: 1e-14
dt_max: 5e-5
# Parameters governing the snapshots
Snapshots:
basename: data/redshift_dependence_no_z
delta_time: 1.02e-6
compression: 4
# Parameters governing the conserved quantities statistics
Statistics:
delta_time: 1.02e-6
# 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).
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
minimal_temperature: 100 # K
# Parameters related to the initial conditions
InitialConditions:
file_name: ./ics_no_z.hdf5 # The file to read
periodic: 1
# Parameters for the EAGLE chemistry
EAGLEChemistry: # Solar abundances
init_abundance_metal: 0.
init_abundance_Hydrogen: 0.752
init_abundance_Helium: 0.248
init_abundance_Carbon: 0.
init_abundance_Nitrogen: 0.
init_abundance_Oxygen: 0.
init_abundance_Neon: 0.
init_abundance_Magnesium: 0.
init_abundance_Silicon: 0.
init_abundance_Iron: 0.
# Parameters for the EAGLE cooling
EAGLECooling:
dir_name: ./coolingtables/
H_reion_z: 11.5
H_reion_eV_p_H: 2.0
He_reion_z_centre: 3.5
He_reion_z_sigma: 0.5
He_reion_eV_p_H: 2.0
# Parameters for the EAGLE "equation of state"
EAGLEEntropyFloor:
Jeans_density_threshold_H_p_cm3: 0.1 # Physical density above which the EAGLE Jeans limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
Jeans_over_density_threshold: 10. # Overdensity above which the EAGLE Jeans limiter entropy floor can kick in.
Jeans_temperature_norm_K: 8000 # Temperature of the EAGLE Jeans limiter entropy floor at the density threshold expressed in Kelvin.
Jeans_gamma_effective: 1.3333333 # Slope the of the EAGLE Jeans limiter entropy floor
Cool_density_threshold_H_p_cm3: 1e-5 # Physical density above which the EAGLE Cool limiter entropy floor kicks in expressed in Hydrogen atoms per cm^3.
Cool_over_density_threshold: 10. # Overdensity above which the EAGLE Cool limiter entropy floor can kick in.
Cool_temperature_norm_K: 8000 # Temperature of the EAGLE Cool limiter entropy floor at the density threshold expressed in Kelvin.
Cool_gamma_effective: 1. # Slope the of the EAGLE Cool limiter entropy floor
LambdaCooling:
lambda_nH2_cgs: 2.13744785e-23 # Cooling rate divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
ConstCooling:
cooling_rate: 1. # Cooling rate (du/dt) (internal units)
min_energy: 1. # Minimal internal energy per unit mass (internal units)
cooling_tstep_mult: 1. # Dimensionless pre-factor for the time-step condition
\ No newline at end of file
#!/bin/bash
wget http://virgodb.cosma.dur.ac.uk/swift-webstorage/ICs/gravity_glassCube_32.hdf5
"""
Creates a redshift-dependent cooling box such that it always has the same
_physical_ density at the given redshift.
"""
from swiftsimio import Writer
from swiftsimio.units import cosmo_units
from unyt import mh, cm, s, K, Mpc, kb
import numpy as np
import h5py
# Physics parameters.
boxsize = 1.0 * Mpc
physical_density = 0.1 * mh / cm ** 3
mu_hydrogen = 0.5 # Fully ionised
temperature = 1e7 * K
gamma = 5.0 / 3.0
def get_coordinates(glass_filename: str) -> np.array:
"""
Gets the coordinates from the glass file.
"""
with h5py.File(glass_filename, "r") as handle:
coordinates = handle["PartType1/Coordinates"][...]
return coordinates
def generate_ics(redshift: float, filename: str, glass_filename: str) -> None:
"""
Generate initial conditions for the CoolingRedshiftDependence example.
"""
scale_factor = 1 / (1 + redshift)
comoving_boxsize = boxsize / scale_factor
glass_coordinates = get_coordinates(glass_filename)
number_of_particles = len(glass_coordinates)
gas_particle_mass = physical_density * (boxsize ** 3) / number_of_particles
writer = Writer(cosmo_units, comoving_boxsize)
writer.gas.coordinates = glass_coordinates * comoving_boxsize
writer.gas.velocities = np.zeros_like(glass_coordinates) * cm / s
writer.gas.masses = np.ones(number_of_particles, dtype=float) * gas_particle_mass
# Leave in physical units; handled by boxsize change.
writer.gas.internal_energy = (
np.ones(number_of_particles, dtype=float)
* 3.0 / 2.0
* (temperature * kb)
/ (mu_hydrogen * mh)
)
writer.gas.generate_smoothing_lengths(boxsize=comoving_boxsize, dimension=3)
writer.write(filename)
return
if __name__ == "__main__":
"""
Sets up the initial parameters.
"""
import argparse as ap
parser = ap.ArgumentParser(
description="""
Sets up the initial conditions for the cooling test. Takes two
redshifts, and produces two files: ics_high_z.hdf5 and
ics_low_z.hdf5.
"""
)
parser.add_argument(
"-a",
"--high",
help="The high redshift to generate initial conditions for. Default: 1.0",
default=1,
type=float,
)
parser.add_argument(
"-b",
"--low",
help="The low redshift to generate initial conditions for. Default: 0.01",
default=0.01,
type=float,
)
parser.add_argument(
"-n",
"--nocosmo",
help="Generate a non-cosmological box? Default: Truthy",
default=1,
type=bool,
)
parser.add_argument(
"-g",
"--glass",
help="Glass filename. Default: gravity_glassCube_32.hdf5",
type=str,
default="gravity_glassCube_32.hdf5",
)
args = parser.parse_args()
generate_ics(args.low, filename="ics_low_z.hdf5", glass_filename=args.glass)
generate_ics(args.high, filename="ics_high_z.hdf5", glass_filename=args.glass)
if args.nocosmo:
generate_ics(0.0, filename="ics_no_z.hdf5", glass_filename=args.glass)
exit(0)
"""
Plots the mean temperature.
"""
import matplotlib.pyplot as plt