This change introduces a new parameter to control how particles in subgrids are deposited into the mass field to generate the mass. Previously, this was hard-coded to NGP deposit (following a change made by Tom about a year ago, previous to which it was CIC deposit). We now introduce a parameter which controls this -- the new parameter is ParticleSubgridDepositMode, and three values are allowed:
0 (CIC_DEPOSIT) - This is a second-order, cloud-in-cell deposition
method in which the cloud size is equal to the cell size in
the target grid (particles are in source grid, deposited into
target grid). This method preserves the correct center-of-mass
for a single particle but smears out boundaries and can result
in small artifacts for smooth particle distributions (e.g.
nested cosmological simulations with low perturbations).
1 (CIC_DEPOSIT_SMALL) - This is also a CIC method, but the cloud
size is taken to be the cell size in the source grid, so for
subgrids, the cloud is smaller than the grid size. This
is an attempt to compromise between the other two methods.
2 (NGP_DEPOSIT) - This uses a first order, nearest-grid-point
method to deposit particle mass. It does not preserve center-
of mass position and so for single particle results in noisy
accelerations. However, it does correctly treat nested
cosmology simulations with low initial perturbations.
The previous code corresponds to NGP_DEPOSIT, which does a good job of not introducing artifacts in cosmological simulations which are very close to a uniform distribution. However, this does not do well when resolving one or a small number of particles. This is seen most clearly in the GravityTest, which generates large errors in the top grid.
The alternate setting of CIC_DEPOSIT fixes the problem in GravityTest but introduces artifacts for cosmology simulations with a very uniform initial distribution (low perturbations). The new option CIC_DEPOSIT_SMALL, is a compromise, in that it uses a CIC deposit, but with a cloud size corresponding to the particle's grid cells, rather than the target's grid cells. This produces a good result for the GravityTest and also performs well for cosmological simulations with uniform distributions. Given that it performs very well, we adopt it as the default.
More specifically, here is the result of GravityTest (from the method paper) with the (previous) NGP_DEPOSIT deposition (pretty bad! This is what the current code does!):
And here it is with the CIC_DEPOSIT (much better!):
And here it is with CIC_DEPOSIT_SMALL (almost identical to CIC_DEPOSIT):
The cosmological case is a little hard to show, but here are some examples takes from a slightly modified AMRNestedCosmology run. In particular, we decreased the power spectrum amplitude to exaggerate the size of any artifacts (all of these methods work pretty well for reasonably large perturbation amplitudes). In particular, we set:
in the AMRNestedCosmology_*Grid.inits files and making some similar changes to the AMRNestedCosmology.enzo file (the enzo full parameter file is here: http://paste.yt-project.org/show/3618/). We set the baryons to a very low value to focus on the dark matter and set the power spectrum amplitude very low. Then we run it and look at the resulting potential slice through the center.
For the NGP_DEPOSIT (the current way the code is operating), the resulting potential image looks like this:
which is not bad -- there are a few artifact, but the power spectrum is really very, very low so this is expected (in fact, I selected such a low power to make sure that I would still see some artifacts in this case).
For CIC_DEPOSIT, we get:
which is really pretty bad and the reason Tom made the change way back.
With the new CIC_DEPOSIT_SMALL, we get:
which is as good as the NGP_DEPOSIT.
Documentation has been added to the parameter file description. This change will modify the gold standard. It is also required to get the method paper tests correct (in particular TestGravity), so it would be great if people could look at this ASAP.
UPDATE: Corrected the comment mistakes that Sam et al. pointed out. Also, put back cic_deposit_c.o in Make.config.obj (I didn't mean to remove this, although it should probably be removed since it is not used -- but that should probably be another pull request).