科研 Skill
OpenFOAM CFD仿真自动搭建
cfd-simulation-setup
Sets up, runs, diagnoses, and reports OpenFOAM CFD cases from a plain-language request using registered flow families and deterministic accept/reject validators. Use for guided OpenFOAM case setup.
SKILL.md
CFD Simulation Setup (CFD Forge method)
Based on CFD Forge: A Physics-Constrained Agentic Framework for Autonomous CFD (Oza, Johnson, Barati Farimani, arXiv:2610.14104; code at github.com/aakashoza31/physics-constrained-cfd-agent).
The central rule: you propose, the code decides. You interpret the request, build the case, read the evidence, diagnose, and propose one action from a closed list. scripts/validate.py alone returns the verdict. In the paper, a model judging from the evidence alone accepted 12 of 13 detectable planted faults, and with the deterministic gates in place it accepted none. Never write ACCEPT yourself, never relax a threshold to make a run pass, and never present a number in the report that didn't come from an evidence file.
Requires OpenFOAM Foundation v14 (v11 or later works for foamRun), plus numpy. Everything except the solve itself runs without OpenFOAM.
Workflow
0. Pick or register a flow family
python scripts/contracts.py # list registered families
python scripts/contracts.py forward-step-2d # show a contract
Registered families: cd-nozzle (steady, quasi-1-D reference), forward-step-2d (transient shock, storage-aware mass closure), cube-stationarity (development gate for force histories), and generic-steady-incompressible (a template).
If the request fits no family, register one before running anything. Follow references/new_family.md and agree the thresholds with the user. A threshold chosen after seeing the result isn't an acceptance criterion. If the user won't fix tolerances up front, the best possible outcome is INCONCLUSIVE, and you should say so.
1. Interpret → stated values only
Write stated.json with only the values the request states, plus request_criteria (what the user wants to know: e.g. transient_health, grid_sensitivity, q1d_consistency) and requests_unsupported_physics: true if the request asks for physics the family excludes (viscosity in an Euler family, combustion, and so on). Leave everything else out. Don't guess.
python scripts/build_case.py spec --family forward-step-2d --stated stated.json --out spec.json
spec.json labels every field stated_by_user or inferred_from_family_defaults. Show the user this table.
2. Scope gate
python scripts/validate.py scope --family forward-step-2d --spec spec.json
If it's out of scope, stop and report which parameter is outside the envelope. Offer the nearest admissible case or a new family. Don't stretch the family.
3. Build the case (values change, formulations don't)
python scripts/build_case.py forward-step --spec spec.json --case cases/m2 # copies $FOAM_TUTORIALS recipe, hashes it
python scripts/build_case.py nozzle --spec spec.json --case cases/noz
If patches_missing_in_template_fields in the builder output is non-empty, the template's 0/ files don't match the mesh patches. Fix that before solving. Boundary-condition types, numerics, and the physical model come from the family recipe. Don't hand-edit fvSchemes, fvSolution, or BC types. For a new family, write its builder first (see references/new_family.md).
4. Mesh gate, then solve
cd cases/m2 && ./Allrun.agent # blockMesh, checkMesh, foamRun with logs
Before solving, run python scripts/evidence.py mesh log.checkMesh. If mesh_ok is false, or a 2-D family has fewer than 2 solution directions, stop.
5. Extract evidence (deterministic; never typed by hand)
E=scripts/evidence.py
python $E log cases/m2/log.foamRun > ev_log.json
python $E mesh cases/m2/log.checkMesh > ev_mesh.json
python $E minmax cases/m2/postProcessing/fieldMinMax/0/fieldMinMax.dat > ev_mm.json
python $E closure mass_records.csv > ev_mass.json # transient families
python $E front line_y0p1.csv --step-x 0.6 > ev_front.json
python $E drift monitor.dat --col 1 --window 2e-3 > ev_drift.json # steady families
python $E growth forces.dat --col 3 --window 20 > ev_growth.json # bluff-body development
python $E merge --family forward-step-2d --criteria transient_health \
--state t=4,end_time=4,iteration=1,refinements=0,max_co=0.2 --out evidence.json ev_*.json
references/function_objects.md has the controlDict function objects that write these records, including the per-step mass and boundary-flux records. Reference or theory comparisons are computed with scripts/theory.py and added to evidence after diagnosis.
6. Diagnose from the blind packet, and propose ONE action
python scripts/validate.py blind --evidence evidence.json --out packet.json
Read only packet.json. Theory and reference values are stripped out, so you diagnose from the simulation's own evidence. Write proposal.json:
{"diagnosis": "INSUFFICIENT_RUN_TIME", "action": "CONTINUE_RUN",
"evidence_cited": ["monitor_drift 2.0% > 0.2%", "mass mismatch decreasing"],
"competing_hypotheses": [{"h": "local_underresolution", "for": "...", "against": "checkMesh clean"}],
"confidence": "high"}
Diagnosis rules (from the paper's system instruction):
- Solver completion is not evidence of stationarity. A settled mean is not evidence of a developed flow; check growth of fluctuating components too.
- Keep these apart: insufficient run time vs. local under-resolution vs. numerical failure vs. boundary anomaly.
- If the evidence can't separate competing hypotheses, propose
REQUEST_DIAGNOSTIC. - Don't invent measurements. Cite packet keys.
- Choose the action from
permitted_actionsonly.
7. Gates decide
python scripts/validate.py action --evidence evidence.json --proposal proposal.json
python scripts/validate.py verdict --evidence evidence.json
- Action REFUSED → don't execute it. You may propose once more, citing the refusal reason. A refused ACCEPT ends as
STOPPED_ACTION_REFUSED, which is INCONCLUSIVE. - Action APPROVED → execute exactly that action (continue, bounded extension, refine ×2 as a fresh solve), increment
iteration, and go back to step 5. The budget is 4 iterations. - The terminal verdict is whatever
verdictreturns. Record it unchanged.
8. Report
Use references/report_template.md: the request, the provenance table, case/mesh, the evidence table straight from evidence.json, each proposal with its ruling, the verdict with reasons, the reference comparison, and limitations. Use normalized units where the family is normalized; the paper's model wrongly attached SI units to normalized quantities. Keep every case file, log, proposal, and ruling so the run can be audited.
Things the gates catch that look fine
- Mesh-sensitivity requests with no registered cross-grid tolerance → INCONCLUSIVE, even when both grids pass.
CONTINUE_RUNafter the horizon is reached is refused; anEXTEND_END_TIMEbeyond the registered horizon is refused.- Refinement is refused unless the current solution is healthy (mesh or topology faults aren't resolution problems).
- Unequal inlet and outlet mass flux in a transient run isn't a conservation failure if the change in stored mass balances it.
- The OpenFOAM start-up line
sigFpe : Enabling floating point exception trappingisn't a fatal error. The extractor ignores it; the paper's validator once didn't.
The contracts protect against the model's errors, not against errors in their own diagnostics. If a verdict looks wrong, inspect the extractor, fix it, and re-analyse without re-solving. Report that you did.
示例提示词
帮我用OpenFOAM搭建这个弯管的湍流仿真,并检查残差是否收敛。
所属插件
安装该插件会一并获得同领域的 35 个 Skill / MCP。
同插件的其他科研 Skill
- FDM增材制造可制造性设计Checks an existing STEP part for FDM printability with the AgentsCAD method: overhang detection, reorientation, chamfers, and kernel plus visual verification. Use for DFAM review before 3D printing.
- 激光粉末床合金可打印性筛选Screens metal alloy compositions for laser powder bed fusion printability using CALPHAD or built-in thermophysical data and Rosenthal melt pools. Use when choosing or qualifying an AM alloy.
- 增材制造文献问答检索Answers additive-manufacturing questions from the user’s own PDF library with page-cited evidence via retrieval. Use for literature-grounded AM questions instead of relying on memory.
- CADSmith文本生成CADGenerates dimensionally exact CadQuery CAD from natural language using the CADSmith plan-code-validate-refine loop. Use when the user describes a part in words and wants a CAD model.
- 机械设计评审文档汇编Assembles a mechanical design-review package: requirements traceability, design FMEA with RPN, costed multi-level BOM, risk register, and a PDR/CDR checklist. Use when preparing a design review.
- 面向制造的可制造性评审Reviews a part or assembly for CNC machining, sheet metal, injection molding, casting, or 3D printing manufacturability, flagging rule violations. Use when the user asks for a DFM/DFMA check.
- 工程图纸与GD&T审查Reviews mechanical drawings (PDF, image, or DXF) for dimensioning errors, GD&T misuse, datum problems, and ASME Y14.5/ISO GPS compliance. Use when checking a drawing before release.
- 工程计算报告生成Turns engineering calculations or scripts into a formal calculation report with objective, assumptions, equations, and unit-checked results. Use for a calc report ready for sign-off.
- LLM-SR方程发现Discovers interpretable equations from engineering data with the LLM-SR loop: skeleton proposals, constant fitting, and out-of-domain scoring. Use for symbolic regression on experimental data.
- 疲劳断裂寿命分析Estimates fatigue life and crack-growth life for metal parts from S-N data, load histories, and fracture-mechanics inputs. Use for Miner’s-rule damage, rainflow counting, or Paris-law crack growth.
- 图像直接生成FDM G代码Converts a photo, sketch, or slice image of a flat or near-flat part directly into FDM G-code without CAD, via silhouette and toolpath extraction. Use for sketch-to-print without modeling.
- 点阵结构刚度逆向设计Designs 3D-printable lattice unit cells for a target stiffness using TPMS cells, printability checks, and voxel homogenization. Use for lattice infill or metamaterial design.
- 平面连杆机构综合Synthesizes planar four-bar or six-bar linkages whose end-effector traces a target curve, using graph-based topology and forward-kinematics search. Use for mechanism path-generation problems.
- LLM驱动FDM打印逐层监控Monitors an FDM print layer by layer through Klipper/Moonraker, diagnosing defects from camera images and applying safety-bounded G-code corrections. Use to watch or fix a live 3D print.
- LLM迭代桁架优化设计Designs and optimizes 2D trusses with an LLM-in-the-loop FEM workflow where proposed members are scored by an exact truss FEM. Use for iterative truss topology or sizing optimization.
- L-PBF缺陷区间预测Predicts L-PBF defect regime (keyholing, lack of fusion, balling, or none) from process parameters and checks melt-pool dimensions against standard criteria. Use when selecting LPBF parameters.
- L-PBF熔池图像超分辨率Upscales low-cost webcam images of an L-PBF build plate to high resolution via registration and a trained diffusion or CNN model. Use for in-situ L-PBF monitoring with cheap cameras.
- 机械零件强度校核Sizes and checks machine elements: bolted joints, shafts for fatigue, bearings for L10 life, springs, welds, and gears, with shown work and safety factors. Use to size or verify a machine element.
- Ashby材料选型Selects engineering materials with the Ashby method: translate function and constraints into a performance index, then screen and rank a shortlist. Use when choosing between candidate materials.
- 产品逆向拆解分析Reverse-engineers a physical product as an engineering system: function structure, costed BOM, DFA index, should-cost, FMEA, and a printable HTML report. Use when asked to tear down a product.
- 力学教学图绘制Produces mechanics teaching figures such as Mohr’s circle, shear/moment diagrams, S-N curves, and free-body diagrams as PNG/SVG. Use when asked to draw or plot a mechanics concept.
- 增材制造熔池几何预测Predicts metal AM melt-pool depth, width, length, and mode (keyhole, lack of fusion, balling, desirable) from laser power, speed, and beam size. Use for LPBF parameter prediction.
- 自然语言参数化CAD建模Turns a plain-English or dimensioned part description into a parametric CadQuery script and exports STEP, STL, and a mass/volume report. Use when asked to model or generate a CAD part.
- FreeCAD自然语言建模Generates FreeCAD models from natural-language queries using the Query2CAD self-refinement loop: macro generation, error repair, and image-text scoring. Use for text-to-CAD in FreeCAD.
常见问题
OpenFOAM CFD仿真自动搭建能做什么?
Sets up, runs, diagnoses, and reports OpenFOAM CFD cases from a plain-language request using registered flow families and deterministic accept/reject validators. Use for guided OpenFOAM case setup。
如何安装OpenFOAM CFD仿真自动搭建?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「OpenFOAM CFD仿真自动搭建」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
OpenFOAM CFD仿真自动搭建需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
OpenFOAM CFD仿真自动搭建经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。