fluent-cfd
August 26, 2026 · View on GitHub
通过本机 ansys-fluent-mcp(官方 ansys/pyfluent-mcp)驱动 ANSYS Fluent 的 DSH 智能体预设。包含:
agent.cordis.yml— 智能体编排(persona + 工具 + Fluent MCP 执行层)。preset.yml— 预设元数据。skills/fluent-cfd/— Fluent CFD 判断层(工作流、湍流/边界、数值/收敛、PyFluent 执行、预处理计算、校验/恢复)+ 脚本(solver_loop.py长跑驱动、long_run.journal、preprocessing.py)。
只有 预设(判断层 + 执行层配置) 会被安装。真正求解仍需要你本机装有 ANSYS Fluent + license。
1. 前置依赖(必须)
| 项 | 说明 |
|---|---|
DSH(.dsh) | 已安装并可用(~/.dsh/,含 agent-presets 目录) |
| ANSYS Fluent | 支持 2024 R2(v241)及之后所有版本(24R2/25R1/25R2 等;安装脚本按探测到的版本注入对应 AWP_ROOT<版本>)+ 有效 license |
| Python 3.x | 装下述包(见「依赖安装命令」) |
版本不匹配是常见坑:
pyfluent与 Fluent 发行版要对应(PyFluent 0.41 ↔ Fluent 25.2;较新 Fluent 需匹配的 pyfluent-core)。solver_loop.py默认自动探测本机 Fluent 版本。
依赖安装命令
python -m pip install ansys-fluent-core ansys-fluent-mcp
建议按版本锁定,确保与你的 Fluent 发行版匹配(本仓库验证用 ansys-fluent-core==0.41.0、ansys-fluent-mcp==0.4.0):
python -m pip install "ansys-fluent-core==0.41.0" "ansys-fluent-mcp==0.4.0"
ansys-fluent-core(PyFluent):solver_loop.py里import ansys.fluent.core所用的包。ansys-fluent-mcp:提供ansys-fluent-mcp命令(Windows 下为Scripts\ansys-fluent-mcp.exe)。- 安装后确认:
python -c "import ansys.fluent.core as f; print(f.__version__)"和ansys-fluent-mcp --help。
相关官方来源(upstream)
- PyFluent(
ansys-fluent-core):https://github.com/ansys/pyfluent - PyFluent MCP server(
ansys-fluent-mcp):https://github.com/ansys/pyfluent-mcp
2. 一键安装
Windows(PowerShell)
# 克隆后
git clone https://github.com/qing9835/dsh-agent-pyfluent.git fluent-cfd-deploy
cd fluent-cfd-deploy
.\install.ps1
脚本会自动:探测本机 python、ansys-fluent-mcp、Ansys 安装目录,把两个机器路径写进 agent.cordis.yml,并复制预设到 %USERPROFILE%\.dsh\.agent-presets\fluent-cfd。
Linux / macOS(bash)
git clone https://github.com/qing9835/dsh-agent-pyfluent.git fluent-cfd-deploy
cd fluent-cfd-deploy
./install.sh
手动(不跑脚本)
- 把
fluent-cfd/整个拷到~/.dsh/.agent-presets/fluent-cfd/。 - 编辑
agent.cordis.yml两处:command: '<python的Scripts目录>\ansys-fluent-mcp.exe' # 你本机的 mcp 可执行文件 env: AWP_ROOT<版本>: '<你的Ansys安装目录,如 D:\Program Files\ANSYS Inc\v252>' # v241/v252 等
覆盖自动检测
设置环境变量(或安装脚本参数)即可跳过探测:
PYTHON/-p:python 解释器路径PYTHON_ANSYS_FLUENT_MCP:ansys-fluent-mcp完整路径ANSYS_AWP_ROOT/-a:Ansys 安装目录(如/opt/ansys_inc/v252)
3. 使用
- 在 DSH 里以
fluent-cfd预设启动智能体(工具以mcp__fluent__*暴露)。 - 智能体自带
fluent-cfdskill:先session_status,再connect(会占 license,会先告诉你),加载 case,短烟测,再决定长跑。
长跑(重要)
- 不要用
run_code跑长迭代 —— 单次调用超时会杀掉会话(skill 里pyfluent-execution.md已写明)。 - 用后台脚本:
python skills/fluent-cfd/scripts/solver_loop.py --case-dir <案例目录> --blocks 60 --iters-per-block 500- 默认弹出 Fluent GUI;
--no-gui无头;--keep-open跑完后保留界面(自己关)。 - 或用
long_run.journal:fluent.exe 2ddp -t16 -i long_run.journal。
- 默认弹出 Fluent GUI;
4. 故障排查
File has wrong dimensions (2):case 是 2D,但会话是 3D。启动时用dimension=2(solver_loop.py已内置;MCPconnect用connect_kwargs={"dimension":2,...})。- PyFluent 找不到 Fluent:
AWP_ROOT<版本>没指向你的实际安装目录(solver_loop.py用--version或自动探测;MCP 由安装脚本注入正确的 AWP_ROOT 变量)。 ansys-fluent-mcp命令不存在:装ansys-fluent-mcp包,或把command指向实际路径。- license:确认 license 服务已启动、可用。
- 长跑被断:走了
run_code长迭代 → 改用solver_loop.py/long_run.journal(后台进程,无超时)。
5. 目录说明
fluent-cfd-deploy/
├── README.md
├── install.ps1 / install.sh # 一键安装
├── fluent-cfd/ # 预设模板(agent.cordis.yml 含 __占位符__)
│ ├── preset.yml
│ ├── agent.cordis.yml
│ └── skills/fluent-cfd/
│ ├── SKILL.md
│ ├── references/ # 6 个:workflow / boundaries-and-turbulence /
│ │ # numerics-and-convergence / pyfluent-execution /
│ │ # preprocessing-calculations / validation-and-recovery
│ └── scripts/ # solver_loop.py / long_run.journal / preprocessing.py
└── LICENSE