Commit 6d2e4dfb authored by lesgourg's avatar lesgourg
Browse files

Compatible with python3 (credits M. Millea), fixes for more robust wrapper...

Compatible with python3 (credits M. Millea), fixes for more robust wrapper installation, new reionisation scheme reio_inter

* 2.5:
  new version number 2.5.1
  another cosmetic change
  cosmetic changes in view of minor release
  more robust commands in Makefile for the python wrapper installation
  Makefile set back to coding system utf-8-unix to avoid problems of invisible characters
  adding PPF debug notebook
  started to code PPF in newtonian gauge
  reio_inter scheme: updated explanatory.ini
  added scheme reio_inter, but more checkes and debugging needed
  commented out tests on H0, T_cmb, Omega_k
  fixed other python 2/3 compatibility issues by hand
  ran 2to3 tool
parents f798efb4 4d7e33e8
......@@ -30,7 +30,9 @@ cosmo_mini_toolbox, available under GPLv3 at
https://github.com/JesusTorrado/cosmo_mini_toolbox
"""
from __future__ import unicode_literals
from __future__ import unicode_literals, print_function
# System imports
import os
import sys
......@@ -343,8 +345,8 @@ def plot_CLASS_output(files, x_axis, y_axis, ratio=False, printing='',
# Write to the python file all the issued commands. You can then reproduce
# the plot by running "python output/something_cl.dat.py"
with open(python_script_path, 'w') as python_script:
print 'Creating a python script to reproduce the figure'
print '--> stored in %s' % python_script_path
print('Creating a python script to reproduce the figure')
print('--> stored in %s' % python_script_path)
python_script.write('\n'.join(text))
# If the use wants to print the figure to a file
......@@ -439,7 +441,7 @@ def extract_headers(header_path):
def main():
print '~~~ Running CPU, a CLASS Plotting Utility ~~~'
print('~~~ Running CPU, a CLASS Plotting Utility ~~~')
parser = CPU_parser()
# Parse the command line arguments
args = parser.parse_args()
......@@ -480,7 +482,7 @@ def main():
# performed. If asked to be divided, the ratio is shown - whether a need
# for interpolation arises or not.
if args.ratio and args.scale == 'loglog':
print "Defaulting to loglin scale"
print("Defaulting to loglin scale")
args.scale = 'loglin'
plot_CLASS_output(args.files, args.x_axis, args.y_axis,
......
#Some Makefile for CLASS.
#Julien Lesgourgues, 28.11.2011
MDIR := $(shell pwd)
WRKDIR = $(MDIR)/build
.base:
if ! [ -e $(WRKDIR) ]; then mkdir $(WRKDIR) ; mkdir $(WRKDIR)/lib; fi;
touch build/.base
vpath %.c source:tools:main:test
vpath %.o build
vpath .base build
########################################################
###### LINES TO ADAPT TO YOUR PLATEFORM ################
########################################################
# your C compiler:
CC = gcc
#CC = icc
#CC = pgcc
# your tool for creating static libraries:
AR = ar rv
# (OPT) your python interpreter
PYTHON = python
# your optimization flag
OPTFLAG = -O4 -ffast-math #-march=native
#OPTFLAG = -Ofast -ffast-math #-march=native
#OPTFLAG = -fast
# your openmp flag (comment for compiling without openmp)
OMPFLAG = -fopenmp
#OMPFLAG = -mp -mp=nonuma -mp=allcores -g
#OMPFLAG = -openmp
# all other compilation flags
CCFLAG = -g -fPIC
LDFLAG = -g -fPIC
# leave blank to compile without HyRec, or put path to HyRec directory
# (with no slash at the end: e.g. hyrec or ../hyrec)
HYREC = hyrec
########################################################
###### IN PRINCIPLE THE REST SHOULD BE LEFT UNCHANGED ##
########################################################
# pass current working directory to the code
CCFLAG += -D__CLASSDIR__='"$(MDIR)"'
# where to find include files *.h
INCLUDES = -I../include
# automatically add external programs if needed. First, initialize to blank.
EXTERNAL =
# Try to automatically avoid an error 'error: can't combine user with ...'
# which sometimes happens with brewed Python on OSX:
CFGFILE=$(shell $(PYTHON) -c "import sys; print sys.prefix+'/lib/'+'python'+'.'.join(['%i' % e for e in sys.version_info[0:2]])+'/distutils/distutils.cfg'")
PYTHONPREFIX=$(shell grep -s "prefix" $(CFGFILE))
ifeq ($(PYTHONPREFIX),)
PYTHONFLAGS=--user
else
PYTHONFLAGS=
endif
# eventually update flags for including HyRec
ifneq ($(HYREC),)
vpath %.c $(HYREC)
CCFLAG += -DHYREC
#LDFLAGS += -DHYREC
INCLUDES += -I../hyrec
EXTERNAL += hyrectools.o helium.o hydrogen.o history.o
endif
%.o: %.c .base
cd $(WRKDIR);$(CC) $(OPTFLAG) $(OMPFLAG) $(CCFLAG) $(INCLUDES) -c ../$< -o $*.o
TOOLS = growTable.o dei_rkck.o sparse.o evolver_rkck.o evolver_ndf15.o arrays.o parser.o quadrature.o hyperspherical.o common.o
SOURCE = input.o background.o thermodynamics.o perturbations.o primordial.o nonlinear.o transfer.o spectra.o lensing.o
INPUT = input.o
PRECISION = precision.o
BACKGROUND = background.o
THERMO = thermodynamics.o
PERTURBATIONS = perturbations.o
TRANSFER = transfer.o
PRIMORDIAL = primordial.o
SPECTRA = spectra.o
NONLINEAR = nonlinear.o
LENSING = lensing.o
OUTPUT = output.o
CLASS = class.o
TEST_LOOPS = test_loops.o
TEST_LOOPS_OMP = test_loops_omp.o
TEST_DEGENERACY = test_degeneracy.o
TEST_TRANSFER = test_transfer.o
TEST_NONLINEAR = test_nonlinear.o
TEST_PERTURBATIONS = test_perturbations.o
TEST_THERMODYNAMICS = test_thermodynamics.o
TEST_BACKGROUND = test_background.o
TEST_SIGMA = test_sigma.o
TEST_HYPERSPHERICAL = test_hyperspherical.o
TEST_STEPHANE = test_stephane.o
C_TOOLS = $(addprefix tools/, $(addsuffix .c,$(basename $(TOOLS))))
C_SOURCE = $(addprefix source/, $(addsuffix .c,$(basename $(SOURCE) $(OUTPUT))))
C_TEST = $(addprefix test/, $(addsuffix .c,$(basename $(TEST_DEGENERACY) $(TEST_LOOPS) $(TEST_TRANSFER) $(TEST_NONLINEAR) $(TEST_PERTURBATIONS) $(TEST_THERMODYNAMICS))))
C_MAIN = $(addprefix main/, $(addsuffix .c,$(basename $(CLASS))))
C_ALL = $(C_MAIN) $(C_TOOLS) $(C_SOURCE)
H_ALL = $(addprefix include/, common.h svnversion.h $(addsuffix .h, $(basename $(notdir $(C_ALL)))))
PRE_ALL = cl_ref.pre clt_permille.pre
INI_ALL = explanatory.ini lcdm.ini
MISC_FILES = Makefile CPU psd_FD_single.dat myselection.dat myevolution.dat README bbn/sBBN.dat external_Pk/* cpp
PYTHON_FILES = python/classy.pyx python/setup.py python/cclassy.pxd python/test_class.py
all: class libclass.a classy
libclass.a: $(TOOLS) $(SOURCE) $(EXTERNAL)
$(AR) $@ $(addprefix build/, $(TOOLS) $(SOURCE) $(EXTERNAL))
class: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(CLASS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o class $(addprefix build/,$(notdir $^)) -lm
test_sigma: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_SIGMA)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o test_sigma $(addprefix build/,$(notdir $^)) -lm
test_loops: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_LOOPS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_loops_omp: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_LOOPS_OMP)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_stephane: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_STEPHANE)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_degeneracy: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_DEGENERACY)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_transfer: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_TRANSFER)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_nonlinear: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_NONLINEAR)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_perturbations: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_PERTURBATIONS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_thermodynamics: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_THERMODYNAMICS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_background: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_BACKGROUND)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_hyperspherical: $(TOOLS) $(TEST_HYPERSPHERICAL)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o test_hyperspherical $(addprefix build/,$(notdir $^)) -lm
tar: $(C_ALL) $(C_TEST) $(H_ALL) $(PRE_ALL) $(INI_ALL) $(MISC_FILES) $(HYREC) $(PYTHON_FILES)
tar czvf class.tar.gz $(C_ALL) $(H_ALL) $(PRE_ALL) $(INI_ALL) $(MISC_FILES) $(HYREC) $(PYTHON_FILES)
classy: libclass.a python/classy.pyx python/cclassy.pxd
cd python; export CC=$(CC); $(PYTHON) setup.py install $(PYTHONFLAGS)
clean: .base
rm -rf $(WRKDIR);
rm -f libclass.a
rm -f $(MDIR)/python/classy.c
rm -rf $(MDIR)/python/build
#Some Makefile for CLASS.
#Julien Lesgourgues, 28.11.2011
MDIR := $(shell pwd)
WRKDIR = $(MDIR)/build
.base:
if ! [ -e $(WRKDIR) ]; then mkdir $(WRKDIR) ; mkdir $(WRKDIR)/lib; fi;
touch build/.base
vpath %.c source:tools:main:test
vpath %.o build
vpath .base build
########################################################
###### LINES TO ADAPT TO YOUR PLATEFORM ################
########################################################
# your C compiler:
CC = gcc
#CC = icc
#CC = pgcc
# your tool for creating static libraries:
AR = ar rv
# Your python interpreter.
# In order to use Python 3, you can manually
# substitute python3 to python in the line below, or you can simply
# add a compilation option on the terminal command line:
# "PYTHON=python3 make all" (THanks to Marius Millea for pyhton3
# compatibility)
PYTHON ?= python
# your optimization flag
OPTFLAG = -O4 -ffast-math #-march=native
#OPTFLAG = -Ofast -ffast-math #-march=native
#OPTFLAG = -fast
# your openmp flag (comment for compiling without openmp)
OMPFLAG = -fopenmp
#OMPFLAG = -mp -mp=nonuma -mp=allcores -g
#OMPFLAG = -openmp
# all other compilation flags
CCFLAG = -g -fPIC
LDFLAG = -g -fPIC
# leave blank to compile without HyRec, or put path to HyRec directory
# (with no slash at the end: e.g. hyrec or ../hyrec)
HYREC = hyrec
########################################################
###### IN PRINCIPLE THE REST SHOULD BE LEFT UNCHANGED ##
########################################################
# pass current working directory to the code
CCFLAG += -D__CLASSDIR__='"$(MDIR)"'
# where to find include files *.h
INCLUDES = -I../include
# automatically add external programs if needed. First, initialize to blank.
EXTERNAL =
# eventually update flags for including HyRec
ifneq ($(HYREC),)
vpath %.c $(HYREC)
CCFLAG += -DHYREC
#LDFLAGS += -DHYREC
INCLUDES += -I../hyrec
EXTERNAL += hyrectools.o helium.o hydrogen.o history.o
endif
%.o: %.c .base
cd $(WRKDIR);$(CC) $(OPTFLAG) $(OMPFLAG) $(CCFLAG) $(INCLUDES) -c ../$< -o $*.o
TOOLS = growTable.o dei_rkck.o sparse.o evolver_rkck.o evolver_ndf15.o arrays.o parser.o quadrature.o hyperspherical.o common.o
SOURCE = input.o background.o thermodynamics.o perturbations.o primordial.o nonlinear.o transfer.o spectra.o lensing.o
INPUT = input.o
PRECISION = precision.o
BACKGROUND = background.o
THERMO = thermodynamics.o
PERTURBATIONS = perturbations.o
TRANSFER = transfer.o
PRIMORDIAL = primordial.o
SPECTRA = spectra.o
NONLINEAR = nonlinear.o
LENSING = lensing.o
OUTPUT = output.o
CLASS = class.o
TEST_LOOPS = test_loops.o
TEST_LOOPS_OMP = test_loops_omp.o
TEST_DEGENERACY = test_degeneracy.o
TEST_TRANSFER = test_transfer.o
TEST_NONLINEAR = test_nonlinear.o
TEST_PERTURBATIONS = test_perturbations.o
TEST_THERMODYNAMICS = test_thermodynamics.o
TEST_BACKGROUND = test_background.o
TEST_SIGMA = test_sigma.o
TEST_HYPERSPHERICAL = test_hyperspherical.o
TEST_STEPHANE = test_stephane.o
C_TOOLS = $(addprefix tools/, $(addsuffix .c,$(basename $(TOOLS))))
C_SOURCE = $(addprefix source/, $(addsuffix .c,$(basename $(SOURCE) $(OUTPUT))))
C_TEST = $(addprefix test/, $(addsuffix .c,$(basename $(TEST_DEGENERACY) $(TEST_LOOPS) $(TEST_TRANSFER) $(TEST_NONLINEAR) $(TEST_PERTURBATIONS) $(TEST_THERMODYNAMICS))))
C_MAIN = $(addprefix main/, $(addsuffix .c,$(basename $(CLASS))))
C_ALL = $(C_MAIN) $(C_TOOLS) $(C_SOURCE)
H_ALL = $(addprefix include/, common.h svnversion.h $(addsuffix .h, $(basename $(notdir $(C_ALL)))))
PRE_ALL = cl_ref.pre clt_permille.pre
INI_ALL = explanatory.ini lcdm.ini
MISC_FILES = Makefile CPU psd_FD_single.dat myselection.dat myevolution.dat README bbn/sBBN.dat external_Pk/* cpp
PYTHON_FILES = python/classy.pyx python/setup.py python/cclassy.pxd python/test_class.py
all: class libclass.a classy
libclass.a: $(TOOLS) $(SOURCE) $(EXTERNAL)
$(AR) $@ $(addprefix build/, $(TOOLS) $(SOURCE) $(EXTERNAL))
class: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(CLASS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o class $(addprefix build/,$(notdir $^)) -lm
test_sigma: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_SIGMA)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o test_sigma $(addprefix build/,$(notdir $^)) -lm
test_loops: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_LOOPS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_loops_omp: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_LOOPS_OMP)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_stephane: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_STEPHANE)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_degeneracy: $(TOOLS) $(SOURCE) $(EXTERNAL) $(OUTPUT) $(TEST_DEGENERACY)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_transfer: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_TRANSFER)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_nonlinear: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_NONLINEAR)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_perturbations: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_PERTURBATIONS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_thermodynamics: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_THERMODYNAMICS)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_background: $(TOOLS) $(SOURCE) $(EXTERNAL) $(TEST_BACKGROUND)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o $@ $(addprefix build/,$(notdir $^)) -lm
test_hyperspherical: $(TOOLS) $(TEST_HYPERSPHERICAL)
$(CC) $(OPTFLAG) $(OMPFLAG) $(LDFLAG) -o test_hyperspherical $(addprefix build/,$(notdir $^)) -lm
tar: $(C_ALL) $(C_TEST) $(H_ALL) $(PRE_ALL) $(INI_ALL) $(MISC_FILES) $(HYREC) $(PYTHON_FILES)
tar czvf class.tar.gz $(C_ALL) $(H_ALL) $(PRE_ALL) $(INI_ALL) $(MISC_FILES) $(HYREC) $(PYTHON_FILES)
classy: libclass.a python/classy.pyx python/cclassy.pxd
cd python; export CC=$(CC); $(PYTHON) setup.py install || $(PYTHON) setup.py install --user
clean: .base
rm -rf $(WRKDIR);
rm -f libclass.a
rm -f $(MDIR)/python/classy.c
rm -rf $(MDIR)/python/build
......@@ -156,13 +156,22 @@ Omega_k = 0.
Omega_fld = 0
Omega_scf = 0
8b) equation of state parameter (p/rho equal to w0+wa(1-a/a0) ) and sound speed
of the fluid (this is the sound speed defined in the frame comoving with
the fluid, i.e. obeying to the most sensible physical definition)
8b) equation of state parameter (p/rho equal to w0+wa(1-a/a0) ) and
sound speed of the fluid (this is the sound speed defined in the
frame comoving with the fluid, i.e. obeying to the most sensible
physical definition). The flag use_ppf is 'yes' by default, to use
PPF approximation (see 0808.3125 [astro-ph]) allowing
perturbations to cross phantom divide. Set to 'no' to enforce true
fluid equations for perturbations. When PPF apprxomiation is used,
you can choose the ratio c_gamma_over_c_fld (eq. (16) in
0808.3125). The default is 0.4 as recommended by that reference,
and implicitely assumed in other codes.
w0_fld = -0.9
wa_fld = 0.
cs2_fld = 1
use_ppf = yes
c_gamma_over_c_fld = 0.4
8c) Scalar field (scf) initial conditions from attractor solution (assuming
pure exponential potential). (default: yes)
......@@ -212,8 +221,9 @@ recombination = RECFAST
interpolation between input values), 'reio_half_tanh' (like
'reio_camb' excepted that we match the function xe(z) from
recombination with only half a tanh(z-z_reio)), 'reio_many_tanh'
(arbitrary number of tanh-like steps with specified central values,
a scheme usually more useful than 'reio_bins_tanh')... (default:
(arbitrary number of tanh-like steps with specified ending values,
a scheme usually more useful than 'reio_bins_tanh'), 'reio_inter'
(linear interpolation between discrete values of xe(z))... (default:
set to 'reio_camb')
reio_parametrization = reio_camb
......@@ -247,13 +257,30 @@ binned_reio_xe = 0.8,0.2,0.1
binned_reio_step_sharpness = 0.3
3.c.) if 'reio_parametrization' set to 'reio_many_tanh': enter number of jumps,
list of jump redhsifts z_i (central value of each tanh()), list of free electron density x_i after each jump, and common width of all jumps. If you want to end up with all hydrogen reionized but neglecting helium reionization, the first value of x_i in the list should be 1. For each x_i you can also pass the flags -1 or -2. They mean: for -1, after hydrogen + first helium recombination (so the code will substitute a value bigger than one based on Y_He); for -2, after hydrogen + second helium recombination (the code will substitite an even bigger value based on Y_He). You can get results close to reio_camb by setting these parameters to the value showed below (and adapting the second many_tanh_z to the usual z_reio). (default: not set)
list of jump redhsifts z_i (central value of each tanh()), list of free electron density x_i after each jump, and common width of all jumps. If you want to end up with all hydrogen reionized but neglecting helium reionization, the first value of x_i in the list should be 1. For each x_i you can also pass the flags -1 or -2. They mean: for -1, after hydrogen + first helium recombination (so the code will substitute a value bigger than one based on Y_He); for -2, after hydrogen + second helium recombination (the code will substitute an even bigger value based on Y_He). You can get results close to reio_camb by setting these parameters to the value showed below (and adapting the second many_tanh_z to the usual z_reio). (default: not set)
many_tanh_num = 2
many_tanh_z = 3.5,11.3
many_tanh_xe = -2,-1
many_tanh_width = 0.5
3.d.) if 'reio_parametrization' set to 'reio_inter': enter the number
of points, the list of redshifts z_i, and the list of free electron
fraction values x_i. The code will do linear interpolation between
them. The first z_i should always be 0. Like above, for each x_i, you
can also pass the flags -1 or -2. They mean: for -1, after the
hydrogen and the first helium recombination (so the code will
substitute a value bigger than one based on Y_He); for -2, after the
hydrogen and the second helium recombination (the code will substitute
an even bigger value based on Y_He). The last value of x_i should
always be zero, the code will substitute it with the value that one
would get in absence of reionization, as computed by the recombination
code. (default: not set)
reio_inter_num = 8
reio_inter_z = 0, 3, 4, 8, 9, 10, 11, 12
reio_inter_xe = -2, -2, -1, -1, 0.9, 0.5, 0.1, 0
4.a) in order to model energy injection from DM annihilation, specify a
parameter 'annihilation' corresponding to the energy fraction absorbed by
the gas times the DM cross section divided by the DM mass, (f <sigma*v> /
......
#!/usr/bin/python
from __future__ import print_function
import sys
from math import exp
......@@ -51,5 +52,5 @@ while ks[-1] <= float(k_max) :
# Filling the array of Pk's
for k in ks :
P_k = P(k)
print "%.18g %.18g" % (k, P_k)
print("%.18g %.18g" % (k, P_k))
#!/usr/bin/python
from __future__ import print_function
import sys
from math import exp
......@@ -55,5 +56,5 @@ while ks[-1] <= float(k_max) :
# Filling the array of Pk's
for k in ks :
print "%.18g %.18g %.18g" % (k, P_s(k), P_t(k))
print("%.18g %.18g %.18g" % (k, P_s(k), P_t(k)))
......@@ -59,6 +59,14 @@ struct background
not [delta p/delta rho] in the synchronous or
newtonian gauge!!!) */
short use_ppf; /**< flag switching on PPF perturbation equations
instead of true fluid equations for
perturbations. It could have been defined inside
perturbation structure, but we leave it here in
such way to have all fld parameters grouped. */
double c_gamma_over_c_fld; /**< ppf parameter defined in eq. (16) of 0808.3125 [astro-ph] */
double Omega0_ur; /**< \f$ \Omega_{0 \nu r} \f$: ultra-relativistic neutrinos */
double Omega0_dcdmdr; /**< \f$ \Omega_{0 dcdm}+\Omega_{0 dr} \f$: decaying cold dark matter (dcdm) decaying to dark radiation (dr) */
......
......@@ -15,7 +15,7 @@
#ifndef __COMMON__
#define __COMMON__
#define _VERSION_ "v2.5.0"
#define _VERSION_ "v2.5.1"
/* @cond INCLUDE_WITH_DOXYGEN */
#define _TRUE_ 1 /**< integer associated to true statement */
......
......@@ -394,8 +394,9 @@ struct perturb_vector
int index_pt_theta_cdm; /**< cdm velocity */
int index_pt_delta_dcdm; /**< dcdm density */
int index_pt_theta_dcdm; /**< dcdm velocity */
int index_pt_delta_fld; /**< dark energy density */
int index_pt_theta_fld; /**< dark energy velocity */
int index_pt_delta_fld; /**< dark energy density in true fluid case */
int index_pt_theta_fld; /**< dark energy velocity in true fluid case */
int index_pt_Gamma_fld; /**< unique dark energy dynamical variable in PPF case */
int index_pt_phi_scf; /**< scalar field density */
int index_pt_phi_prime_scf; /**< scalar field velocity */
int index_pt_delta_ur; /**< density of ultra-relativistic neutrinos/relics */
......@@ -501,6 +502,11 @@ struct perturb_workspace
double delta_m; /**< relative density perturbation of all non-relativistic species */
double theta_m; /**< velocity divergence theta of all non-relativistic species */
double delta_rho_fld; /**< density perturbation of fluid, not so trivial in PPF scheme */
double rho_plus_p_theta_fld; /**< velocity divergence of fluid, not so trivial in PPF scheme */
double S_fld; /**< S quantity sourcing Gamma_prime evolution in PPF scheme (equivalent to eq. 15 in 0808.3125) */
double Gamma_prime_fld; /**< Gamma_prime in PPF scheme (equivalent to eq. 14 in 0808.3125) */
FILE * perturb_output_file; /**< filepointer to output file*/
int index_ikout; /**< index for output k value (when k_output_values is set) */
......
......@@ -26,7 +26,8 @@ enum reionization_parametrization {
reio_camb, /**< reionization parameterized like in CAMB */
reio_bins_tanh, /**< binned reionization history with tanh inteprolation between bins */
reio_half_tanh, /**< half a tanh, instead of the full tanh */
reio_many_tanh /**< similar to reio_camb but with more than one tanh */
reio_many_tanh, /**< similar to reio_camb but with more than one tanh */
reio_inter /**< linear interpolation between specified points */
};
/**
......@@ -108,6 +109,14 @@ struct thermo
double many_tanh_width; /**< sharpness of tanh() steps */
/** parameters for reio_inter */
int reio_inter_num; /**< with how many jumps do we want to describe reionization? */
double * reio_inter_z; /**< discrete z values */
double * reio_inter_xe; /**< discrete \f$ X_e(z)\f$ values */
/** parameters for energy injection */
double annihilation; /** parameter describing CDM annihilation (f <sigma*v> / m_cdm, see e.g. 0905.0003) */
......@@ -403,7 +412,7 @@ struct reionization {
int index_helium_fullreio_redshift; /**< helium full reionization redshift */
int index_helium_fullreio_width; /**< a width defining the duration of helium full reionization in the reio_camb scheme */
/* parameters used by reio_bins_tanh and reio_many_tanh */
/* parameters used by reio_bins_tanh, reio_many_tanh, reio_inter */
int reio_num_z; /**< number of reionization jumps */
int index_reio_first_z; /**< redshift at which we start to impose reionization function */
......
This diff is collapsed.
......@@ -33,7 +33,7 @@ DEF _MAXTITLESTRINGLENGTH_ = 8000
# MontePython to handle things differently.
class CosmoError(Exception):
def __init__(self, message=""):
self.message = message
self.message = message.decode() if isinstance(message,bytes) else message
def __str__(self):
return '\n\nError in Class: ' + self.message
......@@ -158,9 +158,10 @@ cdef class Class:
i = 0
for kk in self._pars:
dumc = kk
dumcp = kk.encode()
dumc = dumcp
sprintf(self.fc.name[i],"%s",dumc)
dumcp = str(self._pars[kk])