Project 2
AIM:-
To Run simulations, change the threshold, create plots and measure current and hydrogen consumption. Specify the outputs. How to run the model.
Objective:-
To create complete model of FC(Fuel cell) vehicle system with secondary storage of Ultracapacitor and battery.Also to compare the power sharing among three energy sources by EMS(Energy Management Startegy).
To find vehicle H2 consumption,current drawn from fuel cell,its voltage and SOC of battery,ultracapacitor.
Overall Model:
Here below shown the ove-rall vehicle model:-

Subsystems of vehicle model:-
1)Drive cycle source-(Desired velocity as output).
2)Driver subsystem-(Desired velocity and Actual velocity-Inputs,Acceleration and brake commands-Outputs).
3)Powertrain model subsystem-(Acceleration and brake commands- Inputs,Tractive force-Output).
- Acceleration/Brake to Torque request subsystem.
- Torque request to power output subsystem.
- Torque out to Traction force subsystem.
- EMS(Energy Management Startegy) subsystem.
- Fuel Cell model- H2 consumption,O2 consumption,FC current,FC Voltage from FC Power request as input.
- Ultracapacitor model -UC Current,UC OCV(Open circuit voltage),UC SOC,UC Charge from UC Power request as input.
- Battery model -Battery current, voltage,Battery SOC from Battery Power request as input.
4)Vehicle dynamics subsystem-(Tractive force-Input,Actual velocity-Output).
- Rolling resistance force subsystem.
- Airdrag resistance force subsystem.
- Hill climbing force subsystem.
Construction and working:
1)Drive cycle source:-

The drive cycle data of US06 is feeded into the Drive cycle source block.
The US06 drive cycle data file is created and loaded in base workspace area.
As the drive cycle time is for duration 600 secs we have to set the stop time as 600 Secs.
2)Driver subsystem:-
Here shown the driver subsystem model:-

- In this block the inputs are Desired velocity from drive cycle source and Actual velocity as feedback from vehicle dynamics subsystem.
- The outputs of this subsystem are acceleration and brake commands.Initially the Desired velocity is subtracted from actual vehicle velocity and it creats a error(difference) in velocity output.
- This error output is feeded as proportional,integral,derivative outputs and added to get final acceleration/brake command outputs.
- The error is multiplied with a proportion gain value to perform proportional operation output.
- The error is multiplied with an intrgral gain value and given to an integrator block to perform integral operation output.
- A switch to reset the integrator is created as when the velocity of vehicle comes to 0 the integrator gets reseted(Switch o/p as 1 for reset) to perform its operation again from initial stage.
- This action helps to correct the integral error values,preventing from integral wind up condition.
- Again error is multiplied with a derivative gain and given to a derivative block to perform derivative operation output.
- These actions are considered as a PID controlling of vehicle velocity.
- All three outputs from Proportional(P),Integral(I)and Derivative(D) are added with a ADD block to get final acceleration/brake command outputs.
- A saturation block of range 0 to 1 given for acceleration command and saturation of 0 to -1, multiplied with -1 given for brake command to consider brake command also in positive values.
- While acceleration is in progress,brake is in off state and viseversa. Both acceleration and brake will not occure in same time.
3)Powertrain model:-
This subsystem consist of inputs acceleration command and brake command as showh in below mentioned image.
The output of this subsystem are Traction force that will be feeded as input to vehicle dynamics subsystem

- This subsystem consist of various subsystems namely acceleration/brake command to torque,power calculation,traction force,EMS,FC model,UC mode and battery model.
- Initially the acceleration and brake commands are converted to motor torque request as output from ACC/Brake-Torque subsystem.
- Then this motor torque request compared with electric motor angular velocity(Inside power calculation subsystem) and giving output as Torque output of motor and power required for producing this motor torque is calculated.
- From this motor torque output taken as input overall tractive force is calculated from Tractive force subsystem. This Tractive force is given as output from overall powertrain block.
- The total power calculated(Power request) from Power calculation subsystem is feeded into EMS(Energy Management Startegy) subsystem to produce fuel cell (FC) power request,Ultracapacitor(UC) power request and battery power request.
- EMS is used to create power sharing requests to FC,UC and Batery models.According to their power requests energy is drained / charged from these three types of energy sources.
- These power requests are given as inputs to respected FC model,UC model and Battery model for calcculating their current,SOC and voltage values.
- The fuel (H2) consumption is calculated from Fuel cell model subsystem as shown above.
- We can see in detail about their subsystem operations below,
Acc/Brake-Torque subsystem:-
In this subsystem the inputs are acceleration and brake commands and output is EM Torque request.

- The acceleration torque request is calculated by multiplying acceleration command with electric motor maximum torque value by using a max block.
- The brake torque request is calculated by multiplying brake command with electric motor minimum torque value by using min block.
- But before both torque request were added, the SOC of UC and SOC of Battery are verified for its less than maximum SOC limit.
- Whicle braking a regenerative power is feeded into UC or Battery.So to avoid over charge on UC and battery greaterr than their maximum SOC limit they were checked by the switch blocks.
- If both the values from switches were 0,then OR gate output becomes 0 thus makes braking only occured by mechanical brake and not by electric motor.
- To get charge the UC/Battery, the OR gate output should be 1.
- Then both torque requests were added after the SOC checks to give final electric motor torque request(EM.Torque.req).
- These operations are implimented in this subsystem.
Power calculation:-
In this subsystem the EM Torque request from ACC/Brake-Torque subsystem as input and output as motor torque output based on the motor angular velocity.

- The motor angular velocity(EM_F_w) is given as another feedback input from Tractive force subsystem.
- According to the motor angular velocity the motor maximum and minimum torque limit values are extracted from the 1-D look up tables.
- The datas of lookup tables are feeded from already created plot table datas from workspace.
- Seperate lookup tables are created for EM.Max torque values and EM.Min torque values.
- A dynamic saturation block is used to saturate the continuously changing Max and Min limits from lookup tables based on change in motor angular velocity.
- The final output from dynamic saturation block is final EM Torque output.
- To calculate the power required to produce this motor torque is calculated by the formula,
- Motor power =( Motor Torque * Motor Angular velocity)/Motor efficiency.
- The efficiency of motor is based on the parameters angualr velocity and motor torque output.Thus efficieny is extracted from efficiency datas from a 2-D lookup table,were angularr velocity and motor torque as inputs to 2D lookup table.
- Then power required is calculated by multiplying motor angular velocity and motor torque output then divide by motor efficiency values.
- Then angular velocity is checked for its 0 velocity, the power output only given as output when angular velocity is not a 0 velocity.
Tractive force subsystem:-
Tractive force subsystem consist of different subsystems namely,
- EM gear.
- Front brakes.
- Front wheels.
- Rear brakes.
- Rear wheels.

EM gear:-
In this block the inputs as Torque in from power calculation subsystem and outputs as vehicle Torque out.
The EM speed(EM_F_w) is calculated in rad/s in this subsystem.

- The formulae for calculating these outputs are as,
- Torque out=Torque in*gearbox ratio*gear efficiency.
- EM_Speed=Gearbox ratio*FW_w(Front wheel speed)
- FW_w=Vehicle velocity/tire radius.
- Torque in values are multiplied with gear ratio and gearbox efficiency(positive torque),inverse gear efficiency(negative torque) to get vehicle torque out.
- vehicle angular velocity multiplied gearratio to get motor angular velocity(EM_F_w).
Front brake:-
In this subsystem the torque due to un-balance of vehicle weight between front and rear side front wheel torque is calculated seperatey from this subsystem.
This can be given in relation,
[Brake cmd* vehicle mass*ground friction*gravity*tire radius*front brake proportion distribution]-[Final vehicle Torque in] = Front wheel Torque out.
This relation is implimented in this subsystem.

Front wheel:-
In this subsystem the front wheel torque is converted to front wheel tractive force.
Front wheel torque is divided with vehicle tire radius to get front wheel tractive force.
Vehicle velocity is divided by vehicle tire radius to get vehicle angular velocity(WH_F_w)

Rear brake:-
As rear wheels are controlled by only mechnical brake the torque input is get grounged initially.
The rear wheel torque output is due to mechanical brake torque given by relation,
[Brake cmd* vehicle mass*ground friction*gravity*tire radius*Rear brake proportion distribution]-[Torque(Grounded)] = Rear wheel Torque out.
This relation is implimented in this subsystem.

Rear wheel:-
The rear wheel tractive force is calculated by Mechanical torque input divied by vehicle tire radius.
This is implemented in this subsystem.

Both front and back wheels tractive forces are added to get final vehicle required tractive force as output from Tractive force subsystem.
Energy Management Startegy:-
Process flow of EMS:-

In this subsystem we seperating power request(power demand) from power calculation subsystem, as positive power request(Propulsion) and negative power request(Regeneration)

The power request is checked in a switch(positive power) were if power is >=0, power demand values moves into propulsion subsystem.
And if power request is negative,negative power demand values moves into regeneration subsystem.
Proplsion subsystem:-

Power sharing:-
In this subsystem the positive power demand is distributed into three energy sorces for Fuel cell,ultracapacior and battery models.
The fuel cells having a range of operating condition to produce the power needed for propulsion.
Here we are taking fuel cell with have capability to produce power in the range of minimum 23KW to maximum 72KW. But for better effeciency of fuel cell power usage it is derived that fuel cells will operate at maximum efficiency in moderate power generation area as seen from polarization curve.
Thus we are considering lesser power production level for maximum fuel cell power generation as 55KW.
Batteries are prefered to operate in lower power demand conditions and ultracapacitors are prefered to operate in peak power demands.
Thus we are get the final power sharing between three components as,
- From 0 to 23 KW is drawn from battery unit based on its SOC condition.
- Above 23KW to 55KW will be drawn from fuel cell power.
- And above 55KW will be drawn from ultracapacitors based on its SOC condition.
- If SOC of UC is not enough to supply required power demand,in that case the power is drawn from battery as battery backup.
- If SOC of battery and UC are not enough to supply power demand, in that case alternate source is only fuel cell.Power is drawn from fuel cell as fuel cell backup. But at this operating conditions, the overall efficieny of vehicle is reduced as fuel cell can't support with full efficiency for peak power demands and lesser power demands.
UC fail condition:-

The SOC of UC is checked with a switch for fail condition and the UC high test result is again checked for power demand request.
If both inputs of AND gate is 1 then the UC power request is compensated from Battery back up power if the battery capacity is above the Batt.SOC.min limit.
UC and Battery fail condition: -

The SOC of battery and UC are checked for their fail conditions using switches and given to AND block as the output is 1 if both the inputs are 1.
Also the battery test UC_high test results are again checked for power demand request of their range limits and given to a OR block as at a time duration any one condition is in true state.
Thus if both AND and OR block outputs as 1 giving result 1 from AND1 block makes use the power request of UC and battery companseted from fuel cell(FC) power.
Addition of power requests:-
- The power output from FC test and backup FC power are added to get final propulsion FC power.
- The power output from battery test and backup battery power are added to get final propulsion battery power.
- The power output from UC_test as final propulsion UC power.
Regenerative subsystem:-

In regeneration power(Negative power) subsystem,
It was checked for UC_SOC > UC_Battery with the switch block.If the condition is true(1) then the negative power demand is passes as output from the switch 1.
Then if UC_SOC==Bat_SOC was checked, a half of the negative power is given as battery charge power and if fails the output from Switch 1 is given as battery charge power.
This battery charge power was checked in a switch 3 as if Bat_SOC >90% charging will not occur and if condition fails this batteery charge power from switch 2 is considered as final battery charging power.
It was checked for UC_SOC > UC_Battery with the switch block.If the condition is False(0) then the negative power demand is passes as output from the switch 4.
Then if UC_SOC==Bat_SOC was checked, a half of the negative power is given as UC charge power and if fails the output from Switch 4 is given as UC charge power.
This UC charge power was checked in a switch 6 as if UC_SOC >90% charging will not occur and if condition fails this UC charge power from switch 5 is considered as final UC charging power.
Final addition of power requests:-
- The regenerative UC power and final UC propulsion power are added to get final output UC power request.
- The regenerative battery power and final battery propulsion power are added to get final output batttery power request.
- The final propulsion power as final output FC power request.
Fuel cell(FC) model:-

- In this subsystem FC power request is converted from Watts to KW initially.
- Then given as input along with net power drawn(P_net) from FC as feedback from FC subsystem to power control subsystem.
- The output of power control subsystem is total stack FC current.
- The Compressor speed of FC extracted from Current Vs rpm lookup table is given as input to FC system.
- An auxilary load in KW is also given as input to FC system.
- The output from FC system are H2 consumption(Kg),P_net,FC Stack voltage.
Power control subsystem:-

FC current is extracted from a 1-D lookup table based on power demand of FC power request.
FB control:-

In FB control subsystem the power request is compared with net power of FC to create a error values feeded to proportional,intrgral and derivative gains to acheive the
FC power demand request.
The current output from lookup table and from FB control is summed up and given to a switch to extract only positive power demands to get final FC stack ccurrent.
This is because the FC can't having the ability to store energy chemically back.
FC system:-

The fuel cell stack current is used to extract the optimal pressure values from current Vs optimal pressure lookup table given as input to H2 & O2 consumption subsystem.Stack current is also given as input to this subsystem.The outputs of this subsystem are H2 consumption(Kg/s),O2 consumption(Kg/s),FC stack power(KW) and stack voltage(V).
The optimal pressure(bar) along with ambient pressure(bar),compressor speed(rpm) and ambient temperature(K) are given as inputs to compressor model to get output compressor power.
Compressor model:-

The output of this subsystem is compressor power output(KW).
Static screw system:-

The optimal pressure divide by ambient pressure to get the pressure ratio used along with compressor speed to get the air mass flow(Kg/s) values from a 2Dlookup table .
The same inputs are used to get the eta adiabatic pressure values from a 2D lookup table.
Adiabatic pressure system:-

The air mass flow mulltiplied with ambient pressure is again multiplied with [1-(pressure ratio^((1.4-1)/1.4))] and divided with optimal pressure to get compressor power output.
H2 & O2 consumption sybsystem:-

In this subsystem the inputs are optimal pressure and stack current.
The outputs from stack voltage and power system are FC stack voltage and FC stack power output.
The O2 and H2 consumptions are calculated in the second subsysteem.
Stack voltage system:-

Using optimal pressure and current density(get from stack current) the single FC voltage values are extracted from a 2D lookup table multiplied by number of fuel cells in series(FC.N) gives total output FC stack voltage.
The stack current and total stack voltage multiplied to get FC stack power output.
Air and H2 consumption system:-

O2 consumption=(I*AFR*n_cell*molar mass of O2)/(4*Faraday constant)
H2 consumption=(I*n_cell*molar mass of H2)/(2*H2 utility factor*Faraday constant)
From these above relations this subsystem is created to get H2 and O2 consumptions values in Kg/s.
From the stack power output,the compressor power and auxilary load power values are subtracted to get final net power output of fuel cell.
Conversion of H2 consumption from Kg/s to Kg:-
The H2 consumption in Kg/s is integrated with time interval 0 to infinity to get resultant fuel(H2) consumption in Kg.
Additionally a condition to stop simulation is modelled if the fuel consumption reaches above 5 Kg of fuel tank size.

Ultracapacitor model-

From this subsystem we will get the results of UC SOC,UC voltage and UC current values.
This subsystem consist of different subsystems namely,
- UC_Current.
- UC_OCV.
- UC_Charge.
- UC_SOC.
UC current:-

The ultracapacitor current values are calculated from the relation,
UC(I)=(UCsoc⋅Vmax)−√(UCsoc⋅Vmax)2−4⋅R⋅UCeff⋅PUC/2R
This relation is implemented in this subsystem as shown above.
UC OCV :-

The relation to find the UC open circuit voltage is
UCocv=∫[iC]dtUCocv=∫[iC]dt
This is implimented inthis subsystem.
UC_Charge:-

The net voltage of ultracapacitor multiplied with Capacitance of UC gives the UC_charge value.
UC_SOC:-

From the relation mentioned below the SOC of UC is calculated.
UCsoc=∫[I⋅UCEffQ]dtUCsoc=∫[I⋅UCEffQ]dt
This integrated SOC values are subtracted from UC Nominal SOC value to get final SOC value of the UC.
UC_Voltage:-

The relation to find the UC voltage as,
UC(Voltage)=(SOC*V_max)-(i*R)
This relation is created in this subsystem as shown above.
Based on the changes in UC_SOC values the voltage also varies with respect to UC_Current values and UC resistance value(Voltage drop due to internal capacitor resistance.
Battery model:-
The relation to find the UC voltage as,
UC(Voltage)=(SOC*V_max)-(i*R)
This relation is created in this subsystem as shown above.
Based on the changes in UC_SOC values the voltage also varies with respect to UC_Current values and UC resistance value(Voltage drop due to internal capacitor resistance.
Battery model:-

In this subsystem the input as battery power request and from this input we can calculate the battery SOC values, battery current,voltage values.
Two subsystems are created namely,
- Battery current,voltage.
- Battery SOC.
Battery Current,Voltage:-

In this subsystem the inputs are battery power request and Battery SOC as feedback from SOC subsystem.
Based on battery SOC values the battery cell voltage values are extracted from SOC Vs VOltage 1D lookup table multiplied with No.of Series cell(44) to get battery stack voltage.
Based on SOC values the battery cell charge and discharge resistance values are extracted from 1D lookup tables multiplied by no.of series cells(44), divided from the battery power request and taking sqrt on them to get charging and discharging battery current values.
This is from the relation,
Bat.current=√Bat.pwrBat/ResistanceBat.current
Here charging current and discharging current from battery are seperated from a switch multiplied with no.of parallel cells(1) to get final battery current values.
Battery SOC:-

The battery current from battery current,voltage subsystem is integrated and divided by battery capacity and subtracted from the nominal battery SOC value to get the final battery SOC values.
This can be given in relation,
SOC(t)=SOC(t−1)+∫(iQ)dtSOC(t)=SOC(t-1)+∫(iQ)dt
Where,
Positive current for discharging
Negative current for charging.
This relation is inplimented in this subsystem where when battery current is -ve represents charging as SOC gets added up with nominal SOC value and if battery current +ve represent discharging as SOC gets subtracted from nominal SOC value.
4)Vehicle dynamics:-

- In this subsystem the input is the total traction force of vehicle generated from the power train subsystem.
- This Total resistance forces from rolling resistance,airdrag resistance and hill climbing resistance are get subtracted from the total traction force to get the resultant force.
- The resultant force is divided by mass to get the acceleration values.
- This acceleration values are integrated by using integrator block to get the vehicle velocity output.
- The output from integrator block given to a saturation block to consider the velocity values from 0 to infinity as vehicle velocity output.
- The integrator block is get reseted when the vehicle velocity reaches 0. This is done because as we are using integrator block it produces a integral windup.
- Integral windup means when the actual velocity tends to make match with desired velocity,some times a shoot up of corrected signal occurs which again makes next shootdown signal to attain its steady state desired velocity.
- To avoid this situation when the vehicle velocity gets to zero,the integrator block should get reseted.
- This makes the integrator to start the action again from initial state after the vehicle move from its rest condition.
- This action will avoid the windup situations.
- This can be acheived in model by verifying acceleration and velocity signals as reaching to Zero velocity.
- When the acceleration signal crosses 0 means the output from memory block is 0,as memory block output is precious input.Its makes a step delay.
- As same for velocity signal crosses 0 means the output from memory block becomes 0.
- Both values are summed up and given to a switch condition.
- If summed up values is above 0,satisfying the switch condition.Thus makes no resetting of integrator for positive values.
- If summed up value gets 0, the switch condition fails.Thus makes the integrator to reset.
Rolling resistance force:-

To find the rolling resistant force we have to multiply vehicle mass(Kg),acceleration due to gravity(m/S2),rolling resistance coefficient and cosine of angle of grradeability(in radian).
This can be given as a relation,
Frr=Mass*g*RR*cos(Alpha)
The Mass, g, RR values grade angle are assigned in base workspace.
The gradeability angle in degree is converted to rad by a trigonometric function block atan.
This converted rad value is given to cosine block and multiplied with other parameters as shown in figure.
The final RR force is checked in a switch with velocity condition.
If velocity is positve the RR force is given as output from this block.
Airdrag resistance force:-

To find the aero drag resistance force we have to multiply vehicle frontal area(m2),Air drag coefficient,air density(Kg/m3) and square of vehicle velocity(m/s).
This can be given as a relation,
Faero=0.5*FA*ADcoef*Airden*(Vehicle velocity ^2)
The FA,ADcoef,Airden values are assigned from base workspace.
The velocity of vehicle is get from a From block(output of model) and squared by square block.
All these parameters are get multiplied by a product block and again multiplied by a gain of 0.5 as per above relation.
This output is aero drag resistance force.
Hill climbing resistance force:-

- Hill climbing resistance force can be obtained by multiplying Mass of vehicle(Kg),Acceleration due to gravity(m/s^2),Rolling resistance coefficient and sine of angle of gradeability(in rad).
- This can be given in relation as,
- Fhc=Mass*g*RR*sin(Alpha)
- The Mass,g,RR values are assigned from base workspace.
- Sin of gradeability angle is obtained by a From block as angle is already converted to rad in Rolling resistance force calculation.
- All parameters are get multiplied in a product block and get hill climbing resistance force as shown above.
- Finally all these resistance forces are added and subtracted from total tractive force as we seen earlier to get resultant tractive force.
- After calculating the vehicle velocity values, this velocity is feed backed to the Driver subsystem for comparing with the desired velocity as from drive cycle source.
Initialization of parameters in workspace:-
Usinfg a scrift file attached with this project,all the parameters are initialized as shown below,
Once we run this script file all datas are loaded loaded into the workspace are reflecting in the model.
Results:-
As the drive cycle duration is 600 secs set stop time as 600secs and run the model.
Desired velocity Vs Actual vehicle velocity:-

From the plot we can understand that both desired and actual velocity of vehicle are controlled and matched.
Power sharing:-

From the above plot we can see the sharing of total power request among the Battery,UC and Fuel cell.
The power demand of above 55KW are acheived by the ultra capacitor.
The power demand of 0-23KW are acheived by battery.
And the power demand from above 23 KW upto 55 KW is acheived from Fuel cell.
For better visual we can see in the data inspector as,

In this the first plot shows the total power demand(yellow).
The same total power is shared among three energy sources as in second plot,
- UC Power(Red)-(>55KW)
- Battery power(Green)-(0-23KW)
- Fuel cell power(Navy blue)-(>23KW to 55KW)
SOC and H2 consumption:-

In these plots first plot represents the SOC of battery and second plot represents UC SOC.
The SOC of battery charges and discharge according to the power demands.It starts from 65% of SOC as we given initial SOC as nominal SOC (0.8+0.5)/2=0.65.
The SOC of UC charges and discharges and starts from 60% SOC as we given initial SOC as nominal SOC(0.8+0.4)/2=0.6.
The hydrogen consumption is shown as 0.1228 Kg from the display in model and its plot as shown above.
FC stack current:-

From this plot we can understand that the current drawn from FC is higher makes the fuel H2 consumption also higher.