Code Monkey home page Code Monkey logo

uqtk's Introduction

Sandia National Labs

Uncertainty Quantification Toolkit (UQTk) version 3.1.4

Bert Debusschere, Caitlin Curry, Cosmin Safta, Katherine Johnston, Kenny Chowdhary, Khachik Sargsyan, Luke Boll, Mohammad Khalil, Prashant Rai, Tiernan Casey, Xiaoshu Zeng

Overview

The UQ Toolkit (UQTk) is a collection of libraries and tools for the quantification of uncertainty in numerical model predictions. Version 3.1.4 offers Polynomial Chaos Expansions to represent random variables, intrusive and non-intrusive methods for propagating uncertainties through computational models, tools for sensitivity analysis, methods for sparse surrogate construction, and Bayesian inference tools for inferring parameters and model uncertainties from experimental data.

Documentation

For documentation on how to install and use UQTk, please refer to the manual, which is included as a PDF file in the directory docs/UQTk_manual.pdf. For more detailed documentation on the actual source code for development purposes, please refer to the C++ doxygen documentation. If you are familiar with UQTk and would like just a high level overview of where to find everything and how to install, see the sections on Directory Structure and Installation below.

Directory Structure

On a high level UQTk is organized as follows:

  • config: Example CMake configuration scripts
  • cpp/lib: Core C++ libraries
  • cpp/app: Standalone apps that make UQTk functionality available to the command line
  • cpp/tests: CMake Unit Tests
  • dep: Third party libraries that UQTk depends on
  • examples: short tutorial style examples that illustrate key UQTk capabilities
  • PyUQTk: Python wrappers for the core C++ libraries as well as additional Python tools

In many key directories, README files have been included to further lay out the contents of their subdirectories.

Capabilities

Below is a list of key UQTk capabilities, along with examples that illustrate those capabilities:

  • Intrusive Forward UQ: examples/ops (C++), examples/surf_rxn/SurfRxnISP.cpp (C++)
  • Non-Intrusive Forward UQ: examples/surf_rxn/SurfRxnNISP.cpp (C++), examples/fwd_prop (Python), examples/window (Python), examples/uqpc (Command Line/Python)
  • Non-Intrusive Surrogate Construction: examples/uqpc (Command Line/Python)
  • Bayesian Compressive Sensing (BCS): examples/pce_bcs (C++)
  • Global Sensitivity Analysis: examples/uqpc (Command Line/Python), examples/pce_bcs (C++), examples/sensMC (Command Line)
  • Bayesian Inference: examples/line_infer (C++), examples/iuq (Command Line/Python), examples/polynomial (Python)
  • Bayesian model selection: examples/polynomial (Python)
  • Transitional Markov chain Monte Carlo (TMCMC): examples/tmcmc_bimodal (C++/Python/Command Line)
  • Karhunen-Loève decompositions: examples/kle_ex1 (C++)
  • Data Free Inference (Inference based on summary statistics): examples/dfi (C++)
  • Forward Propagation with Basis Adaptation: examples/d_spring_series (Python)
  • Numerical Integration (Quadrature): examples/num_integ (Python)

For more details on these capabilities, please refer to the UQTk manual in PDF format.

Installation

To install UQTk, first create a build directory outside of the UQTk repository. From within the build directory, configure the distribution via CMake. See example CMake configuration scripts in the directory config Then build via make, and test with ctest. Install with make install For example:

% mkdir build
% cd build
% ../UQTk/config/config-gcc-Python.sh
% make -j 8
% ctest
% make install

For more details, please refer to the UQTk manual in PDF format.

How to Cite

To cite UQTk, please use the following publications:

@ARTICLE{DebusscherePCE:2004,
  author   =  {B.J. Debusschere and H.N. Najm and P.P. P\'ebay and O.M. Knio
               and R.G. Ghanem and O.P. {Le Ma{\^\i}tre}},
  title    =  {Numerical challenges in the use of polynomial chaos representations
               for stochastic processes},
  journal  =  {{SIAM} Journal on Scientific Computing},
  year     =  {2004},
  volume   =  {26},
  pages    =  {698-719},
  number   =  {2},
  url      =  {http://dx.doi.org/10.1137/S1064827503427741}
}

@InCollection{DebusschereUQTk:2017,
  author    = {B. Debusschere and K. Sargsyan and C. Safta and K. Chowdhary},
  title     = {The Uncertainty Quantification Toolkit (UQTk)},
  booktitle = {Handbook of Uncertainty Quantification},
  editor    = {R. Ghanem and D. Higdon and H. Owhadi},
  year      = {2017},
  pages     = {1807--1827},
  publisher = {Springer},
  url       = {http://www.springer.com/us/book/9783319123844}
}

Contact Us

For more information, visit the UQTk website at https://www.sandia.gov/UQToolkit/ or contact the UQTk developers through the github discussions site

uqtk's People

Contributors

bjdebus avatar csafta avatar ksargsyan avatar l-boll avatar lukeboll avatar mkhalil-sandia avatar mparno avatar pieterjanrobbe avatar tcaseysnl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uqtk's Issues

Improve ImportError messages

The import exception messages aren't always accurate. It would be better to have something like:

try:
    from . import bcs
except ImportError as ie:
    print('PyUQTk SWIG bcs interface not imported.', ie)

Comile UQTk with gcc-11

I was trying to compile UQTk on Mac with gcc-11, but it failed. But I have successfully compiled UQTk with gcc-10. Is there something I miss in the config file to compiled with gcc-11.

pytests out of date in release 3.1.2

Looks like minor changes to the pytests are necessary like changing import PyUQTk.array as uqtkarray to from PyUQTk import uqtkarray etc:

$ spack load [email protected] +pyuqtk
$ git clone --depth=1 https://github.com/sandialabs/UQTk.git -b v3.1.2
$ cd UQTk/PyUQTk/pytests/
$ for file in *.py; do echo "=== $file ==="; python3 $file 1>/dev/null; done
=== PyArrayTest2.py ===
=== PyArrayTest.py ===
=== PyBADPTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyBADPTest.py", line 137, in <module>
    pc_model0, c_k0, totquat0 = forward_propagation(mu, sigma, \
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyBADPTest.py", line 85, in forward_propagation
    qdpts, totquat= pce_tools.UQTkGetQuadPoints(pc_model)
NameError: name 'pce_tools' is not defined
=== PyBCSTest1D.py ===
=== PyBCSTest2D.py ===
=== PyBCSTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyBCSTest.py", line 105, in <module>
    regmodel = bcs.bcsreg(ndim=2,pcorder=pcorder,pctype="LU")
NameError: name 'bcs' is not defined
=== PyHMCMCTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyHMCMCTest.py", line 118, in <module>
    qz =  exp(-U(array(zip(qx.flatten(),qy.flatten()))))
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyHMCMCTest.py", line 57, in U
    return b*(q[:,1] - q[:,0]**2)**2 + (a - q[:,0])**2
IndexError: index 1 is out of bounds for axis 1 with size 1
=== PyMCMC2dTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyMCMC2dTest.py", line 52, in <module>
    class pyLikelihood(uqtkmcmc.LikelihoodBase):
NameError: name 'uqtkmcmc' is not defined
=== PyMCMCTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyMCMCTest.py", line 64, in <module>
    class pyLikelihood(uqtkmcmc.LikelihoodBase):
NameError: name 'uqtkmcmc' is not defined
=== PyModTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyModTest.py", line 52, in <module>
    import _tools
ImportError: /home/pnanda/spack/opt/spack/linux-ubuntu18.04-westmere/gcc-11.3.0/uqtk-3.1.2-kfxhs7iftxrsy5isacage3clpadbtteo/PyUQTk/_tools.cpython-39-x86_64-linux-gnu.so: undefined symbol: _gfortran_transfer_character_write
=== PyPCE1dTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyPCE1dTest.py", line 49, in <module>
    x = uqtkarray.dblArray2D()
NameError: name 'uqtkarray' is not defined
=== PyPCE2dTest.py ===
Traceback (most recent call last):
  File "/home/pnanda/src/UQTk/PyUQTk/pytests/PyPCE2dTest.py", line 49, in <module>
    x = uqtkarray.dblArray2D()
NameError: name 'uqtkarray' is not defined
=== PyQuadTest.py ===
$ grep import PyPCE1dTest.py 
from __future__ import print_function # To make print() in Python 2 behave like in Python 3
import sys
	from numpy import *
	from matplotlib.pyplot import *
	import PyUQTk.array as uqtkarray
	import PyUQTk.quad as uqtkquad
	import PyUQTk.pce as uqtkpce
$ python3
Python 3.9.13 (main, Jun 15 2022, 19:27:16) 
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyUQTk.array
Scipy and/or matplotlib may need to be installed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyUQTk.array'
>>> import PyUQTk.quad
>>> import PyUQTk.pce
>>> from numpy import *
>>> from matplotlib.pyplot import *
$ python3
Python 3.9.13 (main, Jun 15 2022, 19:27:16) 
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyUQTk import uqtkarray
Scipy and/or matplotlib may need to be installed
>>> 

About MSC in regression.cpp

Hi, I am a new user of UQTk (Downloading github file Apr. 3, 2024).
I downloaded this in WSL2-Ubuntu 22.04

I sucessfully downloaded UQTk and binded UQTk with Python.
Every test was passed.

After making 'UQTk-install', I connected this to Jupyter lab.
The problem was that I got some errors for *.ipynb files in the folder, "examples/dfi_app/", especially in this part.
"subprocess.run(shlex.split(f"{path_to_python} {path_to_uq_pc} -r offline_post -p param_ranges.dat -m lsq -n {xs.shape[0]} -s rand -t 2 -z"), cwd=tmp, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)"
When I run this, the error message showed me that
"[Errno 2] No such file or directory: '/home/theokim/UQTk-install/examples/dfi_app/results.pk'"

When I visit the "uq_pc.py" file, the initial "pred_mode" was "ms".
Here, my problem can be solved after changing initial "pred_mode" from "ms" - mean + std to "m" - mean.

If I run "regression" using terminal using "ms" or "msc",
./regression -l0 -x /home/theokim/UQTk-install/examples/dfi_app/xdata.dat -y /home/theokim/UQTk-install/examples/dfi_app/ydata.dat -b PC -p /home/theokim/UQTk-install/examples/dfi_app/mi.dat -m ms
or
./regression -l0 -x /home/theokim/UQTk-install/examples/dfi_app/xdata.dat -y /home/theokim/UQTk-install/examples/dfi_app/ydata.dat -b PC -p /home/theokim/UQTk-install/examples/dfi_app/mi.dat -m msc

The terminal output was like below. And the results showed "Segmentation fault" in the code.:
############
xfile = /home/theokim/UQTk-install/examples/dfi_app/xdata.dat
yfile = /home/theokim/UQTk-install/examples/dfi_app/ydata.dat
basistype = PC
method = lsq
intpar = 5
dblpar = 0
strpar = LU
msc = msc
Dimensionality 3
Number of bases 56
Segmentation fault
############

If I run "regression" using terminal using "m",
############
xfile = /home/theokim/UQTk-install/examples/dfi_app/xdata.dat
yfile = /home/theokim/UQTk-install/examples/dfi_app/ydata.dat
basistype = PC
method = lsq
intpar = 5
dblpar = 0
strpar = LU
msc = m
Dimensionality 3
Number of bases 56
LOO error : 7.85189e-08
GCV error : -5.06816e-09
############

I think there are some problems inside of the source code when running the "ms" or "msc" options.
Can you fix it for this? If this is fixed, it would be much helpful for using this !

Thank you so much for your help!

Taeho Kim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.