0% found this document useful (0 votes)
13 views30 pages

Annex

MBD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views30 pages

Annex

MBD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Annex

Layout design of an electric vehicle


powertrain and simulation of energy
deployment using torque vectoring
techniques.

Autor: Ignacio Vicente Basanta

Director: Toni Garcia Espinosa

Undergraduate degree: Grado en ingeniería en tecnologías industriales

Delivery date: June 2019


Contents

1 Matlab model architecture 4


1.1 Drivetrain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Traction control Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Torque vectoring Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Inverter and motor controller . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 PMAC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 Gearbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.7 Tires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.8 Environment model block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Matlab code 9
2.1 Matlab Initiation Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Matlab Code for Plotting Results . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3 Matlab Code for comparing vehicle layouts . . . . . . . . . . . . . . . . . . 25

2
List of Figures

1.1 Basic components of the Simulink model. . . . . . . . . . . . . . . . . . . . 4


1.2 Powertrain components of the Simulink model. . . . . . . . . . . . . . . . . 4
1.3 Traction control block schematic from Simulink model. . . . . . . . . . . . . 5
1.4 Torque vectoring block schematic from Simulink model. . . . . . . . . . . . 5
1.5 Schematic of the Simulink inverter block for the vehicle model. . . . . . . . 6
1.6 Detail of the inverter operation, where the the rotor phase angle and motor
current are used to obtain the estimated output current of the inverter. . . 6
1.7 Implements a limiter to keep the inverter power output bellow the motor’s
torque and power limits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.8 Block representing the PMSM motor operation, where the currents gener-
ated by the inverter block are transformed into mechanical torque. . . . . . 7
1.9 PMAC Ideal motor block, which converts the three phase input current into
a torque output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.10 Block schematic of of the PMSM losses model . . . . . . . . . . . . . . . . . 7
1.11 Schematic of the gearbox block for the vehicles model . . . . . . . . . . . . 7
1.12 Schematic of the tire block for the vehicles model . . . . . . . . . . . . . . . 8
1.13 Schematic of the environment block tasked with accounting for rolling re-
sistance, aerodynamic drag and road incline . . . . . . . . . . . . . . . . . . 8

3
Matlab model architecture

Figure 1.1: Basic components of the Simulink model.

1.1 Drivetrain

Figure 1.2: Powertrain components of the Simulink model.

4
1.2. Traction control Block 5

1.2 Traction control Block

Figure 1.3: Traction control block schematic from Simulink model.

1.3 Torque vectoring Block

Figure 1.4: Torque vectoring block schematic from Simulink model.


6 Matlab model architecture

1.4 Inverter and motor controller

Figure 1.5: Schematic of the Simulink inverter block for the vehicle model.

Figure 1.6: Detail of the inverter operation, where the the rotor phase angle and motor
current are used to obtain the estimated output current of the inverter.

Figure 1.7: Implements a limiter to keep the inverter power output bellow the motor’s
torque and power limits.
1.5. PMAC motor 7

1.5 PMAC motor

Figure 1.8: Block representing the PMSM motor operation, where the currents generated
by the inverter block are transformed into mechanical torque.

Figure 1.9: PMAC Ideal motor block, which converts the three phase input current into
a torque output

Figure 1.10: Block schematic of of the PMSM losses model

1.6 Gearbox

Figure 1.11: Schematic of the gearbox block for the vehicles model
8 Matlab model architecture

1.7 Tires

Figure 1.12: Schematic of the tire block for the vehicles model

1.8 Environment model block

Figure 1.13: Schematic of the environment block tasked with accounting for rolling resis-
tance, aerodynamic drag and road incline
Matlab code

2.1 Matlab Initiation Code

1 %% l o a d d r i v i n g c y c l e s
2 clear all ;
3 close all ;
4 clc ;
5

7 %% S i m u l a t i o n Parameters
8 tstop = 780; % s i m u l a t i o n run time [
sec ]
9 tstep = .01; % maximum s i m u l a t i o n
step [ sec ]
10

11 %% D r i v e r model p a r a m e t e r s y . q
12 Ti = 5 0 ; % i n t e g r a l time c o n s t a n t
13 Kv = 6 5 0 ; % proportional gain
14

15

16 %% T r a n s m i s s i o n Parameters
17

18 g r a t i o =5.5;
19 g_rat_electric = 3.06;
20

21 %% Wheel Parameters
22 rw = 0 . 6 6 8 / 2 ; % wheel r a d i u s f o r
275/40/ r 1 8 t i r e [m]
23

24 %% C h a s i s s p a r a m e t e r s
25 S_weight =800;
26

27 %% B a t t e r y c e l l s data %Based on data from a


samsung i n r 50E c e l l
28 cell_capacity =5.0; %c a p a c i t y o f a s i n g l e

9
10 Matlab code

21700 c e l l [ Ah ]
29 cell_nom_v = 3 . 7 ; %c e l l ’ s nominal v o l t a g e
30 cell_max_v = 4 . 2 ; %c e l l ’ s maximum
a l l o w a b l e v o l t a g e [V]
31 cell_cutoff_v =3.2; %c e l l ’ s l o w e r cut−o f f
v o l t a g e [V]
32 c e l l _ e n e r g y=c e l l _ c a p a c i t y ∗ cell_nom_v ; %t o t a l c e l l e n e r g y [Wh]
33 cell_nom_curr =15; %c e l l ’ s maximum
c o n t i n u o u s c u r r e n t [A]
34 cell_max_curr =20; %c e l l ’ s maximum
i n t a n t a n e u s c u r r e n t [A]
35

36

37

38 success = false ;
39 while ~ success
40 b = i n p u t ( ’ S e l e c t t h e g e a r r a t i o f o r t h e v e h i c l e (0= d e f a u l t ,
1=s h o r t , 2=medium o r 3= t a l l ) ’);
41 switch b
42 case 0
43 d i s p ( ’ The g e a r r a t i o w i l l remain u n a l t e r e d ( 5 . 5 : 1 ) ’
)
44 success = true ;
45 case 1
46 g r a t i o =3;
47 d i s p ( ’ The g e a r r a t i o s e l e c t e d i s 3 : 1 ’ )
48 success = true ;
49 case 2
50 g r a t i o =5;
51 d i s p ( ’ The g e a r r a t i o s e l e c t e d i s 5 : 1 ’ )
52 success = true ;
53 case 3
54 g r a t i o =7;
55 d i s p ( ’ The g e a r r a t i o s e l e c t e d i s 7 : 1 ’ )
56 success = true ;
57 otherwise
58 d i s p ( ’ P l e a s e , s e l e c t one o f t h e a v a i l a b l e o p t i o n s ’ )
59 success = false ;
60 end
61 end
62

63 success = false ;
64 while ~ success
2.1. Matlab Initiation Code 11

65 b = i n p u t ( ’ S e l e c t t h e d e s i r e d b a t t e r y pack s i z e (1= s m a l l , 2=
medium o r 3= l a r g e ) ’);
66 switch b
67 case 1
68 d i s p ( ’ The b a t t e r y s i z e i s 30 kWh ’ )
69 batt_cap = 30
70 success = true ;
71 case 2
72 d i s p ( ’ The b a t t e r y s i z e i s 50 kWh ’ )
73 batt_cap = 5 0 ;
74 success = true ;
75 case 3
76 d i s p ( ’ The b a t t e r y s i z e i s 70 kWh ’ )
77 batt_cap = 7 0 ;
78 success = true ;
79 otherwise
80 d i s p ( ’ P l e a s e , s e l e c t one o f t h e a v a i l a b l e o p t i o n s ’ )
81 success = false ;
82 end
83 end
84 success = false ;
85 while ~ success
86 b = i n p u t ( ’ S e l e c t t h e number o f motors f o r t h e FRONT a x l e (
choose 0 , 1 or 2) ’);
87 switch b
88 case 0
89 d i s p ( ’ The f r o n t a x l e o f t h e v e h i c l e i s not d r i v e n
by any motor ’ )
90 front_motor = 0 ;
91 success = true ;
92 case 1
93 d i s p ( ’ Front a x l e has 1 motor powering both w h e e l s ’ )
94 front_motor = 1 ;
95 success = true ;
96 case 2
97 d i s p ( ’ Front a x l e has 2 i n d i v i d u a l motors on each
wheel ’ )
98 front_motor = 2 ;
99 success = true ;
100 otherwise
101 d i s p ( ’ P l e a s e , s e l e c t one o f t h e a v a i l a b l e o p t i o n s ’ )
102 success = false ;
103 end
12 Matlab code

104 end
105 success = false ;
106 while ~ success
107 b = i n p u t ( ’ S e l e c t t h e number o f motors f o r t h e REAR a x l e (
choose 0 , 1 or 2) ’);
108 switch b
109 case 0
110 d i s p ( ’ The Rear a x l e o f t h e v e h i c l e i s not d r i v e n by
any motor ’ )
111 rear_motor = 0 ;
112 success = true ;
113 case 1
114 d i s p ( ’ Rear a x l e has 1 motor powering both w h e e l s ’ )
115 rear_motor = 1 ;
116 success = true ;
117 case 2
118 d i s p ( ’ Rear a x l e has 2 i n d i v i d u a l motors on each
wheel ’ )
119 rear_motor = 2 ;
120 success = true ;
121 otherwise
122 disp ( ’ Please , s e l e c t one o f t h e a v a i l a b l e o p t i o n s ’ )
123 success = false ;
124 end
125 end
126

127 %% B a t t e r y pack c h r a c t e r i s t i c s
128

129 pack_desired_v =540;


130 b a t t _ c e l l s=roundn ( ( ( batt_cap ∗1 e3 ) / c e l l _ e n e r g y ) , 1 ) ;
%C a l c u l a t e s number o f b a t t e r y c e l l s based on c h o s e n b a t t e r y
size
131 c e l l _ s e r i e s=roundn ( ( pack_desired_v / cell_nom_v ) , 0 ) ;
%number o f c e l l s a r r a n g e i n s e r i e s c o n n e c t i o n
132 batt_nom_v=c e l l _ s e r i e s ∗ cell_nom_v ;
%naminal b a t t e r y v o l t a g e ( assuming 4 . 2 v a s maximum c e l l
voltage )
133 batt_max_v=c e l l _ s e r i e s ∗ cell_max_v ;
%naminal b a t t e r y v o l t a g e ( assuming 4 . 2 v a s maximum c e l l
voltage )
134 c e l l s _ p a r a l l e l=roundn ( ( b a t t _ c e l l s / c e l l _ s e r i e s ) , 1 ) ;
%c a l c u l a t e s t h e number o f p a r a l l e a r r a n g e d c e l l s
135 Capacity=batt_cap ∗1 e3 ∗ 3 6 0 0 ;
2.1. Matlab Initiation Code 13

%t r a n s f o r m s t h e c h o s e n b a t t e r y e n e r g y from kWh t o J u l e s
136 SOC_0 = 8 0 ;
% I n i t i a l battery s t a t e of charge [%]
137 Vbat=c e l l _ s e r i e s ∗ 3 . 7 ;
%b a t t e r y pack nominal v o l t a g e [V]
138

139

140 %% C a l c u l a t e s t h e w e i g h t o f t h e b a t t e r y
141

142

143 c e l l s _ w e i g h t =( b a t t _ c e l l s ∗ 0 . 0 6 9 ) ;
144 batt_weight=c e l l s _ w e i g h t ∗ 1 . 5 ;
%b a t t e r y pack w e i g h t asumming each c e l l w e i g h t s 69 g
145 max_curr=cell_max_curr ∗ c e l l s _ p a r a l l e l ;
%max b a t t e r y output c u r r e n t assuming peack d i s c h a r g e
o f 15A
146 nom_curr=cell_nom_curr ∗ c e l l s _ p a r a l l e l ;
%nominal b a t t e r y output c u r r e n t assuming peack
d i s c h a r g e o f 10A
147 max_batt_pwr=max_curr∗batt_nom_v∗1 e −3;
%maximum b a t t e r y power output i n kW
148 batt_pwr=nom_curr∗batt_nom_v∗1 e −3;
%nominal b a t t e r y power output
149

150 %% I n v e r t e r p a r a m e t e r s
151 inv_eff =0.98;
152 regen_eff =0.8;
153

154 %% E l e c t r i c Motor Parameters


155 l o a d MotorEff ;
%
E l e c t r i c Motor E f f i c i e n c y Data
156 Ke = 0 . 6 0 7 ;
%
Torque Constant [Nm/A]
157 Pe_max = 160 e3 ;
%
Maximum Motor Power [W]
158 Vbase = 1 4 . 3 0 ;
%
Base s p e e d [m/ s ]
159 Te_max_electric = Pe_max∗rw/ g _ r a t _ e l e c t r i c / Vbase ;
% Maximum motor t o r q u e e l e c t r i c [Nm]
14 Matlab code

160 Fv_max_electric = Te_max_electric ∗ g _ r a t _ e l e c t r i c /rw ;


% Maximum v e h i c l e t r a c t i v e f o r c e e l e c t r i c [
N]
161 Fv_max = 2∗ Fv_max_electric ;
% Maximum v e h i c l e
t r a c t i v e f o r c e [N]
162 Te_max = 2∗ Te_max_electric ;
% Maximum motor
t o r q u e [Nm]
163 Br_th =0.3∗ Fv_max_electric ;
% Brake
t h e r s s h o l s e x p r e s s e d a s a p e r c e n t a g e o f Fv_max_electric
164

165

166 %% C a l c u l a t e s t h e t o t a l mass o f t h e v e h i c e l g i v e n p r e v i o u s
inputs
167 base_weight = 1 1 0 0 ; %w e i g h t
of the base v e h i c l e c h a s i s witchout powertrain
168 M_weight =140; %wheig
f o r each added motor i n kg ( t e s l a motor taken a s r e f e r e n c e )
169 motor_weight = M_weight ∗ ( rear_motor+front_motor ) ; %
c a l c u l a t e s t h e t o t a l w e i g h t o f a l l motors e x i s t e n t i n t h e
vehicle
170 Mv = ( base_weight+batt_weight+motor_weight ) ; %
c a l c u l a t e s t h e t o t a l v e h i c l e w e i g h t used f o r t h e dynamic
equations
171

172 %% C a l c u l a t e s t h e t i r e v e r t i c a l f o r c e
173

174

175 i f ( front_motor == 1 | | front_motor == 2 ) && rear_motor


== 0
176 weight_dist =0.3; %w e i g h t
r a t i o f o r the r e a r axle
177 F z _ t i r e =(Mv∗ w e i g h t _ d i s t ∗ 0 . 5 ) ∗ 9 . 8 1 ; %
c a l c u l a t e s v e r t i c a l f o r c e a c t i n g on an i n d i v i d u a l
tire
178 X=[ ’ I n d i v i d u a l t i r e f o r c e i s ’ , num2str ( F z _ t i r e ) , ’ N
’] ;
179 Y=[ ’ V e h i c l e w e i g h t i s ’ , num2str (Mv) , ’ kg , with a
b a t t e r y c a p a c i t y o f ’ , num2str ( batt_cap ∗1 e3 ) , ’ Wh
’] ;
180 Z=[ ’ B a t t e r y maximum c o n t i n u p u s c u r r e n t i s ’ , num2str (
2.1. Matlab Initiation Code 15

nom_curr ) , ’ A with a maximum power o f ’ , num2str (


batt_cap ) , ’ kW’ ] ;
181 d i s p (X)
182 d i s p (Y)
183 d i s p (Z )
184 e l s e i f ( rear_motor == 1 | | rear_motor == 2 ) &&
front_motor == 0
185 weight_dist =0.65; %w e i g h t
r a t i o f o r the r e a r axle
186 F z _ t i r e =(Mv∗ w e i g h t _ d i s t ∗ 0 . 5 ) ∗ 9 . 8 1 ; %
c a l c u l a t e s v e r t i c a l f o r c e a c t i n g on an i n d i v i d u a l
tire
187 X=[ ’ I n d i v i d u a l t i r e f o r c e i s ’ , num2str ( F z _ t i r e ) , ’ N
’] ;
188 Y=[ ’ V e h i c l e w e i g h t i s ’ , num2str (Mv) , ’ kg , with a
b a t t e r y c a p a c i t y o f ’ , num2str ( batt_cap ∗1 e3 ) , ’ Wh
’ ];
189 Z=[ ’ B a t t e r y maximum c o n t i n u o u s c u r r e n t i s ’ , num2str (
nom_curr ) , ’ A with a maximum power o f ’ , num2str (
batt_cap ) , ’ kW’ ] ;
190 d i s p (X)
191 d i s p (Y)
192 d i s p (Z )
193 e l s e i f ( front_motor == 1 | | front_motor == 2 ) && (
rear_motor == 1 | | rear_motor == 2 )
194 weight_dist =0.45; %w e i g h t
r a t i o f o r the r e a r axle
195 F z _ t i r e = (Mv ∗ w e i g h t _ d i s t ∗ 0 . 5 ) ∗ 9 . 8 1 ;
%c a l c u l a t e s v e r t i c a l f o r c e a c t i n g on an
individual tire
196 X=[ ’ I n d i v i d u a l t i r e f o r c e i s ’ , num2str ( F z _ t i r e ) , ’ N
’] ;
197 Y=[ ’ V e h i c l e w e i g h t i s ’ , num2str (Mv) , ’ kg , with a
b a t t e r y Capacity o f ’ , num2str ( batt_cap ∗1 e3 ) , ’ Wh
’ ];
198 Z=[ ’ B a t t e r y maximum c o n t i n u o s c u r r e n t i s ’ , num2str (
nom_curr ) , ’ A with a maximum power o f ’ , num2str (
batt_pwr ) , ’ kW’ ] ;
199 d i s p (X)
200 d i s p (Y)
201 d i s p (Z )
202 end
203
16 Matlab code

204

205

206 %% DC−DC C o n v e r t e r Parameters


207 eta_DC = . 9 8 5 ; % DC−DC C o n v e r t e r E f f i c i e n c y (
constant )
208 Vbus_ref = 6 0 0 ; % DC Bus V o l t a g e R e f e r e n c e ( c o n s t a n t
) [V]
209

210 %% I n v e r t e r Parameters
211 eta_inv = . 9 6 5 ; % Inverter E f f i c i e n c y ( constant )
212

213 %% Torque v e c t o r i n g p a r a m e t e r s
214 opt_slip =0.18; %optimum t i r e s l i p r a t i o
215 Tv_gain =800;
216

217 %% V e h i c l e p h y s i c a l p a r a m e t e r s
218 Mv = 1 4 2 0 ; % V e h i c l e curb w e i g h t + 120 kg
p a s s e n g e r and c a r g 0
219 W_d = 0 . 5 ; % V e h i c l e s weight d i s t r i b u t i o n fore −
a f t (0 −1)
220 Cd = 0 . 2 6 ; % C o e f f i c i e n t o f Drag
221 Cr = 0 . 0 1 ; % Coefficient of Friction
222 Av = 2 . 7 5 ; % Front a r e a [m^ 2 ]
223 rho_air = 1 . 2 0 4 ; % Air d e n s i t y [ kg /m^ 3 ]
224 g r a d e =0; % Grade o f t h e road � [ ]
225 grav = 9 . 8 1 ;
226 motoreff_T=l i n s p a c e ( 0 , 3 0 0 , 1 0 1 ) ;
227

228 %% Sample t i m e s
229 s_time = 0 . 0 1 ;
230 %% t i r e model p a r a m e t e r s f o r f r i c t i o n c a l c u l a t i o n
231

232 %dry road


233 b_d = 10.0;
234 c_d = 1.9;
235 d_d = 1;
236 e_d = 0.97;
237

238 %wet road


239 b_w = 1 2 ;
240 c_w = 2 . 3 ;
241 d_w = 0 . 8 2 ;
242 e_w = 1 ;
2.1. Matlab Initiation Code 17

243

244 %snowy road


245 b_s = 5 ;
246 c_s = 2 ;
247 d_s = 0 . 3 ;
248 e_s = 1 ;
249

250 %i c e road
251 b_i = 4 ;
252 c_i = 2 ;
253 d_i = 0 . 1 ;
254 e_i = 1 ;
255

256 %% T i r e s e l e c t o r
257

258 %%s e l e c t s s u r f a c e f o r l e f t t i r e
259 %c l c
260

261 t i r e _ L = i n p u t ( ’ what i s t h e l e f t t i r e ’ ’ s s u r f a c e ? ( d=dry , w=wet ,


s=snow , i=i c e ) : ’ , ’ s ’ ) ;
262 i f strcmp ( tire_L , ’ s ’ )
263 d i s p ( ’ L e f t t i r e s u r f a c e i s snow ’ )
264 b_l=b_s ;
265 c_l=c_s ;
266 d_l=d_s ;
267 e_l=e_s ;
268 e l s e i f strcmp ( tire_L , ’ d ’ )
269 d i s p ( ’ L e f t t i r e s u r f a c e i s dry ’ )
270 b_l=b_d ;
271 c_l=c_d ;
272 d_l=d_d ;
273 e_l=e_d ;
274 e l s e i f strcmp ( tire_L , ’ i ’ )
275 disp ( ’ Left t i r e surface i s ice ’ )
276 b_l=b_i ;
277 c_l=c_i ;
278 d_l=d_i ;
279 e_l=e_i ;
280 e l s e i f strcmp ( tire_L , ’w ’ )
281 d i s p ( ’ Right t i r e s u r f a c e i s wet ’ )
282 b_l=b_w ;
283 c_l=c_w ;
284 d_l=d_w ;
18 Matlab code

285 e_l=e_w ;
286 else
287 d i s p ( ’ S e l e c t a c o r r e c t s u r f a c e type f o r t h e l e f t t i r e . ’ )
288

289 end
290

291

292 tire_R = i n p u t ( ’ what i s t h e r i g h t t i r e ’ ’ s s u r f a c e ? ( d=dry , w=wet


, s=snow , i=i c e ) : ’ , ’ s ’ ) ;
293 i f strcmp ( tire_R , ’ s ’ )
294 d i s p ( ’ Right t i r e s u r f a c e i s snow ’ )
295 b_r=b_s ;
296 c_r=c_s ;
297 d_r=d_s ;
298 e_r=e_s ;
299 e l s e i f strcmp ( tire_R , ’ d ’ )
300 d i s p ( ’ Right t i r e s u r f a c e i s dry ’ )
301 b_r=b_d ;
302 c_r=c_d ;
303 d_r=d_d ;
304 e_r=e_d ;
305 e l s e i f strcmp ( tire_R , ’ i ’ )
306 d i s p ( ’ Right t i r e s u r f a c e i s i c e ’ )
307 b_r=b_i ;
308 c_r=c_i ;
309 d_r=d_i ;
310 e_r=e_i ;
311 e l s e i f strcmp ( tire_R , ’w ’ )
312 d i s p ( ’ Right t i r e s u r f a c e i s wet ’ )
313 b_r=b_w ;
314 c_r=c_w ;
315 d_r=d_w ;
316 e_r=e_w ;
317 else
318 d i s p ( ’ S e l e c t a c o r r e c t s u r f a c e type f o r t h e r i g h t t i r e . ’ )
319 end
2.2. Matlab Code for Plotting Results 19

2.2 Matlab Code for Plotting Results

1 close all ;
2

3 f i g u r e s d i r = ’ /home/ i g n a c i o / Dropbox /Q2_2018_19_drop/TFG/ T h e s i s /


Images / ’ ;
4

5 success = false ;
6 while ~ success
7 b = i n p u t ( ’Do you want t o s a v e t h e g e n e r a t e d p l o t s ? 1=y e s 2=
no ’);
8 switch b
9 case 1
10 d i s p ( ’ The p l o t s w i l l be saved t o s e l e c e d f o l d e r ’ )
11 save = 1 ;
12 success = true ;
13 case 2
14 d i s p ( ’ The p l o t s w i l l not be saved ’ )
15 save = 2 ;
16 success = true ;
17 otherwise
18 d i s p ( ’ P l e a s e , s e l e c t one o f t h e a v a i l a b l e o p t i o n s ’ )
19 success = false ;
20 end
21 end
22

23 figure (1) ;
24 h o l d on ;
25 p l o t ( s p e e d s . time / 6 0 , R_speed . s i g n a l s . v a l u e s ( : , 1 ) ∗ 3 . 6 , ’ b ’ , ’
LineWidth ’ , 0 . 7 ) ;
26 plot1 . Color (4) = 0 . 2 ;
27 p l o t ( s p e e d s . time / 6 0 , L_speed . s i g n a l s . v a l u e s ( : , 1 ) ∗ 3 . 6 , ’ r ’ , ’
LineWidth ’ , 0 . 6 ) ;
28 plot1 . Color (4) = 0 . 2 ;
29 p l o t ( s p e e d s . time / 6 0 , Cm_speed . s i g n a l s . v a l u e s ( : , 1 ) ∗ 3 . 6 , ’ y ’ , ’
LineWidth ’ , 0 . 5 ) ;
30 p l o t ( s p e e d s . time / 6 0 , Ve_speed . s i g n a l s . v a l u e s ( : , 1 ) ∗ 3 . 6 , ’ k ’ , ’
LineWidth ’ , 0 . 4 ) ;
31 l e g e n d ( ’ Right wheel s p e e d ’ , ’ L e f t wheel s p e e d ’ , ’ R e f e r e n c e Speed ’ ,
’ V e h i c l e sp e e d ’ ) ;
32 t i t l e ( ’ Vehicle speeds ’ ) ;
33 y l a b e l ( ’ Speed [ km/h ] ’ ) ;
34 s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
20 Matlab code

35 xlim ( [ 0 8 ] ) ;
36 g r i d on ;
37 i f s a v e==1
38 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ v e h i c l e _ s p e e d s ’ ) , ’ png ’ ) ;
39 else
40 end
41

42 figure (2) ;
43 h o l d on ;
44 p l o t ( F o r c e s . time / 6 0 , L e f t _ t o r q u e . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’
LineWidth ’ , 1 ) ;
45 p l o t ( F o r c e s . time / 6 0 , Right_torque . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ , ’
LineWidth ’ , 0 . 7 ) ;
46 p l o t ( F o r c e s . time / 6 0 , Commanded_torque . s i g n a l s . v a l u e s ( : , 1 ) , ’ k ’ ,
’ LineWidth ’ , 0 . 4 ) ;
47 l e g e n d ( ’ L e f t t i r e t o r q u e ’ , ’ Right t i r e t o r q u e ’ , ’ Torque command ’
);
48 t i t l e ( ’ V e h i c l e output t o r q u e ’ ) ;
49 y l a b e l ( ’ Torque [Nm] ’ ) ;
50 x l a b e l ( ’ Time [ s ] ’ ) ;
51 s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
52 xlim ( [ 0 8 ] ) ;
53 g r i d on ;
54 i f s a v e==1
55 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ torque_output ’ ) , ’ png ’ ) ;
56 else
57 end
58

59 figure (3) ;
60 h o l d on ;
61 p l o t ( d i s t . s i g n a l s . v a l u e s ( : , 1 ) , SOC. s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’
LineWidth ’ , 1 . 5 ) ;
62 t i t l e ( ’ B a t t e r y SOC vs . D i s t a n c e t r a v e l l e d ’ ) ;
63 l e g e n d ( ’ B a t t e r y SOC] ’ ) ;
64 y l a b e l ( ’ B a t t e r y SOC [ % ] ’ ) ;
65 x l a b e l ( ’ D i s t a n c e [ km ] ’ ) ;
66 g r i d on ;
67 i f s a v e==1
68 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ t e v e l l e d _ d i s t a n c e ’ ) , ’ png ’ ) ;
69 else
70 end
71 %
72 % figure (4) ;
2.2. Matlab Code for Plotting Results 21

73 % h o l d on
74 % p l o t (P . time / 6 0 , P . s i g n a l s . v a l u e s ( : , 1 )−Pmec . s i g n a l s . v a l u e s ( : , 1 )
, ’ b ’ , ’ LineWidth ’ , 1 . 5 ) ;
75 % p l o t ( Pmec . time / 6 0 , Pmec . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ , ’ LineWidth ’ ,
1.5) ;
76 % l e g e n d ( ’ P e l e c t r i c ’ , ’ Pmecanic ’ ) ;
77 % t i t l e ( ’ V e h i c l e power output ’ ) ;
78 % y l a b e l ( ’ I n s t . Power [kW] ’ ) ;
79 % s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
80 % g r i d on ;
81 % i f s a v e==1
82 % s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ power_output ’ ) , ’ png ’ ) ;
83 % else
84 % end
85

86 figure (4) ;
87 h o l d on
88 p l o t ( a e r o _ l o s s e s . time / 6 0 , a e r o _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ ,
’ LineWidth ’ , 1 ) ;
89 p l o t ( a e r o _ l o s s e s . time / 6 0 , r o l l i n g _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’m
’ , ’ LineWidth ’ , 1 ) ;
90 p l o t ( a e r o _ l o s s e s . time / 6 0 , i n c l i n e _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’ r
’ , ’ LineWidth ’ , 0 . 7 ) ;
91 p l o t ( a e r o _ l o s s e s . time / 6 0 , s p e e d s . s i g n a l s . v a l u e s ( : , 1 ) , ’ k ’ , ’
LineWidth ’ , 1 . 2 ) ;
92 l e g e n d ( ’ Aero l o s s e s ’ , ’ R o l l i n g r e s i t a n c e l o s s e s ’ , ’ I n c l i n e l o s s e s
’ , ’ V e h i c l e sp e e d ’ ) ;
93 t i t l e ( ’ Power l o s s e s due t o t h e environment ’ ) ;
94 y l a b e l ( ’ Power [kW] ’ ) ;
95 x l a b e l ( ’ Time [ s ] ’ ) ;
96 s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
97 xlim ( [ 0 8 ] ) ;
98 g r i d on ;
99 i f s a v e==1
100 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ p o w e r _ l o s s e s _ v e h i c l e ’ ) , ’ png ’ ) ;
101 else
102 end
103

104 figure (5) ;


105 h o l d on ;
106 p l o t ( d c d c _ l o s s e s . time / 6 0 , m o t o r _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’ k ’ ,
’ LineWidth ’ , 0 . 3 ) ;
107 p l o t ( d c d c _ l o s s e s . time / 6 0 , g e a r b o x _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’ b
22 Matlab code

’ , ’ LineWidth ’ , 0 . 5 ) ;
108 p l o t ( d c d c _ l o s s e s . time / 6 0 , i n v e r t e r _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’
m’ , ’ LineWidth ’ , 0 . 5 ) ;
109 p l o t ( d c d c _ l o s s e s . time / 6 0 , d c d c _ l o s s e s . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ ,
’ LineWidth ’ , 0 . 5 ) ;
110 t i t l e ( ’ Drivetrain losses ’ ) ;
111 l e g e n d ( ’ Motor l o s s e s ’ , ’ Gearbox l o s s e s ’ , ’ I n v e r t e r l o s s e s ’ , ’ DcDc
losses ’) ;
112 y l a b e l ( ’ Power l o s s e s [kW] ’ ) ;
113 x l a b e l ( ’ Time [ min ] ’ ) ;
114 xlim ( [ 0 8 ] ) ;
115 g r i d on ;
116 i f s a v e==1
117 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ d r i v e t r a i n _ l o s s e s ’ ) , ’ png ’ ) ;
118 else
119 end
120

121 figure (6) ;


122 h o l d on ;
123 p l o t ( I b a t 1 . time / 6 0 , I a b c . s i g n a l s . v a l u e s ( : , 1 ) , ’ y ’ , ’ LineWidth ’ ,
0.5) ;
124 p l o t ( I i n v . time / 6 0 , I i n v . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’ LineWidth ’ ,
0.5) ;
125 p l o t ( I b a t . time / 6 0 , I b a t . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ , ’ LineWidth ’ ,
0.5) ;
126

127 l e g e n d ( ’ B a t t e r y Current ’ , ’ I n v e r t e r Input Current ’ , ’ I n v e r t e r


Output Current ’ ) ;
128 t i t l e ( ’ V e h i c l e c u r r e n t draw ’ ) ;
129 y l a b e l ( ’ Current [A] ’ ) ;
130 x l a b e l ( ’ time [ min ] ’ ) ;
131 xlim ( [ 0 8 ] ) ;
132 g r i d on ;
133 i f s a v e ==1
134 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ c u r r e n t _ p l o t ’ ) , ’ png ’ ) ;
135 else
136 end
137

138 figure (7) ;


139 h o l d on ;
140 x =1:10:1200;
141 y =23700./ x ;
142 plot (x , y) ;
2.2. Matlab Code for Plotting Results 23

143 a x i s ( [ 0 1200 0 3 5 0 ] ) ;
144 c o n t o u r ( motoreff_w , motoreff_T , m o t o r e f f ) ;
145 p l o t ( s p e e d s . s i g n a l s . v a l u e s ( : , 2 ) /rw∗ g r a t i o , F o r c e s . s i g n a l s . v a l u e s
( : , 1 ) ∗rw/ g r a t i o , ’ k ’ , ’ LineWidth ’ , 1 ) ;
146 t i t l e ( ’ Motor e f f i c e n c y ’ ) ;
147 x l a b e l ( ’ Motor Angular Speed [ rad / s ] ’ ) ;
148 y l a b e l ( ’ Motor Torque [Nm] ’ ) ;
149 l e g e n d ( ’ Motor E f f i c i e n c y ’ , ’ Drive c y c l e ’ ) ;
150 i f s a v e == 1
151 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ M o t o r _ e f f i c i e n c y ’ ) , ’ png ’ ) ;
152 else
153 end
154

155 figure (8) ;


156 h o l d on ;
157 p l o t ( Right_torque . time / 6 0 , Right_torque . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’
, ’ LineWidth ’ , 0 . 7 ) ;
158 p l o t ( Right_torque . time / 6 0 , L e f t _ t o r q u e . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ ,
’ LineWidth ’ , 0 . 7 ) ;
159 p l o t ( Right_torque . time / 6 0 , Commanded_torque . s i g n a l s . v a l u e s ( : , 1 ) ,
’ k ’ , ’ LineWidth ’ , 0 . 7 ) ;
160 l e g e n d ( ’ Right motor t o r q u e ’ , ’ L e f t motor t o r q u e ’ , ’ Torque command
’);
161 t i t l e ( ’ Motor t o r q u e o u t p u t s ’ ) ;
162 y l a b e l ( ’ Torque [Nm] ’ ) ;
163 x l a b e l ( ’ time [ min ] ’ ) ;
164 xlim ( [ 5 8 ] )
165 g r i d on ;
166 i f s a v e==1
167 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ TC_output ’ ) , ’ png ’ ) ;
168 else
169 end
170

171 figure (9) ;


172 h o l d on ;
173 p l o t ( s l i p _ l e f t . time / 6 0 , s l i p _ l e f t . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’
LineWidth ’ , 0 . 5 ) ;
174 p l o t ( t r a c t i o n _ c o r r e c t i o n _ l . time / 6 0 , t r a c t i o n _ c o r r e c t i o n _ l .
s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 0 . 5 ) ;
175 l e g e n d ( ’ L e f t wheel s l i p r a t i o ’ , ’ T r a c t i o n c o n t r o l i n t e r v e n t i o n
Left ’ ) ;
176 xlim ( [ 0 . 5 7 ] )
177 ylim ( [ − 0 . 4 0 . 4 ] )
24 Matlab code

178 t i t l e ( ’ L e f t wheel s l i p and T. C i n t e r v e n t i o n ’ ) ;


179 y l a b e l ( ’ Force [N] ’ ) ;
180 x l a b e l ( ’ time [ min ] ’ ) ;
181 g r i d on ;
182 i f s a v e == 1
183 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ l e f t _ s l i p _ i n t e r v e n t i o n ’ ) , ’ png ’
);
184 else
185 end
186

187 figure (10) ;


188 h o l d on ;
189 p l o t ( s l i p _ r i g h t . time / 6 0 , s l i p _ r i g h t . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’
LineWidth ’ , 0 . 5 ) ;
190 p l o t ( t r a c t i o n _ c o r r e c t i o n _ r . time / 6 0 , t r a c t i o n _ c o r r e c t i o n _ r .
s i g n a l s . v a l u e s ( : , 1 ) ∗ 0 . 0 0 1 , ’ r ’ , ’ LineWidth ’ , 0 . 5 ) ;
191 l e g e n d ( ’ Right wheel s l i p r a t i o ’ , ’ T r a c t i o n c o n t r o l i n t e r v e n t i o n
Right ’ ) ;
192 xlim ( [ 0 . 5 7 ] )
193 ylim ( [ − 0 . 4 0 . 4 ] )
194 t i t l e ( ’ Right wheel s l i p and T .C i n t e r v e n t i o n ’ ) ;
195 y l a b e l ( ’ Force [N] ’ ) ;
196 x l a b e l ( ’ time [ min ] ’ ) ;
197 g r i d on ;
198 i f s a v e==1
199 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ r i g h t _ s l i p _ i n t e r v e n t i o n ’ ) , ’ png
’);
200 else
201 end
202

203 figure (11) ;


204 plot ( dist . signals . values (: , 1) , slope . signals . values (: , 1) , ’b ’ , ’
LineWidth ’ , 1 . 5 ) ;
205 legend ( ’ Slope ’ ) ;
206 t i t l e ( ’ Slope p r o f i l e ’ ) ;
207 y l a b e l ( ’ Slope [%] ’ ) ;
208 x l a b e l ( ’ time [ min ] ’ ) ;
209 xlim ( [ 0 7 ] )
210

211 g r i d on ;
212 i f s a v e==1
213 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ e l e v a t i o n _ p r o f i l e ’ ) , ’ png ’ ) ;
214 else
2.3. Matlab Code for comparing vehicle layouts 25

215 end
216

217 % figure (12) ;


218 % h o l d on ;
219 % p l o t ( s l i p _ l e f t . time / 6 0 , s l i p _ l e f t . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’
LineWidth ’ , 1 . 5 ) ;
220 % p l o t ( s l i p _ l e f t . time / 6 0 , t r a c t i o n _ c o r r e c t i o n _ l . s i g n a l s . v a l u e s
( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 1 . 5 ) ;
221 % l e g e n d ( ’ L e f t wheel s l i p r a t i o ’ , ’ T r a c t i o n c o n t r o l i n t e r v e n t i o n
Left ’ ) ;
222 % xlim ( [ 0 2 ] ) ;
223 % ylim ( [ − 0 . 5 0 . 5 ] ) ;
224 % y l a b e l ( ’ Force [N] ’ ) ;
225 % x l a b e l ( ’ time [ min ] ’ ) ;
226 % g r i d on ;
227 % i f s a v e==1
228 % s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ l e f t _ s l i p ’ ) , ’ png ’ )
229 % else
230 % end
231

232 figure (13) ;


233 h o l d on ;
234 plot ( di st . s i g n a l s . values ( : , 1 ) , E. s i g n a l s . values ( : , 1 ) , ’ r ’ , ’
LineWidth ’ , 0 . 8 ) ;
235 p l o t ( d i s t . s i g n a l s . v a l u e s ( : , 1 ) , energy_regen . s i g n a l s . v a l u e s ( : , 1 ) ,
’ b ’ , ’ LineWidth ’ , 0 . 8 ) ;
236 l e g e n d ( ’ Energy used ’ , ’ Regen e n e r g y ’ ) ;
237 t i t l e ( ’ Consumed e n e r g y vs d i s t a n c e t r a v e l l e d ’ ) ;
238 x l a b e l ( ’ D i s t a n c e [ km ] ’ ) ;
239 y l a b e l ( ’ Energy [kWh] ’ ) ;
240 i f s a v e==1
241 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ en e r g y_ v s _ di s t ’ ) , ’ png ’ )
242 else
243 end

2.3 Matlab Code for comparing vehicle layouts

1 save ( ’ Pmec_single . mat ’ , ’ Pmec_single ’ ) ;


2 save ( ’ Ve_speed_single . mat ’ , ’ Ve_speed_single ’ ) ;
3 save ( ’ L e f t _ t o r q u e _ s i n g l e . mat ’ , ’ L e f t _ t o r q u e _ s i n g l e ’ ) ;
4 save ( ’ d i s t _ s i n g l e . mat ’ , ’ d i s t _ s i n g l e ’ ) ;
5 save ( ’ E _ s i n g l e . mat ’ , ’ E _ s i n g l e ’ ) ;
6 save ( ’ SOC_single . mat ’ , ’ SOC_single ’ ) ;
26 Matlab code

7 s a v e ( ’ d r i v e t r a i n _ l o s s e s _ s i n g l e . mat ’ , ’ d r i v e t r a i n _ l o s s e s _ s i n g l e ’ ) ;
8 s a v e ( ’ s l i p _ r i g h t _ s i n g l e . mat ’ , ’ s l i p _ r i g h t _ s i n g l e ’ ) ;

1 s a v e ( ’ Pmec_triple . mat ’ , ’ Pmec_triple ’ ) ;


2 s a v e ( ’ Ve_speed_triple . mat ’ , ’ Ve_speed_triple ’ ) ;
3 s a v e ( ’ L e f t _ t o r q u e _ t r i p l e . mat ’ , ’ L e f t _ t o r q u e _ t r i p l e ’ ) ;
4 s a v e ( ’ d i s t _ t r i p l e . mat ’ , ’ d i s t _ t r i p l e ’ ) ;
5 s a v e ( ’ E _ t r i p l e . mat ’ , ’ E _ t r i p l e ’ ) ;
6 s a v e ( ’ SOC_triple . mat ’ , ’ SOC_triple ’ ) ;
7 s a v e ( ’ d r i v e t r a i n _ l o s s e s _ t r i p l e . mat ’ , ’ d r i v e t r a i n _ l o s s e s _ t r i p l e ’ ) ;
8 s a v e ( ’ s l i p _ r i g h t _ t r i p l e . mat ’ , ’ s l i p _ r i g h t _ t r i p l e ’ ) ;
9 d i s p ( Data s t o r e d s u c c e s s f u l l y ) ;

1 close all ;
2

3 f i g u r e s d i r = ’ /home/ i g n a c i o / Dropbox /Q2_2018_19_drop/TFG/ T h e s i s /


Images / ’ ;
4

5 success = false ;
6 while ~ success
7 b = i n p u t ( ’Do you want t o s a v e t h e g e n e r a t e d p l o t s ? 1=y e s 2=
no ’);
8 switch b
9 case 1
10 d i s p ( ’ The p l o t s w i l l be saved t o s e l e c e d f o l d e r ’ )
11 save = 1 ;
12 success = true ;
13 case 2
14 d i s p ( ’ The p l o t s w i l l not be saved ’ )
15 save = 2 ;
16 success = true ;
17 otherwise
18 d i s p ( ’ P l e a s e , s e l e c t one o f t h e a v a i l a b l e o p t i o n s ’ )
19 success = false ;
20 end
21 end
22

23

24 load ( ’ Pmec_single . mat ’ ) ;


25 load ( ’ Ve_speed_single . mat ’ ) ;
26 load ( ’ L e f t _ t o r q u e _ s i n g l e . mat ’ ) ;
27 load ( ’ d i s t _ s i n g l e . mat ’ ) ;
28 load ( ’ E _ s i n g l e . mat ’ ) ;
29 load ( ’ SOC_single . mat ’ ) ;
2.3. Matlab Code for comparing vehicle layouts 27

30 l o a d ( ’ d r i v e t r a i n _ l o s s e s _ s i n g l e . mat ’ ) ;
31 l o a d ( ’ s l i p _ r i g h t _ s i n g l e . mat ’ ) ;
32

33 load ( ’ Pmec_triple . mat ’ ) ;


34 load ( ’ Ve_speed_triple . mat ’ ) ;
35 load ( ’ L e f t _ t o r q u e _ t r i p l e . mat ’ ) ;
36 load ( ’ d i s t _ t r i p l e . mat ’ ) ;
37 load ( ’ E _ t r i p l e . mat ’ ) ;
38 load ( ’ SOC_triple . mat ’ ) ;
39 load ( ’ d r i v e t r a i n _ l o s s e s _ t r i p l e . mat ’ ) ;
40 load ( ’ s l i p _ r i g h t _ t r i p l e . mat ’ ) ;
41

42

43 figure (1) ;
44 h o l d on ;
45 p l o t ( Ve_speed_triple . time / 6 0 , Ve_speed_triple . s i g n a l s . v a l u e s
( : , 1 ) ∗ 3 . 6 , ’ b ’ , ’ LineWidth ’ , 0 . 7 ) ;
46 p l o t ( Ve_speed_single . time / 6 0 , Ve_speed_single . s i g n a l s . v a l u e s
( : , 1 ) ∗ 3 . 6 , ’ r ’ , ’ LineWidth ’ , 0 . 7 ) ;
47 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ ) ;
48 t i t l e ( ’ Vehicle speeds ’ ) ;
49 y l a b e l ( ’ Speed [ km/h ] ’ ) ;
50 x l a b e l ( ’ Time [ min ] ’ ) ;
51 %s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
52 g r i d on ;
53 i f s a v e==1
54 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ vehicle_speeds_comp ’ ) , ’ png ’ ) ;
55 else
56 end
57

58

59 figure (2) ;
60 h o l d on ;
61 p l o t ( Ve_speed_triple . time / 6 0 , 2∗ L e f t _ t o r q u e _ t r i p l e . s i g n a l s .
v a l u e s ( : , 1 ) , ’ b ’ , ’ LineWidth ’ , 1 ) ;
62 p l o t ( Ve_speed_single . time / 6 0 , 2∗ L e f t _ t o r q u e _ s i n g l e . s i g n a l s .
v a l u e s ( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 0 . 7 ) ;
63 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ ) ;
64 t i t l e ( ’ V e h i c l e output t o r q u e ’ ) ;
65 y l a b e l ( ’ Torque [Nm] ’ ) ;
66 x l a b e l ( ’ Time [ min ] ’ ) ;
67 %s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
68 g r i d on ;
28 Matlab code

69 i f s a v e==1
70 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ vehicle_torque_comp ’ ) , ’ png ’ ) ;
71 else
72 end
73

74

75 figure (3) ;
76 h o l d on ;
77 p l o t ( d i s t _ t r i p l e . s i g n a l s . v a l u e s ( : , 1 ) , SOC_triple . s i g n a l s . v a l u e s
( : , 1 ) , ’ b ’ , ’ LineWidth ’ , 0 . 6 ) ;
78 p l o t ( d i s t _ s i n g l e . s i g n a l s . v a l u e s ( : , 1 ) , SOC_single . s i g n a l s . v a l u e s
( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 0 . 6 ) ;
79 t i t l e ( ’ B a t t e r y SOC vs . D i s t a n c e t r a v e l l e d ’ ) ;
80 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ ) ;
81 y l a b e l ( ’ B a t t e r y SOC [ % ] ’ ) ;
82 x l a b e l ( ’ D i s t a n c e [ km ] ’ ) ;
83 g r i d on ;
84 i f s a v e==1
85 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’SOC_comp ’ ) , ’ png ’ ) ;
86 else
87 end
88

89

90 figure (4) ;
91 h o l d on
92 p l o t ( Pmec_triple . time / 6 0 , Pmec_triple . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ ,
’ LineWidth ’ , 0 . 5 ) ;
93 p l o t ( Pmec_single . time / 6 0 , Pmec_single . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ ,
’ LineWidth ’ , 0 . 5 ) ;
94 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ ) ;
95 t i t l e ( ’ Mechanical power output ’ ) ;
96 y l a b e l ( ’ Power output [kW] ’ ) ;
97 x l a b e l ( ’ Time [ min ] ’ ) ;
98 %s e t ( gca , ’ XTickLabel ’ , [ ] ) ;
99 g r i d on ;
100 i f s a v e==1
101 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’Pmec_comp ’ ) , ’ png ’ ) ;
102 else
103 end
104

105

106 figure (5) ;


107 h o l d on ;
2.3. Matlab Code for comparing vehicle layouts 29

108 p l o t ( d r i v e t r a i n _ l o s s e s _ t r i p l e . time / 6 0 , d r i v e t r a i n _ l o s s e s _ t r i p l e .
s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ , ’ LineWidth ’ , 0 . 5 ) ;
109 p l o t ( d r i v e t r a i n _ l o s s e s _ s i n g l e . time / 6 0 , d r i v e t r a i n _ l o s s e s _ s i n g l e .
s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 0 . 5 ) ;
110 t i t l e ( ’ Drivetrain losses ’ ) ;
111 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ )
112 y l a b e l ( ’ Power l o s s e s [W] ’ ) ;
113 x l a b e l ( ’ Time [ min ] ’ ) ;
114 g r i d on ;
115 i f s a v e==1
116 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ d r i v e t r a i n _ l o s s e s _ c o m p ’ ) , ’ png ’
);
117 else
118 end
119

120

121 figure (6) ;


122 h o l d on ;
123 p l o t ( s l i p _ r i g h t _ t r i p l e . time / 6 0 , s l i p _ r i g h t _ t r i p l e . s i g n a l s . v a l u e s
( : , 1 ) , ’ b ’ , ’ LineWidth ’ , 0 . 5 ) ;
124 p l o t ( s l i p _ r i g h t _ s i n g l e . time / 6 0 , s l i p _ r i g h t _ s i n g l e . s i g n a l s . v a l u e s
( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 0 . 5 ) ;
125 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ ) ;
126 xlim ( [ 0 . 5 7 . 5 ] )
127 ylim ( [ − 0 . 4 0 . 4 ] )
128 t i t l e ( ’ Wheel s l i p ’ ) ;
129 y l a b e l ( ’ Force [N] ’ ) ;
130 x l a b e l ( ’ Time [ min ] ’ ) ;
131 g r i d on ;
132 i f s a v e==1
133 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ slip_comp ’ ) , ’ png ’ ) ;
134 else
135 end
136

137 figure (7) ;


138 p l o t ( d i s t _ s i n g l e . time / 6 0 , d i s t _ t r i p l e . s i g n a l s . v a l u e s ( : , 1 ) , ’ b ’ ,
’ LineWidth ’ , 0 . 5 ) ;
139 p l o t ( d i s t _ s i n g l e . time / 6 0 , d i s t _ s i n g l e . s i g n a l s . v a l u e s ( : , 1 ) , ’ r ’ ,
’ LineWidth ’ , 0 . 5 ) ;
140 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ ) ;
141 t i t l e ( ’ Distance t r a v e l l e d ’ ) ;
142 y l a b e l ( ’ D i s t a n c e [ km ] ’ ) ;
143 x l a b e l ( ’ Time [ min ] ’ ) ;
30 Matlab code

144 xlim ( [ 0 8 ] )
145

146 g r i d on ;
147 i f s a v e==1
148 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ distance_comp ’ ) , ’ png ’ ) ;
149 else
150 end
151

152

153 figure (8) ;


154 h o l d on ;
155 plot ( d i s t _ t r i p l e . s i g n a l s . values ( : , 1 ) , E_triple . s i g n a l s . values
( : , 1 ) , ’ r ’ , ’ LineWidth ’ , 0 . 8 ) ;
156 p l o t ( d i s t _ s i n g l e . s i g n a l s . values ( : , 1 ) , E_single . s i g n a l s . values
( : , 1 ) , ’ b ’ , ’ LineWidth ’ , 0 . 8 ) ;
157 t i t l e ( ’ Consumed e n e r g y vs d i s t a n c e t r a v e l l e d ’ ) ;
158 x l a b e l ( ’ D i s t a n c e [ km ] ’ ) ;
159 y l a b e l ( ’ Energy [kWh] ’ ) ;
160 l e g e n d ( ’ Layout 2 ’ , ’ Layout 1 ’ )
161 i f s a v e==1
162 s a v e a s ( g c f , s t r c a t ( f i g u r e s d i r , ’ energy_comp ’ ) , ’ png ’ )
163 else
164 end

You might also like