打开FEM代理
开源 模型上下文协议(MCP)服务器 其将AI编码代理连接到8个独立的有限元代码。任何兼容MCP的AI工具(Claude Code、Cursor、Windsurf、GitHub Copilot)都可以 操作 求解器, 一对 它们跨越代码,以及 开发 新的求解器功能——全部通过一个协议实现。
关键数字
| 度量 | 值 |
|---|---|
| FEM后端 | 7工作 (FEniCSx、deal.II、4C、NGSolve、scikit fem、Kratos、DUNE fem) |
| MCP工具 | 13 整合工具 |
| 物理类型 | 194 跨越所有后端 |
| 耦合模式 | 7 (热DD、泊松DD、单向TSI、双向TSI、松弛研究、L型支架、预CICE) |
| 支持的求解器对 | 20 用于领域分解(任何Python求解器+任何后端) |
| 测试 | 209通过 |
| E2E压力测试 | 24已完成 (24次通过) |
快速开始
1.克隆并安装
git clone && cd open-fem-agent
python3 -m venv .venv && source .venv/bin/activate
pip install -e .2.安装求解器后端(选择所需内容)
# pip-installable (any combination)
pip install ngsolve scikit-fem dune-fem
pip install KratosMultiphysics KratosStructuralMechanicsApplication
# FEniCSx (requires conda)
conda create -n fenics -c conda-forge fenics-dolfinx
# or: pip install fenics-dolfinx (if available for your platform)
# deal.II (system package)
sudo apt install libdeal.ii-dev # Ubuntu/Debian
# 4C Multiphysics (build from source — see 4C documentation)3.连接到您的AI工具
MCP服务器作为stdio进程运行。每个AI工具都有自己的注册方式。
克劳德代码 (推荐--支持评论家工作流的子代理生成):
# From the project root:
claude mcp add open-fem-agent \
.venv/bin/python -- -m server \
-e PYTHONPATH=src \
-e PYVISTA_OFF_SCREEN=true或手动创建 .claude/settings.json 在项目目录中:
{
"mcpServers": {
"open-fem-agent": {
"type": "stdio",
"command": ".venv/bin/python",
"args": ["-m", "server"],
"cwd": "src",
"env": {
"PYTHONPATH": "src",
"PYVISTA_OFF_SCREEN": "true"
}
}
}
}光标:
前往“设置”>“MCP服务器”>“添加服务器”,然后输入:
- 姓名:
open-fem-agent - 命令:
/path/to/open-fem-agent/.venv/bin/python - Args:
-m server - 工作目录:
/path/to/open-fem-agent/src - 环境:
PYTHONPATH=src,PYVISTA_OFF_SCREEN=true
帆板运动:
添加到您的Windsurf MCP配置中(设置>MCP):
{
"open-fem-agent": {
"command": "/path/to/open-fem-agent/.venv/bin/python",
"args": ["-m", "server"],
"cwd": "/path/to/open-fem-agent/src",
"env": { "PYTHONPATH": "src", "PYVISTA_OFF_SCREEN": "true" }
}
}OpenAI Codex/任何MCP客户端:
服务器通过stdio与标准MCP通信。为您的客户指出:
command: .venv/bin/python -m server
cwd: src/
env: PYTHONPATH=src4.验证
source .venv/bin/activate
cd src && python -m server # should start without errors (Ctrl+C to stop)
# Run tests
cd .. && pytest tests/ -v5.可选:配置求解器源访问
要启用开发人员模式(源代码浏览、修改、重建),请将求解器路径添加到MCP环境中。看 .claude/settings.json.example 对于模板。
环境变量
从pip/conda安装中自动检测求解器后端。对于编译的求解器或源代码级开发访问,请在MCP设置中设置这些:
| 变量 | 目的 | 示例 |
|---|---|---|
FOURC_ROOT | 4C源树 | /home/user/4C |
FOURC_BINARY | 4C二进制路径 | /home/user/4C/build/4C |
DEALII_ROOT | 交易。II来源 | /opt/dealii |
FENICS_ROOT | FEniCSx来源 | /home/user/dolfinx |
NGSOLVE_ROOT | NGSolve来源 | /home/user/ngsolve |
KRATOS_ROOT | 奎托斯来源 | /home/user/Kratos |
DUNE_ROOT | DUNE有限元源 | /home/user/dune-fem |
SKFEM_ROOT | scikit有限元源 | /home/user/scikit-fem |
当a *_ROOT 设置变量后,代理可以浏览、修改和重建求解器源代码(开发人员模式)。
建筑
User --> AI Agent (any MCP client) --> MCP Protocol --> Open FEM Agent
|
+-------------+-------------+-----------+--------+--------+--------+
| | | | | | |
FEniCSx deal.II 4C NGSolve skfem Kratos DUNE
(Python) (C++) (YAML) (Python) (Python) (JSON) (Python)三种操作模式
1.操作:运行模拟
代理生成求解器特定的输入,运行模拟并验证结果。
2.耦合:多求解器工作流
不同有限元代码之间的域分解、场传递和多物理场耦合。
3.开发:扩展求解能力
当求解器缺少所需的功能时,代理可以读取源代码、实现缺失的部分、重建和测试。
MCP工具
| 工具 | 目的 |
|---|---|
prepare_simulation | 一次通话中的知识+示例+模板 |
run_simulation | 执行基于Python的求解器(FEniCS、NGSolve、scikit fem、DUNE) |
run_with_generator | 生成输入+运行编译的求解器(4C、deal.II、Kratos) |
knowledge | 物理知识、陷阱、材料、耦合文档 |
discover | 列出求解器,检查可用性,能力矩阵 |
examples | 求解器测试套件中的真实测试文件和模板 |
coupled_solve | 交叉求解器域分解(20个求解器对组合) |
transfer_field | 在求解器输出之间提取和传输字段 |
visualize | 现场统计、绘图、自动验证 |
generate_mesh | Gmsh网格生成(L域、带孔板、通道) |
developer | 源架构、文件浏览、扩展点 |
session_insights | 回顾会话模式,贡献知识 |
测试基准
这些基准测试是使用新的人工智能代理进行的端到端压力测试。每个提示都逐字逐句地提供给代理人,没有额外的指导。
单解算器基准测试(9/9通过)
| # | 提示 | 求解器 | 结果 |
|---|---|---|---|
| 1 | Solve the lid-driven cavity problem at Re=400 using FEniCS and visualize the vortex structure in ParaView. | FEniCS | 通过 |
| 2 | Run a 3D magnetostatics problem in NGSolve: a permanent magnet inside a steel housing. Show the B-field distribution. | NGSolve | 通过 |
| 3 | Simulate a cantilever beam with Neo-Hookean hyperelastic material under large deformation using deal.II. Apply 30% compression. | 交易。II | 通行证 |
| 4 | Run an eigenvalue analysis on an L-shaped membrane in scikit-fem. Find the first 10 eigenfrequencies and compare against known values. | scikit有限元 | 通过 |
| 5 | Simulate fluid-structure interaction of a flexible flag behind a cylinder in 4C. | 4C | 通行证 |
| 6 | Solve a transient reaction-diffusion system (Turing patterns) on a unit square using DUNE-fem. Show the pattern evolution. | DUNE fem | 通过 |
| 7 | Simulate a 3D cantilever beam subjected to a sudden tip load using Kratos Multiphysics. Track the tip displacement over time and compare the oscillation frequency against the analytical first natural frequency. | 奎托斯 | 通行证 |
| 8 | Simulate 2D flow past a circular cylinder at Re=100 using FEniCS. Run long enough to capture periodic vortex shedding and measure the Strouhal number. Compare against the accepted value St~0.164. | FEniCS | 通过 |
| 9 | Solve the Poisson equation with a known analytical solution on a 3D unit cube using NGSolve. Run an h-convergence study with 4 mesh refinement levels and verify optimal L2 convergence rate for P1 and P2 elements. | NGSolve | 通过 |
交叉求解器验证(2/2通过)
| # | 提示 | 求解器 | 结果 |
|---|---|---|---|
| 10 | Solve Stokes flow in a backward-facing step on FEniCS, NGSolve, and scikit-fem. Compare the reattachment length. | 3个求解器 | 通过 |
| 11 | Run linear elasticity on a plate with a circular hole under uniaxial tension. Compare stress concentration factor across deal.II, FEniCS, and 4C. | 3个求解器 | 通过 |
多求解器耦合(4/4通道)
| # | 提示 | 求解器 | 结果 |
|---|---|---|---|
| 12 | Solve heat conduction on an L-domain with FEniCS, transfer the temperature field to NGSolve, and solve thermoelasticity there. Show the thermal stress distribution. | FEniCS+NSolve | 通过 |
| 13 | Run a Poisson problem with domain decomposition: left half on DUNE-fem, right half on scikit-fem. Iterate until convergence. | DUNE+scikit有限元 | 通过 |
| 14 | Simulate a heated steel beam in 4C (TSI one-way) and independently verify the thermal expansion using FEniCS. Compare displacements. | 4C+费用 | 通过 |
| 15 | Model electromagnetic wave scattering in NGSolve around an obstacle, then use the Joule heating field as a thermal load in a Kratos structural analysis. | NGSolve+奎托斯 | 通行证 |
高级(7/7通过)
| # | 提示 | 求解器 | 结果 |
|---|---|---|---|
| 16 | Run a poroelasticity consolidation problem in 4C (Terzaghi's problem) and verify against the analytical solution. | 4C | PASS(重新运行:沉降0.1%,压力\<0.4%误差,代理导出正确BULKMODULUS→阿尔法映射) |
| 17 | Simulate crack propagation in a double-cantilever beam using 4C peridynamics and compare the energy release rate against LEFM predictions. | 4C | PASS(G_eff=G_Ic精确值,CMOD为LEFM的8.5%) |
| 18 | Set up a fluid-beam interaction problem in 4C: flow around a slender elastic beam. Monitor the beam tip displacement over time. | 4C | PASS(4.36mm尖端偏转,单调增长) |
| 19 | Simulate gravity-driven packing of 500 spherical particles into a cylindrical container using Kratos DEM. Measure the final packing fraction and compare against the random close packing limit (~0.64). | 奎托斯 | 通行证 |
| 20 | Compute the first 6 electromagnetic resonant frequencies of a 3D rectangular cavity using NGSolve Nédélec elements. Compare against the analytical TM/TE mode frequencies. | NGSolve | 通过(所有6种模式都匹配\<10⁻⁶ 相对误差) |
| 21 | Generate a 3D thick-walled cylinder mesh with Gmsh, then solve internal pressure loading with Neo-Hookean material in FEniCS. Compare the radial displacement against the analytical Lamé solution at small strain. | FEniCS | PASS(L2误差与Lamé、P2曲线元素相比为0.42%) |
求解器选择和代理智能(1/1通过)
| # | 提示 | 选择求解器 | 结果 |
|---|---|---|---|
| 22 | Solve the heat equation on a unit square with T=1 on the left, T=0 on the right, and zero-flux top/bottom. Pick the best solver and verify against the analytical solution. | FEniCS(自动选择) | 通过(L2误差=7e-15,机器精度) |
| 23 | Simulate two elastic blocks being pressed together with contact. Use whichever solver is most appropriate. | 4C(自动选择) | PASS(砂浆惩罚接触,10个加载步骤,应力集中1.66x) |
| 24 | Set up a simple fluid-structure interaction problem in Kratos using the CoSimulation application: flow in a channel with a flexible wall segment. Monitor the wall deflection. | 奎托斯 | PASS(14次艾特肯迭代,13.99mm偏转,与梁理论相比为1.3%) |
贡献
我们欢迎改善 多用途的 Open FEM Agent的功能。关键原则:
每一项改进都必须使所有模拟受益,而不是针对特定示例进行微调。
如何做出贡献
- 报告代理行为 --使用AI工具和求解器设置运行任何基准测试提示(或您自己的)。报告:
- 你使用了哪种人工智能工具(克劳德代码、光标、风帆等) - 你给出的确切提示 - 什么有效,什么无效 - 代理人的回顾(问下面的汇报问题)
- 提高求解器知识 -添加陷阱、元素目录或API文档,以帮助任何代理正确设置模拟。专注于代理人必须通过反复试验发现的事情。
- 添加求解器后端 --实施
SolverBackend新FEM代码的接口。
- 膨胀联轴器 --在中为新的求解器对添加脚本生成器
src/tools/coupling.py.
什么不该贡献
- 基准特定参数数据库(代理应针对每个问题进行研究)
- 特定于模型的模板(例如“Turek Hron FSI2模板”)——这些是微调
- 硬编码路径或机器特定配置
汇报问题(每次压力测试后提问)
- "What went wrong and what workarounds did you have to use?"
- "Which MCP tools were useful and which were missing or unhelpful?"
- "What information did you have to look up online that should have been available through the MCP?"
- "What parameters did you struggle with and why?"
- "If you had to do this again, what would you do differently?"将答案反馈为对MCP知识和工具的通用改进。
AI工具兼容性
MCP服务器可与任何兼容MCP的AI工具配合使用。代理指令以多种格式提供:
| 文件 | AI工具 |
|---|---|
CLAUDE.md | 克劳德代码 |
AGENTS.md | 交叉工具标准 |
.cursorrules | 光标 |
.windsurfrules | 风帆冲浪 |
.github/copilot-instructions.md | GitHub副本 |
许可证
麻省理工学院
引用
如果您在研究中使用Open FEM Agent,请引用:
@article{openfem2026,
title={Open FEM Agent: An Open-Source Multi-Solver MCP Server for LLM-Driven Finite Element Simulation},
year={2026},
}