AutoPDEx

AutoPDEx: An Automized Partial Differential Equation solver based on JAX - Published in JOSS (2025)

https://github.com/bodetobias/autopdex

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

differential-algebraic-equations finite-element-method jax ordinary-differential-equations partial-differential-equations sensitivity-analysis
Last synced: 6 months ago · JSON representation

Repository

An Automized Partial Differential Equation solver based on JAX

Basic Info
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 11
Topics
differential-algebraic-equations finite-element-method jax ordinary-differential-equations partial-differential-equations sensitivity-analysis
Created over 1 year ago · Last pushed 11 months ago
Metadata Files
Readme Contributing License Citation Cla

README.md

DOI

AutoPDEx is a free open source partial differential equation (PDE) solver based on the automatic code transformation capabilities of JAX.

The idea of the project is to develop a modular and easily extendable environment for the solution of boundary and initial boundary value problems, which provides automatic sensitivity analysis, allows for good integration with machine learning algorithms and can be executed on accelerators such as GPUs.

The documentation with more examples is available here.

Installation

To install AutoPDEx, you can use the following command. Note, that it requires python>=3.10.

pip install --upgrade pip pip install autopdex

Example

This is a short example for solving Poisson's problem with homogeneous Dirichlet conditions on the domain $[0,1]\times[0,1]$ with the source term

$$b = 20 \left(\sin{\left(10\ \boldsymbol{x}\cdot\boldsymbol{x}\right)} - \cos{\left(10\ \left(\boldsymbol{x} - \boldsymbol{x}2\right) \cdot \left(\boldsymbol{x} - \boldsymbol{x}2\right)\right)}\right)$$

where $\boldsymbol{x}_2 = (1, 0.5)^T$.

Download full example

First, we import the necessary packages and enable double precision.

```python import jax import jax.numpy as jnp import flax import meshio

from autopdex import seeder, geometry, solver, utility, models, spaces, mesher jax.config.update("jaxenablex64", True)

```

Generate the mesh (or import the node coordinates and connectivity)

python pts = [[0., 0.], [1., 0.], [1., 1.], [0., 1.]] coords, elems = mesher.structured_mesh((200, 200), pts, 'quad') node_coordinates = {'phi': coords,} connectivity = {'phi': elems,}

Selection of nodes and degrees of freedom for Dirichlet conditions

python sdf = lambda x: geometry.psdf_polygon(x, pts) dirichlet_nodes = geometry.in_sdfs(node_coordinates['phi'], sdf) dirichlet_dofs = {'phi': dirichlet_nodes,} dirichlet_conditions = utility.dict_zeros_like(dirichlet_dofs, dtype=jnp.float64)

The variational problem is defined in terms of the potential $\Pi$. The stationarity condition of this potential gives the Poisson equation. The potential is represented by the integral

$$\Pi(\phi) = \int_\Omega \left( \frac{1}{2} \nabla \phi \cdot \nabla \phi - b \phi \right)\ \mathrm{d}\Omega$$

This leads to the following Euler-Lagrange equation (Poisson's equation):

$$- \Delta \phi = b$$

python def integrand_fun(x_int, ansatz_fun, settings, static_settings, elem_number, set): # Definition of custom functional x = ansatz_fun['physical coor'](x_int) phi_fun = ansatz_fun['phi'] phi = phi_fun(x_int) dphi_dx = jax.jacrev(phi_fun)(x_int) x_2 = x - jnp.array([1., 0.5]) b = 20 * (jnp.sin(10 * x @ x) - jnp.cos(10 * x_2 @ x_2)) return (1/2) * dphi_dx @ dphi_dx - b * phi

Set up the finite element, here Q1 elements for the field 'phi' python user_potential = models.mixed_reference_domain_potential( integrand_fun, {'phi': spaces.fem_iso_line_quad_brick,}, *seeder.gauss_legendre_nd(dimension = 2, order = 2), 'phi')

Prepare the settings for autopdex python static_settings = flax.core.FrozenDict({ 'assembling mode': ('user potential',), 'solution structure': ('nodal imposition',), 'model': (user_potential, ), 'solver type': 'newton', 'solver backend': 'scipy', 'solver': 'lapack', 'verbose': 1, }) settings = { 'connectivity': (connectivity,), 'dirichlet dofs': dirichlet_dofs, 'node coordinates': node_coordinates, 'dirichlet conditions': dirichlet_conditions, }

Compile, assemble and solve linear system python initial_guess = utility.dict_zeros_like(dirichlet_dofs, dtype=jnp.float64) dofs = solver.solver(initial_guess, settings, static_settings)[0]

Write vtk file for visualization with Paraview python meshio.Mesh( coords, {'quad': elems}, point_data={ "phi": dofs['phi'], }, ).write("./short_example.vtk")

Citation

If you found this library useful in academic research, please cite the JOSS paper:

bibtex @article{Bode_AutoPDEx_An_Automized_2025, author = {Bode, Tobias}, doi = {10.21105/joss.07300}, journal = {Journal of Open Source Software}, month = apr, number = {108}, pages = {7300}, title = {{AutoPDEx: An Automized Partial Differential Equation solver based on JAX}}, url = {https://joss.theoj.org/papers/10.21105/joss.07300}, volume = {10}, year = {2025} }

Contributions

You are warmly invited to contribute to the project. For larger developments, please get in touch beforehand in order to circumvent double work.

For detailed information on how to contribute, please see our Contribution Guidelines

License

AutoPDEx is licensed under the GNU Affero General Public License, Version 3.

Owner

  • Login: BodeTobias
  • Kind: user

JOSS Publication

AutoPDEx: An Automized Partial Differential Equation solver based on JAX
Published
April 11, 2025
Volume 10, Issue 108, Page 7300
Authors
Tobias Bode ORCID
Institute of Continuum Mechanics, Leibniz University Hannover, An der Universität 1, 30823 Garbsen, Germany
Editor
Daniel S. Katz ORCID
Tags
JAX Partial Differential Equations (PDEs) Automatic Differentiation Sensitivity Analysis Machine Learning

GitHub Events

Total
  • Release event: 7
  • Watch event: 4
  • Delete event: 3
  • Push event: 19
  • Pull request review event: 1
  • Pull request event: 8
  • Fork event: 2
  • Create event: 9
Last Year
  • Release event: 7
  • Watch event: 4
  • Delete event: 3
  • Push event: 19
  • Pull request review event: 1
  • Pull request event: 8
  • Fork event: 2
  • Create event: 9

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 1
  • Total pull requests: 9
  • Average time to close issues: 2 days
  • Average time to close pull requests: 11 minutes
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 9
  • Average time to close issues: 2 days
  • Average time to close pull requests: 11 minutes
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • celliern (1)
Pull Request Authors
  • BodeTobias (8)
  • danielskatz (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/draft-pdf.yml actions
  • actions/checkout v4 composite
  • actions/upload-artifact v4 composite
  • openjournals/openjournals-draft-action master composite
.github/workflows/static.yml actions
  • actions/checkout v4 composite
  • actions/configure-pages v5 composite
  • actions/deploy-pages v4 composite
  • actions/upload-pages-artifact v3 composite
.github/workflows/tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
.github/workflows/publish_to_pypi.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite