You are on page 1of 23

MFeval: Magic Formula 6.1.

2 solver
Version 1.4

Authors:
Marco Furlan mfurlant@jaguarlandrover.com
Matthew Corner mcorner1@jaguarlandrover.com

JULY 03, 2017


JAGUAR LAND ROVER
ABBEY ROAD, WHITLEY, COVENTRY, CV3 4LF
Contents
1 Introduction .......................................................................................................... 2
2 Getting started ...................................................................................................... 3
2.1 Installation ..................................................................................................... 3
2.2 System Requirements ..................................................................................... 4
2.3 Release Notes................................................................................................. 4
3 User guide ............................................................................................................ 6
3.1 MATLAB ...................................................................................................... 6
3.2 Simulink ........................................................................................................ 8
4 Magic Formula 6.1.2 Equations ........................................................................... 10
4.1 Important changes to the equations of the book ............................................. 10
4.1.1 Use of alpha star .................................................................................... 10
4.1.2 Use of lambda prime and Aµ definition .................................................. 12
4.1.3 The use of epsilon .................................................................................. 12
4.1.4 Tyre deflection ...................................................................................... 13
4.1.5 Rolling resistance (My) .......................................................................... 14
4.1.6 Aligning torque (Mz) ............................................................................. 15
4.1.7 Overturning moment (Mx) ..................................................................... 16
4.1.8 Turn slip equations ................................................................................ 18
5 Future work and support...................................................................................... 21
6 Validation........................................................................................................... 22

1|P age
1 Introduction
MFeval is a MATLAB® toolbox which contains the function with the same name
“mfeval.m”, “mfeval_CPI_tyre.slx” and “loadTIR.m” used to evaluate tyre property
files (.TIR) with the Magic Formula 6.1.2 equations. A tyre property file (.TIR)
contains the parameters that define the tyre's force and moment characteristics.

The idea for the creation of MFeval emerged after observing differences between the
outputs of the Scaling tool (developed by Benjamin Dwyer) and OptimumTire. An
investigation into different solvers and their hard coded equations was conducted.
This investigation showed that there are several different approaches to the
implementation of Magic Formula 6.1. Different solvers had different outputs and
different published sources had different implementations.

MFeval is intended to standardize the implementation of Magic Formula equations


across the business. The objective is to use the same equations during the fitting
process of the model and in simulations carried out in different softwares such as
MATLAB®, Simulink, Simpack and CarMaker.

Currently MFeval has only been developed for MATLAB®. “mfeval.m” was inspired
by the TNO “dteval.m” function with the addition of two optional inputs: pressure and
rotational speed.

2|P age
2 Getting started

2.1 Installation
To install the toolbox open the .mltbx file downloaded from the store in MATLAB®.
You can do this by double clicking it or by dragging and dropping it in to the
command window. Once installed, the toolbox will be available from any working
directory. You can manage the toolbox by clicking on the Manage Add-Ons menu in
the Home toolbar, as shown below.

Figure 1: Add-O ns menu

The installation directory can be opened by clicking on the “Open folder” button as
shown below.

Figure 2: Installation directory

In this directory, there are some useful sub-folders for the user.
 The folder named “Examples” contains an example of how to use mfeval.m
and mfeval_CPI_tyre.slx.
 The folder “Documentation” contains this document in PDF format.
 The folder “Validation” contains images showing the outputs of mfeval.m
against the TNO solver dteval.m for a series of input arguments.

3|P age
Figure 3: Installation subfolders

2.2 System Requirements


The software has only been tested in MATLAB R2015b (latest JLR release)

2.3 Release Notes


Version Release Date Notes
1.0 25/01/2017 First release of the toolbox for beta-testing
1.1 31/01/2017 Equation (4.E40) modified
Allow a structure of parameters to be passed in
instead of a TIR file name.
Replace for loops in the coefficient checks with
vector expressions
Rho calculation reviewed avoiding (NaNs) in external
effects
Coefficient checks can be disabled
Coefficients of friction are checked before being
exported
1.2 16/02/2017 Typo in the help text corrected
Mux and Muy warnings can be deactivated with the
coefficient checks.
Rolling resistance (4.E70), pneumatic trail (4.E73), Bt
(4.E40), Dt (4.E43) and s (4.E76) equations have
been modified to match TNO solver.
1.3 06/03/2017 Code modified for code generation
Simulink blocks with transients have been included
Use mode implementation modified
Turn Slip equations modified
Pneumatic trail equation fixed

4|P age
1.4 03/07/2017 First implementation of the low speed mode
Publication of MFeval in MathWorks File Exchange

5|P age
3 User guide

3.1 MATLAB
The function mfeval.m evaluates Magic Formula 6.1.2 in steady state for a series of
input variables.

“mfeval.m” formulation includes:


 Combined force/moment and turn slip calculation
 ISO coordinate system
 At the moment mfeval is only valid for steady state (No transients)

The syntax is the following:

OUTPUT = mfeval (PARAMETER_SOURCE, INPUTS, USE_MODE)

PARAMETER_SOURCE refers to a MF-Tyre tyre property file (.TIR) or to a structure


containing all the Magic Formula coefficients.

If the user wants to evaluate a (.TIR) file, the location and name of the file should be
written in a string format. For example:

FILE_NAME = ('C:\Users\mfurlan\Documents\MATLAB\MFeval\TyreA.tir');

When the TIR file is in the MATLAB® current folder we can write:

FILE_NAME = ('TyreA.tir');

And if the user wants to evaluate a structure with all the parameters:

FILE_NAME = MyStructure;

More information about MATLAB® structures can be found at the following link.

INPUTS refer to a matrix containing all the input variables as described:

Figure 4: Input arguments

The variables P* and OMEGA* are optional inputs. If they are not included pressure
is constant and equal to the inflation pressure on the TIR file and the rotational speed
is approximated. All the variables should be in column vector format and with the
same length.

6|P age
USE_MODE is a 3 digit number that specifies the type of calculation performed. The
options are:

1: combined force/moment calculation


2: combined force/moment calculation + turn slip
+10: revoke alpha_star definition
+20: include alpha_star definition
+100: include limit checks
+200: ignore limit checks

For example: USE_MODE = 121 implies:


-combined force/moment
-include alpha_star
-include limit checks

For normal situations turn slip may be neglected, meaning that the radius of the path
is close to infinity (straight line).
Alpha_star is only defined in the Pacejka book and it is said to improve the accuracy
of the model for very large slip angles and possibly backwards running of the wheel
(negative speed).
The limit checks verify that the inputs are inside the stable range defined in the TIR
file and activates the low speed model.

It’s recommended to use USE_MODE = 111. In this mode the outputs will match TNO
results.
It’s important to note that the mfeval USE_MODE numbering convention is different
from MSC ADAMS to avoid confusion.

OUTPUT consists of a matrix with 20 columns where:

Figure 5: O utputs

OUTPUT matches the TNO format including some extra columns.

7|P age
3.2 Simulink
Under the installation directory shown in Figure 3 there is a Simulink file named
“mfeval_CPI_tyre.slx”. This file contains a Simulink model for the tires that can be
used in a full car vehicle model.
This model runs the MFeval equations using the contact point interface (CPI). The
inputs to the tyre model are the sliding velocities at the tyre-road contact point.
The inputs for the model are shown in Table 1.

Table 1

Inputs Description Units


Fz tyre normal load [N]
Vx Forward velocity of wheel centre, parallel to the road surface [m/s]
Vy lateral wheel slip velocity at road level [m/s]
Omega Wheel angular velocity about wheel spin axis [rad/s]
Psidot Tyre yaw velocity about the road normal [rad/s]
Gamma Inclination angle of the wheel with respect to the road [rad]
P Tyre pressure [Pa]

All the outputs are wrapped in a structure called “simout”. This structure will contain
timeseries variables.

Figure 6. mfeval_CPI_tyre

If the user double clicks on the Simulink block the mask will pop-out as shown in
Figure 7. Here the user specifies the location of the TIR file, Use Mode, Tyre side and
Dynamics mode. This is done in the same format as explained in section 3.1 of this
document.

8|P age
Depending on the tyre side selected, the lateral force (Fy), the self-aligning torque
(Mz) and the overturning moment (Mx) will be mirrored.
The Dynamics mode can be changed between steady state, linear transients and non-
linear transients. These different approaches are explained in paper of Besselink (See
section 4 )

Figure 7. Mask of mfeval_CPI_tyre

9|P age
4 Magic Formula 6.1.2 Equations
The equations used in mfeval.m are published in the book:
Title: Tyre and Vehicle Dynamics
Author: Hans Pacejka
Edition: 3, revised
Publisher: Elsevier, 2012
ISBN: 0080970176, 9780080970172
Length: 672 pages

And in the following paper:


Besselink, I. J. M. , Schmeitz, A. J. C. and Pacejka, H. B.(2010) 'An improved Magic
Formula/Swift tyre model that can handle inflation pressure changes', Vehicle System
Dynamics, 48: 1, 337 — 352
Link to this Article: DOI: 10.1080/00423111003748088
URL: http://dx.doi.org/10.1080/00423111003748088

Most of the equations in mfeval are from the Section 4.3.2 (Page 176) of the book.
Those equations that had errors or their results where diverging too much from the
results of the TNO solver (MF-Tyre MF-Swift 6.1.2.1) have been replaced with the
equations published in the paper.

All the equations of the code have a number in brackets for reference, corresponding
to the equations located in the book and the paper as shown below:

Figure 8: Equation reference

The notation is as similar as possible with the notation of the book. The outputs of this
script have been validated against the outputs from the official TNO solver "dteval.m"
(MF-Tyre MF-Swift 6.1.2.1). The validation showed a perfect match between
mfeval.m and the TNO dteval.m. Turn slip equations have not been validated because
turn slip mode requires a paid license from TNO.

4.1 Important changes to the equations of the book

4.1.1 Use of alpha star


Alpha star or the lateral slip is the tangent of the slip angle. Pacejka describes in the
book that it might be better to use alpha star at very large slip angles and possibly
negative rotation of the wheel.

Figure 9: Alpha star definition (Pacejka, 2012)

10 | P a g e
It was demonstrated that the TNO solver is not using this definition. Therefore it’s up
to the user whether to use it or not by selecting the correct USE_MODE number.
If alpha star is not used, then alpha star is equal to alpha. Keep in mind that during the
fitting process of the model, the alpha star definition is not used.
In the image below there is a comparison between the use or not of alpha star and
TNO. It can be noticed that above 0.3 radians mfeval with alpha_star (red line)
diverges from TNO and mfeval without alpha_star.

Figure 10: Alpha star effect

11 | P a g e
4.1.2 Use of lambda prime and Aµ definition
On page 179 of the book, Pacejka introduces a special digressive friction factor
named lambda prime. This factor is used in pure lateral and pure longitudinal
equations (Fxo and Fyo) and is intended to replicate the fact that when the coefficient
of friction tends to zero, vertical shifts between the force curves vanish at a slower
rate. The equation is the following:

Figure 11: Lambda prime definition (Pacejka, 2012)

As Figure 11 shows, Pacejka suggests setting Aµ to 10. However if for example,


lambda star is set to 0.7:
Aµ 𝜆µ𝑥 ∗ 10 ∗ 0.7
𝜆′µ𝑥 = = = 0.9589
1 + (Aµ − 1) 𝜆µ𝑥 ∗ 1 + (10 − 1) ∗ 0.7

This was causing a big difference between the TNO solver dteval and mfeval when
scaling factors where applied. To solve this problem Aµ has been hardcoded to be
equal to 1. Now, if lambda star is set to 0.7:

Aµ 𝜆µ𝑥 ∗ 1 ∗ 0.7
𝜆′µ𝑥 = = = 0.7
1 + (Aµ − 1) 𝜆µ𝑥 ∗ 1 + (1 − 1) ∗ 0.7

With Aµ equal to 1, there is a good correlation with TNO. In the image below we can
see the error between dteval and mfeval varying each scaling factor (individually)
from 1 to a 100.

Figure 12: Scaling factors validation

All the errors are close to 0%. The current formulation of mfeval is in accordance
with the published equations and is giving the best approach at the moment.

4.1.3 The use of epsilon


At the bottom of page 177 of the book, Pacejka explains the use of the term epsilon
(ɛ). Epsilon is used to avoid singularities (like divisions by zero) by adding a small

12 | P a g e
quantity with the same sign as its neighbouring main quantity. Epsilon appears in
different equations with different subscripts:

 Epsilon_v
 Epsilon_x
 Epsilon_k
 Epsilon_y
 Epsilon_r

In the mfeval code, all of these are set to be equal to 0.0001. It’s easy to forget that
epsilon should have the same sign of its neighbouring main quantity because this is
not written inside the equations. See Figure 13:

Figure 13: Equation 4.E26 (Pacejka, 2012)

The neighbouring main quantity in equation 4.E26 is Dy. So the correct formulation
in MATLAB should be:

Figure 14: Modified equation 4.E26

However, in MATLAB the sign of zero is equal to zero:

Figure 15: sign of zero

To avoid zero division when the parameter Dy is equal to zero and keep using the
correct definition of epsilon we can write:

Figure 16: Corrected equation 4.E26

4.1.4 Tyre deflection


There is not an explicit equation to calculate tyre deflection in the book. But it can be
calculated from the equation A3.3 on page 619:

13 | P a g e
Figure 17: Vertical load formulation (Pacejka, 2012)

Equation A3.3 can be split into separate equations and rearranged to end up with a
quadratic function as:
𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0
Where:
𝜌
𝑥=
𝑟𝑜

More information can be found inside the code, in the function calculateRhoRl.

4.1.5 Rolling resistance (My)


The base equation in the book is equation 4.E70 on page 182 of the book. With the
ISO sign convention the rolling resistance should be negative and increase (in
absolute terms) with the speed. Equation 4.E70 diverges from TNO and there are two
differences with the formulation of the paper
In Figure 18, is shown how the paper uses Fzo instead of Fz and includes a negative
sign.

Figure 18: Rolling resistance formulae (Pacejka, 2012)

By using equation A48 from the paper, a perfect match with TNO it’s achieved.

14 | P a g e
4.1.6 Aligning torque (Mz)
There is a possible typo in the book on equation 4.E40 of page 182. In this equation
it’s used the parameter QBZ6 which doesn't exist in the standard TIR files, but neither
appears on page 190 or on page 615, where an example full set of parameters is given.

Furthermore, in the Bt formulation of the paper (equation A58), gamma (camber


angle), is not squared.
The formulation from the book was causing bad correlation when negative camber
angles where used as inputs. For those reasons, equation 4.E40 has been replaced by
equation A58.

Figure 19: Bt equation (Pacejka, 2012)

The coefficient Dt (equation 4.E43) affects the pneumatic trail (t) and the self-
aligning torque (Mz). Here there is another discrepancy caused by the sign of the
camber angle. This difference comes from the term QDZ3, which in the original
equation is multiplied by the absolute value of gamma. But in the paper equation, the
absolute term is not written. Equation (A60) from the paper gives a perfect match
with TNO. Keep in mind that the equations from the paper don't include turn slip
effects. So the term zeta5 has been manually added into mfeval to include this effect.

Figure 20: Dt equation (Pacejka, 2012)

The equations 4.E78 and 4.E77 are not used due to small differences discovered at
negative camber angles with the TNO solver. Instead equations A54 and A55 from
the paper are used. These equations have an effect on the pneumatic trail calculation.

Finally, the last difference was discovered using the scaling factors. The coefficient s
(Equation 4.E76) determines the effect of Fx into Mz. The book uses Fzo_prime, and
the paper Fzo in their formulations. Using the paper definition and multiplying the
pneumatic trail (t) by LFZO gives a good correlation with TNO.

15 | P a g e
Figure 21: s and alpha_eq equations (Pacejka, 2012)

Figure 22: Scaling factor LFZO in the pneumatic trail equation.

4.1.7 Overturning moment (Mx)


The base line equation was 4.E69 on page 182. This equation works fine in most of
the cases, but for some TIR files the outputs diverged from the TNO dteval.m as
shown in Figure 24.

Figure 23: O verturning moment (Pacejka, 2012)

16 | P a g e
Figure 24: Mx book vs paper vs TNO

17 | P a g e
After implementing the equation #49 published in the draft paper of Besselink (which
has a completely different formulation), a perfect correlation with TNO was achieved.
The draft paper of Besselink (Not the official paper), can be downloaded from:

https://pure.tue.nl/ws/files/3139488/677330157969510.pdf

purl.tue.nl/677330157969510.pdf

Figure 25: O verturning moment (Besselink, 2010)

There are three extra parameters used in this alternative formulation that are not
present in the “original” equation 4.E69, which are:

 QSX12: Camber squared induced overturning moment


 QSX13: Lateral force induced overturning moment
 QSX14: Lateral force induced overturning moment with camber

These parameters help to improve the fitting, especially at high loads where the
overturning moment sign is flipped.

4.1.8 Turn slip equations


It was empirically discovered that the turn slip is affected by the slip angle in the TNO
solver. When the slip angle is not equal to zero the turn slip (phit) is slightly lower.
To get the same output than TNO it is used the equation shown below.

Figure 26. Turn slip modification

This modification to the turn slip is only applied if the use mode +100 is used (include
limit checks)

In Figure 27 is shown a comparison between the input turn slip, the output turn slip
from TNO and the output turn slip from mfeval applying the equation from Figure 26.
The conditions to produce this graph are constant vertical load, zero slip ratio, a
sweep of slip angle (±17.10 degrees), zero camber angle, constant turn slip, constant
speed and constant pressure.

18 | P a g e
Figure 27. Turn slip data modification

In chapter 2.2 "Definition of tire input quantities" in the Pacejka book, it is assumed
that the z-axis of the road coordinate system "points downward normal to the road
plane" (p. 62). Due to this definition, Pacejka introduces the minus sign for the spin
slip so that a positive spin leads to a positive torque Mz (p. 68).But in CarMaker (and
other MBS software), the road coordinate system is orientated differently. The z-axis
points upward to the road plane. Thus switchixng the signs is not needed here and
equation 4.75 has been modified as shown:

Figure 28. Modification of e quation 4.75

The parameters Kya0_prime is not defined in the book. Kya0 is the cornering stiffness
when the camber angle is zero (Gamma=0) which is again the product of the
coefficients By, Cy and Dy at zero camber angle. And it is assumed that Kya0_prime
can be calculated like Kya_prime as shown in equation 4.E39.

Figure 29. No definition for Kyao_prime

Figure 30. Kya_prime definition

19 | P a g e
Kya0 has been calculated as shown below:

Kyao = PKY1.*Fzo_prime.*(1 + PPY1.*dpi).*(1 -


PKY3.*abs(0)).*sin(PKY4.*atan((Fz./Fzo_prime)./((PKY2+PKY5.*0.^2).*(1
+PPY2.*dpi)))).*zeta3.*LKY;

Finally the equations 4.93 (Drp) and 4.104 (zeta7) have been modified to operate with
-phi, so that a positive spin leads to a positive torque Mz (p. 68).

Drp = DDrp.*sin(CDrp.*atan(BDrp.*Ro.*(-phi) - EDrp.*(BDrp.*Ro.*(-phi)


- atan(BDrp.*Ro.*(-phi))))); % Eqn (4.93) Page 187 - Book]

x = Mzp90./(-abs(Drp)+epsilonr.*signDrp); % Argument of Eqn (4.104)


[sign(Drp) term is explained on page 177]

20 | P a g e
5 Future work and support
The MFeval Toolbox is maintained by the Tyre CAE Team of Jaguar Land Rover.

If you find any bugs whilst working with MFeval or you would like to suggest
enhancements for a future release then please email TyreCAE@jaguarlandrover.com
or mfurlant@jaguarlandrover.com A member of the Tyre CAE Team will then be in
touch to discuss your request and agree a date when your bug/enhancement will be
dealt with.

If you would like to contribute to the development of MFeval or you already have
some useful code that you would like to be part of the toolbox then please contact
TyreCAE@jaguarlandrover.com or mfurlant@jaguarlandrover.com

In the next release of MFeval the following items will be reviewed:

 Low speed model is not perfect, review the effect on pneumatic trail
(t) and aligning torque (Mz)
 Turn slip equations needs to be reviewed, especially for Mz

21 | P a g e
6 Validation
The outputs of mfeval have been validated against the outputs from the official TNO
solver "dteval" (MF-Tyre MF-Swift 6.1.2.1) using the same input conditions with
USE_MODE = 111 (No turn slip, no alpha star and with coefficient checks)

The validation shows a perfect match between mfeval and dteval. Images can be
found under the folder “Validation” in the installation path.

22 | P a g e

You might also like