Interactive 2026 F1 Engineering & Strategy Analysis Tool
F1LapForge is an open‑source, physics‑based simulation workbench for exploring 2026 Formula 1 car performance — with a strong focus on energy recovery system (ERS) deployment & harvesting strategies, power unit output, aerodynamics, tyre behaviour, and driver style under realistic FIA regulations.
It’s built for race engineers, sim racers, strategy analysts, and F1 enthusiasts who want to understand why one setup is faster than another, not just see a lap time.
Everything important is editable directly in the UI:
- Race / circuit selection
- Circuits and segment definitions come from
tracks_2026.yaml(e.g., China, Australia).
- Circuits and segment definitions come from
- Constructor selection
- Generic baseline plus team‑specific overrides (Mercedes, Ferrari, RedBullFord, etc.).
- Strategy selection
- Driving / ERS styles (
aggressive,balanced,conservative, andauto_optimizerif enabled in config).
- Driving / ERS styles (
- Powertrain
- ICE power and total PU power (
ice_power_kw,total_pu_kw).
- ICE power and total PU power (
- ERS parameters
- Battery capacity (
SOC_max_MJ), MGU‑K max power (P_K_max_kW), deploy & harvest efficiency, thermal duty threshold, per‑lap harvest limit, SOC floor penalty threshold.
- Battery capacity (
- Chassis
- Mass, drag coefficients, downforce coefficients, reference area, DRS reduction.
- Tyres
- Compound‑specific grip multipliers (soft / medium) and optional friction coefficients.
- Driver style
- Trail‑brake factor and related driving parameters.
- Environment
- Air temperature, track temperature, wind speed per race.
Changes are made against a single backing YAML config (config_runtime.yaml), so you can always export / version your setups.
-
Live Preview toggle
When enabled, the app will automatically re‑run the simulation whenever key configuration parameters change (with basic debouncing so you don’t spam runs). -
Run Simulation button
Executes a high‑fidelity single‑lap simulation using the current settings, logs tosimulation_log.txt, and updates all result views.
Shows a high‑level view suitable for quick engineering decisions:
- Summary metrics
- Total lap time
- Final battery SOC
- Total energy harvested per lap
- Segment‑by‑segment breakdown table
- For each segment: time, exit speed, throttle %, brake %, SOC, MGU‑K deploy power, and harvest power.
- Consolidated multi‑axis telemetry chart
- Single Plotly chart with:
- Speed vs distance (primary y‑axis)
- MGU‑K deploy and harvest power vs distance (secondary y‑axis)
- SOC vs distance (secondary y‑axis)
- Hover‑synchronised and rendered directly in Streamlit (no external HTML files).
- Single Plotly chart with:
More detailed look at the telemetry, split into four interactive Plotly charts:
- Speed profile
Speed vs distance. - MGU‑K deploy & harvest power
Deploy power and harvest power traces. - Battery SOC
SOC (MJ) vs distance. - Throttle & brake pedal
Throttle % and brake % vs distance.
- Live viewer for
simulation_log.txtwith a Refresh Logs button. - Includes:
- High‑level run events (config loads, constructor/strategy used).
simulate_lapprogress and per‑segment timing.- Diagnostics from config merge and validation (e.g., warnings when critical sections are missing).
- Save the current configuration to a YAML preset file.
- Load any preset back into the app from the sidebar.
- Useful for:
- Comparing different strategies or constructors.
- Keeping “reference” real‑world runs (e.g., tuned to a specific quali lap).
- Built‑in config validation checks:
- Runtime section & default constructor existence.
- ERS constraints (SOC, MGU‑K power, efficiencies, duty threshold, per‑lap harvest).
- Basic environment sanity ranges (air / track temperature).
- Invalid configurations are rejected with clear error messages before the physics engine runs.
Implemented in model/core.py:
- Tyre grip
- Base grip per compound from config, adjusted for track temperature offset and simple warm‑up model.
- Drag & downforce
- Drag is quadratic in speed with DRS effects on straights.
- Downforce / friction circle limits maximum corner speed using tyre lateral μ and corner radius.
- ERS deploy / harvest
- MGU‑K deploy power capped by both
P_K_max_kWand available SOC. - Speed‑derated deploy at high velocities (realistic 290–340 km/h taper).
- Harvest model triggered by braking and corner types, limited by efficiency and power caps.
- MGU‑K deploy power capped by both
- Thermal fade
- When cumulative deploy exceeds a duty threshold, effective power fades towards a floor.
- SOC floor penalty
- If SOC drops below a strategy‑specific floor, a time penalty is added to simulate lift‑and‑coast / compromised lines.
All of this is integrated with a simple Euler scheme over each track segment.
Implemented in model/optimization.py:
- Uses
scipy.optimize.minimizewith L‑BFGS‑B to tune:deploy_factor_baseharvest_factor_base
- Bounds for both are taken from the
auto_optimizerentry in the strategies section of the runtime config. - Objective:
- Minimise lap time plus a penalty if final SOC falls below the strategy’s SOC floor threshold.
- The resulting optimal strategy is passed back into
simulate_lapfor a final “best lap” and full telemetry.
F1LapForge/
├── app.py # Main Streamlit entry point + tabs
├── config_runtime.yaml # Default vehicle, ERS, strategy config
├── tracks_2026.yaml # Circuit segment data
├── model/
│ ├── core.py # Physics engine (segment_dynamics + simulate_lap)
│ └── optimization.py # Gradient-based auto-optimizer
├── ui/
│ ├── config_panel.py # Sidebar parameter editor
│ ├── results_panel.py # Metrics, table, Plotly charts
│ └── presets.py # Save/load YAML presets
├── utils/
│ ├── yaml.py # YAML load/save/merge helpers
│ ├── format.py # Time formatting utilities
│ └── validation.py # Input validation
├── simulation_log.txt # Auto-generated execution log
└── requirements.txt
- Clone the repository
git clone https://github.com/ak-dev-os/F1LapForge.git cd F1LapForge - Create virtual environment (recommended)
python -m venv venv source venv/bin/activate # Linux / macOS venv\Scripts\activate # Windows
- Install dependencies
pip install -r requirements.txt
- Run the application
streamlit run app.py
- Go to: https://github.com/ak-dev-os/F1LapForge/issues
- Click New issue.
- Choose the appropriate template (Bug report / Feature request) or write a clear description including:
- Steps to reproduce
- Expected vs actual behavior
- Screenshots, log excerpts, and environment information
- Fork the repository.
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m "Add amazing feature" - Push to the branch
git push origin feature/amazing-feature
- Raise Pull Request





