uqtopus 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uqtopus-0.1.0/.gitignore +69 -0
- uqtopus-0.1.0/LICENSE +21 -0
- uqtopus-0.1.0/PKG-INFO +224 -0
- uqtopus-0.1.0/README.md +178 -0
- uqtopus-0.1.0/assets/simulator_wrapper.png +0 -0
- uqtopus-0.1.0/assets/uqtopus.png +0 -0
- uqtopus-0.1.0/assets/uqtopus_raster.png +0 -0
- uqtopus-0.1.0/examples/01_hello_uq_world.ipynb +1604 -0
- uqtopus-0.1.0/examples/02_random_field.ipynb +1598 -0
- uqtopus-0.1.0/examples/03_emulator.ipynb +2101 -0
- uqtopus-0.1.0/examples/config_01.yml +6 -0
- uqtopus-0.1.0/examples/config_03.yml +10 -0
- uqtopus-0.1.0/examples/config_03_cylinder.yml +8 -0
- uqtopus-0.1.0/examples/templates/cavity/0/U +39 -0
- uqtopus-0.1.0/examples/templates/cavity/0/epsilon +40 -0
- uqtopus-0.1.0/examples/templates/cavity/0/k +40 -0
- uqtopus-0.1.0/examples/templates/cavity/0/nuTilda +38 -0
- uqtopus-0.1.0/examples/templates/cavity/0/nut +40 -0
- uqtopus-0.1.0/examples/templates/cavity/0/omega +40 -0
- uqtopus-0.1.0/examples/templates/cavity/0/p +38 -0
- uqtopus-0.1.0/examples/templates/cavity/Allrun +10 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/momentumTransport +37 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/polyMesh/boundary +42 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/polyMesh/faces +1663 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/polyMesh/neighbour +784 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/polyMesh/owner +1664 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/polyMesh/points +905 -0
- uqtopus-0.1.0/examples/templates/cavity/constant/transportProperties +21 -0
- uqtopus-0.1.0/examples/templates/cavity/system/blockMeshDict +74 -0
- uqtopus-0.1.0/examples/templates/cavity/system/controlDict +48 -0
- uqtopus-0.1.0/examples/templates/cavity/system/fvSchemes +56 -0
- uqtopus-0.1.0/examples/templates/cavity/system/fvSolution +52 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/0/U +54 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/0/p +54 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/Allrun +10 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/constant/momentumTransport +29 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/constant/transportProperties +21 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/system/blockMeshDict +213 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/system/controlDict +48 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/system/fvSchemes +51 -0
- uqtopus-0.1.0/examples/templates/offsetCylinder/system/fvSolution +53 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/0/T +49 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/0/U +12275 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/Allrun +12 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/constant/transportProperties +20 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/system/controlDict +48 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/system/fvSchemes +50 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoam/system/fvSolution +34 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/0/T +49 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/0/U +53 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/Allrun +11 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/constant/polyMesh/boundary +54 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/constant/polyMesh/faces +49203 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/constant/polyMesh/neighbour +24194 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/constant/polyMesh/owner +49204 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/constant/polyMesh/points +25035 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/constant/transportProperties +20 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/log.blockMesh +93 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/system/controlDict +48 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/system/fvSchemes +50 -0
- uqtopus-0.1.0/examples/templates/scalarTransportFoamVelocity/system/fvSolution +34 -0
- uqtopus-0.1.0/pyproject.toml +34 -0
- uqtopus-0.1.0/requirements.txt +15 -0
- uqtopus-0.1.0/setup.py +18 -0
- uqtopus-0.1.0/src/uqtopus/__init__.py +18 -0
- uqtopus-0.1.0/src/uqtopus/core/__init__.py +8 -0
- uqtopus-0.1.0/src/uqtopus/core/sampling.py +40 -0
- uqtopus-0.1.0/src/uqtopus/core/uq_runner.py +270 -0
- uqtopus-0.1.0/src/uqtopus/utils/__init__.py +6 -0
- uqtopus-0.1.0/src/uqtopus/utils/openfoam_tools.py +233 -0
uqtopus-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Prerequisites
|
|
2
|
+
*.d
|
|
3
|
+
|
|
4
|
+
# Compiled Object files
|
|
5
|
+
*.slo
|
|
6
|
+
*.lo
|
|
7
|
+
*.o
|
|
8
|
+
*.obj
|
|
9
|
+
|
|
10
|
+
# Precompiled Headers
|
|
11
|
+
*.gch
|
|
12
|
+
*.pch
|
|
13
|
+
|
|
14
|
+
# Compiled Dynamic libraries
|
|
15
|
+
*.so
|
|
16
|
+
*.dylib
|
|
17
|
+
*.dll
|
|
18
|
+
|
|
19
|
+
# Fortran module files
|
|
20
|
+
*.mod
|
|
21
|
+
*.smod
|
|
22
|
+
|
|
23
|
+
# Compiled Static libraries
|
|
24
|
+
*.lai
|
|
25
|
+
*.la
|
|
26
|
+
*.a
|
|
27
|
+
*.lib
|
|
28
|
+
|
|
29
|
+
# Executables
|
|
30
|
+
*.exe
|
|
31
|
+
*.out
|
|
32
|
+
*.app
|
|
33
|
+
|
|
34
|
+
# Jupyter Notebook
|
|
35
|
+
.ipynb_checkpoints
|
|
36
|
+
|
|
37
|
+
# IPython
|
|
38
|
+
profile_default/
|
|
39
|
+
ipython_config.py
|
|
40
|
+
|
|
41
|
+
**/data/
|
|
42
|
+
|
|
43
|
+
# my folder for uq experiments
|
|
44
|
+
experiments/*
|
|
45
|
+
*/experiments/*
|
|
46
|
+
|
|
47
|
+
.env
|
|
48
|
+
.vscode/
|
|
49
|
+
|
|
50
|
+
# Installer logs
|
|
51
|
+
pip-log.txt
|
|
52
|
+
pip-delete-this-directory.txt
|
|
53
|
+
|
|
54
|
+
# Python cache/bytecode
|
|
55
|
+
__pycache__/
|
|
56
|
+
*.py[cod]
|
|
57
|
+
*$py.class
|
|
58
|
+
|
|
59
|
+
# Distribution / packaging
|
|
60
|
+
*.egg
|
|
61
|
+
*.egg-info/
|
|
62
|
+
dist/
|
|
63
|
+
build/
|
|
64
|
+
eggs/
|
|
65
|
+
parts/
|
|
66
|
+
var/
|
|
67
|
+
wheels/
|
|
68
|
+
pip-wheel-metadata/
|
|
69
|
+
share/python-wheels/
|
uqtopus-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gabriel Brandão de Miranda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
uqtopus-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uqtopus
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Uncertainty Quantification Toolbox for OpenFOAM and Python Unified Simulation workflows
|
|
5
|
+
Author-email: Gabriel Brandao de Miranda <gabrielbrandaodemiranda@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Gabriel Brandão de Miranda
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: fluidfoam<0.3.0,>=0.2.9
|
|
29
|
+
Requires-Dist: jinja2<4.0.0,>=3.1.6
|
|
30
|
+
Requires-Dist: numpy<2.0.0,>=1.21.0
|
|
31
|
+
Requires-Dist: pydoe3<2.0.0,>=1.2.0
|
|
32
|
+
Requires-Dist: pyyaml<7.0.0,>=6.0.2
|
|
33
|
+
Requires-Dist: tqdm<5.0.0,>=4.66.5
|
|
34
|
+
Requires-Dist: xarray<2026.0.0,>=2024.6.0
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: ipython; extra == 'dev'
|
|
37
|
+
Requires-Dist: uv>=0.1.0; extra == 'dev'
|
|
38
|
+
Provides-Extra: test
|
|
39
|
+
Requires-Dist: ipython; extra == 'test'
|
|
40
|
+
Requires-Dist: matplotlib>=3.5.0; extra == 'test'
|
|
41
|
+
Requires-Dist: pytest; extra == 'test'
|
|
42
|
+
Requires-Dist: python-dotenv>=1.1.1; extra == 'test'
|
|
43
|
+
Requires-Dist: setuptools>=75.1.0; extra == 'test'
|
|
44
|
+
Requires-Dist: uqpylab>=1.0.2; extra == 'test'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
<div align="center">
|
|
48
|
+
<img src="assets/uqtopus.png" alt="UQTOPUS Logo" width="128" height="128">
|
|
49
|
+
<h1>UQTOPUS</h1>
|
|
50
|
+
<p><b>U</b>ncertainty <b>Q</b>uantification <b>T</b>oolbox for <b>O</b>penFOAM and <b>P</b>ython <b>U</b>nified <b>S</b>imulation workflows<br></p>
|
|
51
|
+
|
|
52
|
+
[](https://opensource.org/licenses/MIT)
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
UQTOPUS is a Python framework for uncertainty quantification (UQ) studies with OpenFOAM CFD simulations
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
<img src="assets/simulator_wrapper.png" alt="Simulator wrapper overview" width="600">
|
|
61
|
+
|
|
62
|
+
Built on top of `Jinja2`, `xarray` and `fluidfoam`.
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- End-to-end UQ workflow: sample → render cases → run → collect → analyze
|
|
67
|
+
- OpenFOAM-native integration: Jinja2-templated dictionaries and Allrun orchestration
|
|
68
|
+
- Parallel execution built-in support for sampled scenarios
|
|
69
|
+
- Reproducible experiment management and basic statistics with CSV/NumPy-friendly outputs
|
|
70
|
+
- Extensible hooks for surrogate modeling with `uqpylab` (https://uqpylab.uq-cloud.io/) and custom post-processing
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
### OpenFOAM Installation
|
|
75
|
+
|
|
76
|
+
For Ubuntu/Debian systems:
|
|
77
|
+
```bash
|
|
78
|
+
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
|
|
79
|
+
sudo add-apt-repository http://dl.openfoam.org/ubuntu
|
|
80
|
+
sudo apt-get update
|
|
81
|
+
sudo apt-get -y install openfoam9
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Source OpenFOAM environment:
|
|
85
|
+
```bash
|
|
86
|
+
source /opt/openfoam9/etc/bashrc
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For other systems, visit: https://openfoam.org/download/
|
|
90
|
+
|
|
91
|
+
### Requirements
|
|
92
|
+
|
|
93
|
+
- Python 3.9+
|
|
94
|
+
- OpenFOAM 9+ (for running actual simulations)
|
|
95
|
+
|
|
96
|
+
### Setup
|
|
97
|
+
|
|
98
|
+
1. Install Python package:
|
|
99
|
+
```bash
|
|
100
|
+
pip install uqtopus
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
2. Ensure OpenFOAM is installed and sourced:
|
|
104
|
+
```bash
|
|
105
|
+
source /opt/openfoam9/etc/bashrc # Adjust path as needed
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Basic Usage
|
|
109
|
+
|
|
110
|
+
- Set a config file:
|
|
111
|
+
```yaml
|
|
112
|
+
# config.yaml
|
|
113
|
+
output_path: experiments/myUQStudy
|
|
114
|
+
input_path: templates/templateSimulation
|
|
115
|
+
solver: mySolverScript
|
|
116
|
+
parameter_ranges:
|
|
117
|
+
[folder_path]__[file_name]__[param_name]: [0.01, 0.3]
|
|
118
|
+
nthreads: 2
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- Templatize the simulation file with the desired variables in Jinja2 format (double curly braces):
|
|
122
|
+
```
|
|
123
|
+
...
|
|
124
|
+
FoamFile
|
|
125
|
+
{
|
|
126
|
+
format ascii;
|
|
127
|
+
class dictionary;
|
|
128
|
+
location "constant";
|
|
129
|
+
object transportProperties;
|
|
130
|
+
}
|
|
131
|
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
132
|
+
|
|
133
|
+
param1 {{param1}};
|
|
134
|
+
param2 {{param2}};
|
|
135
|
+
param3 {{param3}};
|
|
136
|
+
...
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- Set the solver script:
|
|
140
|
+
```bash
|
|
141
|
+
#!/bin/bash
|
|
142
|
+
cd ${0%/*} || exit 1 # Run from this directory
|
|
143
|
+
|
|
144
|
+
# Source tutorial run functions
|
|
145
|
+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
|
146
|
+
|
|
147
|
+
runApplication blockMesh
|
|
148
|
+
runApplication $(getApplication)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- Run a UQ study:
|
|
152
|
+
```python
|
|
153
|
+
import uqtopus as uqt
|
|
154
|
+
config = 'config.yaml'
|
|
155
|
+
uqt.run_uq_study(config, n_samples=50)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
For more information on configuring and running UQ studies, please refer to the example notebooks.
|
|
159
|
+
|
|
160
|
+
## Directory Structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
UQTOPUS/
|
|
164
|
+
├── src/ # Python package
|
|
165
|
+
├── examples/ # Example of usage with scripts and templates
|
|
166
|
+
│ ├── templates/ # OpenFOAM case templates
|
|
167
|
+
│ │ └── base_case/ # Base case with Jinja2 placeholders
|
|
168
|
+
│ │ ├── constant/
|
|
169
|
+
│ │ ├── system/
|
|
170
|
+
│ │ ├── 0/
|
|
171
|
+
│ │ └── [script_file] # Run script (e.g., Allrun)
|
|
172
|
+
│ ├── experiments/ # UQ study results
|
|
173
|
+
│ │ └── [study_name]/ # Individual study results
|
|
174
|
+
│ │ ├── sample_001/ # OpenFOAM case for sample 1
|
|
175
|
+
│ │ ├── sample_002/ # OpenFOAM case for sample 2
|
|
176
|
+
│ │ └── ...
|
|
177
|
+
│ └── config.yaml # Configuration file for examples
|
|
178
|
+
└── README.md # This file
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Configuring a template case
|
|
182
|
+
|
|
183
|
+
1) Add Jinja2 placeholders in OpenFOAM dictionaries where parameters vary.
|
|
184
|
+
- Example (constant/transportProperties):
|
|
185
|
+
```foam
|
|
186
|
+
transportModel {{ transportModel | default('Newtonian') }};
|
|
187
|
+
nu [0 2 -1 0 0 0 0] {{ nu | default(1e-5) }};
|
|
188
|
+
```
|
|
189
|
+
- Example with conditionals (constant/turbulenceProperties):
|
|
190
|
+
```foam
|
|
191
|
+
simulationType RAS;
|
|
192
|
+
RAS
|
|
193
|
+
{
|
|
194
|
+
RASModel {% if turbulence == "kEpsilon" %}kEpsilon{% else %}kOmegaSST{% endif %};
|
|
195
|
+
turbulence on;
|
|
196
|
+
printCoeffs on;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
- Jinja tips:
|
|
200
|
+
- Use default: {{ var|default(1.0) }}
|
|
201
|
+
- Use rounding: {{ diameter|round(5) }}
|
|
202
|
+
- Use conditionals/loops for switching models or patch sets.
|
|
203
|
+
|
|
204
|
+
2) Provide a run script in the template root (e.g., templates/base_case/Allrun). Keep it non-templated.
|
|
205
|
+
- Minimal example (mesh + solver):
|
|
206
|
+
```bash
|
|
207
|
+
cd ${0%/*} || exit 1 # Run from this directory
|
|
208
|
+
|
|
209
|
+
# Source tutorial run functions
|
|
210
|
+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
|
211
|
+
|
|
212
|
+
runApplication blockMesh
|
|
213
|
+
runApplication $(getApplication)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
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.
|
|
217
|
+
|
|
218
|
+
## Examples
|
|
219
|
+
|
|
220
|
+
See `examples` folder for notebooks with workflow demonstrations.
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT License - see LICENSE file for details.
|
uqtopus-0.1.0/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="assets/uqtopus.png" alt="UQTOPUS Logo" width="128" height="128">
|
|
3
|
+
<h1>UQTOPUS</h1>
|
|
4
|
+
<p><b>U</b>ncertainty <b>Q</b>uantification <b>T</b>oolbox for <b>O</b>penFOAM and <b>P</b>ython <b>U</b>nified <b>S</b>imulation workflows<br></p>
|
|
5
|
+
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
UQTOPUS is a Python framework for uncertainty quantification (UQ) studies with OpenFOAM CFD simulations
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
<img src="assets/simulator_wrapper.png" alt="Simulator wrapper overview" width="600">
|
|
15
|
+
|
|
16
|
+
Built on top of `Jinja2`, `xarray` and `fluidfoam`.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- End-to-end UQ workflow: sample → render cases → run → collect → analyze
|
|
21
|
+
- OpenFOAM-native integration: Jinja2-templated dictionaries and Allrun orchestration
|
|
22
|
+
- Parallel execution built-in support for sampled scenarios
|
|
23
|
+
- Reproducible experiment management and basic statistics with CSV/NumPy-friendly outputs
|
|
24
|
+
- Extensible hooks for surrogate modeling with `uqpylab` (https://uqpylab.uq-cloud.io/) and custom post-processing
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
### OpenFOAM Installation
|
|
29
|
+
|
|
30
|
+
For Ubuntu/Debian systems:
|
|
31
|
+
```bash
|
|
32
|
+
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
|
|
33
|
+
sudo add-apt-repository http://dl.openfoam.org/ubuntu
|
|
34
|
+
sudo apt-get update
|
|
35
|
+
sudo apt-get -y install openfoam9
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Source OpenFOAM environment:
|
|
39
|
+
```bash
|
|
40
|
+
source /opt/openfoam9/etc/bashrc
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For other systems, visit: https://openfoam.org/download/
|
|
44
|
+
|
|
45
|
+
### Requirements
|
|
46
|
+
|
|
47
|
+
- Python 3.9+
|
|
48
|
+
- OpenFOAM 9+ (for running actual simulations)
|
|
49
|
+
|
|
50
|
+
### Setup
|
|
51
|
+
|
|
52
|
+
1. Install Python package:
|
|
53
|
+
```bash
|
|
54
|
+
pip install uqtopus
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2. Ensure OpenFOAM is installed and sourced:
|
|
58
|
+
```bash
|
|
59
|
+
source /opt/openfoam9/etc/bashrc # Adjust path as needed
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Basic Usage
|
|
63
|
+
|
|
64
|
+
- Set a config file:
|
|
65
|
+
```yaml
|
|
66
|
+
# config.yaml
|
|
67
|
+
output_path: experiments/myUQStudy
|
|
68
|
+
input_path: templates/templateSimulation
|
|
69
|
+
solver: mySolverScript
|
|
70
|
+
parameter_ranges:
|
|
71
|
+
[folder_path]__[file_name]__[param_name]: [0.01, 0.3]
|
|
72
|
+
nthreads: 2
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- Templatize the simulation file with the desired variables in Jinja2 format (double curly braces):
|
|
76
|
+
```
|
|
77
|
+
...
|
|
78
|
+
FoamFile
|
|
79
|
+
{
|
|
80
|
+
format ascii;
|
|
81
|
+
class dictionary;
|
|
82
|
+
location "constant";
|
|
83
|
+
object transportProperties;
|
|
84
|
+
}
|
|
85
|
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
86
|
+
|
|
87
|
+
param1 {{param1}};
|
|
88
|
+
param2 {{param2}};
|
|
89
|
+
param3 {{param3}};
|
|
90
|
+
...
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- Set the solver script:
|
|
94
|
+
```bash
|
|
95
|
+
#!/bin/bash
|
|
96
|
+
cd ${0%/*} || exit 1 # Run from this directory
|
|
97
|
+
|
|
98
|
+
# Source tutorial run functions
|
|
99
|
+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
|
100
|
+
|
|
101
|
+
runApplication blockMesh
|
|
102
|
+
runApplication $(getApplication)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- Run a UQ study:
|
|
106
|
+
```python
|
|
107
|
+
import uqtopus as uqt
|
|
108
|
+
config = 'config.yaml'
|
|
109
|
+
uqt.run_uq_study(config, n_samples=50)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
For more information on configuring and running UQ studies, please refer to the example notebooks.
|
|
113
|
+
|
|
114
|
+
## Directory Structure
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
UQTOPUS/
|
|
118
|
+
├── src/ # Python package
|
|
119
|
+
├── examples/ # Example of usage with scripts and templates
|
|
120
|
+
│ ├── templates/ # OpenFOAM case templates
|
|
121
|
+
│ │ └── base_case/ # Base case with Jinja2 placeholders
|
|
122
|
+
│ │ ├── constant/
|
|
123
|
+
│ │ ├── system/
|
|
124
|
+
│ │ ├── 0/
|
|
125
|
+
│ │ └── [script_file] # Run script (e.g., Allrun)
|
|
126
|
+
│ ├── experiments/ # UQ study results
|
|
127
|
+
│ │ └── [study_name]/ # Individual study results
|
|
128
|
+
│ │ ├── sample_001/ # OpenFOAM case for sample 1
|
|
129
|
+
│ │ ├── sample_002/ # OpenFOAM case for sample 2
|
|
130
|
+
│ │ └── ...
|
|
131
|
+
│ └── config.yaml # Configuration file for examples
|
|
132
|
+
└── README.md # This file
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Configuring a template case
|
|
136
|
+
|
|
137
|
+
1) Add Jinja2 placeholders in OpenFOAM dictionaries where parameters vary.
|
|
138
|
+
- Example (constant/transportProperties):
|
|
139
|
+
```foam
|
|
140
|
+
transportModel {{ transportModel | default('Newtonian') }};
|
|
141
|
+
nu [0 2 -1 0 0 0 0] {{ nu | default(1e-5) }};
|
|
142
|
+
```
|
|
143
|
+
- Example with conditionals (constant/turbulenceProperties):
|
|
144
|
+
```foam
|
|
145
|
+
simulationType RAS;
|
|
146
|
+
RAS
|
|
147
|
+
{
|
|
148
|
+
RASModel {% if turbulence == "kEpsilon" %}kEpsilon{% else %}kOmegaSST{% endif %};
|
|
149
|
+
turbulence on;
|
|
150
|
+
printCoeffs on;
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
- Jinja tips:
|
|
154
|
+
- Use default: {{ var|default(1.0) }}
|
|
155
|
+
- Use rounding: {{ diameter|round(5) }}
|
|
156
|
+
- Use conditionals/loops for switching models or patch sets.
|
|
157
|
+
|
|
158
|
+
2) Provide a run script in the template root (e.g., templates/base_case/Allrun). Keep it non-templated.
|
|
159
|
+
- Minimal example (mesh + solver):
|
|
160
|
+
```bash
|
|
161
|
+
cd ${0%/*} || exit 1 # Run from this directory
|
|
162
|
+
|
|
163
|
+
# Source tutorial run functions
|
|
164
|
+
. $WM_PROJECT_DIR/bin/tools/RunFunctions
|
|
165
|
+
|
|
166
|
+
runApplication blockMesh
|
|
167
|
+
runApplication $(getApplication)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
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.
|
|
171
|
+
|
|
172
|
+
## Examples
|
|
173
|
+
|
|
174
|
+
See `examples` folder for notebooks with workflow demonstrations.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT License - see LICENSE file for details.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|