How to plot graph of power vs speed and Speed vs torque using below speed?

58 views (last 30 days)
Good afternoon. I am trying to build graph of speed vs power and speed vs torque using below matlab code.
I want graph for four slopes such as 0%,4%,7% and 14%. I am unable to find solution of this, please help me .
Thank you
%% Rolling resistance force
Fr= M*g*fr*cos(alpha);
%% power required to overcome the rolling resistance Pr= Fr*V;
%% Force due to aerodyamnic drag Fw= 0.5*rho*Af*Cd*V^2*(1+Cw);
%% Power due aerodymanic drag Pw=0.5*rho*Af*Cd*V^3*(1+Cw);
%% Grading force Fg=M*g*sin(alpha);
%% grading power
Pg=M*g*V*sin(alpha);
%% total vehicle resitance force
Ftr =M*g*(fr*cos(alpha)+sin(alpha))+0.5*rho*Af*Cd*V^2*(1+Cw);
% Ftr=Fr+Fw+Fg;
%% vehicle accleration Ft=(V*M*delta)+Ftr; % acc =Ft-Ftr / M*delta;
% % Pt=Pwheel; %% Tractive power a=Vf^2+Vb^2; Pt0=2*ta; Pt1= delta*M/Pt0; Pt11=Pt1*a; b=fr*cos(alpha)+sin(alpha); Pt2=0.666*M*g*Vf*b; Pt3=0.2*rho*Cd*Af*Vf^3; Pt4=1/1000; Pt=Pt4*(Pt11+Pt2+Pt3);
%% power rating of electric motor (kW)
Pem1= (Pt11+Pt2+Pt3); Pem2=1/1000*nt; Pem=Pem2*Pem1;
for alpha =0:8;; aa=cos(alpha)+sin(alpha); ab=fr*aa; ac=0.666*M*g*Vf*ab; Ptt=Pt4*(Pt11+ac+Pt3); Pem111= (Pt11+Pt2+Pt3); Pem21=1/1000*nt; Pem9=Pem21*Pem111; end V=80; figure plot(V,Pem9,'Color','k','LineWidth',2.0); hold on;
% x = 0:80; % y=tan(alpha); % figure % plot(x,y)
Wem=60/2*3.14*RPMem;
%% Electric motor torque
Tem=Pem/Wem;
%% power output for energy or generator
Peg1=0.666*M*g*Vf*b+0.2*rho*Cd*Af*Vf^3; Peg2=1/1000*nt*nm; Peg=Peg2*Peg1; % %% average load power syms x c= (M*g*fr+0.5*rho*Cd*Af*V^2)*V; Pave1= int(c,x,0, T); Pavel1=1/T; Pave2=Pavel1*Pave1; syms y(x) d=functionalDerivative(V,y); Pave3=int(delta*M* d); Pave4=Pavel1*Pave3; Pave=Pave2+Pave4;
%% battery pack current
Ibatt=Pbatt/Vbatt;
%% energy capacity of battery pack
Qbatt=Ibatt*tpem;

Answers (1)

Joel Van Sickel
Joel Van Sickel on 2 Feb 2023
In general, to create these types of curves, you need to find some variable that you can sweep, to generate the curve. In your case, that variable should be tied to either power or torque. For instance, you could sweep the calculations over the full range of torques, for a given alpha, and then also calculate the equivalent power since that is known if you know speed and torque. You can then iterate on this for each value of alpha. Unfortunately, your code is missing a lot of parameters and doesn't work, so you need to first get a set of equations that work for a single operating condition before worrying about trying to generate a curve.
Here is an example for a very simple system with basic drag and gravity effects on vehicle dynamics. These equations are too simplistic to be realistic, particularly at the higher speeds:
grade = [0 .04 .07 .14]; % percent
slope = atan(grade);
Mass = 1814; % 2 ton car in kg;
g = 9.8;
fx = -g*Mass*sin(slope); % reverse force from gravity
cd = 0.3; % average drag coefficient for a car
area = 7.33*0.0929; % area for an Acura CL
density = 1.21; % density of air
r = .48; % radius of tire to convert torque to force
final_drive_ratio = 4.2;
gear_ratio = 1.2;
TorqueSweep = 0:1:200; % sweep betweein 0 and 200 NM on the engine
TorqueTireSweep = TorqueSweep*final_drive_ratio*gear_ratio;
ForceSweep = TorqueTireSweep/r;
n = length(TorqueSweep);
for i = 1:length(fx)
dragForce = ForceSweep + fx(i); % need to solve for steady state operating condition
dragForce = max(dragForce',zeros(1,n)');
speed(i,:) = sqrt(dragForce/(0.5*cd*area*density))*2.236; % converstion to mph
end
figure(1)
plot(TorqueSweep,speed)
legend('0','4%','7%','14%')
xlabel('Torque (Nm)')
ylabel('Speed (mph)')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!