Skip to content
Snippets Groups Projects
Commit 07df10c8 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Read in the new MAC parameters

parent 81d60151
Branches
Tags
1 merge request!1077Improved multipole acceptance criterion (MAC)
......@@ -62,20 +62,22 @@ Stars:
# Parameters for the self-gravity scheme
Gravity:
mesh_side_length: 128 # Number of cells along each axis for the periodic gravity mesh.
eta: 0.025 # Constant dimensionless multiplier for time integration.
theta: 0.7 # Opening angle (Multipole acceptance criterion).
comoving_DM_softening: 0.0026994 # Comoving Plummer-equivalent softening length for DM particles (in internal units).
max_physical_DM_softening: 0.0007 # Maximal Plummer-equivalent softening length in physical coordinates for DM particles (in internal units).
comoving_baryon_softening: 0.0026994 # Comoving Plummer-equivalent softening length for baryon particles (in internal units).
max_physical_baryon_softening: 0.0007 # Maximal Plummer-equivalent softening length in physical coordinates for baryon particles (in internal units).
softening_ratio_background: 0.04 # Fraction of the mean inter-particle separation to use as Plummer-equivalent softening for the background DM particles.
rebuild_frequency: 0.01 # (Optional) Frequency of the gravity-tree rebuild in units of the number of g-particles (this is the default value).
a_smooth: 1.25 # (Optional) Smoothing scale in top-level cell sizes to smooth the long-range forces over (this is the default value).
r_cut_max: 4.5 # (Optional) Cut-off in number of top-level cells beyond which no FMM forces are computed (this is the default value).
r_cut_min: 0.1 # (Optional) Cut-off in number of top-level cells below which no truncation of FMM forces are performed (this is the default value).
dithering: 1 # (Optional) Activate the dithering of the gravity mesh at every rebuild (this is the default value).
dithering_ratio: 1.0 # (Optional) Magnitude of each component of the dithering vector in units of the top-level cell sizes (this is the default value).
mesh_side_length: 128 # Number of cells along each axis for the periodic gravity mesh.
eta: 0.025 # Constant dimensionless multiplier for time integration.
mulitpole_acceptance_criterion: adaptive # Choice of mulitpole acceptance criterion: 'adaptive' OR 'geometric'.
epsilon_fmm: 0.01 # Tolerance parameter for the adaptice multipole acceptance criterion.
theta_cr: 0.7 # Opening angle for the purely gemoetric criterion.
comoving_DM_softening: 0.0026994 # Comoving Plummer-equivalent softening length for DM particles (in internal units).
max_physical_DM_softening: 0.0007 # Maximal Plummer-equivalent softening length in physical coordinates for DM particles (in internal units).
comoving_baryon_softening: 0.0026994 # Comoving Plummer-equivalent softening length for baryon particles (in internal units).
max_physical_baryon_softening: 0.0007 # Maximal Plummer-equivalent softening length in physical coordinates for baryon particles (in internal units).
softening_ratio_background: 0.04 # Fraction of the mean inter-particle separation to use as Plummer-equivalent softening for the background DM particles.
rebuild_frequency: 0.01 # (Optional) Frequency of the gravity-tree rebuild in units of the number of g-particles (this is the default value).
a_smooth: 1.25 # (Optional) Smoothing scale in top-level cell sizes to smooth the long-range forces over (this is the default value).
r_cut_max: 4.5 # (Optional) Cut-off in number of top-level cells beyond which no FMM forces are computed (this is the default value).
r_cut_min: 0.1 # (Optional) Cut-off in number of top-level cells below which no truncation of FMM forces are performed (this is the default value).
dithering: 1 # (Optional) Activate the dithering of the gravity mesh at every rebuild (this is the default value).
dithering_ratio: 1.0 # (Optional) Magnitude of each component of the dithering vector in units of the top-level cell sizes (this is the default value).
# Parameters when running with SWIFT_GRAVITY_FORCE_CHECKS
ForceChecks:
......
......@@ -23,6 +23,7 @@
/* Standard headers */
#include <float.h>
#include <math.h>
#include <string.h>
/* Local headers. */
#include "adiabatic_index.h"
......@@ -84,10 +85,32 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
/* Time integration */
p->eta = parser_get_param_float(params, "Gravity:eta");
/* Opening angle */
/* Read the choice of multipole acceptance criterion */
char buffer[32] = {0};
parser_get_param_string(params, "Gravity:mulitpole_acceptance_criterion",
buffer);
if (strcmp(buffer, "adaptive") == 0) {
p->use_adaptive_tolerance = 1;
} else if (strcmp(buffer, "geometric") == 0) {
p->use_adaptive_tolerance = 0;
} else {
error(
"Invalid choice of multipole acceptance criterion: '%s'. Should be "
"'adaptive' or 'geometric'",
buffer);
}
/* We always start with the geometric MAC */
p->use_advanced_mac = 0;
/* Geometric opening angle */
p->theta_crit = parser_get_param_double(params, "Gravity:theta");
if (p->theta_crit >= 1.) error("Theta too large. FMM won't converge.");
/* Adaptive opening angle tolerance */
p->adaptive_tolerance = parser_get_param_float(params, "Gravity:epsilon_fmm");
/* Mesh dithering */
if (periodic && !with_external_potential) {
p->with_dithering =
......@@ -170,6 +193,9 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
void gravity_props_update(struct gravity_props *p,
const struct cosmology *cosmo) {
/* Choice of MAC */
if (p->use_adaptive_tolerance) p->use_advanced_mac = 1;
/* Current softening length for the high-res. DM particles. */
double DM_softening, baryon_softening;
if (p->epsilon_DM_comoving * cosmo->a > p->epsilon_DM_max_physical)
......
......@@ -54,6 +54,9 @@ struct gravity_props {
/* -------------- Properties of the FFM gravity ---------------------- */
/*! What MAC are we currently using? */
int use_advanced_mac;
/*! Are we using the adaptive opening angle? */
int use_adaptive_tolerance;
......
......@@ -89,7 +89,7 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept(
/* Get the sum of the multipole sizes */
const float rho_sum = rho_A + rho_B;
if (props->use_adaptive_tolerance) {
if (props->use_advanced_mac) {
/* Test the different conditions */
......@@ -181,7 +181,7 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2P_accept(
const float theta_crit = props->theta_crit;
const float theta_crit2 = theta_crit * theta_crit;
if (props->use_adaptive_tolerance) {
if (props->use_advanced_mac) {
/* Test the different conditions */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment