There are many methods for numerically solving partial differential equations. Finite element methods, geometric multigrid, algebraic multigrid. Stochastic methods… Building a solver from base principles is a wonderful and improving activity but something that I do not wish to do recreationally. For a list that weights them by usefulness in a machine learning context see ML PDEs.

## HOWTO

## ADCME

A Julia system using Tensorflow to handle some of the autodiff mechanics.

ADCME is suitable for conducting inverse modeling in scientific computing; specifically, ADCME targets physics informed machine learning, which leverages machine learning techniques to solve challenging scientific computing problems. The purpose of the package is to:

- provide differentiable programming framework for scientific computing based on TensorFlow automatic differentiation (AD) backend;
- adapt syntax to facilitate implementing scientific computing, particularly for numerical PDE discretization schemes;
- supply missing functionalities in the backend (TensorFlow) that are important for engineering, such as sparse linear algebra, constrained optimization, etc.
Applications include

- physics informed machine learning (a.k.a., scientific machine learning, physics informed learning, etc.)
- coupled hydrological and full waveform inversion
- constitutive modeling in solid mechanics
- learning hidden geophysical dynamics
- parameter estimation in stochastic processes
The package inherits the scalability and efficiency from the well-optimized backend TensorFlow. Meanwhile, it provides access to incorporate existing C/C++ codes via the custom operators. For example, some functionalities for sparse matrices are implemented in this way and serve as extendable ”plugins” for ADCME.

AFAICT this implies that GPUs are not in general supported.

## TenFEM

https://sciml.ai/ (plus maybe Julaifem)?

TenFEM offers a small library of differentiable FEM solvers fpr Tensorflow.

## JuliaFEM

Julaifem is an umbrella organisation supporting julia-backed FEM solvers. The documentation is tricksy, but check out the examples. Analyses and solvers · JuliaFEM.jl

## Trixi

Trixi.jl is a numerical simulation framework for hyperbolic conservation laws written in Julia. A key objective for the framework is to be useful to both scientists and students. Therefore, next to having an extensible design with a fast implementation, Trixi is focused on being easy to use for new or inexperienced users, including the installation and postprocessing procedures.

## Firedrake

Firedrake seems popular for Python projects that do not need GPU?

Firedrake is an automated system for the solution of partial differential equations using the finite element method (FEM). Firedrake uses sophisticated code generation to provide mathematicians, scientists, and engineers with a very high productivity way to create sophisticated high performance simulations.

- Expressive specification of any PDE using the Unified Form Language from the FEniCS Project.
- Sophisticated, programmable solvers through seamless coupling with PETSc.…
- Sophisticated automatic optimisation, including sum factorisation for high order elements, and vectorisation.

## FEniCS

Also seems to be a friendly PDE solver. Also lacking in GPU support. However, it does have an interface to pytorch, barkm/torch-fenics so is a tenable, if slow, component in ML PDE solution (Alnæs 2012; Alnæs et al. 2015, 2014, 2009; Alnæs, Logg, and Mardal 2012; Kirby 2004, 2012; Kirby and Logg 2006; Logg, Mardal, et al. 2012; Logg, Ølgaard, et al. 2012; Logg and Wells 2010; Logg, Wells, and Hake 2012).

FEniCS is a popular open-source (LGPLv3) computing platform for solving partial differential equations (PDEs). FEniCS enables users to quickly translate scientific models into efficient finite element code. With the high-level Python and C++ interfaces to FEniCS, it is easy to get started, but FEniCS offers also powerful capabilities for more experienced programmers. .FEniCS runs on a multitude of platforms ranging from laptops to high-performance clusters.

As an illustration of how to program a simple PDE model with FEniCS, consider the Stokes equations in variational form:

\[\int_{\Omega} \mathrm{grad} \, u : \mathrm{grad} \, v \,\mathrm{d}x \, – \int_{\Omega} p \, \mathrm{div} \, v \,\mathrm{d}x + \int_{\Omega} \mathrm{div} \, u \, q \,\mathrm{d}x = \int_{\Omega} f \cdot v \,\mathrm{d}x.\]

The variational problem is easily transcribed into Python using mathematical operators in FEniCS:

```
# Define function space
P2 = VectorElement('P', tetrahedron, 2)
P1 = FiniteElement('P', tetrahedron, 1)
TH = P2 * P1
W = FunctionSpace(mesh, TH)
# Define variational problem
(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)
a = inner(grad(u), grad(v))*dx - p*div(v)*dx + div(u)*q*dx
L = dot(f, v)*dx
# Compute solution
w = Function(W)
solve(a == L, w, [bc1, bc0])
```

## dolfin-adjoint

dolfin-adjoint (Mitusch, Funke, and Dokken 2019):

The dolfin-adjoint project automatically

derives the discrete adjoint and tangent linear modelsfrom a forward model written in the Python interface to FEniCS and Firedrake.These adjoint and tangent linear models are key ingredients in many important algorithms, such as data assimilation, optimal control, sensitivity analysis, design optimisation, and error estimation. Such models have made an enormous impact in fields such as meteorology and oceanography, but their use in other scientific fields has been hampered by the great practical difficulty of their derivation and implementation. In his recent book, Naumann (2011) states that

[T]he automatic generation of optimal (in terms of robustness and efficiency) adjoint versions of large-scale simulation code is

one of the great open challenges in the field of High-Performance Scientific Computing.

The dolfin-adjoint project aims to solve this problemfor the case where the model is implemented in the Python interface to FEniCS/Firedrake.

This provides the AD backend to `torch-fenics`

.

## PolyFEM

PolyFEM is a simple C++ and Python finite element library. We provide a wide set of common PDEs including:

- Laplace
- Helmholtz
- Linear Elasticity
- Saint-Venant Elasticity
- Neo-Hookean Elasticity
- Stokes
- Navier Stokes [beta]
PolyFEM simplicity lies on the interface: just pick a problem, select some boundary condition, and solve. No need to construct complicated function spaces, or learn a new scripting language: everything is set-up trough a JSON interface or through the Setting class in python.

## SfePy

SfePy is a (sic) software for solving systems of coupled partial differential equations (PDEs) by the finite element method in 1D, 2D and 3D. It can be viewed both as black-box PDE solver, and as a Python package which can be used for building custom applications. The word “simple” means that complex FEM problems can be coded very easily and rapidly.

## fipy

fipy is original school:

FiPy is an object oriented, partial differential equation (PDE) solver, written in Python, based on a standard finite volume (FV) approach. … The FiPy framework includes terms for transient diffusion, convection and standard sources, enabling the solution of arbitrary combinations of coupled elliptic, hyperbolic and parabolic PDEs. Currently implemented models include phase field treatments of polycrystalline, dendritic, and electrochemical phase transformations as well as a level set treatment of the electrodeposition process.

## PyAMG

pyamg is an algebraic multigrid solver, which is … a kind of multi-resolution method?

AMG is a multilevel technique for solving large-scale linear systems with optimal or near-optimal efficiency. Unlike geometric multigrid, AMG requires little or no geometric information about the underlying problem and develops a sequence of coarser grids directly from the input matrix. This feature is especially important for problems discretised on unstructured meshes and irregular grids:

```
A = poisson((500,500), format='csr') # 2D Poisson problem on 500x500 grid
ml = ruge_stuben_solver(A) # construct the multigrid hierarchy
print ml # print hierarchy information
b = rand(A.shape[0]) # pick a random right hand side
x = ml.solve(b, tol=1e-10) # solve Ax=b to a tolerance of 1e-8
print("residual norm is", norm(b - A*x)) # compute norm of residual vector
```

See Yousef Saad’s textbooks on algebraic multigrid methods (free online).

## Single-purpose solvers

nsfds2 is a Navier-Stokes solver in 2d especially for acoustics models

## References

*Automated Solution of Differential Equations by the Finite Element Method, Volume 84 of Lecture Notes in Computational Science and Engineering*, edited by Anders Logg, Kent-Andre Mardal, and Garth N. Wells. Springer.

*Archive of Numerical Software*3 (100). https://doi.org/10.11588/ans.2015.100.20553.

*Automated Solution of Differential Equations by the Finite Element Method, Volume 84 of Lecture Notes in Computational Science and Engineering*, edited by Anders Logg, Kent-Andre Mardal, and Garth N. Wells. Springer.

*International Journal of Computational Science and Engineering*4 (4): 231–44. https://doi.org/10.1504/IJCSE.2009.029160.

*ACM Transactions on Mathematical Software*40 (2). https://doi.org/10.1145/2566630.

*Mathematical Programming Computation*11 (1): 1–36. https://doi.org/10.1007/s12532-018-0139-4.

*Journal of Open Source Education*2 (16): 21. https://doi.org/10.21105/jose.00021.

*Advances in Computational Mathematics*45 (4): 1897–1921. https://doi.org/10.1007/s10444-019-09666-0.

*ACM Transactions on Mathematical Software*30 (4): 502–16. https://doi.org/10.1145/1039813.1039820.

*Automated Solution of Differential Equations by the Finite Element Method, Volume 84 of Lecture Notes in Computational Science and Engineering*, edited by Anders Logg, Kent-Andre Mardal, and Garth N. Wells. Springer.

*ACM Transactions on Mathematical Software*32 (3). https://doi.org/10.1145/1163641.1163644.

*Automated Solution of Differential Equations by the Finite Element Method*. Springer. https://doi.org/10.1007/978-3-642-23099-8.

*ACM Transactions on Mathematical Software*37 (2). https://doi.org/10.1145/1731022.1731030.

*Journal of Open Source Software*4 (38): 1292. https://doi.org/10.21105/joss.01292.

*Fluids*4 (3, 3): 159. https://doi.org/10.3390/fluids4030159.

## No comments yet. Why not leave one?