{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 3 Fundamentals of Fault Clearing and Switching Phenomena"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_1 pgno:24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the transient current =A 1.56\n"
     ]
    }
   ],
   "source": [
    "from math import pi,exp\n",
    "from math import atan,sin\n",
    "from math import sqrt\n",
    "R=10; \n",
    "L=0.1; \n",
    "f=50; \n",
    "w=2*pi*f; \n",
    "k=sqrt((R**2)+((w*L)**2));\n",
    "angle=atan(w*L/R);\n",
    "E=400 \n",
    "A=E*sin(angle)/k;\n",
    "i=A*exp((-R)*.02/L);\n",
    "i=round(i*100)/100;\n",
    "print\"the transient current =A\",i\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_2 pgno:26"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current in amperes for part1=A\n",
      "4.1\n",
      "current in part 2& part 3= 0\n",
      "\n",
      "the DC component vanishes if e=V 141.4\n",
      "\n",
      "current at .5 cycles for t1=sec \n",
      "current in the problem = A 0.01 1.50368424845\n",
      "\n",
      "current at 1.5 cycles for t2=sec \n",
      "current in the problem = A 0.03 0.203501533662\n",
      "\n",
      "current at 5.5 cycles for t3=sec \n",
      "current in the problem = A 0.11 6.82671592646e-05\n",
      "the difference in result is due to erroneous value in textbook.\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,sin,atan,pi,exp\n",
    "R=10; \n",
    "L=0.1; \n",
    "f=50; \n",
    "w=2*pi*f; \n",
    "k=sqrt((R**2)+((w*L)**2));\n",
    "angle=atan(w*L/R); \n",
    "E=100; \n",
    "Em=sqrt(2)*E; \n",
    "A=Em*sin(angle)/k;\n",
    "i1=A; \n",
    "Em=round(Em*10)/10;\n",
    "i1=round(i1*10)/10;\n",
    "print\"current in amperes for part1=A\\n\",i1\n",
    "print\"current in part 2& part 3= 0\\n\"\n",
    "print\"the DC component vanishes if e=V\",Em#the error is due to the erroneous values in the textbook\n",
    "\n",
    "t1=0.5*.02; \n",
    "i2=A*exp((-R)*t1/L);\n",
    "print\"\\ncurrent at .5 cycles for t1=sec \\ncurrent in the problem = A\",t1,i2\n",
    "t2=1.5*.02;\n",
    "i3=A*exp((-R)*t2/L);\n",
    "print\"\\ncurrent at 1.5 cycles for t2=sec \\ncurrent in the problem = A\",t2,i3\n",
    "t3=5.5*.02;\n",
    "i4=A*exp((-R)*t3/L);\n",
    "print\"\\ncurrent at 5.5 cycles for t3=sec \\ncurrent in the problem = A\",t3,i4\n",
    "\n",
    "\n",
    "print\"the difference in result is due to erroneous value in textbook.\"\n",
    "         "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_3 pgno:28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "frequency of oscillations=c/s 72400.0\n",
      "\n",
      "time of maximum restriking voltage=microsec 3.46\n",
      "\n",
      "maximum restriking voltage=V/microsecs 2430.0\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,e,pi\n",
    "C=.003e-6 \n",
    "L=1.6e-3 \n",
    "y=sqrt(L*C);\n",
    "y=round(y*1e7)/1e7;\n",
    "f=(2*3.14*y)**-1; \n",
    "f=round(f/100)*100;\n",
    "i=7500;\n",
    "E=i*2*3.15*L*50;\n",
    "Em=1.414*E;\n",
    "Em=round(Em/10)*10\n",
    "t=y*pi/2;\n",
    "t=t*1e6;\n",
    "t=round(t*100)/100;\n",
    "e=Em/y;\n",
    "e=round((e)/1e6)*1e6;\n",
    "e=round(e/1e7)*1e7\n",
    "print\"frequency of oscillations=c/s\",f\n",
    "print\"\\ntime of maximum restriking voltage=microsec\",t\n",
    "print\"\\nmaximum restriking voltage=V/microsecs\",e/1e6\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_4 pgno:30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "peak restriking voltage=kV 18.0\n",
      "\n",
      "frequency of oscillations=c/s 12637.7514913\n",
      "\n",
      "average rate of restriking voltage=kV/microsecs 0.455\n",
      "\n",
      "max restriking voltage=V/microsecs 714.0\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "R=5 \n",
    "f=50\n",
    "L=R/(2*pi*f);\n",
    "V=11e3;\n",
    "Vph=11/sqrt(3);\n",
    "C=0.01e-6;\n",
    "y=sqrt(L*C);\n",
    "Em=sqrt(2)*Vph;\n",
    "ep=2*Em;\n",
    "ep=round(ep*10)/10;\n",
    "y=round(y*1e7)/1e7;\n",
    "t=y*pi;\n",
    "t=round(t*1e7)/1e7\n",
    "ea=ep/t;\n",
    "ea=round(ea/1e3)*1e3\n",
    "fn=(2*3.14*y)**-1;\n",
    "Em=round(Em)\n",
    "Emax=Em/y;\n",
    "Emax=round(Emax/1000)*1e3;\n",
    "print\"peak restriking voltage=kV\",ep\n",
    "print\"\\nfrequency of oscillations=c/s\",fn\n",
    "print\"\\naverage rate of restriking voltage=kV/microsecs\",ea/1e6\n",
    "print\"\\nmax restriking voltage=V/microsecs\",Emax/1e3\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_5 pgno:31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average restriking voltage=V/microsecs 1220.0\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "E=19.1*1e3;\n",
    "L=10*1e-3;\n",
    "C=.02*1e-6;\n",
    "Em=sqrt(2)*E;\n",
    "y=sqrt(L*C);\n",
    "t=pi*y*1e6;\n",
    "emax=2*Em;\n",
    "eavg=emax/t;\n",
    "eavg=round(eavg/10)*10\n",
    "print\"average restriking voltage=V/microsecs\",eavg\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_6 pgno:33"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average restriking voltage=kV/microsecs 4.8\n"
     ]
    }
   ],
   "source": [
    "from math import e,sqrt,acos,sin\n",
    "V=78e3;\n",
    "Vph=V/sqrt(3);\n",
    "Em=2*Vph;\n",
    "pf=0.4;\n",
    "angle=acos(pf);\n",
    "k1=sin(angle); \n",
    "k1=round(k1*100)/100;\n",
    "k2=.951;\n",
    "k3=1;\n",
    "k=k1*k2*k3;\n",
    "k=round(k*1000)/1e3;\n",
    "E=k*Em;\n",
    "f=15000.; \n",
    "t=1/(2*f);\n",
    "t=round(t*1e6);\n",
    "eavg=2*E/t;\n",
    "eavg=round(eavg/100)*100;\n",
    "print\"average restriking voltage=kV/microsecs\",eavg/1e3\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_7 pgno:35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average voltage in volts=V/microsecs 1430.0\n",
      "frequency of oscillation =c/s 7143.0\n"
     ]
    }
   ],
   "source": [
    "Em=100e3\n",
    "t=70e-6\n",
    "Ea=Em/t/1e6\n",
    "f=1/(2*t);\n",
    "Ea=round(Ea/10)*10;\n",
    "f=round(f);\n",
    "print\"average voltage in volts=V/microsecs\",Ea\n",
    "print\"frequency of oscillation =c/s\",f\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_8 pgno:37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "damping resistance in ohms=kohms 12.25\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "L=6; \n",
    "C=0.01e-6;\n",
    "i=10;\n",
    "v=i*sqrt(L/C);\n",
    "R=.5*v/i;\n",
    "R=round(R/10)*10;\n",
    "print\"damping resistance in ohms=kohms\",R/1e3\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}