1 git clone https://github.com/AGN000/foam-cfd-deploy
2 cd foam-cfd-deploy
3 pip install -r requirements.txt
1 pip install huggingface_hub
2 python3 -c "
3 from huggingface_hub import snapshot_download
4 snapshot_download(
5 'arungovindneelan/foam-cfd-unified-7b',
6 local_dir='checkpoints/unified/merged'
7 )
8 "
1 # Quick demo
2 python3 demo.py "Lid driven cavity, Re=1000"
3
4 # Or call the API directly
5 curl -X POST http://localhost:8000/simulate \
6 -H "Content-Type: application/json" \
7 -d '{"prompt": "flow over a cylinder, Re=100, diameter 0.1m"}'
1 from transformers import AutoTokenizer , AutoModelForCausalLM
2 import torch
3
4 model_id = "arungovindneelan/foam-cfd-unified-7b"
5 tokenizer = AutoTokenizer . from_pretrained ( model_id )
6 model = AutoModelForCausalLM . from_pretrained (
7 model_id ,
8 torch_dtype = torch . float16 ,
9 device_map = "auto" ,
10 )
11
12 # Generate a Gmsh mesh script
13 messages = [
14 { "role" : "system" , "content" : "You are a CFD mesh generation expert. Generate valid Gmsh .geo scripts." } ,
15 { "role" : "user" , "content" : "Create a 2D lid-driven cavity mesh, 0.1m x 0.1m, structured 50x50 grid." } ,
16 ]
17 text = tokenizer . apply_chat_template ( messages , tokenize = False , add_generation_prompt = True )
18 inputs = tokenizer ( text , return_tensors = "pt" ) . to ( model . device )
19
20 with torch . no_grad ( ) :
21 outputs = model . generate ( ** inputs , max_new_tokens = 1024 , temperature = 0.1 , do_sample = True )
22
23 response = tokenizer . decode ( outputs [ 0 ] [ inputs . input_ids . shape [ 1 ] : ] , skip_special_tokens = True )
24 print ( response )
foam-cfd-ai/
checkpoints/unified/merged/ <- this model
inference/
server.py <- FastAPI server (POST /generate /mesh /simulate)
mesh_pipeline.py <- Gmsh script generation + validation
rag/
build_index.py <- build vector store from OpenFOAM tutorials
llm_case_generator.py <- LLM-driven BC file generation
rag_case_builder.py <- RAG + LLM -> OpenFOAM case directory
retriever.py <- vector search over tutorial chunks
simulation/
case_builder.py <- hardcoded fallback case builder
foam_runner.py <- runs foamRun -solver incompressibleFluid
training/
train.py <- QLoRA fine-tuning (Unsloth + TRL)
config_unified.yaml <- training config for this model
demo.py <- end-to-end demo script
requirements.txt
1 curl -X POST http://localhost:8000/simulate \
2 -H "Content-Type: application/json" \
3 -d '{
4 "prompt": "NACA 0012 airfoil, chord 1m, AoA 5 degrees, Re 1e6",
5 "n_iter": 500
6 }'
1 {
2 "status" : "converged" ,
3 "solver" : "simpleFoam" ,
4 "iterations" : 487 ,
5 "residuals" : {
6 "Ux" : { "initial" : 1.0 , "final" : 3.2e-5 } ,
7 "Uy" : { "initial" : 1.0 , "final" : 8.7e-5 } ,
8 "p" : { "initial" : 1.0 , "final" : 2.1e-4 }
9 } ,
10 "case_dir" : "/tmp/foam_cases/20260407_094950_airfoil"
11 }
Apache 2.0 — same as the Qwen2.5-Coder base model.