CoolFace
Modelpublic

arungovindneelan/foam-cfd-unified-14b

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes18downloads
Model Card

foam-cfd-unified-14b

A 14-billion-parameter Qwen2.5-Coder fine-tuned for OpenFOAM v2412 case generation from natural-language CFD prompts. The model emits valid JSON parameter blocks and full OpenFOAM dictionary files (controlDict, fvSchemes, fvSolution, 0/U, 0/p, transportProperties, etc.) when paired with the openfoam-Agent pipeline.

This is the same architecture as `foam-cfd-unified-7b` scaled up to 14 B parameters and re-trained on a larger, validated case corpus. It is not a drop-in replacement for the 7 B model — the JSON schema and patch-naming conventions match, but accuracy on the harder geometries is meaningfully better.

TL;DR — what's new in the 14 B model

MetricEval setScore
Cases that ran end-to-end (no FOAM FATAL)110 fresh OOD prompts110 / 110 (100 %)
Solver-pick exact match vs labeller110 fresh OOD prompts106 / 110 (96.4 %)
Per-family solver match (buoyantSimpleFoam, icoFoam, interFoam, rhoSimpleFoam, rhoPimpleFoam)30 cases across 5 families30 / 30 (100 %)
Domain-coverage geometries supported via hand-written gmsh templates—13

The four mismatches in the 110-case run are all defensible borderline calls (low-Re cylinder transient → icoFoam-or-pimpleFoam; "subsonic diffuser" → incompressible-or-compressible) — not real model errors.

How it was trained

  • —Base model: Qwen/Qwen2.5-Coder-14B-Instruct
  • —Method: 4-bit QLoRA (Unsloth) → bf16 merge
  • —LoRA config: r=64, α=128, dropout=0.0, target = all q,k,v,o,gate,up,down projections
  • —Dataset: 402 validated OpenFOAM v2412 cases from arungovindneelan/openfoam-Agent-Dataset, reward-weighted by per-case solver score (≥ 0.5)
  • —Schedule: 3 epochs, pagedadamw8bit, bf16, batch 1 × grad-accum 8, max_seq 8192, learning rate 2 × 10⁻⁴
  • —Training loss: 0.318 → 0.0061 over 153 steps
  • —Hardware: single H100 80 GB
  • —Wall time: ~25 min training + ~5 min adapter merge

What the agent pipeline does at inference

The model is one component of a CFD-aware agent that:

  1. 1.Refines the user's natural-language CFD prompt
  2. 2.Extracts structured CFDParams (geometry type, Re, fluid, regime, …) as JSON-schema-validated output
  3. 3.Selects the OpenFOAM solver (simpleFoam / pimpleFoam / icoFoam / buoyantSimpleFoam / interFoam / rhoSimpleFoam / rhoPimpleFoam)
  4. 4.Calls a parametric gmsh template to mesh the geometry
  5. 5.Writes all OpenFOAM v2412 dictionaries
  6. 6.Runs the solver and scores the result

This model handles steps 1–3 and 5 (the dictionary text). The gmsh templates that produce step 4 cover 13 geometry families:

lid_driven_cavity   pipe              cylinder              channel
backward_facing_step  airfoil (NACA-4-digit)  wedge          sphere (3D)
periodic_hill (Mellen)  multi_hill   s_bend (sinusoidal)    diffuser
ahmed_body (3D)         t_junction    convergent_divergent_nozzle
elbow (90°)

Patch names emitted by these templates match what the model expects in 0/U, 0/p, etc. — the system is closed-loop.

Quick start (vLLM)

python
from vllm import LLM, SamplingParams
llm = LLM(
    model="arungovindneelan/foam-cfd-unified-14b",
    dtype="bfloat16",
    max_model_len=8192,
    gpu_memory_utilization=0.55,  # if sharing the GPU
)
out = llm.chat(
    [{"role": "system", "content": "You are an expert OpenFOAM CFD engineer..."},
     {"role": "user",   "content": "2D lid-driven cavity Re=1000, 2m square, water"}],
    sampling_params=SamplingParams(temperature=0.0, max_tokens=1024),
)
print(out[0].outputs[0].text)

Quick start (transformers)

python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tok = AutoTokenizer.from_pretrained("arungovindneelan/foam-cfd-unified-14b")
model = AutoModelForCausalLM.from_pretrained(
    "arungovindneelan/foam-cfd-unified-14b",
    torch_dtype=torch.bfloat16, device_map="auto",
)
msgs = [{"role": "user", "content": "Generate the system/fvSchemes for a kOmegaSST steady airfoil case."}]
ids = tok.apply_chat_template(msgs, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=1024, do_sample=False)
print(tok.decode(out[0][ids.shape[-1]:], skip_special_tokens=True))

Recommended use

  • —Authoring OpenFOAM v2412 cases from natural-language requests in the full agent pipeline (best results — model + gmsh templates + case writer are co-trained).
  • —Per-file completion benchmark for CFD-aware code models. The per-file dataset format is documented in arungovindneelan/openfoam-Agent-Dataset.
  • —RAG knowledge-grounded CFD assistant — pair with the case bundle at github.com/AGN000/FoamAgentCases for retrieval-augmented generation.

Limitations

  • —OpenFOAM version: trained for v2412 syntax. Foundation-flavour OpenFOAM may need minor BC-name patching.
  • —Geometry coverage: 13 hand-written templates as listed above, plus any LLM-routable variation of those families. Industrial CAD imports, AMR, and chimera meshes are not supported.
  • —Mesh sizes: 2 D cases are 10 k–80 k cells; 3 D cases (sphere, Ahmed, 3 D pipe / channel) are 100 k–800 k cells. No automatic refinement beyond the Distance/Threshold field at walls.
  • —Compressible-transient (`rhoPimpleFoam`): under-represented in the training corpus (~30 cases); harder, fragile prompts may still mis-route to rhoSimpleFoam.
  • —Borderline solver picks: low-Re transient cylinder cases legitimately route to icoFoam (laminar) instead of pimpleFoam (URANS); both are CFD-correct.

License

MIT. Free for commercial and academic use; attribution appreciated.

Citation

bibtex
@misc{foam_cfd_unified_14b_2026,
  title  = {foam-cfd-unified-14b: a fine-tuned Qwen2.5-Coder model for OpenFOAM v2412 case authoring},
  author = {Neelan, Arun Govind},
  year   = {2026},
  howpublished = {Hugging Face model},
  url    = {https://huggingface.co/arungovindneelan/foam-cfd-unified-14b}
}

Related artefacts