DualSPHysics MCP

io.github.vegetableno1由 GitHub 账号 vegetableno1 发布v0.2.0更新于 Oct 24, 2026

Agent toolchain for the DualSPHysics SPH solver: case creation, runs, post-processing, validation.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

封装本地 DualSPHysics SPH 工具链,让助手设计、运行、后处理并验证二维溃坝模拟。

可以做什么
  • 检查本地 DualSPHysics 安装:定位 GenCase、求解器、PartVTK 与 MeasureTool,并给出版本与安装提示
  • 以结构化参数创建、修改和回读二维溃坝算例,并估算粒子数
  • 用 GenCase 离散算例,并把 CPU 求解器作为后台任务启动
  • 轮询任务进度、模拟时间、吞吐量与预计完成时间
  • 把粒子输出转换为 ParaView 可读的 VTK 文件,并在指定点采样为 CSV 时间序列
  • 将溃坝涌潮前沿与内置的 Koshizuka & Oka (1996) 实验对比,给出逐时刻误差与 MAE/RMSE/最大值
适用场景
适合在本地运行 DualSPHysics、希望由助手反复调整溃坝算例参数、启动并监控求解任务,并与参考实验对比结果的场景,无需手写 XML 或命令行。
运行要求
在桌面机器上以本地进程运行,需要 Python 3.10+(PyPI 包,可用 uvx 启动)。还需另行安装 DualSPHysics:GenCase、CPU 求解器、PartVTK 与 MeasureTool 可执行文件,通过 DSPH_GENCASE、DSPH_SOLVER、DSPH_PARTVTK、DSPH_MEASURETOOL、PATH 或常见安装路径发现。可选 DSPH_JOBS_DIR 与 DSPH_OMP_THREADS。无需认证。
安装前请注意
求解计算占用大量 CPU 且耗时较长:文档示例在 8 线程下模拟 2 秒约需 14 分钟。任务会向作业目录写入输出文件,edit_case 在未指定保存路径时会就地修改已有算例文件。该服务器只是以子进程方式调用本地程序,DualSPHysics 本身不随包分发,需自行获取并编译。

安装

在 SourceWeft 中

  1. 打开 控制台中的 DualSPHysics MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

DualSPHysics MCP

Language: English | 中文

[Listed on mcpservers.org] [vegetableno1/DualSPHysics-mcp MCP server] [CI]

Design, run, and verify DualSPHysics simulations from an AI agent — not just stare at them.

Ten Model Context Protocol tools wrap a local DualSPHysics SPH toolchain end to end: design cases as structured parameters (no hand-written XML, no solver needed to iterate), run them as background CPU jobs with progress, throughput and the solver's own ETA on tap, post-process into ParaView-ready VTK and CSV time series, and verify a 2D dam-break against the Koshizuka & Oka (1996) experiment with per-time errors and MAE / RMSE / max.

The server only launches the DualSPHysics command-line tools as subprocesses; DualSPHysics itself is not distributed here — it is free LGPL-2.1-or-later software, this package neither links nor redistributes its code or binaries, so the MIT licence carries no extra obligations. If you publish work using DualSPHysics, cite Dominguez et al. (2022), Computational Particle Mechanics 9:867–895, doi:10.1007/s40571-021-00404-2.

Tools

ToolWhat it does
check_environmentFind the four DualSPHysics tools on this machine: resolved path, provenance (env var, PATH, scan), version, solver feature flags; install hints when one is missing.
create_caseDescribe a 2D dam-break experiment in plain parameters and get a GenCase *_Def.xml back — no XML by hand, no solver needed. Returns a particle-count estimate for self-checking.
edit_caseChange parameters of an existing case (in place or to a save_path), re-validating the merged result.
describe_caseRead a case file back as a summary: dp, domain, column/tank/obstacle, timing, gauges, particle estimate.
gencaseDiscretise the case into Case.xml + Case.bi4 (plus preview VTK) and report the real particle counts.
run_caseStart the CPU solver in the background (jobs/ directory, Run.out, Part_*.bi4) and return a job_id immediately.
job_statusPoll a job: state, t/tmax, percent, the solver's Time/Sec throughput and projected finish, Run.out tail.
partvtkTurn Part_*.bi4 output into VTK particle files for ParaView; filters and variables pass through.
measure_toolProbe the solution at points and get CSV time series back (comma separator enforced for deterministic parsing).
validate_dambreakReconstruct the dam-tip surge front from the CSV and score it against the embedded Koshizuka & Oka (1996) series: per-time errors + MAE/RMSE/max.

Working chain: check_environment → create_case → describe_case → gencase → run_case → poll job_status → partvtk + measure_tool → validate_dambreak. Vocabulary, three guards and particle-estimate arithmetic: docs/case-generation.md.

Domain contracts

Behaviours of the wrapped tools that their -h output does not tell you:

  • Geometry outside the domain box is silently clipped by GenCase (exit 0, no warning) — create_case containment-checks every domain.
  • DualSPHysics CSVs default to semicolon separators; measure_tool forces commas unless the caller passes their own -csvsep.
  • MeasureTool points files reject leading # comment lines; MeasureTool errors print on stdout, not stderr.
  • Time/Sec in Run.out is wall-clock seconds per simulated second — not steps/second; the row tail is the solver's projected finish.
  • Run.out row formats differ between solver v5.0/v5.2 and v5.4; the parser handles both.

All fourteen contracts (formats, exit codes): docs/domain-contracts.md.

Install

Python 3.10+. The binaries are discovered from DSPH_* environment variables, PATH, or conventional install roots (/opt, /usr/local, ~/softwares, ~, cwd → <root>/DualSPHysics*/bin/linux).

bash
uv sync                 # or: python -m venv .venv && .venv/bin/pip install -e .

Getting the solver (the GitHub repository ships GenCase / PartVTK / MeasureTool prebuilt but not the solver):

  1. Full package from https://dual.sphysics.org/downloads/, or
  2. git clone https://github.com/DualSPHysics/DualSPHysics and build the CPU solver with make -f Makefile_cpu (g++ only, no CUDA needed), then copy the prebuilt tools from bin/linux/.

Configure through environment variables (no .env parsing; see .env.example — the same paths appear in examples/mcp_config.example.json):

DSPH_GENCASE=/home/<user>/softwares/DualSPHysics/bin/linux/GenCase_linux64DSPH_SOLVER=/home/<user>/softwares/DualSPHysics/bin/linux/DualSPHysics5.4CPU_linux64DSPH_PARTVTK=/home/<user>/softwares/DualSPHysics/bin/linux/PartVTK_linux64DSPH_MEASURETOOL=/home/<user>/softwares/DualSPHysics/bin/linux/MeasureTool_linux64DSPH_JOBS_DIR=/abs/path/to/jobs     # optional, default ./jobsDSPH_OMP_THREADS=8                  # optional, default all cores

Run

bash
.venv/bin/python mcp_server.py    # hub-style entry point (stdio).venv/bin/dualsphysics-mcp        # console scriptuvx dualsphysics-mcp              # published on PyPI

Client registration templates: examples/mcp_config.example.json:

json
{ "mcpServers": { "dualsphysics-mcp": { "command": "uvx", "args": ["dualsphysics-mcp"] } } }
bash
claude mcp add dualsphysics-mcp -- /abs/repo/path/.venv/bin/python /abs/repo/path/mcp_server.py

Example: 2D dam-break validation (Koshizuka & Oka 1996)

examples/dambreak_val2d/ holds the showcase: the official validation layout (dp = 0.01 m; 1 m × 2 m water column in a 4 m × 3 m tank; TimeMax = 2 s, TimeOut = 0.01 s; Verlet / Wendland / artificial viscosity 0.02 / Fourtakas DDT 0.1), regenerated by gen_dambreak_val2d.py (MIT), a surge-front MeasureTool points file (401 points along z = 0.03 m), and the digitised experiment.

Measured on this case (GenCase v5.4.354 / solver v5.4.355, 8 CPU threads, i5-10210U):

QuantityValue
Total particles21,001 (fluid 20,000 + bound 1,001)
Part files201 (Part_0000 … Part_0200)
Solver wall time (TimeMax = 2 s)≈ 14 min
Dam-tip MAE vs experiment (0.09–0.75 s)0.220 m (22.0 % of the column); RMSE 0.240 m
Dam-tip error, early collapse (t ≤ 0.2 s)within ±0.01–0.16 m
Wall impactfront pins at 3.98 m at t ≈ 0.67 s

[Simulated surge front vs the 1996 experiment]

The residual is SPH physics, not a measurement artefact: the front extraction tracks the solver's own SWL gauge (mean deviation 8 mm < 10 mm point spacing), and the experiment ends at X/a ≈ 4.13 — beyond the 4 m tank — so the comparison saturates after wall impact (validate_dambreak notes impact_time_s).

Agent transcript:

check_environment()                                  # all four tools foundgencase("examples/dambreak_val2d/CaseDambreakVal2D_Def.xml")  -> particle_counts: total=21001 fluid=20000 bound=1001run_case("<out>/CaseDambreakVal2D")                  # returns job_idjob_status(job_id)                                   # poll until percent=100partvtk(job_id=job_id)                               # 201 fluid VTK filesmeasure_tool(job_id=job_id, points_file="examples/dambreak_val2d/points_damtip.txt")validate_dambreak(csv_path="<measure csv>", points_file="examples/dambreak_val2d/points_damtip.txt")

validate_dambreak reports per-time errors plus MAE / RMSE / max in metres and as % of the 1 m column. The figure comes from examples/make_validation_figure.py; examples/render_dambreak.py turns the same run's Part_*.vtk into an MP4 animation (dev dependencies).

Tests

bash
uv run pytest -q          # or: .venv/bin/python -m pytestuv run ruff check .

The suite is green without any solver installed (discovery, command construction, log-fixture parsing, validation math, case generation, stdio end-to-end). Tests marked solver exercise a real local toolchain and auto-skip otherwise.

Contents

  • src/dualsphysics_mcp/ — MCP server, tool discovery and config, error codes, the ten tools in tools/.
  • examples/ — validation case, create_case_demo.py, figure + animation scripts, client template.
  • tests/ — pytest suite (solver tests auto-skip).

Repository rules

  • Committed: source, tests, examples, documentation, templates.
  • Not committed: DualSPHysics binaries or sources (LGPL work stays out), virtual environments, .env, job outputs and generated results.
  • Experiment values in examples/dambreak_val2d/ are digitised facts cited to Koshizuka & Oka (1996) as shipped with the DualSPHysics examples; the generated case XML and all code here are original MIT content — details in CONTRIBUTING.md.

来源:README.md,提交 ac42bff

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.2.0最新Sep 25, 2026
  2. v0.1.1Sep 22, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分