PETSc

New
License: BSD-2-Clause · Updated 2026-11-11
My rating

1. Overview

PETSc (Portable, Extensible Toolkit for Scientific Computation) is the numerical engine underneath a large fraction of open-source scientific computing: nearly every mainstream open-source CFD and multiphysics code - OpenFOAM, SU2, FEniCS, deal.II - relies on PETSc for its linear and nonlinear algebra. Maintained by Argonne National Laboratory, it is not a solver you typically drive by hand for a single problem; it is the parallel infrastructure that lets a domain-specific code scale to thousands of cores and exposes Newton-Krylov, multigrid and time-integration algorithms. The aim of this guide is to help you decide when to build on PETSc directly versus calling it through a higher-level framework. This site compares PETSc with JAX-Fluids for differentiable physics and with PhysicsNeMo for physics ML.

After reading, you should understand what PETSc actually provides - the Krylov solvers, the preconditioners, the nonlinear and time-integration interfaces - and where the cost of using it directly sits. The companion classical-solver cost-boundary guide explains when a classical solve is the right reference, and the numerics-and-solvers collection collects the surrounding entry points. All version and capability statements below were verified against the project repository, release pages and the PETSc documentation on 11 November 2026, and any claim that is the project's own description rather than an independent measurement is labelled as such in Section 9.

2. How It Works

PETSc organises scientific computing around a small set of parallel objects: vectors and matrices distributed over MPI, and solvers that operate on them. The linear-algebra layer provides Krylov methods (CG, GMRES, BiCGStab) paired with preconditioners ranging from Jacobi and ILU to algebraic multigrid (GAMG), so the user composes a solver from building blocks rather than implementing one. The nonlinear layer (SNES) wraps a Newton-Krylov loop, and the time-integration layer (TS) offers explicit and implicit ODE/DAE integrators, which is what lets a multiphysics code reuse one parallel backbone for steady, transient and optimisation problems.

The parallel data model is what makes PETSc scale. Structured grids use DMDA and unstructured meshes use DMPlex, and these distribute the problem across ranks while hiding most of the communication from the application writer. Backends span MPI, CUDA, HIP and the Kokkos portability layer, so the same code can target CPUs and GPUs. Because PETSc is a library of algorithms rather than a monolithic solver, the accuracy and performance you obtain depend on the preconditioner and the discretisation you supply, which the framework leaves to you rather than choosing automatically.

3. Scope and Assumptions

PETSc assumes you bring a discretised problem: a sparse linear or nonlinear system, usually from a finite-element, finite-volume or finite-difference method, expressed in parallel vectors and matrices. It is the solver and parallel infrastructure, not a geometry or meshing tool, and not a turnkey CFD or structural code; you still need a physics front-end to generate the system. The accuracy of the result depends on the preconditioner, the tolerance and the discretisation, none of which PETSc selects for you, and a poor preconditioner can make a formally convergent method stall in practice.

The licensing assumption is favourable for commercial work. PETSc is BSD-2-Clause, a permissive licence that permits use, modification and embedding in proprietary products without copyleft obligations on your own code, provided the PETSc copyright notice is retained. The practical assumption is that you accept a learning curve: PETSc is a large, opinionated library, and effective use means reading its examples and learning its object model before writing production code. It is not the right tool when the deliverable is a quick single-node solve where a classical solver or a domain-specific code already does the job with less integration cost.

4. Getting Started

The fastest entry is the project's own tutorial examples: clone petsc/petsc, configure with the standard options, and run the documented SNES and TS examples to see a working parallel solve before writing your own. A first problem follows the documented workflow: create the distributed matrix and vectors for your discretisation, choose a Krylov method and a preconditioner (often GAMG for elliptic problems), set the tolerances, and solve, optionally wrapping the residual in SNES for a nonlinear problem. The official PETSc tutorials and the users manual walk through the Poisson and Bratu problems as the gentlest path rather than starting from an empty script.

Before trusting a result, run a manufactured-solution or grid-convergence test: confirm that the residual and the observed order of accuracy match theory as you refine the grid, because a parallel solver that has not been verified is just as wrong as a serial one. Then evaluate any solution on a held-out configuration with an independent reference. The companion FEniCS learn material and the physics-based deep-learning material on this site supply the surrounding theory, and the classical-solver cost-boundary guide organises when a classical solve is worth the compute. For Python users, petsc4py exposes the same objects without recompiling the C core, which is often the path of least resistance for prototyping before moving to compiled code.

5. Comparison with Alternatives

The useful comparison is by layer. OpenFOAM and SU2 are complete CFD applications that call PETSc underneath for their algebra, so they sit one layer above it; adopting PETSc directly means you own the physics front-end that those applications already provide. JAX-Fluids is a differentiable solver on JAX rather than a general sparse-algebra library, and PhysicsNeMo is a training framework for physics ML, so the comparison is about contracts rather than feature lists. PETSc is the shared substrate, not a competitor to the codes that embed it.

Within numerical libraries, PETSc's differentiator is the breadth and maturity of its composable solver stack and its exascale-ready parallelism. A domain-specific code or a hand-written solver can also deliver a single solve, but rebuilding Newton-Krylov, multigrid and scalable data distribution is a large investment that PETSc already amortises across the community. The classical-solver cost-boundary guide keeps these comparisons honest by stating the deliverable: a certified single solve, an interactive design sweep, or a surrogate that amortises thousands of queries. A framework that wins on generality may lose precisely where a specialised, turnkey application dominates.

6. Benchmarks and Evidence

Public evidence is largely the project's own documentation, tutorial suite and the published scaling studies of codes that use PETSc. The PETSc team reports strong scaling of its solvers to large core counts on leadership machines, and independent applications - OpenFOAM, SU2, FEniCS, deal.II - demonstrate PETSc-backed solves at production scale across fluid, structural and multiphysics regimes. These are project-authored or community capability statements tied to specific hardware and configurations, not independent blind validations of accuracy or speed at scale.

Independent context tempers the optimism. The performance of an iterative solver is dominated by the preconditioner and the problem, so a generic "PETSc is fast" claim is meaningless without the preconditioner, tolerance, mesh and core count spelled out. A 2024 review finding that many "ML beats classical solvers" papers compared against weak baselines is a reminder that any speed or accuracy figure should be re-measured on an independent reference for your own configuration. For a GPU-centric linear-algebra view, the AMGX GPU linear solver case on this site shows a different, GPU-native algebraic path with its own trade-offs rather than a drop-in PETSc replacement. The discipline of archiving the exact configuration next to every number applies here exactly as it does for any numerical result.

7. Role in Physics-AI Workflows

In a physics-AI pipeline PETSc occupies the trustworthy reference and the large-scale adjoint end. It produces the high-fidelity solves that label training data for surrogates, and it supplies the reference against which a neural operator's error is measured; an operator such as those covered in the neural-operator selection guide is only as credible as the classical solutions it was trained and validated on. PETSc also underpins PDE-constrained optimisation and adjoint sensitivity, which feed gradient-based design loops and inverse problems.

PETSc fits a longer verification chain alongside differentiable tools. A differentiable solver such as JAX-Fluids can provide gradients through a single physical regime, while PETSc provides the certified reference that the differentiable surrogate is checked against on held-out configurations. The physics-AI learning path places these roles in sequence, and the multiphysics-coupling collection shows where coupled field solves sit in a production stack. None of these removes the need for an independent reference solve, and writing down the expected query count before committing to a surrogate still decides whether the data-generation cost is ever recovered.

8. Limitations and Failure Modes

The first failure mode is preconditioner choice. PETSc exposes many options precisely because no single default wins; a wrong or absent preconditioner can turn a convergent method into one that stalls or diverges, and the symptom is a solver that "runs forever" rather than an explicit error. The mitigation is to start from a documented example that matches your problem class and to measure iteration counts before tuning tolerances.

The second failure mode is the integration cost. PETSc is a C/Fortran library with a substantial object model, so wrapping it in a new physics front-end is real engineering, not a configuration toggle. The third failure mode is scalability claims: strong scaling that holds on one machine does not transfer automatically to another architecture, and oversubscription, load imbalance and communication hotspots can erase the theoretical benefit. PETSc is also the wrong tool for a quick single-node solve where a classical solver or a domain-specific code already does the job with less integration cost, and it is not a geometry, meshing or visualisation tool. Treating it as a black box rather than learning its examples is the most common source of stalled projects.

9. Version and Source Notes

Version statements below were verified against the PETSc repository and release pages on 11 November 2026. The repository shows a 3.25 series with 3.25.2 dated 1 June 2026 and 3.25.0 dated 31 March 2026, alongside the earlier 3.23 line dated 28 March 2025; these dates and numbers are the project's own release records rather than an independent measurement, and an exact feature list should be confirmed against the release notes of the specific version you deploy. PETSc is maintained at Argonne National Laboratory and is distributed under BSD-2-Clause, which the project documents as permitting use, modification and redistribution including in proprietary products with attribution.

The backend matrix spans MPI, CUDA, HIP and Kokkos, and the algebraic multigrid preconditioner GAMG is documented as a standard building block for scalable elliptic solves. Because the project's own descriptions of capability reflect intended design rather than a measured benchmark, any throughput or accuracy claim you put into a proposal should be reproduced on your own hardware with the exact version, preconditioner, tolerance and core count archived next to it, following the same discipline used by the openfoam-multiphysics case and the bridge-structural case on this site.

10. References

  1. PETSc project repository and documentation, petsc.org, release pages and users manual (Argonne National Laboratory).
  2. Balay et al., "PETSc/TAO Users Manual", Argonne National Laboratory technical report, current 3.25 series.
  3. Balay et al., "The Portable, Extensible Toolkit for Scientific Computation", ACM Transactions on Mathematical Software.
  4. PETSc release records: 3.25.2 (1 June 2026), 3.25.0 (31 March 2026), 3.23 (28 March 2025), verified on 11 November 2026.
  5. OpenFOAM documentation, sparse linear-algebra layer and solver configuration notes that call PETSc.
  6. SU2 documentation, adjoint and PDE-constrained optimisation solvers built on PETSc.
  7. FEniCS and deal.II project documentation describing PETSc as the underlying algebraic backend.
  8. PETSc GPU backend notes covering CUDA, HIP and the Kokkos portability layer for CPU/GPU targeting.
  9. GAMG algebraic multigrid preconditioner documentation within the PETSc linear solver suite.
  10. PETSc BSD-2-Clause licence text and redistribution terms as documented on the project site.
Tags: