From a34f4ba596a536efd6f44773709c4a53a341bb8b Mon Sep 17 00:00:00 2001 From: Felix Koehler Date: Tue, 22 Oct 2024 17:40:02 +0200 Subject: [PATCH] Rerun showcase 2D --- docs/examples/solver_showcase_2d.ipynb | 91556 ++++++++++++----------- 1 file changed, 46398 insertions(+), 45158 deletions(-) diff --git a/docs/examples/solver_showcase_2d.ipynb b/docs/examples/solver_showcase_2d.ipynb index 47f6533..26a7fed 100644 --- a/docs/examples/solver_showcase_2d.ipynb +++ b/docs/examples/solver_showcase_2d.ipynb @@ -60,14 +60,14 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-04-08 15:33:37.695864: W external/xla/xla/service/gpu/nvptx_compiler.cc:679] The NVIDIA driver's CUDA version is 12.2 which is older than the ptxas CUDA version (12.3.52). Because the driver is older than the ptxas version, XLA is disabling parallel compilation, which may slow down compilation. You should update your NVIDIA driver or use the NVIDIA-provided CUDA forward compatibility packages.\n" + "2024-10-22 17:37:14.817038: W external/xla/xla/service/gpu/nvptx_compiler.cc:836] The NVIDIA driver's CUDA version is 12.2 which is older than the PTX compiler version (12.6.68). Because the driver is older than the PTX compiler version, XLA is disabling parallel compilation, which may slow down compilation. You should update your NVIDIA driver or use the NVIDIA-provided CUDA forward compatibility packages.\n" ] }, { "data": { "text/html": [ "" @@ -1553,7 +1637,7 @@ "data": { "text/html": [ "" @@ -2462,7 +2633,7 @@ "data": { "text/html": [ "" @@ -3386,7 +3631,7 @@ "data": { "text/html": [ "" @@ -4618,7 +4955,7 @@ "data": { "text/html": [ "" @@ -8799,7 +9194,7 @@ "data": { "text/html": [ "" @@ -9700,7 +10152,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Burgers" + "### Burgers (non-conservative)" ] }, { @@ -9708,20 +10160,20 @@ "metadata": {}, "source": [ "$$\n", - "\\frac{\\partial u}{\\partial t} + \\frac{1}{2} \\nabla \\cdot \\left( u \\otimes u \\right) = \\nu \\Delta u\n", + "\\frac{\\partial u}{\\partial t} + (u \\cdot \\nabla) u = \\nu \\Delta u\n", "$$" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -10563,7 +11028,7 @@ "" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -10572,7 +11037,7 @@ "DOMAIN_EXTENT = 1.0\n", "NUM_POINTS = 100\n", "DT = 0.01\n", - "NU = 0.01\n", + "NU = 0.02\n", "\n", "burgers_stepper = ex.stepper.Burgers(2, DOMAIN_EXTENT, NUM_POINTS, DT, diffusivity=NU)\n", "\n", @@ -10599,6 +11064,911 @@ "HTML(burgers_ani.to_html5_video())" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Burgers (conservative)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$\n", + "\\frac{\\partial u}{\\partial t} + \\frac{1}{2} \\nabla \\cdot \\left( u \\otimes u \\right) = \\nu \\Delta u\n", + "$$" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DOMAIN_EXTENT = 1.0\n", + "NUM_POINTS = 100\n", + "DT = 0.01\n", + "NU = 0.02\n", + "\n", + "burgers_stepper_conservative = ex.stepper.Burgers(\n", + " 2, DOMAIN_EXTENT, NUM_POINTS, DT, diffusivity=NU, conservative=True\n", + ")\n", + "\n", + "grid = ex.make_grid(2, DOMAIN_EXTENT, NUM_POINTS)\n", + "\n", + "# Burgers has two channels!\n", + "u_0 = jnp.concatenate(\n", + " [\n", + " jnp.sin(2 * jnp.pi * grid[0:1] / DOMAIN_EXTENT)\n", + " * jnp.cos(2 * 2 * jnp.pi * grid[1:2] / DOMAIN_EXTENT),\n", + " jnp.cos(2 * jnp.pi * grid[0:1] / DOMAIN_EXTENT)\n", + " * jnp.sin(2 * 2 * jnp.pi * grid[1:2] / DOMAIN_EXTENT),\n", + " ]\n", + ")\n", + "\n", + "burgers_trj_conservative = ex.rollout(\n", + " burgers_stepper_conservative, 40, include_init=True\n", + ")(u_0)\n", + "\n", + "burgers_ani_conservative = ex.viz.animate_state_2d_facet(\n", + " burgers_trj_conservative,\n", + " grid=(1, 2),\n", + " figsize=(7, 3),\n", + ")\n", + "\n", + "HTML(burgers_ani_conservative.to_html5_video())" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -10626,7 +11996,7 @@ "data": { "text/html": [ "" @@ -11728,14 +13170,14 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -15501,7 +16951,7 @@ "" ] }, - "execution_count": 13, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -15548,14 +16998,14 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -19025,7 +19409,7 @@ "" ] }, - "execution_count": 22, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -19034,6 +19418,7 @@ "DOMAIN_EXTENT = 20.0\n", "NUM_POINTS = 100\n", "DT = 0.05\n", + "HYPER_NU = 0.03\n", "\n", "kdv_stepper = ex.stepper.KortewegDeVries(\n", " 2,\n", @@ -19041,6 +19426,7 @@ " NUM_POINTS,\n", " DT,\n", " single_channel=True,\n", + " hyper_diffusivity=HYPER_NU,\n", ")\n", "\n", "grid = ex.make_grid(2, DOMAIN_EXTENT, NUM_POINTS)\n", @@ -19075,14 +19461,14 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -20167,7 +20620,7 @@ "" ] }, - "execution_count": 35, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -20218,14 +20671,14 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -24435,7 +26421,7 @@ "" ] }, - "execution_count": 33, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -24444,7 +26430,7 @@ "DOMAIN_EXTENT = 2 * jnp.pi\n", "NUM_POINTS = 100\n", "DT = 0.5\n", - "NU = 0.001\n", + "NU = 0.01\n", "DRAG = -0.1\n", "INJECTION_MODE = 4\n", "INJECTION_SCALE = 1.0\n", @@ -24505,14 +26491,14 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -25792,7 +27849,7 @@ "" ] }, - "execution_count": 41, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -25804,7 +27861,7 @@ "DIFFUSIVITY = 0.01\n", "REACTIVITY = 10.0\n", "\n", - "fisher_kpp_stepper = ex.reaction.FisherKPP(\n", + "fisher_kpp_stepper = ex.stepper.reaction.FisherKPP(\n", " 2, DOMAIN_EXTENT, NUM_POINTS, DT, diffusivity=DIFFUSIVITY, reactivity=REACTIVITY\n", ")\n", "\n", @@ -25839,14 +27896,14 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -26522,7 +28655,7 @@ "" ] }, - "execution_count": 44, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -26537,7 +28670,7 @@ "KILL_RATE = 0.06\n", "\n", "gray_scott_stepper = ex.RepeatedStepper(\n", - " ex.reaction.GrayScott(\n", + " ex.stepper.reaction.GrayScott(\n", " 2,\n", " DOMAIN_EXTENT,\n", " NUM_POINTS,\n", @@ -26586,14 +28719,14 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -32161,7 +34378,7 @@ "" ] }, - "execution_count": 46, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -32172,7 +34389,7 @@ "DT = 1.0\n", "\n", "swift_hohenberg_stepper = ex.RepeatedStepper(\n", - " ex.reaction.SwiftHohenberg(2, DOMAIN_EXTENT, NUM_POINTS, DT / 10),\n", + " ex.stepper.reaction.SwiftHohenberg(2, DOMAIN_EXTENT, NUM_POINTS, DT / 10),\n", " 10,\n", ")\n", "\n", @@ -32196,14 +34413,14 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" @@ -46380,7 +47616,7 @@ "" ] }, - "execution_count": 48, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -46395,6 +47631,7 @@ " dispersion_trj,\n", " hyper_diffusion_trj,\n", " burgers_trj,\n", + " burgers_trj_conservative,\n", " single_channel_burgers_trj,\n", " kdv_trj,\n", " ks_trj,\n", @@ -46418,6 +47655,8 @@ " \"Hyper-Diffusion\",\n", " \"Burgers channel 1\",\n", " \"Burgers channel 2\",\n", + " \"Burgers (Conservative)\\nchannel 1\",\n", + " \"Burgers (Conservative)\\nchannel 2\",\n", " \"Burgers single channel\",\n", " \"KdV\",\n", " \"KS\",\n", @@ -46428,8 +47667,9 @@ " \"Gray-Scott 2\",\n", " \"Swift-Hohenberg\",\n", " \"\",\n", + " \"\",\n", " ],\n", - " grid=(3, 6),\n", + " grid=(3, 7),\n", " figsize=(17, 10),\n", ")\n", "\n", @@ -46460,7 +47700,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.10.14" } }, "nbformat": 4,