|
5 | 5 |
|
6 | 6 | ## A native PyTorch port of [Google's Computational Fluid Dynamics package in Jax](https://github.com/google/jax-cfd) |
7 | 7 | This port is a good pedagogical tool to learn how to implement traditional numerical solvers using modern deep learning software interfaces. The main changes are documented in the [`torch_cfd` directory](./torch_cfd/). The most significant changes in all routines include: |
8 | | - - Supports for nonhomogenous boundary conditions, many routines in Jax-CFD only work with only periodic boundary. |
9 | | - - Routines that rely on the functional programming of Jax have been rewritten to be the PyTorch's tensor-in-tensor-out style, which is arguably more user-friendly to debugging as one can view intermediate values in tensors in VS Code debugger, opposed to Jax's `JaxprTrace`. |
10 | | - - All operations take into consideration the batch dimension of tensors `(b, *, n, m)` regardless of `*` dimension, for example, `(b, T, C, n, m)`, which is similar to PyTorch behavior. In the original Jax-CFD package, only a single trajectory is implemented. The stencil operators are changed to generally operate from the last dimension using negative indexing, following `torch.nn.functional.pad`'s behavior. |
11 | | - - Functions and operators are in general implemented as `nn.Module` like a factory template. |
12 | | - - Jax-CFD's `funcutils.trajectory` function supports tracking only one field variable (vorticity or velocity). In Torch-CFD, extra fields computation and tracking are more accessible and easier for user to add, such as time derivatives $\partial_t\mathbf{u}_h$ and PDE residual $R(\mathbf{u}_h):=\mathbf{f}-\partial_t \mathbf{u}_h-(\mathbf{u}_h\cdot\nabla)\mathbf{u}_h + \nu \Delta \mathbf{u}_h$. |
| 8 | + - (**enhanced**) Nonhomogenous boundary conditions support: the user can provide array-valued or function-valued bcs. Many routines in Jax-CFD only work with only periodic or constant boundary. |
| 9 | + - (**changed**) Routines that rely on the functional programming of Jax have been rewritten to be the PyTorch's tensor-in-tensor-out style, which is arguably more user-friendly to debugging as one can view intermediate values in tensors in VS Code debugger, opposed to Jax's `JaxprTrace`. |
| 10 | + - (**enhanced**) Batch-dimension: all operations take into consideration the batch dimension of tensors `(b, *, n, m)` regardless of `*` dimension, for example, `(b, T, C, n, m)`, which is similar to PyTorch behavior. In the original Jax-CFD package, only a single trajectory is implemented. The stencil operators are changed to generally operate from the last dimension using negative indexing, following `torch.nn.functional.pad`'s behavior. |
| 11 | + - (**changed**) Neural Network interface: functions and operators are in general implemented as `nn.Module` like a factory template. |
| 12 | + - (**enhanced**) Jax-CFD's `funcutils.trajectory` function supports tracking only one field variable (vorticity or velocity). In Torch-CFD, extra fields computation and tracking are more accessible and easier for user to add, such as time derivatives $\partial_t\mathbf{u}_h$ and PDE residual $R(\mathbf{u}_h):=\mathbf{f}-\partial_t \mathbf{u}_h-(\mathbf{u}_h\cdot\nabla)\mathbf{u}_h + \nu \Delta \mathbf{u}_h$. |
13 | 13 |
|
14 | 14 |
|
15 | 15 | ## Neural Operator-Assisted Navier-Stokes Equations simulator. |
@@ -60,7 +60,7 @@ PR welcome. Currently, the port of `torch-cfd` currently includes: |
60 | 60 | - The pseudospectral method for vorticity uses anti-aliasing filtering techniques for nonlinear terms to maintain stability. |
61 | 61 | - The finite volume method on a MAC grids for velocity, and using the projection scheme to impose the divergence free condition. |
62 | 62 | - Temporal discretization: Currently it has only single-step RK4-family schemes uses explicit time-stepping for advection, either implicit or explicit time-stepping for diffusion. |
63 | | -- Boundary conditions: only periodic and Dirichlet boundary conditions for velocity, Neumann boundary for pressure. |
| 63 | +- Boundary conditions: periodic and Dirichlet boundary conditions for velocity, Neumann boundary for pressure. |
64 | 64 | - Solvers: pseudoinverse (either FFT-based or SVD based), Jacobi- or Multigrid V-cycle-preconditioned Conjugate gradient. |
65 | 65 |
|
66 | 66 | ## Reference |
|
0 commit comments