Skip to content

Commit

Permalink
Navier-Stokes plots and next release
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrous committed Apr 25, 2024
1 parent 58ecf26 commit 99c65a0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<th><img src="docs/assets/laplace.png" width="180"></th>
<th><img src="docs/assets/adv_diff_periodic.gif" width="350"></th>
<!-- <th><img src="docs/assets/burgers_u.gif" width="188"></th> -->
<th><img src="docs/assets/ns_norm.gif" width="188"></th>
<th><img src="docs/assets/ns_norm.gif" width="150"></th>
</tr>
</table>

Expand Down
9 changes: 5 additions & 4 deletions demos/NavierStokes/001_unit_square_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# RBF = gaussian
MAX_DEGREE = 1

DT = 1e-3
DT = 4e-3
NB_TIMESTEPS = 200
PLOT_EVERY = 20

Expand All @@ -38,8 +38,8 @@

## Diffusive constant

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

facet_types_vel={"South":"d", "North":"d", "West":"d", "East":"d"}
Expand Down Expand Up @@ -213,8 +213,9 @@ def Phi_x_Phi_y(x, y):
# cloud_vel.animate_fields([ulist], cmaps="coolwarm", filename=filename, levels=200, duration=10, figsize=(7.5,6), titles=["Burgers with RBFs - u"]);

normlist = [jnp.sqrt(sol[0]**2 + sol[1]**2) for sol in sol_list]
# normlist = [sol[0] for sol in sol_list]
filename = DATAFOLDER + "ns_norm.gif"
cloud_vel.animate_fields([normlist[::10]], cmaps="coolwarm", filename=filename, levels=200, duration=10, figsize=(7.5,6), titles=["Navier-Stokes with RBFs"]);
cloud_vel.animate_fields([normlist[::10]], cmaps="coolwarm", filename=filename, levels=200, duration=10, figsize=(6,6), titles=["Navier-Stokes with RBFs"], colorbar=False);


# %%
Expand Down
2 changes: 2 additions & 0 deletions docs/assets/NextRelease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
For the next release v1.1.0
- [X] Added colorbar to animate fields
Binary file modified docs/assets/ns_norm.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions updes/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def visualize_field(self, field, projection="2d", title="Field", xlabel=r'$x$',
return ax, img


def animate_fields(self, fields, filename=None, titles="Field", xlabel=r'$x$', ylabel=r'$y$', levels=50, figsize=(6,5), cmaps="jet", cbarsplit=50, duration=5, **kwargs):
def animate_fields(self, fields, filename=None, titles="Field", xlabel=r'$x$', ylabel=r'$y$', levels=50, figsize=(6,5), cmaps="jet", cbarsplit=50, duration=5, colorbar=True, **kwargs):
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -307,15 +307,16 @@ def animate_fields(self, fields, filename=None, titles="Field", xlabel=r'$x$', y
minmax = minmax[0], minmax[0]+1e-3

minmaxs.append(minmax)
boundaries = jnp.linspace(minmax[0], minmax[1], cbarsplit)

imgs.append(ax[i].tricontourf(x, y, signals[i][0], levels=levels, vmin=minmax[0], vmax=minmax[1], cmap=cmaps[i], **kwargs))

m = plt.cm.ScalarMappable(cmap=cmaps[i])
m.set_array(signals[i])
m.set_clim(minmax[0], minmax[1])
# m.set_norm(plt.Normalize(vmin=minmax[0], vmax=minmax[1]))
plt.colorbar(m, boundaries=boundaries, shrink=1.0, aspect=10, ax=ax[i])
if colorbar == True:
boundaries = jnp.linspace(minmax[0], minmax[1], cbarsplit)
m = plt.cm.ScalarMappable(cmap=cmaps[i])
m.set_array(signals[i])
m.set_clim(minmax[0], minmax[1])
# m.set_norm(plt.Normalize(vmin=minmax[0], vmax=minmax[1]))
plt.colorbar(m, boundaries=boundaries, shrink=1.0, aspect=10, ax=ax[i])

try:
title = titles[i]
Expand Down

0 comments on commit 99c65a0

Please sign in to comment.