{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2 - Ionization"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1: pg 22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the breakdown strength of air for 0.1mm air gap is (kV/cm.) =  43.447\n",
      "\n",
      "the breakdown strength of air for 20 cm air gap is (kV/cm.) =  25.58\n"
     ]
    }
   ],
   "source": [
    "#example 2.1\n",
    "#calculation of breakdown strength of air\n",
    "\n",
    "#given data\n",
    "d1=0.1#length(in cm) of the gap\n",
    "d2=20#length(in cm) of the gap\n",
    "\n",
    "#calculation\n",
    "#from equation of breakdown strength\n",
    "E1=24.22+(6.08/(d1**(1./2)))#for gap d1\n",
    "E2=24.22+(6.08/(d2**(1./2)))#for gap d2\n",
    "#results\n",
    "print 'the breakdown strength of air for 0.1mm air gap is (kV/cm.) = ',round(E1,3)\n",
    "print '\\nthe breakdown strength of air for 20 cm air gap is (kV/cm.) = ',round(E2,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2: pg 23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Townsend primary ioniztion coefficient is (/cm torr) =  7.675\n"
     ]
    }
   ],
   "source": [
    "#example 2.2\n",
    "#calculation of Townsend primary ionization coefficient\n",
    "from math import log\n",
    "#given data\n",
    "d1=0.4#gap distance(in cm)\n",
    "d2=0.1#gap distance(in cm)\n",
    "I1=5.5*10**-8#value of current(in A)\n",
    "I2=5.5*10**-9#value of current(in A)\n",
    "\n",
    "#calculation\n",
    "#from equation of current at anode I=I0*exp(alpha*d)\n",
    "alpha=(log(I1/I2))*(1/(d1-d2))\n",
    "#results\n",
    "print 'Townsend primary ioniztion coefficient is (/cm torr) = ',round(alpha,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3: pg 25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the value of Townsend secondary ionization coefficient is  9.994e-04\n"
     ]
    }
   ],
   "source": [
    "#example 2.3\n",
    "#calculation of Townsend secondary ionization coefficient\n",
    "from math import exp\n",
    "#given data\n",
    "d=0.9#gap distance(in cm)\n",
    "alpha=7.676#value of alpha\n",
    "\n",
    "#calculation\n",
    "#from condition of breakdown.....gama*exp(alpha*d)=1\n",
    "gama=1/(exp(d*alpha))\n",
    "#results\n",
    "print '%s %.3e' %('the value of Townsend secondary ionization coefficient is ',gama)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4: pg 26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the value of breakdown voltage of the spark gap is (V) =  5626.0\n",
      "The answer is a bit different due to rounding off error in textbook\n"
     ]
    }
   ],
   "source": [
    "#example 2.4\n",
    "#calculation of breakdown voltage of a spark gap\n",
    "from math import log\n",
    "#given data\n",
    "A=15#value of A(in per cm)\n",
    "B=360#value of B(in per cm)\n",
    "d=0.1#spark gap(in cm)\n",
    "gama=1.5*10**-4#value of gama\n",
    "p=760#value of pressure of gas(in torr)\n",
    "\n",
    "#calculation\n",
    "#from equation of breakdown voltage\n",
    "V=(B*p*d)/(log((A*p*d)/(log(1+(1/gama)))))\n",
    "\n",
    "#results\n",
    "print 'the value of breakdown voltage of the spark gap is (V) = ',round(V)\n",
    "print 'The answer is a bit different due to rounding off error in textbook'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5: pg 26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the value of minimum spark over voltage is (V) =  481.0\n"
     ]
    }
   ],
   "source": [
    "#example 2.5\n",
    "#calculation of minimum spark over voltage\n",
    "from math import log\n",
    "#given data\n",
    "A=15#value of A(in per cm)\n",
    "B=360#value of B(in per cm)\n",
    "gama=10**-4#value of gama\n",
    "e=2.178#value of constant\n",
    "\n",
    "#calculation\n",
    "Vbmin=(B*e/A)*(log(1+(1/gama)))\n",
    "\n",
    "#results\n",
    "print 'the value of minimum spark over voltage is (V) = ',round(Vbmin)\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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}