Internal Combustion Engine Analysis
										
										            \(By\  : 
								\ \ \ \ Ida\ Karimfazli\ \ \((\ Undergradugate\ Student\ )\)\)
												Mohammad Mirzadeh ( Undergradugate Student )

										Mechanical Engineering Dep .  
              Faculty of Engineering 
													University of Tehran 
														March 2006

Off[General::"spell"];
Off[General::"spell1"];

<< Statistics`NonlinearFit`
<< Graphics`Colors`
<< Graphics`Legend`
<< Graphics`MultipleListPlot`

AutomobileName = 
        InputString[" Enter the name of automobile  "];
Print[""];
Print[""];
Print[""];
ν = 
        Input[" Enter the engine speeds(Rpm) for which you wish to enter \
the data , you should enter 10 numbers. i.e. {1500,2000,...} "];
T = 
        Input[" Enter the tourques(N.m) for the engine speeds you've \
entered. i.e {120,132,...} "];
rpmmax = ν[[10]];
rpmmin = ν[[1]];
G = 
        Input[" Enter the gear ratios , you should enter 5 numbers. i.e \
{3.25,1.85,1.28,0.969,0.757} "];
G3 = 
        G[[3]];
θ = π/180*
          Input[" Enter the road grades(degree) , you should enter 5 \
numbers. i.e {0,5,10,15,20} "];
AXR = 
        Input[" Enter the axel ratio "];
\(η\_d = 
        Input[" Enter the drivetrain efficiency "];\)
R = 
        Input[" Enter the wheel radius(meter) "];
(Subscript[μ, f]) = 
        Input[" Enter the coefficient of rolling resistance "];
m = 
        Input[" Enter the vehicle mass(kg) "];
(Subscript[A, F]) = Input[" Enter the frontal area(m^2) "];
(Subscript[C, D]) = 
        Input[" Enter the coefficient of drag "];
Print["*******************************************************************\
*********" ];
Show[
        Graphics[
          Text[StyleForm[AutomobileName, FontFamily ->  "Times", 
              FontSize ->  "25"], {6, 5}]], ImageSize -> 500, 
        AspectRatio ->  .05];
Print["*******************************************************************\
*********" ];
ρ = 
        1.2;
g = 9.81;




ϵ =  .04 +  .0025 (((AXR*G))^2);
(Subscript[P, b]) = (2*π*ν)/
            60*T;
V[rpm_] = 
        R*(1/(AXR*G))*2*π*
          rpm/60;
RoadLoad[velocity_] = 
        1/2  ρ*(Subscript[C, D])*(Subscript[A, F])*(velocity^2) + (Subscript[μ, f])*m*g*
            Cos[θ];
TotalLoad[velocity_] = 
          1/2  ρ*(Subscript[C, D])*(Subscript[A, F])*(velocity^2) + (Subscript[μ, f])*m*g*Cos[θ] + 
            m*g*Sin[θ];


Print[""];
Print[""];
Print[""];
Print[""];

Print["  -------------------  Solution for part # 1 -------------------    "];
Print[""];



btrpm = 
        ListPlot[Table[{ν[[i]], T[[i]]}, {i, 1, 10}], 
          PlotStyle -> PointSize[0.015], 
          DisplayFunction -> Identity];
For[
        n = 3, n ≤ 11, 
    BT[n] = 
          NonlinearFit[
            Table[{ν[[i]], T[[i]]}, {i, 1, 
                10}], (∑_(k = 1)^n) a[n][k]*(rpm^(k - 1)), {rpm}, 
            Array[a[n], 
              n]]; 
  n++];
btrpmc = 
        Plot[{BT[3], BT[4], BT[5], BT[6], BT[7], BT[8], BT[9], BT[10], 
            BT[11]}, {rpm, rpmmin, 
            rpmmax}, 
DisplayFunction -> 
            Identity, 
PlotStyle -> {Red, Blue, Peach, 
              CinnabarGreen, Violet, Brown, Black, Navy, 
              Orange}];
Print["            Curve-fit of brake Torque Vs. Rpm Using polynomials of degree 2 to 10"];
\(Show[btrpm, 
        btrpmc, 
DisplayFunction -> $DisplayFunction, 
TextStyle -> {FontFamily -> "Times", 
            FontSize -> 14}, 
ImageSize -> 
          550, 
AxesLabel -> {"Rpm", "N.m"}];\)
Main = 
        ShadowBox[{0, 0}, {1, 1}];
Show[Graphics[Main],
\(Graphics[
            Text[
              StyleForm[\*""\!\(2\^nd\) order"", 
                FontColor -> \ Red, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .7}]]\),
\(Graphics[
            Text[StyleForm[\*""\!\(3\^rd\) order"", 
                FontColor -> \ Blue, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .5}]]\),\(Graphics[
            Text[StyleForm[\*""\!\(4\^th\) order"", 
                FontColor -> \ Peach, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .3}]]\),Graphics[Text[StyleForm["(5^th) order",FontColor-> CinnabarGreen,FontFamily ->  "Times",FontSize ->  "14"],{ .5,  .7}]],\(Graphics[
            Text[StyleForm[\*""\!\(6\^th\) order"", 
                FontColor -> \ Violet, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .5}]]\),\(Graphics[
            Text[StyleForm[\*""\!\(7\^th\) order"", 
                FontColor -> \ Brown, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .3}]]\),\(Graphics[
            Text[StyleForm[\*""\!\(8\^th\) order"", 
                FontColor -> \ Black, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .7}]]\),\(Graphics[
            Text[StyleForm[\*""\!\(9\^th\) order"", 
                FontColor -> \ Navy, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .5}]]\),\(Graphics[
            Text[StyleForm[\*""\!\(10\^th\) order"", 
                FontColor -> \ Orange, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .3}]]\),
ImageSize ->  250];
Print[""];
Print[""];
Print["            Curve-fit of Brake Tourqe Vs. Rpm using polynomial of degree 5 "];
\(Show[
        Plot[BT[6], {rpm, rpmmin, 
            rpmmax}, 
DisplayFunction -> 
            Identity], 
\ \ btrpm, 
\ \ DisplayFunction -> $DisplayFunction, 
\ 
        TextStyle -> {FontFamily -> "Times", 
            FontSize -> 14}, 
ImageSize -> 
          550, 
AxesLabel -> {"Rpm", "N.m"}];\)
Print[""];
Print[""];
bprpm = 
        ListPlot[
          Table[{ν[[i]], (Subscript[P, b])[[i]]/1000}, {i, 1, 
              10}], 
PlotStyle -> PointSize[0.015], 
          DisplayFunction -> Identity];
For[
        n = 3, n ≤ 11, 
BP[n] = 
          BT[n]*rpm*2*π/
              60; 
n++];
bprpmc = 
        Plot[{BP[3]/1000, BP[4]/1000, BP[5]/1000, BP[6]/1000, 
            BP[7]/1000, BP[8]/1000, BP[9]/1000, BP[10]/1000, 
            BP[11]/1000}, {rpm, rpmmin, 
            rpmmax}, 
PlotStyle -> {Red, Blue, Peach, 
              EmeraldGreen, Violet, Brown, Black, Navy, 
              Orange}, 
DisplayFunction -> 
            Identity];
Print["            Curve-fit of Brake Power Vs. Rpm using polynomials of degree 3 to 11 "];
\(Show[bprpm, 
        bprpmc, 
DisplayFunction -> $DisplayFunction, 
TextStyle -> {FontFamily -> "Times", 
            FontSize -> 14}, 
ImageSize -> 
          550, 
AxesLabel -> {"Rpm", "kW"}];\)
\(Show[
        Graphics[Main], 
Graphics[
          Text[StyleForm[\*""(3^rd) order"", 
              FontColor -> \ Red, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .2,  .7}]], 
        Graphics[
          Text[StyleForm[\*""(4^th) order"", 
              FontColor -> \ Blue, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .2,  .5}]], 
        Graphics[
          Text[StyleForm[\*""(5^th) order"", 
              FontColor -> \ Peach, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .2,  .3}]], 
        Graphics[
          Text[StyleForm[\*""(6^th) order"", 
              FontColor -> \ EmeraldGreen, 
              FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .5,  .7}]], 
        Graphics[
          Text[StyleForm[\*""(7^th) order"", 
              FontColor -> \ Violet, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .5,  .5}]], 
        Graphics[
          Text[StyleForm[\*""(8^th) order"", 
              FontColor -> \ Brown, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .5,  .3}]], 
        Graphics[
          Text[StyleForm[\*""(9^th) order"", 
              FontColor -> \ Black, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .8,  .7}]], 
        Graphics[
          Text[StyleForm[\*""(10^th) order"", 
              FontColor -> \ Navy, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .8,  .5}]], 
        Graphics[
          Text[StyleForm[\*""(11^th) order"", 
              FontColor -> \ Orange, FontFamily -> \ "Times", 
              FontSize -> \ "14"], { .8,  .3}]], 
ImageSize -> \ 
          250];\)
Print[""];
Print[""];
Print["            Curve-fit of Brake Power Vs. Rpm using polynomial of degree 6"];
\(Show[
          Plot[BP[6]/1000, {rpm, rpmmin, rpmmax}, 
            DisplayFunction -> Identity], 
bprpm, 
          DisplayFunction -> $DisplayFunction, 
TextStyle -> {FontFamily -> "Times", 
              FontSize -> 14}, 
ImageSize -> 
            550, 
AxesLabel -> {"Rpm", "kW"}];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 2  -------------------    "];
Print[""];


Print[""];
Print["            Rpm Vs. Velocity"]; 
\(ParametricPlot[{{3.6*\(V[
                  rpm]\)[\([1]\)], rpm}, {3.6*\(V[rpm]\)[\([2]\)], 
            rpm}, {3.6*\(V[rpm]\)[\([3]\)], rpm}, {3.6*\(V[rpm]\)[\([4]\)], 
            rpm}, {3.6*\(V[rpm]\)[\([5]\)], rpm}}, {rpm, rpmmin, 
          rpmmax}, 
TextStyle -> {FontFamily -> "Times", FontSize -> 14}, 
ImageSize -> 
          550, 
PlotStyle -> {Black, Brown, Red, Blue, 
            EmeraldGreen}, 
AxesLabel -> {\*""(km/h)"", "Rpm"}];\)
Main = 
        ShadowBox[{0, 0}, {1,  .4}];
\(Show[
          Graphics[ShadowBox[{0, 0}, {1,  .4}]], 
Graphics[
            Text[StyleForm[\*""(1^st) Gear"", 
                FontColor -> \ Black, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(2^nd) Gear"", 
                FontColor -> \ Brown, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(3^rd) Gear"", 
                FontColor -> \ Red, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(4^th) Gear"", 
                FontColor -> \ Blue, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .15}]], 
          Graphics[
            Text[StyleForm[\*""(5^th) Gear"", 
                FontColor -> EmeraldGreen, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .15}]], 
ImageSize -> 250];\)


Print[""];
Print[""];
Print["  -------------------  Solution for part # 3  -------------------    "];
Print[""];
Print[""];



Print["            Roadload Vs. Velocity"];
\(ParametricPlot[{{v, \(RoadLoad[v\/3.6]\)[\([1]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([2]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([3]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([4]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([5]\)]\/1000}}, {v, 0, 
          220}, 
TextStyle -> {FontFamily -> "Times", FontSize -> 14}, 
ImageSize -> 
          550, 
AxesLabel -> {\*""(km/h)"", "kN"}];\)
Print[""];
Print[""];
Print["            Roadload Vs. Velocity"];
\(ParametricPlot[{{v, \(RoadLoad[v\/3.6]\)[\([1]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([2]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([3]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([4]\)]\/1000}, {v, \(RoadLoad[v\/3.6]\)[\([5]\)]\/1000}}, {v, 0, 
          10}, 
TextStyle -> {FontFamily -> "Times", FontSize -> 14}, 
ImageSize -> 
          550, 
PlotStyle -> {Black, Brown, Red, Blue, 
            EmeraldGreen}, 
AxesLabel -> {\*""(km/h)"", "kN"}];\)
Main = 
        ShadowBox[{0, 0}, {1,  .4}];
\(Show[
          Graphics[Main], 
Graphics[
            Text[StyleForm["0° Slope", FontColor -> \ Black, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .25}]], 
          Graphics[
            Text[StyleForm["5° Slope", FontColor -> \ Brown, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .25}]], 
          Graphics[
            Text[StyleForm["10° Slope", FontColor -> \ Red, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .25}]], 
          Graphics[
            Text[StyleForm["15° Slope", FontColor -> \ Blue, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .15}]], 
          Graphics[
            Text[StyleForm["20° Slope", 
                FontColor -> \ EmeraldGreen, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .15}]], 
ImageSize -> 250];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 4 -------------------    "];
Print[""];
Print[""];



For[i = 1, 
        i ≤ 6, 
        tfv[i] = ((3.6*20000  i)/v); i++];
TFV = Plot[{tfv[1]/1000, tfv[2]/1000, tfv[3]/1000, tfv[4]/1000, 
            tfv[5]/1000, tfv[6]/1000}, {v, 0, 220}, 
          DisplayFunction -> Identity, PlotRange -> {0, 8}, 
          PlotStyle -> {Black, Brown, Red, Blue, EmeraldGreen, 
              Violet}];
Print["            Traction Force Vs. Velocity"];
\(Show[TFV, 
        DisplayFunction -> $DisplayFunction, 
TextStyle -> {FontFamily -> "Times", 
            FontSize -> 14}, 
ImageSize -> 
          550, 
AxesLabel -> {\*""(km/h)"", "kN"}];\)
Main = 
        ShadowBox[{0, 0}, {1, 1}];
\(Show[
          Graphics[Main], 
Graphics[
            Text[StyleForm["20 kW", FontColor -> \ Black, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .7}]], 
          Graphics[
            Text[StyleForm["40 kW", FontColor -> \ Brown, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .7}]], 
          Graphics[
            Text[StyleForm["60 kW", FontColor -> \ Red, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .7}]], 
          Graphics[
            Text[StyleForm["80 kW", FontColor -> \ Blue, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .3}]], 
          Graphics[
            Text[StyleForm["100 kW", FontColor -> EmeraldGreen, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .3}]], 
          Graphics[
            Text[StyleForm["120 kW", FontColor -> \ Violet, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .3}]], 
ImageSize -> 250];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 5  -------------------    "];
Print[""];
Print[""];



For[i = 1, 
        i ≤ 
          5, 
NTF[rpm_][
            i] = (((Subscript[η, d])*BP[6])/(V[rpm]))[[i]] - RoadLoad[V[
                    rpm][[i]]][[1]]; 
i++];
Print["            Net Traction Force Vs. Rpm"];
\(Plot[{\(NTF[rpm]\)[1]\/1000, \(NTF[rpm]\)[2]\/1000, \(NTF[rpm]\)[3]\/1000, \(NTF[rpm]\)[4]\/1000, \(NTF[rpm]\)[5]\/1000}, {rpm, rpmmin, 
          rpmmax}, 
TextStyle -> {FontFamily -> "Times", FontSize -> 14}, 
ImageSize -> 
          550, 
PlotStyle -> {Black, Brown, Red, Blue, 
            EmeraldGreen}, 
AxesLabel -> {"Rpm", "kN"}];\)
Main = 
        ShadowBox[{0, 0}, {1,  .4}];
\(Show[
          Graphics[Main], 
Graphics[
            Text[StyleForm[\*""(1^st) Gear"", 
                FontColor -> \ Black, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(2^nd) Gear"", 
                FontColor -> \ Brown, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .25}]], 
          Graphics[
            Text[
              StyleForm[\*""(3^rd) Gear"", 
                FontColor -> \ Red, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(4^th) Gear"", 
                FontColor -> \ Blue, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .15}]], 
          Graphics[
            Text[StyleForm[\*""(5^th) Gear"", 
                FontColor -> EmeraldGreen, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .15}]], 
ImageSize -> 250];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 6  -------------------    "];
Print[""];
Print[""];



Print["                     Traction-Force diagram"];
\(Show[
          Plot[{tfv[1]\/1000, tfv[2]\/1000, tfv[3]\/1000, tfv[4]\/1000, 
              tfv[5]\/1000, tfv[6]\/1000}, {v, 0, 
              220}, 
DisplayFunction -> 
              Identity, 
PlotRange -> {0, 
                8}, 
PlotStyle -> {Black, Brown, Red, 
                Blue, EmeraldGreen, Violet}], 
          Plot[{\(TotalLoad[v\/3.6]\)[\([1]\)]\/1000, \(TotalLoad[v\/3.6]\)[\([2]\)]\/1000, \(TotalLoad[v\/3.6]\)[\([3]\)]\/1000, \(TotalLoad[v\/3.6]\)[\([4]\)]\/1000, \(TotalLoad[v\/3.6]\)[\([5]\)]\/1000}, {v, 0, 220}, 
DisplayFunction -> 
              Identity, 
PlotStyle -> {Black, Brown, 
                Red, Blue, EmeraldGreen}], 
          ParametricPlot[{{3.6*\(V[
                      rpm]\)[\([1]\)], \(η\_d*BP[6]\)\/\(1000*\(V[rpm]\)[\([1]\)]\)}, {3.6*\(V[
                      rpm]\)[\([2]\)], \(η\_d*BP[6]\)\/\(1000*\(V[rpm]\)[\([2]\)]\)}, {3.6*\(V[
                      rpm]\)[\([3]\)], \(η\_d*BP[6]\)\/\(1000*\(V[rpm]\)[\([3]\)]\)}, {3.6*\(V[
                      rpm]\)[\([4]\)], \(η\_d*BP[6]\)\/\(1000*\(V[rpm]\)[\([4]\)]\)}, {3.6*\(V[
                      rpm]\)[\([5]\)], \(η\_d*BP[6]\)\/\(1000*\(V[rpm]\)[\([5]\)]\)}}, {rpm, rpmmin, 
              rpmmax}, 
DisplayFunction -> 
              Identity, 
PlotStyle -> {Black, Brown, 
                Red, Blue, 
                EmeraldGreen}], 
DisplayFunction -> $DisplayFunction, 
TextStyle -> {FontFamily -> "Times", FontSize -> 14}, 
ImageSize -> 
            550, 
AxesLabel -> {\*""(km/h)"", "kN"}];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 7  -------------------    "];
Print[""];
Print[""];



Print[ "            Acceleration of each gear Vs. Velocity"];
\(ParametricPlot[{{3.6*\(V[
                  rpm]\)[\([1]\)], \(NTF[rpm]\)[1]\/\(m*\((1 + ϵ[\([1]\)])\)\)}, {3.6*\(V[
                  rpm]\)[\([2]\)], \(NTF[rpm]\)[2]\/\(m*\((1 + ϵ[\([2]\)])\)\)}, {3.6*\(V[
                  rpm]\)[\([3]\)], \(NTF[rpm]\)[3]\/\(m*\((1 + ϵ[\([3]\)])\)\)}, {3.6*\(V[
                  rpm]\)[\([4]\)], \(NTF[rpm]\)[4]\/\(m*\((1 + ϵ[\([4]\)])\)\)}, {3.6*\(V[
                  rpm]\)[\([5]\)], \(NTF[rpm]\)[5]\/\(m*\((1 + ϵ[\([5]\)])\)\)}}, {rpm, rpmmin, 
          rpmmax}, 
TextStyle -> {FontFamily -> "Times", FontSize -> 14}, 
ImageSize -> 
          550, 
PlotStyle -> {Black, Brown, Red, Blue, 
            EmeraldGreen}, 
AxesLabel -> {\*""(km/h)"", \*""(m/(s^2))""}];\)
Main = 
        ShadowBox[{0, 0}, {1,  .4}];
\(Show[
          Graphics[Main], 
Graphics[
            Text[StyleForm[\*""(1^st) Gear"", 
                FontColor -> \ Black, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(2^nd) Gear"", 
                FontColor -> \ Brown, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(3^rd) Gear"", 
                FontColor -> \ Red, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .8,  .25}]], 
          Graphics[
            Text[StyleForm[\*""(4^th) Gear"", 
                FontColor -> \ Blue, FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .2,  .15}]], 
          Graphics[
            Text[StyleForm[\*""(5^th) Gear"", 
                FontColor -> EmeraldGreen, 
                FontFamily -> \ "Times", 
                FontSize -> \ "14"], { .5,  .15}]], 
ImageSize -> 250];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 8  -------------------    "];
Print[""];
Print[""];



Clear[
        rpm];
V[rpm_] = 
        R*(1/(AXR*G))*2*π*rpm/60;
For[
        i = 1, i ≤ 5, 
For[j = 1, 
          j ≤ 5, 
a[i, j] = 
            rpm /. Solve[(((Subscript[η, d])*BP[6])/(V[rpm]))[[j]] - TotalLoad[V[rpm][[j]]][[i]] == 0, 
                rpm]; 
Clear[
            rpm]; 
j++]; 
i++];
For[k = 1, 
        k ≤ 5, 
For[j = 1, 
          j ≤ 5, 
For[i = 1, 
            i ≤ 5, 
If[
              Im[a[k, j][[i]]] ≠  0, 
              a[k, j] = 
                ReplacePart[a[k, j], 0, 
                  i], 
If[a[k, j][[i]] < 
                  rpmmin   , 
                a[k, j] = 
                  ReplacePart[a[k, j], 0, 
                    i], 
If[a[k, j][[i]] > 
                    rpmmax , 
                  a[k, j] = 
                    ReplacePart[a[k, j], 0, 
                      i]]]]; 
i++]; 
For[i = 1, 
            i ≤ 5, 
If[Max[a[k, j]] == 0, 
              rpm = ((rpmmax + rpmmin)/2); 
If[(((Subscript[η, d])*BP[6])/(V[rpm]))[[j]] - TotalLoad[V[rpm][[j]]][[k]] > 0, 
                a[k, j] = 
                  ReplacePart[a[k, j], rpmmax, 
                    i]]]; 
i++]; 
a[
              k, j] = Sort[a[k, j], 
              Greater]; 
j++]; 
k++];
For[i = 1, 
        i ≤ 5, 
For[j = 1, 
          j ≤ 
            5, 
v[i, 
              j] = V[a[i, 
                    j][[1]]][[j]]; 
j++]; 
i++];
For[i = 1, 
        i ≤ 5, 
Gear[i] = 
          Table[v[i, j], {j, 
              5}]; 
i++];
For[i = 1,i ≤ 5,GearNo[i] = Ordering[Gear[i], 1, Greater];Print["For ",5*(i - 1),"°  Slope ", " gear number ",GearNo[i][[1]]," gives the maximum speed of ",3.6*Max[Gear[i]] ," (km/h) "," @ ",Max[a[i, GearNo[i][[1]]]]," rpm." ];i++];
Clear[rpm];



Print[""];
Print[""];
Print["  -------------------  Solution for part # 9  -------------------    "];
Print[""];
Print[""];



Clear[
        rpm];
V[rpm_] = 
        R*(1/(AXR*G))*2*π*rpm/60;
For[
        i = 1, i ≤ 250, 
a[i] = 
          rpm /. Solve[(((Subscript[η, d])*BP[6])/(V[rpm]))[[5]] - (1/2) ρ*((3/250) i)*(Subscript[A, F])*V[rpm][[5]]^2 - (Subscript[μ, f])*m*g*
                    Cos[θ[[1]]] - 
                  m*g*Sin[θ[[1]]] == 0, 
              rpm]; 
For[j = 1, 
          j ≤ 5, 
If[
            Im[a[i][[j]]] ≠  0, 
            a[i] = ReplacePart[a[i], 0, 
                j], 
If[a[i][[j]] > rpmmax, 
              a[i] = ReplacePart[a[i], 0, 
                  j], 
If[a[i][[j]] < rpmmin, 
                a[i] = ReplacePart[a[i], 0, 
                    j]
]
]
]; 
j++]; 
If[
          Max[a[i]] == 0, 
          rpm = ((rpmmax + rpmmin)/2); 
If[
(((Subscript[η, d])*BP[6])/(V[rpm]))[[5]] - (1/2) ρ*((3/250) i)*(Subscript[A, F])*V[rpm][[5]]^2 - (Subscript[μ, f])*m*g*
                  Cos[θ[[1]]] - 
                m*g*Sin[θ[[1]]] ≥  0, 
            a[i] = ReplacePart[a[i], rpmmax, 
                1]]]; 

v[
            i] = {((3/250) i), 
            3.6*V[Max[a[i]]][[5]]}; 
Clear[
          rpm]; 
i++];
Velocity = Array[v, 250];
Print["            Velocity Vs. Coefficient of Drag((Subscript[C, D]))"];
\(ListPlot[Velocity, 
          PlotStyle -> 
            PointSize[ .005], 
TextStyle -> {FontFamily -> "Times", 
              FontSize -> 14}, 
ImageSize -> 
            550, 
AxesLabel -> {\*""(Subscript[C, D])"", \*""(km/h)""}];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 10  -------------------    "];
Print[""];
Print[""];


shiftingtime[v_] = 
        Table[∫(m/(-TotalLoad[
                        v][[1]])) \[DifferentialD]v, {i, 
            3}];
For[k = 0, 
        k ≤ 
          50, 
VS[k] = 
Table[
            x /. NSolve[shiftingtime[
                        x][[i]] - shiftingtime[V[
                            rpmmax][[i]]][[i]] == (3/50) 
                    k, x], {i, 2}]; 
AccelerationCapability[
            k] = 
NIntegrate[
              (1/(NTF[((60*v)/(R*((1/(AXR*G[[1]])))*2*π))][1]/(m*(1 + ϵ[[1]])))), {v, V[rpmmin][[1]], V[
                    rpmmax][[1]]}] + 
            NIntegrate[
              (1/(NTF[((60*v)/(R*((1/(AXR*G[[2]])))*2*π))][2]/(m*(1 + ϵ[[2]])))), {v, VS[
                      k][[1]][[1]], V[rpmmax][[2]]}] + 
            NIntegrate[
              (1/(NTF[((60*v)/(R*((1/(AXR*G[[3]])))*2*π))][3]/(m*(1 + ϵ[[3]])))), {v, VS[
                      k][[2]][[1]], 
                (100/3.6)}] + 
2*(3/150) 
              k; 
k++];
Print["            Acceleration capability Vs. Gear shifting time"];
\(ListPlot[
          Table[{\(3\/50\) k, AccelerationCapability[k]}, {k, 0, 
              50}], 
ImageSize -> 
            550, 
PlotStyle -> 
            PointSize[ .01], 
TextStyle -> {FontFamily -> "Times", 
              FontSize -> 
                14}, 
AxesLabel -> {"s", "s"}];\)



Print[""];
Print[""];
Print["  -------------------  Solution for part # 11  -------------------    "];
Print[""];
Print[""];



m = 
        m + 4*70;
shiftingtime[
          v_] = 
Table[∫(m/(-TotalLoad[
                        v][[1]])) \[DifferentialD]v, {i, 
            3}];
For[k = 0, 
        k ≤ 
          50, 
VS[k] = 
Table[
            x /. NSolve[shiftingtime[
                        x][[i]] - shiftingtime[V[
                            rpmmax][[i]]][[i]] == (3/50) 
                    k, x], {i, 2}]; 
AccelerationCapability[
            k] = 
NIntegrate[
              (1/(NTF[((60*v)/(R*((1/(AXR*G[[1]])))*2*π))][1]/(m*(1 + ϵ[[1]])))), {v, V[rpmmin][[1]], V[
                    rpmmax][[1]]}] + 
NIntegrate[
              (1/(NTF[((60*v)/(R*((1/(AXR*G[[2]])))*2*π))][2]/(m*(1 + ϵ[[2]])))), {v, VS[
                      k][[1]][[1]], V[
                    rpmmax][[2]]}] + 
NIntegrate[
              (1/(NTF[((60*v)/(R*((1/(AXR*G[[3]])))*2*π))][3]/(m*(1 + ϵ[[3]])))), {v, VS[
                      k][[2]][[1]], 
                (100/3.6)}] + 
2*(3/150) 
              k; 
k++];
Print["   Acceleration capability(s) Vs. Gear shifting time(s),Transporting 4 people, each weighting 70 kg"];
\(ListPlot[
        Table[{\(3\/50\) k, AccelerationCapability[k]}, {k, 50}], 
        ImageSize -> 550, PlotStyle -> PointSize[ .01], 
        TextStyle -> {FontFamily -> "Times", 
            FontSize -> 
              14}, 
AxesLabel -> {"s", "s"}\ ];\)
m = m - 4*70;



Print[""];
Print[""];
Print["  -------------------  Solution for part # 12  -------------------    "];
Print[""];
Print[""];



Clear[shiftingtime, 
        VS, AccelerationCapability, 
        k];
NTFCD[rpm_, 
          k_] = (((Subscript[η, d])*BP[6])/V)[rpm] - (1/2) ρ*(2/50) k*
            (Subscript[A, F])*V[rpm]^2 - (Subscript[μ, f])*m*g*Cos[θ[[1]]] - 
          m*g*Sin[θ[[1]]];
For[k = 0, 
        k ≤ 25, 
shiftingtime[v_][k] = 
          Table[∫(m/(-((1/2) ρ*(2/50) k*(Subscript[A, F])*
                            (v^2) + (Subscript[μ, f])*m*g*Cos[θ[[1]]] + 
                          m*g*Sin[θ[[1]]]))) \[DifferentialD]v, {i, 
              3}]; 
k++];
For[k = 0, 
        k ≤ 25, 
For[j = 1, 
          j ≤ 6, 
VS[k, j] = 
            Table[x /. 
                NSolve[shiftingtime[x][
                          k][[i]] - shiftingtime[V[
                                rpmmax][[i]]][k][[i]] == 
                    (j/2), x], {i, 
                2}]; 
AccelerationCapability[k, j] = 
            NIntegrate[
                (1/(NTFCD[((60*v)/(R*((1/(AXR*G[[1]])))*2*π)), k][[1]]/(m*(1 + ϵ[[1]])))), {v, V[
                      rpmmin][[1]], V[
                      rpmmax][[1]]}] + 
2*(3/150) 
                k + NIntegrate[
                (1/(NTFCD[((60*v)/(R*((1/(AXR*G[[2]])))*2*π)), k][[2]]/(m*(1 + ϵ[[2]])))), {v, VS[k, 
                        j][[1]][[1]], V[rpmmax][[2]]}] + 
              NIntegrate[
                (1/(NTFCD[((60*v)/(R*((1/(AXR*G[[3]])))*2*π)), k][[3]]/(m*(1 + ϵ[[3]])))), {v, VS[k, 
                        j][[2]][[1]], 
                  (100/3.6)}]; 
j++]; 
k++];
Print[ "                        Acceleration capability(s) vs. Coefficient of drag ((Subscript[C, D]))"];
MultipleListPlot[
Table[{(2/50) k, AccelerationCapability[k, 1]}, {k, 
                25}],Table[{(2/50) k, AccelerationCapability[k, 2]}, {k, 
                25}],Table[{(2/50) k, AccelerationCapability[k, 3]}, {k, 
                25}],Table[{(2/50) k, AccelerationCapability[k, 4]}, {k, 
                25}],Table[{(2/50) k, AccelerationCapability[k, 5]}, {k, 
                25}],Table[{(2/50) k, AccelerationCapability[k, 6]}, {k, 
                25}],PlotLegend-> {"0.5 sec.","1 sec.","1.5 sec.","2 sec.","2.5 sec.","3 sec."},
LegendLabel-> "Gear shifting time",
LegendSize -> { .55, 1.1},
LegendPosition -> {1.1, - .55},
SymbolStyle->{Red,Black,Blue,Violet,CinnabarGreen,Gray},
ImageSize -> 600,
\(TextStyle -> {FontFamily -> "Times", FontSize -> 14}\),
AxesLabel -> {"", "s"}];



Print[""];
Print[""];
Print["  -------------------  Solution for part # 13  -------------------    "];
Print[""];
Print[""];



Clear[shiftingtime, 
        VS, AccelerationCapability, 
        i];
NTFslope[
          rpm_, α_] = (((Subscript[η, d])*BP[6])/V)[rpm] - (1/2) ρ*
            (Subscript[C, D])*(Subscript[A, F])*V[rpm]^2 - (Subscript[μ, f])*m*g*Cos[α] - 
          m*g*Sin[α];
For[k = 0, 
        k ≤ 
          50, 
shiftingtime[v_][
            k] = 
Table[∫(m/(-((1/2) ρ*(Subscript[C, D])*(Subscript[A, F])*(v^2) + (Subscript[μ, f])*m*g*Cos[(π/180)*(6/50)*k] + 
                          m*g*Sin[(π/180)*(6/50)*
                                k]))) \[DifferentialD]v, {i, 
              3}]; 
k++];
For[k = 0, 
        k ≤ 50, 
For[j = 1, 
          j ≤ 
            6, 
VS[k, j] = 
Table[
              x /. NSolve[shiftingtime[x][
                          k][[i]] - shiftingtime[V[
                                rpmmax][[i]]][k][[i]] == 
                    (j/2), x], {i, 
                2}]; 
AccelerationCapability[k, 
              j] = 
NIntegrate[
                (1/(NTFslope[((60*v)/(R*((1/(AXR*G[[1]])))*2*π)), (π/180)*(6/50)*k][[1]]/(m*(1 + ϵ[[1]])))), {v, V[rpmmin][[1]], V[
                      rpmmax][[1]]}] + 
NIntegrate[
                (1/(NTFslope[((60*v)/(R*((1/(AXR*G[[2]])))*2*π)), (π/180)*(6/50)*k][[2]]/(m*(1 + ϵ[[2]])))), {v, VS[k, j][[1]][[1]], V[
                      rpmmax][[2]]}] + 
              NIntegrate[
                (1/(NTFslope[((60*v)/(R*((1/(AXR*G[[3]])))*2*π)), (π/180)*(6/50)*k][[3]]/(m*(1 + ϵ[[3]])))), {v, VS[k, 
                        j][[2]][[1]], 
(100/3.6)}] + 
2*(3/150) 
                k; 
j++]; 
k++];
Print["            Acceleration capability(s) vs. Slop (°)"];
MultipleListPlot[
Table[{(6/50) k, AccelerationCapability[k, 1]}, {k, 
                50}],Table[{(6/50) k, AccelerationCapability[k, 2]}, {k, 
                50}],Table[{(6/50) k, AccelerationCapability[k, 3]}, {k, 
                50}],Table[{(6/50) k, AccelerationCapability[k, 4]}, {k, 
                50}],Table[{(6/50) k, AccelerationCapability[k, 5]}, {k, 
                50}],Table[{(6/50) k, AccelerationCapability[k, 6]}, {k, 
                50}],PlotLegend-> {"0.5 sec.","1 sec.","1.5 sec.","2 sec.","2.5 sec.","3 sec."},
LegendLabel-> "Gear shifting time",
LegendSize -> { .55, 1.1},
LegendPosition -> {1.1, - .55},
SymbolStyle->{Red,Black,Blue,Violet,CinnabarGreen,Gray},
ImageSize -> 600,
\(TextStyle -> {FontFamily -> "Times", FontSize -> 14}\),
\(AxesLabel -> {" Degree ", "s"}\) ];



Print[""];
Print[""];
Print["  -------------------  Solution for part # 14  -------------------    "];
Print[""];
Print[""];



Clear[shiftingtime, 
        VS, AccelerationCapability];
shiftingtime[
          v_] = 
Table[∫(m/(-((1/2) ρ*(Subscript[C, D])*(Subscript[A, F])*(v^2) + (Subscript[μ, f])*m*g*Cos[0] + 
                        m*g*Sin[0]))) \[DifferentialD]v, {i, 
            3}];
For[k = 50, 
        k ≥ 
          0, 
VS12[k] = 
x /. 
            NSolve[shiftingtime[
                      x][[1]] - shiftingtime[V[(((rpmmax - 
                                      rpmmin))/50) k + 
                            rpmmin][[1]]][[1]] == 1, 
              x]; 
For[j = 50, 
          j ≥ 
            k, 
VS23[j] = 
x /. 
              NSolve[shiftingtime[
                        x][[2]] - shiftingtime[V[(((rpmmax - 
                                        rpmmin))/50) j + 
                              rpmmin][[2]]][[2]] == 1, 
                x]; 
AccelerationCapability[k, 
              j] = 
NIntegrate[
                (1/(NTF[((60*v)/(R*((1/(AXR*G[[1]])))*2*π))][1]/(m*(1 + ϵ[[1]])))), {v, V[
                      rpmmin][[1]], V[(((rpmmax - rpmmin))/50) 
                          k + rpmmin][[1]]}] + 
NIntegrate[
                (1/(NTF[((60*v)/(R*((1/(AXR*G[[2]])))*2*π))][2]/(m*(1 + ϵ[[2]])))), {v, VS12[
                      k][[1]], V[(((rpmmax - rpmmin))/50) j + 
                        rpmmin][[2]]}] + 
              NIntegrate[
                (1/(NTF[((60*v)/(R*((1/(AXR*G[[3]])))*2*π))][3]/(m*(1 + ϵ[[3]])))), {v, VS23[j][[1]], 
                  (100/3.6)}] + 2; 
j = 
            j - 1]; 
k = 
          k - 1];
data = {};
For[k = 0, 
        k ≤ 
          50, 
data = 
Join[data, 
            Table[{(rpmmax/50)*(j + k - 1), 
                AccelerationCapability[k, j + k - 1]}, {j, 
                51 - k}]]; 
k++];
Print["                      Acceleration Capability Spectrum"];
Print["Acceleration Capability Vs. 2->3 Gear shifting rpm for different 1->2 Gear shifting rpms"];
ListPlot[data,ImageSize -> 550,PlotStyle -> PointSize[ .005],AxesLabel-> {"rpm","s"}];
Print["* Gear shifting time=1s"];
Print["** In this plot it is assumed that the ultimate speed is reached at (3^rd) gear."];



Print[""];
Print[""];
Print["  -------------------  Solution for part # 15  -------------------    "];
Print[""];
Print[""];



Clear[shiftingtime, 
        VS, AccelerationCapability, G, ϵ, V, 
        NTF];
G = 
        Table[1.03 +  .05*i, {i, 
            80}];
ϵ =  .04 +  .0025*(((AXR*G))^2);
V[rpm_] = 
        R*(1/(AXR*G))*2*π*rpm/60;
For[
        i = 1, i ≤ 
          80, 
NTF[rpm_][
            i] = (((Subscript[η, d])*BP[6])/(V[rpm]))[[i]] - RoadLoad[V[
                    rpm][[i]]][[1]]; 
i++];
shiftingtime[
          v_] = 
∫(m/(-((1/2) ρ*(Subscript[C, D])*
                        (Subscript[A, F])*(v^2) + (Subscript[μ, f])*m*g*Cos[θ[[1]]] + 
                      m*g*Sin[θ[[1]]]))) \[DifferentialD]v;
For[k = 80, 
        k ≥ 
          1, 
VS12[k] = 
x /. 
            NSolve[shiftingtime[x] - 
                  shiftingtime[V[rpmmax][[k]]] == 1, 
              x]; 
For[j = 1, 
          j ≤  
            k, 
VS23[j] = 
x /. 
              NSolve[shiftingtime[x] - 
                    shiftingtime[V[rpmmax][[j]]] == 1, 
                x]; 
If[V[
                  rpmmax][[k]] ≥ 
              (100/3.6), 
AccelerationCapability[k, 
                j] = 
NIntegrate[
                (1/(NTF[((60*v)/(R*((1/(AXR*G[[k]])))*2*π))][k]/(m*(1 + ϵ[[k]])))), {v, V[rpmmin][[k]], 
                  (100/3.6)}], 
If[V[
                    rpmmax][[j]] ≥  
                (100/3.6), 
AccelerationCapability[k, 
                  j] = 
NIntegrate[
                    (1/(NTF[((60*v)/(R*((1/(AXR*G[[k]])))*2*π))][k]/(m*(1 + ϵ[[k]])))), {v, V[
                          rpmmin][[k]], V[
                          rpmmax][[k]]}] + 
NIntegrate[
                    (1/(NTF[((60*v)/(R*((1/(AXR*G[[j]])))*2*π))][j]/(m*(1 + ϵ[[j]])))), {v, VS12[
                          k][[1]], (100/3.6)}] + 
                  1, 
AccelerationCapability[k, 
                  j] = 
NIntegrate[
                    (1/(NTF[((60*v)/(R*((1/(AXR*G[[k]])))*2*π))][k]/(m*(1 + ϵ[[k]])))), {v, V[
                          rpmmin][[k]], V[
                          rpmmax][[k]]}] + 
NIntegrate[
                    (1/(NTF[((60*v)/(R*((1/(AXR*G[[j]])))*2*π))][j]/(m*(1 + ϵ[[j]])))), {v, VS12[
                          k][[1]], V[
                          rpmmax][[j]]}] + 
NIntegrate[
                    (1/(NTF[((60*v)/(R*((1/(AXR*G[[5]])))*2*π))][5]/(m*(1 + ϵ[[5]])))), {v, VS23[
                          j][[1]], (100/3.6)}] + 
                  2]]; 
j++]; 
k = 
          k - 1];
data = {};
For[k = 1, 
        k ≤ 
          80, 
data = 
Join[data, 
            Table[{G[[j]], AccelerationCapability[k, j]}, {j, 
                k}]]; 
k++];
Print["                      Acceleration Capability Spectrum"];
Print["      Acceleration Capability Vs. (2^nd) Gear ratio for different (1^st) Gear ratios "];
ListPlot[data,PlotStyle -> PointSize[ .005],ImageSize -> 550,AxesLabel-> {"","s"}];
Print["* Gear shifting time=1s"];
Print["** If necessary in this plot it is assumed that the ultimate speed is reached at (3^rd) gear."];
Clear[shiftingtime, VS, AccelerationCapability, G, ϵ, 
          V, NTF];



Print[""];
Print[""];
Print[""];
Quit[];