A physics-based lap time simulation tool that models vehicle dynamics to predict optimal lap times on racing circuits. Originally developed as part of a TIPE (Travaux d'Initiative Personnelle EncadrΓ©s) project.
- Overview
- Features
- Physics Model
- Installation
- Usage
- File Formats
- Project Structure
- Examples
- Contributing
- License
LapTimeSim is a quasi-static lap time simulator that calculates the theoretical optimal lap time for a given car-track combination. The simulation uses fundamental physics principles including:
- Tire friction modeling with load sensitivity
- Aerodynamic forces (downforce and drag)
- Powertrain modeling with gear ratios and efficiency
- Combined grip using the friction ellipse (traction circle) concept
- Optimal velocity profiling through corners and straights
Unlike dynamic simulations that solve differential equations in real-time, a quasi-static approach assumes the vehicle is always in equilibrium at each point. This simplification allows for faster computation while still capturing the essential physics of vehicle performance.
- π Comprehensive Vehicle Model: Mass distribution, aerodynamics, tires, powertrain
- π€οΈ Track Discretization: Converts track centerline data into simulation-ready mesh
- π GGV Diagram Generation: 3D traction envelope visualization
- π Optimal Gear Selection: Automatic gear optimization based on engine curves
- π Rich Visualization: Speed traces, circuit maps with velocity coloring, gear/RPM plots
- πΎ Modular Data Format: Separate car and track model files for easy mixing and matching
The simulator models the following forces:
F_x = F_engine - F_aero_drag - F_rolling - F_braking
- Engine Force: Interpolated from torque curve Γ gear ratio Γ efficiency
- Aerodynamic Drag:
F_drag = 0.5 Γ Ο Γ Cd Γ A Γ vΒ² - Rolling Resistance:
F_roll = Cr Γ |F_z|
F_z = -M Γ g + F_downforce
- Weight:
F_weight = M Γ g - Downforce:
F_down = 0.5 Γ Ο Γ Cl Γ A Γ vΒ²
F_y = M Γ vΒ² / R (centripetal force required for cornering)
The tire friction model includes load sensitivity:
ΞΌ = ΞΌ_0 + sensitivity Γ (N_rated - N_actual)
Where:
ΞΌ_0is the base friction coefficientsensitivityis the load sensitivity factorN_ratedis the rated load for the tireN_actualis the actual normal load on the tire
The combined longitudinal and lateral grip is modeled using the friction ellipse:
(a_x / a_x_max)Β² + (a_y / a_y_max)Β² β€ 1
This ensures that when the car is cornering at maximum lateral grip, longitudinal acceleration capacity is reduced accordingly.
- Calculate Maximum Cornering Speeds: For each point, compute the maximum velocity limited by lateral grip
- Find Apex Points: Identify local minima in the velocity profile (braking zones)
- Forward Integration: From each apex, simulate acceleration forward
- Backward Integration: From each apex, simulate braking backward
- Merge Profiles: Take the minimum velocity at each point from all integration passes
- Python 3.7 or higher
- pip package manager
pip install numpy matplotlib scipygit clone https://github.com/yourusername/LapTimeSim.git
cd LapTimeSim- Model your car (or use an existing model):
python src/CarModelSimV2.py- Model your track (or use an existing model):
python src/CircuitModelingSimV2.py- Run the lap simulation:
python src/LapSimV2.pyEdit the file paths in each script to point to your data files:
# In LapSimV2.py
nom_circuit, pays, tr = ouvertureFileTrack("data/tracks/Model_Monza_TrackSimV2.txt")
nom_voiture, veh = ouvertureFileCar("data/cars/Model_Alpine_A110_CarSimV2.txt")Tab-separated values with parameter names and values:
Alpine A110 (cup)
Total Mass 1100 kg
Front Mass Distribution 42 %
Wheelbase 2420 mm
Lift Coefficient CL -2.8 -
Drag Coefficient CD -0.8 -
...
MARKER_info/data
1000 150
2000 200
...
The section after MARKER_info/data contains the engine torque curve (RPM vs Torque in NΒ·m).
Tab-separated with corner type, length, and radius:
Country TrackName
Straight 465.949 0.000
Left 5.364 1856.545
Right 4.046 787.304
...
- Straight: Length in meters, radius = 0
- Left/Right: Arc length in meters, radius in meters
Both car and track models are exported as Python dictionaries serialized to text files, containing all computed parameters needed for simulation.
LapTimeSim/
βββ README.md
βββ LICENSE
βββ requirements.txt
βββ src/
β βββ CarModelSimV2.py # Vehicle parameter processing
β βββ CircuitModelingSimV2.py # Track geometry processing
β βββ LapSimV2.py # Main lap time simulation
βββ data/
β βββ cars/ # Car definition files
β β βββ AlpineA110V2.txt
β β βββ essaieCARV2.txt
β βββ tracks/ # Track definition files
β βββ castelletV2.txt
β βββ monza.txt
βββ docs/
β βββ physics_model.md # Detailed physics documentation
βββ examples/
β βββ example_usage.py # Example usage scripts
βββ output/
βββ Model_*_SimV2.txt # Generated model files
Running the simulation on Paul Ricard (Le Castellet) with an Alpine A110 Cup:
DΓ©coupage du circuit : OK
Simulation terminΓ©
Temps au tour: 1:52.340
The simulator generates several plots:
- Speed vs Time: Vehicle speed throughout the lap
- Circuit Map: Track layout colored by velocity
- Engine RPM & Gear: Gear selection and engine speed
- Yaw Rate: Vehicle rotation rate through corners
- GGV Diagram: 3D traction envelope (Car Model only)
- Create a new car definition file following the format in
data/cars/ - Run
CarModelSimV2.pywith the new file path - Use the generated model file in
LapSimV2.py
- Create track data with corner-by-corner radius and length
- Format as per
data/tracks/examples - Run
CircuitModelingSimV2.pyto generate the model
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Add elevation changes (3D track model)
- Implement thermal tire model
- Add fuel consumption modeling
- Create GUI interface
- Support for telemetry data import
- Validate against real lap times
This project is licensed under the MIT License - see the LICENSE file for details.
- Developed as part of a TIPE project on racing simulation
- Inspired by professional lap time simulation tools
- Physics model based on vehicle dynamics literature
For questions or feedback, please open an issue on GitHub.
Made with β€οΈ for motorsport enthusiasts and engineering students
