Skip to content

Commit

Permalink
Update docs, CI for cookie model
Browse files Browse the repository at this point in the history
* Update README.md

fixed latex error in mount directories \output

* Update README.md

fixed latex errors in mount directory \output and description

* Update README.md

fixed latex error in mount directories \output

* Update README.md

fixed latex errors in "Properties forward \output" and "Description" section

* Update README.md

fixed links of references, changed the bibliography to links (for consistency of other references)

* Update README.md

fixed one mistake (link in the overview)

* Update README.md

fixed brackets

* changed default fidelity 

changed default fidelity value from 1 to 7

* changed default fidelity

changed default fidelity value from 1 to 7

* changed default fidelity

changed default fidelity from 1 to 7

* add Julia server in supported languages

add Julia server in supported languages table

* Create cookies-problem-propagation

* Delete benchmarks/cookies-problem-propagation

* copied cookies-problem but changed folder name

copied cookies-problem but changed folder name, thus it is now in the propagation part

* add file run_forward_benchmark_in_matlab.m

* Delete benchmarks/cookies-problem directory

due to changing folder name directly not possible, added a copy of this folder but with "-propagation" in the folder name

* Update README.md

fixed latex errors, changed bibliography to links

* Create model-cookies-problem.yml

added CI for cookies problem model

* Update tutorial.rst

fixed a small typo
  • Loading branch information
marlenaweidenauer authored Apr 18, 2024
1 parent 7453be4 commit 2516924
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 58 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/model-cookies-problem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: model-cookies-problem

on:
push:
branches:
- 'main'

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2

-
name: Set up QEMU
uses: docker/setup-qemu-action@v1

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Build and push
uses: docker/build-push-action@v3
with:
context: models/cookies-problem/
push: true
tags: linusseelinger/cookies-problem:latest

test:
runs-on: ubuntu-latest
needs: build

services:
model:
image: linusseelinger/cookies-problem:latest
ports:
- 4242:4242

steps:
-
name: Validate
run: |
docker run --network=host -e model_host=http://localhost:4242 linusseelinger/testing-protocol-conformity-current:latest
-
name: Checkout
uses: actions/checkout@v2
-
name: Dependencies
run: |
sudo apt update && DEBIAN_FRONTEND="noninteractive" sudo apt install -y python3-pip && pip3 install pytest umbridge
-
name: Validate output
run: |
cd models/cookies-problem/ && \
python3 test_output.py http://localhost:4242
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ C++ | ✓ | ✓
MATLAB | ✓ | ✗
Python | ✓ | ✓
R | ✓ | ✗
Julia | ✓ |
Julia | ✓ |

Framework | Client (UQ) | Server (model)
---|---|---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ docker run -it -p 4242:4242 linusseelinger/cookies-problem

Model | Description
--- | ---
benchmark | sets the config options for the forward UQ benchmark (see below)
benchmark | Sets the config options for the forward UQ benchmark (see below)

### Benchmark configuration

Mapping | Dimensions | Description
--- |--- |---
input | [8] | These values modify the conductivity coefficient in the 8 cookies. They are i.i.d. uniform random variables in the range [-0.99 -0.2] (software does not check that inputs are within the bound)
output | \[1\] | The integral of the solution over the central subdomain (see definition of $$\Psi$$ at [cookies model](https://github.com/UM-Bridge/benchmarks/tree/main/models/cookies-problem/README.md) for info)
input | [8] | These values modify the conductivity coefficient in the 8 cookies. They are i.i.d. uniform random variables in the range [-0.99, -0.2] (software does not check that inputs are within the bound)
output | \[1\] | The integral of the solution over the central subdomain (see definition of $\Psi$ at [cookies model](https://github.com/UM-Bridge/benchmarks/tree/main/models/cookies-problem/README.md) for info)

Feature | Supported
--- |---
Expand All @@ -35,7 +35,7 @@ ApplyHessian | False

Config | Type | Default value | Can be changed in benchmark model | Description
--- |--- |--- |--- | ---
NumThreads | integer | 1 | yes | number of physical cores to be used by the solver
NumThreads | integer | 1 | yes | Number of physical cores to be used by the solver
BasisDegree | integer | 4 | no | Default degree of spline basis (must be a positive integer)
Fidelity | integer | 2 | no | Controls the number of mesh elements (must be a positive integer, see below for details)

Expand All @@ -53,21 +53,12 @@ None |

![cookies-problem](https://raw.githubusercontent.com/UM-Bridge/benchmarks/main/models/cookies-problem/cookies_domain.png "geometry of the cookies problem")

The benchmark implements a forward uncertainty quantification problem for the [cookies model](https://github.com/UM-Bridge/benchmarks/tree/main/models/cookies-problem/README.md). More specifically, we assume that the uncertain parameters $$y_n$$ appearing in the definition of the diffusion coefficient are uniform i.i.d. random variables on the range $$[-0.99, -0.2]$$ and we aim at computing the expected value of the quantity of interest (i.e., output of the model) $$\Psi$$, which is defined as the integral of the solution over $$F$$.
The benchmark implements a forward uncertainty quantification problem for the [cookies model](https://github.com/UM-Bridge/benchmarks/tree/main/models/cookies-problem/README.md). More specifically, we assume that the uncertain parameters $y_n$ appearing in the definition of the diffusion coefficient are uniform i.i.d. random variables on the range $[-0.99, -0.2]$ and we aim at computing the expected value of the quantity of interest (i.e., output of the model) $\Psi$, which is defined as the integral of the solution over $F$.

The PDE is solved with an IGA solver that uses as basis splines of degree $$p=4$$ and maximal regularity, i.e. of continuity $$3$$, and the mesh has $$200 \times 200$$ elements (i.e., the fidelity config parameter is set to $$2$$). The structure of this benchmark is identical to the one discussed in \[1\]; however, raw numbers are different since in \[1\] the PDE solver employed was different (standard FEM with piecewise linear basis) and the mesh was also different.


As a reference value, we provide the approximation of the expected value computed with a standard Smolyak sparse grid, based on Clenshaw--Curtis points, for level $$w=5$$, see e.g. \[2\]. The resulting sparse grid has 15713 points, and the corresponding approximation of the expected value is $$0.064196096847169$$.


The script available [here](https://github.com/UM-Bridge/benchmarks/tree/main/benchmarks/cookies-problem/run_forward_benchmark_in_matlab.m) generates the results, using the Sparse Grids Matlab Kit \[2\] for generating sparse grids. The Grids Matlab Kit is available on Github [here](https://github.com/lorenzo-tamellini/sparse-grids-matlab-kit) and a dedicated website with full resources including user manual is available [here](https://sites.google.com/view/sparse-grids-kit).


## Bibliography
1 Joakim Bäck, Fabio Nobile, Lorenzo Tamellini, Raul Tempone, **Stochastic spectral Galerkin and collocation methods for PDEs with random coefficients: a numerical comparison**. In *Spectral and High Order Methods for Partial Differential Equations*, Vol. 76 of Lecture Notes in Computational Science and Engineering, Springer, 2011
2 Chiara Piazzola, Lorenzo Tamellini, **The Sparse Grids Matlab Kit - a Matlab implementation of sparse grids for high-dimensional function approximation and uncertainty quantification**. ACM Transactions on Mathematical Software, 2023.
The PDE is solved with an IGA solver that uses as basis splines of degree $p=4$ and maximal regularity, i.e. of continuity $3$, and the mesh has $200 \times 200$ elements (i.e., the fidelity config parameter is set to $2$). The structure of this benchmark is identical to the one discussed in [[Bäck et al.,2011]](https://doi.org/10.1007/978-3-642-15337-2_3); however, raw numbers are different since in [[Bäck et al.,2011]](https://doi.org/10.1007/978-3-642-15337-2_3) the PDE solver employed was different (standard FEM with piecewise linear basis) and the mesh was also different.


As a reference value, we provide the approximation of the expected value computed with a standard Smolyak sparse grid, based on Clenshaw--Curtis points, for level $w=5$, see e.g. [[Piazzola et al.,2023]](https://doi.org/10.48550/arXiv.2203.09314). The resulting sparse grid has 15713 points, and the corresponding approximation of the expected value is $0.064196096847169$.


The script available [here](https://github.com/UM-Bridge/benchmarks/tree/main/benchmarks/cookies-problem/run_forward_benchmark_in_matlab.m) generates the results, using the Sparse Grids Matlab Kit [[Piazzola et al.,2023]](https://doi.org/10.48550/arXiv.2203.09314) for generating sparse grids. The Grids Matlab Kit is available on Github [here](https://github.com/lorenzo-tamellini/sparse-grids-matlab-kit) and a dedicated website with full resources including user manual is available [here](https://sites.google.com/view/sparse-grids-kit).
4 changes: 2 additions & 2 deletions benchmarks/l2-sea-optimization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ ApplyHessian | False

Config | Type | Default | Description
---|---|---|---
fidelity | integer | 1 | Fidelity level for the total resistance evaluation associated to the numerical grid discretization. Fidelity goes from 1 to 7, where 1 is highest-fidelity level (finest grid) and 7 is the lowest-fidelity level (coarsest grid).
fidelity | integer | 7 | Fidelity level for the total resistance evaluation associated to the numerical grid discretization. Fidelity goes from 1 to 7, where 1 is highest-fidelity level (finest grid) and 7 is the lowest-fidelity level (coarsest grid).

## Mount directories
Mount directory | Purpose
---|---
/output | \texttt{ASCII} files for visualization of pressure distribution along the hull \texttt{pre\textit{XXXX}.plt} and free-surface \texttt{intfr\textit{XXXX}.plt} formatted for Tecplot and Paraview, where \texttt{\textit{XXXX}} is the Froude number.
/output | ASCII files for visualization of pressure distribution along the hull `preXXXX.plt` and free-surface `intfrXXXX.plt` formatted for Tecplot and Paraview, where `XXXX` is the Froude number.

## Source code

Expand Down
12 changes: 5 additions & 7 deletions benchmarks/l2-sea-propagation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,25 @@ ApplyHessian | False

Config | Type | Default | Description
---|---|---|---
fidelity | integer | 1 | Fidelity level for the total resistance evaluation associated to the numerical grid discretization. Fidelity goes from 1 to 7, where 1 is highest-fidelity level (finest grid) and 7 is the lowest-fidelity level (coarsest grid).

fidelity | integer | 7 | Fidelity level for the total resistance evaluation associated to the numerical grid discretization. Fidelity goes from 1 to 7, where 1 is highest-fidelity level (finest grid) and 7 is the lowest-fidelity level (coarsest grid).

## Mount directories
Mount directory | Purpose
---|---
/output | \texttt{ASCII} files for visualization of pressure distribution along the hull \texttt{pre\textit{XXXX}.plt} and free-surface \texttt{intfr\textit{XXXX}.plt} formatted for Tecplot and Paraview, where \texttt{\textit{XXXX}} is the Froude number.
/output | ASCII files for visualization of pressure distribution along the hull `preXXXX.plt` and free-surface `intfrXXXX.plt` formatted for Tecplot and Paraview, where `XXXX` is the Froude number.

## Source code

[Model sources here.](https://github.com/UM-Bridge/benchmarks/tree/main/models/l2-sea)

## Description

The benchmark pertains to the evaluation of the expected value of the DTMB 5415 model scale total resistance in calm water, conditional to operational uncertain parameters, related to the speed and the payload. The latter is associated with the hull draft. Speed is expressed by its non-dimensional counterpart, the Froude number (Fr) is a unimodal triangular random variable with support over
$$[Fr_{\text{a}}, Fr_{\text{b}}]= [0.25, 0.41]$$, i.e.,
The benchmark pertains to the evaluation of the expected value of the DTMB 5415 model scale total resistance in calm water, conditional to operational uncertain parameters, related to the speed and the payload. The latter is associated with the hull draft. Speed is expressed by its non-dimensional counterpart, the Froude number (Fr) is a unimodal triangular random variable with support over $[Fr_{\text{a}}, Fr_{\text{b}}]= [0.25, 0.41]$, i.e.,

$$\pi_{Fr}(t) = \frac{2}{(Fr_{\text{b}}-Fr_{\text{a}})^2} \left(Fr_{\text{b}}-t\right),$$

while draft is a beta random variable with support over $$[T_{\text{a}},T_{\text{b}}]=[-6.776, -5.544]$$
and shape parameters $$\alpha=10,\beta=10$$, i.e.,%$$D \sim Beta(D_a,D_b,\alpha,\beta)$$, i.e.
while draft is a beta random variable with support over $[T_{\text{a}},T_{\text{b}}]=[-6.776, -5.544]$
and shape parameters $\alpha=10, \beta=10$, i.e., $D \sim Beta(D_a,D_b,\alpha,\beta)$, i.e.

$$\displaystyle \pi_{T}(t)= \frac{\Gamma(\alpha+\beta+2)}{\Gamma(\alpha+1)\Gamma(\beta+1)} \times (T_{\text{b}}-T_{\text{a}})^{\alpha+\beta+1}(t-T_{\text{a}})^\alpha(T_{\text{b}}-t)^\beta.$$

4 changes: 2 additions & 2 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ It will connect to your model :math:`F` as before, and perform uncertainty propa
Simply put, it will draw (cleverly chosen) Quasi-Monte Carlo samples from the distribution specified in the client, apply the model to each and output statistics of the results. Due to tight integration, this code looks like any other basic QMCPy example; however, it can immediately connect to any (arbitrarily complex) UM-Bridge model.

* Look at ``qmcpy-client.py`` and find out what distribution it is sampling from. Does the ``Solution`` output match your expectation?
* Optional: Write you own Monte Carlo sampler: Draw random samples :math:`\{\theta_1, \ldots, \theta_N\}` from the same distribution QMCPy is using, apply the model to each, and print out the resulting mean :math:`\frac{1}{N} \sum_{i=1}^N \theta_i`. Does it match QMCPy's output?
* Optional: Write you own Monte Carlo sampler: Draw random samples :math:`\{\theta_1, \ldots, \theta_N\}` from the same distribution QMCPy is using, apply the model to each, and print out the resulting mean :math:`\frac{1}{N} \sum_{i=1}^N f(\theta_i)`. Does it match QMCPy's output?

2: Running containerized simulation models
========================
Expand Down Expand Up @@ -347,4 +347,4 @@ Modify the client to run in parallel: The ``UMBridgeWrapper`` takes an argument

Run the client and point it to the cluster's address.

* Try different values for ``parallel``. Does run time scale as expected?
* Try different values for ``parallel``. Does run time scale as expected?
Loading

0 comments on commit 2516924

Please sign in to comment.