Skip to content

Commit

Permalink
fixed conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Aug 22, 2024
1 parent d3ed159 commit 5f03d30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/whfast512_unittests/problem.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int test_synchronization_fallback(){

for (int i=0;i<r1->N;i++){
double dx = fabs(r1->particles[i].x - r2->particles[i].x);
double dvx = fabs(r1->particles[i].x - r2->particles[i].x);
double dvx = fabs(r1->particles[i].vx - r2->particles[i].vx);
if (dx>1e-16 || dvx>1e-16){
printf("Accuracy not met in synchronization fallback test.\n");
printf("i=%i diff_x=%.16e diff_vx=%.16e\n",i,dx, dvx);
Expand Down
26 changes: 9 additions & 17 deletions src/integrator_whfast512.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,20 +1070,13 @@ static void democraticheliocentric_to_inertial_posvel_fallback(struct reb_simula
const unsigned int p_per_system = 8/N_systems;
const unsigned int N_per_system = r->N/N_systems;

double m[8];
double x[8];
double y[8];
double z[8];
double vx[8];
double vy[8];
double vz[8];
memcpy(&m, &p_jh->m, sizeof(double)*8);
memcpy(&x, &p_jh->x, sizeof(double)*8);
memcpy(&y, &p_jh->y, sizeof(double)*8);
memcpy(&z, &p_jh->z, sizeof(double)*8);
memcpy(&vx, &p_jh->vx, sizeof(double)*8);
memcpy(&vy, &p_jh->vy, sizeof(double)*8);
memcpy(&vz, &p_jh->vz, sizeof(double)*8);
double* m = p_jh->m;
double* x = p_jh->x;
double* y = p_jh->y;
double* z = p_jh->z;
double* vx = p_jh->vx;
double* vy = p_jh->vy;
double* vz = p_jh->vz;

for (unsigned s=0;s<N_systems;s++){
double x0s = 0;
Expand Down Expand Up @@ -1135,7 +1128,7 @@ void reb_integrator_whfast512_synchronize_fallback(struct reb_simulation* const
for (int s=0; s<N_systems; s++){
double m0 = r->particles[s*N_per_system].m;
// 1/2 Kepler
for (unsigned int i=1;i<=N_per_system;i++){
for (unsigned int i=1;i<N_per_system;i++){
struct reb_particle p = {0};
p.m = ri_whfast512->p_jh->m[s*p_per_system+i-1];
p.x = ri_whfast512->p_jh->x[s*p_per_system+i-1];
Expand All @@ -1144,7 +1137,6 @@ void reb_integrator_whfast512_synchronize_fallback(struct reb_simulation* const
p.vx = ri_whfast512->p_jh->vx[s*p_per_system+i-1];
p.vy = ri_whfast512->p_jh->vy[s*p_per_system+i-1];
p.vz = ri_whfast512->p_jh->vz[s*p_per_system+i-1];
p.sim = r;
reb_whfast_kepler_solver(r, &p, m0, 0, dt/2.0);
ri_whfast512->p_jh->x[s*p_per_system+i-1] = p.x;
ri_whfast512->p_jh->y[s*p_per_system+i-1] = p.y;
Expand All @@ -1154,7 +1146,7 @@ void reb_integrator_whfast512_synchronize_fallback(struct reb_simulation* const
ri_whfast512->p_jh->vz[s*p_per_system+i-1] = p.vz;
}
}
reb_whfast512_com_step(r, dt/2.0); // does extra work if N_systems>1, but not important.
reb_whfast512_com_step(r, dt/2.0); // does not use AVX512
democraticheliocentric_to_inertial_posvel_fallback(r);
ri_whfast512->is_synchronized = 1;
}
Expand Down

0 comments on commit 5f03d30

Please sign in to comment.