MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
timestep.h
Go to the documentation of this file.
1 #ifndef TIMESTEP_H
2 #define TIMESTEP_H
3 
4 #include "utils/paramset.h"
5 #include "timebinmgr.h"
6 #include "timefac.h"
7 /*Flat array containing all active particles:
8 set in rebuild_activelist.*/
9 typedef struct ActiveParticles
10 {
15 
16 /* Structure to hold the kickfactors around the current position on the integer timeline*/
17 typedef struct
18 {
19  /*Minimum and maximum active and occupied timebins. Initially (but never again) zero*/
22  /* Kick times per bin*/
23  inttime_t Ti_kick[TIMEBINS+1];
24  /* Drift time when this timebin was last active*/
25  inttime_t Ti_lastactivedrift[TIMEBINS+1];
26  /* Current drift time, which is universal.*/
28  /* PM Timesteps*/
30  inttime_t PM_start; /* current start point of the PM step*/
31  inttime_t PM_kick; /* current inttime of PM Kick (velocity) */
33 
34 int rebuild_activelist(ActiveParticles * act, const DriftKickTimes * const times, int NumCurrentTiStep, const double Time);
36 double get_atime(const inttime_t Ti_Current);
37 
38 /* This function assigns new short-range timesteps to particles.
39  * It will also advance the PM timestep and set the new timestep length.
40  * Arguments:
41  * ActiveParticles: particles to assign new timesteps for.
42  * times: structure of kick times.
43  * atime: current scale factor.
44  * FastParticleType: particle type (generally neutrinos, 2) which has only long-range timestepping.
45  * Cosmology: to compute hubble scaling factors.
46  * asmth: size of PM smoothing cell in internal units. asmth = All.Asmth * PartManager->BoxSize / Nmesh
47  * isFirstTimeStep: Flags to do special things for BHs on first time step.
48  * Returns 0 if success, 1 if timestep is bad.*/
49 int find_timesteps(const ActiveParticles * act, DriftKickTimes * times, const double atime, int FastParticleType, const Cosmology * CP, const double asmth, const int isFirstTimeStep);
50 /* Apply half a kick to the particles: short-range and long-range.
51  * These functions sync drift and kick times.*/
52 void apply_half_kick(const ActiveParticles * act, Cosmology * CP, DriftKickTimes * times, const double atime, const double MinEgySpec);
54 
55 int is_timebin_active(int i, inttime_t current);
56 
57 inttime_t find_next_kick(inttime_t Ti_Current, int minTimeBin);
58 
59 inttime_t init_timebins(double TimeInit);
60 
61 /* Update the table of active bin drift times */
63 
65 
66 int is_PM_timestep(const DriftKickTimes * const times);
67 
69 
70 #endif
static Cosmology * CP
Definition: power.c:27
int * ActiveParticle
Definition: timestep.h:13
int64_t MaxActiveParticle
Definition: timestep.h:11
int64_t NumActiveParticle
Definition: timestep.h:12
inttime_t PM_kick
Definition: timestep.h:31
int maxtimebin
Definition: timestep.h:21
inttime_t PM_length
Definition: timestep.h:29
inttime_t Ti_Current
Definition: timestep.h:27
inttime_t PM_start
Definition: timestep.h:30
int mintimebin
Definition: timestep.h:20
#define TIMEBINS
Definition: timebinmgr.h:13
void apply_PM_half_kick(Cosmology *CP, DriftKickTimes *times)
Definition: timestep.c:373
int is_PM_timestep(const DriftKickTimes *const times)
Definition: timestep.c:160
void set_timestep_params(ParameterSet *ps)
Definition: timestep.c:51
double get_atime(const inttime_t Ti_Current)
Definition: timestep.c:168
DriftKickTimes init_driftkicktime(inttime_t Ti_Current)
Definition: timestep.c:133
inttime_t init_timebins(double TimeInit)
Definition: timestep.c:123
int find_timesteps(const ActiveParticles *act, DriftKickTimes *times, const double atime, int FastParticleType, const Cosmology *CP, const double asmth, const int isFirstTimeStep)
Definition: timestep.c:176
int rebuild_activelist(ActiveParticles *act, const DriftKickTimes *const times, int NumCurrentTiStep, const double Time)
Definition: timestep.c:721
int is_timebin_active(int i, inttime_t current)
Definition: timestep.c:149
void apply_half_kick(const ActiveParticles *act, Cosmology *CP, DriftKickTimes *times, const double atime, const double MinEgySpec)
Definition: timestep.c:323
struct ActiveParticles ActiveParticles
inttime_t find_next_kick(inttime_t Ti_Current, int minTimeBin)
Definition: timestep.c:712
void update_lastactive_drift(DriftKickTimes *times)
Definition: timestep.c:309
void free_activelist(ActiveParticles *act)
Definition: timestep.c:795
int32_t inttime_t
Definition: types.h:8