Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Preview
Under review
Only the notes changed on this branch were built. The rest of the site is not here, which is why this was quick.

AI and Scientific Software: What We Learned Rebuilding Underworld3

Underworld3 has about 50,000 lines of Python/ Cython wrapping PETSc, SymPy, and a just-in-time compiler. I began a trial of AI coding tools in 2025 and they have gradually become central to the way our team works. This is a story of co-evolution as much as it is about adoption of a new set of tools.

Boundary conditions on non-planar boundaries

No flow through this wall is a single velocity component on a box and is not a component of anything on a sphere, a deformed mesh, or a surface with topography. Three ways to impose it — a direct penalty, Nitsche, and rotating the degrees of freedom — what each costs, and the one measurement that tells them apart.

Constitutive Models in Symbolic Form

A constitutive model is a Python class where the relationship between fluxes and gradients is encoded in SymPy. At every stage the mathematics is visible, inspectable, and differentiable. The framework handles Jacobians, C code generation, and PETSc integration. You handle the physics.

Finding Particles in a Distributed, Unstructured Mesh

It can be difficult to figure out where you are in an unstructured mesh of triangles or tetrahedra; worse when the mesh is distributed in parallel. We have to solve this problem for particle-in-cell type codes such as Underworld3. This is how we do it.

How many processors should we use to solve Problem X?

Parallel computation puts many CPUs to work on solving a problem much more quickly than one CPU alone. But this only works if the tasks are carefully scheduled and the additional CPUs are not waiting around for something to do. How do we choose the right number of processors for a given problem ?

How Underworld3 Turns SymPy into C

What actually happens between the moment you write a mathematical expression in underworld3's python layer and the moment PETSc receives a finite element term in the form of compiled C code ?

Mesh Variables and PETSc Vectors: Keeping Arrays in Sync

One of the less glamorous but important problems in a finite element framework is this: how does the user assign values to a field variable, and how does the framework ensure that PETSc sees those values correctly, in parallel, without the user needing to keep track themselves?

Moving the Mesh Without Remaking It

There are three ways to put resolution where a calculation needs it: rebuild the mesh, subdivide it, or move its nodes. The third conserves the node budget and leaves the connectivity, the parallel partition and the multigrid hierarchy untouched — nothing is created or destroyed, only relocated. How that redistribution works in Underworld3, what it is worth in numbers, and where its ceiling is.

New features of the surface-coupling framework in Underworld 2

Our Journey from Underworld2 to Underworld3

Underworld is a code for geodynamics — mantle convection, lithospheric deformation, subduction, ice flow. We solve coupled, nonlinear PDEs with complex rheologies using Lagrangian particles to track material history. The project has been running for 20 years: why did we start again ?

Particles in Underworld3

Underworld is built around the idea of active Lagrangian tracer particles that carry history and composition information as the material deforms. How do we combine this information with our symbolic mathematical framework ?

Physical Units in Computational Geodynamics

Non-dimensionalisation (rewriting problems to make them re-scalable from lab to the real world) is a specialised task that all modellers confront at some point. It is important for accurate and efficient numerical solutions. Can we take away the pain that comes with the task ?

Faults: to mesh or not to mesh?

A fault is a discontinuity and a mesh represents continuity, so the first question is whether the fault has to go into the mesh at all. Shear bands and a painted director cost no mesh work; cutting and conforming cost a great deal. What each of the four representations asks of the mesh and of the constitutive model, where they agree, and why they part company at a junction.

Setting Up Full Multigrid

Underworld can precondition a Stokes solve with geometric multigrid built from a real hierarchy of meshes, rather than with the algebraic multigrid it falls back to. What the difference is, how to build a mesh that has a hierarchy, and when the choice is worth making.

Symbolic FEM and Adjoint Forms

Every implicit solve in Underworld3 is a residual written in SymPy, and its Newton solver assembles the tangent stiffness from four symbolic derivative blocks. We show that the same blocks give the adjoint: one transposed linear solve, and an integral for each parameter, yield the derivative of a misfit with respect to every parameter of the model at once.

Symbolic Time Derivatives in Underworld3

In Underworld3, the time derivative is a symbolic object. It appears in the solver's strong form as a SymPy expression, alongside the constitutive stress and the body force.

Underworld3 published in Journal of Open Source Software

The aim of underworld3 is to provide strong support to users in developing sophisticated mathematical models, and provide the ability to interrogate those models during development and at run-time. Underworld3 encodes the mathematical structure of the equations it solves in symbolic form.