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
Require Seed #1211
Require Seed #1211
Conversation
The tutorial scripts and corresponding tex files need to be changed, too.
|
Great! More global variables. |
This is broken on Python 3: https://travis-ci.org/espressomd/espresso/jobs/247486394#L1369 |
Codecov Report
@@ Coverage Diff @@
## python #1211 +/- ##
========================================
Coverage ? 60%
========================================
Files ? 416
Lines ? 28977
Branches ? 0
========================================
Hits ? 17391
Misses ? 11586
Partials ? 0
Continue to review full report at Codecov.
|
… I seeded them anyways as good measure.
This PR seems to have a lot of merge conflicts. Identical seeds may result in synchronization even when the system is setup in different start configurations. This is due to stochastic thermostats like the langevin thermostat acting as an attractor and the Lyapunov exponent(s) therefore having a negative sign such that trajectories exponentially converge. The Lyapunov exponent is system dependent. This attracting behaviour has for example been shown in 1D Lennard-Jones systems and I can reproduce this behaviour with espresso. The remaining question is whether this synchronization may be present in systems which are of interest for us. In this case it is important to seed with different seeds when using multiple simulations to estimate the variance of observables. With same seeds (but different start configurations Synchronization has for example also been reported in a 3d alanine peptide system: Although synchronization might not always happen I would be careful here and rather use a random seed. I would say to be on the safe side we should look at the alanine peptide example and see wether something like this can happen in our systems. If we decide it s not possible we can keep the fixed seeds and maybe just close this PR? |
If the user is required to provide a seed, what prevents him from providing a random seed? |
github and CI seem to be happy. Any specific thing @KaiSzuttor? |
@@ -65,7 +65,9 @@ | |||
|
|||
# System setup | |||
############################################################# | |||
system = espressomd.System(box_l=[1.0, 1.0, 1.0]) | |||
system = espressomd.Systembox_l=([1.0, 1.0, 1.0]) |
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.
This looks wrong.
src/core/random.hpp
Outdated
@@ -83,6 +89,12 @@ void init_random_seed(int seed); | |||
|
|||
inline double d_random() { | |||
using namespace Random; | |||
|
|||
if (!user_has_seeded && !unseeded_error_thrown) { | |||
unseeded_error_thrown = true; |
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.
there is a lot of code duplication here for every function that returns random numbers... also there is no need to throw if temperature is 0.0, e.g. the user only wants the damping part of a langevin thermostat
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.
@davidsean please remove code duplication and only throw if temperature != 0.0
@@ -73,7 +74,7 @@ def test_npt(self): | |||
print(avp,compressibility) | |||
|
|||
self.assertAlmostEqual(2.0, avp, delta=0.02) | |||
self.assertAlmostEqual(0.2, compressibility, delta=0.01) | |||
self.assertAlmostEqual(0.2, compressibility, delta=0.013) |
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.
Why did you change the accepted deviation?
On Tue, Jul 24, 2018 at 06:29:24AM -0700, Kai Szuttor wrote:
KaiSzuttor commented on this pull request.
> @@ -73,7 +74,7 @@ def test_npt(self):
print(avp,compressibility)
self.assertAlmostEqual(2.0, avp, delta=0.02)
- self.assertAlmostEqual(0.2, compressibility, delta=0.01)
+ self.assertAlmostEqual(0.2, compressibility, delta=0.013)
Why did you change the accepted deviation?
Blew up for a certain number of cores.
|
This reverts commit dfd232b.
I broke the drude testcase, no idea how. Thermalized bond and harmonic bond tests pass. |
@fweik , ready for review i think |
src/core/random.hpp
Outdated
|
||
namespace Random { | ||
extern std::mt19937 generator; | ||
extern std::normal_distribution<double> normal_distribution; | ||
extern std::uniform_real_distribution<double> uniform_real_distribution; | ||
extern bool user_has_seeded; | ||
extern bool unseeded_error_thrown; |
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.
This should not be global, I think the best solution is to make it a static local variable in check_user_has_seeded.
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.
hmm, but how to switch the user_has_seeded variable?
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.
I'm only talking about unseeded_error_thrown
.
What was the exact reason for not requiring a user provided seed when initializing a random number generator (and preventing a random number generator to exist without a user provided seed or state)? That would be the correct dependency inversion right? Then we would not need to check for a seed to be present all the time. |
good idea, but i think that would be some more work. having our manpower in mind, i think this PR serves our current needs. But you can open an issue. |
Fixes #1039
Description of changes:
Requires that the user seeds from the script, displays how to do it as part of the runtime error message
PR Checklist