Closed
Conversation
Previously there was a singularity at r==0.
Code that was in grid.c and weights.c has been put in a new module, random_points.c.
This is in preparation for the introduction of a new grid-point-selection algorithm.
The module weights.c is no longer compiled, since it is now obsolete.
Additional changes connected with the above:
- Added a new (optional) user parameter 'samplingAlgorithm'.
- Added external variables modelRadiusSquared, densityNormalizer,
numCollisionPartners.
- Added macro DENSITY_POWER.
- New struct locusType.
The new algorithm calls the function randomsViaTree() recursively in a 2^D-tree divide-and-conquer approach. The aim of this is to allow more accurate representation of models for which the density varies strongly across the model, without the severe time penalties that straightforward use of the rejection method would entail. (The previous algorithm uses rejection method, but it 'flattens' the density function in order to avoid long run times, which has the effect that high-density regions are undersampled.) The algorithm assesses the density gradients over a sub-volume of the model space, and if those gradients are judged too large for quick results from the rejection method, the sub-volume is divided into 8 smaller sub-volumes and the same function is called for each one of these. The division is performed by cutting the volume approximately in halves (at the 0.5 point plus some random dither) along each of the (3) axes of the coordinate space. Additional changes connected with the above: - New macros: N_TREE_RANDOMS MAX_RECURSION MAX_N_TRIALS_TREE TREE_DITHER
The new grid-selection algorithm estimates the density gradients within a sub-volume. This estimate may be too low if the function has narrow peaks. In this case, the functioning of the algorithm is improved if the user pre-supplies a list of the maximal values of the density function. Additional changes connected with the above: - New (optional) user parameters numDensityMaxima, densityMaxLoc, densityMaxValue. Note that I have left the appropriate lines commented out for now in the example model.c file. - New macro: MAX_N_HIGH
In general it seems desirable to have the grid point number density follow the total density of the collision partners, as is now more accurately provided by the new algorithm. If the density function is heavily peaked, whereas the chosen number of grid points is kept relatively small, a situation could arise in which the distribution of points in the low-density regions of the model was very sparse. To prevent this occurring, the user can now set a parameter minPointNumDensity. The units of this should if possible save the user calculation, and to be scale-invariant: the chosen unit therefore is points per spherical model volume. Note that this feature is only implemented when par->samplingAlgorithm==1. Additional changes connected with the above: - A new extern variable minDensity is defined.
fbee0e8 to
e773558
Compare
Merged
Contributor
|
Superseded by #93. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a new optional algorithm for generating grid points. The original algorithm is based on the rejection method, but this is slow when the (number) density function is highly peaked (i.e. when its maximum value is many times its average value). To compensate for this, the original algorithm flattens the user-input density function by raising it to a small positive power. An effect of this is that dense areas of the model are undersampled.
I ran this fairly extensive code addition/modification through valgrind to fix reported memory leaks etc. This addition seems to work ok in that it produces images broadly similar to the previous; it probably needs some more extensive testing though to investigate the effects of the new algorithm.