An educational simulation that demonstrates how the Three Mile Island Unit 2 (TMI-2) nuclear accident unfolded on March 28, 1979, and the critical role that instrumentation failure played in one of the most significant nuclear incidents in history.
- Installation
- What Was the Three Mile Island Accident?
- The Fatal Flaw: The Stuck PORV Valve
- How to Use the Simulation
- The Historical TMI-2 Timeline
- Scenario 1: ECCS Intervention (Successful Recovery)
- Scenario 2: Explosion Scenario (No Intervention)
- Key Physics & System Behaviors
- Educational Goals
- Tips for Effective Learning
Requirements: Python 3.12 or higher
pip install -r requirements.txt
python main.pyOn March 28, 1979, at 4:00 AM, a series of equipment failures and instrumentation errors at the Three Mile Island nuclear power plant in Pennsylvania led to a partial meltdown of the reactor core. While the containment structure prevented radioactive release to the environment, the accident exposed critical weaknesses in nuclear plant design and operator training.
The incident began with a routine maintenance issue but escalated into a crisis due to a deceptively simple problem: a stuck valve and a misleading indicator light.
At the heart of the TMI-2 accident was the Pilot-Operated Relief Valve (PORV) - a safety valve designed to release pressure when it builds up too high in the reactor cooling system.
- Initial Trigger: A minor malfunction caused pressure to spike in the primary cooling loop
- PORV Opens: The relief valve automatically opened to release excess pressure (as designed)
- The Critical Failure: The PORV became stuck open due to mechanical failure
- The Deceptive Indicator: The control room light showed the valve as "CLOSED"
- Coolant Loss: With the valve stuck open, radioactive coolant continuously drained from the reactor
- Operator Confusion: For over two hours, operators did not realize coolant was escaping
The indicator light only showed whether the signal to close the valve had been sent - not whether the valve had actually closed. This crucial design flaw meant operators believed the system was intact while thousands of gallons of coolant were being lost.
Without adequate coolant, the reactor core began to overheat. Nuclear fuel rods started melting, leading to a partial core meltdown.
After installation, the simulation window will open with:
- Left Side: Visual representation of the nuclear power plant with animated flow particles
- Right Side: Control panel with reactor systems, turbine systems, and scenario controls
The simulation shows three interconnected cooling loops:
Primary Loop (Red/Orange) - Radioactive coolant flowing through the reactor core
- Hot leg: Reactor → Steam Generator (bright red)
- Cold leg: Steam Generator → Reactor (blue)
- Contains the Reactor Coolant Pump (RCP)
- The Pressurizer maintains system pressure around 155 bar (2,250 psi)
- The PORV valve sits atop the pressurizer as a pressure relief mechanism
Secondary Loop (White/Steam) - Non-radioactive steam generation
- Heat from the primary loop is transferred to water in the Steam Generator
- This water boils into steam (without becoming radioactive)
- High-pressure steam drives the turbine to generate electricity
- The Feedwater Pump supplies fresh water to replace what becomes steam
Tertiary Loop (Blue) - Cooling water circulation
- Cooling water from a nearby river or cooling tower
- Condenses exhaust steam back into water
- Dissipates waste heat to the environment
- Reactor Core: Shows ONLINE/SHUTDOWN status with visual coolant level indicator
- RCP (Reactor Coolant Pump): ON/OFF control - circulates primary coolant
- Temperature: Real-time reactor temperature in °C (Normal: 315°C)
- Pressure: Primary loop pressure in bar (Normal: 155 bar)
- Coolant Level: Qualitative indicator (High/Normal/Low/Very Low) with visual blue layer in reactor
- PORV Valve: Manual control for pressure relief valve (CLOSED/OPEN)
- ECCS: Emergency Core Cooling System (STANDBY/ACTIVE)
- Main Turbine: Status indicator (RUNNING/STOPPED)
- Generator: Power output in MW
- Feedwater Pump: ON/OFF control - supplies water to steam generator
- RESET SIMULATION: Returns all systems to initial safe state
- STOP & CLOSE: Exits the simulation
- TMI Scenario: OFF/ACTIVE toggle for realistic accident simulation
- Time to Explosion: Adjustable slider (30-600 seconds) - controls full scenario timeline
- Live Countdown: Shows "PORV opens in Xs" during first 20%, then "Xs to explosion"
- Two-Phase Timeline:
- Phase 1 (First 20%): Pressure/temperature buildup before PORV opens
- Phase 2 (Remaining 80%): PORV stuck open, coolant drains, meltdown progresses
| Time | Event |
|---|---|
| 04:00 AM | Routine maintenance causes feedwater pumps to stop |
| 04:00:36 | Reactor automatically trips (emergency shutdown begins) |
| 04:00:37 | PORV opens due to pressure spike from stopped pumps |
| 04:00:39 | PORV receives signal to close, indicator light shows "CLOSED" |
| 04:00:39+ | CRITICAL FAILURE: PORV mechanically stuck OPEN, but operators believe it's closed |
| 04:00-06:00 | ~2 hours of undetected coolant loss through stuck-open PORV |
| 06:00-07:00 | Operators realize pressure is dropping abnormally |
| ~06:30 | Top of reactor core becomes exposed to steam |
| ~07:00 | Fuel rods begin to fail - partial meltdown begins |
| ~13:00 | Operators finally close the backup valve, stopping coolant loss |
| Damage done: 30-40% of core melted |
- Instrumentation Ambiguity: The PORV indicator only showed the command sent to the valve, not its actual position
- Operator Training: Operators were not trained to recognize this specific failure mode
- Conflicting Indicators: Multiple alarms and confusing readings delayed correct diagnosis
- Design Flaw: No direct measurement of PORV valve position
Just like the actual TMI-2 operators, you face a challenging situation:
- The PORV indicator falsely shows the valve is closed
- Multiple alarms and warnings create confusion
- The true problem is not immediately obvious
- You must recognize the pattern: falling pressure + rising temperature + dropping coolant level = coolant loss
- You must act quickly by activating the Emergency Core Cooling System (ECCS) before irreversible damage occurs
Demonstrate how activating the Emergency Core Cooling System can prevent meltdown during the PORV failure.
YES! The reactor CAN be saved if ECCS is activated before meltdown reaches 70%:
✅ Meltdown < 70%: ECCS reverses damage at -0.5% per frame ✅ Temperature < 500°C + Meltdown = 0%: Reactor is fully saved ❌ Meltdown ≥ 70%: Point of no return - ECCS can slow but not reverse
-
Launch the simulation - all systems start at normal operating conditions
-
Activate TMI Scenario:
- Click the "TMI Scenario" button to turn it ACTIVE
- Note: PORV indicator shows "CLOSED" (false reading)
- The valve is actually stuck OPEN and coolant is escaping
-
Observe the Crisis Developing:
- Pressure: Begins dropping from 155 bar → ~50-80 bar
- Temperature: Starts rising from 300°C → 600°C+
- Coolant Level: Drops from 100% → critical levels (<30%)
- Flow particles slow down or stop in affected areas
-
Recognize the Problem:
- Despite PORV showing "CLOSED", you see:
- Falling pressure
- Rising temperature
- Dropping coolant level
- This pattern indicates coolant loss!
- Despite PORV showing "CLOSED", you see:
-
Emergency Response - Activate ECCS:
- Click the ECCS button to activate emergency cooling
- Watch the system respond:
- Coolant Level: Rapidly increases (0.8% per frame)
- Pressure: Begins stabilizing and rising
- Temperature: Drops rapidly (15°C per frame)
- If activated early enough, meltdown progress reverses
✅ ECCS activated before coolant level reaches 20% ✅ Temperature kept below 800°C ✅ Meltdown progress remains below 70%
If these conditions are met, the reactor will stabilize and avoid catastrophic failure.
- Best Practice: Activate ECCS when coolant drops to 60-70%
- Critical Window: Must activate before temperature exceeds 800°C
- Point of No Return: If meltdown progress exceeds 70%, ECCS may be too late
Demonstrate the catastrophic consequences when the PORV failure goes undetected and untreated.
-
Launch the simulation
-
Configure explosion timing (optional):
- Adjust the "Time to Explosion" slider (30-600 seconds)
- Default: 180 seconds (3 minutes)
- Shorter times simulate faster meltdown progression
-
Activate TMI Scenario:
- Click "TMI Scenario" button to ACTIVE
- Timer begins counting toward explosion
-
Observe Without Intervention:
- Do NOT activate ECCS
- Do NOT close any valves
- Simply watch the cascade of failures
The TMI scenario follows a historically accurate two-phase timeline based on actual TMI-2 accident data.
This phase simulates the initial pressure transient that triggered the PORV to open.
- Pressure: Gradually increases from 155 bar → 162 bar (PORV setpoint)
- Temperature: Rises from 315°C (600°F) → 343°C (650°F)
- Coolant Level: Remains at 100% (no loss yet)
- PORV Status: Mechanically CLOSED (building toward opening)
- Countdown: Shows "PORV opens in Xs"
Historical Accuracy: Real TMI-2 operators saw pressure climb from normal ~155 bar to ~162 bar, triggering the PORV to open. Temperature rose from ~315°C to ~343°C during this buildup phase.
At exactly 20% of the configured timeline, the PORV opens and becomes stuck.
Immediate PORV Opening (at 20% mark):
- PORV mechanically opens due to pressure exceeding setpoint
- CRITICAL FAILURE: PORV gets stuck in OPEN position
- Control panel indicator falsely shows "CLOSED" (the deception!)
- Coolant begins draining through the stuck-open valve
- Countdown changes to "Xs to explosion"
Progressive Coolant Loss:
- Coolant drains from 100% → 30% over the remaining timeline
- Coolant loss rate calibrated to match configured "Time to Explosion"
- Visual blue coolant layer drains visibly in reactor diagram
- Coolant level indicator: High → Normal → Low → Very Low
Pressure Behavior:
- Initial drop from 162 bar → ~50 bar as steam escapes
- Then gradual rise back to ~162 bar as core overheats and generates more steam
Temperature Escalation:
- Continues rising from 343°C → 1200°C over remaining timeline
- Rate increases as coolant drops below critical thresholds
- Temperature display turns ORANGE (>500°C) then RED (>800°C)
Meltdown Progression:
- Begins when coolant <30% AND temperature >600°C
- Progress increases gradually based on elapsed time
- Visual meltdown effects intensify (cracks, glow, particles)
- Capped at 90% until final explosion timer
When the configured "Time to Explosion" is reached:
- Explosion Sequence Starts: Meltdown progress forced to 95%
- 3-Second Animation: Dramatic visual explosion with multiple pulsing layers
- Expanding fireball with rotating debris
- Fire tongues shooting outward
- Energy sparks and screen flashes
- Progressive fade-out in final 0.7 seconds
- Complete Shutdown: After 3 seconds, explosion ends
- Destroyed Reactor: Shows catastrophic damage with breach, smoke, and debris
The simulation includes a realistic visual coolant indicator inside the reactor vessel:
- Light Blue Transparent Layer: Fills from bottom up based on coolant percentage
- Animated Waves: Subtle surface waves when coolant is not at 100%
- Color Gradients: Changes from bright cyan (high coolant) to darker blue (low coolant)
- Real-time Updates: Drains visibly during PORV failure, refills with ECCS activation
- Semi-Transparent: Can see the glowing reactor core through the coolant layer
In the TMI scenario, the PORV valve demonstrates the critical instrumentation failure:
- Control Panel Button: Always shows "CLOSED" during TMI scenario (false reading)
- Visual Valve in Diagram: Shows actual PORV state (opens at 20% mark)
- This Discrepancy: Simulates the exact confusion faced by TMI-2 operators
The 3-second explosion sequence features:
- Multi-layer Effects: Smoke, fire, yellow core, white-hot center
- Rotating Debris: 8 debris particles spinning outward
- Fire Tongues: 12 dynamic flame projections
- Energy Sparks: 20 sparks shooting from the core with trails
- Screen Flashes: Periodic intense flashes for dramatic effect
- Progressive Fade: Smooth fade-out in final 0.7 seconds
- Destroyed State: Post-explosion shows catastrophic damage with breach and smoke
The simulation is highly configurable via config.json:
- Component positions and sizes
- Flow paths and pipe routing
- Particle counts, speeds, and colors
- Initial system parameters
- Visual settings
The reactor physics are calibrated to match real TMI-2 accident behavior:
- Temperature: 315°C (PWR operating temperature)
- Pressure: 155 bar (~2,250 psi)
- Coolant Level: 100%
- Power Level: 100%
- Pressure Buildup: 155 bar → 162 bar (PORV setpoint)
- Temperature Rise: 315°C → 343°C
- Coolant Level: Remains at 100% (no loss)
- Duration: 20% of configured "Time to Explosion"
- Coolant Loss Rate: Calibrated to drain 70% over remaining timeline
- Formula:
70.0 / (remaining_time * 60)% per frame - Example: 180s total → 144s remaining → 0.0081% per frame
- Formula:
- Pressure Behavior:
- Initial drop to ~50 bar when PORV opens
- Gradual rise to ~162 bar as core overheats
- Temperature Escalation: 343°C → 1200°C over remaining timeline
- Meltdown Progress: Timer-controlled, capped at 90% until explosion
- ECCS Cooling Rate: 15°C per frame (rapid emergency cooling)
- ECCS Water Injection: 0.8% coolant per frame
- ECCS Pressure Restoration: +3 bar per frame when coolant >50%
- Meltdown Reversal: -0.5% per frame if activated before 70% meltdown
- Normal Meltdown: Explosion at 95% meltdown progress
- TMI Scenario: Time-based explosion at configured duration
- Animation Duration: Exactly 3 seconds
- Post-Explosion: Complete shutdown, destroyed reactor visual
sensor_lehre_tmi_simulation/
├── main.py # Entry point, UI, control logic
├── config.json # All visual and system configuration
├── models/
│ ├── reactor.py # Reactor core physics and behavior
│ ├── pump.py # Pump models
│ ├── turbine.py # Turbine model
│ └── flow_particle.py # Particle animation
├── renderers/
│ ├── reactor_renderer.py # Reactor visual rendering
│ ├── pump_renderer.py # Pump visual rendering
│ └── ... # Other rendering components
└── README.md # This comprehensive guide
