Skip to content

Commit 6c96b17

Browse files
committed
adding MUSIC code
1 parent 77d8e26 commit 6c96b17

File tree

114 files changed

+39690
-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.

114 files changed

+39690
-0
lines changed

MUSIC/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.

MUSIC/LICENSE.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CosmoFlow simulations Copyright (c) 2018, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
(1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
(3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12+
13+
You are under no obligation whatsoever to provide any bug fixes, patches, or upgrades to the features, functionality or performance of the source code ("Enhancements") to anyone; however, if you choose to make your Enhancements available either publicly, or directly to Lawrence Berkeley National Laboratory, without imposing a separate written license agreement for such Enhancements, then you hereby grant the following license: a non-exclusive, royalty-free perpetual license to install, use, modify, prepare derivative works, incorporate into other computer software, distribute, and sublicense such enhancements or derivative works thereof, in binary and source code form.

MUSIC/MUSIC

42.9 MB
Binary file not shown.

MUSIC/Makefile

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

MUSIC/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+
}

MUSIC/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+

MUSIC/Numerics.o

22.6 KB
Binary file not shown.

MUSIC/OmSiNs/ics_template.conf

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[setup]
2+
boxlength = 512
3+
zstart = 0
4+
levelmin = 9
5+
levelmax = 9
6+
overlap = 4
7+
align_top = no
8+
baryons = no
9+
use_2LPT = no
10+
use_LLA = no
11+
periodic_TF = yes
12+
13+
14+
[cosmology]
15+
Omega_m = 0.276
16+
Omega_L = 0.724
17+
w0 = -1.0
18+
wa = 0.0
19+
Omega_b = 0.045
20+
H0 = 70.3
21+
sigma_8 = 0.811
22+
nspec = 0.961
23+
transfer = eisenstein
24+
25+
[random]
26+
seed[9] = 34567
27+
28+
[output]
29+
##generic MUSIC data format (used for testing)
30+
##requires HDF5 installation and HDF5 enabled in Makefile
31+
format = generic
32+
filename = ics_nozoom.hdf5
33+
34+
[poisson]
35+
fft_fine = yes
36+
accuracy = 1e-5
37+
pre_smooth = 3
38+
post_smooth = 3
39+
smoother = gs
40+
laplace_order = 6
41+
grad_order = 6
42+

0 commit comments

Comments
 (0)