summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics_by_O_Singh/3-First_Law_Of_Thermodynamics.ipynb
blob: 0f99525596e44901222daa01cbfa5099ee582861 (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
{
"cells": [
 {
		   "cell_type": "markdown",
	   "metadata": {},
	   "source": [
       "# Chapter 3: First Law Of Thermodynamics"
	   ]
	},
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.10: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_10.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 10')\n",
"n=500;//total number of persons\n",
"q=50;//heat requirement per person in kcal/hr\n",
"h1=80;//enthalpy of hot water enter in pipe in kcal/kg\n",
"h2=45;//enthalpy of hot water leaves the pipe in kcal/kg\n",
"g=9.81;//acceleartion due to gravity in m/s^2\n",
"deltaz=10;//difference in elevation of inlet and exit pipe in m\n",
"disp('above problem can be solved using steady flow energy equations upon hot water flow')\n",
"disp('Q+m1*(h1+C1^2/2+g*z1)=W+m2*(h2+C2^2/2+g*z2)')\n",
"disp('here total heat to be supplied(Q)in kcal/hr')\n",
"Q=n*q\n",
"disp('so heat lost by water(-ve),Q=-25000 kcal/hr')\n",
"Q=-25000//heat loss by water in kcal/hr\n",
"disp('there shall be no work interaction and change in kinetic energy,so,steady flow energy equation shall be,')\n",
"disp('Q+m*(h1+g*z1)=m*(h2+g*z2)')\n",
"disp('so water circulation rate(m)in kg/hr')\n",
"disp('so m=Q*10^3*4.18/(g*deltaz-(h1-h2)*10^3*4.18')\n",
"m=Q*10^3*4.18/(g*deltaz-(h1-h2)*10^3*4.18)\n",
"disp('water circulation rate(m)in kg/min')\n",
"m=m/60"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.11: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_11.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 11')\n",
"v1=50;//velocity of steam entering injector in m/s\n",
"v2=25;//velocity of mixture leave injector in m/s\n",
"h1=720;//enthalpy of steam entering injector in kcal/kg\n",
"h2=24.6;//enthalpy of water entering injector in kcal/kg\n",
"h3=100;//enthalpy of steam leaving injector in kcal/kg\n",
"h4=100;//enthalpy of water leaving injector in kcal/kg\n",
"deltaz=2;//depth from axis of injector in m\n",
"q=12;//heat loss from injector to surrounding through injector\n",
"g=9.81;//acceleration due to gravity in m/s^2\n",
"disp('let mass of steam to be supplied per kg of water lifted be(m) kg.applying law of energy conservation upon steam injector,for unit mass of water lifted')\n",
"disp('energy with steam entering + energy with water entering = energy with mixture leaving + heat loss to surrounding')\n",
"disp('m*(v1^2/2+h1*10^3*4.18)+h2*10^3*4.18+g*deltaz=(1+m)*(h3*10^3*4.18+v2^2/2)+m*q*10^3*4.18')\n",
"disp('so steam suppling rate(m)in kg/s per kg of water')\n",
"disp('m=((h3*10^3*4.18+v2^2/2)-(h2*10^3*4.18+g*deltaz))/((v1^2/2+h1*10^3*4.18)-(h3*10^3*4.18+v2^2/2)-(q*10^3*4.18))')\n",
"m=((h3*10^3*4.18+v2^2/2)-(h2*10^3*4.18+g*deltaz))/((v1^2/2+h1*10^3*4.18)-(h3*10^3*4.18+v2^2/2)-(q*10^3*4.18))\n",
"disp('NOTE=>here enthalpy of steam entering injector(h1)should be taken 720 kcal/kg instead of 72 kcal/kg otherwise the steam supplying rate comes wrong.')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.12: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_12.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 12')\n",
"p=1.013*10^5;//atmospheric pressure in pa\n",
"deltav=0.4;//change in volume in m^3\n",
"disp('here let us assume that the pressure is always equal to atmospheric presure as ballon is flexible,inelastic and unstressed and no work is done for stretching ballon during its filling figure shows the boundary of system before and after filling ballon by firm line and dotted line respectively.')\n",
"disp('displacement work, W=(p.dv)cylinder+(p.dv)ballon')\n",
"disp('(p.dv)cylinder=0,as cylinder is rigid')\n",
"disp('so work done by system upon atmosphere(W)in KJ, W=(p*deltav)/1000')\n",
"W=(p*deltav)/1000\n",
"disp('and work done by atmosphere=-40.52 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.13: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_13.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 13')\n",
"Qadd=5000;//heat supplied in boiler in J/s\n",
"disp('work done by turbine(Wt)in J/s is 25% of heat added i.e')\n",
"disp('Wt=.25*Qadd')\n",
"Wt=.25*Qadd\n",
"disp('heat rejected by condensor(Qrejected)in J/s is 75% of head added i.e')\n",
"disp('Qrejected=.75*Qadd')\n",
"Qrejected=.75*Qadd\n",
"disp('and feed water pump work(Wp)in J/s is 0.2% of heat added i.e')\n",
"disp('Wp=(-)0.002*Qadd')\n",
"Wp=0.002*Qadd\n",
"disp('capacity of generator(W)=(Wt-Wp)/1000 in Kw')\n",
"W=(Wt-Wp)/1000\n",
"\n",
"\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.14: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_14.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 14')\n",
"T1=(27+273);//ambient temperature in K\n",
"T2=(750+273);//temperature of heated air inside heat exchanger in K\n",
"T3=(600+273);//temperature of hot air leaves turbine in K\n",
"T4=(500+273);//temperature at which air leaves nozzle in K\n",
"Cp=1.005;//specific heat at constant pressure in KJ/kg K\n",
"C2=50;//velocity of hot air enter into gas turbine in m/s\n",
"C3=60;//velocity of air leaving turbine enters a nozzle in m/s\n",
"disp('in heat exchanger upon applying S.F.E.E with assumption of no change in kinetic energy,no work interaction,no change in potential energy,for unit mass flow rate of air,')\n",
"disp('h1+Q1_2=h2')\n",
"disp('Q1_2=h2-h1')\n",
"disp('so heat transfer to air in heat exchanger(Q1_2)in KJ')\n",
"disp('Q1_2=Cp*(T2-T1)')\n",
"Q1_2=Cp*(T2-T1)\n",
"disp('in gas turbine let us use S.F.E.E,assuming no change in potential energy,for unit mass flow rate of air')\n",
"disp('h2+C2^2/2=h3+C3^2/2+Wt')\n",
"disp('Wt=(h2-h3)+(C2^2-C3^2)/2')\n",
"disp('so power output from turbine(Wt)in KJ/s')\n",
"disp('Wt=Cp*(T2-T3)+(C2^2-C3^2)*10^-3/2')\n",
"Wt=Cp*(T2-T3)+(C2^2-C3^2)*10^-3/2\n",
"disp('applying S.F.E.E upon nozzle assuming no change in potential energy,no work and heat interactions,for unit mass flow rate,')\n",
"disp('h3+C=h4+C4^2/2')\n",
"disp('C4^2/2=(h3-h4)+C3^2/2')\n",
"disp('velocity at exit of nozzle(C4)in m/s')\n",
"disp('C4=sqrt(2*(Cp*(T3-T4)+C3^2*10^-3/2))')\n",
"C4=sqrt(2*(Cp*(T3-T4)+C3^2*10^-3/2))"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.15: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_15.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 15')\n",
"T1=400;//initial temperature of gas in K\n",
"R=8.314;//gas constant in \n",
"disp('for constant pressure heating,say state changes from 1 to 2')\n",
"disp('Wa=p1*dv')\n",
"disp('Wa=p1*(v2-v1)')\n",
"disp('it is given that v2=2v1')\n",
"disp('so Wa=p1*v1=R*T1')\n",
"disp('for subsequent expansion at constant temperature say state from 2 to 3')\n",
"disp('also given that v3/v1=6,v3/v2=3')\n",
"disp('so work=Wb=p*dv')\n",
"disp('on solving above we get Wb=R*T2*ln(v3/v2)=R*T2*log3')\n",
"disp('temperature at 2 can be given by perfect gas consideration as,')\n",
"disp('T2/T1=v2/v1')\n",
"disp('or T2=2*T1')\n",
"disp('now total work done by air W=Wa+Wb=R*T1+R*T2*log3=R*T1+2*R*T1*log3 in KJ')\n",
"disp('so W=R*T1+2*R*T1*log(3)in KJ')\n",
"W=R*T1+2*R*T1*log(3)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.16: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_16.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 16')\n",
"Pi=0.5*10^6;//initial pressure of gas in pa\n",
"Vi=0.5;//initial volume of gas in m^3\n",
"Pf=1*10^6;//final pressure of gas in pa\n",
"disp('NOTE=>this question contain derivation which cannot be solve using scilab so we use the result of derivation to proceed further ')\n",
"disp('we get W=(Vf-Vi)*((Pi+Pf)/2)')\n",
"disp('also final volume of gas in m^3 is Vf=3*Vi') \n",
"Vf=3*Vi\n",
"disp('now work done by gas(W)in J')\n",
" W=(Vf-Vi)*((Pi+Pf)/2)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.17: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_17.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 17')\n",
"Cp_H2=14.307;//specific heat of H2 at constant pressure in KJ/kg K\n",
"R_H2=4.1240;//gas constant for H2 in KJ/kg K\n",
"Cp_N2=1.039;//specific heat of N2 at constant pressure in KJ/kg K\n",
"R_N2=0.2968;//gas constant for N2 in KJ/kg K\n",
"T1=(27+273);//ambient temperature in K\n",
"v1=0.5;//initial volume of H2 in m^3\n",
"p1=0.5*10^6;//initial pressure of H2 in pa \n",
"v2=0.25;//final volume of H2 in m^3 \n",
"p2=1.324*10^6;//final pressure of H2 in pa\n",
"disp('with the heating of N2 it will get expanded while H2 gets compressed simultaneously.compression of H2 in insulated chamber may be considered of adiabatic type.')\n",
"disp('adiabatic index of compression of H2 can be obtained as,')\n",
"disp('Cp_H2=R_H2*(y_H2/(y_H2-1))')\n",
"disp('y_H2=Cp_H2/(Cp_H2-R_H2)')\n",
"y_H2=Cp_H2/(Cp_H2-R_H2)\n",
"disp('adiabatic index of expansion for N2,Cp_N2=R_N2*(y_N2/(y_N2-1))')\n",
"disp('y_N2=Cp_N2/(Cp_N2-R_N2)')\n",
"y_N2=Cp_N2/(Cp_N2-R_N2)\n",
"disp('i>for hydrogen,p1*v1^y=p2*v2^y')\n",
"disp('so final pressure of H2(p2)in pa')\n",
"disp('p2=p1*(v1/v2)^y_H2')\n",
"p2=p1*(v1/v2)^y_H2\n",
"disp('ii>since partition remains in equlibrium throughout hence no work is done by partition.it is  a case similar to free expansion ')\n",
"disp('partition work=0')\n",
"disp('iii>work done upon H2(W_H2)in J,')\n",
"disp('W_H2=(p1*v1-p2*v2)/(y_H2-1)')\n",
"W_H2=(p1*v1-p2*v2)/(y_H2-1)\n",
"disp('work done upon H2(W_H2)=-2*10^5 J')\n",
"disp('so work done by N2(W_N2)=2*10^5 J ')\n",
"W_N2=2*10^5;//work done by N2 in J\n",
"disp('iv>heat added to N2 can be obtained using  first law of thermodynamics as')\n",
"disp('Q_N2=deltaU_N2+W_N2=>Q_N2=m*Cv_N2*(T2-T1)+W_N2')\n",
"disp('final temperature of N2 can be obtained considering it as perfect gas')\n",
"disp('therefore, T2=(p2*v2*T1)/(p1*v1)')\n",
"disp('here p2=final pressure of N2 which will be equal to that of H2 as the partition is free and frictionless')\n",
"disp('p2=1.324*10^6 pa,v2=0.75 m^3')\n",
"v2=0.75;//final volume of N2 in m^3\n",
"disp('so now final temperature of N2(T2)in K')\n",
"T2=(p2*v2*T1)/(p1*v1)\n",
"T2=1191.6;//T2 approx. equal to 1191.6 K\n",
"disp('mass of N2(m)in kg=(p1*v1)/(R_N2*T1)')\n",
"m=(p1*v1)/(R_N2*1000*T1)\n",
"m=2.8;//m approx equal to 2.8 kg\n",
"disp('specific heat at constant volume(Cv_N2)in KJ/kg K,Cv_N2=Cp_N2-R_N2')\n",
"Cv_N2=Cp_N2-R_N2\n",
"disp('heat added to N2,(Q_N2)in KJ')\n",
"disp('Q_N2=(m*Cv_N2*1000*(T2-T1))+W_N2')\n",
"Q_N2=((m*Cv_N2*1000*(T2-T1))+W_N2)/1000\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.18: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_18.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 18')\n",
"p1=0.5*10^6;//initial pressure of air in pa\n",
"p2=1.013*10^5;//atmospheric pressure in pa\n",
"v1=2;//initial volume of air in m^3\n",
"v2=v1;//final volume of air in m^3\n",
"T1=375;//initial temperature of air in K\n",
"Cp_air=1.003;//specific heat at consatnt pressure in KJ/kg K\n",
"Cv_air=0.716;//specific heat at consatnt volume in KJ/kg K\n",
"R_air=0.287;//gas constant in KJ/kg K\n",
"y=1.4;//expansion constant for air\n",
"disp('let initial states and final states of air inside cylinder be given by m1,p1,v1,,T1 and m2,p2,v2,T2 respectively.it is case of emptying of cylinder')\n",
"disp('initial mass of air(m1)in kg')\n",
"disp('m1=(p1*v1)/(R_air*1000*T1)')\n",
"m1=(p1*v1)/(R_air*1000*T1)\n",
"disp('for adiabatic expansion during release of air through valve from 0.5 Mpa to atmospheric pressure')\n",
"disp('T2=T1*(p2/p1)^((y-1)/y)in K')\n",
"T2=T1*(p2/p1)^((y-1)/y)\n",
"disp('final mass of air left in tank(m2)in kg')\n",
"disp('m2=(p2*v2)/(R_air*1000*T2)')\n",
"m2=(p2*v2)/(R_air*1000*T2)\n",
"disp('writing down energy equation for unsteady flow system')\n",
"disp('(m1-m2)*(h2+C^2/2)=(m1*u1-m2*u2)')\n",
"disp('or (m1-m2)*C^2/2=(m1*u1-m2*u2)-(m1-m2)*h2')\n",
"disp('kinetic energy available for running turbine(W)in KJ')\n",
"disp('W=(m1*u1-m2*u2)-(m1-m2)*h2=(m1*Cv_air*1000*T1-m2*Cv_air*1000*T2)-(m1-m2)*Cp_air*1000*T2')\n",
"disp('W=(m1*Cv_air*1000*T1-m2*Cv_air*1000*T2)-(m1-m2)*Cp_air*1000*T2')\n",
"W=((m1*Cv_air*1000*T1-m2*Cv_air*1000*T2)-(m1-m2)*Cp_air*1000*T2)/1000\n",
"disp('amount of work available=482.66 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.19: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_19.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 19')\n",
"p1=0.5*10^6;//initial pressure of air in pa\n",
"v1=0.5;//initial volume of air in m^3\n",
"T1=(27+273);//initial temperature of air in K\n",
"p2=1*10^6;//final pressure of air in pa\n",
"v2=0.5;//final volume of air in m^3\n",
"T2=500;//final temperature of air in K\n",
"R=8314;//gas constant in J/kg K\n",
"Cv=0.716;//specific heat at constant volume in KJ/kg K\n",
"disp('using perfect gas equation for the two chambers having initial states  as 1 and 2 and final states as 3')\n",
"disp('n1=(p1*v1)/(R*T1)')\n",
"n1=(p1*v1)/(R*T1)\n",
"disp('now n2=(p2*v2)/(R*T2)')\n",
"n2=(p2*v2)/(R*T2)\n",
"disp('for tank being insulated and rigid we can assume,deltaU=0,W=0,Q=0,so writing deltaU,')\n",
"deltaU=0;//change in internal energy\n",
"disp('deltaU=n1*Cv*(T3-T1)+n2*Cv*(T3-T2)')\n",
"disp('final temperature of gas(T3)in K')\n",
"disp('T3=(deltaU+Cv*(n1*T1+n2*T2))/(Cv*(n1+n2))')\n",
"T3=(deltaU+Cv*(n1*T1+n2*T2))/(Cv*(n1+n2))\n",
"disp('using perfect gas equation for final mixture,')\n",
"disp('final pressure of gas(p3)in Mpa')\n",
"disp('p3=((n1+n2)*R*T3)/(v1+v2)')\n",
"p3=((n1+n2)*R*T3)/(v1+v2)\n",
"disp('so final pressure and temperature =0.75 Mpa and 409.11 K')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.1: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_1.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 1')\n",
"p=689;//pressure of gas in cylinder in kpa\n",
"v1=0.04;//initial volume of fluid in m^3\n",
"v2=0.045;//final volume of fluid in m^3\n",
"W_paddle=-4.88;//paddle work done on the system in KJ\n",
"disp('a> work done on piston(W_piston)in KJ can be obtained as')\n",
"disp('W_piston=pdv')\n",
"function y = f(v), y=p, endfunction\n",
"W_piston=intg(v1,v2,f) \n",
"disp('b> paddle work done on the system(W_paddle)=-4.88 KJ')\n",
"disp('net work done of system(W_net)in KJ')\n",
"disp('W_net=W_piston+W_paddle')\n",
"W_net=W_piston+W_paddle\n",
"disp('so work done on system(W_net)=1.435 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.20: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_20.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 20')\n",
"v1=0;//initial volume of air inside bottle in m^3\n",
"v2=0.5;//final volume of air inside bottle in m^3\n",
"p=1.0135*10^5;//atmospheric pressure in pa\n",
"disp('displacement work,W=p*(v1-v2)in N.m')\n",
"W=p*(v1-v2)\n",
"disp('so heat transfer(Q)in N.m')\n",
"disp('Q=-W')\n",
"Q=-W"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.21: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_21.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 21')\n",
"p1=35*10^5;//initial pressure of air in pa\n",
"v1=0.3;//initial volume of air in m^3\n",
"T1=(40+273);//initial temperature of air in K\n",
"p2=1*10^5;//final pressure of air in pa\n",
"v2=0.3;//final volume of air in m^3\n",
"y=1.4;//expansion constant\n",
"R=0.287;//gas constant in KJ/kg K\n",
"Cv=0.718;//specific heat at constant volume in KJ/kg K\n",
"Cp=1.005;//specific heat at constant pressure in KJ/kg K\n",
"disp('here turbogenerator is fed with compressed air from a compressed air bottle.pressure inside bottle gradually decreases from 35 bar to 1 bar.expansion from 35 bar to 1 bar occurs isentropically.thus,for the initial and final states of pressure,volume,temperatureand mass inside bottle being given as p1,v1,T1 & m1 and p2,v2,T2 & m2 respectively.it is transient flow process similar to emptying of the bottle.')\n",
"disp('(p2/p1)^((y-1)/y)=(T2/T1)')\n",
"disp('final temperature of air(T2)in K')\n",
"disp('T2=T1*(p2/p1)^((y-1)/y)')\n",
"T2=T1*(p2/p1)^((y-1)/y)\n",
"disp('by perfect gas law,initial mass in bottle(m1)in kg')\n",
"disp('m1=(p1*v1)/(R*1000*T1)')\n",
"m1=(p1*v1)/(R*1000*T1)\n",
"disp('final mass in bottle(m2)in kg')\n",
"disp('m2=(p2*v2)/(R*1000*T2)')\n",
"m2=(p2*v2)/(R*1000*T2)\n",
"disp('energy available for running turbo generator or work(W)in KJ')\n",
"disp('W+(m1-m2)*h2=m1*u1-m2*u2')\n",
"disp('W=(m1*Cv*T1-m2*Cv*T2)-(m1-m2)*Cp*T2')\n",
"W=(m1*Cv*T1-m2*Cv*T2)-(m1-m2)*Cp*T2\n",
"disp('this is maximum work that can be had from the emptying of compresssed air bottle between given pressure limits')\n",
"disp('turbogenerator actual output(P1)=5 KJ/s')\n",
"P1=5;//turbogenerator actual output in KJ/s\n",
"disp('input to turbogenerator(P2)in KJ/s')\n",
"P2=P1/0.6\n",
"disp('time duration for which turbogenerator can be run(deltat)in seconds')\n",
"disp('deltat=W/P2')\n",
"deltat=W/P2\n",
"disp('duration=160 seconds approx.')\n",
"\n",
"\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.22: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_22.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 22')\n",
"p1=1.5*10^5;//initial pressure of air in pa\n",
"T1=(77+273);//initial temperature of air in K\n",
"p2=7.5*10^5;//final pressure of air in pa\n",
"n=1.2;//expansion constant for process 1-2\n",
"R=0.287;//gas constant in KJ/kg K\n",
"m=3;//mass of air in kg\n",
"disp('different states as described in the problem are denoted as 1,2and 3 and shown on p-V diagram')\n",
"disp('process 1-2 is polytropic process with index 1.2')\n",
"disp('(T2/T1)=(p2/p1)^((n-1)/n)')\n",
"disp('final temperature of air(T2)in K')\n",
"disp('T2=T1*(p2/p1)^((n-1)/n)')\n",
"T2=T1*((p2/p1)^((n-1)/n))\n",
"disp('at state 1,p1*v1=m*R*T1')\n",
"disp('initial volume of air(v1)in m^3')\n",
"disp('v1=(m*R*1000*T1)/p1')\n",
"v1=(m*R*1000*T1)/p1\n",
"disp('final volume of air(v2)in m^3')\n",
"disp('for process 1-2,v2=((p1*v1^n)/p2)^(1/n)')\n",
"v2=((p1*v1^n)/p2)^(1/n)\n",
"disp('for process 2-3 is constant pressure process so p2*v2/T2=p3*v3/T3')\n",
"disp('v3=v2*T3/T2 in m^3')\n",
"disp('here process 3-1 is isothermal process so T1=T3')\n",
"T3=T1;//process 3-1 is isothermal\n",
"v3=v2*T3/T2\n",
"disp('during process 1-2 the compression work(W1_2)in KJ')\n",
"disp('W1_2=(m*R*(T2-T1)/(1-n))')\n",
"W1_2=(m*R*(T2-T1)/(1-n))\n",
"disp('work during process 2-3(W2_3)in KJ,')\n",
"disp('W2_3=p2*(v3-v2)/1000')\n",
"W2_3=p2*(v3-v2)/1000\n",
"disp('work during process 3-1(W3_1)in KJ')\n",
"disp('W3_1=p3*v3*log(v1/v3)/1000')\n",
"p3=p2;//pressure is constant for process 2-3\n",
"W3_1=p3*v3*log(v1/v3)/1000\n",
"disp('net work done(W_net)in KJ')\n",
"disp('W_net=W1_2+W2_3+W3_1')\n",
"W_net=W1_2+W2_3+W3_1\n",
"disp('net work=-71.27 KJ')\n",
"disp('here -ve workshows work done upon the system.since it is cycle,so')\n",
"disp('W_net=Q_net')\n",
"disp('phi dW=phi dQ=-71.27 KJ')\n",
"disp('heat transferred from system=71.27 KJ')\n",
"\n",
"\n",
"\n",
"\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.23: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_23.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 23')\n",
"Cp=1.005;//specific heat at constant pressure in KJ/kg K\n",
"Cv=0.718;//specific heat at constant volume in KJ/kg K\n",
"y=1.4;//expansion constant \n",
"p1=40*10^5;//initial temperature of air in pa\n",
"v1=0.15;//initial volume of air in m^3\n",
"T1=(27+273);//initial temperature of air in K\n",
"p2=2*10^5;//final temperature of air in pa\n",
"v2=0.15;//final volume of air in m^3\n",
"R=0.287;//gas constant in KJ/kg K\n",
"disp('initial mass of air in bottle(m1)in kg ')\n",
"disp('m1=(p1*v1)/(R*1000*T1)')\n",
"m1=(p1*v1)/(R*1000*T1)\n",
"disp('now final temperature(T2)in K')\n",
"disp('T2=T1*(p2/p1)^((y-1)/y)')\n",
"T2=T1*(p2/p1)^((y-1)/y)\n",
"T2=127.36;//take T2=127.36 approx.\n",
"disp('final mass of air in bottle(m2)in kg')\n",
"disp('m2=(p2*v2)/(R*1000*T2)')\n",
"m2=(p2*v2)/(R*1000*T2)\n",
"m2=0.821;//take m2=0.821 approx.\n",
"disp('energy available for running of turbine due to emptying of bottle(W)in KJ')\n",
"disp('W=(m1*Cv*T1-m2*Cv*T2)-(m1-m2)*Cp*T2')\n",
"W=(m1*Cv*T1-m2*Cv*T2)-(m1-m2)*Cp*T2\n",
"disp('work available from turbine=639.09 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.2: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_2.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 2')\n",
"m=0.5;//mass of gas in kg\n",
"u1=26.6;//internal energy of gas at 200 degree celcius\n",
"u2=37.8;//internal energy of gas at 400 degree celcius\n",
"W=0;//work done by vessel in KJ\n",
"disp('as the vessel is rigid therefore work done shall be zero')\n",
"disp('W=0')\n",
"disp('from first law of thermodynamics,heat required(Q)in KJ')\n",
"disp('Q=U2-U1+W=Q=m(u2-u1)+W')\n",
"Q=m*(u2-u1)+W\n",
"disp('so heat required =5.6 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.3: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_3.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 3')\n",
"m=50;//rate at which carbon dioxide passing through heat exchanger in kg/hr\n",
"T2=800;//initial temperature of carbon dioxide in degree celcius\n",
"T1=50;//final temperature of carbon dioxide in degree celcius\n",
"Cp=1.08;//specific heat at constant pressure in KJ/kg K\n",
"disp('by steady flow energy equation')\n",
"disp('q+h1+C1^2/2+g*z1=h2+C2^2/2+g*z2+w')\n",
"disp('let us assume changes in kinetic and potential energy is negligible,during flow the work interaction shall be zero')\n",
"disp('q=h2-h1')\n",
"disp('rate of heat removal(Q)in KJ/hr')\n",
"disp('Q=m(h2-h1)=m*Cp*(T2-T1)')\n",
"Q=m*Cp*(T2-T1)\n",
"disp('heat should be removed at the rate of 40500 KJ/hr')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.4: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_4.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 4')\n",
"v=0.78;//volume of cylinder in m^3\n",
"p=101.325;//atmospheric pressure in kPa\n",
"disp('total work done by the air at atmospheric pressure of 101.325 kPa')\n",
"disp('W=(pdv)cylinder+(pdv)air')\n",
"disp('0+p*(delta v)')\n",
"disp('work done by air(W)=-p*v in KJ')\n",
"W=-p*v\n",
"disp('so work done by surrounding on system =79.03 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.5: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_5.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 5')\n",
"m=5;//mass of gas in kg\n",
"p1=1*10^3;//initial pressure of gas in KPa\n",
"V1=0.5;//initial volume of gas in m^3\n",
"p2=0.5*10^3;//final pressure of gas in KPa\n",
"n=1.3;//expansion constant\n",
"disp('given p*v^1.3=constant')\n",
"disp('assuming expansion to be quasi-static,the work may be given as')\n",
"disp('W=m(p*dv)=(p2*V2-p1*V1)/(1-n)')\n",
"disp('from internal energy relation,change in specific internal energy')\n",
"disp('deltau=u2-u1=1.8*(p2*v2-p1*v1)in KJ/kg')\n",
"disp('total change,deltaU=1.8*m*(p2*v2-p1*v1)=1.8*(p2*V2-p1*V1)in KJ')\n",
"disp('using p1*V1^1.3=p2*V2^1.3')\n",
"disp('V2=V1*(p1/p2)^(1/1.3)in m^3')\n",
"V2=V1*(p1/p2)^(1/1.3)\n",
"disp('take V2=.852 m^3')\n",
"V2=0.852;//final volume of gas in m^3\n",
"disp('so deltaU in KJ')\n",
"deltaU=1.8*(p2*V2-p1*V1)\n",
"disp('and W in KJ')\n",
"W=(p2*V2-p1*V1)/(1-n)\n",
"disp('from first law')\n",
"disp('deltaQ=deltaU+W in KJ')\n",
"deltaQ=deltaU+W\n",
"disp('heat interaction=113.5 KJ')\n",
"disp('work interaction=246.7 KJ')\n",
"disp('change in internal energy=-113.2 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.6: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_6.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 6')\n",
"p1=1;//initial pressure of gas in MPa\n",
"v1=0.05;//initial volume of gas in m^3\n",
"p2=2;//final pressure of gas in MPa\n",
"n=1.4;//expansion constant\n",
"disp('final state volume(v2)in m^3')\n",
"disp('v2=((p1/p2)^(1/1.4))*v1')\n",
"v2=((p1/p2)^(1/1.4))*v1\n",
"disp('take v2=0.03 m^3')\n",
"v2=0.03;//final volume of gas in m^3\n",
"disp('now internal energy of gas is given by U=7.5*p*v-425')\n",
"disp('change in internal energy(deltaU)in KJ')\n",
"disp('deltaU=U2-U1=7.5*p2*v2-7.5*p1*v1')\n",
"disp('deltaU=7.5*10^3*(p2*v2-p1*v1)')\n",
"deltaU=7.5*10^3*(p2*v2-p1*v1)\n",
"disp('for quasi-static process')\n",
"disp('work(W) in KJ,W=p*dv')\n",
"disp('W=(p2*v2-p1*v1)/(1-n)')\n",
"W=((p2*v2-p1*v1)/(1-n))*10^3\n",
"disp('from first law of thermodynamics,')\n",
"disp('heat interaction(deltaQ)=deltaU+W')\n",
"deltaQ=deltaU+W\n",
"disp('heat=50 KJ')\n",
"disp('work=25 KJ(-ve)')\n",
"disp('internal energy change=75 KJ')\n",
"disp('if 180 KJ heat transfer takes place,then from 1st law,')\n",
"disp('deltaQ=deltaU+W')\n",
"disp('since end states remain same,therefore deltaU i.e change in internal energy remains unaltered.')\n",
"disp('W=180-75')\n",
"W=180-75\n",
"disp('W=105 KJ')"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.7: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_7.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 7')\n",
"M=16;//molecular weight of gas\n",
"p1=101.3;//initial pressure of gas in KPa\n",
"p2=600;//final pressure of gas in KPa\n",
"T1=(273+20);//initial temperature of gas in K\n",
"R1=8.3143*10^3;//universal gas constant in J/kg K\n",
"Cp=1.7;//specific heat at constant pressure in KJ/kg K\n",
"n=1.3;//expansion constant\n",
"T2=((p2/p1)^(n-1/n))\n",
"disp('characteristics gas constant(R)in J/kg K')\n",
"disp('R=R1/M')\n",
"R=R1/M\n",
"disp('take R=0.520,KJ/kg K')\n",
"R=0.520;//characteristics gas constant in KJ/kg K\n",
"disp('Cv=Cp-R,inKJ/kg K')\n",
"Cv=Cp-R\n",
"disp('y=Cp/Cv')\n",
"y=Cp/Cv\n",
"y=1.44;//ratio of specific heat at constant pressure to constant volume\n",
"disp('for polytropic process,v2=((p1/p2)^(1/n))*v1 in m^3')\n",
"disp('now,T2=T1*((p2/p1)^((n-1)/n)),in K')\n",
"T2=T1*((p2/p1)^((n-1)/n))\n",
"disp('work(W)in KJ/kg')\n",
"disp('W=R*((T1-T2)/(n-1))')\n",
"W=R*((T1-T2)/(n-1))\n",
"W=257.78034;//work done in KJ/kg\n",
"disp('for polytropic process,heat(Q)in KJ/K')\n",
"disp('Q=((y-n)/(y-1))*W')\n",
"Q=((y-n)/(y-1))*W\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.8: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_8.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 8')\n",
"T1=(627+273);//initial temperature of air in nozzle in K\n",
"T2=(27+273);//temperature at which air leaves nozzle in K\n",
"Cp=1.005*10^3;//specific heat at constant pressure in J/kg K\n",
"disp('applying steady flow energy equation with inlet and exit states as 1,2 with no heat and work interaction and no change in potential energy')\n",
"disp('h1+C1^2/2=h2+C2^2/2')\n",
"disp('given that C1=0,negligible inlet velocity')\n",
"disp('so C2=sqrt(2(h1-h2))=sqrt(2*Cp*(T1-T2))')\n",
"disp('exit velocity(C2)in m/s')\n",
"C2=sqrt(2*Cp*(T1-T2))\n",
"disp('so exit velocity=1098.2 m/s')\n",
""
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 3.9: Engineering_Thermodynamics_by_Onkar_Singh_Chapter_3_Example_9.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Display mode\n",
"mode(0);\n",
"// Display warning for floating point exception\n",
"ieee(1);\n",
"clear;\n",
"clc;\n",
"disp('Engineering Thermodynamics by Onkar Singh Chapter 3 Example 9')\n",
"W=-200;//shaft work in KJ/kg of air\n",
"deltah=100;//increase in enthalpy in KJ/kg of air\n",
"Q1=-90;//heat transferred to water in KJ/kg of air\n",
"disp('work interaction,W=-200 KJ/kg of air')\n",
"disp('increase in enthalpy of air=100 KJ/kg of air')\n",
"disp('total heat interaction,Q=heat transferred to water + heat transferred to atmosphere')\n",
"disp('writing steady flow energy equation on compressor,for unit mass of air entering at 1 and leaving at 2')\n",
"disp('h1+C1^2/2+g*z1+Q=h2+C2^2/2+g*z2+W')\n",
"disp('assuming no change in potential energy and kinetic energy')\n",
"disp('deltaK.E=deltaP.=0')\n",
"disp('total heat interaction(Q)in KJ/kg of air')\n",
"disp('Q=deltah+W')\n",
"Q=deltah+W\n",
"disp('Q=heat transferred to water + heat transferred to atmosphere=Q1+Q2')\n",
"disp('so heat transferred to atmosphere(Q2)in KJ/kg of air')\n",
"Q2=Q-Q1"
   ]
   }
],
"metadata": {
		  "kernelspec": {
		   "display_name": "Scilab",
		   "language": "scilab",
		   "name": "scilab"
		  },
		  "language_info": {
		   "file_extension": ".sce",
		   "help_links": [
			{
			 "text": "MetaKernel Magics",
			 "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
			}
		   ],
		   "mimetype": "text/x-octave",
		   "name": "scilab",
		   "version": "0.7.1"
		  }
		 },
		 "nbformat": 4,
		 "nbformat_minor": 0
}