summaryrefslogtreecommitdiff
path: root/555/CH4/EX4.5/5.sce
blob: e5260bc6e13071befa1085cc69b2df70c4521a66 (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
// Implementation of example 4.5
// Basic and Applied Thermodynamics by P.K.Nag

clc
clear

//pressure in initial state 'p1',Volume in initial state 'V1',
//pressure in final state 'p2',Volume in final state 'V2',
//internal energy U = (34 + 3.15 * p * V); 
p1 = 170; //kPa
V1 = 0.03; //m3
p2 = 400; //kPa
V2 = 0.06; //m3
dU = 3.15 * (p2 *V2 - p1 * V1); //kJ


A = [1 V1;1 V2];
C = [p1;p2];
B = inv(A)*C;
a = round(B(1,1));
b = round(B(2,1));

function p = pdV(V)
  p = a+b*V;
endfunction
//Work transfer involved during the process 'W12'
W12 = intg(V1,V2,pdV); //kJ
printf("Work done by the system, W12 = %0.2f kJ\n\n",W12);
//Heat transfer 'Q12'
Q12 = dU + W12;
printf("Heat flow into the system during the process, Q12 = %0.2f kJ",Q12);
// end