updated NS forward sim
This commit is contained in:
1 parent
f9d78531c5
commit
f533fd7a4f
3 files changed
+19
-405
No files matched your search
@@ -16,7 +16,7 @@
|
|||||||
"## Model\n",
|
"## Model\n",
|
||||||
"\n",
|
"\n",
|
||||||
"As phyical model we'll use Burgers equation.\n",
|
"As phyical model we'll use Burgers equation.\n",
|
||||||
"This equation is a very simple, yet non-linear and non-trivial, model equation that can lead to interesting shock formations. Hence, it's a very good starting point for experiments, and it's 1D version (from equation {ref}`model-burgers1d`) is given by:\n",
|
"This equation is a very simple, yet non-linear and non-trivial, model equation that can lead to interesting shock formations. Hence, it's a very good starting point for experiments, and it's 1D version (from equation {eq}`model-burgers1d`) is given by:\n",
|
||||||
"\n",
|
"\n",
|
||||||
"$$\n",
|
"$$\n",
|
||||||
" \\frac{\\partial u}{\\partial{t}} + u \\nabla u =\n",
|
" \\frac{\\partial u}{\\partial{t}} + u \\nabla u =\n",
|
||||||
@@ -87,7 +87,10 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Next we can define the `domain` to contain $\\Omega$, as outlined above periodically for $[-1,1]$. We also initialize a 1D `velocity` from the `initial` array.\n",
|
"Φ<sub>Flow</sub> is object-oriented and centered around field data in the form of grids (internally represented by a tensor object). I.e. you assemble your simulation by constructing a number of grids, and updating them over the course of time steps.\n",
|
||||||
|
"\n",
|
||||||
|
"Next, we declare the `domain` object to contain $\\Omega$, as outlined above periodically for $[-1,1]$. We also \n",
|
||||||
|
"initialize a 1D `velocity` grid from the `INITIAL` numpy array.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Just to illustrate, we'll also print some info about the velocity object: it's a `phiflow.math` tensor with a size of 128. Note that the actual grid content is contained in the `values` of the grid. Below we're printing five entries by using the `numpy()` function to convert the content of the phiflow tensor into a numpy array."
|
"Just to illustrate, we'll also print some info about the velocity object: it's a `phiflow.math` tensor with a size of 128. Note that the actual grid content is contained in the `values` of the grid. Below we're printing five entries by using the `numpy()` function to convert the content of the phiflow tensor into a numpy array."
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,381 +0,0 @@
|
|||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "o4JZ84moBKMr"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"# Navier-Stokes Forward Simulation with Φ<sub>Flow</sub>\n",
|
|
||||||
"\n",
|
|
||||||
"... now a more complex example with fluid simulations (Navier-Stokes) ... still very simple with phiflow (complexity of the differentiable operators hidden).\n",
|
|
||||||
"\n",
|
|
||||||
"As before, the first command with a \"!\" prefix installs the [Φ<sub>Flow</sub> Python package from GitHub](https://github.com/tum-pbs/PhiFlow) via `pip` in your python environment. (Skip or modify this command if necessary.)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 1,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/"
|
|
||||||
},
|
|
||||||
"id": "da1uZcDXdVcF",
|
|
||||||
"outputId": "1082dc87-796c-4b57-e72e-5790fc1444c9"
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stderr",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"/home/thuerey/anaconda3/envs/tf/lib/python3.8/_collections_abc.py:743: MatplotlibDeprecationWarning: The global colormaps dictionary is no longer considered public API.\n",
|
|
||||||
" for key in self._mapping:\n",
|
|
||||||
"/home/thuerey/anaconda3/envs/tf/lib/python3.8/_collections_abc.py:744: MatplotlibDeprecationWarning: The global colormaps dictionary is no longer considered public API.\n",
|
|
||||||
" yield (key, self._mapping[key])\n",
|
|
||||||
"/home/thuerey/phiflow/phi/viz/display.py:80: UserWarning: GUI is disabled because of missing dependencies: No module named 'imageio'. To install all dependencies, run $ pip install phiflow[gui]\n",
|
|
||||||
" warnings.warn('GUI is disabled because of missing dependencies: %s. To install all dependencies, run $ pip install phiflow[gui]' % import_error)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"!pip install --upgrade --quiet phiflow\n",
|
|
||||||
"from phi.flow import * # The Dash GUI is not supported on Google Colab, ignore the warning\n",
|
|
||||||
"import pylab"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "BVV1IKVqDfLl"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"## Setting up the simulation\n",
|
|
||||||
"\n",
|
|
||||||
"Φ<sub>Flow</sub> is object-oriented, i.e. you assemble your simulation by constructing a number of objects and adding them to the world.\n",
|
|
||||||
"\n",
|
|
||||||
"The following code sets up four fluid simulations that run in parallel (`batch_size=4`). Each fluid simulation has a circular Inflow at a different location."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"metadata": {
|
|
||||||
"id": "WrA3IXDxv31P"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"world = World()\n",
|
|
||||||
"fluid = world.add(Fluid(Domain([40, 32], boundaries=CLOSED), buoyancy_factor=0.05), physics=IncompressibleFlow())\n",
|
|
||||||
"world.add(Inflow(Sphere(center=[5,14], radius=3), rate=0.2));"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "ExA0Pi2sFVka"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"The inflow affects the fluid's marker density. Because a Boussinesq model with a positive `buoyancy_factor` is active, the marker field `density` creates an upward force. Note that this density is not the density of the fluid, but the amount of marker quantity present in each cell.\n",
|
|
||||||
"\n",
|
|
||||||
"Let's plot the marker density after one simulation frame."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/",
|
|
||||||
"height": 282
|
|
||||||
},
|
|
||||||
"id": "WmGZdOwswOva",
|
|
||||||
"outputId": "3ae4d68d-b586-4bbe-eca9-a223d7720949"
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"<matplotlib.image.AxesImage at 0x7f9cf945eee0>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAANAAAAD4CAYAAACdW2gvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAALeElEQVR4nO3dYahk9XnH8e+v2zUJTcDY2GVR29hGGqSpN0UWQ32RSCxboWgglFgoCxU2gVgSCAVJoU3aBhpo46vSsCHWfZGapFHRFttms7VNC0WzmhuzumnVVKnL6mITib6x3fXpizlXNu693rnzzNyduff7gWHOnHPmnP+f3R/nnP8985xUFZIm8xPnugHSIjNAUoMBkhoMkNRggKSGn9zMnSVxyE+L6PmqunC1BZsaoJEdm79LqeX002st8RROajBAUoMBkhoMkNRggKQGAyQ1GCCpwQBJDQZIajBAUoMBkhoMkNRggKQGAyQ1GCCpwQBJDQZIajBAUoMBkhoMkNSwboCSvDHJg0m+k+TRJJ8e5t+e5L+SLA+vpZm3Vpoz41TleRm4pqpeSrIT+Lckfz8s+72q+trsmifNt3UDVKPHN7w0fNw5vKzvJjHmNVCSHUmWgZPAoap6Y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252gF69g3sY6fgQcO8mt2HW7gX2DdP7gHvOYVsmkiTAF4FjVfW5MxYtdN+SXJjk/GH6TYzKERxjFKSVp9durF9Vtakv4DpGtRSeBH5/s/c/5b7cAZwA/o/RufNNwE8zGqF6HPgGcMG5bucE/bqa0enZI8Dy8Lpu0fsG/DLw7aFfR4E/GOb/PPAg8ATwN8Abxt2mt/JIDQ4iSA0GSGowQFKDAZIaDJDUYICkBgMkNfw/J69t/fXJCH0AAAAASUVORK5CYII=\n",
|
|
||||||
"text/plain": [
|
|
||||||
"<Figure size 432x288 with 1 Axes>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {
|
|
||||||
"needs_background": "light"
|
|
||||||
},
|
|
||||||
"output_type": "display_data"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"world.step()\n",
|
|
||||||
"pylab.imshow(fluid.density.data[0,...,0], origin='lower', cmap='magma')"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"A lot has happened internally in the `world.step()` call, e.g., for fluids we have a more complex `struct` object that stores the different fields of the simulation. For fluids we have the aforementioned marker density in addition to a velocity."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 8,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Fluid state: Fluid[density: Grid[40x32(1), size=[40. 32.], float32], velocity: StaggeredGrid[40x32, size=[40. 32.], float32]]\n",
|
|
||||||
"\n",
|
|
||||||
" Velocity content:\n",
|
|
||||||
"(1, 41, 32, 1)\n",
|
|
||||||
"(1, 40, 33, 1)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"print(\"Fluid state: \" + format(fluid.state))\n",
|
|
||||||
"print(\"\\nVelocity content:\")\n",
|
|
||||||
"[print(grid.data.shape) for grid in fluid.velocity.unstack()];"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"Note that we actually created two variables, one for each velocity component. If you're interested in how this works, have a look at the [Struct documentation](https://github.com/tum-pbs/PhiFlow/blob/master/documentation/Structs.ipynb).\n",
|
|
||||||
"\n",
|
|
||||||
"If you look closely at the output from the last `print` command, you'll notice that the shapes of the variables differ. This is because the velocity is sampled in [staggered form](https://github.com/tum-pbs/PhiFlow/blob/master/documentation/Staggered_Grids.md).\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "PA-2tGuWGHv2"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"We can run more steps by repeatedly calling `world.step()`."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 5,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/"
|
|
||||||
},
|
|
||||||
"id": "0hZk5HX3w4Or",
|
|
||||||
"outputId": "f7811af7-4b58-4ff6-a8b6-6e7bedefaa6e"
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Computing frame 0\n",
|
|
||||||
"Computing frame 1\n",
|
|
||||||
"Computing frame 2\n",
|
|
||||||
"Computing frame 3\n",
|
|
||||||
"Computing frame 4\n",
|
|
||||||
"Computing frame 5\n",
|
|
||||||
"Computing frame 6\n",
|
|
||||||
"Computing frame 7\n",
|
|
||||||
"Computing frame 8\n",
|
|
||||||
"Computing frame 9\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"for frame in range(10):\n",
|
|
||||||
" print('Computing frame %d' % frame)\n",
|
|
||||||
" world.step(dt=1.5)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "GMKKWQBLHIwP"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"Now the hot plume is starting to rise:"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/",
|
|
||||||
"height": 282
|
|
||||||
},
|
|
||||||
"id": "Mfl80CjZxZcL",
|
|
||||||
"outputId": "92f3a9ba-d403-4799-a543-132ee8ed234c"
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"<matplotlib.image.AxesImage at 0x7fa84d3553d0>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAANAAAAD4CAYAAACdW2gvAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAOMUlEQVR4nO3dbYxc51nG8f+1ztpO7CLHjeNaSZq4xBBZpXEhWClEKBiCnEDlVCpRAi2WMHKIGtSKChGVAm3TCCqV+gsI4SomBtokJS/EQg3UuKYvAjmxXSf1S1LbJRE2a2828Xtix7t782HOulufM97ZuWfWM7vXT1rt7D1nZp5j+/KZefY591FEYGbN6bnYAzDrZg6QWYIDZJbgAJklOEBmCZdM5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xBJqi5+XAjdknm+iAzQVVnAflrQAoPjef5HH0xRJvdTC85WIeKooT4p9A4iIo8Bm4APAHEkjy9rG9W9yogN0bgV3MdNxN7BhgsfQbhuAlcXtlcAzF3EsTZEk4GFgT0R8adRdXb1vkuZJmlPcvpRaO4I91IL04WKz8e1XREzoF3AH8ANq7z3/ZKJfv8X78ijQB5yl9t55FfBOajNUe4H/AOZe7HE2sV+3UHt79iKwo/i6o9v3DXgf8L1iv3YCf1bU3wM8B+wD/hmY0ehzeimPWYInEcwLine truncated
|
|
||||||
"text/plain": [
|
|
||||||
"<Figure size 432x288 with 1 Axes>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {
|
|
||||||
"needs_background": "light"
|
|
||||||
},
|
|
||||||
"output_type": "display_data"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"pylab.imshow(fluid.density.data[0,...,0], origin='lower', cmap='magma')"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "wnbQJvA-HPSL"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"Let's compute and show a few more steps of the simulation."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 7,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/",
|
|
||||||
"height": 489
|
|
||||||
},
|
|
||||||
"id": "tkhCOzc0ITsj",
|
|
||||||
"outputId": "f6366c12-1eb5-4ff6-e0d7-94b806bfd8e4"
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Computing frame 0\n",
|
|
||||||
"Computing frame 1\n",
|
|
||||||
"Computing frame 2\n",
|
|
||||||
"Computing frame 3\n",
|
|
||||||
"Computing frame 4\n",
|
|
||||||
"Computing frame 5\n",
|
|
||||||
"Computing frame 6\n",
|
|
||||||
"Computing frame 7\n",
|
|
||||||
"Computing frame 8\n",
|
|
||||||
"Computing frame 9\n",
|
|
||||||
"Computing frame 10\n",
|
|
||||||
"Computing frame 11\n",
|
|
||||||
"Computing frame 12\n",
|
|
||||||
"Computing frame 13\n",
|
|
||||||
"Computing frame 14\n",
|
|
||||||
"Computing frame 15\n",
|
|
||||||
"Computing frame 16\n",
|
|
||||||
"Computing frame 17\n",
|
|
||||||
"Computing frame 18\n",
|
|
||||||
"Computing frame 19\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"<matplotlib.image.AxesImage at 0x7fa84d2d8790>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 7,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAABzCAYAAACB+lklAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAA7h0lEQVR4nO29eaxsW1rY9/vW2nvXcOY7v3ff6zf3RNMTQ3dDO2Bohrba4FjIZhDGChJSFOQhSA4YKU6k/IHlyA5RbBxkE5OkA9gYTAdDEHQziARD093Q3bzu129+707vnHvumWrYw1rryx9r7zp153Onc+qct39S3XNr166qVV/V/va3v1FUlZaWlpaWw4c56AW0tLS0tNwdrQJvaWlpOaS0CrylpaXlkNIq8JaWlpZDSqvAW1paWg4prQJvaWlpOaQk+/lmItLmLLa0tNwjAgjWdLCSkdIhxSAiGMAIiMhtX2H672R7veHa7Gq99m+9w40UWvPcUO8QUBTweDwBR0EIFUE94G65zikuq+rJazfuqwKP2P1/y5aWliODkIAk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bbGHeZVRlfshgRE+5FjTpcwew7EcA5sCl3PPS9U6G+FVvB8Q7eJ747atsETkZG15IyI94NuALwG/C3xPvdsPAb92z6tpaXmLine truncated
|
|
||||||
"text/plain": [
|
|
||||||
"<Figure size 432x288 with 1 Axes>"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {
|
|
||||||
"needs_background": "light"
|
|
||||||
},
|
|
||||||
"output_type": "display_data"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"frames = [fluid.density.data[0,...,0]]\n",
|
|
||||||
"for frame in range(20):\n",
|
|
||||||
" print('Computing frame %d' % frame)\n",
|
|
||||||
" world.step(dt=1.5)\n",
|
|
||||||
" if frame%5==0:\n",
|
|
||||||
" frames.append(fluid.density.data[0,...,0])\n",
|
|
||||||
"\n",
|
|
||||||
"pylab.imshow(np.concatenate(frames,axis=1), origin='lower', cmap='magma')"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {
|
|
||||||
"id": "ooqVxCPM8PXl"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"It looks simple here, but this is a powerful tool. The simulation could easily be extended to more complex cases or 3D, and they're fully compatible with back-propagation pipelines of deep learning frameworks. \n",
|
|
||||||
"\n",
|
|
||||||
"In the next chapters we'll show how to use these simulations for training NNs, and how to steer and modify them via trained NNs. This will illustrate how much we can improve the training process by having a solver in the loop, and especially by having differentiable solvers."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "BL-AOqwMJmkq"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"collapsed_sections": [],
|
|
||||||
"name": "Forw Simulations with Φ-Flow.ipynb",
|
|
||||||
"provenance": []
|
|
||||||
},
|
|
||||||
"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.8.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 1
|
|
||||||
}
|
|
||||||
+14
-22
@@ -8,26 +8,32 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# Navier-Stokes Forward Simulation\n",
|
"# Navier-Stokes Forward Simulation\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Now let's target a somewhat more complex example: a fluid simulations based on the Navier-Stokes equations. This is still very simple with Φ<sub>Flow</sub>, as differentiable operators for all steps exist. The Navier-Stokes equations (in their incompressible form) introduce an additional pressure field $p$, and a constraint for conservation of mass. We're also moving a marker quantity $d$ with the flow, that indicates regions of higher temperature with a bouyance model via the parameter $\\xi$:\n",
|
"Now let's target a somewhat more complex example: a fluid simulations based on the Navier-Stokes equations. This is still very simple with Φ<sub>Flow</sub>, as differentiable operators for all steps exist. The Navier-Stokes equations (in their incompressible form) introduce an additional pressure field $p$, and a constraint for conservation of mass, as introduced in equation {eq}`model-boussinesq2d`. We're also moving a marker field, denoted by $d$ here, with the flow. It indicates regions of higher temperature, and excerts a force via with a bouyancy factor $\\xi$:\n",
|
||||||
"\n",
|
"\n",
|
||||||
"$\\begin{aligned}\n",
|
"$$\\begin{aligned}\n",
|
||||||
" \\frac{\\partial \\mathbf{u}}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla \\mathbf{u} &= - \\frac{\\Delta t}{\\rho} \\nabla p + \\nu \\nabla\\cdot \\nabla \\mathbf{u} + (0,1)^T \\xi d\n",
|
" \\frac{\\partial \\mathbf{u}}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla \\mathbf{u} &= - \\frac{\\Delta t}{\\rho} \\nabla p + \\nu \\nabla\\cdot \\nabla \\mathbf{u} + (0,1)^T \\xi d\n",
|
||||||
" \\quad \\text{s.t.} \\quad \\nabla \\cdot \\mathbf{u} = 0,\n",
|
" \\quad \\text{s.t.} \\quad \\nabla \\cdot \\mathbf{u} = 0,\n",
|
||||||
" \\\\\n",
|
" \\\\\n",
|
||||||
" \\frac{\\partial d}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla d &= 0 \n",
|
" \\frac{\\partial d}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla d &= 0 \n",
|
||||||
"\\end{aligned}$\n",
|
"\\end{aligned}$$\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Here $\\mathbf{g}$ collects the forcing terms. Below we'll use a simple buoyancy model. We'll solve this PDE on a closed domain with Dirchlet boundary conditions $\\mathbf{u}=0$ for the velocity, and Neumann boundaries $\\frac{\\partial p}{\\partial x}=0$ for pressure, on a domain $\\Omega$ with a physical size of $100 \\times 80$ units. \n",
|
"Here $\\mathbf{g}$ collects the forcing terms. Below we'll use a simple buoyancy model. We'll solve this PDE on a closed domain with Dirchlet boundary conditions $\\mathbf{u}=0$ for the velocity, and Neumann boundaries $\\frac{\\partial p}{\\partial x}=0$ for pressure, on a domain $\\Omega$ with a physical size of $100 \\times 80$ units. \n",
|
||||||
"\n",
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
"## Implementation\n",
|
"## Implementation\n",
|
||||||
"\n",
|
"\n",
|
||||||
"As before, the first command with a \"!\" prefix installs the [Φ<sub>Flow</sub> Python package from GitHub](https://github.com/tum-pbs/PhiFlow) via `pip` in your python environment. (Skip or modify this command if necessary.)"
|
"As in the previous section, the first command with a \"!\" prefix installs the [Φ<sub>Flow</sub> Python package from GitHub](https://github.com/tum-pbs/PhiFlow) via `pip` in your python environment. (Skip or modify this command if necessary.)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"colab": {
|
"colab": {
|
||||||
"base_uri": "https://localhost:8080/"
|
"base_uri": "https://localhost:8080/"
|
||||||
@@ -51,8 +57,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Setting up the simulation\n",
|
"## Setting up the simulation\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Φ<sub>Flow</sub> is object-oriented and centered around field data in the form of grids (internally represented by a tensor object). I.e. you assemble your simulation by constructing a number of grids, and updating them over the course of time steps.\n",
|
|
||||||
"\n",
|
|
||||||
"The following code sets up a simulation domain with the physical size, an inflow object to emit a smoke density, and three field: a staggerend `velocity` grid, and two centered grids for the smoke density and a pressure field. We'll use $40\\times32$ cells to discretize our domain, introduce a slight viscosity via $\\nu$, and define the time step to be $\\Delta t=1.5$. \n",
|
"The following code sets up a simulation domain with the physical size, an inflow object to emit a smoke density, and three field: a staggerend `velocity` grid, and two centered grids for the smoke density and a pressure field. We'll use $40\\times32$ cells to discretize our domain, introduce a slight viscosity via $\\nu$, and define the time step to be $\\Delta t=1.5$. \n",
|
||||||
"(As the following variables are constants, they have upper case names.)"
|
"(As the following variables are constants, they have upper case names.)"
|
||||||
]
|
]
|
||||||
@@ -92,9 +96,6 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# velocity = domain.staggered_grid(0) # alternatively vector_grid(0)\n",
|
|
||||||
"# smoke = pressure = divergence = domain.grid(0)\n",
|
|
||||||
"\n",
|
|
||||||
"smoke = DOMAIN.scalar_grid(0) # sampled at cell centers\n",
|
"smoke = DOMAIN.scalar_grid(0) # sampled at cell centers\n",
|
||||||
"velocity = DOMAIN.staggered_grid(0) # sampled in staggered form at face centers "
|
"velocity = DOMAIN.staggered_grid(0) # sampled in staggered form at face centers "
|
||||||
]
|
]
|
||||||
@@ -450,19 +451,10 @@
|
|||||||
"id": "ooqVxCPM8PXl"
|
"id": "ooqVxCPM8PXl"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"It looks simple here, but this simulation setup is a powerful tool. The simulation could easily be extended to more complex cases or 3D, and they're fully compatible with back-propagation pipelines of deep learning frameworks. \n",
|
"It looks simple here, but this simulation setup is a powerful tool. The simulation could easily be extended to more complex cases or 3D, and it is already fully compatible with back-propagation pipelines of deep learning frameworks. \n",
|
||||||
"\n",
|
"\n",
|
||||||
"In the next chapters we'll show how to use these simulations for training NNs, and how to steer and modify them via trained NNs. This will illustrate how much we can improve the training process by having a solver in the loop, and especially by having differentiable solvers. Before moving to these more complex training processes, we will cover a simpler supervised approach in the next chapter. This is very fundamental: even when aiming for advanced physics-based learning setups, a working supervised training is always the first step."
|
"In the next chapters we'll show how to use these simulations for training NNs, and how to steer and modify them via trained NNs. This will illustrate how much we can improve the training process by having a solver in the loop, especially when the solver is _differentiable_. Before moving to these more complex training processes, we will cover a simpler supervised approach in the next chapter. This is very fundamental: even when aiming for advanced physics-based learning setups, a working supervised training is always the first step."
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "BL-AOqwMJmkq"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
Reference in new issue
Block a user