Created
May 22, 2017 16:51
-
-
Save lmmentel/1154b9289eb4a06e4823ffb38f4f3a7a to your computer and use it in GitHub Desktop.
Animation of the deactivation profile of a reactor filled with catalyst.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib import animation | |
fig, ax = plt.subplots(figsize=(16, 2)) | |
ax.get_xaxis().set_visible(False) | |
ax.get_yaxis().set_visible(False) | |
z = coke[0, :] | |
profile = ax.pcolormesh(z[np.newaxis, :], vmin=0.0, vmax=1.0, cmap='magma_r') | |
tos = fig.text(0.01, 0.98, '', horizontalalignment='left', | |
verticalalignment='top') | |
cb = fig.colorbar(profile, ax=ax, pad=0.03, fraction=0.08) | |
def init_coke(): | |
'plot the first frame' | |
profile.set_array(np.zeros(200)) | |
tos.set_text('TOS = 0.00 min') | |
return [profile, tos] | |
def update(n): | |
'update the frame with the next row of data' | |
z = coke[n, :] | |
profile.set_array(z.ravel()) | |
t = 'TOS = {:.2f} min'.format(240.0 * (n / 437.0)) | |
tos.set_text(t) | |
return [profile, tos] | |
plt.tight_layout() | |
anim = animation.FuncAnimation(fig, update, init_func=init_coke, frames=coke.shape[0], | |
blit=False, interval=500, repeat=False) | |
anim.save('coke_animation_magma.gif', writer='imagemagick', fps=30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment