DP code updates
This commit is contained in:
parent
d42fe17a6f
commit
c4947c78e9
@ -11,6 +11,8 @@
|
||||
"Also, as we choose an initial discretization for the DP approach, the unknown initial state consists of the sampling points of the involved physical fields, and we can simply represent these unknowns as floating point variables. Hence, even for the initial state we do not need to set up an NN. Thus, our Burgers reconstruction problem reduces to a gradient-based opitmization without any NN when solving it with DP. Nonetheless, it's a very good starting point to illustrate the process.\n",
|
||||
"\n",
|
||||
"First, we'll set up our discretized simulation. Here we can employ phiflow, as shown in the overview section on _Burgers forward simulations_. \n",
|
||||
"[[run in colab]](https://colab.research.google.com/github/tum-pbs/pbdl-book/blob/main/diffphys-code-burgers.ipynb)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Initialization\n",
|
||||
"\n",
|
||||
|
@ -10,7 +10,14 @@
|
||||
"\n",
|
||||
"**(Note - this example is not final. TODO: update from diffphys-code-ns-v1-syncWith2.ipynb, diff display for target, adjust params so that the loss properly goes down)**\n",
|
||||
"\n",
|
||||
"Next, we'll target a more complex example with the Navier-Stokes equations as physical model. In line with {doc}`overview-ns-forw`, we'll target a 2D case with velocity $\\mathbf{u}$, no explicit viscosity term, and a marker density $d$ that drives a simple Boussinesq buoyancy term $\\eta d$ adding a force along the y dimension. For the velocity this gives:\n",
|
||||
"Next, we'll target a more complex example with the Navier-Stokes equations as physical model. In line with {doc}`overview-ns-forw`, we'll target a 2D case.\n",
|
||||
"\n",
|
||||
"As optimization objective we'll consider a more difficult variant of the previous Burgers example: the state of the observed density $d$ should match a given target after $n=20$ steps of simulation. In contrast to before, the marker $d$ cannot be modified in any way, but only the initial state of the velocity $\\mathbf{u}_0$ at $t=0$. This gives us a split between observable quantities for the loss formulation and quantities that we can interact with during the optimization (or later on via NNs).\n",
|
||||
"[[run in colab]](https://colab.research.google.com/github/tum-pbs/pbdl-book/blob/main/diffphys-code-ns.ipynb)\n",
|
||||
"\n",
|
||||
"## Physical Model\n",
|
||||
"\n",
|
||||
"We'll use a Navier-Stokes model with velocity $\\mathbf{u}$, no explicit viscosity term, and a marker density $d$ that drives a simple Boussinesq buoyancy term $\\eta d$ adding a force along the y dimension. For the velocity this gives:\n",
|
||||
"\n",
|
||||
"$\\begin{aligned}\n",
|
||||
" \\frac{\\partial u_x}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla u_x &= - \\frac{1}{\\rho} \\nabla p \n",
|
||||
@ -25,7 +32,6 @@
|
||||
"$\\begin{aligned}\n",
|
||||
" \\frac{\\partial s}{\\partial{t}} + \\mathbf{u} \\cdot \\nabla s &= 0 \n",
|
||||
"\\end{aligned}$\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
@ -35,9 +41,8 @@
|
||||
"source": [
|
||||
"## Formulation\n",
|
||||
"\n",
|
||||
"As optimization objective we'll consider a more difficult variant of the previous example: the state of the observed density $d$ should match a given target after $n=20$ steps of simulation. In contrast to before, the marker $d$ cannot be modified in any way, but only the initial state of the velocity $\\mathbf{u}_0$ at $t=0$. This gives us a split between observable quantities for the loss formulation and quantities that we can interact with during the optimization (or later on via NNs).\n",
|
||||
"\n",
|
||||
"With the notation from {doc}`overview-equations` this gives the minimization problem \n",
|
||||
"With the notation from {doc}`overview-equations` the inverse problem outlined above can be formulated as a minimization problem \n",
|
||||
"\n",
|
||||
"$$\n",
|
||||
"\\text{arg min}_{\\mathbf{u}_{0}} \\sum_i |f(x_{t_e,i} ; \\theta)-y^*_{t_e,i}|^2 ,\n",
|
||||
@ -61,7 +66,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Start-up\n",
|
||||
"## Starting the Implementation\n",
|
||||
"\n",
|
||||
"First, let's get the loading of python modules out of the way. By importing `phi.torch.flow`, we get fluid simulation functions that work within pytorch graphs and can provide gradients (`phi.tf.flow` would be the alternative for tensorflow).\n",
|
||||
"\n"
|
||||
|
Loading…
Reference in New Issue
Block a user