Skip to content

Commit 1182af7

Browse files
annaivagnesndem0
authored andcommitted
add smithers dataset in tutorial 1
1 parent 496b071 commit 1182af7

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

tutorials/tutorial-1.ipynb

Lines changed: 33 additions & 32 deletions
Large diffs are not rendered by default.

tutorials/tutorial-1.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33

44
# # EZyRB Tutorial 1
55
# ## Build and query a simple reduced order model
6-
#
6+
#
77
# In this tutorial we will show the typical workflow for the construcion of the Reduced Order Model based only on the outputs of the higher-order model. In detail, we consider here a POD-RBF framework (Proper Orthogonal Decomposition for dimensionality reduction and Radial Basis Function for manifold approximation), but the tutorial can be easily extended to other methods thanks to the modularity nature of **EZyRB**.
8-
#
8+
#
99
# We consider a parametric steady heat conduction problem in a two-dimensional domain $\Omega$. While in this tutorial we are going to focus on the data-driven approach, the same problem can be tackled in an intrusive manner (with the Reduced Basis method) using the [RBniCS](https://gitlab.com/RBniCS/RBniCS), as demonstrated in this [RBniCS tutorial](https://gitlab.com/RBniCS/RBniCS/tree/master/tutorials/01_thermal_block).<br>
1010
# This book is therefore exhaustively discussed in the book *Certified reduced basis methods for parametrized partial differential equations*, J.S. Hesthaven, G. Rozza, B. Stamm, 2016, Springer. An additional description is available also at [https://rbnics.gitlab.io/RBniCS-jupyter/tutorial_thermal_block.html]().
11-
#
11+
#
1212
# Since the good documentation already available for this problem and since the data-driven methodologies we will take into consideration, we just summarize the model to allow a better understanding.
13-
#
13+
#
1414
# The domain is depicted below:
15-
#
15+
#
1616
# <img src="pictures/tut1_sketch.png" alt="Drawing" style="width: 300px;"/>
17-
#
17+
#
1818
# where:
1919
# - the first parameter $\mu_o$ controls the conductivity in the circular subdomain $\Omega_0$;
2020
# - the second parameter $\mu_1$ controls the flux over $\Gamma_\text{base}$.
21-
#
22-
#
21+
#
22+
#
2323
# ### Initial setting
24-
#
24+
#
2525
# First of all import the required packages: we need the standard Numpy and Matplotlib, and some classes from EZyRB. In the EZyRB framework, we need three main ingredients to construct a reduced order model:
2626
# - an initial database where the snapshots are stored;
2727
# - a reduction method to reduce the dimensionality of the system, in this tutorial we will use the proper orthogonal decomposition (POD) method;
@@ -36,18 +36,20 @@
3636

3737
from ezyrb import POD, RBF, Database
3838
from ezyrb import ReducedOrderModel as ROM
39+
from smithers.dataset import TermalDataset as ThermalDataset
3940
get_ipython().run_line_magic('matplotlib', 'inline')
4041

4142

4243
# ## Offline phase
43-
#
44+
#
4445
# In the *offline* phase, we need some samples of the parametric high-fidelity model. In this case, we extract 8 snapshots from the numerical model implemented in **FEniCS**, and we import them and the related parameters.
4546

4647
# In[2]:
4748

49+
data = ThermalDataset()
4850

49-
snapshots = np.load('data/tut1_snapshots.npy')
50-
param = np.load('data/tut1_mu.npy')
51+
snapshots = data.snapshots
52+
param = data.params
5153
print(snapshots.shape, param.shape)
5254

5355

@@ -56,10 +58,7 @@
5658
# In[3]:
5759

5860

59-
tri = np.load('data/tut1_triangles.npy')
60-
coord = np.load('data/tut1_coord.npy')
61-
triang = mtri.Triangulation(coord[0],coord[1],tri)
62-
61+
triang = data.triang
6362

6463
# For the sake of clarity the snapshots are plotted.
6564

@@ -150,8 +149,8 @@ def plot_solution(mu0, mu1):
150149

151150

152151
# ## Error Approximation & Improvement
153-
#
154-
# At the moment, we used a database which is composed by 8 files. we would have an idea of the approximation accuracy we are able to reach with these high-fidelity solutions. Using the *leave-one-out* strategy, an error is computed for each parametric point in our database and these values are returned as array.
152+
#
153+
# At the moment, we used a database which is composed by 8 files. we would have an idea of the approximation accuracy we are able to reach with these high-fidelity solutions. Using the *leave-one-out* strategy, an error is computed for each parametric point in our database and these values are returned as array.
155154

156155
# In[12]:
157156

0 commit comments

Comments
 (0)