Pseudo-Random Number Generation (PRNG)
- Most MOOSE objects include an interface for generating pseudo-random numbers consistently during serial, parallel, and threaded r
- This consistency enables more robust development and debugging without sacrificing PRNG quality.
- Users have control over the reset frequency of the PRNG.
- Helps avoid convergence issues due to excessive PRNG noise during linear or non-linear iterations.
- The PRNG system avoids the repetition of "patterns" in subsequent executions of an application.
Using Random Numbers
- Make a call to
setRandomResetFrequency() in your object's constructor.
// Options include EXEC_RESIDUAL, EXEC_JACOBIAN, EXEC_TIMESTEP, EXEC_INITIAL
// Note: EXEC_TIMESTEP == EXEC_TIMESTEP_BEGIN for the purpose of reset
- Obtain Random Numbers (Real or Long)
// anywhere inside your object (except the constructor)
unsigned long random_long = getRandomLong();
Real random_real = getRandomReal();
MooseObject has its own "seed" value.
- The seed is used to generate different random sequences from run to run.
- The "reset frequency" specifies how often the random number generators should be reset.
- If you reset on
EXEC_RESIDUAL, you will get the same random number sequence each residual evaluation for a given timestep.
- You can also reset less often, e.g. Jacobian, timestep, or simulation initialization only.
- Generators are advanced every time step unless you explicitly set the reset frequency to
- A multi-level random seeding scheme is used to avoid patterning from mesh entity to mesh entity, timestep to timestep, and run to run