{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4 Diode Applications"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.1 Page No 83"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The dc voltage across the load resistor = 17.99 volts\n",
      "The peak inverse voltage across the diode = 56.58 volts\n",
      "The dc current through the diode = 0.90 A\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "V2rms= 40.0##  V\n",
    "R_L= 20.0##  Ω\n",
    "V2peak= V2rms/0.707##  V\n",
    "Vout_peak= V2peak##  V\n",
    "# The dc voltage across the load resistor \n",
    "Vdc=0.318*Vout_peak##  V\n",
    "#The peak inverse voltage across the diode \n",
    "PIV= V2peak##  V\n",
    "Idc= Vdc/R_L##  A\n",
    "# The dc current through the diode \n",
    "I_diode= Idc##  A\n",
    "print \"The dc voltage across the load resistor = %.2f volts\"%Vdc\n",
    "print \"The peak inverse voltage across the diode = %.2f volts\"%PIV\n",
    "print \"The dc current through the diode = %.2f A\"%I_diode"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.2 Page No 86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The dc load voltage = 17.99 volts\n",
      "The peak inverse voltage across each diode = 56.58 volts\n",
      "The dc current through each diode = 0.45 A\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "Vrms= 40.0##  V\n",
    "R_L= 20.0##  Ω\n",
    "V2peak= Vrms/0.707##  V\n",
    "Vout_peak= V2peak/2##  V\n",
    "# The dc load voltage \n",
    "Vdc=0.636*Vout_peak##  V\n",
    "# The peak inverse voltage across each diode \n",
    "PIV= V2peak##  V\n",
    "Idc= Vdc/R_L##  A\n",
    "# The dc current through each diode \n",
    "I_diode= Idc/2##  A\n",
    "print \"The dc load voltage = %.2f volts\"%Vdc\n",
    "print \"The peak inverse voltage across each diode = %.2f volts\"%PIV\n",
    "print \"The dc current through each diode = %.2f A\"%I_diode"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.3 Page No 88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The dc load voltage = 35.98 volts\n",
      "The peak inverse voltage across each diode = 56.58 volts\n",
      "The dc current through each diode = 0.90 A\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "Vrms= 40.0##  V\n",
    "R_L= 20.0##  Ω\n",
    "V2peak= Vrms/0.707##  V\n",
    "Vout_peak= V2peak##  V\n",
    "# The value of Vdc \n",
    "Vdc=0.636*Vout_peak##  V\n",
    "# The value of PIV \n",
    "PIV= V2peak##  V\n",
    "Idc= Vdc/R_L##  A\n",
    "#The value of I_diode\n",
    "I_diode= Idc/2##  A\n",
    "print \"The dc load voltage = %.2f volts\"%Vdc\n",
    "print \"The peak inverse voltage across each diode = %.2f volts\"%PIV\n",
    "print \"The dc current through each diode = %.2f A\"%I_diode"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.6 Page No 94"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The peak-to-peak ripple = 4.72 volts\n",
      "The dc load voltage = 54.24 volts\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "Vdc= 56.6##  V\n",
    "R_L= 100.0##  Ω\n",
    "f=120.0##  Hz\n",
    "C= 1000.0##  µF\n",
    "C= C*10**-6##  F\n",
    "V2peak= Vdc##  V\n",
    "Idc= Vdc/R_L##  A\n",
    "# The peak-to-peak ripple \n",
    "Vrip= Idc/(f*C)##  V\n",
    "# The dc load voltage \n",
    "Vdc= V2peak-Vrip/2##  V\n",
    "print \"The peak-to-peak ripple = %.2f volts\"%Vrip\n",
    "print \"The dc load voltage = %.2f volts\"%Vdc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.8 Page No 98"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The zener current = 5.36 mA\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "V2rms= 12.6##  V\n",
    "V_Z= 6.8##  V\n",
    "V2peak= V2rms/0.707##  V\n",
    "Vin= V2peak##  V\n",
    "Vout= V_Z##  V\n",
    "R_L= 1.2##  kΩ\n",
    "R_L= R_L*10**3##in Ω\n",
    "Rs= 1##  kΩ\n",
    "Rs= Rs*10**3##  Ω\n",
    "Is= (Vin-Vout)/Rs##  A\n",
    "I_L= Vout/R_L##  A\n",
    "# The zener current \n",
    "Iz= Is-I_L##  A\n",
    "Iz= Iz*10**3##  mA\n",
    "print \"The zener current = %.2f mA\"%Iz\n",
    "# Note: The calculation = %.2f the book is not accurate.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.9 Page No 98"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The ripple across the load resistance = 4.56 mV\n"
     ]
    }
   ],
   "source": [
    "# given data\n",
    "C= 100.0##in µF\n",
    "C= C*10**-6##  F\n",
    "Rz= 5.0##in Ω\n",
    "Rs= 1.0*10**3##in Ω\n",
    "Idc= 11.0*10**-3##in A\n",
    "f=120.0##in Hz\n",
    "Vin_rip= Idc/(f*C)##  V\n",
    "# The ripple across the load resistance \n",
    "Vout_rip= Rz*Vin_rip/(Rs+Rz)##in A\n",
    "Vout_rip= Vout_rip*10**3##  mV\n",
    "print \"The ripple across the load resistance = %.2f mV\"%Vout_rip"
   ]
  }
 ],
 "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
}