Sunday, November 8, 2026
Science
No Result
View All Result
  • Login
  • HOME
  • SCIENCE NEWS
  • CONTACT US
  • HOME
  • SCIENCE NEWS
  • CONTACT US
No Result
View All Result
Scienmag
No Result
View All Result
Home Science News Technology and Engineering

CodeJeNN Generates C++ Code for Physics Neural Networks

November 8, 2026
in Technology and Engineering
Cassandra Pierce
By Cassandra Pierce Scienmag Editorial Profile - Systems Neuroscience
Reading Time: 5 mins read
0
CodeJeNN Generates C++ Code for Physics Neural Networks

CodeJeNN Generates C++ Code for Physics Neural Networks

65
SHARES
587
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Published in the journal SoftwareX in December 2026, the study introduces a method designed to bridge the gap between high-level machine learning libraries and the compiled languages used in computational physics solvers. The primary objective of the tool is to allow researchers to embed artificial intelligence models directly into existing simulation codes without relying on external dependencies or complex application programming interfaces. This approach aims to reduce the computational overhead and integration effort typically associated with adding machine learning capabilities to scientific simulation software.

The motivation for developing CodeJeNN stems from the growing integration of machine learning into numerical schemes for partial differential equations and physical modeling. While modern neural network architectures are accessible through libraries such as Keras, TensorFlow, and PyTorch, embedding these models into physics solvers remains challenging. Most physics solvers are written in compiled languages like Fortran and C++ to ensure better resource control, whereas machine learning libraries are primarily based on Python. This disparity often adds computational overhead and requires significant implementation effort to integrate complex architectures into established codes. CodeJeNN addresses this by generating self-contained C++ code that reproduces the trained neural network, allowing users to optimize the source code directly without external dependencies.

The software operates by reading a saved model file from the Keras deep learning API and generating a C++ header file that contains all necessary parameters and functions. The code generation process involves loading the model, extracting parameters into a Python dictionary, reconstructing the model from input to output, and converting it into C++ format. This workflow ensures that the generated code is fully self-contained and inlined, minimizing external dependencies. The tool supports both Multi-Layer Perceptrons and Convolutional Neural Networks, which are common architectures in scientific computing. By producing raw source code, CodeJeNN enables users to incorporate the model into their solvers and further optimize the code if needed, providing a flexible and transparent integration process.

CodeJeNN is designed to be extensible, with each layer type implemented as an independent module. This modular structure allows users to support new architectures by adding the logic for missing layers without altering existing implementations. The tool supports a wide range of activation functions, including ReLU, Sigmoid, Tanh, and Softmax, as well as various layer types such as Dense, Convolutional, and Pooling layers. However, the software has certain limitations, primarily supporting only single-branch neural networks that operate on a single input tensor. It does not support multiple independent inputs or all configuration options available in the Keras API, such as certain regularizers. Dropout layers are skipped during code generation because they act as identity operations during inference, avoiding unnecessary computations.

To demonstrate the performance and accuracy of CodeJeNN, the researchers conducted benchmark tests comparing the inference speed and numerical accuracy of code-generated models against those created directly in Keras. The benchmarks included four model architectures: a small and a large Multi-Layer Perceptron, and a small and a large Convolutional Neural Network. These models varied in depth and total number of learnable parameters, ranging from approximately 11,000 to 843,000 parameters. All models were tested on a single CPU core using 32-bit floating-point precision. The results showed that CodeJeNN-generated models achieved inference times significantly faster than the optimized Keras backends, particularly for smaller models. For instance, the small MLP with approximately 18,000 parameters had an average inference time of 0.01 seconds with CodeJeNN, compared to 0.11 seconds with optimized PyTorch.

The numerical accuracy of the generated models was also evaluated by comparing layer-wise outputs with the Keras baseline. The study reported maximum absolute, mean absolute, and relative errors for each layer. The errors were found to be within acceptable tolerances, with relative errors consistently bounded near 32-bit floating-point precision limits. The final output layers produced smaller absolute errors compared to preceding hidden layers, indicating that the accumulation of numerical deviations remained insignificant for the overall model performance. This level of accuracy is sufficient for embedding trained models into established physics solvers, where the primary goal is to maintain close agreement with reference solutions while improving computational efficiency.

In addition to benchmarking, the researchers applied CodeJeNN to a practical computational fluid dynamics case involving a two-dimensional subsonic splitter-plate mixing layer simulation. The neural network was used to replace the viscosity model, which is typically calculated using Wilke’s mixing rule, in a hydrogen-air flow simulation using OpenFOAM and DetonationFOAM. The model mapped thermochemical state variables directly to viscosity, allowing for faster inference within the simulation. The neural network was trained on 10,000 random states and verified against the Wilke model over 2,000 independently sampled states. The mean error was 0.12%, with a maximum error of 8.12%, demonstrating the model’s ability to accurately approximate the viscosity function.

The simulation results showed that the neural network introduced minimal error into the flow field. The relative L2 error for x-velocity was 0.065%, and for temperature, it was 0.11%. Mean absolute errors were 0.100 m/s for x-velocity and 0.406 K for temperature. Localized maximum errors occurred within the high-gradient mixing layer immediately downstream of the splitter plate, but the absence of large-scale errors elsewhere indicated that the neural network preserved the overall flow evolution. This case study illustrates the potential of CodeJeNN to integrate neural networks into complex physics simulations, providing a robust method for replacing traditional constitutive models with data-driven surrogates.

The development of CodeJeNN also addresses the increasing reliance on large language models for integrating neural networks into computational physics codes. While LLMs can lower the barrier to entry, they introduce recurring costs associated with supplying project-specific context and regenerating infrastructure. CodeJeNN reduces this reliance by automatically generating self-contained inference code, thereby minimizing token consumption and user effort. The tool’s extensibility allows users to leverage LLMs to add new layer logic with substantially fewer tokens, providing a non-invasive workflow for generating new models.

Future work on CodeJeNN will include the integration of Spektral, a Graph Neural Network API for Keras, to support commonly used GNN layers such as message passing and attention-based graphing layers. The developers also plan to add additional activation functions and explore accelerating inference by exporting functions to low-level high-performance libraries like Eigen. These enhancements aim to broaden the applicability of CodeJeNN to a wider range of scientific computing tasks. The software is currently available on GitHub, providing researchers with access to the code, documentation, and tutorials for reproducing the benchmarks and case studies presented in the study.

The study highlights the importance of developing tools that facilitate the integration of machine learning into scientific simulations. By providing a simple and efficient method for generating C++ code from Keras models, CodeJeNN enables researchers to leverage the power of neural networks without the complexities of manual integration. The tool’s design prioritizes ease of integration and self-containment, making it a valuable resource for the computational physics community. As machine learning continues to play a larger role in scientific research, tools like CodeJeNN will be essential for bridging the gap between data-driven models and traditional numerical methods.

Subject of Research: CodeJeNN : A simple C++ neural network generator for physics applications

Article Title: CodeJeNN : A simple C++ neural network generator for physics applications

Article References: Arcities, J., Popov, P. P., Ching, E. J., Viswanath, K., & Johnson, R. F. (2026). CodeJeNN: A simple C++ neural network generator for physics applications. SoftwareX, 36, Article 103203. https://doi.org/10.1016/j.softx.2026.103203

Image Credits: AI Generated

DOI: 10.1016/j.softx.2026.103203

Keywords: CodeJeNN, simple, neural, network, generator, physics, applications, scientific research

Cite Scienmag News

Cassandra Pierce. (November 8, 2026). CodeJeNN Generates C++ Code for Physics Neural Networks. Scienmag. https://scienmag.com/codejenn-generates-c-code-for-physics-neural-networks/

Cassandra Pierce. "CodeJeNN Generates C++ Code for Physics Neural Networks." Scienmag, 8 November 2026, https://scienmag.com/codejenn-generates-c-code-for-physics-neural-networks/. Accessed 8 November 2026.

Cassandra Pierce. "CodeJeNN Generates C++ Code for Physics Neural Networks." Scienmag. November 8, 2026. https://scienmag.com/codejenn-generates-c-code-for-physics-neural-networks/

Tags: applicationsCodeJeNNgeneratornetworkneuralphysicsScientific Researchsimple
Share26Tweet16
Previous Post

Uzbekistan Model for Synthetic Biology Ethics

Next Post

Seaweed Extract Foliar Spray Restores Pechay Yield Following Severe Flooding Stress

Related Posts

Gold Nanoflowers Detect Mercury in Water at 6 nM
Technology and Engineering

Gold Nanoflowers Detect Mercury in Water at 6 nM

November 8, 2026
Chemical Tuning of Bacterial Glucan Boosts Emulsion Stability and Anticancer Bioactivity
Biotechnology

Chemical Tuning of Bacterial Glucan Boosts Emulsion Stability and Anticancer Bioactivity

November 8, 2026
AI Platform Integrates Persona Methods for Fashion Startups
Technology and Engineering

AI Platform Integrates Persona Methods for Fashion Startups

November 8, 2026
Data Grading Boosts Neuron Reconstruction Accuracy
Medicine

Data Grading Boosts Neuron Reconstruction Accuracy

November 8, 2026
LP-Tree Decomposition Accelerates Label-Constrained Routing on Dynamic Road Networks
Technology and Engineering

LP-Tree Decomposition Accelerates Label-Constrained Routing on Dynamic Road Networks

November 8, 2026
New Laser Imaging Method Measures Blood Flow Depth Independently
Technology and Engineering

New Laser Imaging Method Measures Blood Flow Depth Independently

November 8, 2026
Next Post
Seaweed Extract Foliar Spray Restores Pechay Yield Following Severe Flooding Stress

Seaweed Extract Foliar Spray Restores Pechay Yield Following Severe Flooding Stress

  • Mothers who receive childcare support from maternal grandparents show more optimized

    Mothers who receive childcare support from maternal grandparents show more parental warmth, finds NTU Singapore study

    27656 shares
    Share 11059 Tweet 6912
  • University of Seville Breaks 120-Year-Old Mystery, Revises a Key Einstein Concept

    1061 shares
    Share 424 Tweet 265
  • Bee body mass, pathogens and local climate influence heat tolerance

    682 shares
    Share 273 Tweet 171
  • Researchers record first-ever images and data of a shark experiencing a boat strike

    546 shares
    Share 218 Tweet 137
  • Groundbreaking Clinical Trial Reveals Lubiprostone Enhances Kidney Function

    531 shares
    Share 212 Tweet 133
Science

Embark on a thrilling journey of discovery with Scienmag.com—your ultimate source for cutting-edge breakthroughs. Immerse yourself in a world where curiosity knows no limits and tomorrow’s possibilities become today’s reality!

RECENT NEWS

  • Review outlines mechanisms and management for poor graft function
  • How Chinese Social Organizations Navigate Severe Resource Constraints Through Strategic Adaptation
  • Gold Nanoflowers Detect Mercury in Water at 6 nM
  • Neutron Depth Profiling Maps Lithium Dynamics in Batteries

Categories

  • Agriculture
  • Anthropology
  • Archaeology
  • Athmospheric
  • Biology
  • Biotechnology
  • Blog
  • Bussines
  • Cancer
  • Chemistry
  • Climate
  • Earth Science
  • Editorial Policy
  • Marine
  • Mathematics
  • Medicine
  • Pediatry
  • Policy
  • Psychology & Psychiatry
  • Science Education
  • Science News
  • Social Science
  • Space
  • Technology and Engineering

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,150 other subscribers

© 2025 Scienmag - Science Magazine

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • HOME
  • SCIENCE NEWS
  • CONTACT US

© 2025 Scienmag - Science Magazine

Discover more from Science

Subscribe now to keep reading and get access to the full archive.

Continue reading