Monte Carlo Example
Possibly the simplest example of a stochastic analysis is to perform Monte Carlo analysis of a given simulation. That is, solve a single problem and vary parameters within this simulation with a random set of perturbed parameters.
Problem Statement
The first step is to define the simulation to perform, in this case the simulation considered is a 1D transient diffusion equation with Dirichlet boundary conditions on each end of the domain: find such that
where , , and defines a continuous uniform distribution with and defining the lower and upper limits of the distribution, respectively.
Sub-Application Input
The problem defined above, with respect to the MultiApps system, is a sub-application. The complete input file for the problem is provided in Listing 1. The only item required to enable the stochastic analysis is the Controls block, which contains a SamplerReceiver object, the use of which will be explained in the following section.
Listing 1: Complete input file for executing the transient diffusion problem.
(contrib/moose/modules/stochastic_tools/test/tests/transfers/monte_carlo/sub.i)Master Input
The master application, with respect to the MultiApps system, is the driver of the stochastic simulations, by itself it does not perform a solve. The complete input file for the master application is shown in Listing 2, but the import sections will be detailed individually.
First, Distributions for each of the two stochastic boundary conditions are defined.
(contrib/moose/modules/stochastic_tools/test/tests/transfers/monte_carlo/monte_carlo.i)Second, a MonteCarloSampler is defined that utilizes the two distributions and creates the Monte Carlo samples.
(contrib/moose/modules/stochastic_tools/test/tests/transfers/monte_carlo/monte_carlo.i)Notice, that this sampler only executes on "initial", which means that the random numbers are created once during the initial setup of the problem and not changed again during the simulation.
Next, a SamplerTransientMultiApp object is created. This object creates and runs a sub-application for each sample provided by the sampler object.
(contrib/moose/modules/stochastic_tools/test/tests/transfers/monte_carlo/monte_carlo.i)Finally, the SamplerParameterTransfer is utilized to communicate the sampler data to the sub-application. The 'parameters' input lists the parameters on the sub-applications to perturb.
(contrib/moose/modules/stochastic_tools/test/tests/transfers/monte_carlo/monte_carlo.i)Listing 2: Complete input file for master application for executing Monte Carlo stochastic simulations.
(contrib/moose/modules/stochastic_tools/test/tests/transfers/monte_carlo/monte_carlo.i)