Skip to content

Commit 1e32e12

Browse files
committed
First commit of original files.
0 parents  commit 1e32e12

File tree

93 files changed

+54977
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+54977
-0
lines changed

Diff for: LICENSE

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
MUSIC - Multi-scale Initial Conditions for Cosmological Simulations
3+
4+
Copyright(c) 2011 by Oliver Hahn. All rights reserved.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to use
8+
the Software under the following conditions:
9+
10+
1. Redistributions of the Software must contain the above copyright
11+
notice, this list of conditions and the following disclaimers.
12+
13+
2. Scientific publications that make use of results obtained with
14+
the Software must properly reference that the 'MUSIC' software
15+
has been used and include a reference to Hahn & Abel (2011),
16+
published in MNRAS Vol 415(3), the paper describing the
17+
algorithms used in the Software.
18+
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
26+
THE SOFTWARE.

Diff for: Makefile

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
##############################################################################
2+
### compile time configuration options
3+
FFTW3 = yes
4+
MULTITHREADFFTW = yes
5+
SINGLEPRECISION = no
6+
HAVEHDF5 = yes
7+
HAVEPANPHASIA = yes
8+
PANPHASIA_HOME = ./panphasia
9+
HAVEBOXLIB = no
10+
BOXLIB_HOME = ${HOME}/nyx_tot_sterben/BoxLib
11+
12+
##############################################################################
13+
### compiler and path settings
14+
CC = g++-11 ## icpc
15+
FF = gfortran-11 # needed only for panphasia, or ## ifort
16+
LINKER = g++-11 ## ifort # need to link with ifort if using intel
17+
OPT = -Wall -Wno-unknown-pragmas -O3 -mtune=native #-fsanitize=address -fno-omit-frame-pointer
18+
CFLAGS =
19+
LFLAGS = -lgsl -lgslcblas -fsanitize=thread # -fsanitize=address -fno-omit-frame-pointer
20+
FFLAGS = -ffixed-line-length-132 -O3 -fimplicit-none -g #-fsanitize=address -fno-omit-frame-pointer## use for gfortran
21+
#FFLAGS = -extend_source -O3 -fimplicit-none -g ## use for ifort
22+
CPATHS = -I. -I$(HOME)/local/include -I/opt/local/include -I/usr/local/include
23+
LPATHS = -L$(HOME)/local/lib -L/opt/local/lib -L/usr/local/lib
24+
25+
##############################################################################
26+
# if you have FFTW 2.1.5 or 3.x with multi-thread support, you can enable the
27+
# option MULTITHREADFFTW
28+
ifeq ($(strip $(MULTITHREADFFTW)), yes)
29+
ifeq ($(CC), icpc)
30+
CFLAGS += -openmp
31+
LFLAGS += -openmp
32+
else
33+
CFLAGS += -fopenmp
34+
LFLAGS += -fopenmp
35+
endif
36+
ifeq ($(strip $(FFTW3)),yes)
37+
ifeq ($(strip $(SINGLEPRECISION)), yes)
38+
LFLAGS += -lfftw3f_threads
39+
else
40+
LFLAGS += -lfftw3_threads
41+
endif
42+
else
43+
ifeq ($(strip $(SINGLEPRECISION)), yes)
44+
LFLAGS += -lsrfftw_threads -lsfftw_threads
45+
else
46+
LFLAGS += -ldrfftw_threads -ldfftw_threads
47+
endif
48+
endif
49+
else
50+
CFLAGS += -DSINGLETHREAD_FFTW
51+
endif
52+
53+
ifeq ($(strip $(FFTW3)),yes)
54+
CFLAGS += -DFFTW3
55+
endif
56+
57+
##############################################################################
58+
# this section makes sure that the correct FFTW libraries are linked
59+
ifeq ($(strip $(SINGLEPRECISION)), yes)
60+
CFLAGS += -DSINGLE_PRECISION
61+
ifeq ($(FFTW3),yes)
62+
LFLAGS += -lfftw3f
63+
else
64+
LFLAGS += -lsrfftw -lsfftw
65+
endif
66+
else
67+
ifeq ($(strip $(FFTW3)),yes)
68+
LFLAGS += -lfftw3
69+
else
70+
LFLAGS += -ldrfftw -ldfftw
71+
endif
72+
endif
73+
74+
##############################################################################
75+
#if you have HDF5 installed, you can also enable the following options
76+
ifeq ($(strip $(HAVEHDF5)), yes)
77+
OPT += -DH5_USE_16_API -DHAVE_HDF5
78+
LFLAGS += -lhdf5
79+
endif
80+
81+
##############################################################################
82+
CFLAGS += $(OPT)
83+
TARGET = MUSIC
84+
OBJS = output.o transfer_function.o Numerics.o defaults.o constraints.o random.o\
85+
convolution_kernel.o region_generator.o densities.o cosmology.o poisson.o\
86+
densities.o cosmology.o poisson.o log.o main.o \
87+
$(patsubst plugins/%.cc,plugins/%.o,$(wildcard plugins/*.cc))
88+
89+
##############################################################################
90+
# stuff for PANPHASIA
91+
#FFLAGS += $(OPT)
92+
ifeq ($(strip $(HAVEPANPHASIA)), yes)
93+
CFLAGS += -DHAVE_PANPHASIA
94+
OBJS += generic_lecuyer.o panphasia_routines.o
95+
## if linking with g++
96+
LFLAGS += -lgfortran
97+
## if linking with ifort
98+
#LFLAGS += -nofor-main -lstdc++
99+
endif
100+
101+
##############################################################################
102+
# stuff for BoxLib
103+
BLOBJS = ""
104+
ifeq ($(strip $(HAVEBOXLIB)), yes)
105+
IN_MUSIC = YES
106+
TOP = ${PWD}/plugins/nyx_plugin
107+
CCbla := $(CC)
108+
include plugins/nyx_plugin/Make.ic
109+
CC := $(CCbla)
110+
CPATHS += $(INCLUDE_LOCATIONS)
111+
LPATHS += -L$(objEXETempDir)
112+
BLOBJS = $(foreach obj,$(objForExecs),plugins/boxlib_stuff/$(obj))
113+
#
114+
endif
115+
116+
##############################################################################
117+
all: $(OBJS) $(TARGET) Makefile
118+
# cd plugins/boxlib_stuff; make
119+
120+
bla:
121+
echo $(OBJS)
122+
123+
ifeq ($(strip $(HAVEPANPHASIA)), yes)
124+
generic_lecuyer.o: $(PANPHASIA_HOME)/generic_lecuyer.f90 # $(ALLDEP)
125+
$(FF) $(FFLAGS) -c $<
126+
127+
panphasia_routines.o: $(PANPHASIA_HOME)/panphasia_routines.f $(PANPHASIA_HOME)/generic_lecuyer.f90 generic_lecuyer.o # $(ALLDEP)
128+
$(FF) $(FFLAGS) -c $<
129+
endif
130+
131+
ifeq ($(strip $(HAVEBOXLIB)), yes)
132+
$(TARGET): $(OBJS) plugins/nyx_plugin/*.cpp
133+
cd plugins/nyx_plugin; make BOXLIB_HOME=$(BOXLIB_HOME) FFTW3=$(FFTW3) SINGLE=$(SINGLEPRECISION)
134+
$(CC) $(LPATHS) -o $@ $^ $(LFLAGS) $(BLOBJS) -lifcore
135+
else
136+
$(TARGET): $(OBJS)
137+
$(LINKER) $(LPATHS) -o $@ $^ $(LFLAGS)
138+
endif
139+
140+
%.o: %.cc *.hh Makefile
141+
$(CC) $(CFLAGS) $(CPATHS) -c $< -o $@
142+
143+
clean:
144+
rm -rf $(OBJS)
145+
ifeq ($(strip $(HAVEBOXLIB)), yes)
146+
oldpath=`pwd`
147+
cd plugins/nyx_plugin; make realclean BOXLIB_HOME=$(BOXLIB_HOME)
148+
endif
149+
cd $(oldpath)
150+

Diff for: Numerics.cc

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
3+
numerics.cc - This file is part of MUSIC -
4+
a code to generate multi-scale initial conditions
5+
for cosmological simulations
6+
7+
Copyright (C) 2010 Oliver Hahn
8+
9+
*/
10+
11+
#ifdef WITH_MPI
12+
#ifdef MANNO
13+
#include <mpi.h>
14+
#else
15+
#include <mpi++.h>
16+
#endif
17+
#endif
18+
#include <iostream>
19+
#include "Numerics.hh"
20+
21+
22+
#ifndef REL_PRECISION
23+
#define REL_PRECISION 1.e-5
24+
#endif
25+
26+
real_t integrate( double (* func) (double x, void * params), double a, double b, void *params )
27+
{
28+
gsl_function F;
29+
F.function = func;
30+
F.params = params;
31+
32+
double result;
33+
double error;
34+
35+
36+
gsl_set_error_handler_off ();
37+
gsl_integration_workspace *w = gsl_integration_workspace_alloc(100000);
38+
gsl_integration_qag( &F, a, b, 0, REL_PRECISION, 100000, 6, w, &result, &error );
39+
40+
41+
gsl_integration_workspace_free(w);
42+
43+
gsl_set_error_handler(NULL);
44+
45+
if( error/result > REL_PRECISION )
46+
std::cerr << " - Warning: no convergence in function 'integrate', rel. error=" << error/result << std::endl;
47+
48+
return (real_t)result;
49+
}

Diff for: Numerics.hh

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
3+
numerics.hh - This file is part of MUSIC -
4+
a code to generate multi-scale initial conditions
5+
for cosmological simulations
6+
7+
Copyright (C) 2010 Oliver Hahn
8+
9+
*/
10+
11+
#ifndef __NUMERICS_HH
12+
#define __NUMERICS_HH
13+
14+
#ifdef WITH_MPI
15+
#ifdef MANNO
16+
#include <mpi.h>
17+
#else
18+
#include <mpi++.h>
19+
#endif
20+
#endif
21+
22+
#include <cmath>
23+
#include <gsl/gsl_integration.h>
24+
#include <gsl/gsl_errno.h>
25+
26+
#include <vector>
27+
#include <algorithm>
28+
#include "general.hh"
29+
30+
31+
32+
real_t integrate( double (* func) (double x, void * params), double a, double b, void *params=NULL);
33+
34+
typedef __attribute__((__may_alias__)) int aint;
35+
36+
inline float fast_log2 (float val)
37+
{
38+
//if( sizeof(int) != sizeof(float) )
39+
// throw std::runtime_error("fast_log2 will fail on this system!!");
40+
aint * const exp_ptr = reinterpret_cast <aint *> (&val);
41+
aint x = *exp_ptr;
42+
const int log_2 = ((x >> 23) & 255) - 128;
43+
x &= ~(255 << 23);
44+
x += 127 << 23;
45+
*exp_ptr = x;
46+
47+
val = ((-1.0f/3) * val + 2) * val - 2.0f/3; // (1)
48+
49+
return (val + log_2);
50+
}
51+
52+
inline float fast_log (const float &val)
53+
{
54+
return (fast_log2 (val) * 0.69314718f);
55+
}
56+
57+
inline float fast_log10 (const float &val)
58+
{
59+
return (fast_log2 (val) * 0.3010299956639812f);
60+
}
61+
62+
inline unsigned locate( const double x, const std::vector<double> vx )
63+
{
64+
long unsigned ju,jm,jl;
65+
bool ascnd=(vx[vx.size()-1]>=vx[0]);
66+
jl = 0;
67+
ju = vx.size()-1;
68+
while( ju-jl > 1 ) {
69+
jm = (ju+jl)>>1;
70+
if( (x >= vx[jm]) == ascnd )
71+
jl = jm;
72+
else
73+
ju = jm;
74+
}
75+
return std::max((long unsigned)0,std::min((long unsigned)(vx.size()-2),(long unsigned)jl));
76+
}
77+
78+
79+
inline real_t linint( const double x, const std::vector<double>& xx, const std::vector<double>& yy )
80+
{
81+
unsigned i = locate(x,xx);
82+
83+
if( x<xx[0] )
84+
return yy[0];
85+
if( x>=xx[xx.size()-1] )
86+
return yy[yy.size()-1];
87+
double a = 1.0/(xx[i+1]-xx[i]);
88+
double dy = (yy[i+1]-yy[i])*a;
89+
double y0 = (yy[i]*xx[i+1]-xx[i]*yy[i+1])*a;
90+
return dy*x+y0;
91+
}
92+
93+
94+
#endif
95+
96+

Diff for: README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
MUSIC - multi-scale cosmological initial conditions
2+
===================================================
3+
4+
MUSIC is a computer program to generate nested grid initial conditions for
5+
high-resolution "zoom" cosmological simulations. A detailed description
6+
of the algorithms can be found in [Hahn & Abel (2011)][1]. You can
7+
download the user's guide [here][3]. Please consider joining the
8+
[user mailing list][2].
9+
10+
Current MUSIC key features are:
11+
12+
- Supports output for RAMSES, ENZO, Arepo, Gadget-2/3, ART, Pkdgrav/Gasoline
13+
and NyX via plugins. New codes can be added.
14+
15+
- Support for first (1LPT) and second order (2LPT) Lagrangian perturbation
16+
theory, local Lagrangian approximation (LLA) for baryons with grid codes.
17+
18+
- Pluggable transfer functions, currently CAMB, Eisenstein&Hu, BBKS, Warm
19+
Dark Matter variants. Distinct baryon+CDM fields.
20+
21+
- Minimum bounding ellipsoid and convex hull shaped high-res regions supported
22+
with most codes, supports refinement mask generation for RAMSES.
23+
24+
- Parallelized with OpenMP
25+
26+
- Requires FFTW (v2 or v3), GSL (and HDF5 for output for some codes)
27+
28+
29+
This program is distributed in the hope that it will be useful, but
30+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
31+
or FITNESS FOR A PARTICULAR PURPOSE. By downloading and using MUSIC, you
32+
agree to the LICENSE, distributed with the source code in a text
33+
file of the same name.
34+
35+
36+
[1]: http://arxiv.org/abs/1103.6031
37+
[2]: https://groups.google.com/forum/#!forum/cosmo_music
38+
[3]: https://bitbucket.org/ohahn/music/downloads/MUSIC_Users_Guide.pdf

0 commit comments

Comments
 (0)