Skip to content

Commit fd3be09

Browse files
Github action: auto-update.
1 parent 7ef3835 commit fd3be09

File tree

79 files changed

+230322
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+230322
-179
lines changed
Binary file not shown.

dev/_downloads/09a1631d14c6eb51e552aa53b9f6d3e8/checkpoint_FNO_darcy.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"name": "python",
155155
"nbconvert_exporter": "python",
156156
"pygments_lexer": "ipython3",
157-
"version": "3.13.2"
157+
"version": "3.13.3"
158158
}
159159
},
160160
"nbformat": 4,
Binary file not shown.
Binary file not shown.

dev/_downloads/1c2e74cc4f68386faa92c3986ff5e279/plot_embeddings.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"name": "python",
108108
"nbconvert_exporter": "python",
109109
"pygments_lexer": "ipython3",
110-
"version": "3.13.2"
110+
"version": "3.13.3"
111111
}
112112
},
113113
"nbformat": 4,
Binary file not shown.

dev/_downloads/3f74a91662afa758e3d845617240e471/plot_DISCO_convolutions.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
"name": "python",
213213
"nbconvert_exporter": "python",
214214
"pygments_lexer": "ipython3",
215-
"version": "3.13.2"
215+
"version": "3.13.3"
216216
}
217217
},
218218
"nbformat": 4,
Binary file not shown.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
"""
2+
.. _burgers_2d_fd_vis :
3+
4+
A Numerical Solver for Burgers' Equation in 2 Dimensions
5+
========================================================
6+
An intro to our loss module's finite difference utility demonstrating
7+
its use to create a simple numerical solver for Burgers' equation in 2d.
8+
"""
9+
10+
# %%
11+
# Import the library
12+
# ------------------
13+
# We first import our `neuralop` library and required dependencies.
14+
import torch
15+
import numpy as np
16+
import matplotlib.pyplot as plt
17+
import matplotlib.animation as animation
18+
from neuralop.losses.finite_diff import central_diff_2d
19+
20+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
21+
22+
# %%
23+
# Defining our problem
24+
# --------------------
25+
# We aim to solve the 2D viscous Burger's equations:
26+
#
27+
# u_t + u u_x + v u_y = nu (u_xx + u_yy)
28+
#
29+
# v_t + u v_x + v v_y = nu (v_xx + v_yy)
30+
31+
## Simulation parameters
32+
Lx, Ly = 2.0, 2.0 # Domain lengths
33+
nx, ny = 64, 64 # Grid resolution
34+
T = 1 # Total simulation time
35+
dt = 0.001 # Time step
36+
nu = 0.04 # Viscosity
37+
38+
## Create grid
39+
X = torch.linspace(0, Lx, nx, device=device).repeat(ny, 1).T
40+
Y = torch.linspace(0, Ly, ny, device=device).repeat(nx, 1)
41+
dx = Lx / (nx-1)
42+
dy = Ly / (ny-1)
43+
nt = int(T / dt)
44+
45+
## Initial condition
46+
u = -torch.sin(2 * np.pi * Y).to(device)
47+
v = torch.cos(2 * np.pi * X).to(device)
48+
49+
50+
# %%
51+
# Simulate evolution using numerical solver
52+
# -----------------------------------------
53+
54+
u_evolution = [u.clone()]
55+
v_evolution = [v.clone()]
56+
57+
for _ in range(nt):
58+
59+
# Compute first-order derivatives
60+
u_x, u_y = central_diff_2d(u, [dx, dy])
61+
v_x, v_y = central_diff_2d(v, [dx, dy])
62+
63+
# Compute second-order derivatives
64+
u_xx, _ = central_diff_2d(u_x, [dx, dy])
65+
_, u_yy = central_diff_2d(u_y, [dx, dy])
66+
v_xx, _ = central_diff_2d(v_x, [dx, dy])
67+
_, v_yy = central_diff_2d(v_y, [dx, dy])
68+
69+
# Evolve in time using Euler's method
70+
u_next = u + dt * (-u * u_x - v * u_y + nu * (u_xx + u_yy))
71+
v_next = v + dt * (-u * v_x - v * v_y + nu * (v_xx + v_yy))
72+
73+
u, v = u_next.clone(), v_next.clone()
74+
u_evolution.append(u.clone())
75+
v_evolution.append(v.clone())
76+
77+
u_evolution = torch.stack(u_evolution).cpu().numpy()
78+
v_evolution = torch.stack(v_evolution).cpu().numpy()
79+
80+
# %%
81+
# Animating the solution
82+
# ----------------------
83+
84+
num_frames = 100
85+
frame_indices = torch.linspace(0, len(u_evolution) - 1, num_frames, dtype=torch.int).cpu().numpy()
86+
u_frames = u_evolution[frame_indices]
87+
v_frames = v_evolution[frame_indices]
88+
89+
fig, axs = plt.subplots(1, 2, figsize=(12, 6))
90+
cmap_u = axs[0].imshow(u_frames[0], extent=[0, Lx, 0, Ly], origin="lower", cmap="plasma")
91+
axs[0].set_title("Velocity u")
92+
plt.colorbar(cmap_u, ax=axs[0], shrink=0.75)
93+
cmap_v = axs[1].imshow(v_frames[0], extent=[0, Lx, 0, Ly], origin="lower", cmap="plasma")
94+
axs[1].set_title("Velocity v")
95+
plt.colorbar(cmap_v, ax=axs[1], shrink=0.75)
96+
97+
def update(frame):
98+
cmap_u.set_data(u_frames[frame])
99+
cmap_v.set_data(v_frames[frame])
100+
axs[0].set_title(f"Velocity u (Time: {frame_indices[frame] * dt:.3f})")
101+
axs[1].set_title(f"Velocity v (Time: {frame_indices[frame] * dt:.3f})")
102+
axs[0].set_xticks([])
103+
axs[0].set_yticks([])
104+
axs[1].set_xticks([])
105+
axs[1].set_yticks([])
106+
return cmap_u, cmap_v
107+
108+
ani = animation.FuncAnimation(fig, update, frames=len(u_frames), interval=50, blit=False)

dev/_downloads/513ad9091cd6d9b455b9ddd3c807b97f/plot_SFNO_swe.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
"name": "python",
173173
"nbconvert_exporter": "python",
174174
"pygments_lexer": "ipython3",
175-
"version": "3.13.2"
175+
"version": "3.13.3"
176176
}
177177
},
178178
"nbformat": 4,

0 commit comments

Comments
 (0)