{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter - 2 : Diode Applications"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1\n",
      ": Page No 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from numpy import pi\n",
      "from math import sqrt\n",
      "# Given data\n",
      "R_L = 1000 # in ohm\n",
      "N2byN1= 4 \n",
      "Vi= '10*sin(omega*t)'\n",
      "# V2= N2byN1*V1\n",
      "# V2= 40*sin(omega*t)\n",
      "Vm= N2byN1*10 # in V\n",
      "V_Lav= Vm/pi # in V\n",
      "print \"The average load voltage = %0.2f volts\" %V_Lav\n",
      "Im= Vm/R_L # in A\n",
      "I_dc= Im/pi # in A\n",
      "I_av = I_dc # in A\n",
      "I_av= I_av*10**3 # in mA\n",
      "print \"Average load current = %0.2f mA\" %I_av\n",
      "V_Lrms = Vm/2 # in V\n",
      "print \"RMS load voltage = %0.f V\" %V_Lrms\n",
      "I_rms = V_Lrms/R_L # in A\n",
      "I_rms= I_rms*10**3 # in mA\n",
      "print \"RMS load current = %0.f mA\" %I_rms\n",
      "Eta = I_av**2/I_rms**2*100 # in %\n",
      "print \"Efficiency = %0.2f %%\" %Eta\n",
      "V2rms= Vm/sqrt(2) # in V\n",
      "TUF = ((I_av )**2)/(V2rms*I_rms)*100 # in %\n",
      "print \"Transformer utilization factor = %0.2f %%\" %TUF\n",
      "Gamma= sqrt(V_Lrms**2-I_av**2)/V_Lav*100 \n",
      "print \"Ripple factor = %0.f %%\" %round(Gamma)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The average load voltage = 12.73 volts\n",
        "Average load current = 12.73 mA\n",
        "RMS load voltage = 20 V\n",
        "RMS load current = 20 mA\n",
        "Efficiency = 40.53 %\n",
        "Transformer utilization factor = 28.66 %\n",
        "Ripple factor = 121 %\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2\n",
      ": Page No 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R_L = 1 # in K ohm\n",
      "R_L = R_L * 10**3 # in ohm\n",
      "V_m = 15 # in V\n",
      "V_i = '15*sin(314*t)' \n",
      "I_m= V_m/R_L # in A\n",
      "I_dc = I_m/pi # in A\n",
      "I_dc = I_dc * 10**3 # in mA\n",
      "print \"Average current through the diode = %0.2f mA\" %I_dc\n",
      "I_drms = V_m/(2*R_L) \n",
      "I_drms = I_drms * 10**3 # in mA\n",
      "print \"RMS current = %0.1f mA\" %I_drms\n",
      "I_m = V_m/R_L \n",
      "I_m = I_m*10**3 # in mA\n",
      "print \"Peak diode current = %0.f mA\" %I_m\n",
      "PIV = 2*V_m # in V\n",
      "print \"Peak inverse voltage = %0.f V\" %PIV"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Average current through the diode = 4.77 mA\n",
        "RMS current = 7.5 mA\n",
        "Peak diode current = 15 mA\n",
        "Peak inverse voltage = 30 V\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3\n",
      ": Page No 101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R1 = 2.2*10**3 # in ohm\n",
      "R2 = 4.7*10**3 # in ohm\n",
      "R_AB = (R1*R2)/(R1+R2) # in ohm\n",
      "Vi = 20 # in V\n",
      "V_o = (Vi * R_AB)/(R_AB+R1) # in V\n",
      "PIV= Vi # in volts\n",
      "print \"The output voltage = %0.1f V\" %V_o\n",
      "print \"Peak inverse voltage = %0.f volts\" %PIV"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage = 8.1 V\n",
        "Peak inverse voltage = 20 volts\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      " Example 2.4.2 \n",
      ": Page No 102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import cos\n",
      "# Given data\n",
      "V_in  = 10 # in V\n",
      "R1 = 2000 # in ohm\n",
      "R2 = 2000 # in ohm\n",
      "V_o = V_in * (R1/(R1+R2) ) # in V\n",
      "# Vdc= 5/(T/2)*integrate('sin(omega*t)','t',0,T/2) and omega*T= 2*pi, So\n",
      "Vdc= -5/pi*(cos(pi)-cos(0)) # in V\n",
      "print \"The value of Vdc = %0.3f volts\" %Vdc\n",
      "PIV= V_in/2 # in V\n",
      "print \"The PIV value = %0.f volts\" %PIV\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Vdc = 3.183 volts\n",
        "The PIV value = 5 volts\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      " Example 2.4 (again 2.4)\n",
      ": Page No 124"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_in  = 10 # in V\n",
      "R_L = 2000 # in ohm\n",
      "R1 = 100 # in ohm\n",
      "V_R= 0.7 # in V\n",
      "V_o = V_in * ( (R_L)/(R1+R_L) ) # in V\n",
      "print \"The peak magnitude of the positive output voltage = %0.2f V\" %V_o \n",
      "Vo=-V_R # in V\n",
      "print \"The peak magnitude of the negative output voltage = %0.1f V\" %Vo"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The peak magnitude of the positive output voltage = 9.52 V\n",
        "The peak magnitude of the negative output voltage = -0.7 V\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7\n",
      ": Page No 141"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V=240 # in V\n",
      "R= 1 # in k\u03a9\n",
      "R=R*10**3 # in \u03a9\n",
      "Vsrms= V/4 # in V\n",
      "Vm= sqrt(2)*Vsrms # in V\n",
      "V_Ldc= -Vm/pi # in V\n",
      "print \"The value of average load voltage = %0.f volts\" %V_Ldc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of average load voltage = -27 volts\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8\n",
      ": Page No 142"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V = 220 # in V\n",
      "f=50 # in Hz\n",
      "N2byN1=1/4 \n",
      "R_L = 1 # in kohm\n",
      "R_L= R_L*10**3 # in ohm\n",
      "V_o = 220 # in V\n",
      "V_s = N2byN1*V_o # in V\n",
      "V_m = sqrt(2) * V_s # in V\n",
      "V_Ldc = (2*V_m)/pi # in V\n",
      "print \"Average load output voltage = %0.2f V\" %V_Ldc\n",
      "P_dc = (V_Ldc)**2/R_L # in W\n",
      "print \"DC power delivered to load = %0.2f watt\" %P_dc\n",
      "PIV = V_m # in V\n",
      "print \"Peak inverse Voltage = %0.2f V\" %PIV\n",
      "f_o = 2*f # in Hz\n",
      "print \"Output frequency = %0.f Hz\" %f_o"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Average load output voltage = 49.52 V\n",
        "DC power delivered to load = 2.45 watt\n",
        "Peak inverse Voltage = 77.78 V\n",
        "Output frequency = 100 Hz\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10\n",
      ": Page No 145"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R_L = 20 # in ohm\n",
      "I_Ldc = 100 # in mA\n",
      "R2 = 1 # in ohm\n",
      "R_F = 0.5 # in ohm\n",
      "I_m = (pi * I_Ldc)/2 # in mA\n",
      "V_m = I_m*10**-3*(R2+R_F+R_L) # in V\n",
      "V_srms = V_m/sqrt(2) # in V\n",
      "print \"RMS value of secondary signal voltage = %0.1f V\" %V_srms\n",
      "P_Ldc = (I_Ldc*10**-3)**2*R_L # in Watt\n",
      "print \"power delivered to load = %0.1f Watt\" %P_Ldc\n",
      "PIV = 2*V_m # in V\n",
      "print \"Peal inverse voltage = %0.2f V\" %PIV\n",
      "P_ac = (V_m)**2/(2*(R2+R_F+R_L)) # in Watt\n",
      "print \"Input power = %0.3f Watt\" %P_ac\n",
      "Eta = P_Ldc/P_ac*100 # in %\n",
      "print \"Conversion efficiency = %0.2f %%\" %Eta"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "RMS value of secondary signal voltage = 2.4 V\n",
        "power delivered to load = 0.2 Watt\n",
        "Peal inverse voltage = 6.75 V\n",
        "Input power = 0.265 Watt\n",
        "Conversion efficiency = 75.40 %\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.16\n",
      ": Page No 151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_dc = 12 # in V\n",
      "R_L = 500 # in ohm\n",
      "R_F = 25 # in ohm\n",
      "I_dc = V_dc/R_L # in A\n",
      "V_m = I_dc * pi * (R_L+R_F) # in V\n",
      "V_rms = V_m/sqrt(2) # in V\n",
      "V  = V_rms # in V\n",
      "print \"The voltage = %0.f V\" %round(V)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage = 28 V\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.17\n",
      ": Page No 152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_dc = 100 # in V\n",
      "V_m = (V_dc*pi)/2 # in V\n",
      "PIV = 2*V_m # in V\n",
      "print \"Peak inverse voltage for center tapped FWR = %0.2f V\" %PIV\n",
      "PIV1 = V_m # in V\n",
      "print \"Peak inverse voltage for bridge type FWR = %0.2f V\" %PIV1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak inverse voltage for center tapped FWR = 314.16 V\n",
        "Peak inverse voltage for bridge type FWR = 157.08 V\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.19\n",
      ": Page No 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_Gamma = 0.7 # in V\n",
      "R_f = 0 # in ohm\n",
      "V_rms = 120 # in V\n",
      "V_max = sqrt(2)*V_rms # in V\n",
      "R_L = 1 # in K ohm\n",
      "R_L = R_L * 10**3 # in ohm\n",
      "I_max = (V_max - (2*V_Gamma))/R_L # in A\n",
      "I_dc = (2*I_max)/pi # in mA\n",
      "V_dc = I_dc * R_L # in V\n",
      "print \"The dc voltage available at the load = %0.2f V\" %V_dc\n",
      "PIV = V_max # in V\n",
      "print \"Peak inverse voltage = %0.1f V\" %PIV\n",
      "print \"Maximum current through diode = %0.1f mA\" %(I_max*10**3)\n",
      "P_max = V_Gamma * I_max # in W\n",
      "print \"Diode power rating = %0.2f mW\" %(P_max*10**3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc voltage available at the load = 107.15 V\n",
        "Peak inverse voltage = 169.7 V\n",
        "Maximum current through diode = 168.3 mA\n",
        "Diode power rating = 117.81 mW\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.20\n",
      ": Page No 154"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V1 = 10 # in V\n",
      "V2 = 0.7 # in V\n",
      "V3 = V2 # in V\n",
      "V = V1-V2-V3 # in V\n",
      "R1 = 1 # in ohm\n",
      "R2 = 48 # in ohm\n",
      "R3 = 1 # in ohm\n",
      "R = R1+R2+R3 # in ohm\n",
      "I = V/R # in A\n",
      "I = I * 10**3 # in mA\n",
      "print \"Current = %0.f mA\" %I"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current = 172 mA\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.21\n",
      ": Page No 154"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_m = 50 # in V\n",
      "r_f = 20 # in ohm\n",
      "R_L = 800 # in ohm\n",
      "I_m = V_m/(R_L+r_f) # in A\n",
      "I_m = I_m * 10**3 # in mA\n",
      "print \"The value of Im = %0.f mA\" %round(I_m)\n",
      "I_dc = I_m/pi # in mA\n",
      "print \"The value of I_dc = %0.1f mA\" %I_dc\n",
      "I_rms = I_m/2 # in mA\n",
      "print \"The value of Irms = %0.1f mA\" %I_rms\n",
      "P_ac = (I_rms * 10**-3)**2 * (r_f + R_L) # in Watt\n",
      "print \"AC power input = %0.3f Watt\" %P_ac\n",
      "V_dc = I_dc * 10**-3*R_L # in V\n",
      "print \"DC output voltage = %0.2f V\" %V_dc\n",
      "P_dc = (I_dc * 10**-3)**2 * (r_f + R_L) # in Watt\n",
      "Eta = (P_dc/P_ac)*100 # in %\n",
      "print \"The efficiency of rectification = %0.1f %%\" %Eta\n",
      "\n",
      "# Note: There is calculation error to evaluate the ac power input (i.e. P_ac), so the value of Eta is also wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Im = 61 mA\n",
        "The value of I_dc = 19.4 mA\n",
        "The value of Irms = 30.5 mA\n",
        "AC power input = 0.762 Watt\n",
        "DC output voltage = 15.53 V\n",
        "The efficiency of rectification = 40.5 %\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.22\n",
      ": Page No 155"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R_L = 1 # in K ohm\n",
      "R_L = R_L * 10**3 # in ohm\n",
      "r_d = 10 # in ohm\n",
      "V_m = 220 # in V\n",
      "I_m = V_m/(r_d+R_L) # in A\n",
      "print \"Peak value of current = %0.2f A\" %I_m\n",
      "I_dc = (2*I_m)/pi # in A\n",
      "print \"DC value of current = %0.2f A\" %I_dc\n",
      "Irms= I_m/sqrt(2) # in A\n",
      "r_f = sqrt((Irms/I_dc)**2-1)*100 # in %\n",
      "print \"Ripple factor = %0.1f %%\" %r_f\n",
      "Eta = (I_dc)**2 * R_L/((Irms)**2*(R_L+r_d))*100 # in %\n",
      "print \"Rectification efficiency = %0.1f %%\" %Eta"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak value of current = 0.22 A\n",
        "DC value of current = 0.14 A\n",
        "Ripple factor = 48.3 %\n",
        "Rectification efficiency = 80.3 %\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.23\n",
      ": Page No 156"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_s = 12 # in V\n",
      "R_L = 5.1 # in k ohm\n",
      "R_L = R_L * 10**3 # in ohm\n",
      "R_s = 1 # in K ohm\n",
      "R_s = R_s * 10**3 # in ohm\n",
      "V_L = (V_s*R_L)/(R_s+R_L) # in V\n",
      "print \"Peak load voltage = %0.f V\" %V_L"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak load voltage = 10 V\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.24\n",
      ": Page No 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_s = 10 # in V\n",
      "R_L = 100 # in ohm\n",
      "I_L = V_s/R_L # in A\n",
      "print \"The load current during posotive half cycle = %0.1f A\" %I_L\n",
      "I_D2 = 0 # in A\n",
      "R2 = R_L # in ohm\n",
      "I_L1 = -(V_s)/(R2+R_L) # in A\n",
      "print \"The load current during negative half cycle = %0.2f A\" %I_L1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The load current during posotive half cycle = 0.1 A\n",
        "The load current during negative half cycle = -0.05 A\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.25\n",
      ": Page No 158"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V_m = 50 # in V\n",
      "V_dc = (2*V_m)/pi # in V\n",
      "print \"The dc voltage = %0.2f V\" %V_dc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The dc voltage = 31.83 V\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.26\n",
      ": Page No 159"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "R1 = 1.1 # in K ohm\n",
      "R2 = 2.2 # in K ohm\n",
      "Vi= 170 # in V\n",
      "V_o = (Vi*R1)/(R1+R2) # in V\n",
      "print \"The output voltage = %0.2f V\" %V_o\n",
      "V_dc = (2*V_o)/pi # in V\n",
      "print \"The dc voltage = %0.2f V\" %V_dc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output voltage = 56.67 V\n",
        "The dc voltage = 36.08 V\n"
       ]
      }
     ],
     "prompt_number": 48
    }
   ],
   "metadata": {}
  }
 ]
}