summaryrefslogtreecommitdiff
path: root/_Engineering_Thermodynamics_by__O._Singh/chapter6.ipynb
blob: 92ef2871d09ff00b035dcc181b964741c23a0501 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6:Thermo dynamic Properties of pure substance"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.1;pg no: 174"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.1, Page:174  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 1\n",
      "NOTE=>In question no. 1 expression for various quantities is derived which cannot be solve using python software.\n"
     ]
    }
   ],
   "source": [
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.1, Page:174  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 1\")\n",
    "print(\"NOTE=>In question no. 1 expression for various quantities is derived which cannot be solve using python software.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.2;pg no: 175"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.2, Page:175  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 2\n",
      "during throttling,h1=h2\n",
      "at state 2,enthalpy can be seen for superheated steam using Table 4 at 0.05 Mpa and 100 degree celcius\n",
      "thus h2=2682.5 KJ/kg\n",
      "at state 1,before throttling\n",
      "hf_10Mpa=1407.56 KJ/kg\n",
      "hfg_10Mpa=1317.1 KJ/kg\n",
      "h1=hf_10Mpa+x1*hfg_10Mpa\n",
      "dryness fraction(x1)may be given as\n",
      "x1= 0.97\n"
     ]
    }
   ],
   "source": [
    "#cal of dryness fraction\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.2, Page:175  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 2\")\n",
    "print(\"during throttling,h1=h2\")\n",
    "print(\"at state 2,enthalpy can be seen for superheated steam using Table 4 at 0.05 Mpa and 100 degree celcius\")\n",
    "print(\"thus h2=2682.5 KJ/kg\")\n",
    "h2=2682.5;\n",
    "print(\"at state 1,before throttling\")\n",
    "print(\"hf_10Mpa=1407.56 KJ/kg\")\n",
    "hf_10Mpa=1407.56;\n",
    "print(\"hfg_10Mpa=1317.1 KJ/kg\")\n",
    "hfg_10Mpa=1317.1;\n",
    "print(\"h1=hf_10Mpa+x1*hfg_10Mpa\")\n",
    "h1=h2;#during throttling\n",
    "print(\"dryness fraction(x1)may be given as\")\n",
    "x1=(h1-hf_10Mpa)/hfg_10Mpa\n",
    "print(\"x1=\"),round(x1,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.3;pg no: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.3, Page:176  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 3\n",
      "internal energy(u)=in KJ/kg 2644.0\n"
     ]
    }
   ],
   "source": [
    "#cal of internal energy\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.3, Page:176  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 3\")\n",
    "h=2848;#enthalpy in KJ/kg\n",
    "p=12*1000;#pressure in Kpa\n",
    "v=0.017;#specific volume in m^3/kg\n",
    "u=h-p*v\n",
    "print(\"internal energy(u)=in KJ/kg\"),round(u,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.4;pg no: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.4, Page:176  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 4\n",
      "steam state 2 Mpa and 300 degree celcius lies in superheated region as saturation temperature at 2 Mpa is 212.42 degree celcius and hfg=1890.7 KJ/kg\n",
      "entropy of unit mass of superheated steam with reference to absolute zero(S)in KJ/kg K\n",
      "S= 6.65\n",
      "entropy of 5 kg of steam(S)in KJ/K\n",
      "S=m*S 33.23\n"
     ]
    }
   ],
   "source": [
    "#cal of entropy of 5 kg of steam\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "import math\n",
    "print\"Example 6.4, Page:176  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 4\")\n",
    "m=5;#mass of steam in kg\n",
    "p=2;#pressure of steam in Mpa\n",
    "T_superheat=(300+273.15);#temperature of superheat steam in K\n",
    "Cp_water=4.18;#specific heat of water at constant pressure in KJ/kg K\n",
    "Cp_superheat=2.1;#specific heat of superheat steam at constant pressure in KJ/kg K\n",
    "print(\"steam state 2 Mpa and 300 degree celcius lies in superheated region as saturation temperature at 2 Mpa is 212.42 degree celcius and hfg=1890.7 KJ/kg\")\n",
    "T_sat=(212.42+273.15);#saturation temperature at 2 Mpa in K\n",
    "hfg_2Mpa=1890.7;\n",
    "print(\"entropy of unit mass of superheated steam with reference to absolute zero(S)in KJ/kg K\")\n",
    "S=Cp_water*math.log(T_sat/273.15)+(hfg_2Mpa/T_sat)+(Cp_superheat*math.log(T_superheat/T_sat))\n",
    "print(\"S=\"),round(S,2)\n",
    "print(\"entropy of 5 kg of steam(S)in KJ/K\")\n",
    "S=m*S\n",
    "print(\"S=m*S\"),round(S,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.5;pg no: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.5, Page:176  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 5\n",
      "boiling point =110 degree celcius,pressure at which it boils=143.27 Kpa(from steam table,sat. pressure for 110 degree celcius)\n",
      "at further depth of 50 cm the pressure(p)in Kpa\n",
      "p= 138.37\n",
      "boiling point at this depth=Tsat_138.365\n",
      "from steam table this temperature=108.866=108.87 degree celcius\n",
      "so boiling point = 108.87 degree celcius\n"
     ]
    }
   ],
   "source": [
    "#cal of boiling point\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.5, Page:176  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 5\")\n",
    "rho=1000;#density of water in kg/m^3\n",
    "g=9.81;#acceleration due to gravity in m/s^2\n",
    "h=0.50;#depth from above mentioned level in m\n",
    "print(\"boiling point =110 degree celcius,pressure at which it boils=143.27 Kpa(from steam table,sat. pressure for 110 degree celcius)\")\n",
    "p_boil=143.27;#pressure at which pond water boils in Kpa\n",
    "print(\"at further depth of 50 cm the pressure(p)in Kpa\")\n",
    "p=p_boil-((rho*g*h)*10**-3)\n",
    "print(\"p=\"),round(p,2)\n",
    "print(\"boiling point at this depth=Tsat_138.365\")\n",
    "print(\"from steam table this temperature=108.866=108.87 degree celcius\")\n",
    "print(\"so boiling point = 108.87 degree celcius\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.6;pg no: 177"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.6, Page:177  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 6\n",
      "in a rigid vessel it can be treated as constant volume process.\n",
      "so v1=v2\n",
      "since final state is given to be critical state,then specific volume at critical point,\n",
      "v2=0.003155 m^3/kg\n",
      "at 100 degree celcius saturation temperature,from steam table\n",
      "vf_100=0.001044 m^3/kg,vg_100=1.6729 m^3/kg\n",
      "and vfg_100=in m^3/kg= 1.67\n",
      "thus for initial quality being x1\n",
      "v1=vf_100+x1*vfg_100\n",
      "so x1= 0.001\n",
      "mass of water initially=total mass*(1-x1)\n",
      "total mass of fluid/water(m) in kg= 158.48\n",
      "volume of water(v) in m^3= 0.1655\n"
     ]
    }
   ],
   "source": [
    "#cal of mass and volume of water\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.6, Page:177  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 6\")\n",
    "V=0.5;#capacity of rigid vessel in m^3\n",
    "print(\"in a rigid vessel it can be treated as constant volume process.\")\n",
    "print(\"so v1=v2\")\n",
    "print(\"since final state is given to be critical state,then specific volume at critical point,\")\n",
    "print(\"v2=0.003155 m^3/kg\")\n",
    "v2=0.003155;#specific volume at critical point in m^3/kg\n",
    "print(\"at 100 degree celcius saturation temperature,from steam table\")\n",
    "print(\"vf_100=0.001044 m^3/kg,vg_100=1.6729 m^3/kg\")\n",
    "vf_100=0.001044;\n",
    "vg_100=1.6729;\n",
    "vfg_100=vg_100-vf_100\n",
    "print(\"and vfg_100=in m^3/kg=\"),round(vfg_100,2)\n",
    "print(\"thus for initial quality being x1\")\n",
    "v1=v2;#rigid vessel\n",
    "x1=(v1-vf_100)/vfg_100\n",
    "print(\"v1=vf_100+x1*vfg_100\")\n",
    "print(\"so x1=\"),round(x1,3)\n",
    "print(\"mass of water initially=total mass*(1-x1)\")\n",
    "m=V/v2\n",
    "print(\"total mass of fluid/water(m) in kg=\"),round(m,2)\n",
    "v=m*vf_100\n",
    "print(\"volume of water(v) in m^3=\"),round(v,4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.7;pg no: 177"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.7, Page:177  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 7\n",
      "on mollier diadram(h-s diagram)the slope of isobaric line may be given as\n",
      "(dh/ds)_p=cons =slope of isobar\n",
      "from 1st and 2nd law combined;\n",
      "T*ds=dh-v*dp\n",
      "(dh/ds)_p=cons = T\n",
      "here temperature,T=773.15 K\n",
      "here slope=(dh/ds))p=cons = 773.15\n"
     ]
    }
   ],
   "source": [
    "#cal of slope\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.7, Page:177  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 7\")\n",
    "print(\"on mollier diadram(h-s diagram)the slope of isobaric line may be given as\")\n",
    "print(\"(dh/ds)_p=cons =slope of isobar\")\n",
    "print(\"from 1st and 2nd law combined;\")\n",
    "print(\"T*ds=dh-v*dp\")\n",
    "print(\"(dh/ds)_p=cons = T\")\n",
    "print(\"here temperature,T=773.15 K\")\n",
    "print(\"here slope=(dh/ds))p=cons = 773.15\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.8;pg no: 178"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.8, Page:178  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 8\n",
      "at 0.15Mpa,from steam table;\n",
      "hf=467.11 KJ/kg,hg=2693.6 KJ/kg\n",
      "and hfg in KJ/kg= 2226.49\n",
      "vf=0.001053 m^3/kg,vg=1.1593 m^3/kg\n",
      "and vfg in m^3/kg= 1.16\n",
      "sf=1.4336 KJ/kg,sg=7.2233 KJ/kg\n",
      "and sfg=in KJ/kg K= 5.79\n",
      "enthalpy at x=.10(h)in KJ/kg\n",
      "h= 689.76\n",
      "specific volume,(v)in m^3/kg\n",
      "v= 0.12\n",
      "entropy (s)in KJ/kg K\n",
      "s= 2.01\n"
     ]
    }
   ],
   "source": [
    "#cal of entropy\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.8, Page:178  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 8\")\n",
    "x=.10;#quality is 10%\n",
    "print(\"at 0.15Mpa,from steam table;\")\n",
    "print(\"hf=467.11 KJ/kg,hg=2693.6 KJ/kg\")\n",
    "hf=467.11;\n",
    "hg=2693.6;\n",
    "hfg=hg-hf\n",
    "print(\"and hfg in KJ/kg=\"),round(hfg,2)\n",
    "print(\"vf=0.001053 m^3/kg,vg=1.1593 m^3/kg\")\n",
    "vf=0.001053;\n",
    "vg=1.1593;\n",
    "vfg=vg-vf\n",
    "print(\"and vfg in m^3/kg=\"),round(vfg,2)\n",
    "print(\"sf=1.4336 KJ/kg,sg=7.2233 KJ/kg\")\n",
    "sf=1.4336;\n",
    "sg=7.2233;\n",
    "sfg=sg-sf\n",
    "print(\"and sfg=in KJ/kg K=\"),round(sfg,2)\n",
    "print(\"enthalpy at x=.10(h)in KJ/kg\")\n",
    "h=hf+x*hfg\n",
    "print(\"h=\"),round(h,2)\n",
    "print(\"specific volume,(v)in m^3/kg\")\n",
    "v=vf+x*vfg\n",
    "print(\"v=\"),round(v,2)\n",
    "print(\"entropy (s)in KJ/kg K\")\n",
    "s=sf+x*sfg\n",
    "print(\"s=\"),round(s,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.9;pg no: 178"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.9, Page:178  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 9\n",
      "work done during constant pressure process(W)=p1*(V2-V1)in KJ\n",
      "now from steam table at p1,vf=0.001127 m^3/kg,vg=0.19444 m^3/kg,uf=761.68 KJ/kg,ufg=1822 KJ/kg\n",
      "so v1 in m^3/kg=\n",
      "now mass of steam(m) in kg= 0.32\n",
      "specific volume at final state(v2)in m^3/kg\n",
      "v2= 0.62\n",
      "corresponding to this specific volume the final state is to be located for getting the internal energy at final state at 1 Mpa\n",
      "v2>vg_1Mpa\n",
      "hence state lies in superheated region,from the steam table by interpolation we get temperature as;\n",
      "state lies between temperature of 1000 degree celcius and 1100 degree celcius\n",
      "so exact temperature at final state(T)in K= 1077.61\n",
      "thus internal energy at final state,1 Mpa,1077.61 degree celcius;\n",
      "u2=4209.6 KJ/kg\n",
      "internal energy at initial state(u1)in KJ/kg\n",
      "u1= 2219.28\n",
      "from first law of thermodynamics,Q-W=deltaU\n",
      "so heat added(Q)=(U2-U1)+W=m*(u2-u1)+W in KJ= 788.83\n"
     ]
    }
   ],
   "source": [
    "#cal of heat added\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.9, Page:178  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 9\")\n",
    "p1=1*1000;#initial pressure of steam in Kpa\n",
    "V1=0.05;#initial volume of steam in m^3\n",
    "x1=.8;#dryness fraction is 80%\n",
    "V2=0.2;#final volume of steam in m^3\n",
    "p2=p1;#constant pressure process\n",
    "print(\"work done during constant pressure process(W)=p1*(V2-V1)in KJ\")\n",
    "W=p1*(V2-V1)\n",
    "print(\"now from steam table at p1,vf=0.001127 m^3/kg,vg=0.19444 m^3/kg,uf=761.68 KJ/kg,ufg=1822 KJ/kg\")\n",
    "vf=0.001127;\n",
    "vg=0.19444;\n",
    "uf=761.68;\n",
    "ufg=1822;\n",
    "v1=vf+x1*vg\n",
    "print(\"so v1 in m^3/kg=\")\n",
    "m=V1/v1\n",
    "print(\"now mass of steam(m) in kg=\"),round(m,2)\n",
    "m=0.32097;#take m=0.32097 approx.\n",
    "print(\"specific volume at final state(v2)in m^3/kg\")\n",
    "v2=V2/m\n",
    "print(\"v2=\"),round(v2,2)\n",
    "print(\"corresponding to this specific volume the final state is to be located for getting the internal energy at final state at 1 Mpa\")\n",
    "print(\"v2>vg_1Mpa\")\n",
    "print(\"hence state lies in superheated region,from the steam table by interpolation we get temperature as;\")\n",
    "print(\"state lies between temperature of 1000 degree celcius and 1100 degree celcius\")\n",
    "T=1000+((100*(.62311-.5871))/(.6335-.5871))\n",
    "print(\"so exact temperature at final state(T)in K=\"),round(T,2)\n",
    "print(\"thus internal energy at final state,1 Mpa,1077.61 degree celcius;\")\n",
    "print(\"u2=4209.6 KJ/kg\")\n",
    "u2=4209.6;\n",
    "print(\"internal energy at initial state(u1)in KJ/kg\")\n",
    "u1=uf+x1*ufg\n",
    "print(\"u1=\"),round(u1,2)\n",
    "print(\"from first law of thermodynamics,Q-W=deltaU\")\n",
    "Q=m*(u2-u1)+W\n",
    "print(\"so heat added(Q)=(U2-U1)+W=m*(u2-u1)+W in KJ=\"),round(Q,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.10;pg no: 179"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.10, Page:179  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 10\n",
      "here steam is kept in rigid vessel,therefore its specific volume shall remain constant\n",
      "it is superheated steam as Tsat=170.43 degree celcius at 800 Kpa\n",
      "from superheated steam table;v1=0.2404 m^3/kg\n",
      "at begining of condensation specific volume = 0.2404 m^3/kg\n",
      "v2=0.2404 m^3/kg\n",
      "this v2 shall be specific volume corresponding to saturated vapour state for condensation.\n",
      "thus v2=vg=0.2404 m^3/kg\n",
      "looking into steam table vg=0.2404 m^3/kg shall lie between temperature 175 degree celcius(vg=0.2168 m^3/kg)and 170 degree celcius(vg=0.2428 m^3/kg)and pressure 892 Kpa(175 degree celcius)and 791.7 Kpa(170 degree celcius).\n",
      "by interpolation,temperature at begining of condensation(T2)in K\n",
      "similarily,pressure(p2)in Kpa= 800.96\n"
     ]
    }
   ],
   "source": [
    "#cal of pressure\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.10, Page:179  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 10\")\n",
    "p1=800;#initial pressure of steam in Kpa\n",
    "T1=200;#initial temperature of steam in degree celcius\n",
    "print(\"here steam is kept in rigid vessel,therefore its specific volume shall remain constant\")\n",
    "print(\"it is superheated steam as Tsat=170.43 degree celcius at 800 Kpa\")\n",
    "print(\"from superheated steam table;v1=0.2404 m^3/kg\")\n",
    "print(\"at begining of condensation specific volume = 0.2404 m^3/kg\")\n",
    "print(\"v2=0.2404 m^3/kg\")\n",
    "v2=0.2404;\n",
    "print(\"this v2 shall be specific volume corresponding to saturated vapour state for condensation.\")\n",
    "print(\"thus v2=vg=0.2404 m^3/kg\")\n",
    "vg=v2;\n",
    "print(\"looking into steam table vg=0.2404 m^3/kg shall lie between temperature 175 degree celcius(vg=0.2168 m^3/kg)and 170 degree celcius(vg=0.2428 m^3/kg)and pressure 892 Kpa(175 degree celcius)and 791.7 Kpa(170 degree celcius).\")\n",
    "print(\"by interpolation,temperature at begining of condensation(T2)in K\")\n",
    "T2=175-((175-170)*(0.2404-0.2167))/(0.2428-.2168)\n",
    "p=892-(((892-791.7)*(0.2404-0.2168))/(0.2428-0.2168))\n",
    "print(\"similarily,pressure(p2)in Kpa=\"),round(p,2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.11;pg no: 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.11, Page:180  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 11\n",
      "from 1st and 2nd law;\n",
      "T*ds=dh-v*dp\n",
      "for isentropic process,ds=0\n",
      "hence dh=v*dp\n",
      "i.e (h2-h1)=v1*(p2-p1)\n",
      "corresponding to initial state of saturated liquid at 30 degree celcius;from steam table;\n",
      "p1=4.25 Kpa,vf=v1=0.001004 m^3/kg\n",
      "therefore enthalpy change(deltah)=(h2-h1) in KJ/kg= 0.2\n"
     ]
    }
   ],
   "source": [
    "#cal of enthalpy change\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.11, Page:180  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 11\")\n",
    "p2=200;#feed water pump pressure in Kpa\n",
    "print(\"from 1st and 2nd law;\")\n",
    "print(\"T*ds=dh-v*dp\")\n",
    "print(\"for isentropic process,ds=0\")\n",
    "print(\"hence dh=v*dp\")\n",
    "print(\"i.e (h2-h1)=v1*(p2-p1)\")\n",
    "print(\"corresponding to initial state of saturated liquid at 30 degree celcius;from steam table;\")\n",
    "print(\"p1=4.25 Kpa,vf=v1=0.001004 m^3/kg\")\n",
    "p1=4.25;\n",
    "v1=0.001004;\n",
    "deltah=v1*(p2-p1)\n",
    "print(\"therefore enthalpy change(deltah)=(h2-h1) in KJ/kg=\"),round(deltah,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.12;pg no: 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.12, Page:180  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 12\n",
      "from steam table at 150 degree celcius\n",
      "vf=0.001091 m^3/kg,vg=0.3928 m^3/kg\n",
      "so volume occupied by water(Vw)=3*V/(3+2) in m^3 1.2\n",
      "and volume of steam(Vs) in m^3= 0.8\n",
      "mass of water(mf)=Vw/Vf in kg 1099.91\n",
      "mass of steam(mg)=Vs/Vg in kg 2.04\n",
      "total mass in tank(m) in kg= 1101.95\n",
      "quality or dryness fraction(x)\n",
      "x= 0.002\n",
      "NOTE=>answer given in book for mass=1103.99 kg is incorrect and correct answer is 1101.945 which is calculated above.\n"
     ]
    }
   ],
   "source": [
    "#cal of quality or dryness fraction\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.12, Page:180  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 12\")\n",
    "V=2.;#volume of vessel in m^3\n",
    "print(\"from steam table at 150 degree celcius\")\n",
    "print(\"vf=0.001091 m^3/kg,vg=0.3928 m^3/kg\")\n",
    "Vf=0.001091;\n",
    "Vg=0.3928;\n",
    "Vw=3*V/(3+2)\n",
    "print(\"so volume occupied by water(Vw)=3*V/(3+2) in m^3\"),round(Vw,2)\n",
    "Vs=2*V/(3+2)\n",
    "print(\"and volume of steam(Vs) in m^3=\"),round(Vs,2)\n",
    "mf=Vw/Vf\n",
    "print(\"mass of water(mf)=Vw/Vf in kg\"),round(mf,2)\n",
    "mg=Vs/Vg\n",
    "print(\"mass of steam(mg)=Vs/Vg in kg\"),round(mg,2)\n",
    "m=mf+mg\n",
    "print(\"total mass in tank(m) in kg=\"),round(m,2)\n",
    "print(\"quality or dryness fraction(x)\")\n",
    "x=mg/m\n",
    "print(\"x=\"),round(x,3)\n",
    "print(\"NOTE=>answer given in book for mass=1103.99 kg is incorrect and correct answer is 1101.945 which is calculated above.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.13;pg no: 181"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.13, Page:181  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 13\n",
      "fron S.F.S.E on steam turbine;\n",
      "W=h1-h2\n",
      "initially at 4Mpa,300 degree celcius the steam is super heated so enthalpy from superheated steam or mollier diagram\n",
      "h1=2886.2 KJ/kg,s1=6.2285 KJ/kg K\n",
      "reversible adiabatic expansion process has entropy remaining constant.on mollier diagram the state 2 can be simply located at intersection of constant temperature line for 50 degree celcius and isentropic expansion line.\n",
      "else from steam tables at 50 degree celcius saturation temperature;\n",
      "hf=209.33 KJ/kg,sf=0.7038 KJ/kg K\n",
      "hfg=2382.7 KJ/kg,sfg=7.3725 KJ/kg K\n",
      "here s1=s2,let dryness fraction at 2 be x2\n",
      "x2= 0.75\n",
      "hence enthalpy at state 2\n",
      "h2 in KJ/kg= 1994.84\n",
      "steam turbine work(W)in KJ/kg\n",
      "W=h1-h2\n",
      "so turbine output=W 891.36\n"
     ]
    }
   ],
   "source": [
    "#cal of turbine output\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.13, Page:181  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 13\")\n",
    "print(\"fron S.F.S.E on steam turbine;\")\n",
    "print(\"W=h1-h2\")\n",
    "print(\"initially at 4Mpa,300 degree celcius the steam is super heated so enthalpy from superheated steam or mollier diagram\")\n",
    "print(\"h1=2886.2 KJ/kg,s1=6.2285 KJ/kg K\")\n",
    "h1=2886.2;\n",
    "s1=6.2285;\n",
    "print(\"reversible adiabatic expansion process has entropy remaining constant.on mollier diagram the state 2 can be simply located at intersection of constant temperature line for 50 degree celcius and isentropic expansion line.\")\n",
    "print(\"else from steam tables at 50 degree celcius saturation temperature;\")\n",
    "print(\"hf=209.33 KJ/kg,sf=0.7038 KJ/kg K\")\n",
    "hf=209.33;\n",
    "sf=0.7038;\n",
    "print(\"hfg=2382.7 KJ/kg,sfg=7.3725 KJ/kg K\")\n",
    "hfg=2382.7;\n",
    "sfg=7.3725;\n",
    "print(\"here s1=s2,let dryness fraction at 2 be x2\")\n",
    "x2=(s1-sf)/sfg\n",
    "print(\"x2=\"),round(x2,2)\n",
    "print(\"hence enthalpy at state 2\")\n",
    "h2=hf+x2*hfg\n",
    "print(\"h2 in KJ/kg=\"),round(h2,2)\n",
    "print(\"steam turbine work(W)in KJ/kg\")\n",
    "W=h1-h2\n",
    "print(\"W=h1-h2\")\n",
    "print(\"so turbine output=W\"),round(W,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.14;pg no: 181"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.14, Page:181  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 14\n",
      "it is constant volume process\n",
      "volume of vessel(V)=mass of vapour * specific volume of vapour\n",
      "initial specific volume,v1\n",
      "v1=vf_100Kpa+x1*vfg_100 in m^3/kg\n",
      "at 100 Kpa from steam table;\n",
      "hf_100Kpa=417.46 KJ/kg,uf_100Kpa=417.36 KJ/kg,vf_100Kpa=0.001043 m^3/kg,hfg_100Kpa=2258 KJ/kg,ufg_100Kpa=2088.7 KJ/kg,vg_100Kpa=1.6940 m^3/kg\n",
      " here vfg_100Kpa= in m^3/kg= 1.69\n",
      "so v1= in m^3/kg= 0.85\n",
      "and volume of vessel(V) in m^3= 42.38\n",
      "enthalpy at 1,h1=hf_100Kpa+x1*hfg_100Kpa in KJ/kg 1546.46\n",
      "internal energy in the beginning=U1=m1*u1 in KJ 146171.0\n",
      "let the mass of dry steam added be m,final specific volume inside vessel,v2\n",
      "v2=vf_1000Kpa+x2*vfg_1000Kpa\n",
      "at 2000 Kpa,from steam table,\n",
      "vg_2000Kpa=0.09963 m^3/kg,ug_2000Kpa=2600.3 KJ/kg,hg_2000Kpa=2799.5 KJ/kg\n",
      "total mass inside vessel=mass of steam at2000 Kpa+mass of mixture at 100 Kpa\n",
      "V/v2=V/vg_2000Kpa+V/v1\n",
      "so v2 in m^3/kg= 0.09\n",
      "here v2=vf_1000Kpa+x2*vfg_1000Kpa in m^3/kg\n",
      "at 1000 Kpa from steam table,\n",
      "hf_1000Kpa=762.81 KJ/kg,hfg_1000Kpa=2015.3 KJ/kg,vf_1000Kpa=0.001127 m^3/kg,vg_1000Kpa=0.19444 m^3/kg\n",
      "here vfg_1000Kpa= in m^3/kg= 0.19\n",
      "so x2= 0.46\n",
      "for adiabatic mixing,(100+m)*h2=100*h1+m*hg_2000Kpa\n",
      "so mass of dry steam at 2000 Kpa to be added(m)in kg\n",
      "m=(100*(h1-h2))/(h2-hg_2000Kpa)= 11.97\n",
      "quality of final mixture x2= 0.46\n"
     ]
    }
   ],
   "source": [
    "#cal of quality of final mixture\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.14, Page:181  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 14\")\n",
    "x1=0.5;#dryness fraction \n",
    "m1=100;#mass of steam in kg\n",
    "v1=0.8475;#\n",
    "print(\"it is constant volume process\")\n",
    "print(\"volume of vessel(V)=mass of vapour * specific volume of vapour\")\n",
    "print(\"initial specific volume,v1\")\n",
    "print(\"v1=vf_100Kpa+x1*vfg_100 in m^3/kg\")\n",
    "print(\"at 100 Kpa from steam table;\")\n",
    "print(\"hf_100Kpa=417.46 KJ/kg,uf_100Kpa=417.36 KJ/kg,vf_100Kpa=0.001043 m^3/kg,hfg_100Kpa=2258 KJ/kg,ufg_100Kpa=2088.7 KJ/kg,vg_100Kpa=1.6940 m^3/kg\")\n",
    "hf_100Kpa=417.46;\n",
    "uf_100Kpa=417.36;\n",
    "vf_100Kpa=0.001043;\n",
    "hfg_100Kpa=2258;\n",
    "ufg_100Kpa=2088.7;\n",
    "vg_100Kpa=1.6940;\n",
    "vfg_100Kpa=vg_100Kpa-vf_100Kpa\n",
    "print(\" here vfg_100Kpa= in m^3/kg=\"),round(vfg_100Kpa,2)\n",
    "v1=vf_100Kpa+x1*vfg_100Kpa\n",
    "print(\"so v1= in m^3/kg=\"),round(v1,2)\n",
    "V=m1*x1*v1\n",
    "print(\"and volume of vessel(V) in m^3=\"),round(V,2)\n",
    "h1=hf_100Kpa+x1*hfg_100Kpa\n",
    "print(\"enthalpy at 1,h1=hf_100Kpa+x1*hfg_100Kpa in KJ/kg\"),round(h1,2)\n",
    "U1=m1*(uf_100Kpa+x1*ufg_100Kpa)\n",
    "print(\"internal energy in the beginning=U1=m1*u1 in KJ\"),round(U1,2)\n",
    "print(\"let the mass of dry steam added be m,final specific volume inside vessel,v2\")\n",
    "print(\"v2=vf_1000Kpa+x2*vfg_1000Kpa\")\n",
    "print(\"at 2000 Kpa,from steam table,\")\n",
    "print(\"vg_2000Kpa=0.09963 m^3/kg,ug_2000Kpa=2600.3 KJ/kg,hg_2000Kpa=2799.5 KJ/kg\")\n",
    "vg_2000Kpa=0.09963;\n",
    "ug_2000Kpa=2600.3;\n",
    "hg_2000Kpa=2799.5;\n",
    "print(\"total mass inside vessel=mass of steam at2000 Kpa+mass of mixture at 100 Kpa\")\n",
    "print(\"V/v2=V/vg_2000Kpa+V/v1\")\n",
    "v2=1/((1/vg_2000Kpa)+(1/v1))\n",
    "print(\"so v2 in m^3/kg=\"),round(v2,2)\n",
    "print(\"here v2=vf_1000Kpa+x2*vfg_1000Kpa in m^3/kg\")\n",
    "print(\"at 1000 Kpa from steam table,\")\n",
    "print(\"hf_1000Kpa=762.81 KJ/kg,hfg_1000Kpa=2015.3 KJ/kg,vf_1000Kpa=0.001127 m^3/kg,vg_1000Kpa=0.19444 m^3/kg\")\n",
    "hf_1000Kpa=762.81;\n",
    "hfg_1000Kpa=2015.3;\n",
    "vf_1000Kpa=0.001127;\n",
    "vg_1000Kpa=0.19444;\n",
    "vfg_1000Kpa=vg_1000Kpa-vf_1000Kpa\n",
    "print(\"here vfg_1000Kpa= in m^3/kg=\"),round(vfg_1000Kpa,2)\n",
    "x2=(v2-vf_1000Kpa)/vfg_1000Kpa\n",
    "print(\"so x2=\"),round(x2,2)\n",
    "print(\"for adiabatic mixing,(100+m)*h2=100*h1+m*hg_2000Kpa\")\n",
    "print(\"so mass of dry steam at 2000 Kpa to be added(m)in kg\")\n",
    "m=(100*(h1-(hf_1000Kpa+x2*hfg_1000Kpa)))/((hf_1000Kpa+x2*hfg_1000Kpa)-hg_2000Kpa)\n",
    "print(\"m=(100*(h1-h2))/(h2-hg_2000Kpa)=\"),round(m,2)\n",
    "print(\"quality of final mixture x2=\"),round(x2,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.15;pg no: 183"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.15, Page:183  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 15\n",
      "from dalton law of partial pressure the total pressure inside condenser will be sum of partial pressures of vapour and liquid inside.\n",
      "condenser pressure(p_condenser) in Kpa= 7.3\n",
      "partial pressure of steam corresponding to35 degree celcius from steam table;\n",
      "p_steam=5.628 Kpa\n",
      "enthalpy corresponding to 35 degree celcius from steam table,\n",
      "hf=146.68 KJ/kg,hfg=2418.6 KJ/kg\n",
      "let quality of steam entering be x\n",
      "from energy balance;\n",
      "mw*(To-Ti)*4.18=m_cond*(hf+x*hfg-4.18*T_hotwell)\n",
      "so dryness fraction of steam entering(x)is given as\n",
      "x= 0.97\n"
     ]
    }
   ],
   "source": [
    "#cal of  dryness fraction of steam entering\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.15, Page:183  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 15\")\n",
    "p_vaccum=71.5;#recorded condenser vaccum in cm of mercury\n",
    "p_barometer=76.8;#barometer reading in cm of mercury\n",
    "T_cond=35;#temperature of condensation in degree celcius\n",
    "T_hotwell=27.6;#temperature of hot well in degree celcius\n",
    "m_cond=1930;#mass of condensate per hour\n",
    "m_w=62000;#mass of cooling water per hour\n",
    "Ti=8.51;#initial temperature in degree celcius\n",
    "To=26.24;#outlet temperature in degree celcius\n",
    "print(\"from dalton law of partial pressure the total pressure inside condenser will be sum of partial pressures of vapour and liquid inside.\")\n",
    "p_condenser=(p_barometer-p_vaccum)*101.325/73.55\n",
    "print(\"condenser pressure(p_condenser) in Kpa=\"),round(p_condenser,2)\n",
    "print(\"partial pressure of steam corresponding to35 degree celcius from steam table;\")\n",
    "print(\"p_steam=5.628 Kpa\")\n",
    "p_steam=5.628;#partial pressure of steam\n",
    "print(\"enthalpy corresponding to 35 degree celcius from steam table,\")\n",
    "print(\"hf=146.68 KJ/kg,hfg=2418.6 KJ/kg\")\n",
    "hf=146.68;\n",
    "hfg=2418.6;\n",
    "print(\"let quality of steam entering be x\")\n",
    "print(\"from energy balance;\")\n",
    "print(\"mw*(To-Ti)*4.18=m_cond*(hf+x*hfg-4.18*T_hotwell)\")\n",
    "print(\"so dryness fraction of steam entering(x)is given as\")\n",
    "x=(((m_w*(To-Ti)*4.18)/m_cond)-hf+4.18*T_hotwell)/hfg\n",
    "print(\"x=\"),round(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.16;pg no: 184"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.16, Page:184  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 16\n",
      "heating of water in vessel as described above is a constant pressure heating. pressure at which process occurs(p)=F/A+P_atm in Kpa\n",
      "area(A) in m^2= 0.03\n",
      "so p1=in Kpa= 419.61\n",
      "now at 419.61 Kpa,hf=612.1 KJ/kg,hfg=2128.7 KJ/kg,vg=0.4435 m^3/kg\n",
      "volume of water contained(V1) in m^3= 0.001\n",
      "mass of water(m) in kg= 0.63\n",
      "heat supplied shall cause sensible heating and latent heating\n",
      "hence,enthalpy change=heat supplied\n",
      "Q=((hf+x*hfg)-(4.18*T)*m)\n",
      "so dryness fraction of steam produced(x)can be calculated as\n",
      "so x= 0.46\n",
      "internal energy of water(U1)in KJ,initially\n",
      "U1= 393.69\n",
      "finally,internal energy of wet steam(U2)in KJ\n",
      "U2=m*h2-p2*V2\n",
      "here V2 in m^3= 0.13\n",
      "hence U2= 940.68\n",
      "hence change in internal energy(U) in KJ= 547.21\n",
      "work done(W) in KJ= 53.01\n"
     ]
    }
   ],
   "source": [
    "#cal of change in internal energy and work done\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "import math\n",
    "print\"Example 6.16, Page:184  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 16\")\n",
    "F=10;#force applied externally upon piston in KN\n",
    "d=.2;#diameter in m\n",
    "h=0.02;#depth to which water filled in m \n",
    "P_atm=101.3;#atmospheric pressure in Kpa\n",
    "rho=1000;#density of water in kg/m^3\n",
    "Q=600;#heat supplied to water in KJ\n",
    "T=150;#temperature of water in degree celcius\n",
    "print(\"heating of water in vessel as described above is a constant pressure heating. pressure at which process occurs(p)=F/A+P_atm in Kpa\")\n",
    "A=math.pi*d**2/4\n",
    "print(\"area(A) in m^2=\"),round(A,2)\n",
    "p1=F/A+P_atm\n",
    "print(\"so p1=in Kpa=\"),round(p1,2)\n",
    "print(\"now at 419.61 Kpa,hf=612.1 KJ/kg,hfg=2128.7 KJ/kg,vg=0.4435 m^3/kg\")\n",
    "hf=612.1;\n",
    "hfg=2128.7;\n",
    "vg=0.4435;\n",
    "V1=math.pi*d**2*h/4\n",
    "print(\"volume of water contained(V1) in m^3=\"),round(V1,3)\n",
    "m=V1*rho\n",
    "print(\"mass of water(m) in kg=\"),round(m,2)\n",
    "print(\"heat supplied shall cause sensible heating and latent heating\")\n",
    "print(\"hence,enthalpy change=heat supplied\")\n",
    "print(\"Q=((hf+x*hfg)-(4.18*T)*m)\")\n",
    "print(\"so dryness fraction of steam produced(x)can be calculated as\")\n",
    "x=((Q/m)+4.18*T-hf)/hfg\n",
    "print(\"so x=\"),round(x,2)\n",
    "print(\"internal energy of water(U1)in KJ,initially\")\n",
    "h1=4.18*T;#enthalpy of water in KJ/kg\n",
    "U1=m*h1-p1*V1\n",
    "print(\"U1=\"),round(U1,2)\n",
    "U1=393.5;#approx.\n",
    "print(\"finally,internal energy of wet steam(U2)in KJ\")\n",
    "print(\"U2=m*h2-p2*V2\")\n",
    "V2=m*x*vg\n",
    "print(\"here V2 in m^3=\"),round(V2,2)\n",
    "p2=p1;#constant pressure process\n",
    "U2=(m*(hf+x*hfg))-p2*V2\n",
    "print(\"hence U2=\"),round(U2,2)\n",
    "U2=940.71;#approx.\n",
    "U=U2-U1\n",
    "print(\"hence change in internal energy(U) in KJ=\"),round(U,2)\n",
    "p=p1;\n",
    "W=p*(V2-V1)\n",
    "print(\"work done(W) in KJ=\"),round(W,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.17;pg no: 185"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.17, Page:185  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 17\n",
      "consider throttling calorimeter alone,\n",
      "degree of superheat(T_sup)in degree celcius\n",
      "T_sup= 18.2\n",
      "enthalpy of superheated steam(h_sup)in KJ/kg\n",
      "h_sup= 2711.99\n",
      "at 120 degree celcius,h=2673.95 KJ/kg from steam table\n",
      "now enthalpy before throttling = enthalpy after throttling\n",
      "hf+x2*hfg=h_sup\n",
      "here at 1.47 Mpa,hf=840.513 KJ/kg,hfg=1951.02 KJ/kg from steam table\n",
      "so x2= 0.96\n",
      "for seperating calorimeter alone,dryness fraction,x1=(ms-mw)/ms\n",
      "overall dryness fraction(x)= 0.91\n"
     ]
    }
   ],
   "source": [
    "#cal of overall dryness fraction\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.17, Page:185  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 17\")\n",
    "ms=40;#mass of steam in kg\n",
    "mw=2.2;#mass of water in kg\n",
    "p1=1.47;#pressure before throttling in Mpa\n",
    "T2=120;#temperature after throttling in degree celcius\n",
    "p2=107.88;#pressure after throttling in Kpa\n",
    "Cp_sup=2.09;#specific heat of superheated steam in KJ/kg K\n",
    "print(\"consider throttling calorimeter alone,\")\n",
    "print(\"degree of superheat(T_sup)in degree celcius\")\n",
    "T_sup=T2-101.8\n",
    "print(\"T_sup=\"),round(T_sup,2)\n",
    "print(\"enthalpy of superheated steam(h_sup)in KJ/kg\")\n",
    "h=2673.95;\n",
    "h_sup=h+T_sup*Cp_sup\n",
    "print(\"h_sup=\"),round(h_sup,2)\n",
    "print(\"at 120 degree celcius,h=2673.95 KJ/kg from steam table\")\n",
    "print(\"now enthalpy before throttling = enthalpy after throttling\")\n",
    "print(\"hf+x2*hfg=h_sup\")\n",
    "print(\"here at 1.47 Mpa,hf=840.513 KJ/kg,hfg=1951.02 KJ/kg from steam table\")\n",
    "hf=840.513;\n",
    "hfg=1951.02;\n",
    "x2=(h_sup-hf)/hfg\n",
    "print(\"so x2=\"),round(x2,2)\n",
    "print(\"for seperating calorimeter alone,dryness fraction,x1=(ms-mw)/ms\")\n",
    "x1=(ms-mw)/ms\n",
    "x=x1*x2\n",
    "print(\"overall dryness fraction(x)=\"),round(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.18;pg no: 185"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.18, Page:185  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 18\n",
      "here heat addition to part B shall cause evaporation of water and subsequently the rise in pressure.\n",
      "final,part B has dry steam at 15 bar.In order to have equilibrium the part A shall also have pressure of 15 bar.thus heat added\n",
      "Q in KJ= 200.0\n",
      "final enthalpy of dry steam at 15 bar,h2=hg_15bar\n",
      "h2=2792.2 KJ/kg from steam table\n",
      "let initial dryness fraction be x1,initial enthalpy,\n",
      "h1=hf_10bar+x1*hfg_10bar.........eq1\n",
      "here at 10 bar,hf_10bar=762.83 KJ/kg,hfg_10bar=2015.3 KJ/kg from steam table\n",
      "also heat balance yields,\n",
      "h1+Q=h2\n",
      "so h1=h2-Q in KJ/kg\n",
      "so by eq 1=>x1= 0.91\n",
      "heat added(Q)in KJ= 200.0\n",
      "and initial quality(x1) 0.91\n"
     ]
    }
   ],
   "source": [
    "#cal of heat added and initial quality\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.18, Page:185  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 18\")\n",
    "v=0.4;#volume of air in part A and part B in m^3\n",
    "p1=10*10**5;#initial pressure of steam in pa\n",
    "p2=15*10**5;#final pressure of steam in pa\n",
    "print(\"here heat addition to part B shall cause evaporation of water and subsequently the rise in pressure.\")\n",
    "print(\"final,part B has dry steam at 15 bar.In order to have equilibrium the part A shall also have pressure of 15 bar.thus heat added\")\n",
    "Q=v*(p2-p1)/1000\n",
    "print(\"Q in KJ=\"),round(Q,2)\n",
    "print(\"final enthalpy of dry steam at 15 bar,h2=hg_15bar\")\n",
    "print(\"h2=2792.2 KJ/kg from steam table\")\n",
    "h2=2792.2;\n",
    "print(\"let initial dryness fraction be x1,initial enthalpy,\")\n",
    "print(\"h1=hf_10bar+x1*hfg_10bar.........eq1\")\n",
    "print(\"here at 10 bar,hf_10bar=762.83 KJ/kg,hfg_10bar=2015.3 KJ/kg from steam table\")\n",
    "hf_10bar=762.83;\n",
    "hfg_10bar=2015.3;\n",
    "print(\"also heat balance yields,\")\n",
    "print(\"h1+Q=h2\")\n",
    "print(\"so h1=h2-Q in KJ/kg\")\n",
    "h1=h2-Q\n",
    "x1=(h1-hf_10bar)/hfg_10bar\n",
    "print(\"so by eq 1=>x1=\"),round(x1,2)\n",
    "print(\"heat added(Q)in KJ=\"),round(Q,2)\n",
    "print(\"and initial quality(x1)\"),round(x1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.19;pg no: 186"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.19, Page:186  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 19\n",
      "from steam table,vg=1.2455 m^3/kg,hf=457.99 KJ/kg,hfg=2232.3 KJ/kg\n",
      "specific volume of wet steam in cylinder,v1 in m^3/kg= 0.75\n",
      "dryness fraction of initial steam(x1)= 0.6\n",
      "initial enthalpy of wet steam,h1 in KJ/kg= 1801.83\n",
      "at 400 degree celcius specific volume of steam,v2 in m^3/kg= 1.55\n",
      "for specific volume of 1.55 m^3/kg at 400 degree celcius the pressure can be seen from the steam table.From superheated steam tables the specific volume of 1.55 m^3/kg lies between the pressure of 0.10 Mpa (specific volume 3.103 m^3/kg at400 degree celcius)and 0.20 Mpa(specific volume 1.5493 m^3/kg at 400 degree celcius)\n",
      "actual pressure can be obtained by interpolation\n",
      "p2=0.20 MPa(approx.)\n",
      "saturation temperature at 0.20 Mpa(t)=120.23 degree celcius from steam table\n",
      "finally the degree of superheat(T_sup)in K\n",
      "T_sup=T-t\n",
      "final enthalpy of steam at 0.20 Mpa and 400 degree celcius,h2=3276.6 KJ/kg from steam table\n",
      "heat added during process(deltaQ)in KJ\n",
      "deltaQ=m*(h2-h1)\n",
      "internal energy of initial wet steam,u1=uf+x1*ufg in KJ/kg\n",
      "here at 1.4 bar,from steam table,uf=457.84 KJ/kg,ufg=2059.34 KJ/kg\n",
      "internal energy of final state,u2=u at 0.2 Mpa,400 degree celcius\n",
      "u2=2966.7 KJ/kg\n",
      "change in internal energy(deltaU)in KJ\n",
      "deltaU= 3807.41\n",
      "form first law of thermodynamics,work done(deltaW)in KJ\n",
      "deltaW=deltaQ-deltaU 616.88\n",
      "so heat transfer(deltaQ)in KJ 4424.3\n",
      "and work transfer(deltaW)in KJ 616.88\n",
      "NOTE=>In book value of u1=1707.86 KJ/kg is calculated wrong taking x1=0.607,hence correct value of u1 using x1=0.602 is 1697.5627 KJ/kg\n",
      "and corresponding values of heat transfer= 4424.2962 KJ and work transfer=616.88424 KJ.\n"
     ]
    }
   ],
   "source": [
    "#cal of heat and work transfer \n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.19, Page:186  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 19\")\n",
    "m=3;#mass of wet steam in kg\n",
    "p=1.4;#pressure of wet steam in bar\n",
    "V1=2.25;#initial volume in m^3\n",
    "V2=4.65;#final volume in m^3\n",
    "T=400;#temperature of steam in degreee celcius\n",
    "print(\"from steam table,vg=1.2455 m^3/kg,hf=457.99 KJ/kg,hfg=2232.3 KJ/kg\")\n",
    "vg=1.2455;\n",
    "hf=457.99;\n",
    "hfg=2232.3;\n",
    "v1=V1/m\n",
    "print(\"specific volume of wet steam in cylinder,v1 in m^3/kg=\"),round(v1,2)\n",
    "x1=v1/vg\n",
    "print(\"dryness fraction of initial steam(x1)=\"),round(x1,2)\n",
    "x1=0.602;#approx.\n",
    "h1=hf+x1*hfg\n",
    "print(\"initial enthalpy of wet steam,h1 in KJ/kg=\"),round(h1,2)\n",
    "v2=V2/m\n",
    "print(\"at 400 degree celcius specific volume of steam,v2 in m^3/kg=\"),round(v2,2)\n",
    "print(\"for specific volume of 1.55 m^3/kg at 400 degree celcius the pressure can be seen from the steam table.From superheated steam tables the specific volume of 1.55 m^3/kg lies between the pressure of 0.10 Mpa (specific volume 3.103 m^3/kg at400 degree celcius)and 0.20 Mpa(specific volume 1.5493 m^3/kg at 400 degree celcius)\")\n",
    "print(\"actual pressure can be obtained by interpolation\")\n",
    "p2=.1+((0.20-0.10)/(1.5493-3.103))*(1.55-3.103)\n",
    "print(\"p2=0.20 MPa(approx.)\")\n",
    "p2=0.20;\n",
    "print(\"saturation temperature at 0.20 Mpa(t)=120.23 degree celcius from steam table\")\n",
    "t=120.23;\n",
    "print(\"finally the degree of superheat(T_sup)in K\")\n",
    "print(\"T_sup=T-t\")\n",
    "T_sup=T-t\n",
    "print(\"final enthalpy of steam at 0.20 Mpa and 400 degree celcius,h2=3276.6 KJ/kg from steam table\")\n",
    "h2=3276.6;\n",
    "print(\"heat added during process(deltaQ)in KJ\")\n",
    "print(\"deltaQ=m*(h2-h1)\")\n",
    "deltaQ=m*(h2-h1)\n",
    "print(\"internal energy of initial wet steam,u1=uf+x1*ufg in KJ/kg\")\n",
    "print(\"here at 1.4 bar,from steam table,uf=457.84 KJ/kg,ufg=2059.34 KJ/kg\")\n",
    "uf=457.84;\n",
    "ufg=2059.34;\n",
    "u1=uf+x1*ufg\n",
    "print(\"internal energy of final state,u2=u at 0.2 Mpa,400 degree celcius\")\n",
    "print(\"u2=2966.7 KJ/kg\")\n",
    "u2=2966.7;\n",
    "print(\"change in internal energy(deltaU)in KJ\")\n",
    "deltaU=m*(u2-u1)\n",
    "print(\"deltaU=\"),round(deltaU,2)\n",
    "print(\"form first law of thermodynamics,work done(deltaW)in KJ\")\n",
    "deltaW=deltaQ-deltaU\n",
    "print(\"deltaW=deltaQ-deltaU\"),round(deltaW,2)\n",
    "print(\"so heat transfer(deltaQ)in KJ\"),round(deltaQ,2)\n",
    "print(\"and work transfer(deltaW)in KJ\"),round(deltaW,2)\n",
    "print(\"NOTE=>In book value of u1=1707.86 KJ/kg is calculated wrong taking x1=0.607,hence correct value of u1 using x1=0.602 is 1697.5627 KJ/kg\")\n",
    "print(\"and corresponding values of heat transfer= 4424.2962 KJ and work transfer=616.88424 KJ.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 6.20;pg no: 187"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 6.20, Page:187  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 6 Example 20\n",
      "here throttling process is occuring therefore enthalpy before and after expansion remains same.Let initial and final states be given by 1 and 2.Initial enthalpy,from steam table.\n",
      "at 500 degree celcius,h1_10bar_500oc=3478.5 KJ/kg,s1_10bar_500oc=7.7622 KJ/kg K,v1_10bar_500oc=0.3541 m^3/kg\n",
      "finally pressure becomes 1 bar so finally enthalpy(h2) at this pressure(of 1 bar)is also 3478.5 KJ/kg which lies between superheat temperature of 400 degree celcius and 500 degree celcius at 1 bar.Let temperature be T2,\n",
      "h_1bar_400oc=3278.2 KJ/kg,h_1bar_500oc=3488.1 KJ/kg from steam table\n",
      "h2=h_1bar_400oc+(h_1bar_500oc-h_1bar_400oc)*(T2-400)/(500-400)\n",
      "so final temperature(T2)in K\n",
      "T2= 495.43\n",
      "entropy for final state(s2)in KJ/kg K\n",
      "s2= 8.82\n",
      "here from steam table,s_1bar_400oc=8.5435 KJ/kg K,s_1bar_500oc=8.8342 KJ/kg K\n",
      "so change in entropy(deltaS)in KJ/kg K\n",
      "deltaS= 1.06\n",
      "final specific volume,v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400)) in m^3/kg\n",
      "here from steam table,v_1bar_500oc=3.565 m^3/kg,v_1bar_400oc=3.103 m^3/kg\n",
      "percentage of vessel volume initially occupied by steam(V)= 9.99\n"
     ]
    }
   ],
   "source": [
    "#cal of percentage of vessel volume initially occupied by steam\n",
    "#intiation of all variables\n",
    "# Chapter 6\n",
    "print\"Example 6.20, Page:187  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 6 Example 20\")\n",
    "print(\"here throttling process is occuring therefore enthalpy before and after expansion remains same.Let initial and final states be given by 1 and 2.Initial enthalpy,from steam table.\")\n",
    "print(\"at 500 degree celcius,h1_10bar_500oc=3478.5 KJ/kg,s1_10bar_500oc=7.7622 KJ/kg K,v1_10bar_500oc=0.3541 m^3/kg\")\n",
    "h1_10bar_500oc=3478.5;\n",
    "s1_10bar_500oc=7.7622;\n",
    "v1_10bar_500oc=0.3541;\n",
    "print(\"finally pressure becomes 1 bar so finally enthalpy(h2) at this pressure(of 1 bar)is also 3478.5 KJ/kg which lies between superheat temperature of 400 degree celcius and 500 degree celcius at 1 bar.Let temperature be T2,\")\n",
    "h2=h1_10bar_500oc;\n",
    "print(\"h_1bar_400oc=3278.2 KJ/kg,h_1bar_500oc=3488.1 KJ/kg from steam table\")\n",
    "h_1bar_400oc=3278.2;\n",
    "h_1bar_500oc=3488.1;\n",
    "print(\"h2=h_1bar_400oc+(h_1bar_500oc-h_1bar_400oc)*(T2-400)/(500-400)\")\n",
    "print(\"so final temperature(T2)in K\")\n",
    "T2=400+((h2-h_1bar_400oc)*(500-400)/(h_1bar_500oc-h_1bar_400oc))\n",
    "print(\"T2=\"),round(T2,2)\n",
    "print(\"entropy for final state(s2)in KJ/kg K\")\n",
    "s_1bar_400oc=8.5435;\n",
    "s_1bar_500oc=8.8342;\n",
    "s2=s_1bar_400oc+((s_1bar_500oc-s_1bar_400oc)*(495.43-400)/(500-400))\n",
    "print(\"s2=\"),round(s2,2)\n",
    "print(\"here from steam table,s_1bar_400oc=8.5435 KJ/kg K,s_1bar_500oc=8.8342 KJ/kg K\")\n",
    "print(\"so change in entropy(deltaS)in KJ/kg K\")\n",
    "deltaS=s2-s1_10bar_500oc\n",
    "print(\"deltaS=\"),round(deltaS,2)\n",
    "print(\"final specific volume,v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400)) in m^3/kg\")\n",
    "print(\"here from steam table,v_1bar_500oc=3.565 m^3/kg,v_1bar_400oc=3.103 m^3/kg\")\n",
    "v_1bar_500oc=3.565;\n",
    "v_1bar_400oc=3.103;\n",
    "v2=v_1bar_400oc+((v_1bar_500oc-v_1bar_400oc)*(95.43)/(500-400))\n",
    "V=v1_10bar_500oc*100/v2\n",
    "print(\"percentage of vessel volume initially occupied by steam(V)=\"),round(V,2)\n",
    "\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
}