-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add random compositional fields #651
Add random compositional fields #651
Conversation
|
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 great, thanks for making this! I have a few small comments, but otherwise I think it is good to go.
source/world_builder/features/continental_plate_models/composition/random.cc
Outdated
Show resolved
Hide resolved
source/world_builder/features/continental_plate_models/composition/random.cc
Outdated
Show resolved
Hide resolved
source/world_builder/features/continental_plate_models/composition/random.cc
Outdated
Show resolved
Hide resolved
Thank you for the review! I addressed the comments in the latest commit. |
The random numbers are depended on the seed. As long as the seed is the same, the same sequence of random numbers will be generated. If you update your test results, the tester should pass. |
Got it! Thanks for the explanation. |
hmm, strange. Did you rebase on the newest master when updating the test results? |
4b38ea2
to
645f35b
Compare
I rebased the branch but the tests are still failing. I don't understand why. :( |
I checked that each run is gives me a different result, which would explain why the test is failing. |
The problem is that gwb-grid now uses multiple threads by default. This means that the points will not be evaluated in the same, deterministic order. I am not even sure that the random engine is thread-safe. |
ah, that make sense. I was confused, because we currently already use random number generation in the code, but this is for the grains, which is only implemented for the for gwb-dat, which doesn't use threads. |
In any case, we should probably fix the number of threads for the tester. |
hmm, getting a thread rank is not as easy as getting a mpi rank. The thread id seems to be an unpredictable number/hash (I think). We do actually have a unique rank number when creating them, but we would need to pass those id's manually somehow. Looking at it, the easiest solution may be to add a constructor parameter to the world so that you can pass a thread rank. That rank is then use in some way to set the seed of the world. In gwb-grid, we then just create a separate world for each thread, and in the parallel for loop we call the properties function on the appropriate world for each thread. This would make it deterministic again and would require minimal changes I think. |
Add a test. Address comments from the PR. Update tests.
645f35b
to
298af12
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #651 +/- ##
==========================================
- Coverage 98.23% 98.18% -0.05%
==========================================
Files 106 107 +1
Lines 7302 7341 +39
==========================================
+ Hits 7173 7208 +35
- Misses 129 133 +4
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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 am not sure why it didn't work for you, but it seems to work for me :s
This PR addresses part of issue #531 to get random compositional values. Here is the output of this plugin with a continental plate:
This is the result for user specified bounds in the first compositional field: [5, 10]
This is the result from using the default
random
model.