mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
grafic2 can also use SPT now, minor cleanup
This commit is contained in:
parent
a4a40aae4b
commit
d7063e824f
4 changed files with 45 additions and 40 deletions
15
example.conf
15
example.conf
|
@ -2,7 +2,7 @@
|
|||
GridRes = 64
|
||||
BoxLength = 100
|
||||
zstart = 49.0
|
||||
LPTorder = 3
|
||||
LPTorder = 2
|
||||
SymplecticPT = no
|
||||
DoFixing = no
|
||||
BCClattice = no
|
||||
|
@ -15,12 +15,13 @@ fname_hdf5 = output_sch.hdf5
|
|||
fbase_analysis = output
|
||||
#format = gadget2
|
||||
#filename = ics_gadget.dat
|
||||
format = generic
|
||||
filename = debug.hdf5
|
||||
generic_out_eulerian = yes
|
||||
#format = generic
|
||||
#filename = debug.hdf5
|
||||
#generic_out_eulerian = yes
|
||||
|
||||
#format = grafic2
|
||||
#filename = ics_ramses
|
||||
format = grafic2
|
||||
filename = ics_ramses
|
||||
grafic_use_SPT = yes
|
||||
|
||||
[random]
|
||||
generator = NGENIC
|
||||
|
@ -37,5 +38,5 @@ sigma_8 = 0.811
|
|||
nspec = 0.961
|
||||
|
||||
[sch]
|
||||
hbar = 0.5
|
||||
hbar = 5.0 #0.5
|
||||
dt = 1.0
|
||||
|
|
|
@ -244,6 +244,16 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
Grid_FFT<data_t>& apply_negative_Laplacian( void ){
|
||||
this->FourierTransformForward();
|
||||
this->apply_function_k_dep([&](auto x, auto k) {
|
||||
real_t kmod2 = k.norm_squared();
|
||||
return x*kmod2;
|
||||
});
|
||||
this->zero_DC_mode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Grid_FFT<data_t>& apply_InverseLaplacian( void ){
|
||||
this->FourierTransformForward();
|
||||
this->apply_function_k_dep([&](auto x, auto k) {
|
||||
|
|
|
@ -274,10 +274,6 @@ int Run( ConfigFile& the_config )
|
|||
//======================================================================
|
||||
// initialise psi = exp(i Phi(1)/hbar)
|
||||
//======================================================================
|
||||
//real_t hbar= the_config.GetValueSafe<real_t>("sch", "hbar", 0.000001);
|
||||
//real_t dt = the_config.GetValueSafe<real_t>("sch", "dt", 1.0);
|
||||
|
||||
|
||||
phi.FourierTransformBackward();
|
||||
real_t std_phi1 = phi.std();
|
||||
|
||||
|
@ -322,7 +318,6 @@ int Run( ConfigFile& the_config )
|
|||
return pp;
|
||||
}, psi);
|
||||
|
||||
// the_output_plugin->write_grid_data( rho, cosmo_species::dm, fluid_component::density );
|
||||
the_output_plugin->write_grid_data( rho, this_species, fluid_component::density );
|
||||
|
||||
//======================================================================
|
||||
|
@ -343,13 +338,10 @@ int Run( ConfigFile& the_config )
|
|||
}, psi, grad_psi, rho);
|
||||
|
||||
fluid_component fc = (idim==0)? fluid_component::vx : ((idim==1)? fluid_component::vy : fluid_component::vz );
|
||||
//the_output_plugin->write_grid_data( tmp, cosmo_species::dm, fc );
|
||||
the_output_plugin->write_grid_data( tmp, this_species, fc );
|
||||
}
|
||||
}
|
||||
|
||||
// if( the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::particles
|
||||
// || the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::field_lagrangian ){
|
||||
if( the_output_plugin->write_species_as( this_species ) == output_type::particles
|
||||
|| the_output_plugin->write_species_as( this_species ) == output_type::field_lagrangian )
|
||||
{
|
||||
|
@ -360,7 +352,6 @@ int Run( ConfigFile& the_config )
|
|||
particle_container particles;
|
||||
|
||||
// if output plugin wants particles, then we need to store them, along with their IDs
|
||||
//if( the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::particles ){
|
||||
if( the_output_plugin->write_species_as( this_species ) == output_type::particles )
|
||||
{
|
||||
// if particles occupy a bcc lattice, then there are 2 x N^3 of them...
|
||||
|
@ -408,7 +399,6 @@ int Run( ConfigFile& the_config )
|
|||
tmp.FourierTransformBackward();
|
||||
|
||||
// if we write particle data, store particle data in particle structure
|
||||
// if( the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::particles ){
|
||||
if( the_output_plugin->write_species_as( this_species ) == output_type::particles )
|
||||
{
|
||||
for( size_t i=0,ipcount=0; i<tmp.size(0); ++i ){
|
||||
|
@ -438,7 +428,6 @@ int Run( ConfigFile& the_config )
|
|||
else if( the_output_plugin->write_species_as( this_species ) == output_type::field_lagrangian )
|
||||
{
|
||||
fluid_component fc = (idim==0)? fluid_component::dx : ((idim==1)? fluid_component::dy : fluid_component::dz );
|
||||
// the_output_plugin->write_grid_data( tmp, cosmo_species::dm, fc );
|
||||
the_output_plugin->write_grid_data( tmp, this_species, fc );
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +460,6 @@ int Run( ConfigFile& the_config )
|
|||
tmp.FourierTransformBackward();
|
||||
|
||||
// if we write particle data, store particle data in particle structure
|
||||
// if( the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::particles ){
|
||||
if( the_output_plugin->write_species_as( this_species ) == output_type::particles ){
|
||||
for( size_t i=0,ipcount=0; i<tmp.size(0); ++i ){
|
||||
for( size_t j=0; j<tmp.size(1); ++j){
|
||||
|
@ -493,32 +481,26 @@ int Run( ConfigFile& the_config )
|
|||
}
|
||||
}
|
||||
}// otherwise write out the grid data directly to the output plugin
|
||||
// else if( the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::field_lagrangian )
|
||||
else if( the_output_plugin->write_species_as( this_species ) == output_type::field_lagrangian )
|
||||
{
|
||||
fluid_component fc = (idim==0)? fluid_component::vx : ((idim==1)? fluid_component::vy : fluid_component::vz );
|
||||
// the_output_plugin->write_grid_data( tmp, cosmo_species::dm, fc );
|
||||
the_output_plugin->write_grid_data( tmp, this_species, fc );
|
||||
}
|
||||
}
|
||||
|
||||
// if( the_output_plugin->write_species_as( cosmo_species::dm ) == output_type::particles )
|
||||
// {
|
||||
// the_output_plugin->write_particle_data( particles, cosmo_species::dm );
|
||||
// }
|
||||
|
||||
if( the_output_plugin->write_species_as( this_species ) == output_type::particles )
|
||||
{
|
||||
the_output_plugin->write_particle_data( particles, this_species );
|
||||
}
|
||||
|
||||
// if( the_output_plugin->write_species_as_grid( cosmo_species::baryon ) )
|
||||
// {
|
||||
// phi.FourierTransformForward();
|
||||
// phi.apply_Laplacian();
|
||||
// phi.FourierTransformBackward();
|
||||
// the_output_plugin->write_grid_data( phi, cosmo_species::baryon, fluid_component::density );
|
||||
// }
|
||||
if( the_output_plugin->write_species_as( this_species ) == output_type::field_lagrangian )
|
||||
{
|
||||
// use density simply from 1st order SPT
|
||||
phi.FourierTransformForward();
|
||||
phi.apply_negative_Laplacian();
|
||||
phi.FourierTransformBackward();
|
||||
the_output_plugin->write_grid_data( phi, this_species, fluid_component::density );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ protected:
|
|||
bool bhavebaryons_;
|
||||
std::vector<float> data_buf_;
|
||||
std::string dirname_;
|
||||
bool bUseSPT_;
|
||||
|
||||
public:
|
||||
//! constructor
|
||||
|
@ -54,10 +55,11 @@ public:
|
|||
omegaL = cf_.GetValue<double>("cosmology", "Omega_L");
|
||||
uint32_t ngrid = cf_.GetValue<int>("setup", "GridRes");
|
||||
|
||||
bUseSPT_ = cf_.GetValueSafe<bool>("output", "grafic_use_SPT", false);
|
||||
levelmin_ = uint32_t(std::log2(double(ngrid)) + 1e-6);
|
||||
|
||||
levelmin_ = uint32_t( std::log2( double(ngrid) ) + 1e-6 );
|
||||
|
||||
if( std::abs( std::pow( 2.0, levelmin_ )-double(ngrid) ) > 1e-4 ){
|
||||
if (std::abs(std::pow(2.0, levelmin_) - double(ngrid)) > 1e-4)
|
||||
{
|
||||
csoca::elog << interface_name_ << " plugin requires setup/GridRes to be power of 2!" << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
@ -93,10 +95,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
output_type write_species_as(const cosmo_species &s) const {
|
||||
if( s == cosmo_species::baryon ) return output_type::field_eulerian;
|
||||
output_type write_species_as(const cosmo_species &s) const
|
||||
{
|
||||
if (s == cosmo_species::baryon && !bUseSPT_)
|
||||
return output_type::field_eulerian;
|
||||
return output_type::field_lagrangian;
|
||||
}
|
||||
}
|
||||
|
||||
real_t position_unit() const { return lunit_; }
|
||||
|
||||
|
@ -158,8 +162,16 @@ std::string grafic2_output_plugin::get_file_name(const cosmo_species &s, const f
|
|||
|
||||
void grafic2_output_plugin::write_grid_data(const Grid_FFT<real_t> &g, const cosmo_species &s, const fluid_component &c)
|
||||
{
|
||||
// ignore certain components
|
||||
if (s == cosmo_species::dm && c == fluid_component::density)
|
||||
return;
|
||||
if (s == cosmo_species::baryon && (c == fluid_component::dx || c == fluid_component::dy || c == fluid_component::dz))
|
||||
return;
|
||||
|
||||
// get file name based on species and fluid component type
|
||||
std::string file_name = this->get_file_name(s, c);
|
||||
|
||||
// serialize parallel write
|
||||
for (int write_rank = 0; write_rank < CONFIG::MPI_task_size; ++write_rank)
|
||||
{
|
||||
if (write_rank == CONFIG::MPI_task_rank)
|
||||
|
|
Loading…
Reference in a new issue