Skip to content

Commit ec65d70

Browse files
Added tutorials 1 and 2 (#262)
* Change tutorials 1 and 2 * tut 1 & 2 Juputer Notebook compiled files
1 parent 0f4ffb7 commit ec65d70

File tree

4 files changed

+1272
-185
lines changed

4 files changed

+1272
-185
lines changed

tutorials/tutorial-1.ipynb

Lines changed: 430 additions & 75 deletions
Large diffs are not rendered by default.

tutorials/tutorial-1.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
import numpy as np
3434
import matplotlib.tri as mtri
3535
import matplotlib.pyplot as plt
36-
36+
from datasets import load_dataset
3737
from ezyrb import POD, RBF, Database
3838
from ezyrb import ReducedOrderModel as ROM
39-
from smithers.dataset import TermalDataset as ThermalDataset
40-
get_ipython().run_line_magic('matplotlib', 'inline')
39+
40+
# get_ipython().run_line_magic('matplotlib', 'inline')
4141

4242

4343
# ## Offline phase
@@ -46,19 +46,30 @@
4646

4747
# In[2]:
4848

49-
data = ThermalDataset()
49+
data_path = "kshitij-pandey/termal_dataset"
50+
snapshots_hf = load_dataset(data_path, "snapshots", split="train")
51+
param_hf = load_dataset(data_path, "params", split="train")
52+
triangles_hf = load_dataset(data_path, "triangles", split="train")
53+
coords_hf = load_dataset(data_path, "coords", split="train")
54+
5055

51-
snapshots = data.snapshots
52-
param = data.params
53-
print(snapshots.shape, param.shape)
56+
# convert the dict files into numpy
5457

58+
def hf_to_numpy(ds):
59+
return np.stack([np.array(ds[col]) for col in ds.column_names], axis=1)
5560

61+
snapshots = hf_to_numpy(snapshots_hf)
62+
param = hf_to_numpy(param_hf)
63+
triangles = hf_to_numpy(triangles_hf)
64+
coords = hf_to_numpy(coords_hf)
5665
# Moreover, to visualize the solution (both the higher-order one and the reduced one), we import also the mesh information to be able to create the triangulation. We underline this additional step is related only to plotting purpose, and not mandatory for the reduced space generation.
5766

5867
# In[3]:
5968

6069

61-
triang = data.triang
70+
x, y = coords
71+
from matplotlib.tri import Triangulation
72+
triang = Triangulation(x, y, triangles)
6273

6374
# For the sake of clarity the snapshots are plotted.
6475

@@ -163,7 +174,4 @@ def plot_solution(mu0, mu1):
163174
# In[13]:
164175

165176

166-
rom.optimal_mu()
167-
168-
169-
# These function can be used to achieve the wanted (estimated) accuracy.
177+
rom.optimal_mu()

0 commit comments

Comments
 (0)