This repo is envisaged as being an interface mainly to MOOSE, but also must be able to interface with other tools such as meshers for pre-processing. Potentially this could also work with other simulation software such as OpenFOAM (using PyFOAM for parsing).
Dependencies can be installed as:
pip install hjson UQpy numpy scipyTo use for modifying MOOSE input files, we require pyhit is available, which is installed with MOOSE. This can be located by following:
export PYTHONPATH=$MOOSE_DIR/python:$PYTHONPATHTo set-up UQ jobs, we require a directory containing (1) a folder named basedir containing input files to be copied and modified, and (2) a config file (json format) with information on uncertain parameters. Several examples are provided, and explained in further detail below. In general, the config file has the following structure:
{
"apps":
{
"cube_thermal_mechanical.i":
{
"type":"moose",
"uncertain-params":
{
// items to modify in the file `cube_thermal_mechanical.i`
},
"uq_log_name": "uq_log", // name of file used to archive the uncertain params
}
},
"paths":
{
// generally unchanged
"workdir":"./",
"baseline_dir":"basedir",
},
"sampler" : "montecarlo", // currently supports "montecarlo" or "latinhypercube"
"num_samples" : 10, // can be overriden at command line
// if not launched through the nextflow pipeline, a bash script can be used to launch all jobs on e.g. a SLURM cluster
"launcher_name" : "launcher.sh",
"launcher" : "bash", // supports "bash", "slurm" or "lsf"
"template_launcher_script":"runpar.sh", // refers to a script in the `paths/baseline_dir` that will launch the job
}To create a new number of cases which sample the uncertain PDFs, we run the following script:
python python/setup_uq_run.py \
-c run_case1_thermomechanicalcube/config_thermomech.jsonc \
-b run_case1_thermomechanicalcube/basedir \
-n 10We have provided a several examples to show how to set up a UQ run, for the kind of cases we are working on. The scope of these examples is as follows:
run_case1_thermomechanicalcube: This is a cube geometry with an applied heat-flux BC. The material properties are given as csv files which are read by MOOSE asPiecewiseLinearfunctions. Theconfig_thermomech.jsoncfile describes the uncertain parameters. In this example, we show how to put uncertainty on the heat-flux (a scalar value), and material properties. We fit a polynomial to each material properties and the coefficients of the polynomial are treated as uncertain. Thebasedircontains info on the baseline simulation, with a script to setup a geometry and run the executable.config_thermomech.jsoncpoints to this run script. The basedir is copied N times, new input files with perturbed parameters are created, and therun.shorrunpar.shscript is launched. We have not yet set up any post-processing.run_case2_thermomechanicalcube_with_coolantbuilds on the previous example by showing how to impose uncertainties in a MOOSE MultiApp. The MultiApp couples the cube to a coolant pipe flowing through the center. Heat-flux is sent from the solid to the coolant. Coolant temperature is sent back to the solid. The same uncertainties as above are included, but with additional uncertainty on the friction factor of the coolant pipe in the sub-app.run_case3_chimera_coolant_onlyshows how to put uncertainties on some general simulator which is set up using a json file. In this case, we have a custom python script which makes a MOOSE input file based on the geometry of the CHIMERA coolant network (digraph.gml) and other simulation parameters taken fromchimera_params.jsonc. The config file for the UQ run (config.jsonc) overwrites thechimera_params.jsoncvariablestraight_pipe_friction_factorfor each new sample. When the job is submitted, the newchimera_params.jsoncis used to create a MOOSE input file which is then run.