MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Classes | Enumerations | Functions
gravity.h File Reference
#include "forcetree.h"
#include "petapm.h"
#include "powerspectrum.h"
#include "timestep.h"
Include dependency graph for gravity.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  gravshort_tree_params
 

Enumerations

enum  ShortRangeForceWindowType { SHORTRANGE_FORCE_WINDOW_TYPE_EXACT = 0 , SHORTRANGE_FORCE_WINDOW_TYPE_ERFC = 1 }
 

Functions

void gravshort_fill_ntab (const enum ShortRangeForceWindowType ShortRangeForceWindowType, const double Asmth)
 
void gravshort_set_softenings (double MeanDMSeparation)
 
double FORCE_SOFTENING (int i, int type)
 
void gravpm_init_periodic (PetaPM *pm, double BoxSize, double Asmth, int Nmesh, double G)
 
int grav_apply_short_range_window (double r, double *fac, double *pot, const double cellsize)
 
void set_gravshort_tree_params (ParameterSet *ps)
 
void set_gravshort_treepar (struct gravshort_tree_params tree_params)
 
struct gravshort_tree_params get_gravshort_treepar (void)
 
void gravpm_force (PetaPM *pm, ForceTree *tree, Cosmology *CP, double Time, double UnitLength_in_cm, const char *PowerOutputDir, double TimeIC, int FastParticleType)
 
void grav_short_pair (const ActiveParticles *act, PetaPM *pm, ForceTree *tree, double Rcut, double rho0, int NeutrinoTracer, int FastParticleType)
 
void grav_short_tree (const ActiveParticles *act, PetaPM *pm, ForceTree *tree, double rho0, int NeutrinoTracer, int FastParticleType)
 
void measure_power_spectrum (PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
 
void powerspectrum_add_mode (Power *PowerSpectrum, const int64_t k2, const int kpos[3], pfft_complex *const value, const double invwindow, double Nmesh)
 

Enumeration Type Documentation

◆ ShortRangeForceWindowType

Enumerator
SHORTRANGE_FORCE_WINDOW_TYPE_EXACT 
SHORTRANGE_FORCE_WINDOW_TYPE_ERFC 

Definition at line 23 of file gravity.h.

23  {
26 };
@ SHORTRANGE_FORCE_WINDOW_TYPE_ERFC
Definition: gravity.h:25
@ SHORTRANGE_FORCE_WINDOW_TYPE_EXACT
Definition: gravity.h:24

Function Documentation

◆ FORCE_SOFTENING()

double FORCE_SOFTENING ( int  i,
int  type 
)

Definition at line 36 of file gravshort-tree.c.

37 {
38  if (TreeParams.AdaptiveSoftening == 1 && type == 0) {
39  return P[i].Hsml;
40  }
41  /* Force is Newtonian beyond this.*/
42  return 2.8 * GravitySoftening;
43 }
static struct gravshort_tree_params TreeParams
double GravitySoftening
#define P
Definition: partmanager.h:88

References gravshort_tree_params::AdaptiveSoftening, GravitySoftening, P, and TreeParams.

Referenced by blackhole_accretion_ngbiter(), density(), force_treeev_shortrange(), get_timestep_dloga(), grav_force(), grav_short_copy(), grav_short_pair_ngbiter(), and grav_short_postprocess().

Here is the caller graph for this function:

◆ get_gravshort_treepar()

struct gravshort_tree_params get_gravshort_treepar ( void  )

Definition at line 55 of file gravshort-tree.c.

61 {
62  return TreeParams;
63 }

References TreeParams.

Referenced by run(), and run_gravity_test().

Here is the caller graph for this function:

◆ grav_apply_short_range_window()

int grav_apply_short_range_window ( double  r,
double *  fac,
double *  pot,
const double  cellsize 
)

Definition at line 55 of file gravity.c.

56 {
57  const double dx = shortrange_force_kernels[1][0];
58  double i = (r / cellsize / dx);
59  size_t tabindex = floor(i);
60  if(tabindex >= NTAB - 1)
61  return 1;
62  /* use a linear interpolation; */
63  *fac *= (tabindex + 1 - i) * shortrange_table[tabindex] + (i - tabindex) * shortrange_table[tabindex + 1];
64  *pot *= (tabindex + 1 - i) * shortrange_table_potential[tabindex] + (i - tabindex) * shortrange_table_potential[tabindex];
65  return 0;
66 }
#define NTAB
Definition: gravity.c:17
static float shortrange_table[NTAB]
Definition: gravity.c:20
static float shortrange_table_potential[NTAB]
Definition: gravity.c:20
const double shortrange_force_kernels[][5]

References NTAB, shortrange_force_kernels, shortrange_table, and shortrange_table_potential.

Referenced by apply_accn_to_output(), and grav_short_pair_ngbiter().

Here is the caller graph for this function:

◆ grav_short_pair()

void grav_short_pair ( const ActiveParticles act,
PetaPM pm,
ForceTree tree,
double  Rcut,
double  rho0,
int  NeutrinoTracer,
int  FastParticleType 
)

Definition at line 24 of file gravshort-pair.c.

25 {
26  TreeWalk tw[1] = {{0}};
27 
28  struct GravShortPriv priv;
29  priv.cellsize = tree->BoxSize / pm->Nmesh;
30  priv.Rcut = Rcut * pm->Asmth * priv.cellsize;
31  priv.FastParticleType = FastParticleType;
32  priv.NeutrinoTracer = NeutrinoTracer;
33  priv.G = pm->G;
34  priv.cbrtrho0 = pow(rho0, 1.0 / 3);
35 
36  message(0, "Starting pair-wise short range gravity...\n");
37 
38  tw->ev_label = "GRAV_SHORT";
42 
43  tw->haswork = NULL;
49  tw->tree = tree;
50  tw->priv = &priv;
51 
52  walltime_measure("/Misc");
53 
55 
56  walltime_measure("/Tree/Pairwise");
57 }
void message(int where, const char *fmt,...)
Definition: endrun.c:175
static void grav_short_pair_ngbiter(TreeWalkQueryGravShort *I, TreeWalkResultGravShort *O, TreeWalkNgbIterGravShort *iter, LocalTreeWalk *lv)
static void grav_short_copy(int place, TreeWalkQueryGravShort *input, TreeWalk *tw)
Definition: gravshort.h:74
static void grav_short_reduce(int place, TreeWalkResultGravShort *result, enum TreeWalkReduceMode mode, TreeWalk *tw)
Definition: gravshort.h:89
static void grav_short_postprocess(int i, TreeWalk *tw)
Definition: gravshort.h:58
int * ActiveParticle
Definition: timestep.h:13
int64_t NumActiveParticle
Definition: timestep.h:12
double BoxSize
Definition: forcetree.h:106
int FastParticleType
Definition: gravshort.h:41
int NeutrinoTracer
Definition: gravshort.h:43
double cellsize
Definition: gravshort.h:28
double Rcut
Definition: gravshort.h:31
int Nmesh
Definition: petapm.h:68
double G
Definition: petapm.h:71
double Asmth
Definition: petapm.h:69
void * priv
Definition: treewalk.h:85
TreeWalkHasWorkFunction haswork
Definition: treewalk.h:100
size_t ngbiter_type_elsize
Definition: treewalk.h:97
const ForceTree * tree
Definition: treewalk.h:88
TreeWalkProcessFunction postprocess
Definition: treewalk.h:104
TreeWalkNgbIterFunction ngbiter
Definition: treewalk.h:103
TreeWalkReduceResultFunction reduce
Definition: treewalk.h:102
const char * ev_label
Definition: treewalk.h:91
TreeWalkVisitFunction visit
Definition: treewalk.h:99
size_t result_type_elsize
Definition: treewalk.h:96
TreeWalkFillQueryFunction fill
Definition: treewalk.h:101
size_t query_type_elsize
Definition: treewalk.h:95
int treewalk_visit_ngbiter(TreeWalkQueryBase *I, TreeWalkResultBase *O, LocalTreeWalk *lv)
Definition: treewalk.c:924
void treewalk_run(TreeWalk *tw, int *active_set, size_t size)
Definition: treewalk.c:619
int(* TreeWalkVisitFunction)(TreeWalkQueryBase *input, TreeWalkResultBase *output, LocalTreeWalk *lv)
Definition: treewalk.h:68
void(* TreeWalkReduceResultFunction)(const int j, TreeWalkResultBase *result, const enum TreeWalkReduceMode mode, TreeWalk *tw)
Definition: treewalk.h:76
void(* TreeWalkProcessFunction)(const int i, TreeWalk *tw)
Definition: treewalk.h:73
void(* TreeWalkNgbIterFunction)(TreeWalkQueryBase *input, TreeWalkResultBase *output, TreeWalkNgbIterBase *iter, LocalTreeWalk *lv)
Definition: treewalk.h:70
void(* TreeWalkFillQueryFunction)(const int j, TreeWalkQueryBase *query, TreeWalk *tw)
Definition: treewalk.h:75
#define walltime_measure(name)
Definition: walltime.h:8

References ActiveParticles::ActiveParticle, PetaPM::Asmth, ForceTree::BoxSize, GravShortPriv::cbrtrho0, GravShortPriv::cellsize, TreeWalk::ev_label, GravShortPriv::FastParticleType, TreeWalk::fill, GravShortPriv::G, PetaPM::G, grav_short_copy(), grav_short_pair_ngbiter(), grav_short_postprocess(), grav_short_reduce(), TreeWalk::haswork, message(), GravShortPriv::NeutrinoTracer, TreeWalk::ngbiter, TreeWalk::ngbiter_type_elsize, PetaPM::Nmesh, ActiveParticles::NumActiveParticle, TreeWalk::postprocess, TreeWalk::priv, TreeWalk::query_type_elsize, GravShortPriv::Rcut, TreeWalk::reduce, TreeWalk::result_type_elsize, TreeWalk::tree, treewalk_run(), treewalk_visit_ngbiter(), TreeWalk::visit, and walltime_measure.

Referenced by run(), and run_gravity_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grav_short_tree()

void grav_short_tree ( const ActiveParticles act,
PetaPM pm,
ForceTree tree,
double  rho0,
int  NeutrinoTracer,
int  FastParticleType 
)

This function computes the gravitational forces for all active particles. If needed, a new tree is constructed, otherwise the dynamically updated tree is used. Particles are only exported to other processors when really needed, thereby allowing a good use of the communication buffer. NeutrinoTracer = All.HybridNeutrinosOn && (atime <= All.HybridNuPartTime); rho0 = CP.Omega0 * 3 * CP.Hubble * CP.Hubble / (8 * M_PI * G)

Definition at line 105 of file gravshort-tree.c.

106 {
107  double timeall = 0;
108  double timetree, timewait, timecomm;
109 
110  TreeWalk tw[1] = {{0}};
111  struct GravShortPriv priv;
112  priv.cellsize = tree->BoxSize / pm->Nmesh;
113  priv.Rcut = TreeParams.Rcut * pm->Asmth * priv.cellsize;;
114  priv.ErrTolForceAcc = TreeParams.ErrTolForceAcc;
115  priv.TreeUseBH = TreeParams.TreeUseBH;
116  priv.BHOpeningAngle = TreeParams.BHOpeningAngle;
117  priv.FastParticleType = FastParticleType;
118  priv.NeutrinoTracer = NeutrinoTracer;
119  priv.G = pm->G;
120  priv.cbrtrho0 = pow(rho0, 1.0 / 3);
121 
122  if(!tree->moments_computed_flag)
123  endrun(2, "Gravtree called before tree moments computed!\n");
124 
125  tw->ev_label = "GRAVTREE";
127  /* gravity applies to all particles. Including Tracer particles to enhance numerical stability. */
128  tw->haswork = NULL;
131 
135  tw->tree = tree;
136  tw->priv = &priv;
137 
138  walltime_measure("/Misc");
139 
140  /* allocate buffers to arrange communication */
141  MPIU_Barrier(MPI_COMM_WORLD);
142  message(0, "Begin tree force. (presently allocated=%g MB)\n", mymalloc_usedbytes() / (1024.0 * 1024.0));
143 
144  walltime_measure("/Misc");
145 
147 
148  /* Now the force computation is finished */
149  /* gather some diagnostic information */
150 
151  timetree = tw->timecomp1 + tw->timecomp2 + tw->timecomp3;
152  timewait = tw->timewait1 + tw->timewait2;
153  timecomm= tw->timecommsumm1 + tw->timecommsumm2;
154 
155  walltime_add("/Tree/Walk1", tw->timecomp1);
156  walltime_add("/Tree/Walk2", tw->timecomp2);
157  walltime_add("/Tree/PostProcess", tw->timecomp3);
158  walltime_add("/Tree/Send", tw->timecommsumm1);
159  walltime_add("/Tree/Recv", tw->timecommsumm2);
160  walltime_add("/Tree/Wait1", tw->timewait1);
161  walltime_add("/Tree/Wait2", tw->timewait2);
162 
164 
165  walltime_add("/Tree/Misc", timeall - (timetree + timewait + timecomm));
166 
167  /* TreeUseBH > 1 means use the BH criterion on the initial timestep only,
168  * avoiding the fully open O(N^2) case.*/
169  if(TreeParams.TreeUseBH > 1)
170  TreeParams.TreeUseBH = 0;
171 }
void endrun(int where, const char *fmt,...)
Definition: endrun.c:147
int force_treeev_shortrange(TreeWalkQueryGravShort *input, TreeWalkResultGravShort *output, LocalTreeWalk *lv)
#define mymalloc_usedbytes()
Definition: mymalloc.h:32
int moments_computed_flag
Definition: forcetree.h:82
double timecomp2
Definition: treewalk.h:124
double timecomp3
Definition: treewalk.h:125
double timecommsumm1
Definition: treewalk.h:126
double timewait2
Definition: treewalk.h:122
double timecomp1
Definition: treewalk.h:123
double timewait1
Definition: treewalk.h:121
double timecommsumm2
Definition: treewalk.h:127
double BHOpeningAngle
Definition: gravity.h:12
double ErrTolForceAcc
Definition: gravity.h:11
#define MPIU_Barrier(comm)
Definition: system.h:103
#define WALLTIME_IGNORE
Definition: walltime.h:6
#define walltime_add(name, dt)
Definition: walltime.h:9

References ActiveParticles::ActiveParticle, PetaPM::Asmth, gravshort_tree_params::BHOpeningAngle, GravShortPriv::BHOpeningAngle, ForceTree::BoxSize, GravShortPriv::cbrtrho0, GravShortPriv::cellsize, endrun(), gravshort_tree_params::ErrTolForceAcc, GravShortPriv::ErrTolForceAcc, TreeWalk::ev_label, GravShortPriv::FastParticleType, TreeWalk::fill, force_treeev_shortrange(), GravShortPriv::G, PetaPM::G, grav_short_copy(), grav_short_postprocess(), grav_short_reduce(), TreeWalk::haswork, message(), ForceTree::moments_computed_flag, MPIU_Barrier, mymalloc_usedbytes, GravShortPriv::NeutrinoTracer, PetaPM::Nmesh, ActiveParticles::NumActiveParticle, TreeWalk::postprocess, TreeWalk::priv, TreeWalk::query_type_elsize, gravshort_tree_params::Rcut, GravShortPriv::Rcut, TreeWalk::reduce, TreeWalk::result_type_elsize, TreeWalk::timecommsumm1, TreeWalk::timecommsumm2, TreeWalk::timecomp1, TreeWalk::timecomp2, TreeWalk::timecomp3, TreeWalk::timewait1, TreeWalk::timewait2, TreeWalk::tree, TreeParams, gravshort_tree_params::TreeUseBH, GravShortPriv::TreeUseBH, treewalk_run(), TreeWalk::visit, walltime_add, WALLTIME_IGNORE, and walltime_measure.

Referenced by do_force_test(), run(), and run_gravity_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gravpm_force()

void gravpm_force ( PetaPM pm,
ForceTree tree,
Cosmology CP,
double  Time,
double  UnitLength_in_cm,
const char *  PowerOutputDir,
double  TimeIC,
int  FastParticleType 
)

Definition at line 62 of file gravpm.c.

62  {
63  PetaPMParticleStruct pstruct = {
64  P,
65  sizeof(P[0]),
66  (char*) &P[0].Pos[0] - (char*) P,
67  (char*) &P[0].Mass - (char*) P,
68  /* Regions allocated inside _prepare*/
69  NULL,
70  /* By default all particles are active. For hybrid neutrinos set below.*/
71  NULL,
73  };
74 
76 
77  /*Initialise the kspace neutrino code if it is enabled.
78  * Mpc units are used to match power spectrum code.*/
79  if(CP->MassiveNuLinRespOn) {
82  }
83 
84  if(CP->HybridNeutrinosOn && particle_nu_fraction(&(CP->ONu.hybnu), Time, 0) == 0.)
86 
87  int i;
88  #pragma omp parallel for
89  for(i = 0; i < PartManager->NumPart; i++)
90  {
91  P[i].GravPM[0] = P[i].GravPM[1] = P[i].GravPM[2] = 0;
92  }
93 
94  /* Set up parameters*/
95  GravPM.Time = Time;
96  GravPM.TimeIC = TimeIC;
97  GravPM.CP = CP;
98  GravPM.FastParticleType = FastParticleType;
100  /*
101  * we apply potential transfer immediately after the R2C transform,
102  * Therefore the force transfer functions are based on the potential,
103  * not the density.
104  * */
105  petapm_force(pm, _prepare, &global_functions, functions, &pstruct, tree);
106  powerspectrum_sum(pm->ps);
107  /*Now save the power spectrum*/
108  powerspectrum_save(pm->ps, PowerOutputDir, "powerspectrum", Time, GrowthFactor(CP, Time, 1.0));
109  /* Save the neutrino power if it is allocated*/
110  if(pm->ps->logknu)
111  powerspectrum_nu_save(pm->ps, PowerOutputDir, "powerspectrum-nu", Time);
112  /*We are done with the power spectrum, free it*/
113  powerspectrum_free(pm->ps);
114  walltime_measure("/LongRange");
115 }
double GrowthFactor(Cosmology *CP, double astart, double aend)
Definition: cosmology.c:82
static PetaPMGlobalFunctions global_functions
Definition: glass.c:33
static void compute_neutrino_power(PetaPM *pm)
Definition: gravpm.c:304
static int hybrid_nu_gravpm_is_active(int i)
Definition: gravpm.c:465
static PetaPMRegion * _prepare(PetaPM *pm, PetaPMParticleStruct *pstruct, void *userdata, int *Nregions)
Definition: gravpm.c:117
static void potential_transfer(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
Definition: gravpm.c:380
static struct gravpm_params GravPM
void measure_power_spectrum(PetaPM *pm, int64_t k2, int kpos[3], pfft_complex *value)
Definition: gravpm.c:361
static PetaPMFunctions functions[]
Definition: gravpm.c:32
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)
struct part_manager_type PartManager[1]
Definition: partmanager.c:11
void petapm_force(PetaPM *pm, petapm_prepare_func prepare, PetaPMGlobalFunctions *global_functions, PetaPMFunctions *functions, PetaPMParticleStruct *pstruct, void *userdata)
Definition: petapm.c:353
static Cosmology * CP
Definition: power.c:27
static double UnitLength_in_cm
Definition: power.c:26
void powerspectrum_save(Power *ps, const char *OutputDir, const char *filename, const double Time, const double D1)
Definition: powerspectrum.c:92
void powerspectrum_free(Power *ps)
Definition: powerspectrum.c:44
void powerspectrum_sum(Power *ps)
Definition: powerspectrum.c:54
int HybridNeutrinosOn
Definition: cosmology.h:28
int MassiveNuLinRespOn
Definition: cosmology.h:26
_omega_nu ONu
Definition: cosmology.h:24
void(* global_analysis)(PetaPM *pm)
Definition: petapm.h:103
petapm_transfer_func global_readout
Definition: petapm.h:102
int(* active)(int i)
Definition: petapm.h:85
Power ps[1]
Definition: petapm.h:76
_hybrid_nu hybnu
double * logknu
Definition: powerspectrum.h:20
double TimeIC
Definition: gravpm.c:46
double UnitLength_in_cm
Definition: gravpm.c:49
int FastParticleType
Definition: gravpm.c:48
Cosmology * CP
Definition: gravpm.c:47
double Time
Definition: gravpm.c:45

References _prepare(), PetaPMParticleStruct::active, compute_neutrino_power(), gravpm_params::CP, CP, gravpm_params::FastParticleType, functions, PetaPMGlobalFunctions::global_analysis, global_functions, PetaPMGlobalFunctions::global_readout, GravPM, GrowthFactor(), _omega_nu::hybnu, hybrid_nu_gravpm_is_active(), Cosmology::HybridNeutrinosOn, _powerspectrum::logknu, Cosmology::MassiveNuLinRespOn, measure_power_spectrum(), part_manager_type::NumPart, Cosmology::ONu, P, particle_nu_fraction(), PartManager, petapm_force(), potential_transfer(), powerspectrum_free(), powerspectrum_nu_save(), powerspectrum_save(), powerspectrum_sum(), PetaPM::ps, gravpm_params::Time, gravpm_params::TimeIC, gravpm_params::UnitLength_in_cm, UnitLength_in_cm, and walltime_measure.

Referenced by do_force_test(), run(), run_gravity_test(), and runpower().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gravpm_init_periodic()

void gravpm_init_periodic ( PetaPM pm,
double  BoxSize,
double  Asmth,
int  Nmesh,
double  G 
)

Definition at line 53 of file gravpm.c.

53  {
54  petapm_init(pm, BoxSize, Asmth, Nmesh, G, MPI_COMM_WORLD);
55 }
void petapm_init(PetaPM *pm, double BoxSize, double Asmth, int Nmesh, double G, MPI_Comm comm)
Definition: petapm.c:94
static const double G
Definition: test_gravity.c:35

References G, and petapm_init().

Referenced by do_force_test(), run(), run_gravity_test(), runfof(), and runpower().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gravshort_fill_ntab()

void gravshort_fill_ntab ( const enum ShortRangeForceWindowType  ShortRangeForceWindowType,
const double  Asmth 
)

Definition at line 23 of file gravity.c.

24 {
26  if(Asmth != 1.5) {
27  endrun(0, "The short range force window is calibrated for Asmth = 1.5, but running with %g\n", Asmth);
28  }
29  }
30 
31  size_t i;
32  for(i = 0; i < NTAB; i++)
33  {
34  /* force_kernels is in units of mesh points; */
35  double u = shortrange_force_kernels[i][0] * 0.5 / Asmth;
36  switch (ShortRangeForceWindowType) {
38  /* Notice that the table is only calibrated for smth of 1.25*/
39  shortrange_table[i] = shortrange_force_kernels[i][2]; /* ~ erfc(u) + 2.0 * u / sqrt(M_PI) * exp(-u * u); */
40  /* The potential of the calibrated kernel is a bit off, so we still use erfc here; we do not use potential anyways.*/
42  break;
44  shortrange_table[i] = erfc(u) + 2.0 * u / sqrt(M_PI) * exp(-u * u);
45  shortrange_table_potential[i] = erfc(u);
46  break;
47  }
48  /* we don't have a table for that and don't use it anyways. */
49  shortrange_table_tidal[i] = 4.0 * u * u * u / sqrt(M_PI) * exp(-u * u);
50  }
51 }
static float shortrange_table_tidal[NTAB]
Definition: gravity.c:20
ShortRangeForceWindowType
Definition: gravity.h:23

References endrun(), NTAB, shortrange_force_kernels, SHORTRANGE_FORCE_WINDOW_TYPE_ERFC, SHORTRANGE_FORCE_WINDOW_TYPE_EXACT, shortrange_table, shortrange_table_potential, and shortrange_table_tidal.

Referenced by begrun(), and do_force_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gravshort_set_softenings()

void gravshort_set_softenings ( double  MeanSeparation)

Sets the (comoving) softening length, converting from units of the mean DM separation to comoving internal units.

Sets the (comoving) softening length, converting from units of the mean separation to comoving internal units.

Definition at line 47 of file gravshort-tree.c.

48 {
50  /* 0: Gas is collisional */
51  message(0, "GravitySoftening = %g\n", GravitySoftening);
52 }
double FractionalGravitySoftening
Definition: gravity.h:18

References gravshort_tree_params::FractionalGravitySoftening, GravitySoftening, message(), and TreeParams.

Referenced by do_force_test(), init(), and setup_density().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ measure_power_spectrum()

void measure_power_spectrum ( PetaPM pm,
int64_t  k2,
int  kpos[3],
pfft_complex *  value 
)

Definition at line 361 of file gravpm.c.

361  {
362  double f = 1.0;
363  /* the CIC deconvolution kernel is
364  *
365  * sinc_unnormed(k_x L / 2 Nmesh) ** 2
366  *
367  * k_x = kpos * 2pi / L
368  *
369  * */
370  int k;
371  for(k = 0; k < 3; k ++) {
372  double tmp = (kpos[k] * M_PI) / pm->Nmesh;
373  tmp = sinc_unnormed(tmp);
374  f *= 1. / (tmp * tmp);
375  }
376  powerspectrum_add_mode(pm->ps, k2, kpos, value, f, pm->Nmesh);
377 }
void powerspectrum_add_mode(Power *PowerSpectrum, const int64_t k2, const int kpos[3], pfft_complex *const value, const double invwindow, double Nmesh)
Definition: gravpm.c:327
static double sinc_unnormed(double x)
Definition: gravpm.c:291

References NODE::f, PetaPM::Nmesh, powerspectrum_add_mode(), PetaPM::ps, and sinc_unnormed().

Referenced by gravpm_force().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ powerspectrum_add_mode()

void powerspectrum_add_mode ( Power PowerSpectrum,
const int64_t  k2,
const int  kpos[3],
pfft_complex *const  value,
const double  invwindow,
double  Nmesh 
)

Definition at line 327 of file gravpm.c.

328 {
329  if(k2 == 0) {
330  /* Save zero mode corresponding to the mean as the normalisation factor.*/
331  PowerSpectrum->Norm = (value[0][0] * value[0][0] + value[0][1] * value[0][1]);
332  return;
333  }
334  /* Measure power spectrum: we don't want the zero mode.
335  * Some modes with k_z = 0 or N/2 have weight 1, the rest have weight 2.
336  * This is because of the symmetry of the real fft. */
337  if(k2 > 0) {
338  /*How many bins per unit (log) interval in k?*/
339  const double binsperunit=(PowerSpectrum->size-1)/log(sqrt(3) * Nmesh/2.0);
340  int kint=floor(binsperunit*log(k2)/2.);
341  int w;
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]);
344  /*Make sure we do not overflow (although this should never happen)*/
345  if(kint >= PowerSpectrum->size)
346  return;
347  if(kpos[2] == 0 || kpos[2] == Nmesh/2) w = 1;
348  else w = 2;
349  /*Make sure we use thread-local memory to avoid racing.*/
350  const int index = kint + omp_get_thread_num() * PowerSpectrum->size;
351  /*Multiply P(k) by inverse window function*/
352  PowerSpectrum->Power[index] += w * m * invwindow * invwindow;
353  PowerSpectrum->Nmodes[index] += w;
354  PowerSpectrum->kk[index] += w * keff;
355  }
356 
357 }
double * Power
Definition: powerspectrum.h:10
int64_t * Nmodes
Definition: powerspectrum.h:11

References _powerspectrum::kk, _powerspectrum::Nmodes, _powerspectrum::Norm, _powerspectrum::Power, and _powerspectrum::size.

Referenced by measure_power_spectrum(), and potential_transfer().

Here is the caller graph for this function:

◆ set_gravshort_tree_params()

void set_gravshort_tree_params ( ParameterSet ps)

Definition at line 67 of file gravshort-tree.c.

68 {
69  int ThisTask;
70  MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
71  if(ThisTask == 0) {
72  TreeParams.BHOpeningAngle = param_get_double(ps, "BHOpeningAngle");
73  TreeParams.ErrTolForceAcc = param_get_double(ps, "ErrTolForceAcc");
74  TreeParams.BHOpeningAngle = param_get_double(ps, "BHOpeningAngle");
75  TreeParams.TreeUseBH= param_get_int(ps, "TreeUseBH");
76  TreeParams.Rcut = param_get_double(ps, "TreeRcut");
77  TreeParams.FractionalGravitySoftening = param_get_double(ps, "GravitySoftening");
78  TreeParams.AdaptiveSoftening = !param_get_int(ps, "GravitySofteningGas");
79 
80 
81  }
82  MPI_Bcast(&TreeParams, sizeof(struct gravshort_tree_params), MPI_BYTE, 0, MPI_COMM_WORLD);
83 }
double param_get_double(ParameterSet *ps, const char *name)
Definition: paramset.c:336
int param_get_int(ParameterSet *ps, const char *name)
Definition: paramset.c:368
int ThisTask
Definition: test_exchange.c:23

References gravshort_tree_params::AdaptiveSoftening, gravshort_tree_params::BHOpeningAngle, gravshort_tree_params::ErrTolForceAcc, gravshort_tree_params::FractionalGravitySoftening, param_get_double(), param_get_int(), gravshort_tree_params::Rcut, ThisTask, TreeParams, and gravshort_tree_params::TreeUseBH.

Referenced by read_parameter_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_gravshort_treepar()

void set_gravshort_treepar ( struct gravshort_tree_params  tree_params)

Definition at line 55 of file gravshort-tree.c.

56 {
57  TreeParams = tree_params;
58 }

Referenced by do_force_test(), run_gravity_test(), and setup_density().

Here is the caller graph for this function: