Robust implementation of elastoplastic constitutive models using automatic differentiation in PyTorch
DOI:
https://doi.org/10.14311/AP.2025.65.0640Keywords:
elastoplastic constitutive models, automatic differentiation, finite element analysis, implicit stress return mapping, Python programming language, PyTorch, Hardening soil modelAbstract
This paper explores the use of automatic differentiation (AD) for implementing complex elastoplastic constitutive models in finite element analysis. Traditional approaches require manually deriving and coding the derivatives of residual functions governing implicit stress return mapping, a process that becomes cumbersome for advanced models. We demonstrate how AD can simplify the implementation of consistent material stiffness operators and improve code maintainability by using PyTorch and its autograd functionality. A drained triaxial shear test is used to compare AD with manually coded and finite difference derivatives, highlighting the efficiency of the proposed approach. The example shows that AD simplifies code development and reduces the required source code by over 50 %. These findings support the use of AD as a practical approach for implementing and testing constitutive models, especially in the early development stages.Downloads
References
J. C. Simo, R. L. Taylor. Consistent tangent operators for rate-independent elastoplasticity. Computer Methods in Applied Mechanics and Engineering 48(1):101–118, 1985. https://doi.org/10.1016/0045-7825(85)90070-2
A. Pérez-Foguet, A. Rodríguez-Ferran, A. Huerta. Numerical differentiation for local and global tangent operators in computational plasticity. Computer Methods in Applied Mechanics and Engineering 189(1):277–296, 2000. https://doi.org/10.1016/S0045-7825(99)00296-0
C. Miehe. Numerical computation of algorithmic (consistent) tangent moduli in large-strain computational inelasticity. Computer Methods in Applied Mechanics and Engineering 134(3–4):223–240, 1996. https://doi.org/10.1016/0045-7825(96)01019-5
A. Lejeune, H. Boudaoud, N. Mathieu, M. Potier-Ferry. Automatic solver for computational plasticity based on Taylor series and automatic differentiation. In XII International Conference on Computational Plasticity. Fundamentals and Applications (COMPLAS XII), pp. 850–867. Barcelone, Spain, 2013.
Q. Chen, J. T. Ostien, G. Hansen. Automatic differentiation for numerically exact computation of tangent operators in small- and large-deformation computational inelasticity. In TMS 2014: 143rd Annual Meeting & Exhibition, pp. 289–296. Springer International Publishing, Cham, 2016. https://doi.org/10.1007/978-3-319-48237-8_38
S. Rothe, S. Hartmann. Automatic differentiation for stress and consistent tangent computation. Archive of Applied Mechanics 85(8):1103–1125, 2015. https://doi.org/10.1007/s00419-014-0939-6
A. Vigliotti, F. Auricchio. Automatic differentiation for solid mechanics. Archives of Computational Methods in Engineering 28(3):875–895, 2021. https://doi.org/10.1007/s11831-019-09396-y
F. Zwicke, P. Knechtges, M. Behr, S. Elgeti. Automatic implementation of material laws: Jacobian calculation in a finite element code with TAPENADE. Computers & Mathematics with Applications 72(11):2808–2822, 2016. https://doi.org/10.1016/j.camwa.2016.10.010
A. Latyshev, J. Bleyer, C. Maurini, J. S. Hale. Expressing general constitutive models in FEniCSx using external operators and algorithmic automatic differentiation, 2024.
J. Korelc, P. Wriggers. Automation of finite element methods. Springer, Cham, 2016. https://doi.org/10.1007/978-3-319-39005-5
M. Hillgärtner, T. Guo, M. Itskov. Automatic differentiation of strain-energy functions in the context of user-defined materials for the FEM. PAMM 20(1):e202000050, 2021. https://doi.org/10.1002/pamm.202000050
D. T. Seidl, B. N. Granzow. Calibration of elastoplastic constitutive model parameters from full-field data with automatic differentiation-based sensitivities. International Journal for Numerical Methods in Engineering 123(1):69–100, 2022. https://doi.org/10.1002/nme.6843
E. Aulisa, G. Capodaglio. Monolithic coupling of the implicit material point method with the finite element method. Computers & Structures 219:1–15, 2019. https://doi.org/10.1016/j.compstruc.2019.04.006
I. R. Shishir, A. Tabarraei. Multi-materials topology optimization using deep neural network for coupled thermo-mechanical problems. Computers & Structures 291:107218, 2024. https://doi.org/10.1016/j.compstruc.2023.107218
J. Blühdorn, N. R. Gauger, M. Kabel. AutoMat: Automatic differentiation for generalized standard materials on GPUs. Computational Mechanics 69(2):589–613, 2022. https://doi.org/10.1007/s00466-021-02105-2
M. Pundir, D. S. Kammer. Simplifying FFT-based methods for solid mechanics with automatic differentiation. Computer Methods in Applied Mechanics and Engineering 435:117572, 2025. https://doi.org/10.1016/j.cma.2024.117572
F. Masi, I. Stefanou, P. Vannucci, V. Maffi-Berthier. Thermodynamics-based artificial neural networks for constitutive modeling. Journal of the Mechanics and Physics of Solids 147:104277, 2021. https://doi.org/10.1016/j.jmps.2020.104277
T. Janda, M. Šejnoha, A. Zemanová, T. Žalská. Automatic differentiation in PyTorch as a tool for robust implementation of elasto-plastic constitutive model. In Proceedings of the Twelfth International Conference on Engineering Computational Technology, p. 9.3. 2024. https://doi.org/10.4203/ccc.8.9.3
J. Bleyer, A. Latyshev, C. Maurini, J. S. Hale. Differentiable constitutive modeling with FEniCSx and JAX. In FEniCS 2025, pp. 1–18. Groningen, Netherlands, 2025.
A. Favilli, F. Laccone, P. Cignoni, et al. Geometric deep learning for statics-aware grid shells. Computers & Structures 292:107238, 2024. https://doi.org/10.1016/j.compstruc.2023.107238
Y. Liao, R. Lin, R. Zhang, G. Wu. Attention-based LSTM (AttLSTM) neural network for seismic response modeling of bridges. Computers & Structures 275:106915, 2023. https://doi.org/10.1016/j.compstruc.2022.106915
W. Ouyang, L. Chen, A.-R. Liang, S.-W. Liu. Neural networks-based line element method for large deflection frame analysis. Computers & Structures 300:107425, 2024. https://doi.org/10.1016/j.compstruc.2024.107425
T. Schanz, P. A. Vermeer, P. G. Bonnier. The hardening soil model: Formulation and verification. In R. B. J. Brinkgreve (ed.), Beyond 2000 in Computational Geotechnics, pp. 281–296. Routledge, 1st edn., 1999. https://doi.org/10.1201/9781315138206-27
H. Matsuoka, T. Nakai. Stress-deformation and strength characteristics of soil under three different principal stresses. Proceedings of the Japan Society of Civil Engineers 1974(232):59–70, 1974. https://doi.org/10.2208/jscej1969.1974.232_59
T. Benz. Small-strain stiffness of soils and its numerical consequences. No. 55 in Mitteilung. Inst. für Geotechnik, Stuttgart, 2007.
L. Cocco, M. Ruiz. Numerical implementation of hardening soil model. In A. S. Cardoso, J. L. Borges, P. A. Costa, et al. (eds.), Numerical Methods in Geotechnical Engineering IX, pp. 195–203. CRC Press, 1st edn., 2018. https://doi.org/10.1201/9781351003629-25
E. A. de Souza Neto, D. Perić, D. R. J. Owen. Computational Methods for Plasticity: Theory and Applications. Wiley, Chichester, West Sussex, UK, 1st edn., 2008. https://doi.org/10.1002/9780470694626
A. Paszke, S. Gross, S. Chintala, et al. Automatic differentiation in PyTorch. In 31st Conference on Neural Information Processing Systems (NIPS 2017), pp. 1–4. 2017.
A. Paszke, S. Gross, F. Massa, et al. PyTorch: An imperative style, high-performance deep learning library. arXiv p. 1912.01703, 2019. https://doi.org/10.48550/arXiv.1912.01703
C. R. Harris, K. J. Millman, S. J. van der Walt, et al. Array programming with NumPy. Nature 585(7825):357–362, 2020. https://doi.org/10.1038/s41586-020-2649-2
A. Griewank, A. Walther. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, chap. 1. Introduction, pp. 1–12. Society for Industrial and Applied Mathematics, 2nd edn., 2008. https://doi.org/10.1137/1.9780898717761.ch1
B. Patzák, Z. Bittnar. Design of object oriented finite element code. Advances in Engineering Software 32(10–11):759–767, 2001. https://doi.org/10.1016/S0965-9978(01)00027-8
B. Patzák, D. Rypl. Object-oriented, parallel finite element framework with dynamic load balancing. Advances in Engineering Software 47(1):35–50, 2012. https://doi.org/10.1016/j.advengsoft.2011.12.008
L. Devos, M. Van Damme, et al. Tensoroperations.jl, 2023. https://doi.org/10.5281/zenodo.3245496
M. Innes, A. Edelman, K. Fischer, et al. A differentiable programming system to bridge machine learning and scientific computing. arXiv p. 1907.07587, 2019. https://doi.org/10.48550/arXiv.1907.07587
Xtensor-stack. Xtensor: Multi-dimensional arrays with broadcasting and lazy computing, 2025. [2025-09-17]. https://github.com/xtensor-stack/xtensor
A. Leal. Autodiff, a modern, fast and expressive C++ library for automatic differentiation, 2018. [2025-09-17]. https://autodiff.github.io
Downloads
Published
Issue
Section
License
Copyright (c) 2026 Tomáš Janda, Michal Šejnoha, Alena Zemanová, Tereza Žalská

This work is licensed under a Creative Commons Attribution 4.0 International License.


