{
 "metadata": {
  "name": "",
  "signature": "sha256:8ef26de80c6669dcd55ce081279263a5231dd84d81c7a5c7530a5f89da39e8f3"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "chapter09:Power Amplifiers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 327"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Determine the turns ratio of the transformer\n",
      "#given\n",
      "import math\n",
      "Rl=8.;#ohm\n",
      "Rl_=5.*10.**3.;#ohm\n",
      "TR=math.sqrt(Rl_/Rl); #Turns ratio\n",
      "print '%s %.f %s' %(\"Turns Ratio =\",TR,\": 1\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Turns Ratio = 25 : 1\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 328"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Determine the output impedance of the transistor\n",
      "#given\n",
      "TR=16./1.;    #turn ratio\n",
      "Rl=4.;#ohm   #loudspeaker impedance\n",
      "ro=(TR**2.)*Rl;\n",
      "print '%s %.f %s' %(\"The output impedance of the transistor =\",ro,\"ohm\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The output impedance of the transistor = 1024 ohm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 334"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Determine the efficiency of a single ended transformer\n",
      "#given\n",
      "Vceq=10.;#V     #supply voltage\n",
      "\n",
      "#At Vp=10V\n",
      "Vp=10.;#V\n",
      "Vce_max1=Vceq+Vp;\n",
      "Vce_min1=Vceq-Vp;\n",
      "n1=50.*((Vce_max1-Vce_min1)/(Vce_max1+Vce_min1))**2.;\n",
      "print '%s %.f %s' %(\"Efficiency (At Vp = 10V)=\",n1,\"percent\\n\");\n",
      "\n",
      "#At Vp=5V\n",
      "Vp=5.;#V\n",
      "Vce_max2=Vceq+Vp;\n",
      "Vce_min2=Vceq-Vp;\n",
      "n2=50.*((Vce_max2-Vce_min2)/(Vce_max2+Vce_min2))**2.;\n",
      "print '%s %.1f %s' %(\"Efficiency (At Vp = 5V)=\",n2,\"percent\\n\");\n",
      "\n",
      "#At Vp=1V\n",
      "Vp=1.;#V\n",
      "Vce_max3=Vceq+Vp;\n",
      "Vce_min3=Vceq-Vp;\n",
      "n3=50.*((Vce_max3-Vce_min3)/(Vce_max3+Vce_min3))**2.;\n",
      "print '%s %.1f %s' %(\"Efficiency (At Vp = 1V)=\",n3,\"percent\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency (At Vp = 10V)= 50 percent\n",
        "\n",
        "Efficiency (At Vp = 5V)= 12.5 percent\n",
        "\n",
        "Efficiency (At Vp = 1V)= 0.5 percent\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 336"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Determine input and output power and efficiency\n",
      "#given\n",
      "import math\n",
      "Vcc=20.;#V#supply voltage\n",
      "Rl=4.;#ohm\n",
      "Vp=15.;#V\n",
      "Ip=Vp/Rl;\n",
      "Idc=Ip/math.pi;\n",
      "Pi=Vcc*Idc;\n",
      "Po=((Vp/2.)**2.)/Rl;\n",
      "n=100.*Po/Pi;\n",
      "print '%s %.1f %s' %(\"Input power =\",Pi,\"W\\n\");\n",
      "print '%s %.2f %s' %(\"Output power =\",Po,\"W\\n\");\n",
      "print '%s %.2f %s' %(\"Efficiency =\",n,\"percent\\n\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input power = 23.9 W\n",
        "\n",
        "Output power = 14.06 W\n",
        "\n",
        "Efficiency = 58.90 percent\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 337"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the percentage increase in output power\n",
      "#given\n",
      "D=0.2;#harmonic distortion\n",
      "P=(1.+D**2.);#Total power increase\n",
      "\n",
      "#percent increase= (Pi*(1+D**2)-Pi)*100/Pi;\n",
      "#taking out and cancelling Pi\n",
      "PI=(P-1.)*100.;\n",
      "print '%s %.f %s' %(\"The percentage increase in output power=\",PI,\"percent\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The percentage increase in output power= 4 percent\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 338"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate harmonic distortion and percentage increase in output voltage due to this\n",
      "#given\n",
      "import math\n",
      "I1=60.;#A\n",
      "I2=6.;#A\n",
      "I3=1.2;#A\n",
      "I4=0.6;#A\n",
      "D2=I2/I1;\n",
      "D3=I3/I1;\n",
      "D4=I4/I1;\n",
      "print '%s %.f %s %s %.f %s %s %.f %s' %(\"The Harmonic distortion of each component \\nD2=\",D2*100,\"percent\\n\",\"\\nD3=\",D3*100,\"percent\\n\",\"\\nD4=\",D4*100,\"percent\\n\");\n",
      "D=math.sqrt((D2)**2.+(D3)**2.+(D4)**2.);\n",
      "print '%s %.f %s' %(\"The Total Harmonic distortion =\",D*100,\"percent\\n\");\n",
      "P=(1.+D**2.);#Total power increase\n",
      "#percent increase= (Pi*(1+D**2)-Pi)*100/Pi;\n",
      "#taking out and cancelling Pi\n",
      "PI=(P-1.)*100.;\n",
      "print '%s %.f %s' %(\"The percentage increase in output power =\",PI,\"percent\");\n",
      "#Calculate harmonic distortion and percentage increase in output voltage due to this\n",
      "#given\n",
      "import math\n",
      "I1=60.;#A\n",
      "I2=6.;#A\n",
      "I3=1.2;#A\n",
      "I4=0.6;#A\n",
      "D2=I2/I1;\n",
      "D3=I3/I1;\n",
      "D4=I4/I1;\n",
      "print '%s %.f %s %s %.f %s %s %.f %s' %(\"The Harmonic distortion of each component \\nD2=\",D2*100,\"percent\\n\",\"\\nD3=\",D3*100,\"percent\\n\",\"\\nD4=\",D4*100,\"percent\\n\");\n",
      "D=math.sqrt((D2)**2.+(D3)**2.+(D4)**2.);\n",
      "print '%s %.f %s' %(\"The Total Harmonic distortion =\",D*100,\"percent\\n\");\n",
      "P=(1.+D**2.);#Total power increase\n",
      "#percent increase= (Pi*(1+D**2)-Pi)*100/Pi;\n",
      "#taking out and cancelling Pi\n",
      "PI=(P-1.)*100.;\n",
      "print '%s %.f %s' %(\"The percentage increase in output power =\",PI,\"percent\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Harmonic distortion of each component \n",
        "D2= 10 percent\n",
        " \n",
        "D3= 2 percent\n",
        " \n",
        "D4= 1 percent\n",
        "\n",
        "The Total Harmonic distortion = 10 percent\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "The percentage increase in output power = 1 percent\n",
        "The Harmonic distortion of each component \n",
        "D2= 10 percent\n",
        " \n",
        "D3= 2 percent\n",
        " \n",
        "D4= 1 percent\n",
        "\n",
        "The Total Harmonic distortion = 10 percent\n",
        "\n",
        "The percentage increase in output power = 1 percent\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}