Project 1
%% 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 Matlab\files\Project1_Files\Project1_Files\Vehicle_Data\Engine_data_1_9L_Saturn_95kW.mat
load Matlab\files\Project1_Files\Project1_Files\Vehicle_Data\Trans_Shift_map.mat
%% 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 Matlab\files\Project1_Files\Project1_Files\DriveCycles\UDDS.MAT;
elseif Drive_Cycle_Select == 2
load Matlab\files\Project1_Files\Project1_Files\DriveCycles\HWFET.mat;
elseif Drive_Cycle_Select == 3
load Matlab\files\Project1_Files\Project1_Files\DriveCycles\FTP.mat;
elseif Drive_Cycle_Select == 4
load Matlab\files\Project1_Files\Project1_Files\DriveCycles\US06.mat;
elseif Drive_Cycle_Select == 5
load Matlab\files\Project1_Files\Project1_Files\DriveCycles\NEDC.mat;
elseif Drive_Cycle_Select == 6
load Matlab\files\Project1_Files\Project1_Files\DriveCycles\WLTP.mat;
end
time_end = cyc_time(end);
vel_end = cyc_vel(end);
Project1_VehicleModel:
Forward Model:-
It also known as dynamic simulation. Dynamic models are used for detailed simulations. In this model force/torque/power is the input and the vehicle state variable velocity and acceleration are outputs. The models and simulatios are more realistic due to phhysical casualty hence appropriate for control development. There is feedback loop to meet the desired vehicle state. It is mainly used to simulate a vehicle on a driving cycle to analyse the dynamic behaviour of the system helps significantly in control development.

Driver:

It is modeled using a ‘Driver’ block, which is a basic PI controller that generates accelerator and brake pedal outputs to match the desired and actual vehicle speeds. In this we use drive cycles fro the based on these results of fuel consumption and emissions the vehicle gets certified and it also forms a basis of uniform asessment. It is based on time, velocity then its all integrate and creates output accelration pedal and brake pedal.
2) Controller:
The ‘Controller’ block is the brains of the vehicle, representing the electronic controls units. It is based on the driver inputs, it generates desired engine torque, desired transmission gear and desired brake torque. These inputs are fed to the ‘Powertrain’ block which represents the drivetrain of the vehicle.

3) POWERTRAIN:
The powertrain encompasses every component that converts the engine's power into movement. This includes the engine, transmission, the driveshaft, differentials, axles; basically anything from the engine through to the rotating wheels.

A] Engine control Unit:
In this control model We use engine control unit in that give input Engine speed through creating look up table. in that table we give input Maximum torque and map speed then also create 2nd look up trable in that give input ct torque and map speed then it substracts and multiplied. the engine speed also give to ideal contro speed to integrate from this we meet output of engine required torque.

B) Vehicle Dynamics:
In this takes tractive force and road load. It is dictates vehicle speed based on tractive force and road load.
the dynamic equation for calculating road load is
MeqdVveh/dt=ηtλtot/Rw*Tm-(1/2p⋅A⋅Cd⋅(Vveh+Vw∈d)2+Cr⋅M⋅g⋅cos(θ)+M⋅g⋅sin(θ))
where,
p = air density [kg/m^3]
A = Frontal area [m^2]
Cd = drag Coefficiend
Vveh = velocity of vehicle [m/s^2]
Vwind = velocity of wind [m/s^2]
Cr = rolling resistance coefficient
M = mass in [Kg]
g = gravity.
Then we calculate and integrate then we meet acceleration of vehicle and velocity of vehicle it mean vehicle distance and vehicle speed.

% MATLAB SCRIPTS:
3) Project1_ProcessingFile.m:
% Skill-Lync -> Hybrid Drives DevelopmentS
% Project 1 - Conventional Vehicle Model
% 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_Consump; % 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]
Wheel_Spd=out.Wheel_Spd;
Eng_Fuel_Rate=out.Eng_Fuel_Rate;
%% Plotting vehicle characteristics time trace to Engine speed, Engine Torque, Engine Power,
% And Engine fuel rate, Engine fuel consumption
% Data conversion from Double Timeseries
Eng_spd = Eng_Spd.Data(:,1); % engine speed
Eng_trq = Eng_Trq.Data(:,1); % engine torque
Eng_pwr = Eng_Pwr.Data(:,1); % engine power
Eng_fuel_rate = Eng_Fuel_Rate.Data(:,1); % engine fuel rate
Eng_fuel_consumption = Eng_Fuel_Consump.Data(:,1); % engine fuel consumption
Veh_dist = Veh_Dist.Data(:,1); % vehicle distance
Veh_spd = Veh_Spd.Data(:,1); % vehicle speed
Wheel_spd = Wheel_Spd.Data(:,1);
%% Plotting vehicle characteristics time trace
figure(5)
subplot(3,2,1)
hold on
grid on
plot(Time, Acc_Pdl, 'linewidth', 1, 'Color', 'black');
plot(Time, Brk_Pdl, 'linewidth', 1, 'Color', 'red');
ylabel('Pedal [%]')
xlim([0, Time(end)]);
legend('Accel','Brake');
subplot(3,2,2)
hold on
grid on
plot(Time, Trans_In_Spd, 'linewidth', 1, 'Color', 'black');
plot(Time, Trans_Out_Spd, 'linewidth', 1, 'Color', 'red');
ylabel('Speed [rpm]')
xlim([0, Time(end)]);
ylim([0, 6000]);
legend('Trans Input','Trans Output');
subplot(3,2,3)
hold on
grid on
plot(Time, Gear_Cmd, 'linewidth', 1, 'Color', 'black');
xlim([0, Time(end)]);
xlabel('Time [s]');
ylabel('Distance');
subplot(3,2,4)
hold on
grid on
plot(Time, Wheel_spd, 'linewidth', 1, 'Color', 'black');
plot(Time, Veh_spd, 'linewidth', 1, 'Color', 'red');
ylabel('Speed [rpm]')
xlim([0, Time(end)]);
legend('Desired Speed','Actual Speed');
subplot(3,2,5)
hold on
grid on
plot(Time, Veh_dist, 'linewidth', 1, 'Color', 'blue');
xlim([0, Time(end)]);
xlabel('Time [s]');
ylabel('Gear');
%% Plotting engine operating points on engine fuel map
figure('Name','Engine Operating Points');
hold on
grid on
title('Engine Operating Points','fontsize',12);
p1=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,'linestyle','--','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]');
p4 = plot(Eng_spd,Eng_trq,'.','color','k');
legend([p1 p4],{'Max Curve','Operating Points'});
axis([Eng_map_spd(1)*30/pi Eng_map_spd(end)*30/pi 0 Eng_map_trq(end)]);
% Plotting fuel economy Vs Engine Fuel consumption
figure(2)
plot(Eng_fuel_consumption,Eng_fuel_rate,'color','r')
xlabel('Fuel consumption')
ylabel('Fuel Rate [%]')
title('Fuel economy Vs Fuel Consumption')
grid on
% Plotting Time Vs'Trans Input','Trans Output','Wheel Speed'
figure(3)
hold on
grid on
plot(Time, Trans_In_Spd, 'linewidth', 1, 'Color', 'blue');
plot(Time, Trans_Out_Spd, 'linewidth', 1, 'Color', 'green');
plot(Time, Wheel_spd, 'linewidth',1, 'color', 'black')
ylabel('Speed [rpm]')
xlabel('Timem [s]')
xlim([0, Time(end)]);
ylim([0, 6000]);
legend('Trans Input','Trans Output','Wheel Speed');
%subplots for Torque,Power,Fuel Rate,Fuel Consumption
figure(4)
subplot(2,2,1)
plot(Time,Eng_trq,'linewidth',1,'color','black')
xlabel('Time [s]')
ylabel('Torque [Nm]')
legend('Engine Torque')
grid on
subplot(2,2,2)
plot(Time,Eng_pwr,'linewidth',1,'color','blue')
xlabel('Time [s]')
ylabel('Power [KW]')
legend('Engine Power')
grid on
subplot(2,2,3)
plot(Time,Eng_fuel_rate,'linewidth',1,'color','red')
xlabel('Time [s]')
ylabel('Fuel Rate [%]')
legend('Engine Fuel Rate')
grid on
subplot(2,2,4)
plot(Time,Eng_fuel_consumption,'linewidth',1,'color','green')
xlabel('Time [s]')
ylabel('Fuel Consumption')
legend('Engine Fuel Consumption')
grid on
%% 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_consumption(end)/1000/rho_petrol); % Fuel economy [kmpl]
1) UDDS DRIVE CYCLE RESULTS:
1.1) FUEL ECONOMY VS FUEL CONSUMPTION:

1.2) B) Plot accelerator and brake pedal, gear command, vehicle desired and actual speed, vehicle distance using subplots:

1.3) Plot engine torque, engine power, fuel rate and fuel consumption using subplots:

1.4) Plot the time trace for engine, transmission input, transmission output and wheel speed on one plot:

2) HWFET DRIVE CYCLE RESULTS:
2.1) FUEL ECONOMY VS FUEL CONSUMPTION:

2.2) Plot accelerator and brake pedal, gear command, vehicle desired and actual speed, vehicle distance using subplots:

2.3) Plot engine torque, engine power, fuel rate and fuel consumption using subplots:

2.4) Plot the time trace for engine, transmission input, transmission output and wheel speed on one plot:

Results
FUEL ECONOMY RATE(KMPL):
1)UDDS DRIVE CYCLE 13.630 kmpl
2)HWFET DRIVE CYCLE 16.307kmpl
The Fuel Economy Rate of Hwfet Cycle is higher than UDDS cycle