{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10 : Bridge Circuits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_1,pg 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# wheatstone bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "Vs=12.0                  #source voltage\n",
      "R=120.0                  #resistance of arms \n",
      "delv=0.3                 #variation in output voltage(+/-)0.3\n",
      "Rm=100.0                 #meter resistance\n",
      "\n",
      "\n",
      "#Calculations\n",
      "delRbyR=(4.0/Vs)*(delv)*100\n",
      "delIm=(delRbyR/100.0)/(4.0*R*(1+(Rm/R)))\n",
      "\n",
      "#Result\n",
      "print(\"percent change in resistance:\")\n",
      "print(\"delRbyR = %.f%% \\n\"%delRbyR)\n",
      "print(\"current variation:\")\n",
      "print(\"delIm = %.6f A\"%delIm)\n",
      "# Answer current variation is not matchhing with the book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percent change in resistance:\n",
        "delRbyR = 10% \n",
        "\n",
        "current variation:\n",
        "delIm = 0.000114 A\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_2,pg 295"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# high resistance measurement bridge\n",
      "\n",
      "import math\n",
      "#variable declaration\n",
      "#in absence of the guard point arrangement, two 10^10 ohm resistances in series become parallel \n",
      "#to the 10^9 ohm resistance, making the effective unknown resistance\n",
      "\n",
      "#case-1\n",
      "Rh=10.0**9\n",
      "Ra1=10.0**10\n",
      "Rb1=10.0**10\n",
      "#case-2 \n",
      "Ra2=10.0**9\n",
      "Rb2=10.0**9\n",
      "\n",
      "#Calculations\n",
      "Rue1=((Rh*2*Ra1)/(Rh+(2*Ra1)))        #effective resistance\n",
      "err1=((Rh-Rue1)/Rh)*100               #percentage error\n",
      "Rue2=((Rh*2*Ra2)/(Rh+(2*Ra2)))        #effective resistance\n",
      "err2=((Rh-Rue2)/Rh)*100               #percentage error\n",
      "\n",
      "#Result\n",
      "print(\"percentage error case-1:\")\n",
      "print(\"err1 = %.0f%% \\n\"%err1)\n",
      "print(\"percentage error case-2:\")\n",
      "print(\"err2 = %.1f%%\"%err2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage error case-1:\n",
        "err1 = 5% \n",
        "\n",
        "percentage error case-2:\n",
        "err2 = 33.3%\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_3,pg 297"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# capacitance and resistance of AC bridge\n",
      "import math\n",
      "#Variable declaration\n",
      "Z1=20.0+80.0j            #impedance in first arm\n",
      "Z2=200.0                 #impedance in second arm\n",
      "Z3=100.0+200.0j          #impedance in third arm\n",
      "f=50.0                   #excitation frequency\n",
      "\n",
      "#Calculations\n",
      "Zu=((Z2*Z3)/Z1)                 #impedance of fourth arm\n",
      "Cu=(1.0/(2*math.pi*f*Zu.real))  #capacitance in fourth arm\n",
      "Ru=-Zu.imag                     #resistance in fourth arm\n",
      "\n",
      "#Result\n",
      "print(\"capacitance in fourth arm:\")\n",
      "print(\"Cu = %f F\\n\"%(Cu*10**6))\n",
      "print(\"resistance in fourth arm:\")\n",
      "print(\"Ru = %.2f ohm\"%Ru)\n",
      "#Answer is slightly different than book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "capacitance in fourth arm:\n",
        "Cu = 6.012520 F\n",
        "\n",
        "resistance in fourth arm:\n",
        "Ru = 117.65 ohm\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_4,pg 301"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# schering bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "C3=0.001*10**-6                    #capacitor\n",
      "Fd=6.0*10**-4                      #dissipation factor\n",
      "f=1.0*10**3                        #schering bridge frequency\n",
      "R1=10.0*10**3\n",
      "R2=10.0*10**3\n",
      "\n",
      "\n",
      "#Calculations\n",
      "Ru=(Fd/(2*math.pi*f*C3))           #standard resistor\n",
      "C1=C3*(1/R2)*Ru\n",
      "\n",
      "#Result\n",
      "print(\"standard resistor:\")\n",
      "print(\"Ru = %.3f ohm\\n\"%Ru)\n",
      "print(\"capacitor:\")\n",
      "print(\"C1 = %.1f pF\"%(C1*10**12))\n",
      "#Answer do not match with the book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "standard resistor:\n",
        "Ru = 95.493 ohm\n",
        "\n",
        "capacitor:\n",
        "C1 = 9.5 pF\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_5,pg 303"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# wein bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "R=10*10**3                    #resistor\n",
      "C=0.001*10**-6                #capacitor\n",
      "R3=10.0*10**3                 #reistance in third arm\n",
      "\n",
      "#Calculations\n",
      "f=(1.0/(2*math.pi*R*C))       #supply frequency\n",
      "R4=(R3/2)                     #reistance in fourth arm\n",
      "\n",
      "#Result\n",
      "print(\"supply frequency:\")\n",
      "print(\"f = %.2f kHz\\n\"%(f/1000))\n",
      "print(\"reistance in fourth arm:\")\n",
      "print(\"R4 = %.1f k-ohm\"%(R4/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "supply frequency:\n",
        "f = 15.92 kHz\n",
        "\n",
        "reistance in fourth arm:\n",
        "R4 = 5.0 k-ohm\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_6,pg 303"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# balance condition in wein bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "f=47.76*10**3                         #supplu frequency\n",
      "C=10**-9                              #assume\n",
      "\n",
      "#Calculations\n",
      "CR=(1.0/(2*math.pi*f))                #resistor capacitor product\n",
      "R=(CR/C)                              #resistor\n",
      "\n",
      "#Result\n",
      "print(\"for (R3/R4) = 2\\nR3 and R4 may be maintained at earlier values\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "for (R3/R4) = 2\n",
        "R3 and R4 may be maintained at earlier values\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_7,pg 309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# relation between Vo and t for Vi given\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "a1=3.81*10**-3\n",
      "a2=-6.17*10**-7\n",
      "#R1=(R2/2),i.e R2/R1=2\n",
      "R1=10*10**3\n",
      "R2=20*10**3\n",
      "R5=4*10**3\n",
      "R6=20*10**3\n",
      "\n",
      "#Calculations\n",
      "B=(R5/(R5+R6))\n",
      "#using relation 10.68(b)\n",
      "\n",
      "#Result\n",
      "print(\"(Vo/Vi)= (-3.05*10^-3)t/(1+0.76*10^-3)t\")\n",
      "print(\"thus for, t<=130 C, Vo is approx. linear. This however can be extended with proper choice\")\n",
      "print(\"i.e R5 and R6 in relation to R1,R3 and R4\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(Vo/Vi)= (-3.05*10^-3)t/(1+0.76*10^-3)t\n",
        "thus for, t<=130 C, Vo is approx. linear. This however can be extended with proper choice\n",
        "i.e R5 and R6 in relation to R1,R3 and R4\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_8,pg 503"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find deflection in galvanometer\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "R1=120.0                    #resistance of arm-1\n",
      "R2=120.0                    #resistance of arm-2\n",
      "R3=120.0                    #resistance of arm-3\n",
      "R4=121.0                    #resistance of arm-4\n",
      "Rm=100.0                    #meter resistance\n",
      "Vs=6.0                      #source voltage\n",
      "n=1*10**-3                  #meter sensitivity\n",
      "\n",
      "\n",
      "#Calculations\n",
      "k=(R3/(R3+R4))\n",
      "k = math.floor(k*10**3)/10**3\n",
      "Vm=Vs*((R1/(R1+R2))-k)                  #voltage across meter\n",
      "Rb=((R1*R2)/(R1+R2))+((R3*R4)/(R3+R4))  #thevenised bridge resistance\n",
      "Rb=math.floor(Rb*1000)/1000 \n",
      "Ig=(Vm/(Rb+Rm))                         #current through galvanometer\n",
      " \n",
      "D=Ig*10**6\n",
      "\n",
      "#Result\n",
      "print(\"deflection in meter:\")\n",
      "print(\"D = %f mm\"%D)\n",
      "#Calcualtions in the book are not correct"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "deflection in meter:\n",
        "D = 81.726054 mm\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_9,pg 503"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find insulating post resistance\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "err=0.5/100.0                 #(+/-)0.5%\n",
      "R=100.0*10**6               #test resistance\n",
      "\n",
      "#Calculations\n",
      "#Re=((R*2*Rip)/(R+(2*Rip)))\n",
      "Re1=R-(err*R)               #err=+0.5\n",
      "Re2=R+(err*R)               #err=-0.5\n",
      "Rip1=((R*Re1)/(2*(R-Re1)))  #err=+0.5\n",
      "Rip2=((R*Re2)/(2*(Re2-R)))  #err=-0.5\n",
      "\n",
      "\n",
      "#Result\n",
      "print(\"resistance of each insulating post-1:\")\n",
      "print(\"Rip1 = %.2f M-ohm\\n\"%(Rip1*10**-6))\n",
      "print(\"resistance of each insulating post-2:\")\n",
      "print(\"Rip2 = %.2f M-ohm\"%(Rip2*10**-6))\n",
      "# Answer in the book are not matching"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance of each insulating post-1:\n",
        "Rip1 = 9950.00 M-ohm\n",
        "\n",
        "resistance of each insulating post-2:\n",
        "Rip2 = 10050.00 M-ohm\n"
       ]
      }
     ],
     "prompt_number": 61
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_10,pg 504\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# maxwell bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "Ru=130.0                     #resistance\n",
      "Lu=31*10**-3                 #inductance \n",
      "R2=10*10**3                  #resistance in arm-2\n",
      "C1=0.01*10**-6               #capacitance in arm\n",
      "\n",
      "#Calculations\n",
      "R3=(Lu/(C1*R2))              #resistance in arm-3\n",
      "R1=((R2*R3)/Ru)              #resistance in arm-1\n",
      "\n",
      "#Result\n",
      "print(\"R1 = %.2f k-ohm\"%(R1/1000))\n",
      "print(\"R3 = %.f ohm\"%R3)\n",
      "print(\"yes values are unique\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "R1 = 23.85 k-ohm\n",
        "R3 = 310 ohm\n",
        "yes values are unique\n"
       ]
      }
     ],
     "prompt_number": 64
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_11,pg 504"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# hay bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "f=1000.0                 #supply frequency\n",
      "C1=0.04*10**-6           #capacitance\n",
      "R1=220.0                 #resistance in arm-1\n",
      "R2 = 10*10**3            #resistance in arm-2\n",
      "Lu=22.0*10**-3           #inductance\n",
      "\n",
      "\n",
      "#Calculations\n",
      "pi= math.floor(math.pi*100)/100\n",
      "Ru=((2*pi*f)**2)*C1*R1*Lu #resistance\n",
      "R3=((R1*Ru)+(Lu/C1))/R2        #resistance in arm-3\n",
      "\n",
      "#Result\n",
      "print(\"resistance of inductor:\")\n",
      "print(\"Ru = %.3f ohm\\n\"%Ru)\n",
      "print(\"resistance of arm-3:\")\n",
      "print(\"R3 = %.2f ohm\"%R3)\n",
      "#Answer for R3 is not matching."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance of inductor:\n",
        "Ru = 7.635 ohm\n",
        "\n",
        "resistance of arm-3:\n",
        "R3 = 55.17 ohm\n"
       ]
      }
     ],
     "prompt_number": 74
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_12,pg 505"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# find C1 C3 and dissipation factor\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "C4=0.0033*10**-6              #lossy capacitor\n",
      "R2=12.0*10**3                 #arm-2 resistance\n",
      "R1=10.0*10**3                 #arm-1 resistance\n",
      "f = 50.0                      # frequency\n",
      "\n",
      "#Calculations\n",
      "C3=((C4*R2)/R1)               #standard capacitance\n",
      "R4=0.1\n",
      "C1=((R4*C3)/R2)\n",
      "Fd=2*math.pi*f*C4*R4         #dissipation factor\n",
      "\n",
      "#Result\n",
      "print(\"capacitance set value:\")\n",
      "print(\"C1 = %.5f * 10^12 F\\n\"%(C1*10**12))\n",
      "print(\"value of standard capacitance:\")\n",
      "print(\"C3 = %.5f *10^6 F\\n\"%(C3*10**6))\n",
      "print(\"dissipation factor:\")\n",
      "print(\"Fd = %.4f * 10^-6\"%(math.floor(Fd*10**10)/10**4))\n",
      "#Answer for C1 is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "capacitance set value:\n",
        "C1 = 0.03300 * 10^12 F\n",
        "\n",
        "value of standard capacitance:\n",
        "C3 = 0.00396 *10^6 F\n",
        "\n",
        "dissipation factor:\n",
        "Fd = 0.1036 * 10^-6\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example10_13,pg 505"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# wein bridge\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "f=10.0*10**3                     #supply frequency\n",
      "R1=10.0*10**3                    #reistance of arm-1\n",
      "C1=0.01*10**-6\n",
      "C2=0.01*10**-6\n",
      "R3=20*10**3                    #resistance of arm-3\n",
      "\n",
      "#Calaculations\n",
      "R2=(1/(f**2))*(1/(C1*C2*R1))   #resistance of arm-2\n",
      "R4=(R3/((R1/R2)+(C2/C1)))      #resistance of arm-4\n",
      "\n",
      "#Result\n",
      "print(\"resistance of arm-2:\")\n",
      "print(\"R4 = %.f k-ohm\\n\"%(R2/1000))\n",
      "print(\"resistance of arm-4:\")\n",
      "print(\"R2 = %.f k-ohm\\n\"%(R4/1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance of arm-2:\n",
        "R4 = 10 k-ohm\n",
        "\n",
        "resistance of arm-4:\n",
        "R2 = 10 k-ohm\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}