triangulax: Differentiable Simulations with Triangular Meshes across Soft Matter Physics
Many physical and biological systems -foams, membranes, elastic shells, or tissue sheets- can be mathematically described as 2D surfaces. These surfaces can host complex dynamics, like reaction-diffusion systems, and undergo drastic deformations. Here, we present triangulax, an open-source Python library for simulations and geometry processing that discretizes surfaces using triangular meshes available at https://github.com/nikolas-claussen/triangulax. It combines two features. First, discrete differential geometry provides coordinate-free discretization, which allows simulating strongly deforming surfaces. Second, the library is built on the machine-learning framework JAX, so mesh-based energies and entire simulations can be differentiated automatically (including simulations with stochastic forces or topological modifications). This simplifies multi-physics simulations by computing forces automatically and allows fitting model parameters to experimental data or design objectives. We implement an algorithm to preserve mesh quality in strongly deforming surfaces and apply it to a model of membrane mechanics coupled to an on-membrane concentration field. We validate our approach against exact solutions and existing software, and demonstrate triangulax across a range of problems, including membrane mechanics, vertex models, and inverse design of a shape-morphing elastomer sheet.