{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7:Sensors And Transducers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.2,Page No:401"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "displacement 5.75 mm\n",
      "displacement 12.800 mm\n",
      "resolution of potentiometer 0.050 mm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "R   =10000;                           #resistance in Ω\n",
    "R1  = 3850;                           #resistance of potentiometer Ω\n",
    "R2  = 7560;                           #resistance of potentiometer Ω\n",
    "l   = 50*10**-3;                      #length of uniform wound wire in m\n",
    "x   = 10;\n",
    "\n",
    "#calculations\n",
    "\n",
    "R3  = (R/float(2));                  #resistance of potentiometer in .normal position in Ω\n",
    "r   = (R/float(l));                  #resistance of potentiometer wire per unit length Ω/mm\n",
    "dR1  = R3-R1;                        #change in resistance of potentiometer from its normal position Ω\n",
    "D1  = (dR1/float(r));                #displacement in mm\n",
    "dR2  = (R2-R3);                      #change in resistance of potentiometer from its normal position in Ω\n",
    "D2  = (dR2/float(r));                #displacement in mm\n",
    "RE  = (x/float(r));                  #resolution of potentiometer in mm\n",
    "\n",
    "#result\n",
    "print'displacement %3.2f'%(D1*10**3),'mm';\n",
    "print'displacement %3.3f'%(D2*10**3),'mm';\n",
    "print'resolution of potentiometer %3.3f'%(RE*10**3),'mm';\n",
    " \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.3,Page No:403"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "resistance at 35°C is 50 Ω\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "R25  = 100;                             #resistance of thermistor at 25°C\n",
    "t2   = 35;                              #temperature in °C\n",
    "t1   = 25;                              #temperature in  °C\n",
    "alpha = 0.05;                           #temperature coefficient\n",
    "\n",
    "#calculations\n",
    "t   = t2-t1;                            #temperaturre difference in °C\n",
    "x   = alpha*t;\n",
    "R35 = (R25)*(1-x);                      #resistance in Ω\n",
    "\n",
    "#result\n",
    "print'resistance at 35°C is %d'%R35,'Ω';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.4,Page No:406"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "inductance = 0.04 mH\n",
      "ratio of change in inductance to the original inductance =0.02\n",
      "ratio of change in inductance to the original inductance =0.02\n",
      "hence dl is directly proportional to displacement\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "l    = 1.00;                       #length in mm\n",
    "L    = 2;                          #inductance in mH\n",
    "d    = 0.02;                       #displacement in mm\n",
    "\n",
    "#calculations\n",
    "la    = l-d;                     #length of air gap when d=0.02\n",
    "dl    = (2*(1/float(la)))-L;     #change in inductance in mH\n",
    "r     =  dl/L;                   #ratio of change in inductance to the original inductance\n",
    "dd    =  r/l;                    #ratio of displacement to original gap length\n",
    "\n",
    "#result\n",
    "print'inductance = %3.2f'%dl,'mH';\n",
    "print'ratio of change in inductance to the original inductance =%3.2f'%r;\n",
    "print'ratio of change in inductance to the original inductance =%3.2f'%dd;\n",
    "print'hence dl is directly proportional to displacement';\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.5,Page No:409"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "percentage linearity 0.25 %\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "d    = 1.8;                       #output voltage at maximum displacement in V\n",
    "de   = 0.0045;                    #deviation from straight line through the origin\n",
    "\n",
    "#calculations \n",
    "a     = (de/float(d))*100;         #percentage linearity indicating in both -ve and +ve\n",
    "\n",
    "#result\n",
    "print'percentage linearity %3.2f'%a,'%';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.6,Page No:409"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sensitivty of LVDT 3.00 mV/mm\n",
      "resolution 0.0067 mm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Vo    = 1.8;                            #output voltage in mV\n",
    "Vi    = 0.6;                            #input voltage in mV;\n",
    "a     = 500;                            #amplification factor\n",
    "r     = 1/float(4);                     #scale can read \n",
    "v     = 4;                              #output of voltmetr in V\n",
    "D     = 100;                            #millivoltmeter readings\n",
    "\n",
    "#calculation\n",
    "s     = Vo/float(Vi);                        #sensitivity in mV/mm\n",
    "sm    =  a*s;                                #sensitivity of measurement in mV/mm\n",
    "s1    = (v/float(D))*10**3;                  # 1 scale division in mV\n",
    "Vm    = r*s1;                                #minimum voltage  that can be read on voltmeter\n",
    "R     = Vm/float(sm);                        #resolution in mm\n",
    "\n",
    "#result \n",
    "print'sensitivty of LVDT %3.2f'%s,'mV/mm';\n",
    "print'resolution %3.4f'%R,'mm';\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.7,Page No:413"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "capacitance = 13.275 pF\n",
      "change in capacitance 1.475 pF\n",
      "ratio ofper unit change of capacitance to per unit change in displacement = 1.111111\n",
      "capcitance when mica is inserted = 13.88 pF\n",
      "change in capacitance when mica sheet is inserted = 1.62 pF\n",
      "ratio ofper unit change of capacitance to per unit change in displacement = 1.168\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "A     = 300*10**-6;                     #area of plate in m**2\n",
    "d     = 0.2*10**-3;                     #distance between plates in mm\n",
    "e0    = 8.85*10**-12;                   #permittivity in F/m\n",
    "er2    = 8;                             #dielectric constant of mica \n",
    "d1    = 0.18*10**-3;                    #distance between plates in mm\n",
    "er1   = 1;                              #dielectric constant\n",
    "D1    = 0.19;\n",
    "D2    =  0.01;                          #thickness of mica sheet in mm\n",
    "D3    = 0.17;                           #displacement in mm\n",
    "D4    = 0.01;\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "#calculation\n",
    "C    = ((e0*A)/float(d));                    #value of capacitance in pF\n",
    "dD   = d-d1;                                 #change in displacement in mm\n",
    "dC   = ((e0*A)/(float(d1)))-C;               #change in capacitance in capacitance\n",
    "x1   = (dC/float(C));                        #per unit change in capacitance \n",
    "x2   = (dD/float(d));                        #per unit change of displacement\n",
    "d3   =  d-d1;                                #length of air gap between plates in mm\n",
    "x    =  x1/float(x2);                        #ratio of unit change of capacitance to unit change in displacement\n",
    "D    =  (D1/(float(er1)))+((D2/float(er2)));\n",
    "C1   =  (e0*A)/float(D*10**-3);              #initial capacitance of transducer in mm\n",
    "d4   =  d1-d3;                               #length of air gap in mm\n",
    "d1   = (D3/float(er1))+(D4/float(er2));\n",
    "C2   =  (e0*A)/float(d1*10**-3);             # capacitance with displacement is applien in pF\n",
    "dC2  = C2-C1;                                #change in capacitance in pF\n",
    "y1   = (dC2/float(C1));                      #per unit change in capacitance \n",
    "y2   = (dD/float(d));                        #per unit change of displacement\n",
    "Y    = y1/float(y2);                         #ratio of unit change of capacitance to unit change in displacement\n",
    "\n",
    "#result\n",
    "print'capacitance = %2.3f'%(C*10**12),'pF';\n",
    "print'change in capacitance %3.3f'%(dC*10**12),'pF';\n",
    "print'ratio ofper unit change of capacitance to per unit change in displacement = %f'%x;\n",
    "print'capcitance when mica is inserted = %3.2f'%(C1*10**12),'pF';\n",
    "print'change in capacitance when mica sheet is inserted = %2.2f'%(dC2*10**12),'pF';\n",
    "print'ratio ofper unit change of capacitance to per unit change in displacement = %3.3f'%Y;\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.8,Page No:417"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "output voltage = 192.50 V\n",
      "charge sensitivity = 2.233 pC/N\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "t    = 2.5*10**-3;                               #thickness in m\n",
    "g    = 0.055;                                    #voltage intensity in Vm/N\n",
    "p    = 1.4*10**6;                                #pressure in N/m**2\n",
    "e    = 40.6*10**-12;                             #permittivity of quartz in F/m\n",
    "\n",
    "#calculation\n",
    "E     =  g*t*p;                                 #output voltage in V\n",
    "q     =  e*g;                                   #charge sensitivity in pC/N\n",
    "\n",
    "#result\n",
    "print'output voltage = %3.2f'%E,'V';\n",
    "print'charge sensitivity = %3.3f'%(q*10**12),'pC/N';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.9,Page No:417"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "force = 43.64 N\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "r   = 6*10**-3;                      #radius in m\n",
    "t   = 1.8*10**-3;                    #thickness in m\n",
    "g   = 0.055;                         #voltage intensity in Vm/N\n",
    "E   = 120;                           #voltage developed in V\n",
    "\n",
    "#calculation\n",
    "A    = r*r;                          #area in m**2\n",
    "p    = E/(float(g*t));               #pressure in N/m**2\n",
    "F    = p*A;                          #force in N\n",
    "\n",
    "\n",
    "#result\n",
    "print'force = %3.2f'%F,'N';\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.10,Page No:417"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "strain = 0.00000\n",
      "charge = 900.0 pC\n",
      "capacitance = 300 pf\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "r  = 6*10**-3;                       #radius in m\n",
    "t  = 1.5*10**-3;                     #thickness in m\n",
    "e  = 12.5*10**-9;                    #permittivity in F/m\n",
    "F  = 6;                              #force in N\n",
    "d  = 150*10**-12;                    #charge density in pC/N\n",
    "E  = 12*10**6;                       #modulus of elasticity in N/m**2\n",
    "s  = 0.167*10**6;                    #stress \n",
    "\n",
    "#calculation\n",
    "A  = r*r;\n",
    "p  = F/float(A);                       #pressure in MN/m**2\n",
    "p1 = p*10**-6;\n",
    "e1  = s/float(E);                      #strain \n",
    "g  = d/float(e);                       #voltage sensitivity in V*m/N;\n",
    "E1 = g*t*p;                            #voltage generated in V\n",
    "Q  = d*F;                              #charge in C\n",
    "C  = (Q)/float(E1);                    #capacitance in F\n",
    "\n",
    "#result\n",
    "print'strain = %3.5f'%e;\n",
    "print'charge = %3.1f'%(Q*10**12),'pC';\n",
    "print'capacitance = %3.3d'%(C*10**12),'pf';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Example:7.11,Page No:421"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hall angle 1.55 °(Equal to 1 minute 4 seconds)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "p  =  0.00912;                        #resistivity in Ωm\n",
    "B  =  0.48;                           #flux density in Wb/m**2\n",
    "RH =  3.55*10**-4;                    #hall coefficient in m**3/C\n",
    "\n",
    "#calculation\n",
    "Ex  = p;                              #Ex in terms of Jx in °\n",
    "Ey  = RH*B;                           #ey interms of Jx in °\n",
    "x= Ex/float(Ey);\n",
    "t  = math.atan(x);\n",
    "\n",
    "print'hall angle %3.2f'%t,'°(Equal to 1 minute 4 seconds)';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.12,Page No:421"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "voltage between contacts = 0.00256 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "p  =  0.00912;                        #resistivity in Ωm\n",
    "B  =  0.48;                           #flux density in Wb/m**2\n",
    "RH =  3.55*10**-4;                    #hall coefficient in m**3/C\n",
    "I  = 0.015;                           # current in A\n",
    "l  = 15*10**-3;                       #length in m\n",
    "b  = 10**-3;                          #breadth in m\n",
    "\n",
    "\n",
    "#calculation\n",
    "A   = l*b;                            #area in m**2\n",
    "Jx  = I/float(A);                     #current density in A/m**2\n",
    "Ey  = RH*B*Jx;                        #Ey in V/m\n",
    "V   = Ey*I;                           #voltage between contacts in V\n",
    "\n",
    "#result\n",
    "print'voltage between contacts = %5.5f'%V,'V';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.13,Page No:432"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "poissons ratio = 1.6\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Gf  =  4.2;                       #guage factor of resistance \n",
    "\n",
    "#calculation\n",
    "u  =(Gf-1)/float(2);              #poisson's  ratio\n",
    "\n",
    "#result\n",
    "print'poissons ratio = %1.1f'%u;"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.14,Page No:432"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change in resistance = 48.00 mΩ\n",
      "Note:printing mistake in textbook\n",
      "change in resistance = 48.00 mΩ\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "R      = 120;                                 #resistance in Ω\n",
    "Gf     = 2;                                   #guage factor \n",
    "s      = 400*10**6;                           #elastic limit stress in N/m**2\n",
    "E      = 200*10**9;                           #modulus of elasticity in N/m**2\n",
    "alpha  = 20*10**-6;                           #resistance temperature coefficient in /°C\n",
    "x      =  1/float(10);                        #cahnge in stress \n",
    "dt     = 20;                                  #change in temperature in °C\n",
    "\n",
    "#calculations\n",
    "sc     =  s*x;                              #change in stress in N/m**2\n",
    "e      =  sc/float(E);                      #strain \n",
    "dR     =  Gf*e*R;                           #change in resistance in mΩ\n",
    "dR1    =  R*alpha*dt;                       #change in resistance in mΩ\n",
    "\n",
    "#result\n",
    "print'change in resistance = %3.2f'%(dR*10**3),'mΩ';\n",
    "print'Note:printing mistake in textbook';\n",
    "print'change in resistance = %3.2f'%(dR1*10**3),'mΩ';\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.15,Page No:433"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change in length = 3.72e-06 m\n",
      "force = 2.438 kN\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "L      =  0.12;                        #length in m\n",
    "A      = 3.8*10**-4;                   #area in m**2\n",
    "R      = 220;                          #resistance in Ω\n",
    "Gf     = 2.2;                          #guage factor\n",
    "dR     = 0.015;                        #change in resistance in Ω\n",
    "E      = 207*10**9;                    #elasticity in N/m**2\n",
    "\n",
    "#calculations\n",
    "dL     =  (dR*L)/float(R*Gf);    #change in length in m      \n",
    "s      =  (E*dL)/float(L);                              \n",
    "F      =  s*A;                   #force in kN            \n",
    "\n",
    "#result\n",
    "print'change in length = %2.2e'%dL,'m';\n",
    "print'force = %3.3f'%(F*10**-3),'kN';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.16,Page No:444"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "strain  = 594.5 microstrain\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Rg     =  100;                 #resistance in Ω\n",
    "Rsh    =  80000;               #resistance in Ω\n",
    "Gf     = 2.1;\n",
    "\n",
    "#calculations\n",
    "x    = (Rg/float(Rg+Rsh));    #equivalent strain\n",
    "eeq  = x/(float(Gf));         #strain  in microstrain\n",
    "\n",
    "#result\n",
    "print'strain  = %3.1f'%(eeq*10**6),'microstrain';\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.17,Page No:445"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "strain = 356.43 microstrain\n",
      "Note:calculation mistake in text book,Rg value is taken wrong in calculating s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "n     =  4;                                 #four arm bridge\n",
    "Rg    =  200;                               #resistance in Ω\n",
    "Rsh   = 100*10**3;                          #resistance in Ω\n",
    "x     = 140;                                #number of divisions\n",
    "Gf    = 2.0;                                #guage factor\n",
    "\n",
    "#calculation\n",
    "eeff  = Rg/float(n*Gf*(Rg+Rsh));            #effective strain\n",
    "d     = eeff/float(x);                      #1 division scale\n",
    "s     = float(d)*Rg;                        #strain when loaded\n",
    "\n",
    "#result\n",
    "print'strain = %3.2f'%(s*10**6),'microstrain';\n",
    "print'Note:calculation mistake in text book,Rg value is taken wrong in calculating s';\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.18,Page No:447"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "longitudinal stress = 70.01 MN/m**2\n",
      "longitudinal stress = 146.2 MN/m**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "ex     =   0.00016;                    #strain values in axial \n",
    "ey     =   0.00064;                    #strain values in circumferential direction\n",
    "E      =   200*10**9;                  #modulus of elasticity in N/,**2\n",
    "u      =   0.26;                       #poisson's ratio \n",
    "\n",
    "#calculation\n",
    "sigmax  =  (E*(ex+(u*ey)))/float(1-(u**2));         #longitudinal stress in N/m**2\n",
    "sigmay  =  (E*(ey+(u*ex)))/float(1-(u**2));         #hoop stress in N/m**2\n",
    "\n",
    "#result\n",
    "\n",
    "print'longitudinal stress = %3.2f'%(sigmax/10**6),'MN/m**2';\n",
    "print'longitudinal stress = %3.1f'%(sigmay/10**6),'MN/m**2';\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.19,Page No:447"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "modulus of elasticity = 147.6 N/M**2\n",
      "poissons ratio  = 0.2727\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "A     =  110*10**-6;                 #area in m**2\n",
    "P     =  25;                         #load in kN\n",
    "ex    =  1540;                       #strain values in axial direction\n",
    "ey    =  -420;                       #strain values in transvers  direction\n",
    "\n",
    "#calculation\n",
    "sigmax    =  P/float(A);               #axial stress in N/M**2\n",
    "E         =  sigmax/float(ex);         #modulus of elasticity in N/M**2\n",
    "u         =  (-ey*E)/float(sigmax);    #poisson's ratio\n",
    "\n",
    "#result\n",
    "print'modulus of elasticity = %3.1f'%E,'N/M**2'\n",
    "print'poissons ratio  = %3.4f'%u;\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.21,Page No:450"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "emax  = 6.73e-05\n",
      "emin  = -1.927e-05\n",
      "sigmamax = 13.514 MN/m**2\n",
      "sigmamin  = 0.201 MN/m**2\n",
      "maximum shear stress = 6.656 MN/m**2\n",
      "location of principle planes = 16.845034 °\n",
      "location of principle planes = 106.845034 °\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "e1    =  60*10**-6;                        #strain in microstrains\n",
    "e2    =  48*10**-6;                        #strain in microstrain\n",
    "e3    =  -12*10**-6;                       #strain in microstrain\n",
    "E     =  200*10**9;                        #modulus of elsticity in N/m**2\n",
    "u     =  0.3;\n",
    "\n",
    "#calculation\n",
    "x      = (e1+e3)/float(2);                 #average of strains\n",
    "a      = math.sqrt(((e1-e2)**2)+((e2-e3)**2));\n",
    "b      = 1/math.sqrt(2);\n",
    "y      = a*b;\n",
    "emax   = x+y;                             #principle strains\n",
    "emin   = x-y;                             #principle strains\n",
    "x1     = x/float(1-u);\n",
    "y1     = y/float(1+u); \n",
    "sigmamax  = E*(x1+y1);                    #principle stress\n",
    "sigmamin  = E*(x1-y1);                    #principle stress\n",
    "tmax      = E*y1;                         #maximum shear stress in MN/m**2\n",
    "k         = ((2*e2)-e1-e3)/float((e1-e3));\n",
    "theta     = (math.atan(k));      #location of principle planes\n",
    "theta1    =(theta*180)/float(math.pi);\n",
    "theta2    =theta1+180;\n",
    "theta11   = (theta1)/float(2);\n",
    "theta22   = (theta2)/float(2);\n",
    "\n",
    "\n",
    "\n",
    "print'emax  = %2.2e'%(emax);\n",
    "print'emin  = %2.3e'%(emin);\n",
    "print'sigmamax = %3.3f'%(sigmamax*10**-6),'MN/m**2';\n",
    "print'sigmamin  = %3.3f'%(sigmamin*10**-6),'MN/m**2';\n",
    "print'maximum shear stress = %3.3f'%(tmax*10**-6),'MN/m**2';\n",
    "print'location of principle planes = %f'%theta11,'°';\n",
    "print'location of principle planes = %f'%theta22,'°';\n",
    " \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example:7.22,Page No:454"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sensitivity of load = 13.79 uV/kN\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "d      = 0.06;                    #diameter in m\n",
    "Rg     = 120;                     #nominal resistance of each guage Ω\n",
    "Gf     = 2.0;                     #guage factor \n",
    "v      = 6;                       #supply voltage in V\n",
    "E      = 200*10**9;               #modulus of elasticity in N/m**2\n",
    "u      = 0.3;                     #poisson's ratio\n",
    "P      = 1000;                    #load in N\n",
    "\n",
    "#calculation\n",
    "\n",
    "A      = (math.pi/float(4))*d*d;\n",
    "s      =  P/float(A);                      #stress in N/m**2\n",
    "e      =  s/float(E);                      #strain \n",
    "x      = Gf*e;                             #fraction change in resistence i.e dR/R\n",
    "a      = v/float(4);\n",
    "y      = 2*(1+u)*(x)*a;                    #output volatge in uV\n",
    "                  \n",
    "#result\n",
    "print'sensitivity of load = %3.2f'%(y*10**6),'uV/kN';"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}