You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
printf("\n RANDOM CATALOG %d DIAGNOSTICS:\n", index+1);
194
-
printf("Average number of particles per grid cell = %6.2f\n", grid_density);
195
-
if (grid_density > max_density) {
195
+
printf("Average number of particles per grid cell = %6.2f\n", grid_density[index]);
196
+
if (grid_density[index] > max_density) {
196
197
nside_local_success = false; // unset this attempt's success flag
197
198
Float aimed_density = cbrt(max_density * max_density * min_density); // aim for density between the limits but closer to max
198
-
Float nside_approx = cbrt(grid_density/aimed_density) * par.nside; // approximate value of nside to reach this density
199
+
if (index) aimed_density = sqrt(max_density * min_density * grid_density[index] / grid_density[0]); // for two tracers, if the failure happens for the second tracer, effectively aim the geometric mean density of the two tracers at the geometric mean of the limits. specifically, put the naively aimed densities for both tracers equally close to the limits in log-space. this is the aimed density for the second tracer = sqrt(max_density * min_density) * sqrt(grid_density[1] / grid_density[0]), the expectation for the first tracer would then be sqrt(max_density * min_density) * sqrt(grid_density[0] / grid_density[1]). the previous method would not reach a resolution if the tracer densities come close to or above (max_density/min_density)^(2/3) = 4. the new method should be able to push the limit closer to max_density/min_density = 8, but it will probably fail a bit earlier because the aim is approximate due to discreteness
200
+
Float nside_approx = cbrt(grid_density[index]/aimed_density) * par.nside; // approximate value of nside to reach this density
printf("# INFO: Average particle density exceeds maximum advised particle density (%.0f particles per cell). Setting nside=%d.\n", max_density, par.nside);
201
203
break; // terminate the inner, tracer loop
202
204
}
203
-
if (grid_density < min_density) {
205
+
if (grid_density[index] < min_density) {
204
206
nside_local_success = false; // unset this attempt's success flag
205
207
Float aimed_density = cbrt(max_density * min_density * min_density); // aim for density between the limits but closer to min
206
-
Float nside_approx = cbrt(grid_density/aimed_density) * par.nside; // approximate value of nside to reach this density
208
+
if (index) aimed_density = sqrt(max_density * min_density * grid_density[index] / grid_density[0]); // for two tracers, if the failure happens for the second tracer, effectively aim the geometric mean density of the two tracers at the geometric mean of the limits. specifically, put the naively aimed densities for both tracers equally close to the limits in log-space. this is the aimed density for the second tracer = sqrt(max_density * min_density) * sqrt(grid_density[1] / grid_density[0]), the expectation for the first tracer would then be sqrt(max_density * min_density) * sqrt(grid_density[0] / grid_density[1]). the previous method would not reach a resolution if the tracer densities come close to or above (max_density/min_density)^(2/3) = 4. the new method should be able to push the limit closer to max_density/min_density = 8, but it will probably fail a bit earlier because the aim is approximate due to discreteness
209
+
Float nside_approx = cbrt(grid_density[index]/aimed_density) * par.nside; // approximate value of nside to reach this density
0 commit comments