mirror of
https://github.com/cosmo-sims/MUSIC.git
synced 2024-09-11 07:53:43 +02:00
commit
49c43415d6
45 changed files with 739 additions and 417 deletions
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
numerics.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifdef WITH_MPI
|
||||
#ifdef MANNO
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
numerics.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __NUMERICS_HH
|
||||
#define __NUMERICS_HH
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
constraints.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of monofonIC (MUSIC2)
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "constraints.hh"
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
constraints.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of monofonIC (MUSIC2)
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
/*
|
||||
|
||||
convolution_kernel.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions for cosmological simulations
|
||||
|
||||
Copyright (C) 2010-23 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of monofonIC (MUSIC2)
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <general.hh>
|
||||
#include <densities.hh>
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
convolution_kernel.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010-23 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of monofonIC (MUSIC2)
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __CONVOLUTION_KERNELS_HH
|
||||
#define __CONVOLUTION_KERNELS_HH
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
defaults.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "defaults.hh"
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
defaults.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef __DEFAULTS_HH
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
/*
|
||||
|
||||
densities.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "math/special.hh"
|
||||
|
||||
#include "densities.hh"
|
||||
#include "random.hh"
|
||||
#include "convolution_kernel.hh"
|
||||
|
@ -17,21 +26,8 @@
|
|||
//TODO: this should be a larger number by default, just to maintain consistency with old default
|
||||
#define DEF_RAN_CUBE_SIZE 32
|
||||
|
||||
double Meyer_scaling_function( double k, double kmax )
|
||||
{
|
||||
constexpr double twopithirds{2.0*M_PI/3.0};
|
||||
constexpr double fourpithirds{4.0*M_PI/3.0};
|
||||
auto nu = []( double x ){ return x<0.0?0.0:(x<1.0?x:1.0); };
|
||||
|
||||
k = std::abs(k)/kmax * fourpithirds;
|
||||
|
||||
if( k < twopithirds ) return 1.0;
|
||||
else if( k< fourpithirds ){
|
||||
return std::cos( 0.5*M_PI * nu(3*k/(2*M_PI)-1.0) );
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/* interpolate upwards in the hierarchy */
|
||||
template <typename m1, typename m2>
|
||||
void fft_coarsen(m1 &v, m2 &V)
|
||||
{
|
||||
|
@ -89,13 +85,14 @@ void fft_coarsen(m1 &v, m2 &V)
|
|||
|
||||
val_fine *= val_phas * fftnorm / 8.0;
|
||||
|
||||
if( i!=(int)nxF/2 && j!=(int)nyF/2 && k!=(int)nzF/2 ){
|
||||
RE(ccoarse[qc]) = val_fine.real();
|
||||
IM(ccoarse[qc]) = val_fine.imag();
|
||||
}else{
|
||||
RE(ccoarse[qc]) = 0.0;//val_fine.real();
|
||||
IM(ccoarse[qc]) = 0.0;//val_fine.imag();
|
||||
}
|
||||
double blend_coarse_x = Meyer_scaling_function(kx, nxF / 2);
|
||||
double blend_coarse_y = Meyer_scaling_function(ky, nyF / 2);
|
||||
double blend_coarse_z = Meyer_scaling_function(kz, nzF / 2);
|
||||
|
||||
double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z;
|
||||
|
||||
RE(ccoarse[qc]) = val_fine.real() * blend_coarse;
|
||||
IM(ccoarse[qc]) = val_fine.imag() * blend_coarse;
|
||||
}
|
||||
|
||||
delete[] rfine;
|
||||
|
@ -117,6 +114,7 @@ void fft_coarsen(m1 &v, m2 &V)
|
|||
FFTW_API(destroy_plan)(ipc);
|
||||
}
|
||||
|
||||
/* interpolate downwards in the hierarchy */
|
||||
template <typename m1, typename m2>
|
||||
void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false)
|
||||
{
|
||||
|
@ -124,6 +122,7 @@ void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false)
|
|||
size_t nxf = v.size(0), nyf = v.size(1), nzf = v.size(2), nzfp = nzf + 2;
|
||||
size_t mxf = v.margin(0), myf = v.margin(1), mzf = v.margin(2);
|
||||
|
||||
// adjust offsets to respect margins, all grids have 'margins' except basegrid (which is periodic)
|
||||
if (!from_basegrid)
|
||||
{
|
||||
oxf += mxf/2;
|
||||
|
@ -216,16 +215,14 @@ void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false)
|
|||
std::complex<double> val(RE(ccoarse[qc]), IM(ccoarse[qc]));
|
||||
val *= val_phas * 8.0;
|
||||
|
||||
if(i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2){
|
||||
double blend_coarse_x = Meyer_scaling_function(kx, nxc / 2);
|
||||
double blend_coarse_y = Meyer_scaling_function(ky, nyc / 2);
|
||||
double blend_coarse_z = Meyer_scaling_function(kz, nzc / 2);
|
||||
double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z;
|
||||
double blend_fine = 1.0-blend_coarse;
|
||||
double blend_coarse_x = Meyer_scaling_function(kx, nxc / 4);
|
||||
double blend_coarse_y = Meyer_scaling_function(ky, nyc / 4);
|
||||
double blend_coarse_z = Meyer_scaling_function(kz, nzc / 4);
|
||||
double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z;
|
||||
double blend_fine = 1.0-blend_coarse;
|
||||
|
||||
RE(cfine[qf]) = blend_fine * RE(cfine[qf]) + blend_coarse * val.real();
|
||||
IM(cfine[qf]) = blend_fine * IM(cfine[qf]) + blend_coarse * val.imag();
|
||||
}
|
||||
RE(cfine[qf]) = blend_fine * RE(cfine[qf]) + blend_coarse * val.real();
|
||||
IM(cfine[qf]) = blend_fine * IM(cfine[qf]) + blend_coarse * val.imag();
|
||||
}
|
||||
|
||||
delete[] rcoarse;
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
densities.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __DENSITIES_HH
|
||||
#define __DENSITIES_HH
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
fd_schemes.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __FD_SCHEMES_HH
|
||||
#define __FD_SCHEMES_HH
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
general.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn & Michael Michaux (this file)
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn & Michael Michaux (this file)
|
||||
//
|
||||
|
|
25
src/main.cc
25
src/main.cc
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
main.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
|
40
src/math/special.hh
Normal file
40
src/math/special.hh
Normal file
|
@ -0,0 +1,40 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
inline double Meyer_scaling_function( double k, double kmax )
|
||||
{
|
||||
constexpr double twopithirds{2.0*M_PI/3.0};
|
||||
constexpr double fourpithirds{4.0*M_PI/3.0};
|
||||
auto nu = []( double x ){ return x<0.0?0.0:(x<1.0?x:1.0); };
|
||||
|
||||
k = std::abs(k)/kmax * 2 * M_PI;
|
||||
|
||||
if( k < twopithirds ) return 1.0;
|
||||
else if( k< fourpithirds ){
|
||||
return std::cos( 0.5*M_PI * nu(3*k/(2*M_PI)-1.0) );
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
inline double Shannon_scaling_function( double k, double kmax )
|
||||
{
|
||||
if( std::abs(k) < kmax ) return 1.0;
|
||||
return 0.0;
|
||||
}
|
25
src/mesh.hh
25
src/mesh.hh
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
mesh.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
/*
|
||||
* mg_interp.hh
|
||||
* FROLIC_mg
|
||||
*
|
||||
* Created by Oliver Hahn on 5/27/10.
|
||||
* Copyright 2010 KIPAC/Stanford University. All rights reserved.
|
||||
*
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __MG_INTERP_HH
|
||||
#define __MG_INTERP_HH
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
mg_operators.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __MG_OPERATORS_HH
|
||||
#define __MG_OPERATORS_HH
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
mg_solver.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
output.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "output.hh"
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
output.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __OUTPUT_HH
|
||||
#define __OUTPUT_HH
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
cosmology.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <perturbation_theory.hh>
|
||||
#include <mesh.hh>
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
cosmology.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of monofonIC (MUSIC2)
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2020 by Oliver Hahn
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -145,6 +145,7 @@ void RNG_music::parse_random_parameters(void)
|
|||
void RNG_music::compute_random_numbers(void)
|
||||
{
|
||||
bool rndsign = pcf_->get_value_safe<bool>("random", "grafic_sign", false);
|
||||
bool bUseNGenIC = pcf_->get_value_safe<bool>("random","coarse_ngenic",false);
|
||||
|
||||
std::vector<rng *> randc(std::max(levelmax_, levelmin_seed_) + 1, (rng *)NULL);
|
||||
|
||||
|
@ -156,7 +157,8 @@ void RNG_music::compute_random_numbers(void)
|
|||
if (rngfnames_[levelmin_seed_].size() > 0)
|
||||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, rngfnames_[levelmin_seed_], rndsign);
|
||||
else
|
||||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_]);
|
||||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_],
|
||||
bUseNGenIC, true);
|
||||
|
||||
for (int i = levelmin_seed_ + 1; i <= levelmin_; ++i)
|
||||
{
|
||||
|
@ -178,7 +180,7 @@ void RNG_music::compute_random_numbers(void)
|
|||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, rngfnames_[levelmin_seed_], rndsign);
|
||||
else
|
||||
randc[levelmin_seed_] =
|
||||
new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_]); //, x0, lx );
|
||||
new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_], bUseNGenIC, true); //, x0, lx );
|
||||
|
||||
for (int ilevel = levelmin_seed_ - 1; ilevel >= (int)levelmin_; --ilevel)
|
||||
{
|
||||
|
@ -205,7 +207,7 @@ void RNG_music::compute_random_numbers(void)
|
|||
if (rngfnames_[levelmin_].size() > 0)
|
||||
randc[levelmin_] = new rng(1 << levelmin_, rngfnames_[levelmin_], rndsign);
|
||||
else
|
||||
randc[levelmin_] = new rng(1 << levelmin_, ran_cube_size_, rngseeds_[levelmin_]);
|
||||
randc[levelmin_] = new rng(1 << levelmin_, ran_cube_size_, rngseeds_[levelmin_], bUseNGenIC, true);
|
||||
}
|
||||
|
||||
store_rnd(levelmin_, randc[levelmin_]);
|
||||
|
|
|
@ -4,15 +4,24 @@
|
|||
#include <gsl/gsl_rng.h>
|
||||
#include <gsl/gsl_randist.h>
|
||||
|
||||
#include "math/special.hh"
|
||||
|
||||
#include "random.hh"
|
||||
#include "random_music_wnoise_generator.hh"
|
||||
|
||||
|
||||
template <typename T>
|
||||
void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator<T> &R)
|
||||
{
|
||||
music::ulog.Print("Invoking the N-GenIC random number generator");
|
||||
void music_wnoise_generator<T>:: gen_topgrid_NGenIC(size_t res, long baseseed) {
|
||||
music::ulog.Print(
|
||||
"Generating large-scale random numbers using N-GenIC RNG with seed %ld",
|
||||
baseseed);
|
||||
|
||||
rnums_.push_back(new Meshvar<T>(res, 0, 0, 0));
|
||||
cubemap_[0] = 0; // create dummy map index
|
||||
register_cube(0, 0, 0);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// execute N-GenIC rando number generator
|
||||
unsigned *seedtable = new unsigned[res * res];
|
||||
|
||||
gsl_rng *random_generator = gsl_rng_alloc(gsl_rng_ranlxd1);
|
||||
|
@ -39,91 +48,87 @@ void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator<T>
|
|||
for (j = 0; j < i + 1; j++)
|
||||
seedtable[(res - 1 - j) * res + (res - 1 - i)] = 0x7fffffff * gsl_rng_uniform(random_generator);
|
||||
}
|
||||
gsl_rng_free( random_generator );
|
||||
|
||||
real_t *rnoise = new real_t[res * res * (res + 2)];
|
||||
complex_t *knoise = reinterpret_cast<complex_t *>(rnoise);
|
||||
|
||||
double fnorm = 1. / sqrt(res * res * res);
|
||||
double fnorm = pow((double)res, -1.5);
|
||||
|
||||
// #warning need to check for race conditions below
|
||||
//#pragma omp parallel for
|
||||
for (size_t i = 0; i < res; i++)
|
||||
{
|
||||
int ii = (int)res - (int)i;
|
||||
if (ii == (int)res)
|
||||
ii = 0;
|
||||
// launch threads with indendent RNGs
|
||||
#pragma omp parallel
|
||||
{
|
||||
gsl_rng *thread_rng = gsl_rng_alloc(gsl_rng_ranlxd1);
|
||||
|
||||
for (size_t j = 0; j < res; j++)
|
||||
{
|
||||
gsl_rng_set(random_generator, seedtable[i * res + j]);
|
||||
#pragma omp for
|
||||
for (size_t i = 0; i < res; i++) {
|
||||
int ii = (int)res - (int)i;
|
||||
if (ii == (int)res)
|
||||
ii = 0;
|
||||
|
||||
for (size_t k = 0; k < res / 2; k++)
|
||||
{
|
||||
double phase = gsl_rng_uniform(random_generator) * 2 * M_PI;
|
||||
double ampl;
|
||||
do
|
||||
ampl = gsl_rng_uniform(random_generator);
|
||||
while (ampl == 0);
|
||||
for (size_t j = 0; j < res; j++) {
|
||||
gsl_rng_set(thread_rng, seedtable[i * res + j]);
|
||||
for (size_t k = 0; k < res / 2; k++) {
|
||||
double phase = gsl_rng_uniform(thread_rng) * 2 * M_PI;
|
||||
double ampl;
|
||||
do {
|
||||
ampl = gsl_rng_uniform(thread_rng);
|
||||
} while (ampl == 0);
|
||||
|
||||
if (i == res / 2 || j == res / 2 || k == res / 2)
|
||||
continue;
|
||||
if (i == 0 && j == 0 && k == 0)
|
||||
continue;
|
||||
if (i == res / 2 || j == res / 2 || k == res / 2)
|
||||
continue;
|
||||
if (i == 0 && j == 0 && k == 0)
|
||||
continue;
|
||||
|
||||
T rp = -sqrt(-log(ampl)) * cos(phase) * fnorm;
|
||||
T ip = -sqrt(-log(ampl)) * sin(phase) * fnorm;
|
||||
T rp = -sqrt(-log(ampl)) * cos(phase) * fnorm;
|
||||
T ip = -sqrt(-log(ampl)) * sin(phase) * fnorm;
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip;
|
||||
}
|
||||
else /* k=0 plane needs special treatment */
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (j >= res / 2)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
int jj = (int)res - (int)j; /* note: j!=0 surely holds at this point */
|
||||
if (k > 0) {
|
||||
RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip;
|
||||
} else /* k=0 plane needs special treatment */
|
||||
{
|
||||
if (i == 0) {
|
||||
if (j >= res / 2) {
|
||||
continue;
|
||||
} else {
|
||||
int jj =
|
||||
(int)res - (int)j; /* note: j!=0 surely holds at this point */
|
||||
|
||||
RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip;
|
||||
RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip;
|
||||
|
||||
RE(knoise[(i * res + jj) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + jj) * (res / 2 + 1) + k]) = -ip;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i >= res / 2)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
int ii = (int)res - (int)i;
|
||||
if (ii == (int)res)
|
||||
ii = 0;
|
||||
int jj = (int)res - (int)j;
|
||||
if (jj == (int)res)
|
||||
jj = 0;
|
||||
RE(knoise[(i * res + jj) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + jj) * (res / 2 + 1) + k]) = -ip;
|
||||
}
|
||||
} else {
|
||||
if (i >= res / 2) {
|
||||
continue;
|
||||
} else {
|
||||
int ii = (int)res - (int)i;
|
||||
if (ii == (int)res)
|
||||
ii = 0;
|
||||
int jj = (int)res - (int)j;
|
||||
if (jj == (int)res)
|
||||
jj = 0;
|
||||
|
||||
RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip;
|
||||
RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip;
|
||||
|
||||
if (ii >= 0 && ii < (int)res)
|
||||
{
|
||||
RE(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = -ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ii >= 0 && ii < (int)res) {
|
||||
RE(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = rp;
|
||||
IM(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = -ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gsl_rng_free( thread_rng );
|
||||
}
|
||||
|
||||
delete[] seedtable;
|
||||
delete[] seedtable;
|
||||
|
||||
//... perform FT to real space
|
||||
fftw_plan_t plan = FFTW_API(plan_dft_c2r_3d)(res, res, res, knoise, rnoise, FFTW_ESTIMATE);
|
||||
|
@ -131,12 +136,11 @@ void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator<T>
|
|||
FFTW_API(destroy_plan)(plan);
|
||||
|
||||
// copy to array that holds the random numbers
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < (int)res; ++i)
|
||||
for (size_t j = 0; j < res; ++j)
|
||||
for (size_t k = 0; k < res; ++k)
|
||||
R(i, j, k) = rnoise[((size_t)i * res + j) * res + k];
|
||||
(*this)(i, j, k) = -rnoise[((size_t)i * res + j) * (res + 2) + k];
|
||||
|
||||
delete[] rnoise;
|
||||
}
|
||||
|
@ -152,7 +156,8 @@ music_wnoise_generator<T>::music_wnoise_generator(unsigned res, unsigned cubesiz
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
music_wnoise_generator<T>::music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool zeromean)
|
||||
music_wnoise_generator<T>::music_wnoise_generator( unsigned res, unsigned cubesize, long baseseed,
|
||||
bool bUseNGenIC, bool zeromean )
|
||||
: res_(res), cubesize_(cubesize), ncubes_(1), baseseed_(baseseed)
|
||||
{
|
||||
music::ilog.Print("Generating random numbers (2) with seed %ld", baseseed);
|
||||
|
@ -160,23 +165,20 @@ music_wnoise_generator<T>::music_wnoise_generator(unsigned res, unsigned cubesiz
|
|||
double mean = 0.0;
|
||||
size_t res_l = res;
|
||||
|
||||
bool musicnoise = true;
|
||||
if (!musicnoise)
|
||||
cubesize_ = res_;
|
||||
|
||||
if (!musicnoise)
|
||||
music::elog.Print("This currently breaks compatibility. Need to disable by hand! Make sure to not check into repo");
|
||||
if( bUseNGenIC ){
|
||||
cubesize_ = res;
|
||||
ncubes_ = 1;
|
||||
}
|
||||
|
||||
initialize();
|
||||
|
||||
if (musicnoise)
|
||||
if( !bUseNGenIC ){
|
||||
mean = fill_all();
|
||||
else
|
||||
{
|
||||
rnums_.push_back(new Meshvar<T>(res, 0, 0, 0));
|
||||
cubemap_[0] = 0; // create dummy map index
|
||||
register_cube(0, 0, 0);
|
||||
rapid_proto_ngenic_rng( res_, baseseed_, *this );
|
||||
}else{
|
||||
music::ilog.Print("Using N-GenIC generator for top grid...");
|
||||
mean = 0.0;
|
||||
gen_topgrid_NGenIC( res_, baseseed_ );
|
||||
zeromean = false;
|
||||
}
|
||||
|
||||
if (zeromean)
|
||||
|
@ -603,9 +605,6 @@ music_wnoise_generator<T>::music_wnoise_generator(music_wnoise_generator<T> &rc,
|
|||
{
|
||||
int ii(i), jj(j), kk(k);
|
||||
|
||||
// if( i==(int)nxc/2 ) continue;
|
||||
// if( j==(int)nyc/2 ) continue;
|
||||
|
||||
if (i > (int)nxc / 2)
|
||||
ii += (int)nx / 2;
|
||||
if (j > (int)nyc / 2)
|
||||
|
@ -627,18 +626,21 @@ music_wnoise_generator<T>::music_wnoise_generator(music_wnoise_generator<T> &rc,
|
|||
|
||||
val *= val_phas * sqrt8;
|
||||
|
||||
// if (x0_ == NULL || lx_ == NULL){
|
||||
if (i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2)
|
||||
{
|
||||
RE(cfine[qf]) = val.real();
|
||||
IM(cfine[qf]) = val.imag();
|
||||
}
|
||||
else
|
||||
{
|
||||
RE(cfine[qf]) = val.real();
|
||||
IM(cfine[qf]) = 0.0;
|
||||
}
|
||||
// }
|
||||
if(i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2){
|
||||
double blend_coarse_x = Meyer_scaling_function(kx, nxc / 2);
|
||||
double blend_coarse_y = Meyer_scaling_function(ky, nyc / 2);
|
||||
double blend_coarse_z = Meyer_scaling_function(kz, nzc / 2);
|
||||
|
||||
// double blend_coarse_x = Shannon_scaling_function(kx, nxc / 2);
|
||||
// double blend_coarse_y = Shannon_scaling_function(ky, nyc / 2);
|
||||
// double blend_coarse_z = Shannon_scaling_function(kz, nzc / 2);
|
||||
|
||||
double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z;
|
||||
double blend_fine = std::sqrt(1.0-blend_coarse*blend_coarse);
|
||||
|
||||
RE(cfine[qf]) = blend_fine * RE(cfine[qf]) + blend_coarse * val.real();
|
||||
IM(cfine[qf]) = blend_fine * IM(cfine[qf]) + blend_coarse * val.imag();
|
||||
}
|
||||
}
|
||||
|
||||
delete[] rcoarse;
|
||||
|
|
|
@ -39,6 +39,9 @@ protected:
|
|||
//! subtract a constant from an entire cube
|
||||
void subtract_from_cube(int i, int j, int k, double val);
|
||||
|
||||
//! usees the N-GenIC random number generator to set up the top grid
|
||||
void gen_topgrid_NGenIC( size_t res, long baseseed );
|
||||
|
||||
//! copy random numbers from a cube to a full grid array
|
||||
template <class C>
|
||||
void copy_cube(int i, int j, int k, C &dat)
|
||||
|
@ -127,7 +130,7 @@ public:
|
|||
music_wnoise_generator(music_wnoise_generator<T> &rc, unsigned cubesize, long baseseed, int *x0_ = NULL, int *lx_ = NULL, bool zeromean = true);
|
||||
|
||||
//! constructor
|
||||
music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool zeromean = true);
|
||||
music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool bUseNGenIC, bool zeromean = true );
|
||||
|
||||
//! constructor to read white noise from file
|
||||
music_wnoise_generator(unsigned res, std::string randfname, bool rndsign);
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
poisson.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/****** ABSTRACT FACTORY PATTERN IMPLEMENTATION *******/
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
poisson.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef __POISSON_HH
|
||||
#define __POISSON_HH
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
/*
|
||||
|
||||
random.cc - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions for cosmological simulations
|
||||
|
||||
Copyright (C) 2010-23 Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "random.hh"
|
||||
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
/*
|
||||
|
||||
random.hh - This file is part of MUSIC -
|
||||
a code to generate multi-scale initial conditions
|
||||
for cosmological simulations
|
||||
|
||||
Copyright (C) 2010-23 by Oliver Hahn
|
||||
|
||||
*/
|
||||
// This file is part of MUSIC
|
||||
// A software package to generate ICs for cosmological simulations
|
||||
// Copyright (C) 2010-2024 by Oliver Hahn
|
||||
//
|
||||
// monofonIC is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// monofonIC is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this |