54 petapm_init(pm, BoxSize, Asmth, Nmesh,
G, MPI_COMM_WORLD);
66 (
char*) &
P[0].Pos[0] - (
char*)
P,
67 (
char*) &
P[0].Mass - (
char*)
P,
88 #pragma omp parallel for
91 P[i].GravPM[0] =
P[i].GravPM[1] =
P[i].GravPM[2] = 0;
163 MPI_Reduce(&r, &maxNregions, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
164 message(0,
"max number of regions is %d\n", maxNregions);
167 int numswallowed = 0;
168 #pragma omp parallel for reduction(+: numswallowed)
182 #pragma omp parallel for reduction(+: numpart)
183 for(r = 0; r < *Nregions; r++) {
196 for(r =0; r < *Nregions; r++) {
213 while(no >= 0 && no != endno)
219 int p = nop->
s.
suns[i];
225 for(k = 0; k < 3; k ++) {
226 double l =
P[p].Pos[k] - tree->
Nodes[startno].
center[k];
229 if(l > tree->
Nodes[startno].
len * (1+ 1e-7))
230 endrun(1,
"enlarging node size from %g to %g, due to particle of type %d at %g %g %g id=%ld\n",
231 tree->
Nodes[startno].
len, l,
P[p].Type,
P[p].Pos[0],
P[p].Pos[1],
P[p].Pos[2],
P[p].ID);
249 endrun(122,
"Unrecognised Node type %d, memory corruption!\n", nop->
f.
ChildType);
260 printf(
"task = %d no = %d len = %g hmax = %g center = %g %g %g\n",
266 for(k = 0; k < 3; k ++) {
267 r->
offset[k] = floor((Nodes[no].
center[k] - Nodes[no].
len * 0.5) / cellsize);
268 int end = (int) ceil((Nodes[no].
center[k] + Nodes[no].
len * 0.5) / cellsize) + 1;
292 if(x < 1e-5 && x > -1e-5) {
294 return 1.0 - x2 / 6. + x2 * x2 / 120.;
318 ps->
nu_acc = gsl_interp_accel_alloc();
327 powerspectrum_add_mode(
Power * PowerSpectrum,
const int64_t k2,
const int kpos[3], pfft_complex *
const value,
const double invwindow,
double Nmesh)
331 PowerSpectrum->
Norm = (value[0][0] * value[0][0] + value[0][1] * value[0][1]);
339 const double binsperunit=(PowerSpectrum->
size-1)/log(sqrt(3) * Nmesh/2.0);
340 int kint=floor(binsperunit*log(k2)/2.);
342 const double keff = sqrt(kpos[0]*kpos[0]+kpos[1]*kpos[1]+kpos[2]*kpos[2]);
343 const double m = (value[0][0] * value[0][0] + value[0][1] * value[0][1]);
345 if(kint >= PowerSpectrum->
size)
347 if(kpos[2] == 0 || kpos[2] == Nmesh/2) w = 1;
350 const int index = kint + omp_get_thread_num() * PowerSpectrum->
size;
352 PowerSpectrum->
Power[index] += w * m * invwindow * invwindow;
353 PowerSpectrum->
Nmodes[index] += w;
354 PowerSpectrum->
kk[index] += w * keff;
371 for(k = 0; k < 3; k ++) {
372 double tmp = (kpos[k] * M_PI) / pm->
Nmesh;
374 f *= 1. / (tmp * tmp);
382 const double asmth2 = pow((2 * M_PI) * pm->
Asmth / pm->
Nmesh,2);
384 const double smth = exp(-k2 * asmth2) / k2;
399 for(k = 0; k < 3; k ++) {
400 double tmp = (kpos[k] * M_PI) / pm->
Nmesh;
402 f *= 1. / (tmp * tmp);
417 if(logk2 < ps->logknu[0] && logk2 > ps->
logknu[0]-log(2) )
431 value[0][0] *= nufac;
432 value[0][1] *= nufac;
440 ps->
Norm *= MtotbyMcdm*MtotbyMcdm;
461 return 1 / 6.0 * (8 * sin (w) - sin (2 * w));
481 tmp0 = - value[0][1] * fac;
482 tmp1 = value[0][0] * fac;
496 P[i].Potential += weight * mesh[0];
499 P[i].GravPM[0] += weight * mesh[0];
502 P[i].GravPM[1] += weight * mesh[0];
505 P[i].GravPM[2] += weight * mesh[0];
double GrowthFactor(Cosmology *CP, double astart, double aend)
void message(int where, const char *fmt,...)
void endrun(int where, const char *fmt,...)
int force_tree_allocated(const ForceTree *tree)
void force_tree_free(ForceTree *tree)
int force_get_father(int no, const ForceTree *tree)
#define PARTICLE_NODE_TYPE
static PetaPMGlobalFunctions global_functions
static double diff_kernel(double w)
static void readout_potential(PetaPM *pm, int i, double *mesh, double weight)
static void compute_neutrino_power(PetaPM *pm)
static void force_x_transfer(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
static void readout_force_z(PetaPM *pm, int i, double *mesh, double weight)
static void readout_force_x(PetaPM *pm, int i, double *mesh, double weight)
void powerspectrum_add_mode(Power *PowerSpectrum, const int64_t k2, const int kpos[3], pfft_complex *const value, const double invwindow, double Nmesh)
static int pm_mark_region_for_node(int startno, int rid, int *RegionInd, const ForceTree *tt)
static void force_z_transfer(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
static void force_y_transfer(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
static int hybrid_nu_gravpm_is_active(int i)
static void readout_force_y(PetaPM *pm, int i, double *mesh, double weight)
static PetaPMRegion * _prepare(PetaPM *pm, PetaPMParticleStruct *pstruct, void *userdata, int *Nregions)
static double sinc_unnormed(double x)
static void potential_transfer(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
static struct gravpm_params GravPM
void gravpm_force(PetaPM *pm, ForceTree *tree, Cosmology *CP, double Time, double UnitLength_in_cm, const char *PowerOutputDir, double TimeIC, int FastParticleType)
void measure_power_spectrum(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
static PetaPMFunctions functions[]
static void force_transfer(PetaPM *pm, int k, pfft_complex *value)
static void convert_node_to_region(PetaPM *pm, PetaPMRegion *r, struct NODE *Nodes)
void gravpm_init_periodic(PetaPM *pm, double BoxSize, double Asmth, int Nmesh, double G)
#define mymalloc2(name, size)
void delta_nu_from_power(struct _powerspectrum *PowerSpectrum, Cosmology *CP, const double Time, const double TimeIC)
void powerspectrum_nu_save(struct _powerspectrum *PowerSpectrum, const char *OutputDir, const char *filename, const double Time)
double particle_nu_fraction(const _hybrid_nu *const hybnu, const double a, const int i)
double get_omega_nu_nopart(const _omega_nu *const omnu, const double a)
struct part_manager_type PartManager[1]
void petapm_init(PetaPM *pm, double BoxSize, double Asmth, int Nmesh, double G, MPI_Comm comm)
void petapm_region_init_strides(PetaPMRegion *region)
void petapm_force(PetaPM *pm, petapm_prepare_func prepare, PetaPMGlobalFunctions *global_functions, PetaPMFunctions *functions, PetaPMParticleStruct *pstruct, void *userdata)
static double UnitLength_in_cm
void powerspectrum_save(Power *ps, const char *OutputDir, const char *filename, const double Time, const double D1)
void powerspectrum_free(Power *ps)
void powerspectrum_sum(Power *ps)
void powerspectrum_zero(Power *ps)
void powerspectrum_alloc(Power *ps, const int nbins, const int nthreads, const int MassiveNuLinResp, const double BoxSize_in_cm)
unsigned int DependsOnLocalMass
unsigned int InternalTopLevel
void(* global_analysis)(PetaPM *pm)
petapm_transfer_func global_readout
gsl_interp_accel * nu_acc
static const double tt[NEXACT]
#define walltime_measure(name)