Commit 856bcb95 authored by Matthieu Schaller's avatar Matthieu Schaller

Merge branch 'fof_linking_length_in_zooms' into 'master'

In the case of a zoom simulation, use only the high-resolution DM particles to…

See merge request !985
parents 48c6d703 787315b1
......@@ -245,12 +245,41 @@ void fof_set_initial_group_id_mapper(void *map_data, int num_elements,
void fof_allocate(const struct space *s, const long long total_nr_DM_particles,
struct fof_props *props) {
const int verbose = s->e->verbose;
/* Start by computing the mean inter DM particle separation */
/* Collect the mass of the first non-background gpart */
double high_res_DM_mass = 0.;
for (size_t i = 0; i < s->nr_gparts; ++i) {
const struct gpart *gp = &s->gparts[i];
if (gp->type == swift_type_dark_matter &&
gp->time_bin != time_bin_inhibited &&
gp->time_bin != time_bin_not_created) {
high_res_DM_mass = gp->mass;
break;
}
}
/* Calculate the mean inter-particle separation as if we were in
a scenario where the entire box was filled with high-resolution
particles */
const double Omega_m = s->e->cosmology->Omega_m;
const double Omega_b = s->e->cosmology->Omega_b;
const double critical_density_0 = s->e->cosmology->critical_density_0;
double mean_matter_density;
if (s->with_hydro)
mean_matter_density = (Omega_m - Omega_b) * critical_density_0;
else
mean_matter_density = Omega_m * critical_density_0;
/* Mean inter-particle separation of the DM particles */
const double mean_inter_particle_sep =
cbrt(high_res_DM_mass / mean_matter_density);
/* Calculate the particle linking length based upon the mean inter-particle
* spacing of the DM particles. */
const double mean_inter_particle_sep =
s->dim[0] / cbrt((double)total_nr_DM_particles);
const double l_x = props->l_x_ratio * mean_inter_particle_sep;
int verbose = s->e->verbose;
/* Are we using the aboslute value or the one derived from the mean
inter-particle sepration? */
......
......@@ -486,8 +486,13 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) {
/* Linking length based on the mean DM inter-particle separation
* in the zoom region and assuming the mean density of the Universe
* is used in the zoom region. */
const double mean_matter_density =
double mean_matter_density =
e->cosmology->Omega_m * e->cosmology->critical_density_0;
if (s->with_hydro)
mean_matter_density = (Omega_m - Omega_b) * critical_density_0;
else
mean_matter_density = Omega_m * critical_density_0;
sim_info.interparticlespacing =
cbrt(high_res_DM_mass / mean_matter_density);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment