{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4 Electrical Breakdown of Gases"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.1 pgno:139"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Part (a)\n",
      " alpha = 460.5 m^-1\n",
      "Part (b)\n",
      " I0 = 2.7e-09 \n",
      "No of electrons emitted = 1.688e+10 electrons/s\n"
     ]
    }
   ],
   "source": [
    "#Claculate alpha and No. of electrons emmited\n",
    "from math import log,e\n",
    "\n",
    "#Claculate \n",
    "#(a)alpha\n",
    "d2 = 0.01\n",
    "d1 = 0.005\n",
    "I2 = 2.7*10**-7\n",
    "I1 = 2.7*10**-8\n",
    "alpha = 1/(d2-d1)*log(I2/I1) \n",
    "#(b)number of electrons emmited from cathode per second\n",
    "I0 = I1*e**(-alpha*d1)\n",
    "n0 = I0/(1.6*10**-19)\n",
    "print\"Part (a)\\n alpha = %.1f m^-1\"%alpha\n",
    "print\"Part (b)\\n I0 = %.1e \"%I0\n",
    "print\"No of electrons emitted = %.3e electrons/s\"%n0\n",
    "#Answer may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.2 pgno:140"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a*d =   20.7232658369\n",
      "electrode space = 0.045 m\n"
     ]
    }
   ],
   "source": [
    "#Chapter 4, Exmaple 2, page 140\n",
    "#Claculate electrode space\n",
    "from math import log\n",
    "#based on the values of example 1\n",
    "d2 = 0.01\n",
    "d1 = 0.005\n",
    "I2 = 2.7*10**-7\n",
    "I1 = 2.7*10**-8\n",
    "a = 1/(d2-d1)*log(I2/I1) # alpha\n",
    "#10**9 = %e**a(a*d) \n",
    "#multiplying log on bith sides log(10**9) = a*d\n",
    "ad = log(10**9)\n",
    "print\"a*d =  \",ad\n",
    "d = ad/a\n",
    "print\"electrode space = %.3f m\"%d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.3 pgno:140"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Avalanche size = 6766 m\n"
     ]
    }
   ],
   "source": [
    "#Chapter 4, Exmaple 3, page 140\n",
    "#Claculate size of developed avalanche\n",
    "from scipy import integrate\n",
    "\n",
    "a = 4*10**4\n",
    "b = 15*10**5\n",
    "#Rewriting equation 4.2\n",
    "x0=0;x1=0.0005;\n",
    "def fun1(x):\n",
    "    y=a-b*(x)**0.5\n",
    "    return y\n",
    "X=integrate.quad(fun1,x0,x1);\n",
    "expX=6765.964568 \n",
    "As = expX # Avelanche size\n",
    "print\"Avalanche size = %.0f m\"%As\n",
    "\n",
    "#Answers may vary due to round of error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.4 pgno:141"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " 0.051800 m or 0.001540 m away from the cathode\n"
     ]
    }
   ],
   "source": [
    "#Claculate distance to produce avalanche\n",
    "#Rewrite equation 4.2 , using the values of a and b from previous example\n",
    "from numpy import array,roots\n",
    "\n",
    "p=array([7.5*10**5, -4*10**4, 59.97])\n",
    "r=roots(p)\n",
    "#obtaining the roots\n",
    "print\"\\n %f m or %f m away from the cathode\"%(round(r[0],4),round(r[1],5))\n",
    "#Answer may vary due to round of error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.5 pgno:141"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Minimum distance =  m 0.0011\n"
     ]
    }
   ],
   "source": [
    "#Claculate minimum distance to produce avalanche of size 10^19\n",
    "#Rewriting equation 4.2 and converting it into quadratic equation\n",
    "#x=poly(0,\"x\");\n",
    "from numpy import array,roots\n",
    "\n",
    "p=array([7.5*10**5, 4*10**4, 43.75])\n",
    "r=roots(p)\n",
    "#obtaining the roots\n",
    "print\"\\n Minimum distance =  m\",round(-r[1],4)# other root is disregarded\n",
    "#Answer may vary due to round of error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.7 pgno:142"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " E = 4.5e+06 V/m\n",
      "Alpha = 2397.29 m^-1\n",
      "Total secondary coefficient of ionization = 0.008340 \n"
     ]
    }
   ],
   "source": [
    "#Claculate secondary coefficient\n",
    "from math import exp\n",
    "#Using equation 3.15\n",
    "E = 9*10**3/0.002\n",
    "T = 11253.7 # m^-7*kPa^-1\n",
    "B = 273840 # V/mkPa\n",
    "p = 101.3 # kPa or 1 atm\n",
    "d = 0.002 # m\n",
    "alpha = p*T*exp(-B*p/E)\n",
    "Y = 1/(exp(alpha*d)-1)\n",
    "print\"\\n E = %.1e V/m\"%E\n",
    "print\"Alpha = %.2f m^-1\"%alpha\n",
    "print\"Total secondary coefficient of ionization = %f \"%round(Y,5)\n",
    "#Answer may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.8 pgno:143"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Alpha 1 = 39.8 m^-1\n",
      "Alpha 2 = 39.8 m^-1\n",
      "Alpha 3 = 41.97 m^-1\n",
      "From the above results we can understand that ionization mechanism must be acting at d3 \n",
      "secondary ionization coefficient =  0.0363\n"
     ]
    }
   ],
   "source": [
    "#Claculate first and secondary ionization coefficient\n",
    "from math import log\n",
    "from math import exp\n",
    "\n",
    "#(a)first ionization coefficient\n",
    "#Using equation 4.7a\n",
    "d1 = 0.005\n",
    "a1d1 = log(1.22)\n",
    "a1 = a1d1/d1\n",
    "d2 = 0.01504\n",
    "a2d2 = log(1.82)\n",
    "a2 = a2d2/d2\n",
    "d3 = 0.019 # wrong value used in the text\n",
    "a3d3 = log(2.22)\n",
    "a3 = a3d3/d3\n",
    "print\"Alpha 1 = %.1f m^-1\"%round(a1,1)\n",
    "print\"Alpha 2 = %.1f m^-1\"%round(a2,1)\n",
    "print\"Alpha 3 = %.2f m^-1\"%round(a3,2)\n",
    "print\"From the above results we can understand that ionization mechanism must be acting at d3 \"\n",
    "#secondary ionization coefficient\n",
    "I = 2.22\n",
    "e = exp(a1*d3)\n",
    "Y = (I-e)/(I*(e-1.))\n",
    "print\"secondary ionization coefficient = \",round(Y,4)\n",
    "#Answer may vary due to round off error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.9 pgno:144"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Distance = 0.085 m\n",
      "E = 1596 V/m\n",
      "Volatge  = 135.37 V\n"
     ]
    }
   ],
   "source": [
    "#Claculate distance and voltage\n",
    "from math import log\n",
    "\n",
    "a = 39.8 # alpha\n",
    "Y = 0.0354 # corfficient\n",
    "p = 0.133 # kPa\n",
    "Ep = 12000 # E/P , unit : V/m*kPa\n",
    "\n",
    "d = (1/a)*(log(1/Y + 1)) # distance\n",
    "E = Ep*p\n",
    "V = E*d\n",
    "\n",
    "print\"Distance = %.3f m\"%round(d,3)\n",
    "print\"E = %d V/m\"%E\n",
    "print\"Volatge  = %.2f V\"%round(V,2)\n",
    "\n",
    "#Answers may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.10 pgno:144"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "E = 5.9529e+06 V/m\n",
      "Voltage breakdown = 5.95 kV\n",
      "\n",
      "Voltage breakdown = 4.68 kV\n"
     ]
    }
   ],
   "source": [
    "#Claculate (a)Raether's criterion (b)Meek and Lobe's criterion\n",
    "from math import log\n",
    "#(a)Raether's criterion\n",
    "# as assumed by Raether and based equation 3.3, 3.50, 4.22 and 4.23\n",
    "d = 0.001 # m\n",
    "alpha = 10792.2 # m**-1\n",
    "p = 101.3 #kPa**-1\n",
    "ap = 106.54 # alpha/p Unit: m**-1*kPa**-1\n",
    "T = 11253.7 # m**-1*kPa**-1\n",
    "B = 273840 # V/m*kPa\n",
    "Ep = 58764.81 # E/p Unit:V/m*kPa\n",
    "\n",
    "ad = 17.7 + log(d)\n",
    "E = Ep*p\n",
    "Vs = E*d*10**-3 #Voltage breakdown\n",
    "print\"E = %.4e V/m\"%E\n",
    "print\"Voltage breakdown = %.2f kV\"%round(Vs,2)\n",
    "\n",
    "#(b)Meek and Loeb's criterion\n",
    "#Using equation 4.11 and based on 4.24 & 4,25 \n",
    "#+ we get Er = 468*10**4 V/m\n",
    "Er = 468*10**4 # V/m\n",
    "Vs2 = Er*0.001*10**-3\n",
    "print\"\\nVoltage breakdown = %.2f kV\"%Vs2\n",
    "\n",
    "# Answers may vary due to round of error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.11 pgno:146"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Electron drift velocity =2.50e+05 m/s\n",
      "alpha = 114.3 m**-1\n"
     ]
    }
   ],
   "source": [
    "#Claculate the first Townsend's ionization coefficient\n",
    "\n",
    "t = 0.2*10**-6 # transit time of electrons in seconds\n",
    "d = 0.05 # m\n",
    "ve = d/t\n",
    "TC = 35*10**-9 # Time constant\n",
    "a = 1/(ve*TC)\n",
    "print\"Electron drift velocity =%.2e m/s\"%ve\n",
    "print\"alpha = %.1f m**-1\"%round(a,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4.10.12 pgno:146"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Ea = 2.8284e+06 V/m\n",
      "x = 1.260*sin(3.14*t)\n",
      "t = 0.025 ms\n",
      "fmax = 630.2 Hz\n"
     ]
    }
   ],
   "source": [
    "#Travel time and maximum frequency\n",
    "from math import pi\n",
    "from math import asin\n",
    "\n",
    "#(a)Determine the travel time\n",
    "Ea = 200*(2)**0.5*10**3/0.1\n",
    "x = 1.4*10**-4*2828.4*10**3/(2*pi*50)\n",
    "d = 0.1\n",
    "print\"\\nEa = %.4e V/m\"%Ea\n",
    "print\"x = %.3f*sin(3.14*t)\"%x\n",
    "#obtaining t from x\n",
    "t = asin(d/x)/3.14\n",
    "print\"t = %.3f ms\"%t# answer mentioned in the text is wrong\n",
    "#(b)Determine the maximum frequency\n",
    "k = 1.4*10**-4\n",
    "fmax = k*Ea/(2*pi*d)\n",
    "print\"fmax = %.1f Hz\"%round(fmax,1)"
   ]
  }
 ],
 "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
}
