Skip to content

Commit

Permalink
Save animation
Browse files Browse the repository at this point in the history
  • Loading branch information
finsberg committed Aug 14, 2024
1 parent 2aab71d commit 0bc35f5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions demos/purkinje_stimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,21 @@ def compute_ecg_recovery():
dt = 0.05
solver = beat.MonodomainSplittingSolver(pde=pde, ode=ode)

plotter_voltage = pyvista.Plotter()
viridis = plt.get_cmap("viridis")
grid.point_data["V"] = solver.pde.state.vector().get_local()
grid.set_active_scalars("V")
renderer = plotter_voltage.add_mesh(
grid,
show_edges=True,
lighting=False,
cmap=viridis,
clim=[-90.0, 40.0],
)
gif_file = Path("purkinje.gif")
gif_file.unlink(missing_ok=True)
plotter_voltage.open_gif(gif_file.as_posix())

fname = (datadir / "state.xdmf").as_posix()
i = 0
while t < T + 1e-12:
Expand All @@ -441,9 +456,15 @@ def compute_ecg_recovery():
dolfin.XDMFFile.Encoding.HDF5,
True,
)
grid.point_data["V"] = solver.pde.state.vector().get_local()
plotter_voltage.write_frame()
solver.step((t, t + dt))
i += 1
t += dt
plotter_voltage.close()
# # -


# ![_](purkinje.gif)

compute_ecg_recovery()

0 comments on commit 0bc35f5

Please sign in to comment.