Project 2
OBJECTIVE:
To develop a forward energy-based fuel consumption model of a P1 hybrid vehicle using matlab and simulink to analize data and generate plots
MATLAB CODE:
%% Skill-Lync -> Hybrid Drives Development
% Project 2 - Hybrid Vehicle Model
% By - Akhil benny
% Description:
%% Initialization File
% Initialization file for loading the variables for the Conventional vehicle simulation model
%% Vehicle Parameters
M = 1500; % Vehicle weight [kg]
Cr = 0.015; % Rolling resistance coefficient
Rw = 0.35; % Rolling radius [m]
Cd = 0.33; % Drag coefficient
Af = 2; % Frontal area [m2]
rhoa = 1.225; % Air density [kg/m3]
Vwind = 0; % Wind velocity [kmph]
g = 9.81; % Gravitational acceleration [m/s2]
theta = 0; % Slope [deg]
myu_road_tire = 1; % Coefficient of friction between tire - road interface
%% Powertrain Parameters
FDR = 3.73; % Final Drive Ratio / Diff Ratio
DiffEff = 0.99; % Differential efficiency (assumed independent of operating conditions)
NumGear = 4; % Number of gears in transmission
TransGear = [1:NumGear]; % Transmission Gears
TransRatio = [3.06, 1.62, 1, 0.7]; % Corresponding Transmission ratios
TransEff = 0.90; % Transmission efficiency (assumed independent of operating conditions)
TC_SR = [0, .5, .6, .7, .8, .87, .92, .94, .96, .97, 1]; % Torque Converter Speed Ratio (Matlab default) -> TurbSpd/PumpSpd
TC_TR = [2.232, 1.5462, 1.4058, 1.2746, 1.1528, 1.0732, 1.0192, 1, 1, 1, 1]; % Torque Converter Torque Ratio (Matlab default) -> TurbTrq/PumpTrq
TC_Cf = 1e-4 * [.72558, .66322, .63463, .59042, .51331, .4144, .29287, .22444, .12186, .04386, 0]; % Torque Converter Capacity Factor (Matlab default) -> PumpTrq/PumpSpd^2 [Nm/rpm^2]
load Project2_Files/Vehicle_Data/Engine_data_1_9L_Saturn_95kW
load Project2_Files/Vehicle_Data/Trans_Shift_map
load Project2_Files/Vehicle_Data/EM_Honda_Insight_10kW
load Project2_Files/Vehicle_data/ESS_NiMH6
%% Driver Parameters
Kp = 10; % P gain for driver PI model
Ki = 1; % I gain for driver PI model
Drive_Cycle_Select = 1; % Drive cycle selection
% Drive cycle values in m/s
if Drive_Cycle_Select == 1
load Project2_Files/DriveCycles/UDDS;
elseif Drive_Cycle_Select == 2
load Project2_Files/DriveCycles/HWFET;
elseif Drive_Cycle_Select == 3
load Project2_Files/DriveCycles/FTP;
elseif Drive_Cycle_Select == 4
load Project2_Files/DriveCycles/US06;
elseif Drive_Cycle_Select == 5
load Project2_Files/DriveCycles/NEDC;
elseif Drive_Cycle_Select == 6
load Project2_Files/DriveCycles/WLTP;
end
time_end = cyc_time(end);
vel_end = cyc_vel(end);
SIMULINK MODELING:

*This simulink model for the comvention model is created using 3 main subblocks for the driver model,control model and powertrain block
DRIVER MODEL:
*Driver model is a basic pi controller that generates accelarator and brake pedal output to match the desired actual vehicle speeds

*the controller controls the error between the requred drive cycle and actual vehicle speed by providing accelaration and brake pedal output to the controller
CONTROLLER MODEL:
*The contoller block is the brain of the vehicle representing the electronic units. based on the driver inputs,it generates desired engine torque desired motor torque, desired transmission gear and desired brake torque these inputs are fed to the powertrain block which present thre drivetrain of the vehicle



*The input to the state flow charts is accelaration and brake pedal input from the driver unit, engine actual speed, actual vehicle speed,SOC,status and clutch lockup state. and the state flow outputs to the individual controllers are the mode Engine on/off request, engine input throttle and Electric motor input throttle
*The controller consist of an engine control unit, a transmission control unit,Electric motor control unit and a brake unit
*All control signals are passed to transmission model which represents the drive train
ENGINE CONTROL UNIT:

IDLE SPEED CONTROLLER:

*Engine control unit compare engine speed with the maximum torque and minimum torque curves of the loockup table and give the required torque command to the engine block .the throttle input is combined with the idle speed throttle and gain with the torque output from the lookup input required for the engine
ELECTRC MOTOR CONTROL UNIT:

*Motor control unit compare EM speed with the maximum torque curve and maximum torque generation curves of the lookup table and give the required torque command to the electric motor. the EM throttle input is used to compare the lookup tables and to estimate the torque input required for the E-motor
TRANSMISSION CONTROL BLOCK:

*The transmission control block controls the gear shifting using the study flow variable chart

*The gear shifting is controlled accordig to the vehicle speed and throttle input
*Here it is determined whether the clutch is locked up or not . if the gear selection is grater than or equal to 3 , the clutch will lock
*The gear command is passed to the transmission block to select the desired gear ratio
BRAKE CONTROL UNIT:

*Brake controle unit produce required brake torque according to the brake pedal and passes the brake torque into wheel block in the transmission model
Powertrain Model:
*The powertrain model includes all the components that convert the power of the engine into vehicle motion

*This include Engine,battery pack,Electric motor, crank hub,transmission,differential,wheels and vehicle body dynamics subsystems
*The control signals from the control mode are transmitted via a bus to the corresponding blocks in the powertrain model
BATTERY MODEL:

*A battery pack subsystem is created with electric power input and battery SOC as output
*2 different subblocks have been created to determine the SOC and terminal voltage separately the SOC being used to calculate the terminal voltage
SOC Estimation MOdel:

*Pack current in armature is converted to AmpHour and divides with max capacity and adds with the initial SOC to determine the SOC of the battery at each instance the SOC value is limited between 0 to 0.1
TERMINAL VOLTAGE MODEL:

*Ideal voltage and internal resistance are determined by 1D lookup table and battery voltage is determined using the model
*The specifed values are sent back to worksapce using the two workspace block and can used for post processing
ENGINE MODEL:

*Based on the engine speed the required torque from the controller is saturated between max torque curve and min torque curve and passes the engine torque to the crank hub
*The 2D lookup table is used to calculate the fuel flow rate based on engine speed and engine torque . the fuel flow rate is then integrated to find the fuel consumption
*The new engine also has an on/off feature to eliminate the fuel flow rate when the engine is off . also the engine torque cannot be negative torque as minimum torque curve made saturated
ELECTRIC MOTOR MODEL:

*Based on the engine speed the required EM torque from the controller is saturated between max EM torque generation curve and passes the EM torque to the crank hub
*The 2D lookup table is used to calculate the input electric power to the motor based on EM speed and EM torque
CRANK HUB:

*Crank hub adds up the EM torque and the engine torque and pass it to the transmission block as the crank torque
TRANSMISSION MODEL:
*The crank is connected to the automatic transmission via a torque convertor . the output of the transmission is connected to the differential
*New clutch lockup feature is adding to this hybrid version

TORQUE CONVERTOR:

*Torque convertor define the pump and turbine torque by the clutch lock up status , and the combination gives us the desired transmission torque
DIFFERENTIAL MODEL:

*The transmission output torque is multiplied by the differential ratio and differential efficiency in this block and the torque is transmitted to the wheel as the axle torque
WHEEL MODEL:

*The brake torque from the control mode is subtracted feom the axle torque and divides feom the rolling radius to determine the tractive force
*The wheel speed is calculated from the vehicle velocity and saved in the worksapce
VEHICLE DYNAMICS:
*The logitudinal dynamics of the vehicle along with the road load is represented in the vehicle dynamics block

*Tractive force and road loads are used to calculate the vehicle velocity
POST-PROCESSING
%% Skill-Lync -> Hybrid Drives Development
%post-processing file
%file for post processing the P1 hybrid vehicle simulation model data
% By - Akhil benny
% Description:
% The following file is to used with the Initialization file and Simulink
% results for post-processing of the data.
% The file is incomplete, has some examples of how the data is imported
% into a readable format, data analysis and plotting examples.
% Based on the project task, use commands in a similar format as given
% below, to analyse the data and generate required plots.
% You can change variable names if desired
%% Post-Processing File
% File for post-processing the Conventional vehicle simulation model data
%% Renaming variables
Time = out.tout;
Acc_Pdl = out.Acc_Pdl; % Accelerator pedal [%]
Brk_Pdl = out.Brk_Pdl; % Brake pedal [%]
Gear_Cmd = out.Gear_Cmd; % Transmission gear
Trans_In_Spd = out.Trans_In_Spd*30/pi; % Transmission input speed [rpm]
Trans_Out_Spd = out.Trans_Out_Spd*30/pi;% Transmission output speed [rpm]
Eng_Trq = out.Eng_Trq; % Engine brake torque [Nm]
Eng_Spd = out.Eng_Spd*30/pi; % Engine speed [rpm]
Eng_Fuel_Consump = out.Eng_Fuel_Consumption; % Engine fuel consumption [g]
Veh_Dist = out.Veh_Dist/1000; % Distance traveled by vehicle [km]
Veh_Spd = out.Veh_Spd*18/5; % Vehicle speed [kmph]
Wh1_Spd = out.Wh1_spd*18/5; %wheel speed[rpm]
Desired_spd = out.Desired_Velo*18/5; %Desired speed[Kmph]
EM_Spd = out.EM_Spd*30/pi; %E motor speed[rpm]
EM_Trq = out.EM_Trq; %E motor Torque [Nm]
EM_Pwr = out.EM_Pwr; %Motor input Power[w]
V_batt = out.V_batt; %Battery pack voltage[v]
I_pack = out.I_pack; %Battery pack Current [A]
SOC = out.SOC; %SOC [%]
%% Data Analysis
Eng_Pwr = Eng_Spd*pi/30.*Eng_Trq/1000; % Engine brake power [kW]
rho_petrol = 0.7197; % Density of petrol [kg/L]
kmpl = Veh_Dist(end)/(Eng_Fuel_Consump(end)/1000/rho_petrol); % Fuel economy [kmpl]
%Display fuel economy of the cycle
fprint('nfuel economy = %2.2fkmp1nn',kmp1);
%%plotting vehicle characteristics time trace
%potting transmission input,transmission output and wheelspeed
figure(1)
hold on
grid on
plot(Time,Trans_in_Spd,'linewidth',1,'color','black');
plot(Time,Trans_Out_spd,'linewidth',1,'color','red');
plot(Time,Wh1_spd,'linewidth',1,'color','blue');
xlabel('time[s]')
ylabel('speed [rpm]')
xlim([0,Time(end)]);
legend('Trans input','Trans Output','Wheel Speed');
title('Transmission input output and Wheel speed');
%%plotting engine torque,engine power, fuel rate and fuel consumption
figure(2)
subplot(4,1,1)
hold on
grid on
plot(Time,Eng_Trq,'linewidth',1,'color','black');
ylabel('Torque [Nm]')
xlim([0,Time(end)]);
title('Engine Torque')
subplot(4,1,2)
hold on
grid on
plot(Time,Eng_Pwr,'linewidth',1,'color','black');
ylabel('power [KW]')
xlim([0,Time(end)]);
title('Engine power')
subplot(4,1,3)
hold on
grid on
plot(Time,Eng_Fuel_rate,'linewidth',1,'color','black');
xlim([0,Time(end)]);
xlabel('Time[s]');
ylabel('Fuel rate');
title('Engine fuel Rate')
subplot(4,1,4)
hold on
grid on
plot(Time,Veh_Dist,'linewidth',1,'color','black');
xlim([0,Time(end)]);
xlabel('Time [s]');
ylabel('Distance [km]');
title('Vehicle Distance')
%%plotting Drive cycle
figure(4)
hold on
grid on
plot(cyc_time,cyc_vel,'linewidth',1,'color','black');
xlabel('Time[s]')
ylabel('velocity [Mph]')
title('Drive cycle')
%%Test result
Avg_speed = sum(Veh_Spd)/length(Veh_Spd);
Max_speed = maxk(Veh_spd,1);
table(Avg_speed,Max_speed,kmp1,'variableNames',{'Avarage speed[kmph]','Maximum speed[kmp1]'})
%%plotting engine operating points on engine fuel map
figure('Name','Engine operating points');
hold on
grid on
title('Engine operating points','fontsize',12);
plot(Eng_map_spd*30/pi,Eng_max_trq,'linewidth',2,'color','r');
p2=line([Eng_map_spd(end)*30/pi Eng_map_spd(end)*30/pi],[0 Eng_max_trq(end)]);
set(p2,'linewidth',1,'linesyle','--','color','k');
p3=line([Eng_map_spd(1)*30/pi Eng_map_spd(1)*30/pi],[0 Eng_max_trq(1)]);
set(p3,'linewidth',1,'linestyle','--','color','k');
[c,h] = contour(Eng_map_spd'*30/pi,Eng_map_trq,Eng_fuel_map');
clabel(c,h);
xlabel('Engine speed [rpm]');
ylabel('Engine Torque [Nm]');
title('Engine fuel consumption map [g/s]');
legend({'max curve','operating points'});
axis([Eng_map_spd(1)*30/pi Eng_map_spd(end)*30/pi 0 Eng_map_trq(end)]);
%%EM
%plotting motor speed, motor torque and motor input power
figure(6)
subplot(3,1,1)
hold on
grid on
plot(Time,EM_Spd,'linewidth',1,'color','black');
ylabel('Speed [rpm]')
xlim([0, Time(end)]);
title('Motor speed')
subplot(3,1,2)
hold on
grid on
plot(Time,EM_Trq,'linewidth',1,'color','black');
ylabel('Torque[Nm]')
xlim([0, Time(end)]);
title('Motor Torque')
subplot(3,1,3)
hold on
grid on
plot(Time,EM_Pwr,'linewidth',1,'color','black');
xlim([0,Time(end)]);
xlabel('Time [s]');
ylabel('Power [W]');
title('Motor input power')
%% BATTARY
%plotting pack current, voltage and SOC
figure(7)
subplot(3,1,1)
plot(Time,V_batt,'linewidth',1)
xlabel('Time [s]');
ylabel('Voltage [v]');
title('pack Voltage')
xlim([0,Time(end)]);
grid on
subplot(3,1,2)
plot(Time,I_batt,'linewidth',1)
xlabel('Time [s]');
ylabel('current [A]');
title('Battery Current')
xlim([0, Time(end)]);
grid on
subplot(3,1,3)
plot(Time,SOC,'linewidth',1)
xlabel('Time [s]');
ylabel('SOC [%]');
title('state of charge - SOC')
xlim([0, Time(end)]);
grid on
%%plotting engine operating points on engine fuel map
figure('Name','Electric motor operating points','fontsize',12);
p1=plot(EM_map_spd*30/pi,EM_max_trq,'linewidth',2,'color','r');
p4=plot(EM_map_spd*30/pi,EM_max_gen_trq,'linewidth',2,'color','b');
p2=line([EM_map_spd(end)*30/pi EM_map_spd(end)*30/pi],[EM_max_trq(end) EM_max_trq(1)]);
set(p2,'linewidth',1,'linestyle','--','color','k');
p3=line([EM_map_spd(1)*30/pi EM_map_spd(1)*30/pi],[EM_max_gen_trq(1) EM_max_trq(1)]);
set(p3,'linewidth',1,'linestyle','--','color','k');
[c,h] = contour(EM_map_spd'*30/pi,EM_map_trq,EM_inpwr_map');
clabel(c,h);
xlabel('Motor speed [rpm]');
ylabel('Motor Torque [Nm]');
title('Motor in power map [W]');
legend([p1 p2 p3],{'Max curve','Regen curve','operating points'});
xlim([EM_map_gen_trq(1) EM_max_trq(1)]);
ylim([Em_gen_trq(1) EM_max_trq(1)]);
Plot and geaphs:
UDDS Cycle:
FUEL CONSUMPTION VS FUEL RATE


VEHICLE CHARACTERISTICS TIME TRACE ENGINE TORQUE ,ENGINE POWER,FUEL RATED FUEL CONSUMPTION

VEHICLE CHARACTERISTICS TIME TRACE ACCELARATOR AND BRAKE PEDAL,GEAR COMMANS ,VEHICLE DESIRED ANDACTUAL SPEED

ENGINE OPERATING POINTS OF ENGINE FUEL MAP:

MOTOR SPEED,TORQUE,MOTOR INPUT POWER CHARACTERISTICS:

PACK VOLTAGE,PACK CURRENT:

EM OPERATING POINTS:

HWFET CYCLE
FUEL CONSUMPTION VS FUEL RATE

VEHICLE CHARACTERISTICS TIME TRACE ENGINE,TRANSMISSION INPUT,TRANSMISSION OUTPUT AND WHEEL SPEED

VEHICLE CHARACTERISTICS TIME TRACE ENGINE TORQUE,ENGINE POWER,FUEL RATE AND FUEL CONSUMPTION
VEHICLE CHARACTERISTICS TIME TRACE ACCELARATOR AND BRAKE PEDAL,GEAR COMMAND,VEHICLE DESIRED AND ACTUAL SPEED

ENGINE OPERATING POINTS ON ENGINE FUEL MAP

MOTOR SPEED,TORQUE,MOTOR INPUT POWER CHARACTERISTICS:
PACK VOLTAGE,PACK CURRENT,SOC CHARACTERISTICS:

EM OPERATING POINTS:

CONCLUTION:
The forward energy based-fuel consumption model of hybrid electric vehicle was developed and the plots have been plotted for UDDS and HWFET cycles