mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
added distinct amplitudes for cdm and baryons
This commit is contained in:
parent
cd7f451397
commit
1fc2b2d677
5 changed files with 139 additions and 101 deletions
|
@ -5,8 +5,8 @@ project(monofonIC)
|
|||
# include class submodule
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/external/class.cmake)
|
||||
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -march=native -Wall -fno-omit-frame-pointer -g -fsanitize=address")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wall -pedantic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wall -fno-omit-frame-pointer -g -fsanitize=address")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wall -pedantic -g -fno-omit-frame-pointer")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
set(CMAKE_MODULE_PATH
|
||||
|
|
18
example.conf
18
example.conf
|
@ -4,15 +4,15 @@ GridRes = 128
|
|||
# length of the box in Mpc/h
|
||||
BoxLength = 250
|
||||
# starting redshift
|
||||
zstart = 49.0
|
||||
zstart = 129.0
|
||||
# order of the LPT to be used (1,2 or 3)
|
||||
LPTorder = 3
|
||||
# also do baryon ICs?
|
||||
DoBaryons = no
|
||||
DoBaryons = yes
|
||||
# do mode fixing à la Angulo&Pontzen
|
||||
DoFixing = no
|
||||
# particle load, can be 'sc' (1x), 'bcc' (2x) or 'fcc' (4x) (increases number of particles by factor!)
|
||||
ParticleLoad = sc
|
||||
ParticleLoad = bcc
|
||||
|
||||
[cosmology]
|
||||
transfer = CLASS
|
||||
|
@ -42,15 +42,19 @@ seed = 9001
|
|||
test = none
|
||||
|
||||
[execution]
|
||||
NumThreads = 4
|
||||
NumThreads = 16
|
||||
|
||||
[output]
|
||||
fname_hdf5 = output_sch.hdf5
|
||||
fbase_analysis = output
|
||||
|
||||
format = gadget2
|
||||
filename = ics_gadget.dat
|
||||
UseLongids = false
|
||||
#format = gadget2
|
||||
#filename = ics_gadget.dat
|
||||
#UseLongids = false
|
||||
#
|
||||
format = gadget_hdf5
|
||||
filename = ics_gadget.hdf5
|
||||
|
||||
|
||||
#format = generic
|
||||
#filename = debug.hdf5
|
||||
|
|
|
@ -81,23 +81,33 @@ public:
|
|||
|
||||
// write power spectrum to a file
|
||||
std::ofstream ofs(fname.c_str());
|
||||
std::stringstream ss; ss << " (a=" << a <<")";
|
||||
std::stringstream ss; ss << " ,a=" << a <<"";
|
||||
ofs << "# " << std::setw(18) << "k [h/Mpc]"
|
||||
<< std::setw(20) << ("P_dtot(k)"+ss.str())
|
||||
<< std::setw(20) << ("P_dcdm(k)"+ss.str())
|
||||
<< std::setw(20) << ("P_dbar(k)"+ss.str())
|
||||
<< std::setw(20) << ("P_dtot(K) (a=1)")
|
||||
<< std::setw(20) << ("P_tcdm(k)"+ss.str())
|
||||
<< std::setw(20) << ("P_tbar(k)"+ss.str())
|
||||
<< std::setw(20) << ("P_dtot(k"+ss.str()+"|BS)")
|
||||
<< std::setw(20) << ("P_dcdm(k"+ss.str()+"|BS)")
|
||||
<< std::setw(20) << ("P_dbar(k"+ss.str()+"|BS)")
|
||||
<< std::setw(20) << ("P_tcdm(k"+ss.str()+"|BS)")
|
||||
<< std::setw(20) << ("P_tbar(k"+ss.str()+"|BS)")
|
||||
<< std::setw(20) << ("P_dtot(k"+ss.str()+")")
|
||||
<< std::setw(20) << ("P_dcdm(k"+ss.str()+")")
|
||||
<< std::setw(20) << ("P_dbar(k"+ss.str()+")")
|
||||
<< std::setw(20) << ("P_tcdm(k"+ss.str()+")")
|
||||
<< std::setw(20) << ("P_tbar(k"+ss.str()+")")
|
||||
<< std::setw(20) << ("P_dtot(K,a=1)")
|
||||
<< std::endl;
|
||||
for( double k=kmin; k<transfer_function_->get_kmax(); k*=1.05 ){
|
||||
ofs << std::setw(20) << std::setprecision(10) << k
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, total) * Dplus0, 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, cdm) * Dplus0, 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, baryon) * Dplus0, 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, total), 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, vcdm) * Dplus0, 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, vbaryon) * Dplus0, 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, total0), 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, cdm0), 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, baryon0), 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, vcdm0), 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, vbaryon0), 2.0)
|
||||
<< std::setw(20) << std::setprecision(10) << std::pow(this->GetAmplitude(k, total), 2.0)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ const std::vector<vec3<real_t>> second_lattice_shift =
|
|||
{
|
||||
/* SC : */ {0.5, 0.5, 0.5},
|
||||
/* BCC: */ {0.5, 0.5, 0.0},
|
||||
/* FCC: */ {0.5, 0.5, 0.5},
|
||||
/* FCC: */ {0.5, 0.0, 0.0},
|
||||
/* RSC: */ {0.25, 0.25, 0.25},
|
||||
};
|
||||
|
||||
|
|
|
@ -182,6 +182,11 @@ int Run( ConfigFile& the_config )
|
|||
the_random_number_generator->Fill_Grid(wnoise);
|
||||
|
||||
wnoise.FourierTransformForward();
|
||||
wnoise.apply_function_k( [&](auto wn){
|
||||
if (bDoFixing)
|
||||
wn = (std::abs(wn) != 0.0) ? wn / std::abs(wn) : wn;
|
||||
return wn / volfac;
|
||||
});
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -221,12 +226,9 @@ int Run( ConfigFile& the_config )
|
|||
phi.FourierTransformForward(false);
|
||||
phi.assign_function_of_grids_kdep([&](auto k, auto wn) {
|
||||
real_t kmod = k.norm();
|
||||
if (bDoFixing)
|
||||
wn = (std::abs(wn) != 0.0) ? wn / std::abs(wn) : wn;
|
||||
ccomplex_t delta = wn * the_cosmo_calc->GetAmplitude(kmod, total);
|
||||
return -delta / (kmod * kmod) / volfac;
|
||||
},
|
||||
wnoise);
|
||||
return -delta / (kmod * kmod);
|
||||
}, wnoise);
|
||||
|
||||
phi.zero_DC_mode();
|
||||
|
||||
|
@ -492,9 +494,20 @@ int Run( ConfigFile& the_config )
|
|||
// divide by Lbox, because displacement is in box units for output plugin
|
||||
tmp.kelem(idx) = lunit / boxlen * ( lg.gradient(idim,tmp.get_k3(i,j,k)) * phitot
|
||||
+ lg.gradient(idimp,tmp.get_k3(i,j,k)) * A3[idimpp]->kelem(idx) - lg.gradient(idimpp,tmp.get_k3(i,j,k)) * A3[idimp]->kelem(idx) );
|
||||
|
||||
if( bDoBaryons ){
|
||||
vec3<real_t> kvec = phi.get_k<real_t>(i,j,k);
|
||||
real_t k2 = kvec.norm_squared(), kmod = std::sqrt(k2);
|
||||
double ampldiff = ((this_species == cosmo_species::dm)? the_cosmo_calc->GetAmplitude(kmod, cdm0) :
|
||||
(this_species == cosmo_species::baryon)? the_cosmo_calc->GetAmplitude(kmod, baryon0) :
|
||||
the_cosmo_calc->GetAmplitude(kmod, total)*g1) - the_cosmo_calc->GetAmplitude(kmod, total)*g1;
|
||||
|
||||
tmp.kelem(idx) += lg.gradient(idim, tmp.get_k3(i,j,k)) * wnoise.kelem(idx) * lunit * ampldiff / k2 / boxlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp.zero_DC_mode();
|
||||
tmp.FourierTransformBackward();
|
||||
|
||||
// if we write particle data, store particle data in particle structure
|
||||
|
@ -530,9 +543,19 @@ int Run( ConfigFile& the_config )
|
|||
tmp.kelem(idx) = vunit / boxlen * ( lg.gradient(idim,tmp.get_k3(i,j,k)) * phitot_v
|
||||
+ vfac3 * (lg.gradient(idimp,tmp.get_k3(i,j,k)) * A3[idimpp]->kelem(idx) - lg.gradient(idimpp,tmp.get_k3(i,j,k)) * A3[idimp]->kelem(idx)) );
|
||||
|
||||
if( bDoBaryons ){
|
||||
vec3<real_t> kvec = phi.get_k<real_t>(i,j,k);
|
||||
real_t k2 = kvec.norm_squared(), kmod = std::sqrt(k2);
|
||||
double ampldiff = ((this_species == cosmo_species::dm)? -the_cosmo_calc->GetAmplitude(kmod, vcdm0) :
|
||||
(this_species == cosmo_species::baryon)? -the_cosmo_calc->GetAmplitude(kmod, vbaryon0) :
|
||||
the_cosmo_calc->GetAmplitude(kmod, total)*g1) - the_cosmo_calc->GetAmplitude(kmod, total)*g1;
|
||||
tmp.kelem(idx) += lg.gradient(idim, tmp.get_k3(i,j,k)) * wnoise.kelem(idx) * vfac1 * vunit / boxlen * ampldiff / k2 ;
|
||||
}
|
||||
|
||||
// correct velocity with PLT mode growth rate
|
||||
tmp.kelem(idx) *= lg.vfac_corr(tmp.get_k3(i,j,k));
|
||||
|
||||
|
||||
if( bAddExternalTides ){
|
||||
// modify velocities with anisotropic expansion factor**2
|
||||
tmp.kelem(idx) *= std::pow(lss_aniso_alpha[idim],2.0);
|
||||
|
@ -544,6 +567,7 @@ int Run( ConfigFile& the_config )
|
|||
}
|
||||
}
|
||||
}
|
||||
tmp.zero_DC_mode();
|
||||
tmp.FourierTransformBackward();
|
||||
|
||||
// if we write particle data, store particle data in particle structure
|
||||
|
|
Loading…
Reference in a new issue