Skip to main content

Uncertainty Quantification Toolbox for OpenFOAM and Python Unified Simulation workflows

Project description

UQTOPUS Logo

UQTOPUS

Uncertainty Quantification Toolbox for OpenFOAM and Python Unified Simulation

License: MIT

UQTOPUS is a Python framework for uncertainty quantification (UQ) studies with OpenFOAM CFD simulations. It automates sampling, case templating, execution, and results analysis to enable reproducible and scalable UQ experiments. The pipeline is designed to be extensible, including hooks for surrogate modeling and custom post-processing around OpenFOAM runs.

Ultimately, this project aims to enable the usage of OpenFOAM simulator to perform efficient and automated uncertainty quantification studies aided by surrogate modeling techniques wrapping the OpenFOAM simulation process.

Simulator wrapper overview

Built on top of Jinja2, xarray and fluidfoam.

Features

  • End-to-end UQ workflow: sample → render cases → run → collect → analyze
  • OpenFOAM-native integration: Jinja2-templated dictionaries and Allrun orchestration
  • Parallel execution built-in support for sampled scenarios
  • Reproducible experiment management and basic statistics with CSV/NumPy-friendly outputs
  • Extensible hooks for surrogate modeling with uqpylab (https://uqpylab.uq-cloud.io/) and custom post-processing

Installation

OpenFOAM Installation

For Ubuntu/Debian systems:

sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo apt-get update
sudo apt-get -y install openfoam9

Source OpenFOAM environment:

source /opt/openfoam9/etc/bashrc

For other systems, visit: https://openfoam.org/download/

Requirements

  • Python 3.9+
  • OpenFOAM 9+ (for running actual simulations)

Setup

  1. Install Python package:

    pip install uqtopus
    
  2. Ensure OpenFOAM is installed and sourced:

    source /opt/openfoam9/etc/bashrc  # Adjust path as needed
    

Basic Usage

  • Set a config file:
# config.yaml
output_path: experiments/myUQStudy
input_path: templates/templateSimulation
solver: mySolverScript
parameter_ranges:
  [folder_path]__[file_name]__[param_name]: [0.01, 0.3]
nthreads: 2
  • Templatize the simulation file with the desired variables in Jinja2 format (double curly braces):
...
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

param1              {{param1}};
param2              {{param2}};
param3              {{param3}};
...
  • Set the solver script:
#!/bin/bash
cd ${0%/*} || exit 1    # Run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

runApplication blockMesh
runApplication $(getApplication)
  • Run a UQ study:
import uqtopus as uqt
config = 'config.yaml'
uqt.run_uq_study(config, n_samples=50)

For more information on configuring and running UQ studies, please refer to the example notebooks.

Directory Structure

UQTOPUS/
├── src/                      # Python package
├── examples/                 # Example of usage with scripts and templates
│   ├── templates/            # OpenFOAM case templates
│   │   └── base_case/        # Base case with Jinja2 placeholders
│   │       ├── constant/
│   │       ├── system/
│   │       ├── 0/
│   │       └── [script_file]     # Run script (e.g., Allrun)
│   ├── experiments/          # UQ study results
│   │   └── [study_name]/     # Individual study results
│   │       ├── sample_001/   # OpenFOAM case for sample 1
│   │       ├── sample_002/   # OpenFOAM case for sample 2
│   │       └── ...
│   └── config.yaml           # Configuration file for examples
└── README.md                 # This file

Configuring a template case

  1. Add Jinja2 placeholders in OpenFOAM dictionaries where parameters vary.

    • Example (constant/transportProperties):
      transportModel  {{ transportModel | default('Newtonian') }};
      nu              [0 2 -1 0 0 0 0] {{ nu | default(1e-5) }};
      
    • Example with conditionals (constant/turbulenceProperties):
      simulationType RAS;
      RAS
      {
        RASModel      {% if turbulence == "kEpsilon" %}kEpsilon{% else %}kOmegaSST{% endif %};
        turbulence    on;
        printCoeffs   on;
      }
      
    • Jinja tips:
      • Use default: {{ var|default(1.0) }}
      • Use rounding: {{ diameter|round(5) }}
      • Use conditionals/loops for switching models or patch sets.
  2. Provide a run script in the template root (e.g., templates/base_case/Allrun). Keep it non-templated.

    • Minimal example (mesh + solver):
      cd ${0%/*} || exit 1    # Run from this directory
      
      # Source tutorial run functions
      . $WM_PROJECT_DIR/bin/tools/RunFunctions
      
      runApplication blockMesh
      runApplication $(getApplication)
      
  3. Place the template under templates directory to ensure organization with standard OpenFOAM layout (0/, constant/, system/). The UQ runner will render the Jinja placeholders per sample and invoke your run script.

Examples

See examples folder for notebooks with workflow demonstrations.

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uqtopus-0.2.0.tar.gz (5.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uqtopus-0.2.0-py2.py3-none-any.whl (20.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file uqtopus-0.2.0.tar.gz.

File metadata

  • Download URL: uqtopus-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for uqtopus-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8a14da65622a86cfea5d4443e97835053bfc1c7adadaa648e992404066a27c18
MD5 97fae26a9cbde07436f4523d22668ad7
BLAKE2b-256 2fb3e98ccbb805c210d0df067dbf27f2dfc47bf9b3b5727f99fb8079c9b0ae1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for uqtopus-0.2.0.tar.gz:

Publisher: publish.yml on GBdeMiranda/UQTOPUS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file uqtopus-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: uqtopus-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for uqtopus-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ebbc42edeb0e7bb1cd2597aceedf7a1423949b858ec7633c424515807024ae53
MD5 faad0936947827a2102ac4901c5d4201
BLAKE2b-256 59ac8f7c70642c3c54764eb6c78223abf3a7ec0177c255ed0d7ef9e359231ee0

See more details on using hashes here.

Provenance

The following attestation bundles were made for uqtopus-0.2.0-py2.py3-none-any.whl:

Publisher: publish.yml on GBdeMiranda/UQTOPUS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page