Re4: scientific computing agent with rewriting, resolution, review and revision
Open Access
- 17 November 2026
- journal article
- Published by IOP Publishing in Machine Learning: Science and Technology
- Vol. 7 (6) , 065016
Abstract
Large language models (LLMs) are a promising class of generative artificial intelligence models and have demonstrated abilities to perform complex tasks in multiple domains, including mathematical and scientific reasoning. In this work, we construct a novel agent framework for solving representative problems in scientific computing. The proposed agent, incorporating a ‘rewriting-resolution-review-revision’ logical chain via three reasoning LLMs (functioning as the Consultant, Reviewer, and Programmer, respectively), is integrated in a collaborative and interactive manner. The Consultant module endows the agent with knowledge transfer capabilities to link problems to professional domain insights, thereby rewriting problem descriptions through text augmentation. The Programmer module is responsible for generating and executing well-structured code to deliver the problem resolution. The Reviewer module equips the agent with the capacity for self-debugging and self-refinement through interactive feedback with code runtime outputs. By leveraging the end-to-end review mechanism, the executable code provided by the Programmer undergoes iterative revision. A comprehensive evaluation is conducted on the performance of the proposed agent framework in solving typical partial differential equations, engineering-oriented flow past a cylinder, ill-conditioned linear systems, and data-driven physical analysis problems. Compared with a single-model approach, this collaborative framework significantly improves the bug-free code generation rate and reduces the occurrence of non-physical solutions, thereby establishing a highly reliable framework for autonomous code generation based on natural language descriptions. The review mechanism improved the average execution success (bug-free code and non-NaN solutions) rate of the modern reasoning model DeepSeek R1 from 59 % to 82 % , while ChatGPT 4.1-mini improved from 66 % to 87 % and Gemini-2.5 improved from 60 % to 84 % . Automatic code generation and review provide a promising workflow for scientific computing; analysis of solver-development trajectories further reveals recurring implementation difficulties in boundary treatment, array indexing, and the preservation of numerical constraints.Keywords
Funding Information
- CAS Project for Young Scientists in Basic Research (YSBR-136)
- National Natural Science Foundation of China (12202451)
This publication has 38 references indexed in Scilit:
- Toward end-to-end quantum simulation of rapidly distorted turbulenceJournal of Computational Physics, 2026
- A differentiable wall-modeled large-eddy simulation method for high-Reynolds-number wall-bounded turbulent flowsJournal of Computational Physics, 2026
- Evaluations of large language models in computational fluid dynamics: Leveraging, learning and creating knowledgeTheoretical and Applied Mechanics Letters, 2025
- DeepSeek vs. ChatGPT vs. Claude: A comparative study for scientific computing and scientific machine learning tasksTheoretical and Applied Mechanics Letters, 2025
- HiDeNN-TD: Reduced-order hierarchical deep learning neural networksComputer Methods in Applied Mechanics and Engineering, 2022
- Energy Coupling Mechanisms and Scaling Behavior Associated with Laser Powder Bed Fusion Additive ManufacturingAdvanced Engineering Materials, 2019
- Meep: A flexible free-software package for electromagnetic simulations by the FDTD methodComputer Physics Communications, 2010
- High-Re solutions for incompressible flow using the Navier-Stokes equations and a multigrid methodJournal of Computational Physics, 1982
- A survey of several finite difference methods for systems of nonlinear hyperbolic conservation lawsJournal of Computational Physics, 1978
- A numerical method for solving incompressible viscous flow problemsJournal of Computational Physics, 1967