{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 1 - \"Introduction\"" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.1, Page number: 13" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "import math\n", "\n", "#Variables\n", "k=35; #Thermal Conductivity, [W/m*K]\n", "T1=110 # Temperature of front[C]\n", "T2=50; # Temperature of back,[C]\n", "A=0.4 #area of slab,[m**2]\n", "x=0.03; #Thickness of slab,[m]\n", "\n", "#Calculations\n", "q=-k*(T2-T1)/(1000*x); #formula for heat flux[KW/m^2]\n", "Q=q*A; #formula for heat transfer rate[KW]\n", "\n", "#Results\n", "print \"Heat flux is:\",q,\"KW/m^2\\n\"\n", "print \"Heat transfer rate is:\",Q,\"KW \\n\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Heat flux is: 70.0 KW/m^2\n", "\n", "Heat transfer rate is: 28.0 KW \n", "\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.2, Page number: 16" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "import math\n", "from sympy import solve,symbols\n", "\n", "#Variables\n", "x=symbols('x');\n", "k1=372; # Thermal Conductivity of slab,W/m*K\n", "x1=0.003; # Thickness of slab,m\n", "x2=0.002 # Thickness of steel,m\n", "k2=17; # Thermal Conductivity of steel,W/m*K\n", "T1=400; # Temperature on one side,C\n", "T2=100 #Temperature on other side,C\n", "\n", "#Calculations\n", "Tcu=solve(x+2*x*(k1/x1)*(x2/k2)-(T1-T2),x);\n", "#q=k1*(Tcu/x1)=k2*(Tss/x2);\n", "Tss = Tcu[0]*(k1/x1)*(x2/k2); # formula for temperature gradient in steel side\n", "Tcul=T1-Tss;\n", "Tcur=T2+Tss;\n", "q=k2*Tss/(1000*x2); # formula for heat conducted, kW\\m^2\n", "\n", "#Results\n", "print \"Temperature on left copper side is :\",round(Tcul,3),\"C\\n\"\n", "print \"Temperature on right copper side is :\",round(Tcur,3),\"C\\n\"\n", "print \"Heat conducted through the wall is :\",round(q,3),\"kW\\m^2\\n\"\n", "print \"Our initial approximation was accurate within a few percent.\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Temperature on left copper side is : 254.971 C\n", "\n", "Temperature on right copper side is : 245.029 C\n", "\n", "Heat conducted through the wall is : 1232.749 kW\\m^2\n", "\n", "Our initial approximation was accurate within a few percent.\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.3, Page number: 22" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "import math\n", "\n", "#Variables\n", "q1=6000; #Heat flux, W*m**-2\n", "T1=120; #Heater Temperature, C\n", "T2=70; #final Temperature of Heater, C\n", "q2=2000; #final heat flux, W*m**-2\n", "\n", "#Calculations\n", "h=q1/(T1-T2) #formula for average heat transfer cofficient\n", "Tnew=T2+q2/h; #formula for new Heater temperature, C\n", "\n", "#Results\n", "print \"Average Heat transfer coefficient is:\",h,\"W/(m^2*K)\\n\"\n", "print \"New Heater Temperature is:\",round(Tnew,3),\"C\\n\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Average Heat transfer coefficient is: 120.0 W/(m^2*K)\n", "\n", "New Heater Temperature is: 86.667 C\n", "\n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.4, Page number: 25" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "import math\n", "from numpy import array\n", "from numpy import linspace\n", "import matplotlib.pyplot as plt\n", "from pylab import *\n", "%matplotlib inline\n", "\n", "#Variables\n", "h=250; #Heat Transfer Coefficient, W/(m**2*K)\n", "k=45; #Thermal Conductivity, W/(m*K)\n", "c=180; #Heat Capacity, J/(kg*K)\n", "a=9300; #density, kg/m**3\n", "T1=200; #temperature, C\n", "D=0.001; #diameter of bead, m\n", "t1=linspace(0,5,50); #defining time interval of 0.1 seconds\n", "T=linspace(0,5,50);\n", "i=0;\n", "\n", "#Calculations\n", "while i<50:\n", " T[i]=T1-c*math.exp(-t1[i]/((a*c*D)/(6*h))); #Calculating temperature at each time in degree C\n", " i=i+1;\n", "\n", "plt.plot(t1,T);\n", "plt.xlabel(\"Time(in sec)\");\n", "plt.ylabel(\"Temperature(in degree C)\");\n", "plt.title(\"Thermocouple response to a hot gas flow\");\n", "plt.show();\n", "\n", "Bi = h*(D/2)/k; #biot no.\n", "\n", "#Results\n", "print \"The value of Biot no for this thermocouple is\",round(Bi,5);\n", "print \"Bi is <0.1 and hence the thermocouple could be considered as a lumped heat capacity system and the assumption taken is valid.\\n\"" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "ImportError", "evalue": "DLL load failed: %1 is not a valid Win32 application.", "output_type": "pyerr", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)", "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0m__future__\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mdivision\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mmath\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0marray\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 4\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mlinspace\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Users\\jaidev\\Anaconda\\lib\\site-packages\\numpy\\__init__.py\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 151\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mloader\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mpackages\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0moptions\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 152\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 153\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0madd_newdocs\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 154\u001b[0m \u001b[0m__all__\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;34m'add_newdocs'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'ModuleDeprecationWarning'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 155\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Users\\jaidev\\Anaconda\\lib\\site-packages\\numpy\\add_newdocs.py\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0m__future__\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mdivision\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mabsolute_import\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mprint_function\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlib\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0madd_newdoc\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;31m###############################################################################\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Users\\jaidev\\Anaconda\\lib\\site-packages\\numpy\\lib\\__init__.py\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mversion\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mversion\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0m__version__\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m\u001b[0mtype_check\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[1;33m*\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m\u001b[0mindex_tricks\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[1;33m*\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m\u001b[0mfunction_base\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[1;33m*\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Users\\jaidev\\Anaconda\\lib\\site-packages\\numpy\\lib\\type_check.py\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 9\u001b[0m 'common_type']\n\u001b[0;32m 10\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 11\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnumeric\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0m_nx\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 12\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnumeric\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0masarray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0masanyarray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0marray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0misnan\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[0mobj2sctype\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mzeros\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;32mC:\\Users\\jaidev\\Anaconda\\lib\\site-packages\\numpy\\core\\__init__.py\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mnumpy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mversion\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mversion\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0m__version__\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mmultiarray\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 7\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mumath\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0m_internal\u001b[0m \u001b[1;31m# for freeze programs\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", "\u001b[1;31mImportError\u001b[0m: DLL load failed: %1 is not a valid Win32 application." ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.5, Page number: 32" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "import math\n", "from sympy import solve,symbols\n", "\n", "#Variables\n", "x=symbols('x');\n", "T1=293; #Temperature of air around thermocouple, K\n", "T2=373; #Wall temperature, K\n", "h=75; #Average Heat Transfer Coefficient, W/(m**2*K)\n", "s=5.67*10**-8; #stefan Boltzman constant, W/(m**2*K**4)\n", "\n", "#Calculations\n", "x=solve((h*(x-T1)+s*(x**4-T2**4)),x);\t #Calculating Thermocouple Temperature, K\n", "y=x[1]-273;\t\t\t\t #Thermocouple Temperature, C\n", "\n", "#Results\n", "print \"Thermocouple Temperature is :\",round(y,3),\"C\\n\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Thermocouple Temperature is : 28.395 C\n", "\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.6, Page number: 34" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from __future__ import division\n", "import math\n", "from sympy import solve,symbols\n", "\n", "#Variables\n", "x=symbols('x');\n", "e=0.4; #emissivity\n", "T1=293; #Temperature of air around Thermocouple, K\n", "T2=273; #wall Temperature, K\n", "h=75; #Average Heat Transfer Coefficient, W/(m**2*K)\n", "s=5.6704*10**-8; #stefan Boltzman constant, W/(m**2*K**4)\n", "\n", "#Calculations\n", "z=solve(((s*e*((373)**4 - (x)**4)) - h*(x-293)),x);\t#Calculating Thermocouple Temperature, K\n", "y=z[0]-273;\t\t\t\t\t #Thermocouple Temperature, C\n", "\n", "'''NOTE: Equation written is absolutely correct and solving this equation\n", " should give real result as: 296.112 i.e. 23.112 C, but somehow python is giving wrong result.'''\n", "\n", "#Results\n", "print \"Thermocouple Temperature is :\",round(y,1),\"C \\n\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Thermocouple Temperature is : 25.9 C \n", "\n" ] } ], "prompt_number": 3 } ], "metadata": {} } ] }