Efficient n n -body simulations using physics informed graph neural networks

Víctor Ramos Osuna, Alberto Díaz-Álvarez, Raúl Lara Cabrera · 2025

Read Efficient n n -body simulations using physics informed graph neural networks by Víctor Ramos Osuna, Alberto Díaz-Álvarez, Raúl Lara Cabrera (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2504-01169.txt.

Introduction

Víctor Ramos Osuna and two co-authors speed up gravity simulations in a 2025 paper. N-body codes track how many bodies pull on each other. They are core tools in astrophysics, but they run slowly at scale. The team blends a graph neural network into the classic engine.

A leapfrog simulator first generated training scenes of many sizes. Scenes ranged from three bodies to five hundred over a thousand steps. Turned into graphs, they taught the network to predict accelerations. Prediction errors stayed extremely low in their tests. Long runs kept positions and speeds stable as well. The hybrid ran about seventeen percent faster than the classic code. The authors see a path to bigger cosmic simulations at lower cost.

Catalog record

CREATORVíctor Ramos Osuna, Alberto Díaz-Álvarez, Raúl Lara Cabrera
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE25 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2504-01169

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Efficient n n -body simulations using physics informed graph neural networks Víctor Ramos Osuna, Alberto Díaz-Álvarez, Raúl Lara Cabrera Abstract This paper presents a novel approach for accelerating N N -bodies simulations by integrating a physics-informed graph neural networks (GNNs) with traditional numerical methods. Our method implements a leapfrog-based simulation engine to generate datasets from diverse astrophysical scenarios which are then transformed into graph representations. A custom-designed GNN is trained to predict particle accelerations with high precision. Experiments, conducted on 60 60 training and 6 6 testing simulations spanning from 3 3 to 500 500 bodies over 1000 1000 time steps, demonstrate that the proposed model achieves extremely low prediction errors—loss values while maintaining robust long-term stability, with accumulated errors in position, velocity, and acceleration remaining insignificant. Furthermore, our method yields a modest speedup of approximately 17% over conventional simulation techniques. These results indicate that the integration of deep learning with traditional physical simulation methods offers a promising pathway to significantly enhance computational efficiency without compromising accuracy. 1 Introduction A N -bodies system models the evolution of N particles under mutual gravitational interactions, governed by Newton’s laws. Analytical solutions exist only for N=2 ; for larger N , numerical methods are required. Despite their precision, these approaches are computationally expensive due to the need to evaluate every pairwise interaction at each step Aarseth and Aarseth, (2003) , motivating the search for faster alternatives that preserve accuracy. Over the past two decades, deep learning (DL) techniques have opened new avenues for modelling such complex systems. Among them, graph neural networks (GNNs) stand out for their ability to capture both local and global relationships in graph-structured data, as demonstrated in various physical prediction tasks Battaglia et al., (2018) . Although gravity is a long-range force, we adopt a local interaction approximation—similar to hierarchical methods like Barnes-Hut Barnes and Hut, (1986) —to improve efficiency. While this simplifies the problem, it enables the GNN to approximate global dynamics effectively. In this work, we propose an approach that combines the generation of simulation data from an N -bodies system with a regression model based on GNNs . The methodology presented consists of three main modules: 1. Physical simulation and data generation : A simulation engine employing a leapfrog integration scheme Iserles, (1986) iteratively updates the positions, velocities, and accelerations of particles. It generates diverse scenarios (e.g. random distributions, 3D discs, multi-disc systems) to create a dataset containing both particle attributes and their target accelerations. 2. Transformation to graph representation : The simulation data is converted into graphs, with each particle represented as a node (including attributes such as position) and edges established based on proximity. 3. GNNs -based regression model : A graph neural network based on the EdgeConv architecture Wang et al., (2019) propagates and transforms node information to predict particle accelerations. The model includes encoders for nodes and edges, mapping initial features into a higher-dimensional space, and an output layer tailored for the regression task. The primary objective of this work is to validate the ability of the GNN model to predict accelerations in N -bodies systems with sufficient precision , demonstrating that the integration of realistic physical simulation with DL can substantially improve the simulation time of complex dynamics while maintaining a high degree of fidelity to reality. The remainder of the paper is organised as follows. Section 2 Related works reviews recent work on the application of DL in computational physics. This is followed by Sections 3 Methodology and 4 Experiments and results , which detail the structure, execution, and results of the experiments. Finally, the paper concludes with Section 5 Conclusion , which presents the findings and outlines potential future directions for this work. 2 Related works The simulation of N -bodies systems has long been a core topic in computational physics, especially in astrophysics. Early work from the 1980s relied on direct methods to compute gravitational interactions between all particle pairs. While precise for small systems, these algorithms have O(N^{2}) complexity, which scales poorly. This led to the development of more efficient alternatives, notably the Barnes-Hut method Barnes and Hut, (1986) , which reduces complexity to O(N\log N) using a hierarchical approximation of forces, and the fast multipole method (FMM) Greengard and Rokhlin, (1987) , which achieves O(N) by grouping distant particles into clusters. In parallel, numerical integration schemes were developed to simulate system evolution over time. The leapfrog integrator, introduced in 1967, remains one of the most widely used methods due to its ability to preserve physical invariants such as energy Iserles, (1986) . These techniques have enabled simulations of stellar dynamics and galaxy formation Hernquist, (1990) ; Navarro et al., (1997) , often using parametric density profiles to approximate mass distribution. Since the 2010s, the rise of machine learning (ML) has encouraged the combination of traditional methods with artificial intelligence (AI) techniques. Sánchez-González et al. Sanchez-Gonzalez et al., (2020) showed that GNNs can learn latent representations that capture system dynamics across scales, enabling accurate predictions of trajectories and accelerations without explicitly computing all interactions. This significantly reduces computational cost, allowing application to scenarios where full simulation would be prohibitive, such as diffusion, turbulence, or granular systems Raissi et al., (2019) ; Pfaff et al., (2020) . Similar successes have been reported in related areas like fluid dynamics and materials modelling Maurizi et al., (2022) ; Sergeev et al., (2024) . GNNs have also proven highly effective for regression tasks in physics. They have been used to predict continuous quantities—such as forces, energies, or accelerations—with high accuracy Battaglia et al., (2016) ; Kipf and Welling, (2016) , thanks to their ability to capture both local structure and global connectivity. This allows them to infer variations in force fields from particle distributions Gilmer et al., (2017) , and generalise across different configurations, including materials and biological systems Chen et al., (2023) ; Yang et al., (2022) ; Bongini et al., (2022) . In summary, while classical models remain fundamental for N -bodies simulation, the literature shows that DL —and GNNs in particular—can ease their computational burden. Rather than replacing numerical methods (e.g., finite difference or finite element), GNNs serve as efficient computational shortcuts that complement physical models, providing data-driven approximations that reduce cost without compromising physical fidelity. 3 Methodology We will divide this section into the four main stages that have comprised this study: (i) generation of a dataset from a physical N -bodies simulation, (ii) transformation of the raw dataset into a graph structure, (iii) definition of a GNN architecture for a regression problem, that is, the prediction of each body’s acceleration, and (iv)training and evaluation of the model. All experiments were executed on a workstation equipped with an AMD Ryzen 5 5600X 6-Core Processor (6 cores, 12 threads) running Ubuntu GNU/Linux 24.04, with a frequency of approximately 4650 MHz, and 32 GB of system memory. The machine uses an NVIDIA GeForce RTX 2070 graphics card with 8 GB of dedicated memory, running under CUDA 12.4 with driver version 550.120. 3.1 Data generation from physical simulation The foundation of the methodology is a simulation engine that integrates the evolution of N -bodies systems. It begins with a set of initial conditions defined in terms of the particles’ positions,

Read the complete text