Skip to content

Commit

Permalink
Remove burgers pde
Browse files Browse the repository at this point in the history
Will just use heat equation
  • Loading branch information
dafeda committed Dec 25, 2023
1 parent 8bbfbb7 commit 22ee8cc
Showing 1 changed file with 0 additions and 62 deletions.
62 changes: 0 additions & 62 deletions dass/pde.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,65 +47,3 @@ def heat_equation(
)

return _u


def burgers(nx: int, ny: int, nt: float, nu: float) -> npt.NDArray[np.float_]:
"""
Based on https://github.com/Masod-sadipour/Burgers-equation-convection-diffusion-in-2D
"""
dt = 0.001

dx = 2 / (nx - 1)
dy = 2 / (ny - 1)

u = np.ones((ny, nx))
v = np.ones((ny, nx))
un = np.ones((ny, nx))
vn = np.ones((ny, nx))
uf = np.ones((nt, nx, ny))
vf = np.ones((nt, nx, ny))

# assigning initial conditions
u[int(0.75 / dy) : int(1.25 / dy + 1), int(0.75 / dx) : int(1.25 / dx + 1)] = 5
v[int(0.75 / dy) : int(1.25 / dy + 1), int(0.75 / dx) : int(1.25 / dx + 1)] = 5

for n in range(nt):
un = u.copy()
vn = v.copy()
for i in range(1, nx - 1):
for j in range(1, ny - 1):
u[i, j] = (
(
un[i, j]
- (un[i, j] * dt / dx * (un[i, j] - un[i - 1, j]))
- vn[i, j] * dt / dy * (un[i, j] - un[i, j - 1])
)
+ (nu * dt / (dx**2))
* (un[i + 1, j] - 2 * un[i, j] + un[i - 1, j])
+ (nu * dt / (dx**2))
* (un[i, j - 1] - 2 * un[i, j] + un[i, j + 1])
)
v[i, j] = (
(
vn[i, j]
- (un[i, j] * dt / dx * (vn[i, j] - vn[i - 1, j]))
- vn[i, j] * dt / dy * (vn[i, j] - vn[i, j - 1])
)
+ (nu * dt / (dx**2))
* (vn[i + 1, j] - 2 * vn[i, j] + vn[i - 1, j])
+ (nu * dt / (dx**2))
* (vn[i, j - 1] - 2 * vn[i, j] + vn[i, j + 1])
)
uf[n, i, j] = u[i, j] # U in every time-step
vf[n, i, j] = v[i, j] # V in every time-step
# Velocity boundary conditions
u[:, 0] = 1
u[:, -1] = 1
u[0, :] = 1
u[-1, :] = 1
v[0, :] = 1
v[-1, :] = 1
v[:, 0] = 1
v[:, -1] = 1

return uf

0 comments on commit 22ee8cc

Please sign in to comment.