Problem
Large Context
Complete simulation cases contain large amounts of information that are irrelevant to most individual modifications.
AI for Engineering · OpenFOAM · Scientific Computing
A graph-driven engineering system designed to let an LLM inspect, reason about, inherit, and modify OpenFOAM simulation cases without consuming complete dictionary files as raw context.
Primary Language
Python
Domain
OpenFOAM / CFD
Interface
FastAPI + MCP
Status
Active Development
Motivation
OpenFOAM cases are distributed across multiple dictionaries, fields, solver settings, numerical schemes, turbulence models, mesh definitions, and boundary conditions.
Giving an LLM the complete case directly is inefficient and makes precise modification difficult. The system therefore converts the case into a structural graph that an LLM can navigate before requesting any mutation.
This allows the language model to reason about the structure of the simulation first and retrieve detailed information only when it is needed.
System Design
The system separates natural-language reasoning from deterministic simulation manipulation. The LLM decides what needs to change, while dedicated engineering layers determine how those changes are safely applied.
Natural-language engineering request
Collects intent and simulation context
Understands the requested case modification
Provides structural navigation of the OpenFOAM case
Represents the planned case modifications
Applies deterministic dictionary changes
Updated and validated simulation case
Design Philosophy
Problem
Complete simulation cases contain large amounts of information that are irrelevant to most individual modifications.
Problem
Allowing a language model to freely rewrite engineering configuration files makes correctness and validation difficult.
Solution
The LLM identifies intent and graph paths, while dedicated tools retrieve and modify the exact engineering entries.
Core Components
OpenFOAM dictionaries are represented as traversable structural nodes rather than being passed wholesale to the language model.
The language model initially sees names and relationships only. Detailed values are retrieved only when a specific graph path is selected.
A current case can inherit required structures from a compatible tutorial or donor case before any merge or mutation occurs.
Requested changes are represented independently from the original case, allowing modifications to be reviewed, validated, and applied deterministically.
Execution
Implementation
The system uses structured representations between the language model and the execution layer. This makes the reasoning layer easier to inspect and prevents uncontrolled edits to simulation files.
Structural representation of an OpenFOAM case, exposing dictionaries, sections, and entries as navigable paths.
{
"case": "pitzDaily",
"system": {
"fvSchemes": {
"divSchemes": {
"div(phi,U)": "Gauss linearUpwind grad(U)"
}
}
}
}The LLM does not rewrite files directly. It selects a target path and produces a structured modification intent.
{
"path": "system/fvSchemes/divSchemes/div(phi,U)",
"operation": "replace",
"value": "Gauss upwind"
}Changes are represented separately from the source case so they can be inspected and validated before application.
{
"case_id": "current-case",
"changes": [
{
"path": "system/fvSchemes/divSchemes/div(phi,U)",
"old": "Gauss linearUpwind grad(U)",
"new": "Gauss upwind"
}
]
}Case Transformation
A modification travels through the system as structured intent. The reasoning layer determines the target, while the execution layer performs the actual dictionary mutation.
Before
The current case uses the existing discretisation configuration in the fvSchemes dictionary.
divSchemes
{
default none;
div(phi,U)
Gauss linearUpwind grad(U);
}Decision
The reasoning layer identifies the exact graph path and generates a controlled modification request rather than rewriting the dictionary.
{
"path": "system/fvSchemes/divSchemes/div(phi,U)",
"operation": "replace",
"value": "Gauss upwind"
}After
The execution layer applies the requested mutation to the target entry while leaving unrelated dictionary contents untouched.
divSchemes
{
default none;
div(phi,U)
Gauss upwind;
}Engineering
A major challenge is that OpenFOAM dictionaries do not always map cleanly to a unique path. Duplicate keywords and repeated structures require explicit resolution before deterministic mutation can occur.
Another challenge is context management. The LLM should have enough structural information to reason about a case without repeatedly ingesting large dictionary contents.
The architecture therefore separates reasoning, structural navigation, data retrieval, and file mutation into distinct layers.
Contribution
The project combines simulation-domain knowledge with software architecture, structured reasoning, and controlled execution. These are the main pieces I designed and implemented.
OpenFOAM case graph generation
Structural abstraction for LLM consumption
Graph-path based case navigation
Case inheritance workflow
Delta-based modification representation
Controlled dictionary mutation layer
FastAPI endpoints for case operations
MCP / chatbot integration path
Direction
The broader goal is to create an engineering assistant capable of understanding an existing simulation case, selecting compatible tutorial structures when required, planning modifications through a graph representation, and safely executing those changes through controlled tools.