Hi everybody!

Happy new year! First post of 2020 but an old topic. Sometimes old stuff is good.

Once again, Matlab will be a keyword, as today I will talk about the latest updates i have done to my Lap Time Simulation tool.

As some of you (who succeeded in reading my previous entry till the end, without falling asleep) probably already know, I wanted to build up on the base I created already, introducing a more complete/complex vehicle model.

The foundation the tool is based on still remains the same, anyway. The solver employs a quasi steady-state approach and the overall performance of the car over a lap is derived basing on a performance envelope (or g-g-v map) calculated upfront, now also considering all the new vehicle parameters.

As described already in my previous entry, some simplified assumptions has been accepted, for example regarding the way combined grip situations are handled. I employ a four wheels vehicle model: each tire final friction coefficient is calculated separately taking into account the vertical load acting on it and, now, as we will see shortly, also its camber angle.

The tool actually derives car’s performance envelope in pure cornering, pure braking and pure acceleration and then combined them building an ellipse. As i mentioned already before, this is of course a strong simplification, but it proved to produce pretty accurate results anyway.

As before, solving the full lap the tools first determines the maximum speed the car can achieve at each corner apex and then moves forward and backward to calculate braking and acceleration phases.

The main aim for this latest revision was to consider also the effects of **suspensions kinematics and stiffness** and of **full aeromaps** on car’s performance over a lap (or a course). The **tire model** has also undergone a revision and now includes vertical stiffness, centrifugal expansion and camber effects on grip in both lateral and longitudinal direction. All these parameters are strongly linked to each other: for example, both camber angles and car’s aerodynamics are influenced by suspensions and tires vertical stiffness.

During the process, I also added some other small features here and there, either to expand a bit what the tool can do (I included, for example, the possibility to do a simple, straight line simulation) or to make it easier to use.

Moreover, a nice side effect of adding body movements is that I can now also monitor how the CG height changes during a lap (or specific maneuvers) and how this impacts performance.

**What is new?**

Nearly all tabs have a new appearance and some completely new ones were added, to deal with the information required to feed the more complex vehicle model.

At cost being repetitive, I have to say once again i really like working in Matlab and, in particular, in the App Designer, as designing a functional GUI and linking code to each feature is relatively easy.

**Main Data and Setup**

As before, the first tab deals with car’s main dimensions, its mass and mass distribution, CG Height and “fixed” parameters like brake balance or which portion of the engine power is transmitted to the rear wheels.

Here, I also added the maximum steering angle the car can achieve. No Ackermann effects are considered for now and the tool works under the assumption of constant parallel steer and no static or dynamic toe, both for the front and for the rear axle.

The aerodynamics section is now gone, as aerodynamics can be defined in a different window, where full aeromaps can be loaded.

Anyway, this tab is now used to also input car’s full setup, which includes:

- Static ride heights
- Corners wheel rates
- Corners bump stops free gaps
- Third springs wheel rates
- Third springs free gaps
- Third elements bump stops free gaps
- Antiroll bars stiffness
- Front and rear, corners and third elements bump stops curves (defined as force vs displacement look-up tables in an Excel file)
- Static camber

All these parameters (except camber) are used to calculate corners wheel rates, axle vertical rate and roll rate in each calculation step. This is the reason why we don’t need a TLLTD (total lateral load transfer distribution) input anymore and this line is also gone now: loads and load transfers are calculated basing on suspension elastic elements, suspension kinematics, acceleration and aerodynamic forces.

Very basic, but also very useful features are covered by the two buttons at the bottom of this page. Th data relative to the whole car (including information coming from external sources, i.e. Excel files) can be saved and reloaded any time.

**Suspension kinematics
**This is the first new tab.

Here, I can load up front and rear suspensions and steering kinematics. This is actually nothing particularly fancy, mainly because suspension kinematics is here described simply using tables. If i am not mistaken, this approach is often described as “lumped parameters”: the solver doesn’t compute the parameters of interest at each time step basing on the initial pick-up points position and full suspension kinematics, but simply uses as input the results produced using an external suspension kinematics tool.

For front and rear suspensions, the input is an Excel file (so, again, a simple look up table), that contains data relative to the metrics required by the solver, with respect to wheel travel. These include:

- Camber
- Lateral anti effects
- Longitudinal anti effects (in traction and in braking)

Anti effects are calculated using the approach i described some time ago, when talking about load transfer (here), which means considering n-lines inclination.

Steering kinematics can be defined in a similar manner, again using an Excel file where camber angles of inner and outer wheels and wheels vertical movements are monitored with respect to steering angle.

Once again, some of the features of Matlab App Designer come handy here, as the data relative to each axle can be plotted by using a pop-up menu button.

A final, important input here are also the design ride heights, i.e. the ride height that corresponds to zero wheel travel in the look up table.

**Aerodynamics**

The **Aero** tab is also new.

As i shortly mentioned before, the solver works now basing on full aeromaps, providing downforce and drag coefficient and aerodynamic balance with respect to front and rear ride heights. This is enabled by having both suspensions modeled, as the way ride heights (and body position in general) change under external loads depends on suspension and tire properties.

As for the bump stops, I felt the easiest way to input aeromaps (which are basically tables) is, again, in the form of an Excel file.

With three buttons, I can call up a map for each of the above mentioned parameters. Each map can be plotted with respect to front and rear ride heights.

**Tires
**Tires have also undergone some work, mainly because having suspension motion opened the door to modeling some important parameters, like camber. Also modeling how rolling radius change with respect to load and speed is now necessary to complement aerodynamics calculations and required some further input, so the tire tab is now pretty busy!

Suspension kinematics files include, as we have seen already, how camber change with respect to wheel travel and steering angle. I also mentioned how a static camber value must be input in the setup panel and how the design and static/setup ride heights are also considered.

With these data, the solver now can calculate how much camber each tire has in each situation, depending on suspension travel, tires deflections, overall body movements and steering angle.

Having the inclination angle of each wheel opens the door to modeling the effects of camber on grip.

The new tire model is a pretty simple evolution of the one i used already and is still based on a simplified, Pacejka-like approach.

Its foundation is still based on load sensitivity: each tire maximum achievable grip coefficient is calculated basing on the vertical load acting on it. As before, it is also still possible to apply an overall grip correction to front and rear tires separately, in either lateral and longitudinal direction.

Tire slip is represented by a normalized curve that is then reworked by the solver basing on peak slip angles input.

Rolling resistance is still considered as a single coefficient for each tire, but now we have also several parameters used to model tire vertical dynamics.

A static tire radius “R0” is now required, together with a vertical stiffness, which is assumed to remain always constant. Beside this, the user can input two coefficients of a quadratic curve that describe how rolling radius evolves with respect to speed.

These two effects, combined together, result in the instantaneous rolling radius of each tire in each simulation step.

Lastly, the tool considers camber effects on both lateral and longitudinal grip in the form of a multiplier, that acts on top of each tire coefficient of friction.

To calculate the multiplier in lateral direction, three vertical loads must be provided and, for each of these loads, the peak camber angle for the multiplier and its magnitude. Quadratic curves are derived basing on these data and, for each given vertical load and camber angle of each tire, a multiplier is obtained and tire final grip (on top of the values calculated basing on vertical load and load sensitivity) can be calculated.

In longitudinal direction, the approach I use is slightly easier. The tool assumes a grip correction of tires friction coefficient that only depends on camber angle and doesn’t change with respect to vertical load.

Camber multipliers are of course equal to zero, for a zero camber angle.

**Virtual Wind tunnel**

This is also a new tab. The tool performs a scan of some important metrics with respect to speed. For each speed step, the car is assumed to be in steady state, with constant velocity (no longitudinal acceleration and associated load transfer). In my vision, this is pretty much what we would experience if the car would be tested in a wind tunnel at each velocity step we consider.

Among the results, we have ride heights, tires loaded radius, suspension deflections, tires deflection, aerodynamic coefficients and balance.

The results of this scan not only gives a clear picture of car’s attitude depending on speed and of each contribution to final ride heights with respect to speed (and downforce), but also provide data that will be used elsewhere by the tool to build up car’s performance envelope and predict its performance.

Pretty interesting, too, this functionality gives also shows how downforce, drag and balance coefficients evolve depending on speed.

The solver takes into consideration each parameter having an influence on vertical stiffness and ride heights, like springs or tire stiffness, tire expansion with speed, but also each bump stop curve and its free gap.

An additional element in this tab is a quick calculator, providing the values of downforce and drag coefficients and aerodynamic balance, depending on front and rear ride height. This actually doesn’t add any new information to what the plot delivers, but I thought it could be practical to visualize actual numbers on the go, depending on front and rear ride heights input by the user.

**Engine, Gearbox and Performance Envelope**

As I mentioned at the beginning, some functions didn’t change, as i felt they were already delivering what they should. This is the case for **engine** and **gearbox**.

One thing to mention with regards to the final gear ratios, as calculated by the solver, is that the new, more detailed tire model has also an influence in this area. As the solver is now in a position to calculate tires rolling radii at each time step, basing on initial, unloaded tire radius, tire vertical stiffness and centrifugal expansion, now the calculation of the RPM corresponding to a certain speed should be much more accurate.

Also performance envelope tab didn’t change. In this section, I can define the boundaries of the g-g-v diagram (speed) and generate the envelope independently from full lap simulations, if i need it.

What is new here are the metrics that can be plotted. As the model is built on many more parameters, the tool generates also more results that can be use to understand the influence of speed and acceleration on every subsystem.

In other words, i now have a long list of channels i can plot with respect to speed, or lateral/longitudinal, like suspension travels, ride heights, steering angle, body slip angle, etc.

**Straight line simulation**

Another new tab. In this section of the tool I can perform pure straight line simulations, strictly based on all the available car data we described before.

This can come handy to do quick evaluations not only of typical powertrain-related parameters, like engine power, gear ratios, etc., but also enables evaluations about how other metrics change with respect to speed and acceleration (see for example ride heights).

It also offers a way to quickly evaluate assumptions made in terms of drag, engine power, gear ratios, etc. in terms of straight line performance, without the need for a complete lap simulation.

The numerical outputs include the time the car needs to cover a certain distance (starting from a certain speed), final speed, gear used and RPM achieved at final speed.

The plot window, on the other hand, allows to visualize a set of channels (Gears, acceleration, ride heights and aerodynamics metrics) together with a speed plot.

**Track generation, simulation and analysis**

No revolutions in the remaining tabs, but some small additions.

I included the possibility to visualize both closed and open circuits/courses. I don’t think i will deal with hill climb racing anytime soon, but I thought “why not”. You never know!

As a consequence of the expanded vehicle model, the post-processing plots grow significantly in number and I can now look at any parameter the solver computes, when calculating car performance. This includes basic data, like speed, accelerations, gears, steering angle, RPM, yaw rate but also some more “advanced” stuff, like ride heights, suspension travel, vertical loads (hence also load transfer), tires deflections, camber angles, anti effects, tires and body slip angles, aerodynamics coefficients, etc.

Such a big amount of channels also stimulated the desire to be in a position to manipulate them using math formulas or, in other words, writing math channels. It made no sense to write and include in this tool a proper data analysis module: this would have taken a long time, a big effort, most probably to produce something that would not be even close to professional packages available on the market (sometimes even for free, in their easier versions).

As my tool can export simulation results to an Excel file, i looked for data analysis packages that allow to import text files written in standard formats (like CSV or ASCII). To my surprise, there are really few software that enable this functionality for free. Some of them are actually pretty basic tools and this made them a bit unattractive for me. The only, really professional software (although many would probably say it is not really user friendly) with this feature I found is WinDarab, from Bosch Motorsport.

I used it for some years, back when i worked on Formula 3 cars (the tool was mandatory in the class, for the cars fully respecting FIA Spec). My last go with it was in 2008, I think. Heck, I am getting really old!

The latest version of it looks a bit different than what I remembered, but it still works similarly and is pretty capable, in my opinion.

The good thing about using a professional analysis software for data analysis, is that you can create potentially all kind of plots and mathematical channels, easily comparing data of different runs with each other and, potentially, also with external data coming from other simulation packages or a data logger.

The only negative effect of the tool being expanded as i described here, is that the computational time required to simulate a lap increased sensibly.

I am right now at a point where, to simulate a lap of an LMP like car, the tools takes a very slightly bigger time than the simulated lap time (about 1-2% more).

This surely depends, at least partially, on the code not being really optimized yet; there are indeed a couple of things I would like to test, with the aim to improve it a bit and reduce the computational time.

Anyway, an important factor is also the type of car being simulated and the performance envelope boundaries being used (a car reaching higher top speeds, for example, may require to consider a bigger speed window for its performance envelope and, potentially, more time).

A certain amount of “points” (speed) in building the g-g-v map are required to make the simulation robust, but the accuracy of simulation results seems not to be that affected by the number of said points, as far as i could see, while the computational time is.

To get a feeling, reducing the number of points from 21 to 16, produced a reduction of the computational time of about 16%, with a difference in the calculated lap time between the two case studies of only 0.04%.

My feeling is that the tool could be made faster by further working in this direction, if required, even without any specific further optimization in terms of coding.

Despite these latest updates, this lap time simulator is still a pretty easy tool, that uses some important, simplified assumptions and could surely still be optimized in many ways.

Nonetheless, this project has been an incredible experience until now and I am extremely happy I decided to get into it. As I mentioned in my latest entry already, the more I dig into it, the more I can see how the methods I employed to deal with some areas are pretty similar to what other, more clever people did already in the past: even being some 20 years late, it is kind of reassuring to learn that you are coming to the same conclusions of people you have an high opinion of.

I am pretty satisfied about the accuracy of the results and the use I can do out of the tool, above all with addition of the latest features.

Beside this, looking back there are so many “issues” I could not foresee at all, when I started. All this small stones on my way have been actually a great chance to dig deeper into certain topics and improve my understanding of certain phenomena. I still have a long way and a tons of things to learn in front of me, but I really look forward to this.

Finally, it is really cool to have something you can fully adapt to your needs, with the only real limit being your programming skills, something I am keen to go on improving.

Nice times behind and, more importantly, ahead!

Edit: a few days after publishing this article, I could not resist but try to speed up simulation a bit. I further reduced the number of points used to generate the g-g-v map from 16 to 11 and got a further reduction of the computational time of about 16.5%, with a lap time delta of 0.025%. The solver can now compute the same lap I considered before quicker than “real time”: in other words, the tool now takes about 94% of the computed lap time to complete the simulation.