{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Make animations for webpage\n", "\n", "Create html versions of some animations to be uploaded to the webpage. Links from the pdf version of the book will go to these versions for readers who are only reading the pdf.\n", "\n", "Note that `make_html_on_master.py` will copy everything from `html_animations` into `build_html` when creating webpage version." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import FileLink" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Acoustics\n", "\n", "Animation to link from [Acoustics.ipynb](Acoustics.ipynb)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from exact_solvers import acoustics_demos" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def make_bump_animation_html(numframes, file_name):\n", " anim = acoustics_demos.bump_animation(numframes)\n", " video_html = anim.to_html5_video()\n", " f = open(file_name,'w')\n", " f.write('\\n')\n", " file_name = 'acoustics_bump_animation.html'\n", " descr = \"\"\"
\")\n", " f.write(video_html)\n", " print(\"Created \", file_name)\n", " f.close()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_name = 'html_animations/acoustics_bump_animation.html'\n", "anim = make_bump_animation_html(numframes=50, file_name=file_name)\n", "FileLink(file_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Burgers\n", "\n", "Animations to link from [Burgers.ipynb](Burgers.ipynb).\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from exact_solvers import burgers_demos" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "anim = burgers_demos.bump_animation(numframes = 50)\n", "file_name = 'html_animations/burgers_animation0.html'\n", "video_html = anim.to_html5_video()\n", "f = open(file_name,'w')\n", "f.write('\\n')\n", "descr = \"\"\"
\n", " Burgers' equation with hump initial data, evolving into a shock wave\n", " followed by a rarefaction wave.\"\"\"\n", "f.write(descr)\n", "f.write(\"
\")\n", "f.write(video_html)\n", "print(\"Created \", file_name)\n", "f.close()\n", "FileLink(file_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def make_burgers_animation_html(ql, qm, qr, file_name):\n", " anim = burgers_demos.triplestate_animation(ql,qm,qr,numframes=50)\n", " video_html = anim.to_html5_video()\n", " f = open(file_name,'w')\n", " f.write('\\n')\n", " descr = \"\"\"
\n", " Burgers' equation with three constant states as initial data,\\n\n", " ql = %.1f, qm = %.1f, qr = %.1f\"\"\" % (ql,qm,qr)\n", " f.write(descr)\n", " f.write(\"
\")\n", " f.write(video_html)\n", " print(\"Created \", file_name)\n", " f.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_name = 'html_animations/burgers_animation1.html'\n", "make_burgers_animation_html(4., 2., 0., file_name)\n", "FileLink(file_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_name = 'html_animations/burgers_animation2.html'\n", "make_burgers_animation_html(4., -1.5, 0.5, file_name)\n", "FileLink(file_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_name = 'html_animations/burgers_animation3.html'\n", "make_burgers_animation_html(-1., 3., -2., file_name)\n", "FileLink(file_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }