updated NS forward sim
This commit is contained in:
parent
f9d78531c5
commit
f533fd7a4f
@ -16,7 +16,7 @@
|
||||
"## Model\n",
|
||||
"\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",
|
||||
" \\frac{\\partial u}{\\partial{t}} + u \\nabla u =\n",
|
||||
@ -87,7 +87,10 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"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",
|
||||
"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."
|
||||
]
|
||||
|
File diff suppressed because one or more lines are too long
@ -8,26 +8,32 @@
|
||||
"source": [
|
||||
"# Navier-Stokes Forward Simulation\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",
|
||||
"$\\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",
|
||||
" \\quad \\text{s.t.} \\quad \\nabla \\cdot \\mathbf{u} = 0,\n",
|
||||
" \\\\\n",
|
||||
" \\frac{\\partial d}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla d &= 0 \n",
|
||||
"\\end{aligned}$\n",
|
||||
"\\end{aligned}$$\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",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Implementation\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",
|
||||
"execution_count": null,
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
@ -51,8 +57,6 @@
|
||||
"source": [
|
||||
"## Setting up the simulation\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",
|
||||
"(As the following variables are constants, they have upper case names.)"
|
||||
]
|
||||
@ -92,9 +96,6 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"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",
|
||||
"velocity = DOMAIN.staggered_grid(0) # sampled in staggered form at face centers "
|
||||
]
|
||||
@ -450,19 +451,10 @@
|
||||
"id": "ooqVxCPM8PXl"
|
||||
},
|
||||
"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",
|
||||
"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": {
|
||||
|
Loading…
Reference in New Issue
Block a user