41 time_step = cfg.
require(
"time_step", 0.0);
53 template<
class T,
class Gravitation>
56 const static int nbod = T::n;
61 ensemble::SystemRef&
sys;
62 Gravitation& calcForces;
67 bool body_component_grid;
68 bool first_thread_in_system;
74 :_params(p),
sys(s),calcForces(calc){}
79 if( is_in_body_component_grid() )
80 pos =
sys[b][c].pos() , vel =
sys[b][c].vel();
81 calcForces(ij,b,c,pos,vel,acc0,jerk0);
84 GPUAPI
void shutdown() { }
88 GPUAPI
void convert_std_to_internal_coord() {}
90 static GENERIC int thread_per_system(){
94 static GENERIC int shmem_per_system() {
98 __device__
bool is_in_body_component_grid()
99 {
return ((b < nbod) && (c < 3)); }
101 __device__
bool is_in_body_component_grid_no_star()
102 {
return ( (b!=0) && (b < nbod) && (c < 3) ); }
104 __device__
bool is_first_thread_in_system()
109 double h = min(_params.time_step, max_timestep);
110 double pos = 0.0, vel = 0.0;
111 double acc = 0.0, jerk = 0.0;
112 const double third = 1.0/3.0;
114 if( is_in_body_component_grid() )
115 pos =
sys[b][c].pos() , vel =
sys[b][c].vel();
119 pos = pos + h*(vel+(h*0.5)*(acc0+(h/3.0)*jerk0));
120 vel = vel + h*(acc0+(h*0.5)*jerk0);
122 double pre_pos = pos, pre_vel = vel;
126 for(
int i = 0; i < 2 ; i++){
128 calcForces(ij,b,c,pos,vel,acc1,jerk1);
131 pos = pre_pos + ( (0.1-0.25) * (acc0 - acc1) - 1.0/60.0 * ( 7.0 * jerk0 + 2.0 * jerk1 ) * h) * h * h;
132 vel = pre_vel + (( -0.5 ) * (acc0 - acc1 ) - 1.0/12.0 * ( 5.0 * jerk0 + jerk1 ) * h )* h ;
134 acc0 = acc1, jerk0 = jerk1;
138 if( is_in_body_component_grid() )
139 sys[b][c].pos() = pos ,
sys[b][c].vel() = vel;
140 if( is_first_thread_in_system() )