-
Notifications
You must be signed in to change notification settings - Fork 238
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
Random initial temperature and compositional plugins #5831
base: main
Are you sure you want to change the base?
Random initial temperature and compositional plugins #5831
Conversation
This is an update of #1813 to modern standards and currently just open for discussion |
When you say " the plug-in produces different initial temperature fields for the same prm file", do you mean "different initial temperature fields from run to tun", or different from what? |
You've got these warnings and errors:
|
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.
Very close, I just have some stylistic comments. Let me know when you want me to take another look.
noise of user prescribed magnitude to the initial temperature field. | ||
The same type of plugin was added for initial compositions. | ||
<br> | ||
(Rene Gassmoeller, 2017/06/19) |
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.
Feel free to update the date and add your name here as first author.
* random composition perturbations. Should return the same | ||
* random numbers every time since it is seeded with one. |
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 would remove the sentence, since the behavior depends on the input parameters.
/** | ||
* Return the initial temperature as a function of position. | ||
*/ | ||
|
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.
remove this empty line, instead add one before the comment. Also please add documentation for the initialize
function above (check the other plugins, you can likely copy the documentation).
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.
also check the initial temperature plugin for the same function
|
||
#include <aspect/initial_composition/random_perturbation.h> | ||
|
||
// #include <boost/functional/hash.hpp> |
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.
remove this header file
else | ||
random_number_generator.seed(9088+my_rank); | ||
} | ||
|
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.
our typical code style is to have 3 empty lines between function implementations in the source file (and 1 empty line between function declarations in the header file).
template <int dim> | ||
double | ||
RandomPerturbation<dim>:: | ||
initial_composition (const Point<dim> &position, const unsigned int composition_index) const |
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.
The compiler complains because none of the input parameters are used, do this instead:
initial_composition (const Point<dim> &position, const unsigned int composition_index) const | |
initial_composition (const Point<dim> &/*position*/, const unsigned int /*composition_index*/) const |
#include <aspect/initial_composition/interface.h> | ||
#include <aspect/simulator_access.h> | ||
|
||
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS |
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.
As far as I know there is no need for DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
anymore and also DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
. (keep the include).
*/ | ||
template <int dim> | ||
class RandomPerturbation : public Interface<dim>, public aspect::SimulatorAccess<dim> | ||
|
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.
remove this empty line
#include <aspect/initial_temperature/interface.h> | ||
#include <aspect/simulator_access.h> | ||
|
||
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS |
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.
as above
template <int dim> | ||
double | ||
RandomPerturbation<dim>:: | ||
initial_temperature (const Point<dim> &position) const |
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.
as above:
initial_temperature (const Point<dim> &position) const | |
initial_temperature (const Point<dim> &/*position*/) const |
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 is more of a comment for @gassmoeller: This scheme is not thread-safe. If VectorTools::interpolate()
decides to run on multiple processes, we will end up with non-reproducible random numbers. It doesn't, right now, but I thought it's worthwhile putting this into the record in case someone needs to track down a non-reproducibility at some later point.
@bangerth You are right of course. However, we never made the last try to produce a thread-safe version work (#1813), because that one produced non-reproducible random number series even on a single process and neither I nor @KerrMadeleine could figure out why. That is why we decided to go with the algorithm that works for the current version of ASPECT and think about thread-safety if it will ever be necessary. |
I have revisited the Random initial composition (which also includes random initial temperature) and attempted to test that the random number generator MT19937 produces the same sequence of random numbers given the same seed. The generator random_number_generator is a private member of the Initial temperature class and seeded with the integer 1. Seeding the RNG with a hash which uses the position value of each point to generate a combined hash has been removed as well as the option to randomly seed the random number generator. Still, with the RNG seed fixed to 1, the plug-in produces different initial temperature fields for the same prm file.
This *.prm file is:
'''
Test to check the status of the random initial temperature perturbation
plugin.
set Output directory = output-test-2
set Dimension = 2
subsection Boundary velocity model
set Tangential velocity boundary indicators = left, right, bottom, top
end
subsection Mesh refinement
set Initial global refinement = 1
end
subsection Postprocess
set List of postprocessors = temperature statistics, visualization
subsection Visualization
set Output format = gnuplot
end
end
subsection Material model
set Model name = simpler
end
set End time = 0
subsection Geometry model
set Model name = box
end
subsection Gravity model
set Model name = vertical
end
subsection Initial temperature model
set List of model names = function, random perturbation
subsection Random perturbation
set Magnitude = 0.2
set Use random seed = false
end
subsection Function
set Function expression = 0.5
end
end
subsection Boundary temperature model
set List of model names = box
set Fixed temperature boundary indicators = top, bottom #MCK added
subsection Box #MCK added
set Bottom temperature = 1
set Top temperature = 0
end
end
'''