Document Type
Article
Publication Date
2-6-2025
Abstract
This study assesses the capability of ChatGPT to generate finite element code for geotechnical engineering applications from a set of prompts. We tested three different initial boundary value problems using a hydro-mechanically coupled formulation for unsaturated soils, including the dissipation of excess pore water pressure through fluid mass diffusion in one-dimensional space, time-dependent differential settlement of a strip footing, and gravity-driven seepage. For each case, initial prompting involved providing ChatGPT with necessary information for finite element implementation, such as balance and constitutive equations, problem geometry, initial and boundary conditions, material properties, and spatiotemporal discretization and solution strategies. Any errors and unexpected results were further addressed through prompt augmentation processes until the ChatGPT-generated finite element code passed the verification/validation test. Our results demonstrate that ChatGPT required minimal code revisions when using the FEniCS finite element library, owing to its high-level interfaces that enable efficient programming. In contrast, the MATLAB code generated by ChatGPT necessitated extensive prompt augmentations and/or direct human intervention, as it involves a significant amount of low-level programming required for finite element analysis, such as constructing shape functions or assembling global matrices. Given that prompt engineering for this task requires an understanding of the mathematical formulation and numerical techniques, this study suggests that while a large language model may not yet replace human programmers, it can greatly assist in the implementation of numerical models.
Keywords
code generation, finite element method, large language model, prompt engineering, unsaturated soil
Language
English
Publication Title
International Journal for Numerical and Analytical Methods in Geomechanics
Grant
NRF‐2021R1A5A1032433
Rights
© 2025 The Author(s). This is an open access work distributed under the terms of the Creative Commons Attribution-Non-Commercial (https://creativecommons.org/licenses/by-nc/4.0/) which permits non-commercial reuse, distribution, and reproduction in any medium, provided the original work is properly cited.
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License
Recommended Citation
Kim, T., Yun, T.S. and Suh, H.S. (2025), Can ChatGPT Implement Finite Element Models for Geotechnical Engineering Applications?. Int J Numer Anal Methods Geomech., 49: 1747-1766. https://doi.org/10.1002/nag.3956
Manuscript Version
Final Publisher Version