Skip to content

Commit

Permalink
Merge pull request #76 from tum-pbs/develop
Browse files Browse the repository at this point in the history
2.2.1
  • Loading branch information
holl- authored Aug 31, 2022
2 parents 7f0c2c9 + 6b81334 commit f5f7a78
Show file tree
Hide file tree
Showing 30 changed files with 1,112 additions and 1,227 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ![PhiFlow](docs/figures/Logo1_layout.png)
# ![PhiFlow](docs/figures/Logo_DallE2_3_layout.png)

![Build Status](https://github.com/tum-pbs/PhiFlow/actions/workflows/unit-tests.yml/badge.svg)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/phiflow.svg)](https://pypi.org/project/phiflow/)
Expand All @@ -17,9 +17,9 @@ making it easy to build end-to-end differentiable functions involving both learn

[//]: # (![Gui](https://tum-pbs.github.io/PhiFlow/figures/WebInterface.png))

| <img src="docs/figures/RenderedSmoke.gif"> | <img src="docs/figures/Animations.gif"> |
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Fluids Tutorial](https://colab.research.google.com/github/tum-pbs/PhiFlow/blob/develop/docs/Fluids_Tutorial.ipynb) &nbsp;&nbsp; [Φ<sub>Flow</sub> to Blender](https://github.com/intergalactic-mammoth/phiflow2blender) | [Animation Gallery](https://colab.research.google.com/github/tum-pbs/PhiFlow/blob/2.2-develop/docs/Animations.ipynb) &nbsp;&nbsp; [Solar System](https://colab.research.google.com/github/tum-pbs/PhiFlow/blob/develop/docs/Planets_Tutorial.ipynb) &nbsp;&nbsp; [Learning to Throw](https://colab.research.google.com/github/tum-pbs/PhiFlow/blob/develop/docs/Learn_to_Throw_Tutorial.ipynb) |
| <img src="docs/figures/RenderedSmoke.gif"> | <img src="docs/figures/Animations.gif"> |
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Fluids Tutorial](https://tum-pbs.github.io/PhiFlow/Fluids_Tutorial.html) &nbsp;&nbsp; [Φ<sub>Flow</sub> to Blender](https://github.com/intergalactic-mammoth/phiflow2blender) | [Animation Gallery](https://tum-pbs.github.io/PhiFlow/Animations.html) &nbsp;&nbsp; [Solar System](https://tum-pbs.github.io/PhiFlow/Planets_Tutorial.html) &nbsp;&nbsp; [Learning to Throw](https://tum-pbs.github.io/PhiFlow/Learn_to_Throw_Tutorial.html) |


## Features
Expand Down
8 changes: 4 additions & 4 deletions demos/differentiate_advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


DOMAIN = dict(x=50, y=50, bounds=Box(x=100, y=100))
MARKER_0 = CenteredGrid(Sphere((40, 50), radius=20), extrapolation.BOUNDARY, **DOMAIN)
MARKER_TARGET = CenteredGrid(Sphere((60, 50), radius=20), extrapolation.BOUNDARY, **DOMAIN)
MARKER_0 = CenteredGrid(Sphere(x=40, y=50, radius=20), extrapolation.BOUNDARY, **DOMAIN)
MARKER_TARGET = CenteredGrid(Sphere(x=60, y=50, radius=20), extrapolation.BOUNDARY, **DOMAIN)


def loss(velocity):
Expand All @@ -20,15 +20,15 @@ def loss(velocity):
return field.l2_loss(smooth_diff), advected, smooth_diff


gradient_function = field.functional_gradient(loss, get_output=True)
gradient_function = field.functional_gradient(loss, 'velocity', get_output=True)

velocity_fit = StaggeredGrid(0, extrapolation.ZERO, **DOMAIN)
marker_fit = CenteredGrid(0, extrapolation.BOUNDARY, **DOMAIN)
smooth_difference = CenteredGrid(0, extrapolation.BOUNDARY, **DOMAIN)
viewer = view(display=['marker_fit', 'gradient'], play=False, namespace=globals())

for iteration in viewer.range(warmup=1):
(loss, marker_fit, smooth_difference), (gradient,) = gradient_function(velocity_fit)
(loss, marker_fit, smooth_difference), gradient = gradient_function(velocity_fit)
viewer.info(f"Loss = {loss:.2f}")
viewer.log_scalars(loss=loss)
velocity_fit -= gradient
4 changes: 2 additions & 2 deletions demos/differentiate_pressure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def loss(v0, p0):
return field.l2_loss((v1 - TARGET) * RIGHT), v1, p


eval_grad = field.functional_gradient(loss, [0], get_output=True)
eval_grad_v0 = field.functional_gradient(loss, 'v0', get_output=True)
p0 = None
velocity_fit = StaggeredGrid(Noise(), extrapolation.ZERO, **DOMAIN) * 0.1 * LEFT
viewer = view('incompressible_velocity', TARGET, 'gradient', velocity_fit, 'remaining_divergence', play=False, namespace=globals())

for iteration in viewer.range(warmup=1):
(loss, incompressible_velocity, pressure_guess), (gradient,) = eval_grad(velocity_fit, p0)
(loss, incompressible_velocity, pressure_guess), gradient = eval_grad_v0(velocity_fit, p0)
remaining_divergence = field.divergence(incompressible_velocity)
viewer.log_scalars(loss=loss)
velocity_fit -= gradient
Loading

0 comments on commit f5f7a78

Please sign in to comment.