How STEMSCAPE is modelled

STEMSCAPE is a browser game, but every number it shows is the output of a small engineering model running on your device. This page lists the equations, the parameter values, the simplifications we made and why. Parameter values are representative of rural and small-town India and are chosen for teaching consistency, not as a design reference — see Limitations.

Design of each mission is stored as a plain object; the simulation is a pure function simulate(design) → results, so re-running the same design always gives the same report. Random elements (grid outages, cloud cover) are generated from a fixed seed.

Mission 1 · Village Power

Site and demand

Kesarpur: 1,240 people in 260 households (26 house tiles × 10), a primary health clinic, a school and a well. Demand profiles are hourly shapes normalised to daily energy:

LoadDaily energyShape
Households1.6 kWh/household/day (416 kWh)Evening peak 18:00–21:00 (≈2.5× the night base)
Clinic30 kWh/dayNight base (vaccine fridge) + daytime activity
School15 kWh/day07:00–16:00 only
Well pump3 kW while runningDeferrable: prefers daylight, runs when the tank drops below 35%

Connectivity

Distribution lines, generation, batteries, the pump and the grid connection point are conductive tiles. Their 4-neighbour connected components are separate networks, each simulated independently. A house, the clinic or the school is attached to the network of any adjacent conductive tile; if none is adjacent it is unconnected and its entire demand counts as unserved.

Hourly dispatch (7 days × 24 h)

solar_kW(h) = P_solar × IRR(hod) × 0.80 × cloud(day) IRR peaks 0.98 at 12:00, ≈5.0 peak-sun-hours/day; cloud ∈ [0.65, 1.0] seeded wind_kW(h) = P_wind × CF(hod) × var(day) CF 0.18 (night) … 0.42 (afternoon), var ∈ [0.7, 1.3] load(h) = households + clinic + school + pump if renewables ≥ load: charge = min(surplus, 0.5C, (E_usable − SOC)/√η) ; SOC += charge·√η ; rest curtailed else: discharge = min(deficit, 0.5C, SOC·√η) ; then grid (≤ 40 kW, only when available) ; then diesel (≤ P_gen) ; rest unserved grid also charges the battery up to 60% SOC at night when it is up

Battery usable energy is 85% of nameplate (depth of discharge), round-trip efficiency 92% split equally between charge and discharge, and C-rate 0.5. Grid availability is a two-state Markov chain (P(up→down) = 0.09/h, P(down→up) = 0.13/h → ≈59% availability) from a fixed seed, so outages are identical between runs.

Water sub-model

Demand is 50 L/person/day (62,000 L) with a morning/evening shape. The pump delivers 12,000 L/h into storage (20,000 L per tank + a 2,000 L header). Each hour the pump runs for the fraction of the hour the tank can absorb; if the network cannot power it, pumping scales with the served fraction. Water reliability = delivered ÷ demanded.

Costs and emissions

ItemCapexNotes
Distribution line₹15,000 / tilePole + LV line
Solar array 5 kW₹2,00,000₹40/W installed, derating 0.80
Wind turbine 10 kW₹9,00,000Average capacity factor ≈ 0.28
Battery 10 kWh₹1,20,000₹12,000/kWh
Diesel generator 15 kW₹3,20,000₹26/kWh fuel, 0.78 kg CO₂/kWh
Grid import₹8/kWh, 0.71 kg CO₂/kWh (Indian grid average)
Well pump / tank₹1,20,000 / ₹90,0003 kW, 12,000 L/h / 20,000 L

Opex per year = diesel kWh × ₹26 + grid kWh × ₹8 + 1.5% of capex (maintenance). CO₂ is compared with a diesel-only baseline (all demand × 0.78 kg/kWh); credit is only given for energy actually served.

Mission 2 · Bridge Builder

Geometry and loads

A 24 m span with joints on a 2 m grid, y from −4 m to +6 m. The left abutment is a pin (u = v = 0), the right a roller (v = 0). The deck is the chain of deck-level joints (y = 0) from x = 0 to 24 with no panel longer than 6 m; deck stringers hand loads to the two bounding joints by the lever rule. The deck surface weighs 2 kN/m. The truck is 12 t (117.7 kN) on two axles 4 m apart, stepped across in 2 m increments (15 positions); every position is solved.

Solver

k_e = (EA/L) · [ c² cs −c² −cs ; cs s² −cs −s² ; −c² −cs c² cs ; −cs −s² cs s² ] K u = F (assembled, fixed DOFs removed, Gaussian elimination with partial pivoting) N_m = (EA/L) · [ (u_b − u_a)·c + (v_b − v_a)·s ] (+ tension) singular K (pivot < 10⁻¹⁰ · max diagonal) ⇒ mechanism ⇒ collapse

Self-weight of every member (ρ·A·L·g) is split between its end joints. The determinacy count m + r − 2j is reported; indeterminate trusses are solved by the same stiffness method.

Materials and capacity

Materialρ (kg/m³)σ allow tension / compressionEPriceSections
Steel tube7,850250 / 250 MPa200 GPa₹80/kg80, 120, 160 mm hollow square
Sal timber80014 / 11 MPa12 GPa₹35/kg100, 150, 200 mm solid
Bamboo bundle70025 / 18 MPa15 GPa₹12/kg3 or 6 culms Ø100 mm
Precast concrete2,5003 / 15 MPa27 GPa₹9/kg200, 300 mm solid
capacity_tension = σ_t · A capacity_compression = min( σ_c · A , P_cr = π² E I / L² ) (pin-ended Euler buckling) utilisation = |N| / capacity ; safety factor = 1 / max utilisation ; fail if any utilisation > 1 deflection limit = L/250 = 96 mm (max downward deck displacement over all truck positions)

Cost = Σ ρ·A·L·price + ₹4,000 per joint + ₹36,000 for the deck surface; budget ₹6 lakh.

Mission 3 · Clean Water

Dhaneri: 3,800 people × 40 L/day = 152,000 L/day. Source water: 85 NTU turbidity, 1,200 E. coli CFU/100 mL, 45 µg/L arsenic, 1.8 mg/L fluoride. Limits used: turbidity < 1 NTU, E. coli < 1/100 mL, arsenic < 10 µg/L, fluoride ≤ 1.5 mg/L (aligned with WHO guideline values).

Treatment train

Stages on the process lane are ordered by x-position (left → right). Repeated stages of the same type are parallel units (capacity adds, removal applies once). Removal is applied in series:

C_out = C_in × (1 − r) for turbidity, arsenic, fluoride N_out = N_in × 10^(−LRV) for bacteria (log removal value) capacity = min over stages ( units × unit capacity ) ; RO passes only 50% of its inflow (recovery)

Conditional performance (the part that teaches process order): slow sand filters receiving > 30 NTU clog (half capacity, 70% removal); rapid sand filters without upstream coagulation only remove 50% turbidity; chlorination and UV receiving > 5 NTU only achieve 1-log / 1.5-log because particles shield organisms; RO fouls above 5 NTU (half capacity). Without an intake screen the pump loses 30% capacity to clogging.

StageCapacity L/dayTurbidityE. coliAsFkWh/m³CapexOpex/yr
Intake pump240,0000.35₹1.8 L₹20 k
Intake screen400,0005%0₹40 k₹2 k
Coagulation + settling120,00085%0.5 log60%10%0.02₹2.6 L₹60 k
Slow sand filter60,00090%2.0 log10%0₹1.8 L₹15 k
Rapid sand filter200,00080%0.5 log0.05₹2.2 L₹30 k
Activated carbon150,00010%15%5%0.02₹1.5 L₹45 k
Activated alumina100,00050%90%0.02₹1.6 L₹55 k
Chlorination500,0003.0 log0.005₹60 k₹25 k
UV150,0004.0 log0.04₹1.4 L₹20 k
Reverse osmosis80,00099%4.0 log95%95%2.5₹4.5 L₹1.2 L

Storage: 50,000 L per tank; reliability = 0.6 + 0.4 × min(1, storage hours ÷ 12). Population served = 3,800 × min(1, capacity ÷ demand) × reliability, and only counts as safe if all four limits are met. Energy is bought from the grid at ₹9/kWh (0.71 kg CO₂/kWh); each 5 kW solar array offsets 20 kWh/day. Budget ₹18 lakh.

Mission 4 · Flood Defence

Storm and channel

Q(t) = 30 + (Q_peak − 30) · (t/24)⁴ · e^{4(1 − t/24)} m³/s, 0 ≤ t ≤ 72 h, Δt = 0.1 h Q_peak: 10-yr 180, 50-yr 300, 100-yr 380 m³/s Manning: Q = (1/n) · A · R^{2/3} · S^{1/2} channel 30 m × 3 m, n = 0.035, S = 0.0008 → bankfull ≈ 134 m³/s above bankfull: floodplain flow with n = 0.10 over 60 m (left) + 40 m (town side, removed by a levee)

Routing

Level-pool routing over a 1 km reach: dS/dt = I − O − spill, with S(h) the stage-storage of channel + floodplain (the town-side floodplain is removed when a levee exists — which is why a levee raises the river level, the "levee effect" the game reports). Detention basins (2.5 million m³ each) divert inflow above 250 m³/s until full.

levee overtopping: q = 1.7 · L · (h − max(crest, h_town))^{1.5} (broad-crested weir, per 100 m bank tile; gaps have crest 3.5 m) no levee: the town is hydraulically connected — its water level follows the river above 3.5 m town stage–storage: tiles fill lowest first; ground = 3.5 m + 0.25 m per tile away from the river drainage: 5 m³/s flap-gate outfall when the river is lower + pumps (10,000 m³/h, 0.3 kWh/m³)

Damage and risk

damage fraction f(d) = 0.05 + 0.20 · d^{0.8} (capped at 1), d = max flood depth at the asset, −1.5 m if elevated damage = Σ f(d) × asset value (house tile ₹1.6 cr, clinic ₹6 cr, school ₹4 cr, market ₹5 cr, substation ₹10 cr) expected annual damage ≈ ∫ D(p) dp over p = 0.2 → 0.1 → 0.02 → 0.01 (trapezoids) + D₁₀₀ × 0.01

All three storms are routed on every run; the selected storm drives the animation and the "damage avoided" sub-score, while residual risk uses the integral. Costs: levee ₹30k / ₹60k / ₹1 lakh per metre for 1 / 2 / 3 m (100 m per tile), basin ₹12 crore, dredging ₹40 lakh per tile (+1 m, whole reach required), widening ₹60 lakh per tile (+10 m), pump ₹80 lakh, elevating a house tile ₹25 lakh (assets ×3). Budget ₹40 crore.

Scoring, stars and badges

Each mission computes 5 sub-scores in [0, 1] from the simulation variables and combines them with fixed weights; the formula and every sub-score are printed in the report so nothing is hidden.

MissionWeightsPenalty
Village PowerReliability 30 · Population 20 · Cost 20 · Environment 20 · Water 10× 0.6 if over budget
Bridge BuilderSafety 35 · Deflection 20 · Cost 25 · Material efficiency 10 · Crossing 10× 0.5 on collapse
Clean WaterSafety 35 · Coverage 25 · Cost 20 · Energy 10 · Reliability 10× 0.6 if over budget
Flood DefenceDamage avoided 35 · Residual risk 25 · Cost 20 · People 10 · Pump energy 10× 0.6 if over budget

The cost sub-score is 1 − 0.6 × capex ÷ budget (0.4 at exactly the budget, 0 above it), scaled by how much of the population is actually served so that an empty design cannot score on frugality. Stars: ≥ 50 → 1, ≥ 70 → 2, ≥ 85 → 3. Missions unlock when the previous mission has at least one star; "Unlock all (free play)" bypasses this. Badges are derived from run results only (e.g. Zero diesel requires no generator energy and ≥ 90% reliability; Under budget requires a passing score).

Accessibility

  • The canvas is a focusable role="application": arrow keys move a tile cursor, Enter places, Delete removes, I inspects, digits pick palette items, R runs, Escape cancels. Tab reaches the palette, mode buttons, inspector, run button and report.
  • Every canvas change is announced in an aria-live status line and reflected in the "Placed components" text list; the world map has an equivalent mission list of buttons.
  • The report is plain text (downloadable and printable); charts are SVGs with a full-data aria-label; colour is never the only indicator (member failure is red and dashed and listed).
  • prefers-reduced-motion disables the animation loop: the scene is drawn once per change with a static day-time frame.
  • Text is in rem units, contrast ≥ 4.5:1 on all panels, visible focus rings, no keyboard traps (the tutorial is a native <dialog>).
  • On phones the palette becomes a bottom sheet; all controls remain reachable.

Limitations (honest list)

  • Parameter values are representative, not sourced from a specific tariff order, code or catalogue. Do not use STEMSCAPE outputs for real design.
  • Village Power ignores voltage drop, line losses, reactive power, generator minimum load, battery degradation and solar tilt; the grid is a simple capacity with random availability.
  • Bridge Builder is a pin-jointed 2D truss: no bending in members, no joint design, no lateral stability, no dynamic or fatigue effects; buckling uses pin-ended Euler with no effective-length factors.
  • Clean Water uses fixed removal efficiencies; real performance depends on dose, contact time, temperature, pH and maintenance. Fluoride and arsenic chemistry (As(III) vs As(V)) is not modelled.
  • Flood Defence is one-dimensional: a single reach, a lumped town stage–storage, no groundwater, seepage, levee breach or debris; the depth–damage curve is a single generic function.
  • Scores are a teaching device: the weights encode our priorities, not a regulatory or economic standard.

Data & privacy

No account, no analytics, no network calls except Google Fonts. Progress, designs, run history and the tutorial flag are stored in your browser under the localStorage key stemscape:v1; "Reset progress" on the world map removes it. The downloadable report is generated locally as a text file.