Thermal-Fluids Analysis with Uncertainty

Sensitivity Analysis and Uncertainty Quantification

ME 498/599 Sensitivity Propagation and Uncertainty Quantification

University of Washington

Spring Quarter 2017

Class Web Site

We are interested in the simulation of heat transfer and fluid mechanics, from both a control volume (integral) approach, as well as a continuum mechanics approach. The control volume approach has been historically called thermal-network or fluid-network analysis/simulation. Broadly, a continuum mechanics approach utilizes a grid generation step, followed by the application of a discretization method. These methods can include (certainly not limited to) finite difference, finite volume or finite element approaches. The initial effort is to provide guidance and tools for sensitivity analysis and uncertainty quantification and propagation. Sensitivity analysis (local and global) is used to provide insight into how variations in the input parameters to a model affect the output parameters of the simulation. Uncertainty quantification and propagation is concerned with the determination of the uncertainty characteristics of model input parameters and then propagating them through the simulation to provide uncertainty estimates of the output.


Schedule

Date Lecture Topic Notes Remarks Homework Due Date Office Hours
Mon, May 15 Introduction to Dakota Dakota Overview
Wed, May 17 Dakota Installation Installation Procedure
Fri, May 19 Centered Parameter Study with Dakota Dakota Model Characterization Cantilever Math Model Write MATLAB program for cannon Mon, May 22
Mon, May 22 Review cannon.m program and the Dakota interface process. Text based input and output files from simulation program. Add air resistance to your cannon MATLAB program (call it cannon2.m). Write out the math model, which is two ODE's: x-direction motion and y-direction motion. Solve these using the ode45 function in MATLAB. Call the program cannon2.m. Wed, May 24 10-11:30 AM in MEB 215
Wed, May 24 Sensitivity Sampling Study with Dakota Dakota Sensitivity and Uncertainty Quantification
Latest Dakota Sensitivity Analysis
LHS Study of Cantilever Math Model Run Centered Parameter Study with Dakota and your cannon2.m MATLAB program with air resistance. Plot the variation in the response to the input parameters. What are your conclusions? Fri May 26 10-11:30 AM in MEB 215
Fri, May 26 Uncertainty Analysis with Dakota Dakota Uncertainty Quantification
See Chapter 6 in Simulation Credibility NASA/TP-2016-219422
UQ: Specifying Uncertainty in Dakota (Revised June 2)
Probability Distribution Functions Run LHS Study with Dakota and your cannon2.m MATLAB program with air resistance. Add the resistance parameter, k, to the input file and study the uncertainty. Use a nominal value of k such that kV_0^2 = mg. Plot bar graphs of correlation and scatter plots with regressions. What are your conclusions? Wed May 31 10-11:30 AM in MEB 259
Mon, May 29 Holiday
Wed, May 31 Surrogate Models/Variance-based Decomposition/Sobol Indices Global Sensitivity Analysis: The Primer, Saltelli, et al., 2008
Notes on VBD/Sobol' Indices
Dakota Training VBD SA
Dakota Training VBD UQ
Global Sensitivity Analysis Start your project for the final (sooner would be better). Wed Jun 7 2:30-4:30 PM 10:30-11:30 AM in MEB 259
Fri, June 2 Model Parameter Distribution Fitting Fitting Distributions with R
Notes on Fitting Distributions
Dakota Summary
Utilizing R 9:30-11:30 AM in MEB 219
Wed, June 7 Final - Project Presentations 2:30 to 4:30 PM


Sandia Dakota Toolkit

Windows Installation

Dakota is normally used on a Linux OS computer at Sandia. The following open source tools are required for using Dakota on a Windows OS computer. Since Dakota runs from the command line you will need to open a command window as administrator. At the command prompt, execute the following commands:

Note: When installing the following software I would suggest that you unselect all the options, such as start menu folders, path modifications, etc.

  1. The Dakota web site installation instructions: Dakota Quick Start
  2. Download latest Dakota binary: Dakota 6.5 without GUI or Dakota 6.5 with GUI for Input File
  3. Install the latest Python 2.7:
  4. Install the latest Perl:
  5. Install required GnuWin utilities for Windows:
  6. Install the latest GNU Octave (the open source MATLAB, since I have yet to get MATLAB to work with Dakota, on my Windows machine):
  7. Test your Windows installation by typing the following commands in the Command Prompt window:

The following installation will be required in the future:

  1. Install the latest R Project for Statistical Computing:

The Dakota Training Cantilever Model for Windows

The Dakota Training Cantilever Model for Mac OS X/Linux


MATLAB/Octave Plotting Tools


The Cannon Projectile Problem

The cannon projectile problem is building off of HW 5. In order to use Dakota, your MATLAB program will need to open a text input file and write the result (distance) to a text output file. Using MATLAB and the referenced code snippet, write a MATLAB program (and test it) to solve the cannon projectile problem.

We will be using Octave to run your MATLAB program with Dakota. MATLAB, to date, has proven to not be suitable for running with Dakota. This may change in the future, but for the time being we will use Octave.

There are four items you will need to run a Dakota study with cannon2.m:

  1. Dakota input file.
  2. The mdriver.cmd file. Make sure the path is correct.
  3. The cannon.template file used by dprepro to produce cannon.inp.
  4. Your cannon2.m program.
I would suggest starting any study with an empty folder, copy these four items into the folder and then run Dakota.

A detailed checklist for the centered parameter study of the cannon problem can be found here.

Bob's cannon2 Solution

A zip file of the Dakota input files, cannon2.m program and cannon.template is cannon2_solution.zip


Project for Final

You may choose for your project any simulation that can be solved using a program written in a language you are proficient at. You have Dakota interfaces for python, MATLAB/Octave and R. If you want to use a compiled and linked language, such as C, C++ or Fortran, that can also be accommodated with Dakota.

Examples include, cooling of a body (lumped capacity) with free or forced convection using a correlation from a heat transfer text book, a one-dimensional conduction problem with convective boundary conditions described by values of h (convection coefficient), a chemical reaction problem, etc. In other words an extension of the Cannon2 program for a problem that is of interest to you.

Nominally, you should perform a LHS study with Dakota that includes a sensitivity analysis and an uncertainty quantification and propagation. The use of a surrogate model and generation of Sobol indices, is encouraged.

An example of the math model specification that I put together for the cannon problem can be found here: cannon_model.pdf.

Prepare a 15 minute presentation of your study. Include a description of the math model, conclusions from a sensitivity analysis and conclusions from an uncertainty quantification and propagation analysis. The presentations will take place on Wednesday, June 7, from 2:30 to 4:30 PM.


Simulation Driver Script Examples for Dakota

Windows cmd Script

Using Octave
@echo off
SETLOCAL ENABLEEXTENSIONS

REM  What is the directory that I am currently in for use with simulation
REM  program execution of the model

SET curdir=%cd%

REM  Process the simulation input template file with dprepro to produce
REM  an input file for the simulation program

C:\ME498\perl\bin\perl.exe c:\me498\dakota\bin\dprepro %1 cannon.template cannon.inp

REM  Run the simulation program with the current input file

C:\ME498\octave\bin\octave-cli --silent --path %curdir% --eval "cannon2('cannon.inp');" > NUL 2>&1

REM  Post-process the simulation output to provide the repsonses to Dakota

MOVE cannon.out %2 > NUL 2>&1
Using MATLAB
@echo off
SETLOCAL ENABLEEXTENSIONS

REM  What is the directory that I am currently in for use with simulation
REM  program execution of the model

SET curdir=%cd%

REM  Process the simulation input template file with dprepro to produce
REM  an input file for the simulation program

C:\ME498\perl\bin\perl.exe c:\me498\dakota\bin\dprepro %1 cannon.template cannon.inp

REM  Run the simulation program with the current input file

"C:\Program Files\MATLAB\R2014b\bin\matlab" -wait -nojvm -nosplash -nodesktop -minimize -logfile MATLAB.log -r "addpath('%curdir%');cannon2('cannon.inp');exit;"

REM  Post-process the simulation output to provide the repsonses to Dakota

MOVE cannon.out %2 > NUL 2>&1

Note: execute the MATLAB command matlabroot to determine the path to your MATLAB installation. It will be different than the one shown here (since this is the path on my computer).

Using Python
@echo off
SETLOCAL ENABLEEXTENSIONS

REM  What is the directory that I am currently in for use with simulation
REM  program execution of the model

SET curdir=%cd%

REM  Process the simulation input template file with dprepro to produce
REM  an input file for the simulation program

C:\ME498\perl\bin\perl.exe C:\ME498\dakota\bin\dprepro %1 cantilever.template cantilever.i

REM  Run the simulation program with the current input file

C:\ME498\python\python.exe cantilever.py cantilever.i > cantilever.log

REM  Post-process the simulation output to provide the repsonses to Dakota

C:\ME498\gnuwin32\bin\tail -15 cantilever.log | C:\ME498\gnuwin32\bin\head -1 | C:\ME498\gnuwin32\bin\awk "{print $1}"  > %2
C:\ME498\gnuwin32\bin\tail -11 cantilever.log | C:\ME498\gnuwin32\bin\head -1 | C:\ME498\gnuwin32\bin\awk "{print $1}" >> %2
C:\ME498\gnuwin32\bin\tail  -7 cantilever.log | C:\ME498\gnuwin32\bin\head -1 | C:\ME498\gnuwin32\bin\awk "{print $1}" >> %2
Using R
@echo off
SETLOCAL ENABLEEXTENSIONS

REM  What is the directory that I am currently in for use with simulation
REM  program execution of the model

SET curdir=%cd%

REM  Process the simulation input template file with dprepro to produce
REM  an input file for the simulation program

C:\ME498\perl\bin\perl.exe c:\me498\dakota\bin\dprepro %1 cannon.template cannon.inp

REM  Run the simulation program with the current input file

C:\ME498\R\bin\Rscript cannon2.R

REM  Post-process the simulation output to provide the repsonses to Dakota

MOVE cannon.out %2 > NUL 2>&1

bash Shell Script (Linux/Mac OS X)

Using Octave
#!/bin/bash

# $1 and $2 are special variables in bash that contain the 1st and 2nd 
# command line arguments to the script, which are the names of the
# Dakota parameters and results files, respectively.

params=$1
results=$2

############################################################################### 
##
## Pre-processing Phase -- Generate/configure an input file for your simulation 
##  by substiting in parameter values from the Dakota paramters file.
##
###############################################################################

dprepro $params cantilever.template cantilever.i

############################################################################### 
##
## Execution Phase -- Run your simulation
##
###############################################################################

octave --no-gui --silent --path ~/ME498/mcantilever --eval "cantilever('cantilever.i')"

############################################################################### 
##
## Post-processing Phase -- Extract (or calculate) quantities of interest
##  from your simulation's output and write them to a properly-formatted
##  Dakota results file.
##
###############################################################################

mv cannon.out $results
Using MATLAB
Using Python
#!/bin/bash

# $1 and $2 are special variables in bash that contain the 1st and 2nd 
# command line arguments to the script, which are the names of the
# Dakota parameters and results files, respectively.

params=$1
results=$2

############################################################################### 
##
## Pre-processing Phase -- Generate/configure an input file for your simulation 
##  by substiting in parameter values from the Dakota paramters file.
##
###############################################################################

dprepro $params cantilever.template cantilever.i

############################################################################### 
##
## Execution Phase -- Run your simulation
##
###############################################################################

./cantilever cantilever.i > cantilever.log

############################################################################### 
##
## Post-processing Phase -- Extract (or calculate) quantities of interest
##  from your simulation's output and write them to a properly-formatted
##  Dakota results file.
##
###############################################################################

mass=$(tail -15 cantilever.log | head -1 | awk '{print $1}')
stress=$(tail -11 cantilever.log | head -1 | awk '{print $1}')
displacement=$(tail -7 cantilever.log | head -1 | awk '{print $1}')

echo "$mass mass" > $results
echo "$stress stress" >> $results
echo "$displacement displacement" >> $results
Using R
#!/bin/bash

# $1 and $2 are special variables in bash that contain the 1st and 2nd 
# command line arguments to the script, which are the names of the
# Dakota parameters and results files, respectively.

params=$1
results=$2

############################################################################### 
##
## Pre-processing Phase -- Generate/configure an input file for your simulation 
##  by substiting in parameter values from the Dakota paramters file.
##
###############################################################################

dprepro $params cantilever.template cantilever.i

############################################################################### 
##
## Execution Phase -- Run your simulation
##
###############################################################################

Rscript cannon2.R

############################################################################### 
##
## Post-processing Phase -- Extract (or calculate) quantities of interest
##  from your simulation's output and write them to a properly-formatted
##  Dakota results file.
##
###############################################################################

mv cannon.out $results

Dakota interface block for Parallel Execution

For multicore computers (such as the Intel i7) do not specify more than the number of threads that are supported. For the snippet shown here it is an i7/4 core machine with 8 threads, so no more than 8 for the evaluation_concurrency. On my Windows machine at the command prompt:

> WMIC CPU Get DeviceID,NumberOfCores,NumberOfLogicalProcessors
DeviceID  NumberOfCores  NumberOfLogicalProcessors
CPU0      4              8

will return the number of physical cores and the number of threads that the CPU has. See Dakota Training: Parallelism and the associated video, as well as Chapter 17 in the Dakota User's Manual.

interface
  fork 
    analysis_drivers = 'mdriver.cmd'  # MATLAB/Octave program driver script for Windows
    parameters_file  = 'params.in'
    results_file     = 'results.out'
#    file_save
    asynchronous
      evaluation_concurrency = 8
      work_directory named = 'rundir'
      directory_tag
      copy_files = 'cannon.template' 'cannon2.m' 'mdriver.cmd'
#      directory_save

The associated mdriver.cmd script is:

@echo off
SETLOCAL ENABLEEXTENSIONS

REM  What is the directory that I am currently in for use with simulation
REM  program execution of the model

SET curdir=%cd%

REM  Process the simulation input template file with dprepro to produce
REM  an input file for the simulation program

C:\ME498\perl\bin\perl.exe c:\me498\dakota\bin\dprepro %1 cannon.template cannon.inp

REM  Run the simulation program with the current input file

C:\ME498\octave\bin\octave-cli --silent --path %curdir% --eval "cannon2('cannon.inp');" > NUL 2>&1

REM  Post-process the simulation output to provide the repsonses to Dakota

MOVE cannon.out %2 > NUL 2>&1

Note: the use of the SET curdir=%cd% command to set the path for executing Octave. Dakota will create a working directory, then cd into it to execute the simulation script. Hence, the need to copy the files needed to run your simulation into each working directory (see copy_files) and the dynamic detection of the current directory that Dakota is using to execute your program.


Links to Similar Courses


Books and References of Interest

2000
[HM00] Probability, Reliability, and Statistical Methods in Engineering Design, A. Haldar, S. Mahadevan, John Wiley & Sons, 2000, UW Library
2009
[Ate09] Everyday Heat Transfer Problems: Sensitivities to Governing Variables, M. Kemal Atesmen, ASME, 2009, UW Library
[CS09] Experimentation, Validation and Uncertainty Analysis for Engineers, third edition, Coleman and Steele, John Wiley & Sons, 2009, UW Library
2014
[MR14] Applied Statistics and Probability for Engineers, sixth edition, D. Montgomery and G. Runger, John Wiley & Sons, 2014, textbook for UW IND E 315, UW Library
[Smi14] Uncertainty Quantification: Theory, Implementation, and Applications, Ralph Smith, SIAM, 2014, UW Library
[VE14] Forensic Metrology: Scientific Measurement and Inference for Lawyers, Judges, and Criminalists, Ted Vosk and Ashley Emery, CRC Press, 2014, UW Library
2016
[GHO16] Handbook of Uncertainty Quantification, Editors: Roger Ghanem, David Higdon and Houman Owhadi, Springer, 2016

Last Modified by Bob Cochran, on June 1, 2017