Skip to content

Commit

Permalink
Rendering of advection-diffusion with pillow
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrous committed Aug 3, 2023
1 parent d392f50 commit dbec551
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ demos/NavierStokes/data/*
!demos/NavierStokes/data/README.md
!demos/NavierStokes/data/Comparison
!demos/NavierStokes/data/TempFolder/*

demos/Advection/data/*
!demos/Advection/data/README.md
!demos/Advection/data/Comparison
!demos/Advection/data/TempFolder/*
14 changes: 7 additions & 7 deletions demos/Advection/00_advection_with_rbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
MAX_DEGREE = 1

DT = 1e-4
NB_TIMESTEPS = 10
NB_TIMESTEPS = 100
PLOT_EVERY = 10

VEL = jnp.array([100.0, 0.0])
## Diffusive constant
K = 0.08

Nx = 30
Ny = Nx
Nx = 40
Ny = 20
SUPPORT_SIZE = "max"

facet_types={"South":"d", "West":"d", "North":"d", "East":"n"}
Expand Down Expand Up @@ -64,8 +64,8 @@ def my_rhs_operator(x, centers=None, rbf=None, fields=None):

## u0 is zero everywhere except at a point in the middle
u0 = jnp.zeros(cloud.N)
source_id = int(cloud.N*0.05)
source_neighbors = jnp.array(cloud.local_supports[source_id][:cloud.N//50])
source_id = int(cloud.N*0.01)
source_neighbors = jnp.array(cloud.local_supports[source_id][:cloud.N//60])
u0 = u0.at[source_neighbors].set(0.95)

## Begin timestepping for 100 steps
Expand Down Expand Up @@ -112,8 +112,8 @@ def my_rhs_operator(x, centers=None, rbf=None, fields=None):
# %%

ax = plt.gca()
filename = DATAFOLDER + "advection_diffusion_rbf.png"
cloud.animate_fields([ulist], cmaps="jet", filename=filename, figsize=(6,3),colorbar=False, title=["Implicit Advection-Diffusion with RBFs"])
filename = DATAFOLDER + "advection_diffusion_rbf.gif"
cloud.animate_fields([ulist], cmaps="jet", filename=filename, figsize=(6,3),colorbar=False, titles=["Implicit scheme for Advection-Diffusion with RBFs"])



Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion updec/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def animate(frame):
### Save the video
if filename:
fps = step_count / duration
anim.save(filename, writer='ffmpeg', fps=fps)
# anim.save(filename, writer='ffmpeg', fps=fps)
anim.save(filename, writer='pillow', fps=fps)
os.system("open "+filename)

return ax
Expand Down

0 comments on commit dbec551

Please sign in to comment.