Omniadisce

What a simulation is

A simulation is a problem post with a 3D scene in it: a rocket on a rail, a ball and a target, a drone in the wind. The reader changes one or two values, presses Run, and watches what happens. When they press Check answer, the server runs the scene again with their values and tests it against your checks, so nobody can fake a pass.

WordWhat it isExample
SceneEverything in the 3D world: bodies, forces, joints, fluids, wind, ground.A ball launched at 15 m/s, a target 20 m away
KnobA number in the scene the reader may change, with a slider range.Launch angle, 0ยฐ to 90ยฐ
SolutionYour own knob settings that solve it. Readers see them only after they answer or reveal.Angle 30.4ยฐ
CheckA measurement of the run and the range it must fall in.The ball's horizontal distance when it first touches the ground is between 19.5 and 20.5 m

A simulation is for things that move in space: falling, sliding, flying, floating, colliding. For a number that changes over time with no 3D picture (cooling, populations, savings), a model lab is simpler.

Your first simulation

Open New post โ†’ Problem โ†’ 3D simulation. The fastest way in is to start from a template and change it.

  1. Load a template. Pick one from the Template list (projectile, incline, collision, putt, drones, barge, dam break and more) and press Load template. It fills in the scene, the answer and the checks.
  2. Run it. โ–ถ Run starting setup shows what the reader sees first. โ–ถ Run solution shows your answer. Use the speed buttons and Follow to watch closely.
  3. Change the scene. In 1 ยท Scene, pick a body on the left and edit it on the right: size, mass, material, starting speed. ๏ผ‹ Add adds a body, a force, a knob or anything else.
  4. Choose what readers change. Keep one or two knobs. Set their ranges and starting values.
  5. Choose how they answer. In 2 ยท Answer mode: they adjust the knobs, or they pick one of several choices.
  6. Set the checks. In 3 ยท Checks, press โœจ Suggest checks from solution, then widen the ranges so every correct answer passes.
  7. Verify. Press โœ“ Verify. Your solution must pass and the starting setup must fail.
  8. Write the problem. Title, the situation, the question, a worked solution and hints, as for any problem. Then publish.

Publishing runs Verify again on the server. A simulation whose starting setup already passes, or whose solution fails, won't publish.

The scene

The ๐Ÿงฉ Visual editor lists the scene on the left, with each force and joint under the body it acts on. Whatever you pick is edited on the right. { } JSON shows the same scene as text, for copying or for precise edits; press Apply scene after editing it.

Bodies

Boxes, spheres, cylinders and capsules. Give each an id: checks and knobs use it. A material (steel, wood, rubber, foamโ€ฆ) works out the mass for you. A body can be fixed, like a wall or a ramp.

Behaviours

Extra forces on a body: thrust, a steady force or torque, air drag, a spring, a heater, or a whole drone with its own flight controller. They can switch on or off when something happens, e.g. light the engine below 240 m.

Joints

A hinge or a point that holds two bodies together, or a body to the world: a pendulum, a door, a flywheel on its axle.

World

Gravity, the ground's friction, wind and gusts, the air at altitude, hills, rain, snow and fog. See below.

Keep it small. Every body and force is one more thing the reader has to understand. If a body doesn't affect the answer, leave it out.

Knobs: what readers change

A knob points at one number in the scene and gives it a slider. In the visual editor, pick ๏ผ‹ Add โ†’ Knob and fill in:

FieldWhat to put
Shown to solvers asThe name on the slider: "Launch angle".
ControlsThe number it changes, e.g. the ball's launch angle or the engine's thrust.
Minimum, Maximum, StepThe slider's range. Keep it realistic: a thrust of 0 to 10,000 N invites guessing.
UnitShown beside the value: ยฐ, m/s, N.
Starting valueWhere the slider starts. It must not solve the problem.
  • One or two knobs. With one, the reader can reason it out. With three or more, they start guessing.
  • The answer should be inside the range, but not at an end. If it's at the maximum, the reader just drags the slider all the way.

Two ways to answer

ModeThe readerโ€ฆYou giveโ€ฆGood for
Solvers adjust the knobssets the sliders and checks their own settingsyour solution settings"find the angle", "how much thrust", "what spring stiffness"
Multiple choicepicks one of a few choices, each of which sets the knobsthe choices; the ones that pass the checks are correct"which change keeps it upright?", "which site is safe?"

Let solvers run the simulation freely before answering is on by default. Turn it off for "predict first" questions, like Which ball lands first?: the reader has to think it through, and sees the run only after they answer.

A multiple-choice question can also do without checks: tick the right choice yourself and say why each wrong one is wrong. Use this for "what happens ifโ€ฆ" questions that the simulation shows rather than measures.

Checks: what counts as right

A check picks a body, a measurement, when to read it and a range. All checks must pass.

What to measure

Position, height above ground, speed, tilt, rotation, distance from start, distance between two bodies, impact speed, whether it touched something or broke. With water: draft, buoyancy, how much is under water. With heat: temperature.

When

Max or Min over the run, Final, At t = a moment, Mean, Change from start to end, or At first contact, the moment it lands or hits.

Range

A minimum, a maximum or both. "Tilt Max โ‰ค 10ยฐ" means it never tips more than 10ยฐ. "Horizontal distance from start, At first contact with the ground, between 19.5 and 20.5 m" means it lands on the target.

โœจ Suggest checks from solution compares your solution's run with the starting run and proposes checks on what differs. It's a starting point: read each one, delete what doesn't matter and widen the ranges.

Leave room for other right answers. If your solution lands at 20.03 m and the check says 20.02 to 20.04 m, a reader with the right idea and a slightly different angle fails. Allow what a careful hand calculation would give.

Why: the check should test the idea, not whether the reader found your exact number.

The words around it

The simulation is the experiment; the post still needs the story. Write these as for any problem post:

  • The situation, with the numbers that matter: "A ball is launched at 15 m/s toward a target 20 m away." Maths goes between $โ€ฆ$.
  • The question, in one sentence the checks answer: "At what angle must it be launched to land on the target?"
  • The worked solution: the hand calculation, then what the simulation shows. Say how wide the accepted range is.
  • Hints, from gentle to direct: what to watch first, then which equation.

A good simulation problem can be worked out on paper, and the run confirms it. If the only way to solve it is to drag the slider until it passes, readers learn very little.

Air, water, heat and weather

Most problems need only bodies, gravity and friction. The rest is there when the physics calls for it; the scene reference below gives every setting.

AddWhat it doesTemplate to copy
Air dragAn aero behaviour with a drag coefficient (sphere, cube, rocketโ€ฆ)Rocket stability
Wind, gusts, turbulenceThe same wind every run, for the same seedDrone in gusty wind
Altitude and heatThinner air higher up and on hot daysHot and high
Liquids and gasesBuoyancy and drag: hulls float, balloons riseBarge, helium balloon
Draining and pipesTanks empty through holes; pipes carry flowDraining tank, sap in a tree
HeatBodies warm and cool by contact, air and radiationCalorimetry
Hills and weatherTerrain, and rain or snow that make the ground slipperySnowy landing sites
DronesA body that flies itself to a point, follows another, or lands on a padDrone pad landing, swarm

What readers see

  • The question, the list of checks their setup must satisfy, and the 3D view, which they can orbit, zoom and replay.
  • Sliders for your knobs, โ–ถ Run simulation and โ†บ Reset settings (or the choices, in multiple choice).
  • Check answer. Their first real answer is the one that counts for the problem's solve rate; they can keep trying afterwards. Checking the untouched starting setup doesn't use it up.
  • Hints, one at a time, and Reveal the solution, which loads your settings into the scene so they can run it.

When something's wrong

Verify saysWhat it meansFix
The starting setup already passesReaders would be done before they start.Move the knob's starting value away from the answer, or tighten a check.
Your solution fails a checkYour own answer doesn't pass.Run the solution and read the measured values; widen the range or change the solution.
No choice passes / every choice passesMultiple choice needs at least one right and one wrong.Change a choice's values, or adjust the checks.
Unknown body or pathA check or knob names something that was renamed or deleted.Pick the body or value again in the visual editor.
It looks wrong when it runsOften a mass, a unit or a sign: thrust pointing down, an angle in the wrong direction.Run at 0.25ร— with Follow on and watch the first second.

Using your simulation

  • As a problem: it appears in the feed and under Simulations in search.
  • In a lesson: add a Try it step and search for the simulation. Solving it, or revealing the solution, completes the step. See the lesson guide.
  • In a course: add it as an item; it counts as practice. See the course guide.

Log in to build a simulation

Scene reference

Every setting a scene can use, with its JSON. In the visual editor you set the same things with fields; the JSON is what { } JSON shows. Lengths are in metres, speeds in m/s, forces in N and temperatures in ยฐC.

The scene's parts

A scene is JSON with bodies (box, sphere, cylinder, capsule), behaviours (extra forces: thrust, force, torque, aero, attitude_hold, spring, drone, heater), joints (hinge, point), fluids (liquids and gases), junctions and pipes, heat, materials, world and knobs.

A knob's path points at the number it changes, e.g. "behaviours.engine.magnitude" or "bodies.ball.launch.elevation_deg", with min, max, step, unit and its starting value, default.

Materials

Give a body "material": "steel" and its mass is worked out (density ร— volume) unless you give one. Solids: steel, aluminium, copper, lead, glass, concrete, granite, wood, plastic, rubber, foam.

Make your own under "materials" with "phase": "solid", a density, cp (J/(kgยทK)), conductivity (W/(mยทK)) and emissivity.

Heat

"heat": {"ambient": 20, "time_scale": 60} gives every body a temperature (ยฐC). "hold_temperature": true keeps a body at its temperature, like a hot plate.

  • Heat flows by conduction where bodies touch each other or the ground, by convection to the fluids around them (faster in a flow), and by radiation to the surroundings. Switch any of them off, e.g. "effects": {"radiation": false}.
  • time_scale runs heat faster than the motion, so minutes of warming fit in a short run.
  • A fluid region with "warms": true heats up with what it takes in (a calorimeter).
  • A heater behaviour puts in power watts (negative cools), with an optional thermostat target. A behaviour can start or stop when a body's temperature crosses a value.
  • Measure temperature and heat taken in. A body has one temperature all through, and nothing melts or boils.

Liquids and gases

"fluids": [{"id": "pool", "material": "sea_water", "temperature": 15, "level": 2, "bottom": 0, "min": [-8, -6], "max": [8, 6]}] fills a basin up to the surface at level.

  • Liquids: water, sea_water, ethanol, oil, glycerol, honey, mercury. Gases: air, helium, hydrogen, carbon_dioxide. A gas fills a box the same way, or the whole scene with "everywhere": true.
  • Each fluid works out its density and viscosity from the region's temperature and, for gases, its pressure (Pa, at the top).
  • Make your own under "materials": {"id": "syrup", "phase": "liquid", "density": 1300, "viscosity": 2.5}, or a gas with a molar_mass (g/mol).
  • "flow": [0.5, 0, 0] adds a current or a wind.
  • Bodies feel buoyancy where they are in the fluid, so hulls right themselves or capsize and balloons rise, and drag that grows with viscosity at low speed. A body's fluid_cd sets its drag at high speed. Switch an effect off with "effects": {"drag": false}. A body with its own aero behaviour keeps it, and gases then only lift it.
  • A basin has no walls: add fixed bodies for them.
  • Measure draft, share in the fluid, buoyant force, fluid pressure, Reynolds number and the fluid's density, viscosity, temperature and flow speed. A small fixed zone (ghost) works as a pressure probe at a point.

Draining and filling

Give a liquid in a box "outlets": [{"side": "+x", "height": 0, "diameter": 0.02}] and it drains at Torricelli's speed โˆš(2 g h) (outlet_cd is 0.61 for a sharp-edged hole), or "inflow": 2 (L/s) to fill it. "time_scale": 60 makes the level change faster.

Measure a region's level, volume and outflow: a check on those names the region instead of a body.

How a fluid is computed

  • "model": "uniform", the default, gives the exact numbers checks rely on.
  • "particles" turns a liquid in a box into a few hundred particles that pour and splash along its floor ("spread_to": [0, 3]), round the bodies in their way. A body the water reaches touches the region, so first touches checks time a wave.
  • "flow_field" shows the flow around the bodies on a slice (slice_height), computed live in the browser. It's for looks, with its Reynolds number in the readout.

Pipes

"junctions" (points, some held at a pressure in Pa) and "pipes" between them (radius, length) carry a fluid ("network": {"material": "water"}) by Poiseuille's law, downhill too. Measure a pipe's flow, its share of the network's flow, its speed and Reynolds number.

Drag, wind and friction

  • Drag: give a body an aero behaviour with a drag coefficient cd, a number or a preset: sphere 0.47, half_sphere 0.42, cone 0.50, cube 1.05, angled_cube 0.80, long_cylinder 0.82, short_cylinder 1.15, flat_plate 1.28, streamlined 0.04, streamlined_half 0.09, model_rocket 0.75, quadcopter 1.0.
  • Wind: "world": {"wind": {"velocity": [6, 0, 0], "gust": 4, "gust_period": 2, "seed": 1}} is a steady wind plus gusts of up to gust m/s that change about every gust_period seconds. Wind pushes bodies through their aero behaviour (drag acts on the speed relative to the air). Gusts look random but follow seed, so every run meets the same wind; change the seed for a different pattern.
  • Rolling resistance: a body's rolling_friction is the rolling resistance coefficient: about 0.001 for steel on rail, 0.01 for a tyre on asphalt, 0.05 to 0.1 for a ball on grass or carpet. "rolling_start": true starts a ball or wheel rolling rather than skidding; its spin then follows its velocity, also when a knob changes the speed.
  • Sliding friction is friction on the body and ground_friction on the world.

Turbulence and wind shear

Add to the wind "turbulence": 2 (the standard deviation of the air speed in m/s; about 10 to 20% of the wind speed outdoors) and "turbulence_scale": 30 (the size of the largest eddies in m). Turbulent air varies from place to place as well as over time, and also follows the seed.

"shear_exponent": 0.2 with "reference_height": 10 makes the wind stronger with height: velocity is then the wind at the reference height. The exponent is about 0.1 over water, 0.15 to 0.25 over open country and 0.3 to 0.4 among buildings.

Atmosphere

"world": {"atmosphere": {"site_altitude": 1600, "temperature": 30}} works out the air density from the standard atmosphere and the ideal gas law: thinner higher up and on hot days. The temperature defaults to the standard one for the altitude. It replaces air_density.

Give a thrust "density_scaled": true for propellers and rotors, whose thrust falls with the air density; its magnitude is then the rating in sea-level air.

Drones and swarms

A drone behaviour turns a body into a multirotor with its own flight controller: {"type": "drone", "body": "d1", "target": [0, 5, 0]} flies to a point (without a target it holds where it starts), and "follow": "leader", "offset": [-2, 0, 0] keeps station on another body.

  • Optional: max_thrust (N; falls in thin air unless "density_scaled": false), max_speed (default 4 m/s), max_tilt_deg (default 30), the position gains kp_pos and kd_pos, the attitude gains kp_att and kd_att, max_torque (worked out from the body when left out), and drag cd, area, cp_offset.
  • Give the body "visual": "drone" to draw rotors.
  • Drones keep apart with "world": {"swarm": {"separation_radius": 2.5, "separation_gain": 8}}: within the radius of another drone they brake, steer away and veer right. Check spacing with the distance to the nearest other moving body measure.

Takeoff and landing

Any behaviour can wait for a condition: "start_when": {"body": "lander", "metric": "height", "below": 240} lights an engine below 240 m, and "stop_when": {"body": "lander", "metric": "vy", "above": -0.2} shuts it once the lander stops descending. The metrics are height, y, vy, speed and tilt_deg; each switches once.

A drone with "land_at": [x, z] flies over the spot, comes straight down at max_vertical_speed and cuts its motors at touchdown. Check the touchdown with impact speed or at first contact.

Damage

Give a body "max_impact_speed": 3: a collision closing faster than that breaks it, every behaviour on it stops (engines, motors, controllers) and it turns dark red. Check it with the broken (1) or intact (0) measure (maximum โ‰ค 0 means it never breaks) or the impact speed measure.

Terrain

"world": {"terrain": {"seed": 3, "size": 120, "resolution": 64, "height": 10, "scale": 40, "roughness": 0.5, "pads": [{"x": 0, "z": 0, "radius": 4}]}} replaces the flat ground with hills about scale metres across and up to about ยฑheight metres high, the same every time for the same seed. Pads are levelled at their y (by default the natural height there). Heights measured above the ground follow the terrain.

Weather

"world": {"weather": {"type": "fog", "intensity": 0.8}}, with rain, snow, fog or storm. Besides what you see, it changes what weather really changes at these scales: wet and snowy ground grips less (heavy snow about 30% of dry), and visibility (down to 5 m in thick fog) limits how far a lidar sees. For storm winds, add wind.

Lidar navigation

Give a drone "avoid": {"range": 10, "rays": 36, "gain": 8}: a level fan of range-finder beams (updated rate times a second, with noise in m) steers it round anything it sees within its range or the visibility, whichever is shorter. The beams are drawn during a run, red where they hit.

× Enlarged view