Shaderous

v0.4.0
io.github.guillochon/shaderous Checked 3 hours ago Published 7 days ago

GPU gas dynamics on WebGPU (hydro, MHD, gravity, AMR): load, run, measure and look at simulations

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

describe

List the problems (presets) with their ids, dimensions, end times and parameters, and the fields, variables and choices a setup can make. Give `problem` for one problem in full, with its description.

ParameterTypeDescription
problemstringA problem id for its full entry

check_setup

Check a setup document before running it. Returns `ok`, an `error` if it cannot be read at all (with the key at fault), `notes` (keys dropped, values held to their range), and `issues`: each with a level (`error`: a rule broken, such as a star without isolated self-gravity, or a value that cannot work; `warning`: a choice to look at again, such as a softening under two cells, bodies that overlap or leave the box, a grid past the GPU memory), a sentence, and the path of the part or option it is about. Use it after writing or changing a document and before `load`.

ParameterTypeDescription
document *objectThe setup document (format "shaderous-setup")
dirstringThe folder the document’s mesh files are in (its `mesh` shapes name them); default the server’s working folder

load

Build a new run from a setup and leave it paused at t = 0. A setup is a preset with overrides, or a whole setup document (`document`) that assembles a run from parts: point masses, stars, disks, gas regions, obstacles, a magnetic field. The setup uses the keys of a shareable link, as a query string ("problem=sedov&dim=2&n=512&gamma=1.4") or an object ({"problem": "sedov", "dim": 2, "n": 512}). Returns the run’s state, including `query`, the setup in force.

ParameterTypeDescription
dirstringThe folder the document’s mesh files are in (its `mesh` shapes name them); default the server’s working folder
documentobjectA setup document (format "shaderous-setup", see docs/setups.md and describe().setup): the run is built from it, and `setup` then says the grid and what differs. Start from preset(id) to make one
setupstring | objectQuery string, link, or object of setup keys; or a setup document itself

run

Advance the run: to time `until` (the last step is shortened to land on it exactly), by `steps` steps, or whichever comes first. Stops at the problem’s end time (stopped: "end"); to go further, load with a later `tend`. Returns t, dt, steps, steps taken, wall seconds and why it stopped.

ParameterTypeDescription
stepsintegerTake at most this many steps
timeout_secondsnumberGive up after this much wall time (default 600)
untilnumberRun until the clock reads this time

state

The run: problem, dimensions, grid, amr levels, time, timestep, steps, end time, whether it has finished, the GPU adapter, and `query`, the setup that reproduces it.

diagnostics

Totals and extremes read back now: mass, momentum, kinetic/internal/gravitational/total energy, max Mach number, floored cells, Jeans-unresolved cells, center of mass, point masses, and the [min, max] of every field.

stats

Least, greatest and volume-weighted mean of each variable over the box (rho, press, vel1-3, r0 and species mass fractions).

slice

A variable on a res x res grid on a plane through the box (perpendicular to `axis` at fraction `pos`). Returns min, max and mean, and the values (row j, column i: values[j][i]) when res is at most 64 or include_values is set; with save_path the full slice is written there instead: as a .npy file (float32, shape [res, res], for numpy’s np.load) when the name ends in .npy, else as JSON.

ParameterTypeDescription
axisintegerDefault 2 (z); always 2 in 2D
include_valuesbooleanReturn the values at any res (default: only when res is at most 64)
posnumberDefault 0.5
resintegerDefault: the size of the grid, at most 256 (the MCP tool: 32)
save_pathstringWrite the slice to this file: .npy (float32 for numpy), else JSON
variablestringOne of rho, press, vel1, vel2, vel3, r0, level, temp, tempK, or the name of a species. temp is the temperature in code units, tempK in kelvin (a setup with physical units). Default rho

probe

The gas at points given as fractions of the box ([x, y, z], z ignored in 2D): density, pressure, velocity, passive scalar, temperature (temp in code units; tempK in kelvin, with physical units), refinement level and species mass fractions.

ParameterTypeDescription
points *array

screenshot

A picture of the run as a PNG image. `view` changes what is drawn first: mode (volume|slice|projection), field (index, see describe), species, log, lo, hi, sliceAxis, slicePos, minRho, opacity, yaw, pitch, dist, tx, ty, tz, zoom, cx, cy, showBlocks, contours, nContours, fog, surfaceOpacity, light, box, fieldLines, fieldLineCount, fieldLineFloor, mirrorImages, turnWithFrame, colormap, tf, autoRange. Settings persist for later screenshots. `native` saves a plane at the grid's own resolution (one pixel per finest cell), with any overlays in margins beside it.

ParameterTypeDescription
axesbooleanThe axes (default false)
colorbarbooleanThe color bar (default false)
heightintegerDefault: width
layoutstring'over': the overlays over the picture's edges, as in a movie; 'beside': in margins around it, covering nothing. Default 'beside' with native, else 'over'
nativeboolean | stringOne pixel per cell of the finest level (the grid's own resolution, up to the largest texture): true or 'box' for the whole box, 'view' for the part in view. A plane only (a 2D run, a slice or a projec…
save_pathstringAlso write the PNG to this file
statusbooleanThe status line: grid, simulation time, point masses, mesh (default false)
viewobjectView settings to apply first
widthintegerDefault 768

view

Change what screenshots show without touching the run. Returns the view settings.

ParameterTypeDescription
changes *objectAny of mode, field, species, log, lo, hi, sliceAxis, slicePos, minRho, opacity, yaw, pitch, dist, tx, ty, tz, zoom, cx, cy, showBlocks, contours, nContours, fog, surfaceOpacity, light, box, fieldLines…

controls

The control panel as it stands: every control’s id, kind, label, tooltip, value and options. Use with `control` to change settings mid-run.

control

Set a panel control (or press a button, with no value) exactly as a person would, mid-run, and wait for what it starts (a shader rebuild, a restart). Examples: control("riemann", "hll"), control("eos", "gas_radiation"), control("reset"). Number fields take values in the units the panel shows; set control("units", "code") first for code units. The run stays paused.

ParameterTypeDescription
id *string
valuestring | number | boolean

restart

Start the run again from its initial conditions, paused.

save_athdf

Save the state of the gas to an .athdf file (HDF5 in Athena++’s layout; yt reads it). The file carries the setup, so load_athdf continues the run exactly.

ParameterTypeDescription
pathstringFile or folder to write to (default: the current folder, under the file’s own name)

record

Record the run from where it is as an MP4 movie (H.264), stepping it as it goes: the current view with a color bar, x/y/z axes and the status line (grid, simulation time) over it. A frame every `every` steps, or near every `dt` of code time (at the nearest step boundary: no step is shortened, so the run is the one it would have been unrecorded). Stops at `until`, after `frames` frames, or at the end time. Set the view first. Returns the frame count, movie length and where the file went.

ParameterTypeDescription
axesbooleanDefault true
bitrate_mbpsnumberMegabits per second of movie (default 0.2 bits per pixel per frame: 25 at 1080p and 60 fps)
colorbarbooleanDefault true
dtnumberA frame near every multiple of this much code time (default: a 600th of the dynamical time of the problem, so one dynamical time plays in 10 s at 60 fps)
everyintegerOr a frame every this many steps
fpsnumberPlayback rate (default 60)
framesintegerStop after this many frames
heightintegerDefault 1080 (9/16 of width when width is given)
pathstringFile or folder to write to (default: the current folder, under the name of the movie)
statusbooleanThe status line (grid, simulation time, point masses, mesh). Default true
timeout_snumberGive up after this much wall time, keeping what was recorded
untilnumberStop when the clock reaches this time (landed on exactly)
widthintegerDefault 1920

load_athdf

Start a run from an .athdf file: one Shaderous wrote continues exactly; another code’s is loaded into the current problem. Paused at the file’s time.

ParameterTypeDescription
path *stringThe file to read
one_fieldbooleanWith view: hold only the field shown (true) or the state (false), instead of whichever keeps more levels
viewbooleanOpen it only to look at (a run too large to continue here): read in parts, never stepped (run refuses), held with its state or holding only the field shown (baked from the file again when the field ch…

debris

Debris energies, for problems that track them (describe: problems[].debris, e.g. tidal-disruption): the gas binned by its specific orbital energy about the point mass, both what has left the box (tallied as it left) and what is in it, a surviving self-bound core set apart, and the return rate of the bound debris to pericenter, dM/dt (Kepler). Returns totals, the core, the first return and the peak of dM/dt (in days and solar masses per year where the problem has units). save_path writes the full report (bins, dmdt.t and dmdt.rate) as JSON.

ParameterTypeDescription
save_pathstringWrite the full report as JSON to this file

impact

What a giant impact has left (3D runs with gravity, e.g. moon-forming-impact): the gas sorted by the Kepler orbit each cell is on about the densest body into the planet (pericenter inside it), the disk around it and what escapes, with each part’s mass, the share of it that is each species and the mean dye, the disk’s angular momentum, and the mass of the moon the disk would gather into. For 3D runs with gravity (the moon-forming-impact preset). Masses in code units (Earth masses in that preset); shares are mass fractions by species, and the mean dye, which tells the two bodies apart.

edit

Use one of the editing tools, as a person would with the pointer, applied now between steps and logged: mass (add or remove gas), velocity, temperature, obstacle (a shape in a plane of the box, cut through it along the plane normal), field (make the magnetic field stronger or weaker), pull (drag the field lines from one point to another), source, sink, star (3D), clear (the sources or the sinks), or query (the gas at a point). Positions are fractions of the box ([x, y] or [x, y, z]), velocities code units; the rest as the tool’s sliders take them. Unknown options are an error.

ParameterTypeDescription
name *string
optionsobject

session_log

The session log of the run: the setup it started from, and every edit since (the tools, settings changed, the adaptive mesh’s re-meshes), each with the step it was applied at, with the run’s diagnostics along the way. The page’s Save session log button saves the same. Returns a summary: the setup, whether it can be replayed, the actions by kind and the steps they span. save_path writes the full log as JSON, for replay.

ParameterTypeDescription
save_pathstringWrite the session log as JSON to this file

replay

Run a session log again: load the setup it started from, step to each action and apply it, re-meshing where it re-meshed, so the run comes out as it did (to the bit, on the same machine). Returns how many actions it applied, and where it stopped if the run went another way.

ParameterTypeDescription
path *stringThe session log file
untilStepsintegerStop at this many steps (default: after the last action)

errors

What the page has reported going wrong (uncaught errors, failed shader builds, a lost GPU device), oldest first.