mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
can read hdf5 noise files
This commit is contained in:
parent
8c9d2acf7a
commit
64e13026fb
3 changed files with 19 additions and 6 deletions
|
@ -8,11 +8,14 @@ zstart = 129.0
|
|||
# order of the LPT to be used (1,2 or 3)
|
||||
LPTorder = 3
|
||||
# also do baryon ICs?
|
||||
DoBaryons = yes
|
||||
DoBaryons = no
|
||||
# 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 = bcc
|
||||
ParticleLoad = s
|
||||
# Add a possible constraint field here:
|
||||
ConstraintFieldFile = initial_conditions.h5
|
||||
ConstraintFieldName = ic
|
||||
|
||||
[cosmology]
|
||||
transfer = CLASS
|
||||
|
@ -42,7 +45,7 @@ seed = 9001
|
|||
test = none
|
||||
|
||||
[execution]
|
||||
NumThreads = 16
|
||||
NumThreads = 8
|
||||
|
||||
[output]
|
||||
fname_hdf5 = output_sch.hdf5
|
||||
|
|
|
@ -358,6 +358,7 @@ void Grid_FFT<data_t,bdistributed>::Read_from_HDF5(const std::string Filename, c
|
|||
csoca::ilog << "Read external constraint data of dimensions " << dimsize[0] << "**3." << std::endl;
|
||||
|
||||
for( size_t i=0; i<3; ++i ) this->n_[i] = dimsize[i];
|
||||
this->space_ = rspace_id;
|
||||
|
||||
if (data_ != nullptr)
|
||||
{
|
||||
|
@ -367,6 +368,8 @@ void Grid_FFT<data_t,bdistributed>::Read_from_HDF5(const std::string Filename, c
|
|||
|
||||
|
||||
//... copy data to internal array ...
|
||||
double sum1{0.0}, sum2{0.0};
|
||||
#pragma omp parallel for reduction(+:sum1,sum2)
|
||||
for (size_t i = 0; i < size(0); ++i)
|
||||
{
|
||||
for (size_t j = 0; j < size(1); ++j)
|
||||
|
@ -374,9 +377,14 @@ void Grid_FFT<data_t,bdistributed>::Read_from_HDF5(const std::string Filename, c
|
|||
for (size_t k = 0; k < size(2); ++k)
|
||||
{
|
||||
this->relem(i,j,k) = Data[ (i*size(1) + j)*size(2)+k ];
|
||||
sum2 += std::real(this->relem(i,j,k)*this->relem(i,j,k));
|
||||
sum1 += std::real(this->relem(i,j,k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sum1 /= Data.size();
|
||||
sum2 /= Data.size();
|
||||
csoca::ilog << "Constraint field has <W>=" << sum1 << ", <W^2>-<W>^2=" << std::sqrt(sum2-sum1*sum1) << std::endl;
|
||||
}
|
||||
|
||||
template <typename data_t,bool bdistributed>
|
||||
|
|
|
@ -85,7 +85,7 @@ int Run( ConfigFile& the_config )
|
|||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
//! do constrained ICs?
|
||||
const bool bAddConstrainedModes = the_config.ContainsKey("setup", "ConstraintField" );
|
||||
const bool bAddConstrainedModes = the_config.ContainsKey("setup", "ConstraintFieldFile" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
//! add beyond box tidal field modes following Schmidt et al. (2018) [https://arxiv.org/abs/1803.03274]
|
||||
|
@ -198,10 +198,12 @@ int Run( ConfigFile& the_config )
|
|||
//--------------------------------------------------------------------
|
||||
if( bAddConstrainedModes ){
|
||||
Grid_FFT<real_t,false> cwnoise({8,8,8}, {boxlen,boxlen,boxlen});
|
||||
cwnoise.Read_from_HDF5( the_config.GetValue<std::string>("setup", "ConstraintField"), "wnoise" );
|
||||
cwnoise.Read_from_HDF5( the_config.GetValue<std::string>("setup", "ConstraintFieldFile"),
|
||||
the_config.GetValue<std::string>("setup", "ConstraintFieldName") );
|
||||
cwnoise.FourierTransformForward();
|
||||
|
||||
// TODO: copy over modes
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue