Example Codes for Coupled Theories in Solid Mechanics

Eric M. Stewart, Shawn A. Chester, and Lallit Anand

Welcome#

This website compiles a collection of FEniCSx finite element codes for a wide array of coupled-physics theories in solid mechanics. These codes accompany the book,

  • L. Anand, E.M. Stewart, S.A. Chester. Introduction to coupled theories in solid mechanics. Oxford University Press, 2026.

A selection of example codes are provided for:

  1. Finite elasticity

  2. Finite deformation viscoelasticity with inertial effects

  3. Finite thermo-elasticity

  4. Gel mechanics

  5. Gel thermo-mechanics

  6. Chemo-mechanically coupled Cahn-Hilliard

  7. Electro-elasticity of dielectric elastomers

  8. Electro-viscoelasticity of dielectric elastomers with inertial effects

  9. Electro-chemo-elasticity of ionic polymers

  10. Magneto-viscoelasticity of hard-magnetic soft-elastomers

  11. Magneto-viscoelasticity of soft-magnetic soft-elastomers

Running the codes#

We recommend downloading or cloning the entire collection of example codes (< 30 MB of files) from the GitHub repository, and then running example codes locally on your machine using Docker and VSCode.

A detailed guide for installing FEniCSx in a Docker container and running the notebooks using VSCode is provided both for Mac and Windows. The installation process is essentially similar for the two operating systems, but the example screenshots in the instructions are from the relevant system.

These are our preferred methods for editing and running FEniCSx codes, although many other options exist.

Important

All codes were written for FEniCSx v0.8.0, so our instructions documents will direct you to install this specific version of FEniCSx.

Results#

Simulation results are post-processed and visualized in two primary ways:

  1. Plots of curves are constructed and shown in-line using matplotlib.

  2. Field data for the simulation — i.e. contours of displacement, stress, and so on — are written to a *.bp file in the /results directory which is included in each sub-folder of the GitHub repository. The results *.bp file can be read and visualized by ParaView, using the ADIOS2VTXReader option.

Citation#

If you use these codes in your own research, please cite the software:

DOI

as well as the associated textbook:

  • L. Anand, E. M. Stewart, and S. A. Chester. Introduction to coupled theories in solid mechanics. Oxford University Press, 2026.

BibTeX citations:

@software{stewart2025,
  author       = {Stewart, E. M. and Chester, S. A. and Anand, L.},
  title        = {Example codes for coupled theories in solid mechanics},
  month        = jan,
  year         = 2025,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.14680876},
  url          = {https://doi.org/10.5281/zenodo.14680876}
}

@book{anand2026,
author={Anand, L. and Stewart, E. M. and Chester, S. A.},
         title={Introduction to coupled theories in solid mechanics},
         publisher = {Oxford University Press},
         year={2026}
     }

Legacy codes#

“Legacy FEniCS” versions of some of the example codes presented in this repository are available in the following repository:

License#

These codes and the associated website and GitHub repository are distributed under the MIT License, as described below.

MIT License

Copyright (c) 2025 Eric M. Stewart, Shawn A. Chester, and Lallit Anand

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.