DualSPHysics MCP

v0.2.0
io.github.vegetableno1/dualsphysics Checked 3 days ago Published 2 months ago

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

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

check_environment

Probe the DualSPHysics toolchain: paths, versions, solver features. Reports for GenCase / CPU solver / PartVTK / MeasureTool whether each binary was found (env var, PATH or conventional install dirs), its version, and the solver's feature flags (a build without WaveGen cannot run wave cases). Call this first; missing tools come with install hints.

create_case

Create a GenCase case XML (`*_Def.xml`) from a template plus overrides. Pure Python — no solver needed. Designs a 2D dam-break-family experiment in the XZ plane (y pinned to 0) WITHOUT hand-writing XML, with strong parameter validation and a lattice-arithmetic particle estimate to self-check the design before running gencase. The `dambreak_val2d` template reproduces the official validation layout: dp=0.01, 1 m x 2 m water column at the origin, 4 m x 3 m open-top tank, domain (-1, 0, -1)..(4.5, 0, 3.5), TimeMax=2 s, TimeOut=0.01 s, one vertical SWL gauge (x=0…

ParameterTypeDescription
out *string
overrides
templatestring

edit_case

Edit an existing `*_Def.xml` with the create_case override vocabulary. Reads the case (must parse as the 2D dam-break family: one fluid drawbox, one tank drawbox, optional obstacle, vertical/horizontal SWL gauges), applies the same overrides as create_case, re-validates the merged case (including the domain-contains-geometry guard) and writes the result. Files that violate the vocabulary (3D domains, multiple obstacles, diagonal gauges, ...) are rejected with DSPH_BAD_INPUT. Args: path: Case XML to edit (with or without .xml suffix). overrides: Sam…

ParameterTypeDescription
path *string
overrides
save_path

describe_case

Summarise a `*_Def.xml` case: geometry, timing, gauges, particle estimate. Read-only self-check loop for case design: reports dp, the domain box, water column / tank / obstacle dimensions, TimeMax/TimeOut, gauges and a lattice-arithmetic particle estimate (fluid/bound/total) to compare with gencase's real counts. Accepts the same 2D dam-break-family vocabulary as edit_case (the official CaseDambreakVal2D layout parses fine).

ParameterTypeDescription
path *string

gencase

Run GenCase: case XML -> Case.xml + Case.bi4 (+ preview VTK files). Args: xml_path: Path to the *_Def.xml case definition (with or without .xml). output_dir: Output directory (default: <name>_out next to the XML). out_name: Output case name (default: XML stem minus _Def). save_modes: GenCase -save value (default "all" = bi4 + preview VTKs). extra_args: Extra GenCase flags (e.g. ["-dp:0.02"]).

ParameterTypeDescription
xml_path *string
extra_args
out_name
output_dir
save_modesstring

run_case

Start the CPU solver in the BACKGROUND and return a job_id. The case must have been processed by gencase first (Case.xml + Case.bi4). Progress is tracked with job_status; outputs land in the job directory (Run.out, data/Part_*.bi4). Restart/cancel are not implemented; solver flags such as -partbegin:<n> can be passed via extra_args. Args: case_path: Processed case base (gencase out_xml, with/without .xml). dirout: Output directory (default: jobs/<job_id>). omp_threads: OpenMP threads (default: DSPH_OMP_THREADS or all cores). tmax: Override…

ParameterTypeDescription
case_path *string
dirout
extra_args
omp_threads
tmax
tout

job_status

Poll a background solver job: state + Run.out progress digest. Returns the running state (plus pid/returncode), simulated time vs tmax, percent, step counters, the solver's Time/Sec throughput (wall-clock seconds per simulated second), the solver's own projected finish time, particle counts and the Run.out tail.

ParameterTypeDescription
job_id *string

partvtk

PartVTK: convert Part_*.bi4 particle files to VTK for visualisation. Args: job_id: Job whose data/ directory holds the Part_*.bi4 files. dirdata: Explicit particle data directory (alternative to job_id). savevtk: Output prefix (default particles/PartFluid inside the job). onlytype: Particle filter (default fluid only). variables: Variables to store, e.g. "+idp,+vel,+rhop,+press". first/last: Part index range. extra_args: Extra PartVTK flags.

ParameterTypeDescription
dirdata
extra_args
first
job_id
last
onlytypestring
savevtkstring
variables

measure_tool

MeasureTool: interpolate SPH values at points -> CSV time series. For the dam-break validation use a horizontal line of points just above the bottom (examples/dambreak_val2d/points_damtip.txt) with density (default -vars:-all,rhop): points beyond the surge front read 0, so the furthest wet point is the front position that validate_dambreak compares against the experiment. Args: job_id: Job whose data/ directory holds the Part_*.bi4 files. dirdata: Explicit particle data directory (alternative to job_id). points_file: MeasureTool points file (PO…

ParameterTypeDescription
dirdata
extra_args
job_id
onlytypestring
points_file
pointsdef
savecsvstring
savevtk
variablesstring

validate_dambreak

Validate a 2D dam-break run: dam-tip front vs Koshizuka & Oka (1996). Reads the CSV produced by measure_tool with the SAME points definition (columns map to points by order), reconstructs the front position per output time (furthest point above the wetness threshold) and reports per-time errors plus MAE / RMSE / max error in metres and as % of the column length. Args: csv_path: MeasureTool time-history CSV. points: Points [[x, y, z], ...] in CSV column order. points_file: The points file used for the measurement. threshold: Wetness thre…

ParameterTypeDescription
csv_path *string
column_lengthnumber
experimentstring
max_time
points
points_file
thresholdnumber