MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
gravshort.h
Go to the documentation of this file.
1 #ifndef GRAVSHORT_H
2 #define GRAVSHORT_H
3 
4 #include "partmanager.h"
5 #include "treewalk.h"
6 #include "gravity.h"
7 
8 typedef struct {
11 
12 typedef struct
13 {
15  /*Used for adaptive gravitational softening*/
19 
20 typedef struct {
22  MyFloat Acc[3];
25 
26 struct GravShortPriv {
27  /* Size of a PM cell, in internal units. Box / Nmesh */
28  double cellsize;
29  /* How many PM cells do we go
30  * before we stop calculating the tree?*/
31  double Rcut;
32  /* Desired accuracy of the tree force in units of the old acceleration.*/
34  /* If > 0, use the Barnes-Hut opening angle.
35  * If < 0, use the acceleration condition. */
36  int TreeUseBH;
37  /* Barnes-Hut opening angle to use.*/
39  /* Which particle type should we exclude from
40  * the tree calculation. */
42  /* Are neutrinos tracers? If so, exclude them from the tree force*/
44  /* Newton's constant in internal units*/
45  double G;
46  /* Matter density in internal units.
47  * rho_0 = Omega0 * rho_crit
48  * rho_crit = 3 H^2 /(8 pi G).
49  * This is (rho_0)^(1/3) ,
50  * Note: should account for
51  * massive neutrinos, but doesn't. */
52  double cbrtrho0;
53 };
54 
55 #define GRAV_GET_PRIV(tw) ((struct GravShortPriv *) ((tw)->priv))
56 
57 static void
59 {
60  double G = GRAV_GET_PRIV(tw)->G;
61  P[i].GravAccel[0] *= G;
62  P[i].GravAccel[1] *= G;
63  P[i].GravAccel[2] *= G;
64  /* calculate the potential */
65  /* remove self-potential */
66  P[i].Potential += P[i].Mass / (FORCE_SOFTENING(i, P[i].Type) / 2.8);
67 
68  P[i].Potential -= 2.8372975 * pow(P[i].Mass, 2.0 / 3) * GRAV_GET_PRIV(tw)->cbrtrho0;
69 
70  P[i].Potential *= G;
71 }
72 
73 static void
75 {
76  input->Soft = FORCE_SOFTENING(place, P[place].Type);
77  /*Compute old acceleration before we over-write things*/
78  double aold=0;
79  int i;
80  for(i = 0; i < 3; i++) {
81  double ax = P[place].GravAccel[i] + P[place].GravPM[i];
82  aold += ax*ax;
83  }
84 
85  input->OldAcc = sqrt(aold)/GRAV_GET_PRIV(tw)->G;
86 
87 }
88 static void
90 {
91  int k;
92  for(k = 0; k < 3; k++)
93  TREEWALK_REDUCE(P[place].GravAccel[k], result->Acc[k]);
94 
95  TREEWALK_REDUCE(P[place].Potential, result->Potential);
96 }
97 
98 #endif
double FORCE_SOFTENING(int i, int type)
#define GRAV_GET_PRIV(tw)
Definition: gravshort.h:55
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
#define P
Definition: partmanager.h:88
double G
Definition: gravshort.h:45
double ErrTolForceAcc
Definition: gravshort.h:33
int FastParticleType
Definition: gravshort.h:41
double BHOpeningAngle
Definition: gravshort.h:38
double cbrtrho0
Definition: gravshort.h:52
int NeutrinoTracer
Definition: gravshort.h:43
double cellsize
Definition: gravshort.h:28
double Rcut
Definition: gravshort.h:31
TreeWalkNgbIterBase base
Definition: gravshort.h:9
TreeWalkQueryBase base
Definition: gravshort.h:14
TreeWalkResultBase base
Definition: gravshort.h:21
static const double G
Definition: test_gravity.c:35
TreeWalkReduceMode
Definition: treewalk.h:15
#define TREEWALK_REDUCE(A, B)
Definition: treewalk.h:189
LOW_PRECISION MyFloat
Definition: types.h:19