{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# chapter 7 BIPOLAR JUNCTION TRANSISTORB"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_1 pgno: 220"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dnb =  20  cmˆ2/s\n",
      "nB =  10000  /cmˆ3\n",
      "xB =  1e-06  m\n",
      "AB =  0.0001  cmˆ2\n",
      "e =  1.6e-19  columns\n",
      "Vbe =  0.5  V\n",
      "VT =  0.0259  V\n",
      "WB =  0.0001  cm\n",
      "Magnitude of Io , Io=((e∗AB∗Dnb∗nB)/(WB)))= 3.2e-14  A\n",
      "Collector current ,Ic=Io((exp(Vbe/VT))−1))= 7.7484232166e-06  A\n"
     ]
    }
   ],
   "source": [
    "#exa 7.1\n",
    "from math import exp\n",
    "Dnb =20\n",
    "print\"Dnb = \",Dnb,\" cmˆ2/s\" #initializiation the value of one of base parametre of NPN transistor .\n",
    "nB =10**4\n",
    "print\"nB = \",nB,\" /cmˆ3\" # initializiation the value of one of base parametre of NPN transistor .\n",
    "xB =1*10**-6\n",
    "print\"xB = \",xB,\" m\" # initializiation the value of one of base parametre of NPN transistor .\n",
    "AB =10**-4\n",
    "print\"AB = \",AB,\" cmˆ2\" #initializiation the value of one of base parametre of NPN transistor .\n",
    "e=1.6*10**-19\n",
    "print\"e = \",e,\" columns\" # initializiation the value of electronic charge .\n",
    "Vbe=0.5\n",
    "print\"Vbe = \",Vbe,\" V\" # initializiation the value of base emitter voltage of NPN transistor ..\n",
    "VT=0.0259\n",
    "print\"VT = \",VT,\" V\" # initializiation the value of threshold voltage .\n",
    "WB=10**-4\n",
    "print\"WB = \",WB,\" cm\" # initializiation the value of base width of NPN transistor .\n",
    "Io=((e*AB*Dnb*nB)/(WB))\n",
    "print\"Magnitude of Io , Io=((e∗AB∗Dnb∗nB)/(WB)))=\",Io,\" A\"# calculation\n",
    "Ic=Io*(exp(Vbe/VT)-1)\n",
    "print\"Collector current ,Ic=Io((exp(Vbe/VT))−1))=\",Ic,\" A\"# calculation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_2 pgno: 221"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NE =  500000000000000000  /cmˆ3\n",
      "NB =  10000000000000000  /cmˆ3\n",
      "NC =  1000000000000000  /cmˆ3\n",
      "WB =  8e-05  cm\n",
      "no =  15000000000.0 cmˆ−3\n",
      "Number of Majority holes in the emitter ,pEO=(noˆ2/NE) )= 450.0  /cmˆ3\n",
      "Number of Majority holes in the base,nBO=(no ˆ2/NB))= 22500.0  /cmˆ3\n",
      "Number of Majority holes in the collector ,pCO=(noˆ2/NC) )= 225000.0  /cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 7.2\n",
    "NE =5*10**17\n",
    "print\"NE = \",NE,\" /cmˆ3\" # initializiation the value of doping concentration in the emitter\n",
    "NB =10**16\n",
    "print\"NB = \",NB,\" /cmˆ3\" # initializiation the value of doping concentration in the base.\n",
    "NC =10**15\n",
    "print\"NC = \",NC,\" /cmˆ3\" # initializiation the value of doping concentration in the collector .\n",
    "WB =0.8*10**-4\n",
    "print\"WB = \",WB,\" cm\" # initializiation the value of base width of NPN transistor .\n",
    "no=1.5*10**10\n",
    "print\"no = \",no,\"cmˆ−3\" # initializing the intrinsic carrier concentration .\n",
    "pEO=(no**2/NE)\n",
    "print\"Number of Majority holes in the emitter ,pEO=(noˆ2/NE) )=\",pEO,\" /cmˆ3\"# calculationnBO=(no^2/NB)\n",
    "nBO=(no**2/NB)\n",
    "print\"Number of Majority holes in the base,nBO=(no ˆ2/NB))=\",nBO,\" /cmˆ3\"#calculation\n",
    "pCO=(no**2/NC)\n",
    "print\"Number of Majority holes in the collector ,pCO=(noˆ2/NC) )=\",pCO,\" /cmˆ3\"# calculation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_3 pgno: 221"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NE =  500000000000000000  /cmˆ3\n",
      "NB =  10000000000000000  /cmˆ3\n",
      "NC =  1000000000000000  /cmˆ3\n",
      "WB =  8e-05  cm\n",
      "no =  15000000000.0 cmˆ−3\n",
      "VT =  0.0259  V\n",
      "VJ=Vbe =  0.6258  V\n",
      "Number of Majority holes in the emitter ,pEO=(noˆ2/NE) )= 450.0  /cmˆ3\n",
      "Number of Majority holes in the base,nBO=(no ˆ2/NB))= 22500.0  /cmˆ3\n",
      "Number of Majority holes in the collector ,pCO=(noˆ2/NC) )= 225000.0  /cmˆ3\n",
      "pE(O)=pEO∗( exp (VJ/VT) ) )= 1.40186506034e+13 /cmˆ3 \n",
      "nB=(nBO∗( exp (VJ/VT) ) ) )= 7.00932530169e+14 /cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 7.3\n",
    "from math import exp\n",
    "NE =5*10**17\n",
    "print\"NE = \",NE,\" /cmˆ3\" # initializiation of doping concentration in the emitter .\n",
    "NB =10**16\n",
    "print\"NB = \",NB,\" /cmˆ3\" # initializiation of doping concentration in the base .\n",
    "NC =10**15\n",
    "print\"NC = \",NC,\" /cmˆ3\" # initializiation of doping concentration in the collector .\n",
    "WB =0.8*10**-4\n",
    "print\"WB = \",WB,\" cm\" # initializiation the value of base width of NPN transistor .\n",
    "no=1.5*10**10\n",
    "print\"no = \",no,\"cmˆ−3\" # initializing the value of intrinsic carrier concentration .\n",
    "VT=0.0259\n",
    "print\"VT = \",VT,\" V\" # initializiation the value of threshold voltage .\n",
    "VJ=0.6258\n",
    "print\"VJ=Vbe = \",VJ,\" V\" # initializiation the value of base emitter voltage .\n",
    "pEO=(no**2/NE)\n",
    "print\"Number of Majority holes in the emitter ,pEO=(noˆ2/NE) )=\",pEO,\" /cmˆ3\"# calculation\n",
    "nBO=(no**2/NB)\n",
    "print\"Number of Majority holes in the base,nBO=(no ˆ2/NB))=\",nBO,\" /cmˆ3\"#calculation\n",
    "pCO=(no**2/NC)\n",
    "print\"Number of Majority holes in the collector ,pCO=(noˆ2/NC) )=\",pCO,\" /cmˆ3\"# calculation\n",
    "pE=pEO*(exp(VJ/VT))\n",
    "print\"pE(O)=pEO∗( exp (VJ/VT) ) )=\",pE, \"/cmˆ3 \" # calculation\n",
    "nB=nBO*(exp(VJ/VT))\n",
    "print\"nB=(nBO∗( exp (VJ/VT) ) ) )=\",nB,\"/cmˆ3\" # calculation\n",
    "#the answer provided in the book for pE,nB is some what different than actual calculated ."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_5 pgno: 222"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Db =  10  cmˆ2/s\n",
      "Bt =  0.95\n",
      "tb =  1e-07  s\n",
      "Lp=(sqrt(Db∗tb)))= 0.001  cm\n",
      "WB=(Lp∗( acosh (1/Bt) ) )= 0.000323036439272 cm\n"
     ]
    }
   ],
   "source": [
    "#exa 7.5\n",
    "from math import sqrt\n",
    "from math import acosh\n",
    "Db=10\n",
    "print\"Db = \",Db,\" cmˆ2/s\" # initializiation the value of one of parametere of the transistor .\n",
    "Bt =0.95\n",
    "print\"Bt = \",Bt # initializiation the value of base transport factor of the transistor.\n",
    "tb =10**-7\n",
    "print\"tb = \",tb,\" s\" # initializiation the value of one of parametere of the transistor.\n",
    "Lp=(sqrt(Db*tb))\n",
    "print\"Lp=(sqrt(Db∗tb)))=\",Lp,\" cm\"# calculation\n",
    "WB=(Lp*(acosh(1/Bt)))\n",
    "print\"WB=(Lp∗( acosh (1/Bt) ) )=\",WB,\"cm\" #calculation,"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_7 pgno: 224"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jro =  1e-09  A/cmˆ2\n",
      "Jo =  1e-12  A/cmˆ2\n",
      "Vbe =  0.5  V\n",
      "VT =  0.0259  V\n",
      "delta (recombination factor)=(1+((Jro/Jo)∗(exp((−Vbe) /(2∗VT) ) ) ) )ˆ−1)= 0.939616412003\n"
     ]
    }
   ],
   "source": [
    "#exa 7.7\n",
    "from math import exp\n",
    "Jro =10**-9\n",
    "print\"Jro = \",Jro,\" A/cmˆ2\" # initializiation the value of recombination current density .\n",
    "Jo =10**-12\n",
    "print\"Jo = \",Jo,\" A/cmˆ2\" # initializiation the value of reverse saturation current density.\n",
    "Vbe =0.5\n",
    "print\"Vbe = \",Vbe,\" V\" # initializiation the value of base emitter voltage .\n",
    "VT =0.0259\n",
    "print\"VT = \",VT,\" V\" # initializiation the value of threshold voltage .\n",
    "delta=(1+((Jro/Jo)*(exp((-Vbe)/(2*VT)))))**-1\n",
    "print\"delta (recombination factor)=(1+((Jro/Jo)∗(exp((−Vbe) /(2∗VT) ) ) ) )ˆ−1)=\",delta # calculation ."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_8 pgno: 224"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NE =  100000000000000000  /cmˆ3\n",
      "NB =  1000000000000000  /cmˆ3\n",
      "WE =  6e-05  cm\n",
      "WB =  8e-05  cm\n",
      "no =  15000000000.0 cmˆ−3\n",
      "e =  1.6e-19  columns\n",
      "DE =  15  cmˆ2/s\n",
      "DB =  20  cmˆ2/s\n",
      "tE =  2e-07  s\n",
      "tB =  1e-07  s\n",
      "Vbe =  0.6  V\n",
      "VT =  0.0259  V\n",
      "Jro =  2e-08  A/cmˆ2\n",
      "LE=(sqrt(DE∗tE)))= 0.00173205080757  cm\n",
      "LB=(sqrt(DB∗tB)))= 0.00141421356237  cm\n",
      "Number of Majority holes in the emitter ,pEO=(noˆ2/NE) )= 2250.0  /cmˆ3\n",
      "Number of Majority holes in the base,nBO=(no ˆ2/NB))= 225000.0  /cmˆ3\n",
      "Emitter injection efficiency ,Y=(1+((NB∗DE∗LB) /(NE∗DB∗LE)∗(tanh(WB/LB)/tanh(WE/LE)))) )= 0.990105536375\n",
      "Base transport factor ,Bt=(cosh(WB/LB))ˆ−1)= 0.998402130561\n",
      "Reverse saturation current Density , Jro=((e∗DB∗n BO)/(LB∗tanh(WB/LB)))) =  9.00959795262e-09 A/cmˆ2\n",
      "delta(recombination factor)=(1+((Jro/Jo)∗(exp((−Vbe)/(2∗VT)))))ˆ−1)= 0.999979304421  A\n",
      "common base current amplification factor ,(alpha=Bt∗delta∗Y)= 0.988503018931\n",
      "common emitter current amplification factor ,Beta=(a/(1−a) ) )= 85.9793551861\n"
     ]
    }
   ],
   "source": [
    "#exa 7.8\n",
    "from math import sqrt\n",
    "from math import cosh\n",
    "from math import tanh\n",
    "NE =1*10**17\n",
    "print\"NE = \",NE,\" /cmˆ3\" # initializiation the value of doping concentration of emitter in the NPN transistor .\n",
    "NB =10**15\n",
    "print\"NB = \",NB,\" /cmˆ3\" # initializiation the value of doping concentration of base in the NPN transistor .\n",
    "WE =0.6*10**-4\n",
    "print\"WE = \",WE,\" cm\" # initializiation the value of one of parametre of the transistor.\n",
    "WB =0.8*10**-4\n",
    "print\"WB = \",WB,\" cm\" # initializiation the value of one of parametre of the transistor.\n",
    "no=1.5*10**10\n",
    "print\"no = \",no,\"cmˆ−3\" # initializing the value of intrinsic carrier concentration .\n",
    "e=1.6*10**-19\n",
    "print\"e = \",e,\" columns\" # initializiation the value of electronic charge\n",
    "DE=15\n",
    "print\"DE = \",DE,\" cmˆ2/s\" # initializiation the value of one of parametere of the transistor .\n",
    "DB=20\n",
    "print\"DB = \",DB,\" cmˆ2/s\" #initializiation the value of one of parametere of the transistor .\n",
    "tE =0.2*10**-6\n",
    "print\"tE = \",tE,\" s\" # initializiation the value of one of parametere of the transistor.\n",
    "tB =0.1*10**-6\n",
    "print\"tB = \",tB,\" s\" # initializiation the value of one of parametere of the transistor.\n",
    "Vbe=0.60\n",
    "print\"Vbe = \",Vbe,\" V\" # initializiation the value of base emitter voltage .\n",
    "VT=0.0259\n",
    "print\"VT = \",VT,\" V\" # initializiation the value of threshold voltage .\n",
    "Jro =2*10**-8\n",
    "print\"Jro = \",Jro,\" A/cmˆ2\" # initializiation the value of recombination current density .\n",
    "LE=(sqrt(DE*tE))\n",
    "print\"LE=(sqrt(DE∗tE)))=\",LE,\" cm\"#calculation\n",
    "LB=(sqrt(DB*tB))\n",
    "print\"LB=(sqrt(DB∗tB)))=\",LB,\" cm\"#calculation\n",
    "pEO=(no**2/NE)\n",
    "print\"Number of Majority holes in the emitter ,pEO=(noˆ2/NE) )=\",pEO,\" /cmˆ3\"# calculation\n",
    "nBO=(no**2/NB)\n",
    "print\"Number of Majority holes in the base,nBO=(no ˆ2/NB))=\",nBO,\" /cmˆ3\"#calculation\n",
    "Y=(1+(((NB*DE*LB)/(NE*DB*LE))*((tanh(WB/LB)/tanh(WE/ LE)))))**(-1)\n",
    "print\"Emitter injection efficiency ,Y=(1+((NB∗DE∗LB) /(NE∗DB∗LE)∗(tanh(WB/LB)/tanh(WE/LE)))) )=\",Y # calculation\n",
    "Bt=(cosh(WB/LB))**-1\n",
    "print\"Base transport factor ,Bt=(cosh(WB/LB))ˆ−1)=\",Bt# calculation\n",
    "Jo=((e*DB*nBO)/(LB*tanh(WB/LB)))\n",
    "print\"Reverse saturation current Density , Jro=((e∗DB∗n BO)/(LB∗tanh(WB/LB)))) = \",Jo, \"A/cmˆ2\"  # calculation\n",
    "delta=(1+((Jro/Jo)*(exp((-Vbe)/(2*VT)))))**-1\n",
    "print\"delta(recombination factor)=(1+((Jro/Jo)∗(exp((−Vbe)/(2∗VT)))))ˆ−1)=\",delta,\" A\"# calculation\n",
    "a=Bt*delta*Y\n",
    "print\"common base current amplification factor ,(alpha=Bt∗delta∗Y)=\",a # calculation\n",
    "B=(a/(1-a))\n",
    "print\"common emitter current amplification factor ,Beta=(a/(1−a) ) )=\",B # calculation\n",
    "#the value of NE provided in the question is different than used in the solution .\n",
    "#I have used the value (while solving) provided in the question ( i . e NE=10ˆ17/cmˆ3) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_9 pgno: 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NB =  5e+16  /cmˆ3\n",
      "NC =  2e+15  /cmˆ3\n",
      "WBm =  6e-05  cm\n",
      "e =  1.6e-19  columns\n",
      "VCB1 =  1  V\n",
      "VCB2 =  4  V\n",
      "Er =  11.9\n",
      "Eo =  8.854e-14  F/cm\n",
      "no =  15000000000.0 cmˆ−3\n",
      "VT =  0.0259  V\n",
      " VBI=VT∗(log((NB∗NC)/noˆ2))= 0.694640354303  V\n",
      "WBS=((2∗Eo∗Er∗(VBI+VCB1)/e)∗(NC/NB)∗(1/(NC+NB)))ˆ(1/2))= 4.14348090604e-06  cm\n",
      "Neutral base width for VCB1,WB( neutral )=WBm− WBS1= 5.5856519094e-05  cm\n",
      "WBS=((2∗Eo∗Er∗(VBI+VCB2)/e)∗(NC/NB)∗(1/(NC+NB) ))ˆ(1/2))= 1.0  cm\n",
      "Neutral base width for VCB2,WB( neutral )=WBm−WBS2= -0.99994  cm\n",
      "change in the neutal base width ,deltaWb(neutral )=Wb1−Wb2= 0.999995856519  cm\n"
     ]
    }
   ],
   "source": [
    "#exa 7.9\n",
    "from math import log\n",
    "NB =5e16\n",
    "print\"NB = \",NB,\" /cmˆ3\" # initializiation the doping concentration in the base .\n",
    "NC =2e15\n",
    "print\"NC = \",NC,\" /cmˆ3\" # initializiation the doping concentration in the collector .\n",
    "WBm =0.6e-4\n",
    "print\"WBm = \",WBm,\" cm\" # initializiation the value of actual base width .\n",
    "e=1.6e-19\n",
    "print\"e = \",e,\" columns\" # initializiation the value of electronic charge .\n",
    "VCB1=1\n",
    "print\"VCB1 = \",VCB1,\" V\" # initializiation the initial value of collector base voltage .\n",
    "VCB2=4\n",
    "print\"VCB2 = \",VCB2,\" V\" # initializiation the final value of collector base voltage.\n",
    "Er=11.9\n",
    "print\"Er = \",Er  # initializing value of relative dielectric permittivity constant .\n",
    "Eo=8.854e-14\n",
    "print\"Eo = \",Eo,\" F/cm\" # initializing value of permittivity of free space .\n",
    "no=1.5e10\n",
    "print\"no = \",no,\"cmˆ−3\" # initializing the value of intrinsic charge carriers\n",
    "VT=0.0259\n",
    "print\"VT = \",VT,\" V\" # initializiation the value of threshold voltage .\n",
    "VBI=VT*(log((NB*NC)/no**2))\n",
    "print\" VBI=VT∗(log((NB∗NC)/noˆ2))=\",VBI,\" V\" # calculation\n",
    "WBS1=((2*Eo*Er*(VBI+VCB1)/e)*(NC/NB)*(1/(NC+NB)))**(1./2.)\n",
    "print\"WBS=((2∗Eo∗Er∗(VBI+VCB1)/e)∗(NC/NB)∗(1/(NC+NB)))ˆ(1/2))=\",WBS1,\" cm\"#calculation\n",
    "Wb1=WBm-WBS1\n",
    "print\"Neutral base width for VCB1,WB( neutral )=WBm− WBS1=\",Wb1,\" cm\"# calculation\n",
    "WBS2=((2*Eo*Er*(VBI+VCB2)/e)*(NC/NB)*(1/(NC+NB)))**(1/2)\n",
    "print\"WBS=((2∗Eo∗Er∗(VBI+VCB2)/e)∗(NC/NB)∗(1/(NC+NB) ))ˆ(1/2))=\",WBS2,\" cm\"#calculation\n",
    "Wb2=WBm-WBS2\n",
    "print\"Neutral base width for VCB2,WB( neutral )=WBm−WBS2=\",Wb2,\" cm\"# calculation\n",
    "deltaWbneutral=Wb1-Wb2\n",
    "print\"change in the neutal base width ,deltaWb(neutral )=Wb1−Wb2=\",deltaWbneutral,\" cm\" # calculation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7_10 pgno: 226"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ro =  5000000.0  ohm\n",
      "Vce1 =  7  V\n",
      "Vce2 =  1  V\n",
      "change in the collector −emitter voltage , Vce1−Vce2 =  6  V\n",
      "change in the collector current , Ic=(Vce/ro))= 1.2e-06  A\n"
     ]
    }
   ],
   "source": [
    "#exa 7.10\n",
    "ro=500*10e3\n",
    "print\"ro = \",ro,\" ohm\" # initializiation the value of output resistance .\n",
    "Vce1 =7\n",
    "print\"Vce1 = \",Vce1,\" V\" # initializiation the initial value of collector emitter voltage .\n",
    "Vce2 =1\n",
    "print\"Vce2 = \",Vce2,\" V\" # initializiation the final value of collector emitter voltage .\n",
    "Vce=6\n",
    "print\"change in the collector −emitter voltage , Vce1−Vce2 = \",Vce,\" V\" # calculation .\n",
    "Ic=(Vce/ro)\n",
    "print\"change in the collector current , Ic=(Vce/ro))=\" ,Ic,\" A\"# calculation,"
   ]
  }
 ],
 "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.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
