{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7:Junction Rectifier,Transistos and Devices"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.2,Page No:7.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Increase in temperature necessary to increase Is by a factor by 150 is 72.29  °C\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "#given Is2/Is1 =150\n",
    "#Is2/Is1 =2**(T2-T1)/10\n",
    "#dT=10ln(I)/ln(2)\n",
    "I  = 150;\n",
    " \n",
    "\n",
    "#Calculations\n",
    "dT  = 10*math.log(I)/float(math.log(2));       #increase in temperature in °C\n",
    "\n",
    "#Result\n",
    "print'Increase in temperature necessary to increase Is by a factor by 150 is %3.2f '%dT,'°C';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.3,Page No:7.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current flowing through germanium diode = 25.0067  uA\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "Io  = 0.25*10**-6;        # large reverse biased current in A\n",
    "V   = 0.12;               # applied voltage in V\n",
    "Vt  = 0.026;              # Volt-equivalent of temperature in V\n",
    "\n",
    "# Calculations\n",
    "I   = Io*(math.exp(V/float(Vt))-1);     #current in A \n",
    "\n",
    "# Result\n",
    "print'Current flowing through germanium diode = %g '%(I*10**6),'uA';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.4,Page No:7.12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Diffusion co-efficients of electrons = 4.92e-03 m**2/s\n",
      "Diffusion co-efficients of holes = 6.99e-04  m**2/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "k   = 1.38*10**-23;          # boltzmann constant (m**2)*(kg)*(s**-2)*(K**-1)\n",
    "e   = 1.6*10**-19;           # charge of electron in coulombs\n",
    "ue  = 0.19                   # mobility of electron  in m**2.V**-1.s**-1\n",
    "uh  = 0.027;                 # mobilty of holes in m**2.V**-1.s**-1\n",
    "T   = 300;                   # temperature in K\n",
    "\n",
    "#Calculations\n",
    "Dn  = ((k*T)/float(e))*ue;           # diffusion constant of electrons in cm**2/s\n",
    "Dh  = (k*T/float(e))*uh;             # diffusion constant of holes in cm**2/s\n",
    "\n",
    "\n",
    "#Result\n",
    "print'Diffusion co-efficients of electrons = %3.2e'%Dn,'m**2/s';\n",
    "print'Diffusion co-efficients of holes = %3.2e '%Dh,'m**2/s';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.6,Page No:7.13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "resistance = 10 ohm\n",
      "Vreb = 1.0e+07 ohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "I1  = 20;           #current in mA\n",
    "V1  = 0.8;          #voltage in volts\n",
    "V2  = 0.7;          #voltage in volts\n",
    "I2  = 10;           # current in mA\n",
    "v3  = -10;          #voltage in volts\n",
    "I3  = -1*10**-6;     # current in mA\n",
    "\n",
    "# Calculations\n",
    "R   = (V1 - V2)/(I1 - I2);     #resistance in ohm\n",
    "Vreb  = v3/I3;                 #velocity in volts\n",
    "\n",
    "#Result\n",
    "print'resistance = %d'%(R*10**3),'ohm';\n",
    "print'Vreb = %3.1e'%Vreb,'ohm';\n",
    "       "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.7,Page No:7.13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Diffusion constant of electrons = 94.3 cm**2/s\n",
      "Diffusion constant of electrons = 44.4 cm**2/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "T   = 300;                 # temp in kelvin\n",
    "k   = 1.38*10**-23;        # Boltzmann constant (m**2)*(kg)*(s**-2)*(K**-1)\n",
    "e   = 1.602*10**-19;       # charge of electron in coulombs\n",
    "ue  = 3650;                # mobility of electrons \n",
    "uh  = 1720;                # mobility of holes\n",
    "\n",
    "#Calculations\n",
    "De  = (ue*k*T)/float(e);       # diffusion constant of electrons in cm**2/s\n",
    "Dh  = (uh*k*T)/float(e);       # diffusion constant of holes in cm**2/s\n",
    "\n",
    "# Result\n",
    "print'Diffusion constant of electrons = %3.1f'%De,'cm**2/s';\n",
    "print'Diffusion constant of electrons = %3.1f'%Dh,'cm**2/s';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.8,Page No:7.23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pinch-off voltage = 3.92e-02 V\n",
      " Note:calculation mistake in text book ,e value is taken as 14.16*10**-12 instead of 141.6*10**-12\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "p   = 2;                 # resistivity in ohm-m\n",
    "er  = 16;                 #relative dielectrivity of Ge cm**2/s\n",
    "up  = 1800;               # mobility of holes in cm**2/s\n",
    "e0  = 8.85*10**-12;       #permitivity in (m**-3)*(kg**-1)*(s**4)*(A**2)\n",
    "a   = 2*10**-4;           #channel height in m\n",
    "\n",
    "# Calculations\n",
    "qNa  = 1/float(up*p);\n",
    "e    = e0*er;                      #permitivity in F/cm\n",
    "Vp   = (qNa*(a**2))/float(2*e);       # pinch-off voltage in V\n",
    "\n",
    "#Result\n",
    "print'Pinch-off voltage = %3.2e'%Vp,'V';\n",
    "print' Note:calculation mistake in text book ,e value is taken as 14.16*10**-12 instead of 141.6*10**-12';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.9,Page No:7.23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pinch off velocity =9.2 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "a       = 3.5*10**-6;               #channel width in m\n",
    "N       = 10**21;                   #number of electrons in electrons/m**3\n",
    "q       = 1.6*10**-19;              #charge of electron in coulombs\n",
    "er      = 12;                       #dielectric constant F/m\n",
    "e0      = 8.85*10**-12;             #dielectric constant F/m\n",
    " \n",
    "\n",
    "#calculation\n",
    "e      = (e0)*(er);                     #permitivityin F/m\n",
    "Vp     = (q*(a**2)*N)/float(2*e);        #pinch off voltage in V\n",
    "\n",
    "\n",
    "#result \n",
    "print'pinch off velocity =%2.1f'%Vp,'V';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.10,Page No:7.23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transconductance =2.24 m*A/V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "IDSS       = 10;               #current in mA\n",
    "IDS        =2.;                # current in mA\n",
    "Vp         = -4.0;             #pinch off voltage in V\n",
    "\n",
    "#formula\n",
    "#IDS   = IDSS*((1-(VGS/Vp))**2)\n",
    "#calculation\n",
    "VGS        = Vp*(1-(math.sqrt(IDS/float(IDSS))));\n",
    "gm         = ((-2*IDSS)/float(Vp))*(1-(VGS/float(Vp)));    #transconductance in m*A/V\n",
    "\n",
    "\n",
    "#result\n",
    "print'transconductance =%3.2f'%gm,'m*A/V';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.11,Page No:7.24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current =1.60 mA\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "VGS       = -3;                       #pinch off voltage in V\n",
    "IDSS        =10*10**-3;                # current in A\n",
    "Vp         = -5.0;                     #pinch off voltage in V\n",
    " \n",
    "\n",
    "#calculation\n",
    "IDS   = IDSS*((1-(VGS/float(Vp)))**2);    #current in mA\n",
    "\n",
    "\n",
    "#result\n",
    "print'current =%3.2f'%(IDS*10**3),'mA';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.12,Page No:7.24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transconductance =2.05 m S\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "IDS        = 2*10**-3;               #current in mA\n",
    "IDSS       = 8*10**-3;                # current in mA\n",
    "Vp         = -4.5;                    #pinch off voltage in V\n",
    "VGS1       = -1.902;                   #pinch off voltage  when IDS =3*10**-3 A\n",
    "\n",
    "#formula\n",
    "#IDS   = IDSS*((1-(VGS/Vp))**2)\n",
    "#calculation\n",
    "VGS        = Vp*(1-(math.sqrt(IDS/float(IDSS))));\n",
    "gm         = ((-2*IDSS)/float(Vp))*(1-(VGS1/float(Vp)));   #transconductance in m S\n",
    "\n",
    "\n",
    "#result\n",
    "print'transconductance =%3.2f'%(gm/10**-3),'m S';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.13,Page No:7.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "resistance =1.62e+10 ohms\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "VGS        = 26;                #gate source voltage in V\n",
    "IG         = 1.6*10**-9;        #gate current in A\n",
    "\n",
    "\n",
    "#calculation\n",
    "R          = VGS/float(IG);           #gate to current resistance in ohms\n",
    "\n",
    "\n",
    "#result \n",
    "print'resistance =%3.2e'%R,'ohms';\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.14,Page No:7.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transconductance =2.20e-03  ohm\n",
      "Note:wrong answer in textbook\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "ID1          = 1;                #current in A\n",
    "ID2          = 2.1;              # current in A\n",
    "VGS1         = 3.0;              #pinch off voltage in V\n",
    "VGS2         = 3.5;              #pinch off voltage in V\n",
    " \n",
    "\n",
    "#calculation\n",
    "dID         = ID2-ID1;\n",
    "dVGS        = VGS2-VGS1;\n",
    "gm          = (dID*10**-3)/float(dVGS);   #transconductance in mho\n",
    "\n",
    "\n",
    "#result\n",
    "print'transconductance =%3.2e '%gm,'ohm';\n",
    "print'Note:wrong answer in textbook';"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.15,Page No:7.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ac drain resistnce =30.00 k-ohms\n",
      "transconductance =4000 u mhos\n",
      "amplification factor=120.00\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "ID1         = 8;                    #drain current in mA\n",
    "ID2         = 8.3;                  #drain current in mA\n",
    "VDS1        = 5;                    #drainn source voltage in V\n",
    "VDS2        = 14;                   #drain source voltage in V\n",
    "ID3         = 7.1;                  #drain current when VDS constant VGS change\n",
    "ID4         = 8.3;                  #drain current when VDS constant VGS change\n",
    "VGS1         = 0.1;                 #drain source voltage in V\n",
    "VGS2         = 0.4;                 #drain source voltage in V\n",
    "\n",
    "#calculation\n",
    "dID1        = ID2-ID1;\n",
    "dVDS        = VDS2-VDS1;\n",
    "rd          = dVDS/float(dID1);                #ac drain resistance\n",
    "dID2        = ID4-ID3;\n",
    "dVGS        = VGS2-VGS1;\n",
    "gm          = dID2/float(dVGS);               #transconductance mhos\n",
    "u           = rd*gm;                          #amplification factor\n",
    "\n",
    "\n",
    "#result\n",
    "print'ac drain resistnce =%3.2f'%rd,'k-ohms';\n",
    "print'transconductance =%3.2d'%(gm/10**-3),'u mhos';\n",
    "print'amplification factor=%3.2f'%u;\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7.16,Page No:7.26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transconductance =3.03  mmhos\n",
      "Note:transconductance value is wrongly printed in terms of umhos\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "u          = 100;              #amplification factor \n",
    "rd         = 33*10**3;         #drain resistance  in ohms\n",
    "\n",
    "\n",
    "#calculation\n",
    "gm          = u/float(rd);         #transconductance in mhos\n",
    "\n",
    "#result\n",
    "print'transconductance =%3.2f'%(gm*10**3),' mmhos';\n",
    "print'Note:transconductance value is wrongly printed in terms of umhos';\n"
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}