Science Sim Author
by @dimgouso
Generate self-contained interactive science simulations as a single index.html from a SimSpec YAML or JSON. Use when the user asks for physics, chemistry, bi...
clawhub install science-sim-authorπ About This Skill
name: science-sim-author description: Generate self-contained interactive science simulations as a single index.html from a SimSpec YAML or JSON. Use when the user asks for physics, chemistry, biology, STEM, science education, classroom demos, virtual labs, PhET-style activities, mechanics simulations, circuit simulations, parameter sliders, plots, inquiry worksheets, or offline canvas-based teaching tools. metadata: {"openclaw":{"emoji":"π§ͺ","requires":{"bins":[],"env":[],"config":[]},"os":["darwin","linux","win32"]}}
Science Simulation Author
Core promise
Generate one self-contained index.html that runs offline, renders a STEM simulation on a 2D canvas, exposes model parameters as sliders, plots a time series, and includes an inquiry worksheet.
Inputs
Accept a SimSpec in YAML or JSON with:
id, title, domainstate, params, initial, equations, outputslevel, dt, worksheet, success_criteriaValidate against templates/sim_spec_schema.json before generating anything.
Output contract
index.html. and all JS in .simCanvas, plotCanvas, runToggle, stepBtn, resetBtn, dtSlider, paramControls, readouts, statusBanner, worksheet, copyJsonBtn, downloadCsvBtn.Workflow
1. Validate the incoming SimSpec against templates/sim_spec_schema.json.
2. Normalize the spec:
- If dt is missing, use default=0.01, min=0.001, max=0.05.
- If a parameter omits step, derive step=(max-min)/100 with sensible rounding.
- Normalize derivative aliases such as dx, dy, dvx, dvy, dq, dvc to canonical d keys before generating JS.
- Default readouts to t plus every state variable in state order.
3. Choose the renderer:
- mechanics + state includes x and y -> trajectory2d
- mechanics + state includes x and v -> oscillator1d
- electromagnetism + state includes q or vc -> circuit_rc
- Otherwise stop and ask the user for a clearer SimSpec instead of guessing.
4. Populate templates/sim_single_file_html_template.html with pre-normalized values.
5. Run rubrics/validation_checklist.md before returning the final index.html.
Template placeholders
Populate these mustache variables:
sim_id, sim_title, domain, level, renderer_kindstate_json, params_json, initial_json, equations_json, outputs_jsonworksheet_json, success_criteria_json, readout_fields_jsondt_default, dt_min, dt_maxmodel_step_logic_js, scene_draw_js, readout_map_jsExpectations:
model_step_logic_js must return a derivative object without using eval or Function.scene_draw_js and readout_map_js may be no-ops; use return []; for an empty readout override.Rendering and model rules
requestAnimationFrame.NaN or Infinity.outputs; if multiple plots are supplied, use the first one for the visible plot and keep the rest only as metadata.Worksheet rules
Safety rules
Apply rubrics/security_notes.md strictly.