{
 "metadata": {
  "name": "",
  "signature": "sha256:a9ed36d73f9d154839d703d9a4c0fe9425b38f6baf4e4351a575d82599eff181"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1: SEMICONDUCTORS,DIODE AND DIODE CIRCUITS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page number 5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "A=6.022*10**23     #avagadro's number(/m^3)\n",
      "d=2.7*10**6        #density of aluminium conductor(g/m^3)\n",
      "a=26.98            # atomic weight aluminium conductor(g/g-atom)\n",
      "D=10**4.           #current density(A/m^2)\n",
      "e=1.6*10**-19      #electronic charge(C)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "n=A*d/a            #number of atoms(n/m^3)\n",
      "\n",
      "#Part b\n",
      "u=D/(n*e)          #drift velocity (m/s)\n",
      "\n",
      "#Results\n",
      "print \"number of atoms per cubic meter is \",round(n/1e+28,3),\"*10^28 /m^3\"\n",
      "print \"drift velocity is\",round(u/1e-6,2),\"*10^-6 m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "number of atoms per cubic meter is  6.026 *10^28 /m^3\n",
        "drift velocity is 1.04 *10^-6 m/s\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page number 6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "n=10**23        #number of electrons(n/m^3)\n",
      "e=1.6*10**-19   #electronic charge(C) \n",
      "u=0.4           #mobility(m^2/Vs)           \n",
      "a=10**-7        #cross sectional area(m^2) \n",
      "l=15*10**-2     #conductor length(m)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "G=n*e*u         #conductivity(S/m)\n",
      "\n",
      "#Part b\n",
      "R=l/(a*G)       #resistance(ohm)\n",
      "\n",
      "#Results\n",
      "print\"conductivity of the conductor is\",round((G/1E+3),1),\"*10**3 S/m\"\n",
      "print\"resistance of the conductor is\",round(R,1),\"ohm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "conductivity of the conductor is 6.4 *10**3 S/m\n",
        "resistance of the conductor is 234.4 ohm\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3, Page number 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "A=6.022*10**23   #avagadro's number\n",
      "d=5.32*10**6     #density of Ge at 300k(g/m^3)\n",
      "a=72.60          #atomic weight of Ge(g/g-atom)\n",
      "e=1.6*10**-19    #electronic charge(C)\n",
      "ni=2.4*10**19    #intrinsic concentration(electron-hole pairs/m^3)\n",
      "un=0.39          #electron mobility(m^2/V.s)\n",
      "up=0.19          #hole mobility(m^2/V.s)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "nA=A*d/a         #number of atoms(nA/m^3)using avagadro's law\n",
      "x=nA/ni          #Germanium atoms/electron hole pair\n",
      "\n",
      "#Part b\n",
      "g=(un+up)*e*ni   #intrinsic conductivity(S/m)\n",
      "r=1/g            #intrinsic resistivity(ohm.m)\n",
      "\n",
      "#Results\n",
      "print\"the relative concentration of Ge and electron hole pairs is\",round((x/1E9),2),\"*10^9 atoms/electron-hole pair\"\n",
      "print\"the intrinsic resistivity of Ge is\",round(r,3),\"ohm.m\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the relative concentration of Ge and electron hole pairs is 1.84 *10^9 atoms/electron-hole pair\n",
        "the intrinsic resistivity of Ge is 0.449 ohm.m\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4,Page number 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "ni=1.5*10**16    #intrinsic concentration(electron-hole pairs/m^3)\n",
      "n=4.99*10**28    #number of Si atoms(atoms/m^3)\n",
      "un=0.13          #electron mobility(m^2/V.s)\n",
      "up=0.05          #hole mobility(m^2/V.s)\n",
      "e=1.6*10**-19    #electronic charge(c)\n",
      "\n",
      "#Calculation\n",
      "#Part a\n",
      "g=e*ni*(un+up)  #intrinsic conductivity(S/m)\n",
      "r=1/g           #interinsic resistivity(ohm.m)\n",
      "Nd=n/10**8      #doped silicon(atoms/m^3)=nn,majority carriers\n",
      "pn=ni**2/Nd     #minority carrier density(holes/m^3)\n",
      "\n",
      "#Part b\n",
      "k=e*un*Nd    #conductivity(S/m)\n",
      "             #using Nd in place of nn as Nd=nn\n",
      "rho=1/k      #resistivity(ohm.m)\n",
      "\n",
      "#Results\n",
      "print\"the minority carrier density of Si is\",round(pn/1e+11,2),\"*10^11 holes/m^3\"\n",
      "print\"the resistivity of Si is\",round((rho/1E-2),2),\"*10**-2 ohm.m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the minority carrier density of Si is 4.51 *10^11 holes/m^3\n",
        "the resistivity of Si is 9.63 *10**-2 ohm.m\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5,Page number 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vo=0.7                  #contact potential(V)\n",
      "Vf=0.4                  #forward biasing voltage(V)    \n",
      "\n",
      "#Calculation\n",
      "x=math.exp(-20*(Vo-Vf))/math.exp(-20*Vo)   #increase in probability of majority carriers\n",
      "\n",
      "#Result\n",
      "print\"increase in probability of majority carriers is\",round(x),\"times\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "increase in probability of majority carriers is 2981.0 times\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6,Page number 18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "I=10    #Ge diode carries current(mA)\n",
      "V=0.2   #forward bias voltage(V)\n",
      "\n",
      "#Calculation\n",
      "#Part a\n",
      "Is=I/(math.expm1(40*V)-1)      #reverse current(mA)\n",
      "\n",
      "#part b\n",
      "I1=1*10**-3                     #current(mA)                     \n",
      "V1=(math.log((I1/Is)+1))/40      #voltage(V)\n",
      "I2=100*10**-3                  #current(mA) \n",
      "V2=(math.log((I2/Is)+1))/40     #voltage(V) \n",
      "\n",
      "#Part c\n",
      "Is1=4*Is                 #reverse saturation current doubles for every 10 degree celcius temp rise,so for 20 degree rise it will be 4 timese/   \n",
      "x=37.44                  #let x=e/kT\n",
      "I3=Is1*(math.expm1(x*V)) #current when temp doubles(mA)\n",
      "\n",
      "#Results\n",
      "print\"the reverse current is\",round(Is/1e-3,3),\"mA\"  #incorrect units given in the textbook\n",
      "print\"bias voltages are\",round(V1,3),\"V and\", round(V2,3),\"V resp\"\n",
      "print\"Is at 20 degree is\",round(Is1/1e-3,2),\"uA and diode current at 0.2 V is\",round(I3,2),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the reverse current is 3.357 mA\n",
        "bias voltages are 0.007 V and 0.086 V resp\n",
        "Is at 20 degree is 13.43 uA and diode current at 0.2 V is 23.97 mA\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7,Page number 21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V=3.            #Voltage(V)\n",
      "Req=300.        #total resistance as per circuit(ohm)\n",
      "Rfa=20           #forward resistance(ohm)    \n",
      "Vt=0.7          #Thevinine's voltage(V)\n",
      "Rfb=0            #forward resistance(ohm)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "I=V/Req          #current(A)\n",
      "\n",
      "#Part b\n",
      "Id=(V-Vt)/Req   #diode current(mA)\n",
      "\n",
      "#Part c\n",
      "Rf=20               #forward resistance(ohms) \n",
      "Id1=(V-Vt)/(Req+Rfa) #diode current(mA)\n",
      "\n",
      "#Results\n",
      "print\"current in this case is\",round(I,2),\"A\"\n",
      "print\"diode current is\",round((Id/1E-3),2),\"mA\"\n",
      "print\"diode current is\",round((Id1/1E-3),2),\"mA\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "current in this case is 0.01 A\n",
        "diode current is 7.67 mA\n",
        "diode current is 7.19 mA\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.9,Page number 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vx=1.4              #voltage at point X(V) \n",
      "Vt=0.7              #diode voltage(V)\n",
      "Vcc=5               #cathode voltage(V)  \n",
      "R=1                 #circuit resistance(ohm) \n",
      "Vs=Vx-Vt            #supply voltage(V)\n",
      "\n",
      "#Calculations\n",
      "I1=(Vcc-Vt-Vs)/R      #current throgh D1(mA) for 0<Vs<0.7\n",
      "I2=0                  #current through D2 and D3\n",
      "I1=I2=(Vcc-Vt-Vs)/R   #for Vs>0.7 as D2 and D3 conducts\n",
      "\n",
      "#Results\n",
      "print\"I1 for 0<Vs<0.7 is\",I1,\"mA\"\n",
      "print\"I2 for 0<Vs<0.7 is\",I2,\"mA\"\n",
      "print\"I1 and I2 for Vs>0.7 is\",I1,\"mA\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I1 for 0<Vs<0.7 is 3.6 mA\n",
        "I2 for 0<Vs<0.7 is 0 mA\n",
        "I1 and I2 for Vs>0.7 is 3.6 mA\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11,Page number 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vz=100          #zener voltage(V)\n",
      "Rz=25           #diode resistance(ohm)\n",
      "Il=0.05         #load current(A)\n",
      "Iz=0.01         #zener diode current(A)\n",
      "Rs=250          #supply resistance(ohm)\n",
      "\n",
      "#Calculations\n",
      "Vl=Vz+(Iz*Rz)     #load voltage(V)\n",
      "Vs=Vl+(Il+Iz)*Rs  #supply voltage(V)\n",
      "VL=Vl*1.01        #increase in Vl(V)\n",
      "IZ=(VL-Vz)/Rz     #increase in zener current\n",
      "VS=Vl+(Il+IZ)*Rs  #increase in supply voltage(V)\n",
      "Vss=(VS-Vs)/Vs    #%increase in supply voltage(V)\n",
      "P=Il*VL           #power consumed(W) \n",
      "\n",
      "#Results\n",
      "print\"load voltage is\",Vl,\"V\"\n",
      "print\"supply voltage is\",Vs,\"V\"\n",
      "print\"increase in supply voltage is\",VS,\"V\"\n",
      "print\"power consumed is\",round(P,2),\"W\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " load voltage is 100.25 V\n",
        "supply voltage is 115.25 V\n",
        "increase in supply voltage is 125.275 V\n",
        "power consumed is 5.06 W\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.12,Page number 25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vbb=5           #bias voltage(V)\n",
      "Rl=1            #resistance(ohm)\n",
      "Id=4.4          #from the figure(mA)\n",
      "\n",
      "#Part a\n",
      "i=Vbb/Rl        #load line intercepts the Id axis at i(mA)\n",
      "Vl=Id*Rl        #load voltage(V)\n",
      "\n",
      "#Part b\n",
      "Vd=Vbb-Vl       #diode voltage(V)\n",
      "P=Vd*Id         #power absorbed in diode(mW)\n",
      "\n",
      "#Part c        \n",
      "Ida=1.42         #diode current(mA)for 2V\n",
      "Idb=7.35         #diode current(mA)for 8V\n",
      "\n",
      "#Part d\n",
      "Idc=8.7         #diode current(mA)for Rl=0.5k ohm \n",
      "Idd=2.2         #diode current(mA)for Rl=2k ohm\n",
      "\n",
      "#Results\n",
      "print\"diode current is\",Id,\"mA and voltage across the load is\",Vl,\"V\"\n",
      "print\"power absorbed in diode is\",P,\"mW\"\n",
      "print\"diode current for Vbb=2V is\",Ida,\"mA\",\"and for Vbb=8V is\",Idb,\"mA\"\n",
      "print\"diode current for Rl=0.5kohm is\",Idc,\"mA\",\"and for Rl=2kohm is\",Idd,\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "diode current is 4.4 mA and voltage across the load is 4.4 V\n",
        "power absorbed in diode is 2.64 mW\n",
        "diode current for Vbb=2V is 1.42 mA and for Vbb=8V is 7.35 mA\n",
        "diode current for Rl=0.5kohm is 8.7 mA and for Rl=2kohm is 2.2 mA\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13,Page number 38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "T=300             #temperature(k)\n",
      "Ig=100*10**-3     #current(mA)\n",
      "Is=1*10**-9       #current(nA)\n",
      "x=0.0259          #x=kT/e\n",
      "\n",
      "#Calculations\n",
      "Voc=x*math.log(Ig/Is+1)     #as Voc=kT/e*ln((Ig/Is)+1) where ln((Ig/Is)+1)=18.42 after solving \n",
      "Isc=Ig\n",
      "\n",
      "#Result\n",
      "print\"for a solar cell Voc is\",round(Voc,3),\"V and Isc is\",round(Isc/1E-3),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "for a solar cell Voc is 0.477 V and Isc is 100.0 mA\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14,Page number 38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Idc=0.1           #dc current(A)\n",
      "Rf=0.5            #forward resistance(ohms)\n",
      "Rl=20             #load resistance(ohm)\n",
      "Rs=1              #secondary resistance of transformer(ohm)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vdc=Idc*Rl                       #dc voltage(V)\n",
      "Vm=(math.pi/2)*(Vdc+Idc*(Rs+Rf)) #mean voltage(V)\n",
      "Vrms=Vm/math.sqrt(2)             #rms value of voltage(V)   \n",
      "\n",
      "#Part b\n",
      "Pdc=Idc**2*Rl                  #dc power supplied to the load\n",
      "\n",
      "#Part c\n",
      "PIV=2*Vm                       #PIV rating for each diode(V)\n",
      "\n",
      "#Part d\n",
      "Im=(math.pi/2)*Idc            #peak value of current(mA)\n",
      "Irms=Im/math.sqrt(2)          #rms calue of current(A)\n",
      "Pac=Irms**2*(Rs+Rf+Rl)        #ac power input(W)\n",
      "\n",
      "#Part e\n",
      "eta=(Pdc/Pac)*100             #conversion efficiency\n",
      "\n",
      "#Part f\n",
      "Vr=((Rs+Rf)/Rl)*100           #voltage regulation(V)\n",
      "\n",
      "#results\n",
      "print\"rms value of voltage is\",round(Vrms,2),\"V\"\n",
      "print\"dc power supplied to load is\",Pdc,\"W\"\n",
      "print\"PIV rating for each diode\",round(PIV,2),\"V\"\n",
      "print\"ac input power is\",round(Pac,3),\"W\"\n",
      "print\"conversion efficiency\",round(eta,1),\"%\"\n",
      "print\"voltage regulation\",Vr,\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms value of voltage is 2.39 V\n",
        "dc power supplied to load is 0.2 W\n",
        "PIV rating for each diode 6.75 V\n",
        "ac input power is 0.265 W\n",
        "conversion efficiency 75.4 %\n",
        "voltage regulation 7.5 %\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15,Page number 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from scipy import integrate\n",
      "\n",
      "#Variable declaration\n",
      "Vt=1                 \n",
      "Vl=12\n",
      "Vm=63.63                      #peak voltage(V) as Vm=sqr root of 2*45\n",
      "Idc=8.                        #charging current(A)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "theta1=math.degrees(math.asin((Vt+Vl)/Vm))\n",
      "theta2=180-theta1\n",
      "Rl=((2*Vm*math.cos(theta1))-(2*(math.pi-2*theta1)*(Vt+Vl)))/(Idc*math.pi)\n",
      "\n",
      "#Part b\n",
      "wt = lambda wt: (((((math.sqrt(2)*45*math.sin(wt))-(Vt+Vl))/Rl)*wt)**2)\n",
      "integ,err = integrate.quad(wt, theta1 , theta2)\n",
      "print integ\n",
      "Irms = (integ/math.pi)**0.5\n",
      "Pl=Irms**2*Rl               #power loss in resistance(W)\n",
      "\n",
      "#Part c\n",
      "P=Vl*Idc                   #power supplied to battery(W)\n",
      "\n",
      "#results\n",
      "print\"Resistance to be added is\",round(Rl,2),\"Ohms\"\n",
      "print\"\",Pl\n",
      "print\"power supplied to battery is\",P,\"W\"\n",
      "print\"\",Irms  "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "5703935.44277\n",
        "Resistance to be added is 24.75 Ohms\n",
        " 44936628.7032\n",
        "power supplied to battery is 96.0 W\n",
        " 1347.44908683\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16,Page number 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Rf=5                    #forward resistance(ohms)\n",
      "Vo=20                   #output voltage(V)\n",
      "Rs=10                   #secondary resistance of transformer(ohm)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Idc=0.1                 #dc current(A)                  \n",
      "Vm=Vo*(math.sqrt(2))    #mean voltage(V)\n",
      "Vdc=(2*Vm/(math.pi))-Idc*(Rs+2*Rf)  #dc voltage(V)\n",
      "\n",
      "#Part b\n",
      "Idc1=0.2                #full load dc current(A)\n",
      "Vdc2=((2*(math.sqrt(2))*Vo)/(math.pi))-Idc1*(Rs+2*Rf) #full load dc voltage(V)\n",
      "Rl=Vdc2/Idc1              #load resistance(ohm)\n",
      "x=((2*Rf+Rs)/Rl)*100      #% regulation \n",
      "\n",
      "#Part c\n",
      "Idc=0.2                  #dc current(A)\n",
      "Im=(math.pi)*Idc/2       #peak current(mA)\n",
      "Ilrms=Im/math.sqrt(2)    #rms current(mA)\n",
      "Vlrms=Ilrms*Rl           #load rms voltage(V) \n",
      "\n",
      "#Part d\n",
      "Vldc=14                               #load dc voltage(V)\n",
      "Vlacrms=math.sqrt(Vlrms**2-Vldc**2)   #rms value of ac component(V)\n",
      "\n",
      "#Results\n",
      "print\"dc voltage\",round(Vdc),\"V\"\n",
      "print\"regulation is\",round(x,2),\"%\"\n",
      "print\"rms value of output voltage at dc load current is\",round(Vlrms,2),\"V\"\n",
      "print\"rms value of ac component of voltage\",round(Vlacrms,2),\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dc voltage 16.0 V\n",
        "regulation is 28.56 %\n",
        "rms value of output voltage at dc load current is 15.56 V\n",
        "rms value of ac component of voltage 6.78 V\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.17,Page number 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vh=60.           #higher output voltage(V)\n",
      "Vl=45.           #lower output voltage(V)  \n",
      "fz=50.           #frequency(Hz)\n",
      "Vr=15.           #peak to peak ripple voltage(V)\n",
      "Rl=600.          #resistance(ohms)\n",
      "     \n",
      "#Calculations\n",
      "Vldc=(Vh+Vl)/2   #avg load dc voltage(V) as voltage drops from 60 to 45\n",
      "Idc=Vldc/Rl      #dc current(A)\n",
      "T=1/fz           #discharging time(ms)\n",
      "C=(Idc*T)/Vr     #linear discharge rate(uF)\n",
      "C1=C*2           #new capacitance(uF)\n",
      "'''\n",
      "         CVr(p-p)       234Vr(p-p)*10^3\n",
      "Idc = -------------- = ---------------    ----(1)\n",
      "          T                   20\n",
      "    \n",
      "      60+[60-Vr(p-p)     120-Vr(p-p)\n",
      "Idc = --------------- = ------------*1000   ----(2)\n",
      "         2Rl               2*600\n",
      "         \n",
      "Equating equations 1 & 2, we get,    \n",
      "'''\n",
      "\n",
      "Vr1 = (20*120*1000)/(1200*254)\n",
      "Idc1=(Vh-(Vr1/2))/Rl               #dc load current(mA)\n",
      "\n",
      "#Results\n",
      "print\"value of capacitance is\",round(C/1E-6),\"uF\" \n",
      "print\"Vr1 is\",Vr1,\"V\" \n",
      "print\"dc load current Idc is\",round(Idc1/1E-3),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of capacitance is 117.0 uF\n",
        "Vr1 is 7 V\n",
        "dc load current Idc is 95.0 mA\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.18,Page number 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vdc=30                          #dc voltage(V)\n",
      "V1=220                          #source voltage(V)\n",
      "f=50                            #frequency(Hz)\n",
      "Rl=1000                         #load resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "C=100/f*Rl                      #as Vdc/Vr=100\n",
      "Vm=Vdc+(Vr/2)                   #peak voltage(V)\n",
      "V2=Vm/(math.sqrt(2))            #secondary voltage(V)\n",
      "r=V1/V2                         #transformer turn ratio\n",
      "\n",
      "#Results\n",
      "print\"capacitor filtor is\",C,\"uF\"\n",
      "print\"transformer turn ratio is\",round(r,2),\"\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "capacitor filtor is 2000 uF\n",
        "transformer turn ratio is 10.37 \n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.19,Page number 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Idc=60*10**-3                      #dc current(A)\n",
      "Vm=60                              #peak volage(V)\n",
      "f=50                               #frequency(Hz)\n",
      "C=120*10**-6                       #capacitance(F)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Vrms=Idc/(4*(math.sqrt(3))*f*C*Vm) #rms voltage(V)\n",
      "Vr=2*(math.sqrt(3))*Vrms           #ripple factor(V)\n",
      "\n",
      "#Part b\n",
      "Vdc=Vm-(Vr/2)                      #by simplifying\n",
      "\n",
      "#Part c\n",
      "r=(Vrms/Vdc)*100                   #ripple factor\n",
      "\n",
      "#Results\n",
      "print\"ripple factor is\",round(Vr,3),\"Vdc\"\n",
      "print\"dc voltage is\",round(Vdc),\"V\"\n",
      "print\"ripple factor\",round(r,4),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ripple factor is 0.083 Vdc\n",
        "dc voltage is 60.0 V\n",
        "ripple factor 0.0401 %\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.20,Page number 54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "'''     200*1.141      4\n",
      "v1(t)=-------------(1- - cos628t) \n",
      "          3.14         3\n",
      "       200*1.141      800*1.141 \n",
      "v2(t)=----------- - ------------  cos(628t+<(V2/V1))\n",
      "         3.14          3*3.14\n",
      "\n",
      "V2/V1|w=0 =0.8;V2/V1|w=628 =6.43*10^-4 <V2/V1|w=628 =180\n",
      "v2(t)=72.02+0.0538 cos628t\n",
      "'''\n",
      "#Part b\n",
      "vrms=0.0538\n",
      "vdc=math.sqrt(2)*72.02\n",
      "r=vrms/vdc\n",
      "\n",
      "#Results\n",
      "print\"ripple factor is\",round((r/1E-4),2),\"*10**-4\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ripple factor is 5.28 *10**-4\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.24,Page number 61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vz=2                    #zener voltage(V)\n",
      "r1=10                   #resistance after reducing circuit by thevinin(ohms)\n",
      "r2=20                   #resistance after reducing circuit by thevinin(ohms)\n",
      "V1=7.5                  #voltage after circuit reduction(V)\n",
      "V2=15                   #voltage after circuit reduction(V)\n",
      "Rz=100/3                #zener resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "Vab=V2-(((V2-V1)/(r1+r2))*r2)         #thevinin voltage at ab(V)\n",
      "Rth=(Vab*r2)/(Vab+r2)                 #thevinin resistance at ab(ohms)\n",
      "Vd=Vab-Vz                             #diode voltage(V)\n",
      "Id=Vd/(Rth+Rz)                        #diode current(A)\n",
      "\n",
      "#Results\n",
      "print\"diode current is\",round(Id,2),\"A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "diode current is 0.2 A\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.25,Page number 61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vd=0.7                      #diode voltage(V)\n",
      "Ro=18                       #output resistance(k ohms)\n",
      "R1=2                        #diode1 resistance(k ohms)\n",
      "R2=2                        #diode2 resistance(k ohms) \n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "V1=10                       #voltage to D1(V)\n",
      "V2=0                        #voltage to D2(V)\n",
      "Io=(V1-Vd)/(R1+Ro)          #output current(mA)   \n",
      "Vo=Io*Ro                    #output voltage(V)\n",
      "\n",
      "#Part b\n",
      "V1=5                        #voltage to D1(V)\n",
      "V2=0                        #voltage to D2(V)\n",
      "Io=(V1-Vd)/(R1+Ro)          #output current(mA)   \n",
      "Vo1=Io*Ro                   #output voltage(V)\n",
      "\n",
      "#Part c\n",
      "V1=10                      #voltage to D1(V)\n",
      "V2=5                       #voltage to D2(V)\n",
      "Vo=8.37                    #as D1 only conducts,so,Vo is same as in part a\n",
      "Vd1=V2-Vo                  #assume D1 conducts\n",
      "Vo2=8.37                   #D2 does not conduct as as Vd1 is negative\n",
      "\n",
      "#Part d\n",
      "V1=V2=5                  #voltage to D1 and D2(V) \n",
      "Id1=(V1-Vd-Vo)/2         #diode1 current(mA)   \n",
      "Io=Vo/Ro                 #output current(mA)   \n",
      "Vo3=(Ro*(V1-Vd))/(Ro+1)  #output voltage(V)\n",
      "\n",
      "print\"a)output voltage is\",Vo,\"V\"\n",
      "print\"b)output voltage is\",Vo1,\"V\"\n",
      "print\"c)output voltage is\",Vo2,\"V\"\n",
      "print\"d)output voltage is\",round(Vo3,2),\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)output voltage is 8.37 V\n",
        "b)output voltage is 3.87 V\n",
        "c)output voltage is 8.37 V\n",
        "d)output voltage is 4.07 V\n"
       ]
      }
     ],
     "prompt_number": 71
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.26,Page number 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vs=10.                       #supply voltage(V)  \n",
      "Rs=1                         #supply resistane(ohm)\n",
      "Vl=10.                       #load voltage(V)\n",
      "Vi=50.                       #nput voltage(V)\n",
      "Iz=32                        #zener diode current(mA)\n",
      "Is=40                        #supply current(mA) \n",
      "\n",
      "#Calculations\n",
      "#Part a (Rl is min when Iz=0)  \n",
      "Is=(Vi-Vs)/Rs               #source current(mA)       \n",
      "Rlmin=Vl/(Vi-Vs)            #load resistance minimum(ohm) \n",
      "\n",
      "#Part b(Rl is maximum when Iz=32 mA)  \n",
      "Il=(Is-Iz)*10**-3          #load current(A) \n",
      "Rlmax=Vl/Il                #maximum load resistance(k ohms)\n",
      "P=Vl*Iz                    #max diode wattage consumed(mW)\n",
      "\n",
      "#Results\n",
      "print\"Range of Rl is\",round((Rlmin/1E-3),3),\"ohm\",\"to\", round((Rlmax/1E+3),2),\"k ohm\" \n",
      "print \"Il = \",(Il/1E-3),\"*10**-3 A\"\n",
      "print\"max power consumed is\",P,\"mW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Range of Rl is 250.0 ohm to 1.25 k ohm\n",
        "Il =  8.0 *10**-3 A\n",
        "max power consumed is 320.0 mW\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.27,Page number 63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Vz=20           #zener voltage(V)\n",
      "Izmax=50        #maximum zener current(mA)\n",
      "Rz=0            #zener resistance(ohms)\n",
      "Rl=2.           #load resistance(ohm)\n",
      "Vl=20.          #as Vz=Vl(V)\n",
      "Rs=0.25         #source resistance(k ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Il=Vl/Rl           #load current(mA)      \n",
      "Vsmin=(Rs+Rl)*Il   #as Iz is floating so Iz=0\n",
      "\n",
      "#Part b\n",
      "Is=Izmax+Il        #source current(mA)   \n",
      "Vsmax=Vz+(Is*Rs)   #maximum source voltage(V)\n",
      "\n",
      "#Results\n",
      "print\"Vsmin\",round(Vsmin,1),\"V\"\n",
      "print\"Range of input voltage is\",round(Vsmin,1),\"to\", Vsmax,\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Il is 10.0 mA\n",
        "Vsmin 22.5 V\n",
        "Range of input voltage is 22.5 to 35.0 V\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.28,Page number 63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ilmax=100                #load maximum current(mA)\n",
      "Ilmin=0                  #load minimum current(mA)\n",
      "Rz=0.05                  #zener diode resistance(ohms)\n",
      "Rs=10.                    #source resistance(k ohms)\n",
      "Vl=16.015                #load voltage(V)\n",
      "Vl1=16.                  #nominal load voltage(V) \n",
      "Vs=20                    #source voltage(V)\n",
      "Vz=16                    #zener diode voltage(V)\n",
      "\n",
      "#Calculations\n",
      "#Case 1 (i)\n",
      "Iz=(Vl-Vl1)/Rz           #zener current(mA)\n",
      "Is=Iz+Ilmax              #supply current(A)\n",
      "\n",
      "#Case 1 (ii)\n",
      "Is1=(Vs-Vz)/(Rs+Rz)           #supply current(mA)\n",
      "Vl2=Vl1+(Is1*Rz)              #voltage(V)  \n",
      "Vr=((Vl2-Vl)/Vl1)*100        #voltage regulation\n",
      "\n",
      "#Case 2 (i)\n",
      "Vs=18                        #supply voltage(V)\n",
      "Ilmax=0.1                    #load current max(A)\n",
      "Vl=16.005                    #load voltage(V)\n",
      "Iz=(Vl-Vl1)/Rz               #zener current(mA)\n",
      "Is2=Ilmax+Iz                 #supply current(A)\n",
      "\n",
      "#Case 2 (ii)\n",
      "Ilmin=0\n",
      "Iz1=(Vs-Vl1)/(Rs+Rz)        #minimum diode current(mA) \n",
      "Vl=Vl1+(Iz*Rz)              #load voltage at Ilmin(V)          \n",
      "\n",
      "#Part a\n",
      "#Variable declaration\n",
      "Is=0.4                  #supply current(A)\n",
      "Vs=20                    #supply voltage(V)   \n",
      "Vl=16.015               #load voltage(V)\n",
      "Iz=0.3                   #zener current(mA)\n",
      "\n",
      "#Calculations\n",
      "P=Is**2*Rs               #power dissipated by Rs(W)\n",
      "\n",
      "#Part b\n",
      "Pd=Vl*Iz                  #power dissipated(W)\n",
      "Po=(Vs**2)/Rs             #output power(W)\n",
      "\n",
      "print\"maximum power dissipated by Rs is\",P,\"W\"\n",
      "print\"maximum power dissipated by diode is\",round(Pd,3),\"W\"\n",
      "print\"minimum diode current is\",round(Iz1,3),\"A\"\n",
      "print\"voltage regulation is\",round(Vr,2),\"%\"\n",
      "print\"output shorted will be\",Po,\"W\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "maximum power dissipated by Rs is 1.6 W\n",
        "maximum power dissipated by diode is 4.804 W\n",
        "minimum diode current is 0.199 A\n",
        "voltage regulation is 0.03 %\n",
        "output shorted will be 40.0 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.29,Page number 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vrms=20                   #secondary voltage(V)\n",
      "Rs=10                     #Winding resistance(ohm)\n",
      "Rf=5                      #diode has forward resistance(ohms)\n",
      "Idc=2*10**-3              #load current(mA)     \n",
      "\n",
      "#Calculations\n",
      "#Part a \n",
      "Vdc=(Vrms*(math.sqrt(2)))/(math.pi)       #no load Vdc\n",
      "\n",
      "#Part b \n",
      "Vldc=Vdc-(Idc*(Rs+Rf))                    #dc output voltage when load is 20mA\n",
      "\n",
      "#Part c\n",
      "Rl=Vldc/Idc                                #load resistance(ohms)\n",
      "r=((Rs+Rf)/Rl)*100                         #percentage regulation(%)\n",
      "\n",
      "#Part d\n",
      "Im=Idc*(math.pi)                           #peak current(mA)\n",
      "Ilrms=Im/2                                 #rms load current(mA) \n",
      "Vlrms=Ilrms*Rl                             #rms load voltage(V)    \n",
      "Vlrmsac=math.sqrt((Vlrms**2)-(Vldc**2))    #Ripple voltage rms(V)\n",
      "f=50*2                                     #rippLe frequency(Hz)\n",
      "\n",
      "#Part e\n",
      "eta=(((2*(math.pi))**2)/(1+((Rs+Rf)/Rl)))*100  #efficiency\n",
      "\n",
      "#Part f\n",
      "PIV=Vm=Vrms*(math.sqrt(2))                     #peak inverse voltage(V)   \n",
      "\n",
      "#Results\n",
      "print\"no load dc voltage is\",round(Vdc),\"V\" \n",
      "print\"dc output voltage when the load is drawing 20 mA is\",round(Vldc,2),\"V\"\n",
      "print\"percentage regulation at this load is\",round((r/1E-1),2),\"%\"\n",
      "print\"ripple voltage rms is\",round(Vlrmsac,2),\"V and ripple frequency is\",f,\"Hz\"\n",
      "print\"power conversion efficiency is\",round((eta/1E+2),1),\"%\"\n",
      "print\"PIV is\",round(PIV),\"V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "no load dc voltage is 9.0 V\n",
        "dc output voltage when the load is drawing 20 mA is 8.97 V\n",
        "percentage regulation at this load is 3.34 %\n",
        "ripple voltage rms is 10.87 V and ripple frequency is 100 Hz\n",
        "power conversion efficiency is 39.3 %\n",
        "PIV is 28.0 V\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.30,Page number 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vl=24                       #battery voltage(V)\n",
      "Vm=60*(math.sqrt(2))        #peak voltage(V)\n",
      "Ip=2.5                      #peak current(A)\n",
      "c=20                        #charge(Ah)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "theta=math.asin(Vl/Vm)     #angle at which conduction begins\n",
      "Rs=(Vm-Vl)/Ip              #source resistance(ohms) \n",
      "\n",
      "#Part b\n",
      "Idc=(Vm/(math.pi)*Rs)*(math.cos(theta))-(((math.pi)-(2*theta))/2*math.pi)*(Vl/Rs)   #load current(A)\n",
      "T=c/Idc                                                                             #time to deliver 20Ah(h)\n",
      "\n",
      "#Results\n",
      "print\"resistance connected in series is\",round(Rs,1),\"ohm\"\n",
      "print\"time required to deliver a charge of 20 Ah is\",round((T/1E-3),1),\"h\" \n",
      "print\"Idc\",round((Idc/1E+3),2),\"A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resistance connected in series is 24.3 ohm\n",
        "time required to deliver a charge of 20 Ah is 31.9 h\n",
        "Idc 0.63 A\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.32,Page number 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "R=25.                #external resistance(ohms)\n",
      "Vm=200.              #peak value of voltage(V) as vs=200 sinwt\n",
      "Rf=50.               #forward resistance(ohms)\n",
      "\n",
      "#Calculations\n",
      "#Part a \n",
      "Id=Vm/(2*Rf+R)      #diode current(peak)\n",
      "\n",
      "#Part b \n",
      "Idc=(2*Id)/math.pi    #dc current(A)\n",
      "\n",
      "#Part c\n",
      "PIV=Vm/2               #peak value of voltage across D1\n",
      "PIVac=100/math.pi      #average value of voltage across D1\n",
      "\n",
      "#Part d\n",
      "Im=Id                  #peak value of current(A)\n",
      "Irms=Im/(math.sqrt(2)) #rms value of current(A)\n",
      "\n",
      "#Results\n",
      "print\"peak value of current is\",Id,\"A\"\n",
      "print\"dc currect is\",round(Idc,2),\"A\"\n",
      "print\"across D1 are peak voltage is\",PIV,\"V and average voltage is\",round(PIVac,1),\"V\"\n",
      "print\"Irms is\",round(Irms,2),\"A\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "peak value of current is 1.6 A\n",
        "dc currect is 1.02 A\n",
        "across D1 are peak voltage is 100.0 V and average voltage is 31.8 V\n",
        "Irms is 1.13 A\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.33,Page number 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "f=50.              #frequency(Hz)\n",
      "dv=7.              #difference between maximum and minimum(25-18)voltages across the load(V)\n",
      "Ic=100.            #load current(mA)\n",
      "\n",
      "#Calculations\n",
      "dt=1/(2*f)        #time of discharge(seconds)\n",
      "C=Ic/(dv/dt)      #capacitance(uF) \n",
      "\n",
      "#Results\n",
      "print\"value of capacitor is\",round((C/1E-3),2),\"uF\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of capacitor is 142.86 uF\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.34,Page number 68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Vr=10.                          #peak to peak ripple voltage(V)\n",
      "Vm=50.                          #peak output voltage(V)  \n",
      "C=300.                          #Capacitance(uF)\n",
      "Rl=470.                         #load resistance(ohms)\n",
      "f=50.                           #frequency(Hz)\n",
      "\n",
      "#Calculations\n",
      "#Part a \n",
      "Vdc=Vm-(Vr/2)                   #dc voltage(V)      \n",
      "C=Vdc/(f*Vr*Rl)                 #capacitance(mF)\n",
      "\n",
      "#Part b\n",
      "C1=300*10**-6                    #capacitance is increased(uF)\n",
      "Vr=2*Vm/((2*f*C1*Rl)+1)\n",
      "Vdc=Vm-Vr/2                     #load voltage ripple(V)\n",
      "Idc=Vdc/Rl                      #average load current(mA)\n",
      "\n",
      "#Results\n",
      "print\"value of capacitor is\",round((C/1E-6),1),\"mF\" \n",
      "print\"load voltage ripple is\",round(Vdc,2),\"V and average load current is\",round((Idc/1E-4),1),\"mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "value of capacitor is 191.5 mF\n",
        "load voltage ripple is 46.69 V and average load current is 993.4 mA\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.35,Page number 69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "vo=7.5                  #instantaneous voltage(V)\n",
      "R1=15                   #resistance(k ohms)\n",
      "Von=0.5                 #voltage of diode when on(V)\n",
      "\n",
      "#Calculations\n",
      "Rth=(R1*vo)/(R1+vo)                 #equivalent resistance(V)\n",
      "T=2*(math.pi)/10**4                 #time period(ms)\n",
      "t1=(math.asin(Von/2.5))/10**4       #timimgs when D1 conducts(ms)\n",
      "t2=(T/2)-t1\n",
      "\n",
      "#Results\n",
      "print\"time period is\",round((T/1E-3),3),\"ms\"\n",
      "print\"t1 is\",t1,\"ms\"\n",
      "print \"t2 is\",round((t2/1E-3),3),\"ms\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "time period is 0.628 ms\n",
        "t1 is 2.0135792079e-05 ms\n",
        "t2 is 0.294 ms\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.36,Page number 70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declarations\n",
      "v=12                         #output voltage(V)\n",
      "vm=20.                       #peak voltage(V)\n",
      "v1=8                         #output voltage(V) for negative half cycle\n",
      "vm1=20.                      #peak voltage(V) for negative half cycle \n",
      "\n",
      "#Calculations\n",
      "t1=(math.asin(v/vm))/10**4         #for positive half cycle when D1 conducts\n",
      "t2=(0.1*math.pi)-t1/1e-3           \n",
      "t3=(math.asin(v1/vm1))/10**4       #for negative half cycle when D2 conducts\n",
      "t4=(0.1*(math.pi))+t3/1e-3           \n",
      "t5=(0.2*(math.pi))-t3/1e-3\n",
      "\n",
      "#Results\n",
      "print\"t1 is\",round(t1/1e-3,3),\"ms\"\n",
      "print\"t2 is\",round(t2,2),\"ms\"\n",
      "print\"t3 is\",round(t3/1e-3,3),\"ms\"\n",
      "print\"t4 is\",round(t4,3),\"ms\"\n",
      "print\"t5 is\",round(t5,3),\"ms\"\n",
      "print\"vo is\",\"-5.33+6.66*sin(10**4*.15)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "t1 is 0.064 ms\n",
        "t2 is 0.25 ms\n",
        "t3 is 0.041 ms\n",
        "t4 is 0.355 ms\n",
        "t5 is 0.587 ms\n",
        "vo is -5.33+6.66*sin(10**4*.15)\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}