-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throw away random numbers to avoid unexpected correlations #1569
Conversation
Wouldn't it be better to have this change in the constructor? With the current code, the 30 numbers are discarded for every insertion attempt. |
@mkanski It's a good idea! Thank you. I have moved it to the constructor. |
@sjplimp I have moved it after the generator is constructed, thanks. |
@sjplimp does this need to be expanded to other cases? e.g. fix pour? |
Sure, the same logic would apply in fix pour. Can't think of any others. |
OK. updated. turned on regression tests, since we may need to reset some of them. |
what about |
This pull claims it will not break backwards compatibility, though I am afraid it will. Per the Pour documentation, a user provides a seed parameter. The provided seed will lead to a random but repeatable stream of numbers. If I provide the seed |
@rdwyman |
yes, let's also add this 30x warmup to fix evaporate (in the constructor), and to |
@sjplimp added the warmup to two more locations as discussed previously. should be ready to go in now if it passed the integration tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
Summary
When there is a need to inject particles (with fix deposit), a seed is used to generate a sequence of random numbers for the initial position of particles. There is a strong correlation between the first random number generated by different seeds.
Before the first few random numbers are thrown away, the position of first particle generated by different seed has a strong correlation. The figure shown here is the initial position of the first particles generated by different seeds, it is not uniform.
It can be fixed by simply throwing away the first few random numbers generated by each seed.
After the first 30 random numbers are thrown away, the initial position of first particle generated by different seed is uniform:
Related Issues
N/A
Author(s)
Jun-Chieh Wang (Applied Materials, wangjj0120@gmail.com)
Licensing
By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1).
Backward Compatibility
By tossing the first 30 random numbers, a given seed will no longer produce exactly the same random numbers to the code/user which breaks the backward compatibility.
Implementation Notes
The first 30 random numbers are thrown away, it's the only thing that has been changed in this file.
Post Submission Checklist
Please check the fields below as they are completed after the pull request has been submitted. Delete lines that don't apply
Further Information, Files, and Links
Put any additional information here, attach relevant text or image files, and URLs to external sites (e.g. DOIs or webpages)