diff --git a/examples/plot_gravity_checks.py b/examples/plot_gravity_checks.py index ac6d1699b79e45540d6ae67ccf4f805d291918d6..ca4e17c7c8a012c6e5aa33ecc585e7ad35a46e27 100644 --- a/examples/plot_gravity_checks.py +++ b/examples/plot_gravity_checks.py @@ -81,7 +81,10 @@ plt.figure() count = 0 # Get the Gadget-2 data if existing -gadget2_file_list = glob.glob("forcetest_gadget2.txt") +if periodic: + gadget2_file_list = glob.glob("forcetest_gadget2_periodic.txt") +else: + gadget2_file_list = glob.glob("forcetest_gadget2.txt") if len(gadget2_file_list) != 0: gadget2_data = np.loadtxt(gadget2_file_list[0]) diff --git a/src/gravity.c b/src/gravity.c index 42cf1dc4bbd7924f8c1b6cbf772d869dc1e70cee..b21c104d066f522b4bc20004a664b6677abbffbb 100644 --- a/src/gravity.c +++ b/src/gravity.c @@ -145,9 +145,6 @@ void gravity_exact_force_ewald_init(double boxSize) { const float factor_cos = 2.f * M_PI; const float factor_pot = M_PI / alpha2; - /* Ewald factor to access the table */ - ewald_fac = (double)(2 * Newald) / boxSize; - /* Zero everything */ bzero(fewald_x, (Newald + 1) * (Newald + 1) * (Newald + 1) * sizeof(float)); bzero(fewald_y, (Newald + 1) * (Newald + 1) * (Newald + 1) * sizeof(float)); @@ -295,6 +292,9 @@ void gravity_exact_force_ewald_init(double boxSize) { clocks_from_ticks(getticks() - tic), clocks_getunit()); } + /* Ewald factor to access the table */ + ewald_fac = (double)(2 * Newald) / boxSize; + /* Apply the box-size correction */ for (int i = 0; i <= Newald; ++i) { for (int j = 0; j <= Newald; ++j) { @@ -508,7 +508,7 @@ void gravity_exact_force_compute_mapper(void *map_data, int nr_gparts, /* Interact it with all other particles in the space.*/ for (int j = 0; j < (int)s->nr_gparts; ++j) { - struct gpart *gpj = &s->gparts[j]; + const struct gpart *gpj = &s->gparts[j]; /* No self interaction */ if (gpi == gpj) continue;