summaryrefslogtreecommitdiff
path: root/Applied_Thermodynamics/Chapter4.ipynb
diff options
context:
space:
mode:
authorhardythe12014-08-13 11:41:01 +0530
committerhardythe12014-08-13 11:41:01 +0530
commit7e82f054d405211e1e8760524da8ad7c9fd75286 (patch)
tree1790cf5a7460b48582da6c35417a85f3a1389a81 /Applied_Thermodynamics/Chapter4.ipynb
parent98bff1c301dd3b8b14983037a8a483e3eae1796d (diff)
downloadPython-Textbook-Companions-7e82f054d405211e1e8760524da8ad7c9fd75286.tar.gz
Python-Textbook-Companions-7e82f054d405211e1e8760524da8ad7c9fd75286.tar.bz2
Python-Textbook-Companions-7e82f054d405211e1e8760524da8ad7c9fd75286.zip
adding book
Diffstat (limited to 'Applied_Thermodynamics/Chapter4.ipynb')
-rwxr-xr-xApplied_Thermodynamics/Chapter4.ipynb765
1 files changed, 765 insertions, 0 deletions
diff --git a/Applied_Thermodynamics/Chapter4.ipynb b/Applied_Thermodynamics/Chapter4.ipynb
new file mode 100755
index 00000000..bac8596d
--- /dev/null
+++ b/Applied_Thermodynamics/Chapter4.ipynb
@@ -0,0 +1,765 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e33e7b5760e325e5ce218821a1f69234bfd752dae7d88964f3e66dde5271fa8e"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 4: Second Law of Thermodynamics"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2, page no. 114"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 400+273.0 #Highest temperature(in K):\n",
+ "T2 = 15+273.0 #Lowest temperature(in K):\n",
+ "w = 200 #Work produced(in kJ):\n",
+ "\n",
+ "#Calculation:\n",
+ "Q1 = w/(1-T2/T1) #Heat to be supplied(in kJ): #Ratio of Q1 to Q2 is same as T1 to T2\n",
+ "#Results:\n",
+ "print \"Heat to be supplied: \",round(Q1,1),\"KJ\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Heat to be supplied: 349.6 KJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3, page no. 115"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ " \n",
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 42+273.0 #Upper temperature(in K):\n",
+ "T2 = 4+273.0 #Lower temperature(in K):\n",
+ "Q2 = 2.0 #Rate at which heat is extracted(in kJ/s):\n",
+ "\n",
+ "#Calculation:\n",
+ "Q1 = T1/T2*Q2 #Heat to be supplied(in kJ/s):\n",
+ "P = Q1-Q2 #Power required(in kW):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Power required for driving the refrigerator: \",round(P,3),\"KW\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Power required for driving the refrigerator: 0.274 KW\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4, page no. 115"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ " \n",
+ "#Variable Declaration: \n",
+ "T1 = 827+273.0 #Source temperature(in K):\n",
+ "T2 = 27+273.0 #Sink temperature(in K):\n",
+ "T3 = -13+273.0 #Temperature in the refrigerator(in K):\n",
+ "Q1 = 2000.0 #Heat input(in kJ):\n",
+ "W = 300.0 #Net work available(in kJ):\n",
+ "\n",
+ "#Calculation:\n",
+ "Q2 = Q1*T2/T1 #Rate at which heat is extracted(in kJ):\n",
+ "We = Q1-Q2 #Work in the engine(in kJ):\n",
+ "Wr = We-W #Work in the refrigerator(in kJ):\n",
+ "Q3 = Wr/(T2/T3-1) #Heat transferred to the refrigerant(in kJ):\n",
+ "Q4 = Q3+Wr #Heat transferred to reservoir by refrigerant(in kJ):\n",
+ "Wt = Q2+Q4 #Total heat transferred to low temperature reservoir(in kJ):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Heat transferred to refrigerant: \",round(Q3,2),\"KJ\"\n",
+ "print \"Total heat transferred to low temperature reservoir: \",round(Wt,2),\"KJ\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Heat transferred to refrigerant: 7504.55 KJ\n",
+ "Total heat transferred to low temperature reservoir: 9204.55 KJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5, page no. 116"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 25+273.15 #Temperature inside the house(in K):\n",
+ "T2 = -1+273.15 #Temperature outside the house(in K):\n",
+ "Q1 = 125.0 #Heating load(in MJ/h):\n",
+ "\n",
+ "#Calculation:\n",
+ "COP = 1/(1-T2/T1) #COP:\n",
+ "W = Q1/COP #Minimum power required(in MJ/h):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Minimum power required: \",round(W,2), \"MJ/h\"\n",
+ "print \"Minimum power required: \",round(W*10**3/3600,2), \"KW\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Minimum power required: 10.9 MJ/h\n",
+ "Minimum power required: 3.03 KW\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6, page no. 117"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = -15+273.16 #Inside temperature(in K):\n",
+ "T2 = 35+273 #Atmospheric temperature(in K):\n",
+ "Q2 = 140.8 #Heat to be extracted (in kW):\n",
+ "\n",
+ "#Calculation:\n",
+ "COP1 = 1/(T2/T1-1) #Carnot COP of plant:\n",
+ "COP = COP1/4 #Actual COP:\n",
+ "W = Q2/COP #Power required(in kW):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Power required: \",round(W,2),\"KW\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Power required: 108.73 KW\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7, page no. 117"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 1150+273.0 #Maximum temperature(in K):\n",
+ "T2 = 27+273.0 #Minimum temperature(in K):\n",
+ "\n",
+ "#Calculation:\n",
+ "n = 1-(T2/T1) #Efficiency:\n",
+ "\n",
+ "#Results:\n",
+ "print \"Efficiency: \",round(n*100,2),\"%\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Efficiency: 78.92 %\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8, page no. 117"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 27+273 #Maximum temperature(in K):\n",
+ "T2 = -8+273 #Minimum temperature(in K):\n",
+ "Q = 7.5/60 #Leakage(in kJ/s):\n",
+ "\n",
+ "#Calculation:\n",
+ "W = (T1-T2)*Q/T2 #Power required(in kW):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Power required: \" ,round(W,4),\"KW\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Power required: 0.0165 KW\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9, page no. 118"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "from sympy import *\n",
+ "from sympy import symbols,simplify,numer,denom,collect,Wild\n",
+ "from sympy.solvers import solve\n",
+ "\n",
+ "#Variable Declaration:\n",
+ "Tso = 1100 #Temperature of Source (K):\n",
+ "Ts = 300 #Temperature of Sink (K):\n",
+ "W1,Q1,T1,W2,Q2,T2,W3,Q3,T3 = symbols('W1,Q1,T1,W2,Q2,T2,W3,Q3,T3') #Creating symbolic Variables required:\n",
+ "p = Wild('p')\n",
+ "q = Wild('q')\n",
+ "\n",
+ "#Calculations:\n",
+ "HE1 = 1-T2/Tso #Engine 1 Efficiency:\n",
+ "Q1 = W1/HE1\n",
+ "Q2 = Q1 - W1 #Energy balance equation:\n",
+ "#W2byW1 = simplify((Q2*(1-(T3/T2)))/W1)\n",
+ "W2byW1 = (T2-T3)/(1100-T2)\n",
+ "EQ1 = 3*numer(W2byW1)-2*denom(W2byW1) #Creating EQ1 using above symbolic manipulation and given W1:W2 ratio of 3:2\n",
+ "HE2 = simplify(1 - T3/T2) #Engine 2 Efficiency:\n",
+ "Q2 = W2 + Q3 #Energy balance equation:\n",
+ "\n",
+ "\n",
+ "expr = W2*denom(HE2)-Q2*numer(HE2)\n",
+ "a = collect(simplify(expr),[W2,Q3]).match(-p*Q3+q)\n",
+ "\n",
+ "Q3 = a[q]/a[p]\n",
+ "HE3 = simplify(1-Ts/T3)\n",
+ "#W3byW2 = HE3*Q3/W2\n",
+ "W3byW2 = (T3/(T2-T3))*((T3-300)/T3)\n",
+ "EQ2 = 2*numer(W3byW2)-1*denom(W3byW2) #Creating EQ1 using above symbolic manipulation and given W2:W3 ratio of 2:1\n",
+ "Sol = solve([EQ1,EQ2],[T2,T3]) #Solving the two generated symbolic equations:\n",
+ "\n",
+ "#Results:\n",
+ "print \"Intermediate Temperature, T2: \",Sol[T2],\"K\"\n",
+ "print \"Intermediate Temperature, T3: \",round(Sol[T3],2),\"K\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Intermediate Temperature, T2: 700 K\n",
+ "Intermediate Temperature, T3: 433.33 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 10, page no. 119"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 800.0 #Temperature at which heat is receieved (in K):\n",
+ "T2 = 280.0 #Temperature maintained by the carnot engine(in K):\n",
+ "\n",
+ "#Calculation:\n",
+ "T = 2*T1*T2/(T1+T2) #Temperature at which heat is rejected(in K):\n",
+ "n = (T1-T)/T1 #Efficiency:\n",
+ "COP = T2/(T-T2) #COP of refrigerator:\n",
+ "\n",
+ "#Results:\n",
+ "print \"Efficiency: \",round(n,4)\n",
+ "print \"COP of refrigerator: \" ,round(COP,3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Efficiency: 0.4815\n",
+ "COP of refrigerator: 2.077\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 11, page no. 120"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "import math\n",
+ "#Variable Declaration: \n",
+ "n = 0.5 #Efficiency of carnot cycle:\n",
+ "m = 0.5 #Mass of air(in kg):\n",
+ "p2 = 7*10**5 #Initial pressure(in Pa):\n",
+ "v2 = 0.12 #Initial volume(in m**3):\n",
+ "Q23 = 40 #Heat transferred during the process 2-3(in kJ):\n",
+ "Cp = 1.008 #Specific heat at const pressure(in kJ/kg):\n",
+ "Cv = 0.721 #Specific heat at const volume(in kJ/kg):\n",
+ "Ra = 287 #Gas constant for air:\n",
+ "Q12 = 0 #Heat transfer in process 1-2(in kJ):\n",
+ "Q34 = 0 #Heat transfer in process 3-4(in kJ):\n",
+ "\n",
+ "#Calculation:\n",
+ "T2 = p2*v2/(m*Ra) #Maximum temperature of the cycle(in K):\n",
+ "T1 = T2/2 #Minimum temperature(in K):\n",
+ "v3 = v2*(math.e**(Q23/(m*Ra*10**(-3)*T2))) #Volume at state 3(in m**3):\n",
+ "r = Cp/Cv #Compression factor:\n",
+ "p1 = p2/((T2/T1)**(r/(r-1))) #Pressure at point 1(in Pa):\n",
+ "v1 = m*Ra*T1/p1 #Volume at point 1(in m**3):\n",
+ "T3 = T2 #Temperature at state 3(in K):\n",
+ "T4 = T1 #Temperature at state 4(in K):\n",
+ "W12 = -m*Cv*(T2-T1) #During process 1-2, work done(in kJ):\n",
+ "W23 = Q23 #Work done in process 2-3(in kJ):\n",
+ "W34 = -m*Cv*(T4-T3) #During process 3-4, work done(in kJ):\n",
+ "W41 = -W23 #During process 4-1, work done(in kJ):\n",
+ "Q41 = -Q23 #Heat transfer in process 4-1(in kJ):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Process Heat transfer Work interaction\"\n",
+ "print \" 1-2 \",Q12,\"KJ \",round(W12,2)\n",
+ "print \" 2-3 \",Q23,\"KJ \",W23\n",
+ "print \" 3-4 \",Q34,\"KJ \",round(W34,2)\n",
+ "print \" 4-1 \",Q41,\"KJ \",W41\n",
+ "print \"Maximum temperature of the cycle: \",round(T2,2),\"KJ\"\n",
+ "print \"Minimum temperature of the cycle: \",round(T1,2),\"KJ\"\n",
+ "print \"Volume at the end of the expansion:\",round(v3,4),\"m**3\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Process Heat transfer Work interaction\n",
+ " 1-2 0 KJ -105.51\n",
+ " 2-3 40 KJ 40\n",
+ " 3-4 0 KJ 105.51\n",
+ " 4-1 -40 KJ -40\n",
+ "Maximum temperature of the cycle: 585.37 KJ\n",
+ "Minimum temperature of the cycle: 292.68 KJ\n",
+ "Volume at the end of the expansion: 0.1932 m**3\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 12, page no. 122"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "Q1 = 5000 #Heat drawn from 400 K reservoir(in kJ):\n",
+ "W = 840 #Work output(in kJ):\n",
+ "\n",
+ "#Calculation:\n",
+ "Q2 = 3*(Q1/2-W) #Value of heat from heat engine(in kJ):\n",
+ "Q3 = Q1-W-Q2 #Value of heat to heat engine(in kJ):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Q2 =\",Q2,\"kJ from heat engine\"\n",
+ "print \"Q3 =\",-Q3,\"kJ to heat engine\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Q2 = 4980 kJ from heat engine\n",
+ "Q3 = 820 kJ to heat engine\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 13, page no. 123"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T3 = 3+273 #Temperature of the reservoir(in K):\n",
+ "T1 = 77+273 #Lower temperature limit(in K):\n",
+ "T2 = 1077+273 #Higher temperature limit(in K):\n",
+ "E = 100 #Energy supplied to the reservoir(in kJ/s):\n",
+ "\n",
+ "#Calculation:\n",
+ "n = 1-T1/T2 #Efficiency:\n",
+ "Q1 = 26.71 #Solving all the equations, we get: #It is given that Q2+Q4 = E #We get Q4 = 1.27*Q3\t\t\n",
+ "#COP for heat pump = Q4/(Q4-Q3) = T1/(T1-T3)\t\t\t\t#We get Q2 = 0.2593*Q1\t\t\t\t#n = 1-Q2/Q1\t\t\t\t\n",
+ "#Energy taken from the reservoir Q1 can be found by solving the simultaneous equations\n",
+ "\n",
+ "#Results:\n",
+ "print \"Energy taken from reservoir at 1077\u00baC: \",round(Q1,2),\"KJ\"\t\t\t\t#Results: "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Energy taken from reservoir at 1077\u00baC: 26.71 KJ\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 14, page no. 124"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "Qs = 2000.0 #Heat supplied(in kJ/s):\n",
+ "Tso = 1500 #Temperature of source(in K):\n",
+ "Tr = 15+273 #Temperature at which heat is rejected(in K):\n",
+ "Qt = 3000 #Total heat received(in kJ/s):\n",
+ "\n",
+ "#Calculation:\n",
+ "Qr = Qt-Qs #Heat rejected(in kJ/s):\n",
+ "Ts = Qt/(Qs/Tso+Qr/Tr) #Temperature of the sink(in K):\n",
+ "\n",
+ "#Results: \n",
+ "print \"Temperature of the sink: \",round(Ts,2),\"K\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature of the sink: 624.28 K\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 15, page no. 124"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ " \n",
+ "#Variable Declaration: \n",
+ "T1 = 500+273.0 #Maximum temperature(in K):\n",
+ "T2 = 200+273.0 #Minimum temperature(in K):\n",
+ "T3 = 450+273.0 #Temperature of the body(in K):\n",
+ "\n",
+ "#Calculation:\n",
+ "n = 1-T2/T1 #Efficiency:\n",
+ "r1 = n #Ratio of W to Q1:\n",
+ "COP = T3/(T3-T2) #COP of pump:\n",
+ "r2 = COP*2/3 #Ratio of Q3 to W:\n",
+ "r3 = r1*r2 #Ratio of Q3 to Q1:\n",
+ "\n",
+ "#Results:\n",
+ "print \"Ratio of heat rejected to body at 450C to the heat supplied by the reservoir: \",round(r3,4)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Ratio of heat rejected to body at 450C to the heat supplied by the reservoir: 0.7483\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17, page no. 126"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "from sympy import *\n",
+ "\n",
+ "#Variable Declaration:\n",
+ "W,Q1,Q2,Q3,T1,T2,T3 = symbols('W,Q1,Q2,Q3,T1,T2,T3') #Creating symbolic variables:\n",
+ "\n",
+ "#Calculations:\n",
+ "n = 1 - T3/T1 #Efficiency of heat engine:\n",
+ "COP = T2/(T3-T2) #COP of refrigerator:\n",
+ "r = 1/(n*COP) #Ratio of Q1:Q3 :\n",
+ "\n",
+ "#Results:\n",
+ "print \"Ratio of heat supplied from source to heat absorbed from cold body: \",(simplify(r))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Ratio of heat supplied from source to heat absorbed from cold body: "
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-T1*(T2 - T3)/(T2*(T1 - T3))\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 18, page no. 127"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Variable Declaration: \n",
+ "T1 = 900+273.0 #Maximum temperature(in K):\n",
+ "T2 = 50+273.0 #Minimum temperature(in K):\n",
+ "T3 = 50+273.0 #Temperature of the 3rd reservoir(in K):\n",
+ "T4 = 10+273.0 #Temperature of the 4th reservoir(in K):\n",
+ "Q3 = 15.0 #Heat picked up by Carnot cycle(in kW):\n",
+ "E = 25.0 #Energy required to run a machine(in kW):\n",
+ "\n",
+ "#Calculation:\n",
+ "n = 1-T2/T1 #Efficiency:\n",
+ "Q4 = Q3*T3/T4 #From the relation of COP:\n",
+ "Whp = Q4-Q3 #Work by heat pump(in kW):\n",
+ "Whe = Whp+E #Work in the heat engine(in kW):\n",
+ "Q1 = Whe/n #Heat from source at 1173 K(in kW):\n",
+ "Q2 = Q1-Whe #Heat rejected to the reservoir from engine 1(in kW):\n",
+ "Qt = Q2+Q4 #Total heat rejected to the reservoir(in kW):\n",
+ "\n",
+ "#Results:\n",
+ "print \"Heat rejected to the reservoir: \",round(Qt,3),\"KW\" \n",
+ "print \"Heat received from the highest temperature reservoir: \",round(Q1,3),\"KW\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Heat rejected to the reservoir: 27.426 KW\n",
+ "Heat received from the highest temperature reservoir: 37.426 KW\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 19, page no. 128"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ " \n",
+ "\n",
+ "#Variable Declaration: \n",
+ "v1 = 1.8 #Volume of 1st tank(in m**3):\n",
+ "v2 = 3.6 #Volume of 2nd tank(in m**3):\n",
+ "p1 = 12 #Initial pressure(in bar):\n",
+ "T1 = 40+273 #Initial temperature(in K):\n",
+ "R = 0.208 #Gas constant for argon(in kJ/kg.K):\n",
+ "\n",
+ "#Calculation:\n",
+ "pf = p1*v1/(v1+v2) #By gas law for final and initial state:\n",
+ "\n",
+ "#Results:\n",
+ "print \"Final pressure: \",round(pf),\"bar\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final pressure: 4.0 bar\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file