Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
505 changes: 430 additions & 75 deletions tutorials/tutorial-1.ipynb

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions tutorials/tutorial-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
import numpy as np
import matplotlib.tri as mtri
import matplotlib.pyplot as plt

from datasets import load_dataset
from ezyrb import POD, RBF, Database
from ezyrb import ReducedOrderModel as ROM
from smithers.dataset import TermalDataset as ThermalDataset
get_ipython().run_line_magic('matplotlib', 'inline')

# get_ipython().run_line_magic('matplotlib', 'inline')


# ## Offline phase
Expand All @@ -46,19 +46,30 @@

# In[2]:

data = ThermalDataset()
data_path = "kshitij-pandey/termal_dataset"
snapshots_hf = load_dataset(data_path, "snapshots", split="train")
param_hf = load_dataset(data_path, "params", split="train")
triangles_hf = load_dataset(data_path, "triangles", split="train")
coords_hf = load_dataset(data_path, "coords", split="train")


snapshots = data.snapshots
param = data.params
print(snapshots.shape, param.shape)
# convert the dict files into numpy

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

snapshots = hf_to_numpy(snapshots_hf)
param = hf_to_numpy(param_hf)
triangles = hf_to_numpy(triangles_hf)
coords = hf_to_numpy(coords_hf)
# 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.

# In[3]:


triang = data.triang
x, y = coords
from matplotlib.tri import Triangulation
triang = Triangulation(x, y, triangles)

# For the sake of clarity the snapshots are plotted.

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


rom.optimal_mu()


# These function can be used to achieve the wanted (estimated) accuracy.
rom.optimal_mu()
Loading