summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics/ch2.ipynb
blob: b7849ef3d2c556657cbf26d9d0f02f7126fbed0e (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:76568d79b614fc85568c92855047632dbe19f5ec7540dbd287268967c3318f2b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Review of basic concepts"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.1  Page No : 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "R = 8.314;\t\t\t #universal gas constant in J/molK\n",
      "t1 = 300.;\t\t\t #initial temperature of gas in K\n",
      "p1 = 0.1;\t\t\t #initial pressure of the gas in MPa\n",
      "p2 = 0.5;\t\t\t #pressure of gas after heating in MPa\n",
      "p3 = 0.1;\t\t\t #pressure of gas after expansion in MPa\n",
      "n = 1.; \t\t\t #number of moles of gas in mole\n",
      "\n",
      "# Calculations\n",
      "w1 = 0*n;       \t\t\t # Calculations of work done by the gas during heating in kJ (since dv = 0)\n",
      "t2 = t1*(p2/p1);\t\t\t # Calculations of temperature of gas after heating in K\n",
      "t3 = t2;\t\t        \t # Calculations of temperature of gas after expansion in K (constant temperature expansion)\n",
      "volume2 = p2/p3;\t\t\t # Calculations of  ratio of volume of gas after expansion to the volume of gas after heating (no unit)\n",
      "w2 = (R*t2*math.log(volume2)*n)/1000\n",
      "volume3 =  t3/t1;\t\t\n",
      "w3 = (R*t1*(1-volume3)*n)/1000\n",
      "work_net = w1+w2+w3;\t\t\t # Calculations of net work done by the gas for the process in kJ\n",
      "\n",
      "# Results\n",
      "print ' Work done during heating process:Work from 1-2 =  %d kJ '%(w1);\n",
      "print ' Work done during constant temperature expansion: Work from 2-3 =  %.3f kJ '%(w2);\n",
      "print ' Work done during constant pressure compression: Work from 3-1 =  %.3f kJ '%(w3);\n",
      "print ' Net work done by the gas during the process =  %.3f kJ '%(work_net);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Work done during heating process:Work from 1-2 =  0 kJ \n",
        " Work done during constant temperature expansion: Work from 2-3 =  20.071 kJ \n",
        " Work done during constant pressure compression: Work from 3-1 =  -9.977 kJ \n",
        " Net work done by the gas during the process =  10.095 kJ \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.2  Page No : 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "v1 = 0.1;\t\t\t #volume of gas initially present in the cylinder in m**3\n",
      "p1 = 0.1;\t\t\t #initial pressure of gas in MPa\n",
      "p_atm = 0.1;\t\t #atmospheric pressure acting on the piston in MPa\n",
      "v2 = 0.3;\t\t\t #volume of gas after heating in m**3\n",
      "p2 = 0.6;\t\t\t #pressure of gas after heating in MPa\n",
      "\n",
      "# Calculations\n",
      "work = ((p1+p2)*(v2-v1)*10**6)/(2*1000);\t\t\t # Calculations of work done by the gas in kJ \n",
      "\n",
      "# Results\n",
      "print ' The work done by the gas  =  %d kJ'%(work);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The work done by the gas  =  70 kJ\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}