summaryrefslogtreecommitdiff
path: root/Thermal_Engineering_by_K_K_Ramalingam/Chapter7.ipynb
blob: 3e77394f65abca67ffc563dd5d8e9cf93fdda359 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7 - Performance of IC Engines"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 1 - pg 7.19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Brake torque is (Nm) =  971.2\n",
      "(b)Power available at the brakes of the engine is (kW) =  152.48\n",
      "The answers given in textbook are wrong. Please verify using a calculator\n"
     ]
    }
   ],
   "source": [
    "#pg 7.19\n",
    "#calculate the brake torque and Power\n",
    "#Input data\n",
    "N=1500.;#Engine speed in rpm\n",
    "p=110.;#Load on brakes in kg\n",
    "L=900.;#Length of brake arm in mm\n",
    "g=9.81;#Gravitational force in N/m**2\n",
    "pi=3.14;#Mathematical constant\n",
    "\n",
    "#Calculations\n",
    "T=((p*g)*(L/1000.));#Braking torque in Nm\n",
    "P=((T/1000)*((2*3.14*N)/60));#Power available at the brakes of the engine in kW\n",
    "\n",
    "#Output\n",
    "print '(a) Brake torque is (Nm) = ',round(T,1)\n",
    "print '(b)Power available at the brakes of the engine is (kW) = ',round(P,2)\n",
    "print 'The answers given in textbook are wrong. Please verify using a calculator'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 - pg 7.19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The power available at the brakes is (kW) =  7.125\n"
     ]
    }
   ],
   "source": [
    "#pg 7.19\n",
    "#calculate the power available\n",
    "#Input data\n",
    "N=700.;#Engine speed in rpm\n",
    "D=0.6;#Diameter of brake drum in m\n",
    "d=0.05;#Diameter of rope in m\n",
    "W=35.;#Dead load on the brake drum in kg\n",
    "S=4.5;#Spring balance reading in kg\n",
    "g=9.81;#Gravitational constant in N/m**2\n",
    "pi=3.14;#Mathematical constant\n",
    "\n",
    "#Calculations\n",
    "P=(((W-S)*g*pi*(D+d))/1000)*(N/60);#Power in kW\n",
    "\n",
    "#Output\n",
    "print 'The power available at the brakes is (kW) = ',round(P,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 - pg 7.20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Brake thermal efficiency of the engine is (percent) =  34.74\n"
     ]
    }
   ],
   "source": [
    "#pg 7.20\n",
    "#calculate the brake thermal efficiency\n",
    "#Input data\n",
    "W=950.;#Load on hydraulic dynamometer in N\n",
    "C=7500.;#Dynamometer constant\n",
    "f=10.5;#Fuel used per hour in kg\n",
    "h=50000.;#Calorific value of fuel in kJ/kg\n",
    "N=400.;#Engine speed in rpm\n",
    "\n",
    "#Calculations\n",
    "P=(W*N)/C;#Power available at the brakes in kW\n",
    "H=P*60;#Heat equivalent of power at brakes in kJ/min\n",
    "Hf=(f*h)/60;#Heat supplied by fuel per minute in kJ/min\n",
    "n=(H/Hf)*100;#Brake thermal efficiency in percentage\n",
    "\n",
    "#Output\n",
    "print ' Brake thermal efficiency of the engine is (percent) = ',round(n,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 - pg 7.21"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Specific fuel consumption is (kg/BHP hr) =  0.238\n",
      "(b)Brake mean effective pressure is (kgf/cm^2) =  8.066\n"
     ]
    }
   ],
   "source": [
    "#pg 7.21\n",
    "#calculate the specific fuel consumption and Brake mean effective pressure\n",
    "#Input data\n",
    "import math\n",
    "n1=50.5;#Air standard efficiency in percentage\n",
    "n2=50.;#Brake thermal efficiency in percentage\n",
    "N=3000.;#Engine speed in rpm\n",
    "H=10500.;#Heating value of fuel in kcal/kg\n",
    "T=7.2;#Torque developed in kgf*m\n",
    "B=6.3;#Bore diameter in cm\n",
    "S=0.09;#stroke in m\n",
    "\n",
    "#Calculations\n",
    "nbt=(n1/100)*(n2/100.);#Brake thermal efficiency in percentage\n",
    "B1=(2*(22./7)*N*T)/4500.;#Brake horse power in kW\n",
    "B2=B1/4;#Brake horse power per cylinder in kW\n",
    "Bsf=(4500*60)/(H*427.*nbt);#Brake specific fuel consumption in kg/BHP hr\n",
    "bmep=(B2*4500)/(S*(math.pi*B**2. /4.)*(N/2.));#Brake mean effective pressure in kgf/cm**2\n",
    "\n",
    "#Output\n",
    "print '(a)Specific fuel consumption is (kg/BHP hr) = ',round(Bsf,3)\n",
    "print '(b)Brake mean effective pressure is (kgf/cm^2) = ',round(bmep,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 - pg 7.22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mechanical efficiency of the engine is (percent) =  88.54\n"
     ]
    }
   ],
   "source": [
    "#pg 7.22\n",
    "#calculate the Mechanical efficiency\n",
    "#Input data\n",
    "W=30.;#The net dynamometer load in kg\n",
    "R=0.5;#Radius in m\n",
    "N=2400.;#Speed in rpm\n",
    "FHP=6.5;#Engine power in hp\n",
    "\n",
    "#Calculations\n",
    "BHP=(2*3.14*R*N*W)/4500;#Brake horse power in kW\n",
    "IHP=BHP+FHP;#Indicated horse power in kW\n",
    "nm=(BHP/IHP)*100;#Mechanical efficiency in percentage\n",
    "\n",
    "#Output\n",
    "print 'Mechanical efficiency of the engine is (percent) = ',round(nm,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6 - pg 7.22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The indicated horse power is (kW) =  24.35\n",
      "(b)The brake horse power is (kW) =  19.48\n",
      "(c)Friction horse power is (kW) =  4.87\n"
     ]
    }
   ],
   "source": [
    "#pg 7.22\n",
    "#calculate the indicated, brake and Friction horse powers\n",
    "#Input data\n",
    "import math\n",
    "d=25.;#Diameter of cylinder in cm\n",
    "l=0.4;#Stroke of piston in m\n",
    "N=200.;#Speed in rpm\n",
    "m=10.;#Misfires per minute\n",
    "M=6.2;#Mean effective pressure in kgf/cm**2\n",
    "nm=0.8;#Mechanical efficiency in percent\n",
    "\n",
    "#Calculations\n",
    "np=(N/2)-m;#Number of power strokes per minute\n",
    "A=(math.pi*d**2)/4;#Area of the cylinder\n",
    "I=(M*l*A*np)/4500.;#Indicated horse power in kW\n",
    "B=I*nm;#Brake horse power in kW\n",
    "F=I-B;#Friction horse power in kW\n",
    "\n",
    "#Output\n",
    "print '(a)The indicated horse power is (kW) = ',round(I,2)\n",
    "print '(b)The brake horse power is (kW) = ',round(B,2)\n",
    "print '(c)Friction horse power is (kW) = ',round(F,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7 - pg 7.23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The average piston speed is (m/s) =  117.53\n"
     ]
    }
   ],
   "source": [
    "#pg 7.23\n",
    "#calculate the average piston speed\n",
    "#Input data\n",
    "import math\n",
    "I=5.;#Indicated power developed by single cylinder of 2 stroke petrol engine\n",
    "M=6.5;#Mean effective pressure in bar\n",
    "d=0.1;#Diameter of piston in m\n",
    "\n",
    "#Calculations\n",
    "A=(math.pi*d**2)/4;#Area of the cylinder\n",
    "LN=(I*1000*60.)/(M*10**5*A);#Product of length of stroke and engine speed\n",
    "S=2*LN;#Average piston speed in m/s\n",
    "\n",
    "#Output\n",
    "print 'The average piston speed is (m/s) = ',round(S,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8 - pg 7.24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Diameter of the bore is (cm) =  35.43\n",
      "(b)Stroke length of the piston is (cm) =  61.999\n"
     ]
    }
   ],
   "source": [
    "#pg 7.24\n",
    "#calculate the diameter and stroke length\n",
    "#Input data\n",
    "P=60.;#Power developed by oil engine in kW\n",
    "M=6.5;#Mean effective pressure in kgf/cm**2\n",
    "N=85.;#Number of explosions per minute\n",
    "r=1.75;#Ratio of stroke to bore diameter\n",
    "nm=0.8;#Mechanical efficiency \n",
    "\n",
    "#Calculations\n",
    "I=P/nm;#Indicated horse power\n",
    "d=((I*100*4*4500.)/(M*r*3.14*N))**(1./3);#Bore diameter in cm\n",
    "l=r*d;#Stroke length in cm\n",
    "\n",
    "#Output\n",
    "print '(a)Diameter of the bore is (cm) = ',round(d,2)\n",
    "print '(b)Stroke length of the piston is (cm) = ',round(l,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9 - pg 7.24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The bore diameter of the cylinder is (cm) =  11.46\n",
      "(b)Stroke length of the piston is (cm) =  14.89\n"
     ]
    }
   ],
   "source": [
    "#pg 7.24\n",
    "#calculate the bore diameter and stroke length\n",
    "#Input data \n",
    "I=45.;#Power developed by two cylinder internal combustion engine operating on two stroke principle\n",
    "N=1100.;#Speed in rpm\n",
    "M=6.;#Mean effective pressure in kgf/cm**2\n",
    "r=1.3;#Ratio of stroke to the bore\n",
    "nc=2.;#Number of cylinders\n",
    "\n",
    "#Calculations\n",
    "d=((I*4500*4)/(M*(r/100)*3.14*N*nc))**(1./3);#Diameter of the bore in cm\n",
    "l=1.3*d;#Stroke length in cm\n",
    "\n",
    "#Output\n",
    "print '(a)The bore diameter of the cylinder is (cm) = ',round(d,2)\n",
    "print '(b)Stroke length of the piston is (cm) = ',round(l,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10 - pg 7.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The volumetric efficiency is (percent) =  78.5\n"
     ]
    }
   ],
   "source": [
    "#pg 7.25\n",
    "#calculate the volumetric efficiency\n",
    "#Input data\n",
    "d=6.;#Diameter of the bore in cm\n",
    "l=9.;#Length of the stroke in cm\n",
    "m=0.00025;#Mass of charge admitted in each suction stroke\n",
    "R=29.27;#Gas constant Kgfm/kg K\n",
    "p=1.;#Normal pressure in kgf/cm**2\n",
    "T=273.;#Temperature in K\n",
    "\n",
    "#Calculations\n",
    "V=(m*R*T)*10**6/(p*10**4);#Volume of charge admitted in each cycle in m**3\n",
    "Vs=(3.14*d**2*l)/4;#Swept volume of the cylinder\n",
    "nv=(V/Vs)*100;#Volumetric efficiency in percentage\n",
    "\n",
    "#Output\n",
    "print 'The volumetric efficiency is (percent) = ',round(nv,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 11 - pg 7.26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The volumetric efficiency of the engine is (percent) =  79.21\n"
     ]
    }
   ],
   "source": [
    "#pg 7.26\n",
    "#calculate the volumetric efficiency of the engine\n",
    "#Input data\n",
    "import math\n",
    "d=0.12;#Diameter of the bore in m\n",
    "l=0.13;#Length of stroke in m\n",
    "N=2500.;#Speed of the engine in rpm\n",
    "d1=0.06;#Diameter of the orifice in m\n",
    "Cd=0.70;#Discharge coefficient of orifice\n",
    "hw=33.;#Heat causing air flow through orifice in cm of water\n",
    "p=760.;#Barometric reading in mm of Hg\n",
    "T1=298.;#Ambient temperature in degree K\n",
    "p1=1.013;#Pressure of air at the end of suction in bar\n",
    "T2=22.;#Temperature of air at the end of suction in degree C\n",
    "R=0.287;#Universal gas constant\n",
    "n=6.;#Number of cylinders in the engine\n",
    "n1=1250.;#Number of strokes per minute for a four stroke engine operating at 2500 rpm\n",
    "\n",
    "#Calculations\n",
    "V=(math.pi*d**2*l)/4;#Swept volume of piston in m**3\n",
    "Ao=(math.pi*d1**2)/4;#Area of the orifice in m**2\n",
    "rho=p1*10**5/((R*T1)*1000);#Density of air at 1.013 bar and 22 degrees C\n",
    "Va=840.*Cd*Ao*(hw/rho)**(1./2);#Volume of air passing through the orifice in m**3/min\n",
    "V1=8.734/n;#Actual volume of air per cylinder in m**3/min\n",
    "As=V1/n1;#Air supplied per cycle per cylinder in m**3\n",
    "nv=(As/V)*100;#Volumetric efficiency of the engine in percentage\n",
    "\n",
    "#Output\n",
    "print 'The volumetric efficiency of the engine is (percent) = ',round(nv,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12 - pg 7.27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The air standard efficiency is (percent) =  46.1\n",
      "(b)Indicated power is (kW) =  9.093\n",
      "(c)Indicated thermal efficiency is (percent) =  32.5\n"
     ]
    }
   ],
   "source": [
    "#pg 7.27\n",
    "#calculate the air standard efficiency and Indicated power, thermal efficiency\n",
    "#Input data\n",
    "import math\n",
    "d=0.15;#Diameter of the piston in m\n",
    "l=0.19;#Length of the stroke in m\n",
    "V=0.00091;#Clearance volume in m**3\n",
    "N=250.;#Speed of the engine in rpm\n",
    "M=6.5;#Indicated mean effective pressure in bar\n",
    "c=6.3;#Gas consumption in m**3/hr\n",
    "H=16000.;#Calorific value of the has in kJ/m**3\n",
    "r1=1.4;#Polytropic index\n",
    "\n",
    "#Calculations\n",
    "Vs=(math.pi*d**2*l)/4;#Swept volume in m**3\n",
    "Vt=Vs+V;#Total cylinder volume in m**3\n",
    "r=Vt/V;#Compression ratio\n",
    "na=(1-(1/r**(r1-1)))*100;#Air standard efficiency in percent\n",
    "A=(math.pi*d**2)/4;#Area of the bore in m\n",
    "I=(M*10**5*l*A*N)/(1000*60);#Indicated power in kW\n",
    "Hs=(c*H)/(60*60);#Heat supplied per second\n",
    "nt=(I/Hs)*100;#Indicated thermal efficiency in percent\n",
    "\n",
    "#Output\n",
    "print '(a)The air standard efficiency is (percent) = ',round(na,1)\n",
    "print '(b)Indicated power is (kW) = ',round(I,3)\n",
    "print '(c)Indicated thermal efficiency is (percent) = ',round(nt,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 13 - pg 7.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The diameter of the venturi of the venturi if the air speed is 90 m/s is (cm) =  3.55\n",
      "(b)The diameter of the jet if the pressure drop at the jet is 0.8 times the pressure drop at the venturi is (mm) =  2.218\n"
     ]
    }
   ],
   "source": [
    "#pg 7.28\n",
    "#calculate the diameter in all cases\n",
    "#Input data\n",
    "import math\n",
    "ma=6.;#Air supplied per minute by a single jet carburetor in kg/min\n",
    "mf=0.44;#Mass flow rate of petrol in kg/min\n",
    "s=0.74;#Specific gravity of petrol in kg/m**3\n",
    "p1=1.;#Initial pressure of air in bar\n",
    "T1=300.;#Initial temperature of air in K\n",
    "Ci=1.35;#Isentropic coefficient of air\n",
    "V=90.;#Speed of air in the venturi in m/s\n",
    "Vc=0.85;#Velocity coefficient of the venturi in m/s\n",
    "Cf=0.66;#Coefficient of discharge for the jet\n",
    "Cp=1005.;#Coefficient of pressure in J/kg K\n",
    "n=1.35;#Isentropic coefficient of air\n",
    "R=0.281;#Real gas constant in Nm/kg K\n",
    "rhof=740.;#Density of fuel in mm of Hg\n",
    "\n",
    "#Calculations\n",
    "p2=(1-((V/Vc)**(2)/(2*T1*Cp)))**((n)/(n-1));#Pressure at the venturi in bar\n",
    "V1=((R*T1)/(p1*10**5))*1000;#Initial volume in m**3/kg\n",
    "V2=V1*((p1/p2)**(0.741));#Final volume in m**3/kg\n",
    "A2=((ma*V2)/(V*60.))*10**4;#Throat area of venturi in cm**2\n",
    "d=((A2*4.)/math.pi)**(0.5);#Diameter of venturi in cm\n",
    "deltaPa=1-p2;#Pressure drop causing air flow in bar\n",
    "deltaPf=0.8*deltaPa;#Pressure drop causing fuel flow in bar\n",
    "Af=(mf/60.)*(10**4)/((Cf)*(2*rhof*deltaPf*10**5)**(1./2));#Area through which fuel flows in cm**2\n",
    "df=((Af*(4/math.pi))**(1./2))*10.;#Diameter of fuel jet in mm\n",
    "\n",
    "print '(a)The diameter of the venturi of the venturi if the air speed is 90 m/s is (cm) = ',round(d,2)\n",
    "print '(b)The diameter of the jet if the pressure drop at the jet is 0.8 times the pressure drop at the venturi is (mm) = ',round(df,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14 - pg 7.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The weight of fuel required per 1HP hr is (kg) =  0.1947\n"
     ]
    }
   ],
   "source": [
    "#pg 7.30\n",
    "#calculate the weight of fuel\n",
    "#Input data\n",
    "r=14.;#The compression ratio of a diesel engine\n",
    "Vc=1.;#Clearance volume in m**3\n",
    "c=0.08;#Fuel supply cut off point\n",
    "nr=0.55;#Relative efficiency\n",
    "H=10000.;#Calorific value of fuel in kcal/kg\n",
    "r1=1.4;#Ratio of specific heat of air\n",
    "Vs=13.;#Stroke volume in m**3\n",
    "\n",
    "#Calculations\n",
    "rho=Vc+(c*Vs);#Cut off ratio\n",
    "na=1-(1*(rho**r1-1)/((r**(r1-1)*r1)*(rho-1)));#Air standard efficiency of diesel cycle in percent\n",
    "In=(na*nr);#Indicated thermal efficiency in percent\n",
    "H1=(4500*60)/(In*427.);#Heat in fuel supplied/1HP hr\n",
    "W=H1/10**4;#Weight of fuel required/1HP hr\n",
    "\n",
    "#Output\n",
    "print 'The weight of fuel required per 1HP hr is (kg) = ',round(W,4)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 15 - pg 7.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The quantity of fuel to be injected per cycle per cylinder is (cc) =  0.0654\n"
     ]
    }
   ],
   "source": [
    "#pg 7.31\n",
    "#calculate the quantity of fuel\n",
    "#Input data\n",
    "P=120;#Power developed by a six cykinder four stroke diesel engine\n",
    "N=2400;#Speed in rpm\n",
    "f=0.2;#Brake specific fuel consumption in kg/kWh\n",
    "s=0.85;#Specific gravity of fuel\n",
    "\n",
    "#Calculations\n",
    "F=f*P;#Fuel consumed per hour in kg\n",
    "F1=F/6;#Fuel consumed per cylinder in kg/h\n",
    "n=(N*60.)/2;#Number of cycles per hour\n",
    "F2=(F1/n)*10**3;#Fuel consumption per cycle in gm\n",
    "V=F2/s;#Volume of fuel to be injected per cycle in cc\n",
    "\n",
    "#Output\n",
    "print 'The quantity of fuel to be injected per cycle per cylinder is (cc) = ',round(V,4)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16 - pg 7.32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The diameter of the orifice is (mm) =  0.6165\n"
     ]
    }
   ],
   "source": [
    "#pg 7.32\n",
    "#calculate the diameter of the orifice\n",
    "#Input data\n",
    "P=20.;#Power developed by a four stroke diesel engine per cylinder in kW\n",
    "N=2000.;#Operating speed of the diesel engine in rpm\n",
    "s=0.25;#Specific fuel consumption in kh/kW\n",
    "p1=180.;#Pressure of fuel injected in bar\n",
    "d=25.;#Distance travelled by crank in degrees\n",
    "p2=38.;#Pressure in the combustion chamber in bar\n",
    "Cd=0.85;#Coefficient of velocity\n",
    "A=30.;#API in degrees\n",
    "\n",
    "#Calculations\n",
    "T=d/(360.*(N/60));#Duration of fuel injection in s\n",
    "SG=(141.5/(131.5+A))*10**3;#Specific gravity of fuel\n",
    "V=Cd*(2*(p1-p2)*10**5/SG)**(1./2);#Velocity of fuel injection in m/s\n",
    "Vf=(s/60.)*P/((N/2)*SG);#Volume of fuel injected per cycle in m**3/cycle\n",
    "Na=Vf/(V*T);#Nozzle orifice area in m**2\n",
    "d=(((4*Na)/3.14)**(1./2))*10**3;#Diameter of the orifice of the fuel injector in mm\n",
    "\n",
    "#Output\n",
    "print 'The diameter of the orifice is (mm) = ',round(d,4)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 17 - pg 7.33"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The total orifice area required per injector if the injection takes place over 16 degree crank angle is (m^2) =  4.8796e-07\n"
     ]
    }
   ],
   "source": [
    "#pg 7.33\n",
    "#calculate the total orifice area\n",
    "#Input data\n",
    "P=200.;#Power developed by a six cylinder diesel engine in kW\n",
    "N=2000.;#Operating speed of the engine in rpm\n",
    "bs=0.2;#The brake specific fuel consumption in kg/kWh\n",
    "p1=35.;#The pressure of air in the cylinder at the beginning of injection in bar\n",
    "p2=55.;#Maximum cylinder pressure in bar\n",
    "p3=180.;#Initial injection pressure in bar\n",
    "p4=520.;#Maximum pressure at the injector in bar\n",
    "Cd=0.75;#Coefficient of discharge\n",
    "S=850.;#Specific gravity of fuel\n",
    "p5=1.;#Atmospheric pressure in bar\n",
    "a=16.;#The crank angle over which injection takes place in degrees\n",
    "\n",
    "#Calculations\n",
    "Po=P/6.;#Power output per cylinder in kW\n",
    "F=(Po*bs)/60.;#Fuel consumed per cylinder in kg/min\n",
    "Fi=F/(N/2.);#Fuel injected per cycle in kg\n",
    "T=a/(360.*(N/60));#Duration of injection in s\n",
    "deltaP1=p3-p1;#Pressure difference at the beginning of injection in bar\n",
    "deltaP2=p4-p2;#Pressure difference at the end of injection in bar\n",
    "avP=(deltaP1+deltaP2)/2;#Average pressure difference in bar\n",
    "V=Cd*(2.*(avP*10**5)/S)**(1./2);#Velocity of injection of fuel jet in m/s\n",
    "Vo=Fi/S;#Volume of fuel injected per cycle in m**3/cycle\n",
    "A=(Vo/(V*T));#Area of fuel orifices in m**2\n",
    "\n",
    "#Output\n",
    "print 'The total orifice area required per injector if the injection takes place over 16 degree crank angle is (m^2) = ',round(A,11)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 18 - pg 7.34"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The indicated mean effective pressure is (bar) =  8.25\n",
      "(b)Indicated power is (kW) =  2.81\n"
     ]
    }
   ],
   "source": [
    "#pg 7.34\n",
    "#calculate the indicated mean effective pressure and indicated power\n",
    "#Input data\n",
    "A=450.;#Area of indicator diagram in mm^2\n",
    "l=60.;#Length of indicator diagram in mm\n",
    "s=1.1;#Spring number in bar/mm\n",
    "d=0.1;#Diameter of piston in m\n",
    "L=0.13;#Length of stroke in m\n",
    "N=400.;#Operating speed of the engine in rpm\n",
    "\n",
    "#Calculations\n",
    "Av=A/l;#Average height of indicator diagram in mm\n",
    "pm=Av*s;#Mean effective pressure in bar\n",
    "np=N/2.;#Number of power strokes per minute for a four stroke diesel engine\n",
    "Ar=(3.14*d**2)/4;#Area of the piston in m^2\n",
    "I=(pm*10**5*L*Ar*np)/(1000*60);#Indicated power in kW\n",
    "\n",
    "#Output\n",
    "print '(a)The indicated mean effective pressure is (bar) = ',pm\n",
    "print '(b)Indicated power is (kW) = ',round(I,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 19 - pg 7.35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The brake horse power is (kW) =  28.26\n",
      "(b)Indicated horse power is (kW) =  35.063\n",
      "(c)Thermal efficiency on IHP basis is (percent) =  37.33\n",
      "(d)Thermal efficiency on BHP basis is (percent) =  30.08\n"
     ]
    }
   ],
   "source": [
    "#pg 7.35\n",
    "#calculate the brake, Indicated horse power and Thermal efficiency\n",
    "#Input data\n",
    "d=25.;#Diameter of the bore in cm\n",
    "l=0.4;#Stroke length in m\n",
    "N=300.;#Operating speed of the engine in rpm\n",
    "n=120.;#Number of explosions per minute\n",
    "pm=6.7;#Mean effective pressure in kgf/cm**2\n",
    "Tnet=90.;#Net brake load in kg\n",
    "R=0.75;#Radius of brake drum in m\n",
    "f=0.22;#Fuel supplied per minute in m**3\n",
    "C=4500.;#Calorific value of fuel in kcal/m**3\n",
    "\n",
    "#Calculations\n",
    "BHP=(2*3.14*R*N*Tnet)/4500;#Brake horse power in kW\n",
    "A=(3.14*d**2)/4;#Area of the cylinder in cm**2\n",
    "IHP=(pm*l*A*n)/4500;#Indicated horse power in kW\n",
    "H=f*C;#Heat supplied by fuel per minute in kcal\n",
    "nt1=((IHP*C)/(990*427))*100;#Thermal efficiency on IHP basis in percent\n",
    "nt2=((BHP*C)/(990*427))*100;#Thermal efficiency on BHP basis in percent\n",
    "\n",
    "#Output\n",
    "print '(a)The brake horse power is (kW) = ',round(BHP,2)\n",
    "print '(b)Indicated horse power is (kW) = ',round(IHP,3)\n",
    "print '(c)Thermal efficiency on IHP basis is (percent) = ',round(nt1,2)\n",
    "print '(d)Thermal efficiency on BHP basis is (percent) = ',round(nt2,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 20 - pg 7.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The brake horse power is (kW) =  3.62\n",
      "(b)Indicated horse power is (kW) =  4.341\n",
      "(c)Mechanical efficiency is (percent) =  83.4\n",
      "(d)Indicated thermal efficiency is (percent) =  33.0\n",
      "(e)Brake thermal efficiency is (percent) =  27.5\n"
     ]
    }
   ],
   "source": [
    "#pg 7.36\n",
    "#calculate the brake, Indicated horse power and Thermal efficiency\n",
    "#Input data\n",
    "D=0.6;#Brake wheel diameter of a constant speed compression ignition engine operating on four stroke cycle in m\n",
    "t=0.01;#Thickness of brake band in m\n",
    "N=500.;#Operating speed of the engine in rpm\n",
    "W=20.;#Load on brake band in kgf\n",
    "S=3.;#Spring balance reading in kgf\n",
    "l=6.25;#Length of indicator diagram in cm\n",
    "A=4.35;#Area of indicator diagram in cm**2\n",
    "Sn=11.;#Spring number in kgf/cm**2/cm\n",
    "d=10.;#Diameter of the bore in cm\n",
    "L=0.13;#Length of the stroke in m\n",
    "F=0.23;#Specific fuel consumption in kg/BHP hr\n",
    "CV=10000.;#Heating value of fuel in kcal/kg\n",
    "\n",
    "#Calculations\n",
    "BHP=(3.14*(D+t)*N*(W-S))/4500;#Brake horse power in kW\n",
    "MEP=(A*Sn)/l;#Mean effective pressure in kgf/cm**2\n",
    "Ar=(3.14*d**2)/4;#Area of the cylinder in cm**2\n",
    "np=N/2;#Number of explosions per minute\n",
    "IHP=(MEP*L*Ar*np)/4500;#Indicated horse power in kW\n",
    "nm=(BHP/IHP)*100;#Mechanical efficiency in percentage\n",
    "Wf=F*BHP;#Fuel consumption per hr in kg/hr\n",
    "nt=((IHP*4500*60)/(Wf*CV*427))*100;#Indicated thermal efficiency in percentage\n",
    "nb=((BHP*4500*60)/(Wf*CV*427))*100;#Brake thermal efficiency in kW\n",
    "\n",
    "#Output\n",
    "print '(a)The brake horse power is (kW) = ',round(BHP,2)\n",
    "print '(b)Indicated horse power is (kW) = ',round(IHP,3)\n",
    "print '(c)Mechanical efficiency is (percent) = ',round(nm,1)\n",
    "print '(d)Indicated thermal efficiency is (percent) = ',round(nt,0)\n",
    "print '(e)Brake thermal efficiency is (percent) = ',round(nb,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 21 - pg 7.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The indicated thermal efficiency is (percent) =  30.9\n",
      "Mechanical efficiency is (percent) =  82.0\n",
      "Brake thermal efficiency is (percent) =  25.3\n"
     ]
    }
   ],
   "source": [
    "#pg 7.38\n",
    "#calculate the indicated thermal efficiency\n",
    "#Input data\n",
    "N=1200.;#Operating speed of a four cylinder engine in rpm\n",
    "BHP=25.3;#The brake horse power when all 4 cylinders are operating in kW\n",
    "T=10.5;#The average torque when one cylinder was cut out in mkgf\n",
    "CV=10000.;#Calorific value of the fuel used in kcal/kg\n",
    "f=0.25;#The amount of petrol used in engine per BHP hour\n",
    "J=427.;#\n",
    "\n",
    "#Calculations\n",
    "BHP1=(2*3.14*N*T)/4500.;#BHP for 3 cylinders when 1 cylinder is cut out in kW\n",
    "IHP=BHP-BHP1;#IHP of one cylinder in kW\n",
    "IHPt=IHP*4.;#Total IHP of the engine with 4 cylinders\n",
    "Wf=(f*BHP)/60.;#Fuel used per minute in kg\n",
    "ni=((IHPt*4500.)/(Wf*CV*J))*100;#Indicated thermal efficiency in percent\n",
    "nm=(BHP/IHPt)*100;#Mechanical efficiency in percent\n",
    "nb=(IHPt*nm)/100;#Brake thermal efficiency in percent\n",
    "\n",
    "#Output\n",
    "print 'The indicated thermal efficiency is (percent) = ',round(ni,1)\n",
    "print 'Mechanical efficiency is (percent) = ',round(nm,1)\n",
    "print 'Brake thermal efficiency is (percent) = ',round(nb,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 22 - pg 7.39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)The IHP of the engine is (kW) =  38.6\n",
      "(b)Mechanical efficiency is (percent) =  82.9\n"
     ]
    }
   ],
   "source": [
    "#pg 7.39\n",
    "#calculate the IHP of the engine and Mechanical efficiency\n",
    "#Input data\n",
    "B=32.;#Brake horse power in kW with all cylinders working\n",
    "B1=21.6;#BHP with number 1 cylinder cut out in kW\n",
    "B2=22.3;#BHP with number 2 cylinder cut out in kW\n",
    "B3=22.5;#BHP with number 3 cylinder cut out in kW\n",
    "B4=23.;#BHP with number 4 cylinder cut out in kW\n",
    "\n",
    "#Calculations\n",
    "I1=B-B1;#Indicated horse power of number 1 cylinder in kW\n",
    "I2=B-B2;#IHP of number 2 cylinder in kW\n",
    "I3=B-B3;#IHP of number 3 cylinder in kW\n",
    "I4=B-B4;#IHP of number 4 cylinder in kW\n",
    "I=I1+I2+I3+I4;#Total IHP of the engine in kW\n",
    "nm=(B/I)*100;#Mechanical efficiency in percent\n",
    "\n",
    "#Output\n",
    "print '(a)The IHP of the engine is (kW) = ',I\n",
    "print '(b)Mechanical efficiency is (percent) = ',round(nm,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23 - pg 7.40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Compression ratio =  6.6\n",
      "(b)Indicated thermal efficiency is (percent) =  34.45\n",
      "(c)Brake specific fuel consumption is (kg/kW sec) =  7.59e-05\n",
      "(d)Bore diameter of the engine is (mm) =  98.99\n",
      "(e)Stroke length of the engine is (mm) =  128.7\n"
     ]
    }
   ],
   "source": [
    "#pg 7.40\n",
    "#calculate the Compression ratio, indicated thermal efficiency, brake specific fuel consumption and bore diameter\n",
    "#Input data\n",
    "r=15.;#The air fuel ratio by weight\n",
    "CV=45000.;#Calorific value of fuel in kJ/kg\n",
    "nm=85.;#Mechanical efficiency of 4 stroke 4 cylinder engine in percent\n",
    "na=53.;#Air standard efficiency of the engine in percent\n",
    "nr=65.;#Relative efficiency of the engine in percent\n",
    "nv=80.;#Volumetric efficiency of the engine in percent\n",
    "r1=1.3;#Stroke to bore ratio\n",
    "p1=1.;#Suction pressure in bar\n",
    "T=303.;#Suction temperature in K\n",
    "S=3000.;#The operating speed of the engine in rpm\n",
    "P=75.;#Power at brakes in kW\n",
    "r2=1.4;#Ratio of specific heats for air\n",
    "R1=0.287;#Characteristic gas constant for air fuel mixture in kJ/kg K\n",
    "\n",
    "#Calculations\n",
    "R=(1/(1-(na/100)))**(1/(r2-1));#Compression ratio of the engine\n",
    "nti=((na/100)*(nr/100))*100;#The indicated thermal efficiency in percent\n",
    "Pi=P/(nm/100);#Indicated power in kW\n",
    "F=Pi/((nti*CV)/100);#Fuel per second injected in kg/sec\n",
    "B=F/P;#Brake specific fuel consumption in kg/kWsec\n",
    "A=1+r;#Mass of fuel mixture entering the engine foe every one kg of fuel in kg\n",
    "m=A*F;#Mass of air fuel mixture per second in kg\n",
    "V=(m*R1*T)/(p1*10**5/1000);#Volume of air fuel mixture supplied to the engine per sec\n",
    "Vs=V/(nv/100);#Swept volume per second in m**3/sec\n",
    "d=((Vs*2*60*4)/(S*3.14*r1*4))**(1./3)*1000;#Diameter of the bore in mm\n",
    "L=r1*d;#Stroke length in mm\n",
    "\n",
    "#Output\n",
    "print '(a)Compression ratio = ',round(R,1)\n",
    "print '(b)Indicated thermal efficiency is (percent) = ',nti\n",
    "print '(c)Brake specific fuel consumption is (kg/kW sec) = ',round(B,7)\n",
    "print '(d)Bore diameter of the engine is (mm) = ',round(d,2)\n",
    "print '(e)Stroke length of the engine is (mm) = ',round(L,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 24 - pg 7.42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Power available at brakes is (kW) =  24.23\n",
      "(b)Indicated power developed is (kW) =  34.19\n",
      "(c)Mechanical efficiency is (percent) =  70.85\n",
      "(d)Brake Thermal efficiency is (percent) =  27.69\n",
      "(e)Indicated thermal efficiency is (percent) =  39.08\n",
      "Heat balance :\n",
      "Heat supplied by fuel (kJ/hr) =  315000.0\n",
      "Heat equivalent of power of brakes (percent) =  26.9\n",
      "Heat equivalent of loss in friction (percent) =  11.4\n",
      "Heat equivalent of removed through jacket (percent) =  26.6\n",
      "Heat equivalent of carried away by gases (percent) =  26.91\n",
      "Heat equivalent of unaccounted (percent) =  7.4\n"
     ]
    }
   ],
   "source": [
    "#pg 7.42\n",
    "#calculate the power and efficiency in all cases\n",
    "#Input data\n",
    "d=0.3;#Diameter of the bore in m\n",
    "L=0.45;#Stroke length in m\n",
    "N=220.;#Operating speed of the engine in rpm\n",
    "T=3600.;#Duration of trial in sec\n",
    "F=7.;#Fuel consumption in kg per minute\n",
    "CV=45000.;#Calorific value of fuel in kJ/kg\n",
    "A=320.;#Area of indicator diagram in mm**2\n",
    "l=60.;#Length of indicator diagram in mm\n",
    "S=1.1;#Spring index in bar/mm\n",
    "W=130.;#Net load on brakes in kg\n",
    "D=1.65;#Diameter of brake drum in m\n",
    "W1=500.;#Total weight of jacket cooling water in kg\n",
    "t=40.;#Temperature rise of jacket cooling water in degrees celsius\n",
    "t1=300.;#Temperature of exhaust gases in degrees celsius\n",
    "ma=300.;#Air consumption in kg\n",
    "sg=1.004;#Specific heat of exhaust gas in kJ/kgK\n",
    "sw=4.185;#Specific heat of water in kJ/kgK\n",
    "t2=25.;#Room temperature in degrees celsius\n",
    "g=9.81;#gravity\n",
    "\n",
    "#Calculations\n",
    "P=(W*g*3.14*D*N)/(1000*60);#Power available at brakes in kW\n",
    "pm=(A*S)/l;#Mean effective pressure in bar\n",
    "I=(pm*10**5*L*((3.14*d**2)/4)*N)/(1000.*2*60);#Indicated power developed in kW\n",
    "nm=(P/I)*100;#Mechanical efficiency in percent\n",
    "nt=(P/((F/T)*CV))*100;#Brake thermal efficiency in percent\n",
    "ni=(I/((F/T)*CV))*100;#Indicated thermal efficiency in percent\n",
    "Hs=F*CV;#Heat supplied on one hour basis\n",
    "Hp=P*T;#Heat equivalent of brake power in kJ\n",
    "Hf=(I-P)*3600;#Heat lost in friction in kJ\n",
    "Hc=W1*t*sw;#Heat carried away by cooling water in kJ\n",
    "He=(ma+F)*(t1-t2)*sg;#Heat carried away by exhaust gas in kJ\n",
    "Hu=Hs-(Hp+Hf+Hc+He);#Heat unaccounted in kJ\n",
    "nb=(He/Hs)*100;#Heat equivalent of power at brakes in percent\n",
    "nf=(Hf/Hs)*100;#Heat lost in friction in percent\n",
    "nw=(Hc/Hs)*100;#Heat removed by jacket water in percent\n",
    "ne=(He/Hs)*100;#Heat carried away by exhaust gases in percent\n",
    "nu=(Hu/Hs)*100;#Heat unaccounted in percent\n",
    "\n",
    "#Output\n",
    "print '(a)Power available at brakes is (kW) = ',round(P,2)\n",
    "print '(b)Indicated power developed is (kW) = ',round(I,2)\n",
    "print '(c)Mechanical efficiency is (percent) = ',nm\n",
    "print '(d)Brake Thermal efficiency is (percent) = ',round(nt,2)\n",
    "print '(e)Indicated thermal efficiency is (percent) = ',round(ni,2)\n",
    "print 'Heat balance :'\n",
    "print 'Heat supplied by fuel (kJ/hr) = ',Hs\n",
    "print 'Heat equivalent of power of brakes (percent) = ',round(nb,1)\n",
    "print 'Heat equivalent of loss in friction (percent) = ',round(nf,1)\n",
    "print 'Heat equivalent of removed through jacket (percent) = ',round(nw,1)\n",
    "print 'Heat equivalent of carried away by gases (percent) = ',round(ne,2)\n",
    "print 'Heat equivalent of unaccounted (percent) = ',round(nu,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 25 - pg 7.46"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Indicated horse power is (kcal) =  42.62\n",
      "(b)Brake horse power developed is (kcal) =  34.93\n",
      "(c)Heat equivalent of friction is (kcal) =  81.0\n"
     ]
    }
   ],
   "source": [
    "#pg 7.46\n",
    "#calculate the Indicated, brake horse power\n",
    "#Input data\n",
    "d=25.;#The bore diameter of a single cylinder 4 stroke engine in cm\n",
    "l=0.38;#Stroke length in m\n",
    "t=3600.;#Duration of test in sec\n",
    "r=19710.;#Total number of revolutions\n",
    "F=6.25;#Fuel oil used in kg\n",
    "A=5.7;#Area of indicator diagram in cm**2\n",
    "L=7.6;#Length of indicator diagram in cm\n",
    "S=8.35;#Spring number in kgf/cm**3\n",
    "P=63.5;#Net load on brake drum in kg\n",
    "R=1.2;#Radius of brake drum in m\n",
    "Ww=5.7;#Rate of coolant flow in kg/min\n",
    "deltaT=44.;#Temperature rise of coolant in degrees celsius\n",
    "T1=15.5;#Atmospheric temperature in degrees celsius\n",
    "As=30.;#Air supplied per kg of fuel\n",
    "CV=10600.;#Calorific value of fuel in kcal/kg\n",
    "Te=390.;#Exhaust gas temperature in degrees celsius\n",
    "sm=0.25;#Mean specific heat of exhaust gas\n",
    "\n",
    "#Calculations\n",
    "Hs=(F*CV)/60.;#Heat supplied by fuel per minute in kcal\n",
    "pm=(A*S)/L;#Mean effective pressure in kgf/cm**2\n",
    "I=(pm*l*(3.14*d**2)*r)/(4*60.*2*4500);#Indicated horse power in kW\n",
    "B=(P*R*2*3.14*r)/(4500*60);#Brake horse power in kW\n",
    "Hei=(I*4500)/427.;#Heat equivalent of IHP/min in kcal\n",
    "Heb=(B*4500)/427.;#Heat equivalent of BHP/min in kcal\n",
    "Hf=Hei-Heb;#Heat in friction per minute in kcal\n",
    "Hc=Ww*deltaT;#Heat carried away by coolant in kcal\n",
    "We=(F+(As*F))/60.;#Weight of exhaust gases per minute\n",
    "He=We*(Te-T1)*sm;#Heat carried away by exhaust gases in kcal\n",
    "\n",
    "#Output\n",
    "print '(a)Indicated horse power is (kcal) = ',round(I,2)\n",
    "print '(b)Brake horse power developed is (kcal) = ',round(B,2)\n",
    "print '(c)Heat equivalent of friction is (kcal) = ',round(Hf,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 26 - pg 7.48"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percentage of heat carried away by exhaust gas is (percent) =  24.06\n"
     ]
    }
   ],
   "source": [
    "#pg 7.48\n",
    "#calculate the percentage of heat carried away\n",
    "#Input\n",
    "F=10.;#Quantity of fuel supplied during the trial of a diesel engine in kg/hr\n",
    "CV=42500.;#Calorific value of fuel in kJ/kg\n",
    "r=20.;#Air fuel ratio\n",
    "T=20.;#Ambient temperature in degrees celsius\n",
    "mw=585.;#Water circulated through the gas calorimeter in litres/hr\n",
    "T1=35.;#Temperature rise of water through the calorimeter in degrees celsius\n",
    "T2=95.;#Temperature of gases at exit from the calorimeter in degrees celsius\n",
    "se=1.05;#Specific heat of exhaust gases in kJ/kgK\n",
    "sw=4.186;#Specific heat of water in kJ/kgK\n",
    "\n",
    "#Calculations\n",
    "M=(F/60.)*(r+1);#Mass of exhaust gases formed per minute\n",
    "H=((mw/60.)*sw*T1)+(M*se*(T2-T));#Heat carried away by the exhaust gases per minute in kJ/min\n",
    "Hs=(F/60.)*CV;#Heat supplied by fuel per minute in kJ/min\n",
    "nh=(H/Hs)*100;#Percentage of heat carried away by the exhaust gas\n",
    "\n",
    "#Output\n",
    "print 'Percentage of heat carried away by exhaust gas is (percent) = ',round(nh,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 27 - pg 7.49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percentage of heat carried away by exhaust gases is (percent) =  27.9\n"
     ]
    }
   ],
   "source": [
    "#pg 7.49\n",
    "#calculate the Percentage of heat carried away\n",
    "#Input data\n",
    "F=11.;#Fuel used per hour observed during the trial of a single cylinder four stroke diesel engine in kg\n",
    "mc=85.;#Carbon present in the fuel in percent\n",
    "mh=14.;#Hydrogen present in the fuel in percent\n",
    "mn=1.;#Non combustibles present in the fuel in percent\n",
    "CV=50000.;#Calorific value of fuel in kJ/kg\n",
    "Vc=8.5;#Percentage of carbon dioxide present in exhaust gas by Volumetric analysis\n",
    "Vo=10.;#Oxygen present in exhaust gases in percent\n",
    "Vn=81.5;#Nitrogen present in exhaust gases in percent\n",
    "Te=400.;#Temperature of exhaust gases in degrees celsius\n",
    "se=1.05;#Specific heat of exhaust gas in kJ/kg\n",
    "Pp=0.030;#Partial pressure of steam in the exhaust in bar\n",
    "Ta=20.;#Ambient temperature in degrees celsius\n",
    "hs=2545.6;#Enthalpy of saturated steam in kJ/kg\n",
    "Tsa=24.1;#Saturation temperature from graph in degrees celcius\n",
    "Cp=2.1;#Specific heat in kJ/kg K\n",
    "hst=3335.;#Enthalpy of super heated steam in kJ/kg\n",
    "F1=9.\n",
    "#Calculations\n",
    "Ma=(Vn*mc)/(33.*Vc);#Mass of air supplied per kg of fuel in kg\n",
    "Me=Ma+1;#Mass of exhaust gases formed per kg of fuel in kg\n",
    "me=(Me*F)/60.;#Mass of exhaust gases formed per minute in kg\n",
    "ms=F1*(mh/100.);#Mass of steam formed per kg of fuel in kg\n",
    "ms1=(ms*F)/60.;#Mass of steam formed per minute in kg\n",
    "mde=me-ms1;#Mass of dry exhaust gases formed per minute in kg\n",
    "H=mde*se*(Te-Ta);#Heat carried away by the dry exhaust gases per minute in kJ/min\n",
    "Es=hs+(Cp*(Te-Tsa));#Enthalpy of superheated steam in kJ/kg\n",
    "He=ms1*hst;#Heat carried away by steam in the exhaust gases in kJ/min\n",
    "Hl=H+He;#Total heat lost through dry exhaust gases and steam in kJ/min\n",
    "Hf=(F/60.)*CV;#Heat supplied by fuel per minute in kJ/min\n",
    "nh=(Hl/Hf)*100.;#Percentage of heat carried away by exhaust gases\n",
    "\n",
    "#Output\n",
    "print 'Percentage of heat carried away by exhaust gases is (percent) = ',round(nh,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 28 - pg 7.51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The net increase in brake power is (kW) =  29.15\n"
     ]
    }
   ],
   "source": [
    "#pg 7.51\n",
    "#calculate the net increase in brake power\n",
    "#Input data\n",
    "C=0.0033;#The capacity of a four stroke engine of compression ignition type\n",
    "I=13.;#Average indicated power developed in kW/m**3\n",
    "N=3500.;#Operating speed of the engine\n",
    "nv=80.;#Volumetric efficiency in percentage\n",
    "p1=1.013;#Initial pressure in bar\n",
    "T1=298.;#Initial temperature in K\n",
    "r=1.75;#Pressure ratio of the engine\n",
    "ni=75.;#The isentropic efficiency in percentage\n",
    "nm=80.;#mechanical efficiency in percentage\n",
    "r1=1.4;#Polytropic index\n",
    "\n",
    "#Calculations\n",
    "Vs=(N/2.)*C;#Swept volume in m**3/min\n",
    "Vi=Vs*(nv/100);#Unsupercharged engine inducted volume in m**3/min\n",
    "Pb=p1*r;#Blower delivery pressure in bar\n",
    "T2s=((r)**((r1-1)/r1))*T1;#Final temperature in K\n",
    "T2=((T2s-T1)/(ni/100.))+T1;#Blower delivery temperature in K\n",
    "Ve=((Pb*Vs)*T1)/(T2*p1);#Equivalent volume at 1.013 bar and 298K in m**3/min\n",
    "Vin=Ve-Vi;#Increase in inducted volume of air in m**3/min\n",
    "Pin=Vin*I;#Increase in indicated power due to extra air inducted in kW\n",
    "Pinp=((Pb-p1)*Vs*100.)/60.;#Increase in indicated power due to increase in induction pressure in kW\n",
    "Pt=Pin+Pinp;#Total increase in indicated power in kW\n",
    "nb=Pt*(nm/100.);#Total increase in brake power efficiency in kW\n",
    "ma=(Pb*Vs*100.)/(60*0.287*T2);#Mass of air delivered by the blower in kg/s\n",
    "Wb=ma*1.005*(T2-T1);#Work input to air by blower in kW\n",
    "Pb1=Wb/(nv/100.);#Power required to drive the blower in kW\n",
    "Pb2=nb-Pb1;#Net increase in brake power in kW\n",
    "\n",
    "#Output\n",
    "print 'The net increase in brake power is (kW) = ',round(Pb2,2)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}