Laptime simulator

Post here information about your own engineering projects, including but not limited to building your own car or designing a virtual car through CAD.
MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Laptime simulator

Post

Hello guys,

As I have some free time and decided to make this some project I can work on whenever I have free time along the next few months, I've decided to create a laptime simulator in Matlab. Yes, another one, some might say (both for me, and on internet). For sure there are better software on the web, as well as ADAMS, and other suspension software, but I wanted to make one.

I gave it several dozen hours already, and the basis is there now I think. Let me first show you a screenshot of one section:

Image
(ignore the values in the boxes)

This is WORK IN PROGRESS and all sections on the left have been worked on. There are also some under sections not directly listed on the left. In total, about 20 panels at the moment. There will be CoG location calculation, roll centre, anti-dive graphs, motion ratio, traction hyperbola, track creation, and so on.

I have done 2-3 simulators in the past (steady-state type) more or less complicated, and this time I wanted to start from scratch rather than taking over some work that might have flaws already.

It is all about deciding what to take in account, and what to estimate. My simulator will be between OptimumLap (which is very simple and doesn't require lot of input) and ChassisSim (which is a nightmare to fill with details). My aim is to start with a steady-state simulator and upgrade it to transient which shouldn't be too difficult once all variables have been set.

However, I have been through routes which have not been the optimal to create a laptime simulator, and this is why I am opening this thread, so I can benefit from ideas that I wouldn't have myself! Because I feel like opinion from other people is the best way to move forward!

The car will not only either steer, brake, or accelerate, but the driver will be able to brake while steering for example, as if the corner tightens. However, I am still wondering a bit about what input parameters I will need for what outputs. Keeping in mind that transient state will be added hence why I don't want to have to redo the whole code.

What do you think? :)

User avatar
mep
29
Joined: 11 Oct 2003, 15:48
Location: Germany

Re: Laptime simulator

Post

Nice topic. I am also working on a lap time simulation, so this could become an interesting sharing platform and good for problem solving. I currently I stopped working on it because I started to focus on other topics. I started straight away with a transient simulation because I was mainly interested in the suspension behaviour even when I just simulate a short section of a track. I got a bit stuck because I need a decent approach for the braking and cornering problem. As its transient I don’t want to go back and forward from the apexes. My current idea is that the simulation should work only forward but use several iterations to find the ideal speed and brake points by itself. I have to say that programming is not my strongest skill.
From what I can see from your picture, you have an amazing GUI. Actually the best I have seen from a Matlab simulation so far.

User avatar
Tim.Wright
330
Joined: 13 Feb 2009, 06:29

Re: Laptime simulator

Post

Transient ad steady state laptime simulators are 2 fundamentally different things. In my opinion you can't really start with one and then convert it to the other. The transient solver takes the driver's inputs and calculates the vehicle output. The steady state goes in reverse, starting with the desired vehicle response and back calculating the drivers "inputs".

I've too been working on a steady state lap simulator. Matlab based. I've also used a number of commercial lapsimulation tools as well. I can tell you that none of them (that I have used) have an absolutely robust driver controller. In fact I avoid transient laptime simulations unless absolutely necessary.

Either way, its an interesting topic...
Not the engineer at Force India

MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Re: Laptime simulator

Post

Thank you mep! Yes indeed that could be good to share ideas!

That GUI is really far from complete to be honest, here is another shot from the kinematics module where I can input suspension coordinates to show them in 3D and perform motion ratio analysis, camber gain, antidive/squat, etc.:

Image

For the corners, my simulator will consider constant radius corners. They can be added one after the other, but the radius will be known so it simplifies things. Maybe later I will include real track with x-y coordinates and calculate the radius at every point (I've done that in a previous simulator) but I want to keep things simple for now.

I think you can escape going back and forward to calculate braking point. You can build your braking function by inputing the speed in it so that it gives you the maximum braking force. You then have to apply it at every step in the acceleration phase to see if you'll be able to reach the upcoming corner speed. Basically what you just wrote! :)

But it is still not clear to me what inputs I should use to perform the simulation. I mean, to simulate active diffs I will need throttle input, brake input, steering input for example, which are purely driver inputs. So I would have to drive my simulation with these inputs to achieve the max corner speed rather than having the car driven at the corner speed and the driver inputs as outputs if you see what I mean. But I don't know if that is a good solution or not.

EDIT: Basically what Tim wrote! I'm glad I'm not out of the blue with my ideas then.

Greg Locock
Greg Locock
233
Joined: 30 Jun 2012, 00:48

Re: Laptime simulator

Post

I've tried to use one of the ADAMS laptime simulators... and failed. The most robust approach is a glorified friction circle, if you have a look at OptimumLap or LapSim then that is pretty much all they do. So you start with the current state, work out the instantaneous properties of the tires, combine them for each axle, and chuck it into a bicycle model.

At work I use a full vehicle model double lane change simulator, ie 3 sets of cones, try and get the lowest possible time through the cones without rolling the car, spinning out, or hitting a cone, with the car in neutral.

You might think that a driver model to accomplish that rather simple maneuver would be feasible.

Well, it may be, but in practice we don't do it that way. We just simulate some possible steering history and entry speed traces and use an optimiser. We aren't saying that's what a skilled driver would or could do, it is what the tires are capable of in that chassis.

Lycoming
Lycoming
106
Joined: 25 Aug 2011, 22:58

Re: Laptime simulator

Post

It will be very difficult to go from a steady state model to a transient model without re-writing a lot of code. I suppose you could start with a transient model and force all your time derivatives to be 0, but that kind of defeats the purpose.

So, how will you combine constant radius corners with combined traction (simultaneous brake and steer)?

And perhaps more importantly, what do you hope to be able to do with this software?

MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Re: Laptime simulator

Post

Greg, I've done a bicycle model in ADAMS and it worked fine, but for sure it is not really a user friendly software and it can be frustrating, but I've seen a full car model run on a virtual road with cones, it was quite impressive and looked really nice.

Lycomming you've asked me a question I was trying to avoid, what do I want to do with the software. Well at the moment it is still unclear, mostly trying to improve my knowledge of car handling and matlab. I found a transient Simulink model of a car suspension on matlab's website: http://www.mathworks.se/help/simulink/e ... nsion.html

It is quite interesting although only for straight line. At the present moment I won't simulate bumps so the only input this model requires is the pitch moment induced by car acceleration. When adding the corner phase, it will require the rolling moment induced by cornering, and as you said it kind of marks the border between a SS (steady-state) model and a transient, as these 2 moments are defined by throttle, brakes, and steering.

I feel like I will indeed have to create a driver model. This isn't a bad thing I guess.

As for the simultaneous brake and steer, I will use the friction circle of course. I am thinking about 2 main cases:

1) if there is a sequence of straight-corner-straight, the driver will only brake in a straight line, negociate the corner, and then accelerate when the corner is finished.
2) if there is a sequence of straight-corner-corner-straight, 2 more cases appear:
2a) if the 2nd corner in the sequence is slower, the driver will have to slow down at the end of the first corner to achieve the maximum speed of the second corner when it starts.
2b) if the 2nd corner is faster than the first corner, the driver will accelerate only when the first corner is finished to meet the maximum cornering speed of the second corner.

In any case I will have to do the back-and-forth method to define the moment when the driver will need to brake or accelerate.

MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Re: Laptime simulator

Post

I am working at the moment on my acceleration model. Of course the model will take in account inertia of the drivetrain. However, I would like to check some of the equations here since I found different versions on the net with different simplifications which can be confusing when the author doesn't write everything correctly.

At the moment my model gets the engine torque from engine speed, which then gives me a tractive force at the contact patch. From this force I remove the aero resistance (I ignore the rolling resistance for now), and assume (for now) that there is no grip limitation. I therefore get:

(1) Fnet = Ftrac - Faero

This force gives me the car acceleration knowing its mass, thanks to Newton:

(2) acar = Fnet / carmass

Taking in account the rolling radius of the wheel, the resultant torque at the wheel due to this net force is:

(3) Torque = Fnet * rollrad

This is where it gets a bit tricky. I then use this torque to calculate the angular acceleration of the engine:

(4) alphaengine = Torque / Iequ

With Iequ being the equivalent inertia of the drivetrain seen by the engine (assuming we have a RWD car)

(5) Iequ = [ ( Iengine + Igear ) * itot^2 ] + [ Ireardiff * reardiffratio^2 ) + 2 * Iwheel

(6) itot = gearratio * reardiffratio

Knowing the angular acceleration of the engine, I integrate to find the new engine speed and start again!

However, few things:

- In equation 4, I believe the Torque value has to be divided by itot as we are looking at the engine angular acceleration, isn't it?
- What about the car inertia in the longitudinal direction?

Thanks for reading!

Jersey Tom
Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Laptime simulator

Post

First... might want to ask yourself how much value you're adding by including engine rotational inertia. Is it anything significant or is it trivial when it comes down to lap time? Or when it comes down to where you're going to arrive at a car setup?

Second... I don't agree with how you're coming up with wheel torque based on net acceleration. If that were the case then your wheel torque to maintain speed at 200 mph would be zero - which is not correct. You will have significant wheel torque to maintain speed while overcoming aero drag.

Ultimately if you know the engine torque and you know your gearing then you know your wheel torque from the onset.

Third... as you kind of get to later on... you're saying that all that wheel torque is only used to spin up the engine? (implication -> not accelerate the car). Which would clearly not be correct.

I dunno, confusing logic hard for me to follow. Think you need to revisit your force and moment balances, etc. Maybe even the spec of what all you want your sim to do, and how fast (Matlab is not particularly quick). IMO the best simulation tool is the simplest one that meets your accuracy criteria.
Last edited by Jersey Tom on 13 Nov 2014, 19:19, edited 1 time in total.
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Re: Laptime simulator

Post

Thanks for your answer!
Jersey Tom wrote:First... might want to ask yourself how much value you're adding by including engine rotational inertia. Is it anything significant or is it trivial when it comes down to lap time? Or when it comes down to where you're going to arrive at a car setup?
It is trivial, but I can always remove that later on if the impact on results is not relevant. I took values from a F3 at the moment, which gives me the following:

Iengine = 0.1 Kg/m^2
Iwheel = 0.12 to 0.17 Kg/m^2 (gear ratio dependent)

However, Iequ is equal to about 70 Kg/m^2 in 1st gear with the values I have which is still something.

My aim is to take in account the inertia so evaluation of gear ratios on acceleration can be simulated.
Jersey Tom wrote:Second... I don't agree with how you're coming up with wheel torque based on net acceleration. If that were the case then your wheel torque to maintain speed at 200 mph would be zero - which is not correct. You will have significant wheel torque to maintain speed while overcoming aero drag.

Ultimately if you know the engine torque and you know your gearing then you know your wheel torque from the onset.
Of course I know the torque applied to the wheel knowing the engine torque and gear ratio, but the wheel torque I am talking about is the resultant torque, which is indeed 0Nm at 200mph because you will have Ftrac = Faero.

Although you will of course need engine torque to maintain Ftrac = Faero, you won't have any resultant torque in the wheel as these 2 forces are in opposition at the contact patch.
Jersey Tom wrote:Third... as you kind of get to later on... you're saying that all that wheel torque is only used to spin up the engine (implication -> not accelerate the car) which is clearly not correct.

Think you need to revisit your force and moment balances, etc. Maybe even the spec of what all you want your sim to do, and how fast (Matlab is not particularly quick). IMO the best simulation tool is the simplest one that meets your accuracy criteria.
I think my issue come from equ4 as you said I only use this resultant torque to accelerate the engine but how else can I define by how much the engine is accelerated taking in account the powertrain inertia?

Jersey Tom
Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Laptime simulator

Post

I think my issue come from equ4 as you said I only use this resultant torque to accelerate the engine but how else can I define by how much the engine is accelerated taking in account the powertrain inertia?
How would you go about solving the classic high school physics problem of a cylinder rolling down an inclined plane? (A problem which includes both linear and rotational inertias...)
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Re: Laptime simulator

Post

Jersey Tom wrote:
I think my issue come from equ4 as you said I only use this resultant torque to accelerate the engine but how else can I define by how much the engine is accelerated taking in account the powertrain inertia?
How would you go about solving the classic high school physics problem of a cylinder rolling down an inclined plane? (A problem which includes both linear and rotational inertias...)
Well, the cylinder has a moment of inertia I, is accelerated down a slope of angle alpha.

I = 0.5 * m * r^2
alpha = a / r
m * g * sin(alpha) - FrictionForce = m * a
Torque = I * alpha

So:

Torque = 0.5 * m * r^2 * a / r = 0.5 * m * r * a

Torque is given by the resultant force at the point of contact between the cylinder and the slope and the cylinder radius, so we have:

FrictionForce * r = 0.5 * m * r * a => FrictionForce = 0.5 * m * a

Using the 3rd equation above, we get:

m * g * sin(alpha) - m * a = 0.5 * m * a => g * sin(alpha) - a = 0.5 * a => 1.5 * a = g * sin(alpha) => a = 2/3 * g * sin(alpha)

But I don't really see the point. I have seen people calculating the inertia as a mass factor depending on the gear ratio but I don't really like these approximations that don't let you define a change in a wheel design for example and see the effect on acceleration.

MadMatt
MadMatt
125
Joined: 08 Jan 2011, 16:04

Re: Laptime simulator

Post

I will reformulate my question. I would like to calculate the engine angular acceleration including powertrain inertia knowing the net force at the contact patch. I have the feeling that I did things right with my equations but I am not 100% sure.

Greg Locock
Greg Locock
233
Joined: 30 Jun 2012, 00:48

Re: Laptime simulator

Post

I'd rather use energy methods

power_engine*driveline_efficiency=1/2 *d (sum of (rotational inertias * their angular velocities^2))/dt+1/2*d(sum of (translational inertias*their velocities^2))/dt+RR*v+aero*v

off the top of my head
Last edited by Greg Locock on 14 Nov 2014, 02:43, edited 1 time in total.

Jersey Tom
Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Laptime simulator

Post

MadMatt wrote:But I don't really see the point.
Ultimately you're trying to arrive at position vs time for the full vehicle. You have a motive supply (engine) and you have the car, which has both linear and rotational inertias to be overcome. Go back to your original Eq. 2 - you are assuming the acceleration of the car is purely a matter of linear inertia - not correct - and then you are separately trying to integrate the solution for the engine.

I would say you need to rework your force and moment or work balance at the onset. If you know the vehicle speed (and tire slip and rolling radius) then you know exactly what the engine speed is... no need to integrate/solve it separately.
Grip is a four letter word. All opinions are my own and not those of current or previous employers.