{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 8: INDUCTANCE AND CAPACITANCE MEASUREMENTS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-1, Page Number: 194"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Since the measured terminal resistance is 134 kilo ohm, the circuit must consist of a\n",
      "0.005 micro farad capacitor connected in parallel with a 134 kilo ohm resistor\n",
      "For a series connected circuit, the terminal resistance will be much higher than 134 kilo ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "C=0.005*10**-6                     #in farad\n",
    "Rs=8*10**3                         #in ohm\n",
    "f=1*10**3                          #in Hz\n",
    "\n",
    "#Calculations\n",
    "\n",
    "Xs=1/(2*math.pi*f*C)               #Capacitvie Reactance  in ohm\n",
    "Rp=(Rs**2+Xs**2)/Rs                #in ohm\n",
    "Xp=(Rs**2+Xs**2)/Xs                #in ohm\n",
    "Cp=1/(2*math.pi*f*Xp)              #in farad\n",
    "\n",
    "#Result\n",
    "\n",
    "print \"Since the measured terminal resistance is 134 kilo ohm, the circuit must consist of a\"\n",
    "print round(Cp*10**6,3),\"micro farad capacitor connected in parallel with a\",int(Rp/1000),\"kilo ohm resistor\"\n",
    "print \"For a series connected circuit, the terminal resistance will be much higher than 134 kilo ohm\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-2, Page Number: 199"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For R3/R4=100:1, Cx= 10.0 micro farad\n",
      "For R3/R4=1:100, Cx= 0.001 micro farad\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "C1=0.1*10**-6                   #in farad\n",
    "\n",
    "#Calculation\n",
    "\n",
    "#For R3:R4=100:1\n",
    "ratio=100.0/1   \n",
    "Cx=C1*ratio                     #in farad  \n",
    "\n",
    "print \"For R3/R4=100:1, Cx=\",round(Cx*10**6),\"micro farad\"\n",
    "\n",
    "#For R3:R4=1/100\n",
    "ratio=1.0/100.0\n",
    "Cx=C1*ratio                     #in farad \n",
    "print \"For R3/R4=1:100, Cx=\",round(Cx*10**6,3),\"micro farad\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-3, Page Number: 202"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cs= 0.272 micro farad\n",
      "Rs= 183.8 ohm\n",
      "Disspiation factor(D)= 0.031\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "R3=10*10**3               #in ohm\n",
    "f=100                     #in Hz\n",
    "R1=125                    #in ohm\n",
    "R4=14.7*10**3             #in ohm \n",
    "C1=0.4*10**-6             #in farad  \n",
    "\n",
    "#Calculations \n",
    "Cs=C1*R3/R4               #in farad\n",
    "Rs=R1*R4/R3               #in ohm\n",
    "D=2*math.pi*f*Cs*Rs       #Dissipation factor  \n",
    "\n",
    "#Results\n",
    "print \"Cs=\",round(Cs*10**6,3),\"micro farad\"\n",
    "print \"Rs=\",round(Rs,1),\"ohm\"\n",
    "print \"Disspiation factor(D)=\",round(D,3)\n",
    "\n",
    "#****************************Note**********************************************\n",
    "# The value for C1 as per the problem statement is 0.4 micro farad\n",
    "#But while calculating,  0.1 micro farad value has been considered  in text book\n",
    "#C1 is taken to be 0.4 microfarad\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-4, Page Number: 204"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cp= 0.068 micro farad\n",
      "Rp= 551.3 kilo ohm\n",
      "Dissipation Factor(D)= 4.24e-02\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "C1=0.1*10**-6                     #in farad\n",
    "R3=10*10**3                       #in ohm\n",
    "R1=375*10**3                      #in ohm  \n",
    "R4=14.7*10**3                     #in ohm\n",
    "f=100                             #in farad\n",
    "\n",
    "#Calculations\n",
    "Cp=C1*R3/R4                       #in farad \n",
    "Rp=R1*R4/R3                       #in resistance\n",
    "D=1/(2*math.pi*f*Cp*Rp)           #Dissipation factor  \n",
    "\n",
    "#Results\n",
    "print \"Cp=\",round(Cp*10**6,3),\"micro farad\"\n",
    "print \"Rp=\",round(Rp/1000,1),\"kilo ohm\"\n",
    "print \"Dissipation Factor(D)=\",'%.2e' % D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-5, Page Number: 204"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rp= 2.98 mega ohm\n",
      "Cp= 0.068 micro farad\n",
      "R4= 14.7 kilo ohm\n",
      "R1= 2.03 mega ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "#From Example 8-3,\n",
    "Cs=0.068*10**-6              #in farad\n",
    "Rs=183.8                     #in ohm\n",
    "f=100                        #in Hz \n",
    "R3=10*10**3                  #in ohm\n",
    "R1=10*10**3                  #in ohm  \n",
    "\n",
    "#Calculations\n",
    "Xs=1/(2*math.pi*f*Cs)        #in ohm\n",
    "Rp=(Rs**2+Xs**2)/Rs          #in ohm  \n",
    "Xp=(Rs**2+Xs**2)/Xs          #in ohm\n",
    "Cp=1/(2*math.pi*f*Xp)        #in farad  \n",
    "R4=C1*R3/Cp                  #in ohm \n",
    "R1=R3*Rp/R4                  #in ohm\n",
    "\n",
    "\n",
    "#Results\n",
    "\n",
    "print \"Rp=\",round(Rp*10**-6,2),\"mega ohm\"\n",
    "print \"Cp=\",round(Cp*10**6,3),\"micro farad\"\n",
    "print \"R4=\",round(R4/1000,1),\"kilo ohm\"\n",
    "print \"R1=\",round(R1*10**-6,2),\"mega ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-6, Page Number: 207"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R3= 1.0 kilo ohm\n",
      "R1= 54.0 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "L1=100*10**-3                   #in henry\n",
    "R4=5*10**3                      #in ohm\n",
    "Ls=500*10**-3                   #in henry\n",
    "Rs=270                          #in ohm \n",
    "\n",
    "#Calculations\n",
    "R3=R4*L1/Ls                     #in ohm  \n",
    "R1=Rs*R3/R4                     #in ohm\n",
    "\n",
    "#Results\n",
    "print \"R3=\",R3/1000,\"kilo ohm\"\n",
    "print \"R1=\",R1,\"ohm\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-7, Page Number: 209"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ls= 63.0 mH\n",
      "Rs= 1.34 kilo ohm\n",
      "Q factor(Q)= 0.03\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "C3=0.1*10**-6                  #in farad\n",
    "R1=1.26*10**3                  #in ohm\n",
    "R3=470                         #in ohm\n",
    "R4=500                         #in ohm\n",
    "f=100                          #in Hz\n",
    "\n",
    "#Calculations\n",
    "Ls=C3*R1*R4                    #in henry \n",
    "Rs=R1*R4/R3                    #in ohm \n",
    "Q=(2*math.pi*f*Ls)/Rs\n",
    "\n",
    "#Results\n",
    "\n",
    "print \"Ls=\",round(Ls*1000),\"mH\"\n",
    "print \"Rs=\",round(Rs/1000,2),\"kilo ohm\"\n",
    "print \"Q factor(Q)=\",round(Q,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-8, Page Number: 210"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Lp= 63.0 mH\n",
      "Rp= 8.4 kilo ohm\n",
      "Q factor(Q)= 212.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "C3=0.1*10**-6               #in farad\n",
    "R1=1.26*10**3               #in ohm\n",
    "R3=75                       #in ohm\n",
    "R4=500                      #in ohm\n",
    "f=100                       #in Hz\n",
    "\n",
    "#Calculations\n",
    "\n",
    "Lp=C3*R1*R4                 #in henry \n",
    "Rp=R1*R4/R3                 #in ohm\n",
    "Q=Rp/(2*math.pi*f*Lp)       #Quality factor \n",
    "\n",
    "#Results\n",
    "\n",
    "print \"Lp=\",round(Lp*1000),\"mH\"\n",
    "print \"Rp=\",round(Rp/1000,2),\"kilo ohm\"\n",
    "print \"Q factor(Q)=\",round(Q)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-9, Page Number: 211"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rs= 0.187 ohm\n",
      "Ls= 63.0 mH\n",
      "R1= 1.26 kilo ohm\n",
      "R3= 3.38 mega ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "Lp=63*10**-3                  #in henry\n",
    "Rp=8.4*10**3                  #in ohm \n",
    "f=100                         #in Hz\n",
    "\n",
    "#Calculations\n",
    "Xp=2*math.pi*f*Lp             #in ohm            \n",
    "Rs=Rp*Xp**2/(Xp**2+Rp**2)     #in ohm\n",
    "Xs=Xp*Rp**2/(Xp**2+Rp**2)     #in ohm\n",
    "Ls=Xs/(2*math.pi*f)           #in henry\n",
    "\n",
    "R1=Ls/(C3*R4)                 #in ohm  \n",
    "R3=R1*R4/Rs                   #in ohm \n",
    "\n",
    "#Results\n",
    "\n",
    "print \"Rs=\",round(Rs,3),\"ohm\"\n",
    "print \"Ls=\",round(Ls*10**3),\"mH\"\n",
    "print \"R1=\",round(R1/1000,2),\"kilo ohm\"\n",
    "print \"R3=\",round(R3*10**-6,2),\"mega ohm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-10, Page Number: 214"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cx= 200.0 pF\n",
      "Rx= 30.0 mega ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "R1=369.3*10**3                   #in ohm\n",
    "R3=10*10**3                      #in ohm    \n",
    "R4=14.66*10**3                   #in ohm \n",
    "Rp=553.1*10**3                   #in  ohm\n",
    "C1=0.1*10**-6                    #in farad \n",
    "Cp=0.068*10**-6                  #in farad\n",
    "\n",
    "#Calcultions\n",
    "Ceq=round(C1*R3/R4,10)           #Cx+Cp, Equivalent parallel capacitance, in farad\n",
    "Cx=Ceq-Cp                        #in farad\n",
    "\n",
    "Req=R1*R4/R3                     #Equivalent resitance in  ohm    \n",
    "\n",
    "Rx=1/(1/Req-1/Rp)                #in ohm\n",
    "\n",
    "#Results\n",
    "\n",
    "print \"Cx=\",round(Cx*10**12),\"pF\"\n",
    "print \"Rx=\",round(Rx*10**-8,1)*100,\"mega ohm\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8-11, Page Number: 221"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When R=5 ohm, Xl=100 ohm\n",
      "Vl= 2.0 V\n",
      "Q= 20.0\n",
      "\n",
      "When R=10 ohm, Xl=100 ohm\n",
      "V= 1.0\n",
      "Q= 10.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "E=100*10**-3             #in V\n",
    "R=5                      #in ohm\n",
    "Xl=100                   #in ohm\n",
    "Xc=100                   #in ohm\n",
    "\n",
    "#Calculations\n",
    "I=E/R                    #At resonance, I is dependent only on R(A)\n",
    "\n",
    "Vl=I*Xl                  #in V\n",
    "Vc=I*Xc                  #in V\n",
    "Q=Vl/E                   #Quality Factor  \n",
    "print \"When R=5 ohm, Xl=100 ohm\"\n",
    "print \"Vl=\",Vl,\"V\"\n",
    "print \"Q=\",Q\n",
    "#For the second coil\n",
    "R=10                     #in ohm \n",
    "Xl=100                   #in ohm\n",
    "Xc=100                   #in ohm  \n",
    "\n",
    "I=E/R                    #At resonance, I is dependent only on R(A)\n",
    "Vl=I*Xl                  #in V\n",
    "Vc=I*Xc                  #in V\n",
    "Q=Vl/E                   #Quality Factor  \n",
    "\n",
    "print\n",
    "print \"When R=10 ohm, Xl=100 ohm\"\n",
    "print \"V=\",Vl\n",
    "print \"Q=\",Q"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exanoke 8-12, Page Number: 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "L= 110.0 micro henry\n",
      "R= 8.8 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable Declaration\n",
    "\n",
    "C=147*10**-12                  #in farad\n",
    "f=1.25*10**6                   #in Hz\n",
    "Q=98.0                         #Q Factor\n",
    "\n",
    "#Calculations \n",
    "L=1/(C*(2*math.pi*f)**2)       #in henry     \n",
    "R=(2*math.pi*f*L)/Q            #in ohm\n",
    "\n",
    "#Results\n",
    "print \"L=\",round(L*10**6),\"micro henry\"\n",
    "print \"R=\",round(R,1),\"ohm\""
   ]
  }
 ],
 "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}