{
 "metadata": {
  "name": "",
  "signature": "sha256:6fa810433d8fb0d04740abb66d2625b01a8af010ca4183a75eead5496aab3b33"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter8 - Inductance and Capacitance Measurements"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.5.1 - page : 8-22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Percentage error \n",
      "import math\n",
      "r=10 #in ohm\n",
      "f=1 #in  MHz\n",
      "c=65 #capacitance in pF\n",
      "rsh=0.02 #in ohm\n",
      "qact=((1/(2*math.pi*f*10**6*c*10**-12*r))) #actual q factor\n",
      "qm=(1/(2*math.pi*c*10**-12*f*10**6*(r+rsh))) #measured q factor\n",
      "per=((qact-qm)/qact)*100 #percentage error \n",
      "print \"Percentage error is\",round(per,1),\" %\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage error is 0.2  %\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.5.2 - page : 8-23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Self capacitance and inductance\n",
      "f1=2 #in MHz\n",
      "c1=460 #in pF\n",
      "f2=4 #in MHz\n",
      "c2=100 #in pF\n",
      "cd1=((c1-(4*c2))/3) #self capacitance in pF\n",
      "x=((1/(2*math.pi*f1*10**6)))**2 \n",
      "l=x/((c1+cd1)*10**-12) # in H\n",
      "l*=10**6  # in micro H\n",
      "print \"Self capacitance is \",cd1,\" pF\"\n",
      "print \"Inductance is \",round(l,2),\" micro H\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Self capacitance is  20  pF\n",
        "Inductance is  13.19  micro H\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.1 - page : 8-25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Lx and Rx\n",
      "#given data :\n",
      "R1=560 # in kohm\n",
      "R2=6.3 # in kohm\n",
      "R3=120  # in kohm\n",
      "Ci=0.01 # in micro F\n",
      "Sensitivity=10 # in mm/micro A\n",
      "del_r=1 # in ohm\n",
      "Rx=(R2*R3)/R1 \n",
      "print \"Unknown resistance, Rx = \",Rx,\" kohm\"\n",
      "Lx=R2*10**3*R3*10**3*Ci*10**-6 \n",
      "print \"Unknown inductance, Lx = \",Lx,\" H\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Unknown resistance, Rx =  1.35  kohm\n",
        "Unknown inductance, Lx =  7.56  H\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.2 - page : 8-25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Cx,Rx and D\n",
      "#given data :\n",
      "f=1000 #in Hz\n",
      "R1=1.1 # in kohm\n",
      "R2=2.2 # in kohm\n",
      "C1=0.47 # in micro F\n",
      "C3=0.5 # in micro F\n",
      "Rx=(R2*C1)/C3 \n",
      "print \"Unknown resistance, Rx = \", Rx,\" kohm\"\n",
      "Cx=(R1*C3)/R2 \n",
      "print \"Unknown capacitance, Cx = \", Cx, \" micro F\"\n",
      "w=2*f*math.pi \n",
      "D=w*Cx*10**-6*Rx*10**3 \n",
      "print \"Dissipation factor, D = \", round(D,2)\n",
      "#answer is wrong in the textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Unknown resistance, Rx =  2.068  kohm\n",
        "Unknown capacitance, Cx =  0.25  micro F\n",
        "Dissipation factor, D =  3.25\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.3 - page : 8-26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Unknown resistance and capacitance\n",
      "r1=10 #in kohms\n",
      "r2=50 #in kohms\n",
      "r3=100 #in kohms\n",
      "c3=100 #in micro F\n",
      "rx=((r2*10**3*r3*10**3)/(r1*10**3))*10**-3 #unknown resistance in kohms\n",
      "cx=((r1*10**3*c3*10**-6)/(r2*10**3))*10**6 # unknown capacitance in micro F\n",
      "print \"unknown resistance is \",rx,\" kohm\"\n",
      "print \"Unknown capacitance is \",cx,\" micro F\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "unknown resistance is  500.0  kohm\n",
        "Unknown capacitance is  20.0  micro F\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.4 - page : 8-27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Lx and Rx\n",
      "#given data :\n",
      "R1=600 # in ohm\n",
      "R2=1000 # in ohm\n",
      "R3=100 # in ohm\n",
      "C1=1 # in micro F\n",
      "Rx=(R2*R3)/R1 \n",
      "print \"resistance, Rx = \",Rx,\" ohm\"\n",
      "Lx=C1*10**-6*R2*R3 \n",
      "print \"Inductance, Lx = \",Lx, \" H\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance, Rx =  166  ohm\n",
        "Inductance, Lx =  0.1  H\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.5 - page : 8-28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#L3 and R3\n",
      "#given data :\n",
      "R1=10 # in kohm\n",
      "R2=2 # in kohm\n",
      "R4=1 # in kohm\n",
      "C2=1*10**-6 # in micro F\n",
      "w=3000 # in rad/sec\n",
      "L3=(R1*10**3*R4*10**3*C2)/(1+((R2*10**3)**2*(C2**2)*w**2))\n",
      "R3=R2*10**3*L3*C2*w**2 \n",
      "print \"Unknown resistance is \",round(R3,0),\" ohm\"\n",
      "print \"Inductance is \",round(L3,2),\" H\"\n",
      "#resistance is calculated wrong in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Unknown resistance is  4865.0  ohm\n",
        "Inductance is  0.27  H\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.6 - page : 8-28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Cx,Rx and D\n",
      "#given data :\n",
      "f=1000 #in Hz\n",
      "R2=20000 # in ohm\n",
      "R3=1.2*10**3 # in ohm\n",
      "C3=300*10**-12 # in F\n",
      "C4=0.05*10**-6 # in F\n",
      "Rx=(R2*C3)/C4 # in ohm\n",
      "print \"Unknown resistance, Rx = \",Rx, \" ohm\"\n",
      "Cx=((R3*C4)/R2)*10**6 \n",
      "print \"Unknown capacitance, Cx = \",Cx,\" micro F\"\n",
      "w=2*f*math.pi \n",
      "D=w*Cx*10**-6*Rx\n",
      "print \"Dissipation factor, D = %.2E\" %D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Unknown resistance, Rx =  120.0  ohm\n",
        "Unknown capacitance, Cx =  0.003  micro F\n",
        "Dissipation factor, D = 2.26E-03\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.7 - page : 8-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Resistance and capacitance\n",
      "#given data :\n",
      "C2=106*10**-12 # in F\n",
      "C4=0.6*10**-6 # in F\n",
      "R4=1000/math.pi # in ohm\n",
      "R3=250 # in ohm\n",
      "R1=(C4/C2)*R3\n",
      "print \" Resistance, R1 = %.2E\" %R1,\" ohm\"\n",
      "C1=(R4/R3)*C2*10**6 \n",
      "print \"Capacitance, C1 = \",round(C1*10**6),\" micro F\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Resistance, R1 = 1.42E+06  ohm\n",
        "Capacitance, C1 =  135.0  micro F\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.8 - page : 8-30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Resistance and capacitance\n",
      "#given data :\n",
      "R1=3.1 # in kohm\n",
      "C1=5.2 #in micro F\n",
      "R2=25 #in kohm\n",
      "R4=100 #in kohm\n",
      "f=2.5*10**3 #in Hz\n",
      "w=2*math.pi*f*10**-3 \n",
      "R3=(R4/R2)*(R1+(1/(w**2*R1*C1**2))) \n",
      "print \"Resistance, R3 = \",round(R3,1),\" kohm\"\n",
      "C3=((R4/R2)-(R1/R3))*C1 \n",
      "print \"Capacitance, C3 = \",round(C3,1), \"pF\"\n",
      "# answer is wrong in book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Resistance, R3 =  12.4  kohm\n",
        "Capacitance, C3 =  19.5 pF\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.9 - page : 8-31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Inductance and capacitance\n",
      "#given data :\n",
      "F1=1.5 #in MHz\n",
      "C1=650 #in pF\n",
      "F2=3 #in MHz\n",
      "C2=150 #in pF\n",
      "Cd=(C1-(4*C2))/3 \n",
      "print \"Capacitance, Cd = \",Cd, \"pF\"\n",
      "L=(1/(4*math.pi**2*F1**2*((C1*10**-12)+(C2*10**-12))))*10**-6 \n",
      "print \"Inductance, L = \",round(L,2),\" micro H\"\n",
      "# Answer wrong in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance, Cd =  16 pF\n",
        "Inductance, L =  14.07  micro H\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.10 - page : 8-32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Q\n",
      "#given data \n",
      "rsh=0.02 \n",
      "r=10 # in ohm\n",
      "f=1 #in MHz\n",
      "c=65 #in pF\n",
      "L=(1/((2*math.pi*f*10**6)**2*c*10**-12))*10**3 \n",
      "qact=((1/(2*math.pi*f*10**6*c*10**-12*r))) #actual q factor\n",
      "qm=(1/(2*math.pi*c*10**-12*f*10**6*(r+rsh))) #measured q factor\n",
      "per=((qact-qm)/qact)*100 #percentage error \n",
      "print \"Percentage error is \",round(per,3), \" %\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage error is  0.2  %\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.11 - page : 8-32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# capacitance\n",
      "#given data :\n",
      "F1=3 #in MHz\n",
      "C1=400 #in pico-farad\n",
      "F2=6 #in MHz\n",
      "C2=120 #in pico-farad\n",
      "Cd=(4*C2-C1)/3 \n",
      "print \"Self capacitance, Cd = \",Cd, \" pF\"\n",
      "# Answer wrong in the textbook."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Self capacitance, Cd =  26  pF\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.12 - page : 8-33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# capacitance\n",
      "#given data :\n",
      "F1=2.0 #in MHz\n",
      "C1=450 #in pF\n",
      "F2=5 #in MHz\n",
      "C2=60 #in pF\n",
      "ratio=F2/F1 \n",
      "#1/sqrt(C2+Cd)=ratio/sqrt(C1+Cd)\n",
      "Cd=(C1-(ratio**2*C2))/5.25 \n",
      "print \"Self capacitance, Cd = \",round(Cd,2), \" pF\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Self capacitance, Cd =  14.29  pF\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6.13 - page : 8-33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# capacitance\n",
      "#given data :\n",
      "F1=8 #in MHz\n",
      "C1=120 #in pF\n",
      "F2=12 #in MHz\n",
      "C2=40 #in pF\n",
      "ratio=F1/F2 \n",
      "#1/sqrt(C2+Cd)=ratio/sqrt(C1+Cd)\n",
      "Cd=((4*C1-9*C2)/5) \n",
      "print \"Self capacitance, Cd = \", Cd,\" pF\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Self capacitance, Cd =  24  pF\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Q.5 - page : 8-35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Lx and Rx\n",
      "#given data :\n",
      "r1=28.5 #in ohm\n",
      "L1=52.6 #in mH\n",
      "R2=1.68 #in ohm\n",
      "R3=80 #in ohm\n",
      "R4=R3 # in ohm\n",
      "Lx=(R3/R4)*L1 #inductance in mH\n",
      "Rx=r1*(R3/R4)-R2 #in ohm\n",
      "print \"Unknown resistance, Rx = \",Rx,\" ohm\"\n",
      "print \"Unknown inductance, Lx = \", Lx,\" mH\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Unknown resistance, Rx =  26.82  ohm\n",
        "Unknown inductance, Lx =  52.6  mH\n"
       ]
      }
     ],
     "prompt_number": 50
    }
   ],
   "metadata": {}
  }
 ]
}