|
3 | 3 |
|
4 | 4 | # # EZyRB Tutorial 1 |
5 | 5 | # ## Build and query a simple reduced order model |
6 | | -# |
| 6 | +# |
7 | 7 | # 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 | +# |
9 | 9 | # 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> |
10 | 10 | # 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 | +# |
12 | 12 | # 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 | +# |
14 | 14 | # The domain is depicted below: |
15 | | -# |
| 15 | +# |
16 | 16 | # <img src="pictures/tut1_sketch.png" alt="Drawing" style="width: 300px;"/> |
17 | | -# |
| 17 | +# |
18 | 18 | # where: |
19 | 19 | # - the first parameter $\mu_o$ controls the conductivity in the circular subdomain $\Omega_0$; |
20 | 20 | # - the second parameter $\mu_1$ controls the flux over $\Gamma_\text{base}$. |
21 | | -# |
22 | | -# |
| 21 | +# |
| 22 | +# |
23 | 23 | # ### Initial setting |
24 | | -# |
| 24 | +# |
25 | 25 | # 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: |
26 | 26 | # - an initial database where the snapshots are stored; |
27 | 27 | # - a reduction method to reduce the dimensionality of the system, in this tutorial we will use the proper orthogonal decomposition (POD) method; |
|
36 | 36 |
|
37 | 37 | from ezyrb import POD, RBF, Database |
38 | 38 | from ezyrb import ReducedOrderModel as ROM |
| 39 | +from smithers.dataset import TermalDataset as ThermalDataset |
39 | 40 | get_ipython().run_line_magic('matplotlib', 'inline') |
40 | 41 |
|
41 | 42 |
|
42 | 43 | # ## Offline phase |
43 | | -# |
| 44 | +# |
44 | 45 | # 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. |
45 | 46 |
|
46 | 47 | # In[2]: |
47 | 48 |
|
| 49 | +data = ThermalDataset() |
48 | 50 |
|
49 | | -snapshots = np.load('data/tut1_snapshots.npy') |
50 | | -param = np.load('data/tut1_mu.npy') |
| 51 | +snapshots = data.snapshots |
| 52 | +param = data.params |
51 | 53 | print(snapshots.shape, param.shape) |
52 | 54 |
|
53 | 55 |
|
|
56 | 58 | # In[3]: |
57 | 59 |
|
58 | 60 |
|
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 |
63 | 62 |
|
64 | 63 | # For the sake of clarity the snapshots are plotted. |
65 | 64 |
|
@@ -150,8 +149,8 @@ def plot_solution(mu0, mu1): |
150 | 149 |
|
151 | 150 |
|
152 | 151 | # ## 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. |
155 | 154 |
|
156 | 155 | # In[12]: |
157 | 156 |
|
|
0 commit comments