function Calculate() { // Set the unit conversion factors: k1 = (2*3.1416/1)/(60/1)*(1/1000)/(1/3600); k2 =(1/1000)/(1/3600); k3 =1000*1000/(733.333333333333*3600*3600); // Read the input data form the forms: Mass = document.form1.Mass.value; Power = document.form1.Power.value; Rpm = document.form1.Rpm.value; Tyre_D = document.form1.Tyre_D.value; i1 = document.form1.i1.value; i2 = document.form1.i2.value; i3 = document.form1.i3.value; i4 = document.form1.i4.value; i5 = document.form1.i5.value; i6 = document.form1.i6.value; i7 = document.form1.i7.value; // crescent order: if there is any "right" value smaller than it's "left" make it equal to the "left": // the following must be before calculations, because it also avoids DIVISIONs BY ZERO: if (i2 < i1) { i2 = i1;} if (i3 < i2) { i3 = i2;} if (i4 < i3) { i4 = i3;} if (i5 < i4) { i5 = i4;} if (i6 < i5) { i6 = i5;} if (i7 < i6) { i7 = i6;} // Calculate the maximum speed after each gear: Vmax1 = Rpm*i1*Tyre_D/2*k1; Vmax2 = Rpm*i2*Tyre_D/2*k1; Vmax3 = Rpm*i3*Tyre_D/2*k1; Vmax4 = Rpm*i4*Tyre_D/2*k1; Vmax5 = Rpm*i5*Tyre_D/2*k1; Vmax6 = Rpm*i6*Tyre_D/2*k1; Vmax7 = Rpm*i7*Tyre_D/2*k1; // When 100km/ are attained, which is gear at that moment? i_100 = 0; if (Vmax1 > 100 && i_100 == 0) { i_100 = 1;} if (Vmax2 > 100 && i_100 == 0) { i_100 = 2;} if (Vmax3 > 100 && i_100 == 0) { i_100 = 3;} if (Vmax4 > 100 && i_100 == 0) { i_100 = 4;} if (Vmax5 > 100 && i_100 == 0) { i_100 = 5;} if (Vmax6 > 100 && i_100 == 0) { i_100 = 6;} if (Vmax7 > 100 && i_100 == 0) { i_100 = 7;} // Thus, if i_100 is STILL_ZERO, then this means that the gears are too short to attain 100km/h if (i_100 == 0) {javascript:alert('Greater ratios are required.');} if (i_100 != 0) { // Calculate the acceleretion values corresponding to each ratio: a1 = 733.333333333333*Power/(Vmax1*Mass)*k2; a2 = 733.333333333333*Power/(Vmax2*Mass)*k2; a3 = 733.333333333333*Power/(Vmax3*Mass)*k2; a4 = 733.333333333333*Power/(Vmax4*Mass)*k2; a5 = 733.333333333333*Power/(Vmax5*Mass)*k2; a6 = 733.333333333333*Power/(Vmax6*Mass)*k2; a7 = 733.333333333333*Power/(Vmax7*Mass)*k2; // Calculate the time spent on each reatio: t1 = (Vmax1-0)/(a1*k2); t2 = (Vmax2-Vmax1)/(a2*k2); t3 = (Vmax3-Vmax2)/(a3*k2); t4 = (Vmax4-Vmax3)/(a4*k2); t5 = (Vmax5-Vmax4)/(a5*k2); t6 = (Vmax6-Vmax5)/(a6*k2); t7 = (Vmax7-Vmax6)/(a7*k2); // We already know which will be the last gear. Now we must calculate the shorter time spent on that gear: if (i_100 == 1) {MT_Time = (100-0)/(a1*k2);} if (i_100 == 2) {MT_Time = t1 + (100-Vmax1)/(a2*k2);} if (i_100 == 3) {MT_Time = t1 + t2 + (100-Vmax2)/(a3*k2);} if (i_100 == 4) {MT_Time = t1 + t2 + t3 + (100-Vmax3)/(a4*k2);} if (i_100 == 5) {MT_Time = t1 + t2 + t3 + t4 + (100-Vmax4)/(a5*k2);} if (i_100 == 6) {MT_Time = t1 + t2 + t3 + t4 + t5 + (100-Vmax5)/(a6*k2);} if (i_100 == 7) {MT_Time = t1 + t2 + t3 + t4 + t5 + t6 + (100-Vmax6)/(a7*k2);} // Finnaly, we must calculate the CVT_Time, and percentages, which is easier: CVT_Time = 100*100/2*Mass/Power*k3; perc_of_MT = CVT_Time/MT_Time*100; CVT_more_perf = MT_Time/CVT_Time*100-100; // Output the ratios values that were, in fact, used: document.form1.i1.value = i1; document.form1.i2.value = i2; document.form1.i3.value = i3; document.form1.i4.value = i4; document.form1.i5.value = i5; document.form1.i6.value = i6; document.form1.i7.value = i7; // Unexisting ratios are reset to ZERO: // Remember that this program has previously replaced tha last null ratios by the reates non-Zero. if (i7 == i6) {document.form1.i7.value = 0;} if (i6 == i5) {document.form1.i6.value = 0;} if (i5 == i4) {document.form1.i5.value = 0;} if (i4 == i3) {document.form1.i4.value = 0;} if (i3 == i2) {document.form1.i3.value = 0;} if (i2 == i1) {document.form1.i2.value = 0;} // Output the calculated values: document.form1.Last_Gear.value = i_100; document.form1.MT_Time.value = MT_Time; document.form1.CVT_Time.value = CVT_Time; document.form1.perc_of_MT.value = perc_of_MT; document.form1.CVT_more_perf.value = CVT_more_perf; } // END IF (i_100 != 0) } // END FUNCTION CALCULATE function Reset1() { document.form1.Last_Gear.value = "?"; document.form1.Mass.value = 1250; document.form1.Power.value = 75; document.form1.Rpm.value = 5700; document.form1.Tyre_D.value = 0.6; document.form1.i1.value = 0.066; document.form1.i2.value = 0.095; document.form1.i3.value = 0.14; document.form1.i4.value = 0.19; document.form1.i5.value = 0.28; document.form1.i6.value = 0; document.form1.i7.value = 0; document.form1.MT_Time.value = "?"; document.form1.CVT_Time.value = "?"; document.form1.perc_of_MT.value = "?"; document.form1.CVT_more_perf.value = "?"; } // END FUNCTION CALCULATE