added DP control, small update of PINN code
This commit is contained in:
parent
c6906677f9
commit
3017836c8c
4
_toc.yml
4
_toc.yml
@ -21,9 +21,11 @@
|
||||
- file: diffphys-code-burgers.ipynb
|
||||
- file: diffphys-discuss.md
|
||||
- file: diffphys-code-ns.ipynb
|
||||
- file: diffphys-dpvspinn.md
|
||||
- file: diffphys-examples.md
|
||||
sections:
|
||||
- file: diffphys-code-sol.ipynb
|
||||
- file: diffphys-control.ipynb
|
||||
- file: diffphys-dpvspinn.md
|
||||
- file: diffphys-outlook.md
|
||||
- file: physgrad.md
|
||||
sections:
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,7 +0,0 @@
|
||||
Inverse Problems
|
||||
=======================
|
||||
|
||||
... control example ICLR'20 ...
|
||||
|
||||
**TODO**
|
||||
|
||||
@ -17,4 +17,6 @@ achieved via DP approaches it is nonetheless a good time to summarize the pros a
|
||||
- not compatible with all simulators (need to provide gradients)
|
||||
- require more heavy machinery (in terms of framework support) than previously discussed methods
|
||||
|
||||
Especially the last point is one that is bound to strongly improve in a fairly short time, but for now it's important to keep in mind that not every simulator is suitable for DP training out of the box. Hence, in this book we'll focus on examples using phiflow, which was designed for interfacing with deep learning frameworks. Next we can target more a complex scenarios involving fluids.
|
||||
Especially the last point is one that is bound to strongly improve in a fairly short time, but for now it's important to keep in mind that not every simulator is suitable for DP training out of the box. Hence, in this book we'll focus on examples using phiflow, which was designed for interfacing with deep learning frameworks.
|
||||
Next we can target more some complex scenarios to showcase what can be achieved with differentiable physics.
|
||||
|
||||
|
||||
23
diffphys-examples.md
Normal file
23
diffphys-examples.md
Normal file
@ -0,0 +1,23 @@
|
||||
Complex Examples with DP
|
||||
=======================
|
||||
|
||||
The following two sections with show code examples of two more complex cases that
|
||||
will show what can be achieved via differentiable physics training.
|
||||
|
||||
First, we'll show a scenario that employs deep learning to learn the erros
|
||||
of a numerical simulation, following Um et al. {cite}`um2020sol`.
|
||||
This is a very fundamental task, and requires the learned model to closely
|
||||
interact with a numerical solver. Hence, it's a prime example of
|
||||
situations where it's crucial to bring the numerical solver into the
|
||||
deep learning loop.
|
||||
|
||||
Next, we'll show a tough inverse problem, namely the long-term control
|
||||
of a fluid simulation, following Holl et al. {cite}`holl2019pdecontrol`.
|
||||
This task requires long term planning,
|
||||
and hence needs two networks, one to _predict_ the evolution,
|
||||
and another one to _act_ to reach the desired goal.
|
||||
|
||||
Both cases require quite a bit more resources than the previous examples, so you
|
||||
can expect these notebooks to run longer (and it's a good idea to use the checkpointing
|
||||
mechanisms when working with these examples).
|
||||
|
||||
@ -20,7 +20,7 @@ The hybrid approach also bears particular promise for simulators: it improves ge
|
||||
|
||||
We've just scratched the surface regarding the possibilities of this combination. The examples with Burgers equation and Navier-Stokes solvers are non-trivial, and good examples for advection-diffusion-type PDEs. However, there's a wide variety of other potential combinations, to name just a few examples:
|
||||
|
||||
* PDEs for chemical reactions often show complex behavior due to the ineractions of mulltiple species. Here, and especially interesting direction is to train models that quickly learn to predict the evolution of an experiment or machine, and adjust control knobs to stabilize it, i.e., an online _control_ setting.
|
||||
* PDEs for chemical reactions often show complex behavior due to the interactions of mulltiple species. Here, and especially interesting direction is to train models that quickly learn to predict the evolution of an experiment or machine, and adjust control knobs to stabilize it, i.e., an online _control_ setting.
|
||||
|
||||
* Plasma simulations share a lot with vorticity-based formulations for fluids, but additionally introduce terms to handle electric and magnetic interactions within the material. Likwise, controllers for plasma fusion experiments and generators are an excellent topic with plenty of potential for DL with differentiable physics.
|
||||
|
||||
|
||||
@ -243,6 +243,7 @@
|
||||
"vels_img = np.asarray( np.concatenate(vels, axis=-1), dtype=np.float32 ) \n",
|
||||
"\n",
|
||||
"# save for comparison with reconstructions later on\n",
|
||||
"import os; os.makedirs(\"./temp\",exist_ok=True)\n",
|
||||
"np.savez_compressed(\"./temp/burgers-groundtruth-solution.npz\", np.reshape(vels_img,[N,STEPS+1])) # remove batch & channel dimension\n",
|
||||
"\n",
|
||||
"show_state(vels_img)"
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
"source": [
|
||||
"# Burgers Optimization with a Physics-Informed NN\n",
|
||||
"\n",
|
||||
"**Warning: this example still needs phiflow1.x and tensorflow 1.x! **\n",
|
||||
"\n",
|
||||
"To illustrate how the physics-informed losses work, let's consider a \n",
|
||||
"reconstruction example with a simple yet non-linear equation in 1D:\n",
|
||||
"Burgers equation $\\frac{\\partial u}{\\partial{t}} + u \\nabla u = \\nu \\nabla \\cdot \\nabla u$\n",
|
||||
@ -20,7 +18,8 @@
|
||||
"\n",
|
||||
"## Preliminaries\n",
|
||||
"\n",
|
||||
"Let's just load TF and phiflow for now, and initialize the random sampling."
|
||||
"Let's just load TF and phiflow for now, and initialize the random sampling. (_Note: this example uses an older version of phiflow (1.x), and TF 1.x._)\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -29,6 +28,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install --upgrade --quiet git+https://github.com/tum-pbs/PhiFlow@1.5.1\n",
|
||||
"\n",
|
||||
"from phi.tf.flow import *\n",
|
||||
"import numpy as np\n",
|
||||
"\n",
|
||||
@ -531,7 +532,7 @@
|
||||
"vel_resim = [x.velocity.data for x in state]\n",
|
||||
"\n",
|
||||
"fig = plt.figure().gca()\n",
|
||||
"pltx = np.linspace(-1,1,len(vels[0].flatten()))\n",
|
||||
"pltx = np.linspace(-1,1,len(vel_resim[0].flatten()))\n",
|
||||
"fig.plot(pltx, vel_resim[ 0].flatten(), lw=2, color='blue')\n",
|
||||
"#fig.plot(pltx, vel_resim[steps//4].flatten(), lw=2, color='green')\n",
|
||||
"fig.plot(pltx, vel_resim[steps//2].flatten(), lw=2, color='cyan')\n",
|
||||
@ -708,6 +709,7 @@
|
||||
"vels = np.reshape( vels, [vels.shape[1],vels.shape[2]] )\n",
|
||||
"\n",
|
||||
"# save for comparison with other methods\n",
|
||||
"import os; os.makedirs(\"./temp\",exist_ok=True)\n",
|
||||
"np.savez_compressed(\"./temp/burgers-pinn-solution.npz\",vels) ; print(\"Vels array shape: \"+format(vels.shape))"
|
||||
]
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user