From f4784694e0943e8d1c51ea2725cce7907356b620 Mon Sep 17 00:00:00 2001 From: NT Date: Fri, 18 Jun 2021 15:04:19 +0200 Subject: [PATCH] phiflow 2 updates of forw NS sim --- overview-ns-forw.ipynb | 52 ++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/overview-ns-forw.ipynb b/overview-ns-forw.ipynb index abcef98..bf7796a 100644 --- a/overview-ns-forw.ipynb +++ b/overview-ns-forw.ipynb @@ -132,7 +132,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -198,31 +198,55 @@ "text": [ "Smoke: (xˢ=32, yˢ=40)\n", "Velocity: (xˢ=32, yˢ=40, vectorᵛ=2)\n", - "Inflow: (xˢ=32, yˢ=40)\n", - "Inflow, spatial only: (xˢ=32, yˢ=40)\n" + "Inflow: (xˢ=32, yˢ=40), spatial only: (xˢ=32, yˢ=40)\n" ] } ], "source": [ "print(f\"Smoke: {smoke.shape}\")\n", "print(f\"Velocity: {velocity.shape}\")\n", - "print(f\"Inflow: {INFLOW.shape}\")\n", - "print(f\"Inflow, spatial only: {INFLOW.shape.spatial}\")\n" + "print(f\"Inflow: {INFLOW.shape}, spatial only: {INFLOW.shape.spatial}\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Note that the phiflow output here indicates the type of a dimension, e.g., $^V$ for a vector dimension. Later on for learning, we'll also introduce batch dimensions.\n", + "Note that the phiflow output here indicates the type of a dimension, e.g., $^S$ for a spatial, and $^V$ for a vector dimension. Later on for learning, we'll also introduce batch dimensions.\n", "\n", - "The grid values can be accessed using the `values` property. This is an important difference to a phiflow tensor object, which does not have `values`, as illustrated in the code example below." + "The actual content of a shape object can be obtained via `.sizes`, or alternatively we can query the size of a specific dimension `dim` via `.get_size('dim')`. Here are two examples:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Shape content: (32, 40, 2)\n", + "Vector dimension: 2\n" + ] + } + ], + "source": [ + "print(f\"Shape content: {velocity.shape.sizes}\")\n", + "print(f\"Vector dimension: {velocity.shape.get_size('vector')}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The grid values can be accessed using the `values` property. This is an important difference to a phiflow tensor object, which does not have `values`, as illustrated in the code example below." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -231,7 +255,6 @@ "Statistics of the different simulation grids:\n", "(xˢ=32, yˢ=40) float32 0.0 < ... < 0.20000000298023224\n", "(xˢ=(31, 32), yˢ=(40, 39), vectorᵛ=2) float32 -0.12352858483791351 < ... < 0.15530994534492493\n", - "(xˢ=32, yˢ=40) float32 0.0 < ... < 0.20000000298023224\n", "Reordered test tensor shape: (3, 5, 2)\n" ] } @@ -240,7 +263,6 @@ "print(\"Statistics of the different simulation grids:\")\n", "print(smoke.values)\n", "print(velocity.values)\n", - "print(INFLOW.values)\n", "\n", "# in contrast to a simple tensor:\n", "test_tensor = math.tensor(numpy.zeros([2, 5, 3]), spatial('x,y'), channel('vector'))\n", @@ -267,7 +289,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -310,7 +332,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -323,10 +345,10 @@ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" }, @@ -358,7 +380,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -415,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ {