{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 16 High Voltage Generation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.1 pgno:556"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Part (a)\n",
      "Ripple Voltage = 2000 V\n",
      "\n",
      "Part (b)\n",
      "Voltage drop = 11000.0 V\n",
      "\n",
      "Part (c)\n",
      "Average output voltage = 271.8 kV\n",
      "\n",
      "Part (d)\n",
      "Ripple Factor in percentage = 3.89 \n"
     ]
    }
   ],
   "source": [
    "#Determine the (a)ripple voltage (b)voltage drop (c)Average output volatge (d)ripple factor \n",
    "from math import sqrt\n",
    "\n",
    "I1 = 5*10**-3 # A\n",
    "C2 = 0.05*10**-6 # F\n",
    "C1 = 0.01*10**-6 # F\n",
    "Vs = 100 # kV\n",
    "f = 50 # Hz \n",
    "\n",
    "# (a) Ripple voltage\n",
    "print\"Part (a)\"\n",
    "delV = I1/(C2*f)\n",
    "print\"Ripple Voltage = %d V\"%delV\n",
    "# (b) Voltage drop \n",
    "print\"\\nPart (b)\"\n",
    "Vd = I1/f*((1/C1)+(1/(2*C2)))\n",
    "print\"Voltage drop = %.1f V\"%Vd\n",
    "# (c) Average output voltage \n",
    "print\"\\nPart (c)\"\n",
    "Vav = 2*Vs*sqrt(2)-Vd*10**-3\n",
    "print\"Average output voltage = %.1f kV\"%round(Vav,1)\n",
    "# (d) Ripple factor \n",
    "print\"\\nPart (d)\"\n",
    "RF = Vd*10**-3/(2*Vs*sqrt(2)) \n",
    "print\"Ripple Factor in percentage = %.2f \"%round(RF*100,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.2 pgno:556"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Part (a)\n",
      "Ripple Voltage = 21 kV\n",
      "\n",
      "Part (b)\n",
      "Voltage drop = 12.5 kV\n",
      "\n",
      "Part (c)\n",
      "Average output voltage = 411.76 kV\n",
      "\n",
      "Part (d)\n",
      "Ripple Factor in percentage = 2.95 \n"
     ]
    }
   ],
   "source": [
    "#Determine the (a)ripple voltage (b)voltage drop (c)Average output volatge (d)ripple factor \n",
    "from math import sqrt\n",
    "\n",
    "I1 = 5*10**-3 # A\n",
    "C3 = 0.10*10**-6 # F\n",
    "C2 = 0.05*10**-6 # F\n",
    "C1 = 0.01*10**-6 # F\n",
    "Vs = 100 # kV\n",
    "f = 50 # Hz \n",
    "\n",
    "# (a) Ripple voltage\n",
    "print\"\\nPart (a)\"\n",
    "delV = I1/f*((2/C1)+(1/C3))\n",
    "print\"Ripple Voltage = %d kV\"%(delV*10**-3)\n",
    "# (b) Voltage drop \n",
    "print\"\\nPart (b)\"\n",
    "Vd = I1/f*((1/C2)+(1/C1)+(1/(2*C3)))\n",
    "print\"Voltage drop = %.1f kV\"%round(Vd*10**-3,1)\n",
    "# (c) Average output voltage \n",
    "print\"\\nPart (c)\"\n",
    "Vav = 3*Vs*sqrt(2)-Vd*10**-3\n",
    "print\"Average output voltage = %.2f kV\"%round(Vav,2)\n",
    "# (d) Ripple factor \n",
    "print\"\\nPart (d)\"\n",
    "RF = Vd*10**-3/(3*Vs*sqrt(2)) \n",
    "print\"Ripple Factor in percentage = %.2f \"%round(RF*100,2)\n",
    "\n",
    "# Answers may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.3 pgno:557"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Part (a)\n",
      "Ripple Voltage = 52 kV\n",
      "\n",
      "Part (b)\n",
      "Voltage drop = 840.7 kV\n",
      "\n",
      "Part (c)\n",
      "Average output voltage = 5947.6 kV\n",
      "\n",
      "Part (d)\n",
      "Ripple Factor in percentage = 12.4\n",
      "\n",
      "Part (e)\n",
      "Optimum number of stages = 20 stages\n"
     ]
    }
   ],
   "source": [
    "#Determine the (a)ripple voltage (b)voltage drop (c)Average output volatge (d)ripple factor (e)optimum number of stages\n",
    "from math import sqrt\n",
    "\n",
    "I1 = 5*10**-3 # A\n",
    "C = 0.15*10**-6 # F\n",
    "Vs = 200. # kV\n",
    "f = 50 # Hz \n",
    "n = 12\n",
    "\n",
    "# (a) Ripple voltage\n",
    "print\"\\nPart (a)\"\n",
    "delV = I1*n*(n+1)/(f*C*2)\n",
    "print\"Ripple Voltage = %d kV\"%(delV*10**-3)\n",
    "# (b) Voltage drop \n",
    "print\"\\nPart (b)\"\n",
    "a = I1/(f*C)\n",
    "Vd = a*((2./3*n**3)+(n**2/2)-(n/6)+(n*(n+1)/4))\n",
    "print\"Voltage drop = %.1f kV\"%(Vd*10**-3)\n",
    "# (c) Average output voltage \n",
    "print\"\\nPart (c)\"\n",
    "Vav = 2*n*Vs*sqrt(2)-Vd*10**-3\n",
    "print\"Average output voltage = %.1f kV\"%Vav\n",
    "# (d) Ripple factor \n",
    "print\"\\nPart (d)\"\n",
    "RF = Vd*10**-3/(2*n*Vs*sqrt(2))\n",
    "print\"Ripple Factor in percentage = %.1f\"%(RF*100)\n",
    "# (e) Optimum number of stages\n",
    "print\"\\nPart (e)\"\n",
    "nopt = sqrt(Vs*sqrt(2)*10**3.*f*C/I1) \n",
    "print\"Optimum number of stages = %d stages\"%nopt\n",
    "\n",
    "# Answers may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.4 pgno:558"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reactance of the cable = 125 k ohm\n",
      "Leakage reactance of the transformer = 50 k ohm\n",
      "Additional series reactance = 75 k ohm\n",
      "Inductance of required series inductor = 238.7 H\n",
      "Total circuit resistance = 21.88 k ohm\n",
      "maximum current that can be supplied by the transformer = 0.4 A\n",
      "Exciting voltage of transformer secondary = 8.75 kV\n",
      "Input voltage of transformer primary = 7.7 V\n",
      "Input power of the transformer = 3.5 kW\n"
     ]
    }
   ],
   "source": [
    "#Determine the input voltage and power\n",
    "from math import pi\n",
    "\n",
    "Vc = 500*10**3        # V\n",
    "A = 4                 # A\n",
    "Xl = 8./100.          # in percentage \n",
    "kV = 250.\n",
    "Xc = Vc/A             # Reactance of the cable\n",
    "XL = Xl*(kV**2/100)*10**3 # Leakage reactance of the transformer\n",
    "Radd = Xc-XL          # Additional series reactance\n",
    "Ind = Radd/(2*pi*XL)  # Inductance of required series inductor\n",
    "R = 3.5/100.*(kV**2/100)*10**3  # Total circuit resistance\n",
    "Imax = 100./250.      # maximum current that can be supplied by the transformer\n",
    "Vex = Imax*R          # Exciting voltage of transformer secondary\n",
    "Vin = Vex*220/kV      # Input voltage of transformer primary\n",
    "P = Vin*100./220.     # Input power of the transformer\n",
    "print\"Reactance of the cable = %d k ohm\"%(Xc*10**-3)\n",
    "print\"Leakage reactance of the transformer = %d k ohm\"%(XL*10**-3)\n",
    "print\"Additional series reactance = %d k ohm\"%(Radd*10**-3)\n",
    "print\"Inductance of required series inductor = %.1f H\"%(Ind*10**3)\n",
    "print\"Total circuit resistance = %.2f k ohm\"%(R*10**-3)\n",
    "print\"maximum current that can be supplied by the transformer = %.1f A\"%(Imax)\n",
    "print\"Exciting voltage of transformer secondary = %.2f kV\"%(Vex*10**-3)\n",
    "print\"Input voltage of transformer primary = %.1f V\"%(Vin*10**-3)\n",
    "print\"Input power of the transformer = %.1f kW\"%(P*10**-3)\n",
    "\n",
    "# Answers may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.5 pgno:559"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Charging current= 0.5 micro A\n",
      "Potential difference = 50 MV\n"
     ]
    }
   ],
   "source": [
    "#Determine the charging current and potential difference\n",
    "\n",
    "ps = 0.5*10**-6 # C/m**2\n",
    "u = 10 # m/s\n",
    "w = 0.1 # m\n",
    "I = ps*u*w \n",
    "Rl = 10**14 # ohm\n",
    "V = I*Rl*10**-6\n",
    "print\"Charging current= %.1f micro A\"%(I*10**6)\n",
    "print\"Potential difference = %d MV\"%V\n",
    "\n",
    "# Answers may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.6 pgno:560"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Theta = 4.95 micro S\n",
      "Neta = 0.99\n",
      "Alpha = 6.96 \n",
      "\n",
      "T1 = 1.11 microS\n",
      "T2 = 49.97 microS\n",
      "Generated lighting impulse = 0.022222 wave\n",
      "alpha1 = 0.015 microS\n",
      "alpha2 = 2.80 microS\n",
      "e(t) = 99.722 * (e**-0.015t - f**-2.800t)\n"
     ]
    }
   ],
   "source": [
    "#Determine the wave generated\n",
    "from math import sqrt\n",
    "\n",
    "# With refrence to table 16.1\n",
    "C1 = 0.125*10**-6 # F\n",
    "C2 = 1*10**-9 # F\n",
    "R1 = 360. # ohm\n",
    "R2 = 544. # ohm\n",
    "V0 = 100. # kV\n",
    "\n",
    "theta = sqrt(C1*C2*R1*R2)\n",
    "neta = 1./(1+(1+R1/R2)*C2/C1)\n",
    "alpha = R2*C1/(2*theta*neta)\n",
    "print\"Theta = %.2f micro S\"%(theta*10**6)\n",
    "print\"Neta = %.2f\"%neta\n",
    "print\"Alpha = %.2f \"%alpha\n",
    "# Coresponding to alpha the following can be deduced from Fig 16.12\n",
    "T2 = 10.1*theta*10**6\n",
    "T1 = T2/45\n",
    "imp = T1/T2 # generated lighting impulse\n",
    "# From equations 16.41 and 16.42\n",
    "a1 = (alpha-sqrt(alpha**2-1))*10**-6/(theta) \n",
    "a2 = (alpha+sqrt(alpha**2-1))*10**-6/theta \n",
    "print\"\\nT1 = %.2f microS\"%T1\n",
    "print\"T2 = %.2f microS\"%T2\n",
    "print\"Generated lighting impulse = %f wave\"%imp\n",
    "print\"alpha1 = %.3f microS\"%a1\n",
    "print\"alpha2 = %.2f microS\"%a2\n",
    "# According to equation 16.40\n",
    "et = neta*(alpha*V0)/sqrt(alpha**2-1)\n",
    "print\"e(t) = %.3f * (e**%.3ft - f**%.3ft)\"%(et,round(-a1,3),round(-a2,2)) # Equation of the wave form generated by the impulese\n",
    "\n",
    "#Answers may vary due to round off error "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.7 pgno:561"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Theta = 4.95 micro S\n",
      "Neta = 0.60\n",
      "Alpha =  11.47\n",
      "T1 = 0.67 microS\n",
      "T2 = 80.40 microS\n",
      "alpha1 = 0.0088 microS\n",
      "alpha2 = 4.63 microS\n",
      "e(t) = 60.117 * (e**-0.009t - f**-4.630t)\n"
     ]
    }
   ],
   "source": [
    "#Determine the wave generated\n",
    "from math import sqrt\n",
    "\n",
    "C1 = 0.125*10**-6 # F\n",
    "C2 = 1*10**-9 # F\n",
    "R1 = 360. # ohm\n",
    "R2 = 544. # ohm\n",
    "V0 = 100. # kV\n",
    "\n",
    "theta = sqrt(C1*C2*R1*R2)\n",
    "neta = 1/(1+R1/R2+C2/C1)\n",
    "alpha = R2*C1/(2*theta*neta)\n",
    "print\"Theta = %.2f micro S\"%(theta*10**6)\n",
    "print\"Neta = %.2f\"%neta\n",
    "print\"Alpha =  %.2f\"%alpha\n",
    "# Coresponding to alpha the following can be deduced from Fig 16.12\n",
    "T2 = 16.25*theta*10**6\n",
    "T1 = T2/120.\n",
    "# From equations 16.41 and 16.42\n",
    "a1 = (alpha-sqrt(alpha**2-1))*10**-6/(theta) \n",
    "a2 = (alpha+sqrt(alpha**2-1))*10**-6/theta \n",
    "print\"T1 = %.2f microS\"%T1 # Answer given in the text is wrong\n",
    "print\"T2 = %.2f microS\"%T2 \n",
    "print\"alpha1 = %.4f microS\"%a1\n",
    "print\"alpha2 = %.2f microS\"%a2\n",
    "# According to equation 16.40\n",
    "et = neta*(alpha*V0)/sqrt(alpha**2-1)\n",
    "print\"e(t) = %.3f * (e**%.3ft - f**%.3ft)\"%(et,round(-a1,4),round(-a2,2)) # Equation of the wave form generated by the impulese\n",
    "\n",
    "#Answers may vary due to round off error "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.8 pgno:562"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Theta = 416.67 micro S\n",
      "X = 0.0630 \n",
      "R1 = 53.4 k Ohm\n",
      "R2 = 26.0 k Ohm\n",
      "neta = 0.976 \n"
     ]
    }
   ],
   "source": [
    "#Determine the circuit efficiency\n",
    "from math import sqrt\n",
    "\n",
    "C1 = 0.125*10**-6 # F\n",
    "C2 = 1*10**-9 # F\n",
    "T2 = 2500.\n",
    "T1 = 250.\n",
    "\n",
    "# Bsaed on Figure 16.12\n",
    "T2T1 = T2/T1\n",
    "a = 4. # alpha\n",
    "theta = T2/6.\n",
    "# From table 16.1\n",
    "X = (1/a**2)*(1+C2/C1)\n",
    "R1 = (a*theta*10**-6/C2)*(1-sqrt(1-X))\n",
    "R2 = (a*theta*10**-6/(C1+C2))*(1+sqrt(1-X))\n",
    "neta = 1/(1+(1+R1/R2)*C2/C1)\n",
    "print\"Theta = %.2f micro S\"%theta\n",
    "print\"X = %.4f \"%X\n",
    "print\"R1 = %.1f k Ohm\"%(R1*10**-3)\n",
    "print\"R2 = %.1f k Ohm\"%(R2*10**-3)\n",
    "print\"neta = %.3f \"%round(neta,3)\n",
    "\n",
    "# Answers may vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.9 pgno:563"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Theta = 5.26 micro S\n",
      "X = 0.026 \n",
      "V0 = 960.00 \n",
      "R1 = 434.55 Ohm\n",
      "R2 = 3187.33 Ohm\n",
      "R1/n = 54.32 Ohm\n",
      "R2/n = 398.42 Ohm\n",
      "neta = 0.95 \n",
      "Maximum output voltage = 908.39 kV\n",
      "Energy rating = 9.22 kJ\n"
     ]
    }
   ],
   "source": [
    "#Determine the maximum output voltage and energy rating\n",
    "from math import sqrt\n",
    "\n",
    "n = 8.\n",
    "C1 = 0.16/n # micro F\n",
    "C2 = 0.001 # micro F\n",
    "T2 = 50.\n",
    "T1 = 1.2\n",
    "\n",
    "# beased on figure 16.12\n",
    "a = 6.4 # alpha\n",
    "theta = T2/9.5\n",
    "X = (1./a**2)*(1.+C2/C1)\n",
    "R1 = (a*theta*10**-6/C2)*(1.-sqrt(1-X))\n",
    "R2 = (a*theta*10**-6/(C1+C2))*(1+sqrt(1-X))\n",
    "R1n = R1/n\n",
    "R2n = R2/n\n",
    "V0 = n*120 \n",
    "neta = 1/(1+(1+R1/R2)*C2/C1)\n",
    "V = neta*V0\n",
    "E = 1./2.*C1*V0**2 \n",
    "print\"Theta = %.2f micro S\"%theta\n",
    "print\"X = %.3f \"%X\n",
    "print\"V0 = %.2f \"%V0\n",
    "print\"R1 = %.2f Ohm\"%(R1*10**6) \n",
    "print\"R2 = %.2f Ohm\"%(R2*10**6)\n",
    "print\"R1/n = %.2f Ohm\"%(R1n*10**6)\n",
    "print\"R2/n = %.2f Ohm\"%(R2n*10**6)\n",
    "print\"neta = %.2f \"%neta\n",
    "print\"Maximum output voltage = %.2f kV\"%V\n",
    "print\"Energy rating = %.2f kJ\"%(E/1000)\n",
    "\n",
    "# Answers greatly vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.10 pgno:564"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R1 = 840.00 Ohm\n",
      "R2 = 4800.00 Ohm\n",
      "Theta = 6.48 microS\n",
      "Neta = 0.79\n",
      "Alpha = 4.90 \n",
      "T1 = 1.81 microS\n",
      "T2 = 45.37 microS\n"
     ]
    }
   ],
   "source": [
    "#Determine the from and tail times\n",
    "from math import sqrt\n",
    "\n",
    "n = 12.\n",
    "C1 = 0.125*10**-6/n # micro F\n",
    "C2 = 0.001*10**-6 # micro F\n",
    "R1 = 70.*n # ohm\n",
    "R2 = 400.*n # ohm\n",
    "\n",
    "# beased on figure 16.15\n",
    "theta = sqrt(C1*C2*R1*R2)\n",
    "neta = 1./(1+R1/R2+C2/C1)\n",
    "a = R2*C1/(2*theta*neta) # alpha\n",
    "T2 = 7.*theta*10**6\n",
    "T1 = T2/25\n",
    "print\"R1 = %.2f Ohm\"%R1 \n",
    "print\"R2 = %.2f Ohm\"%R2 \n",
    "print\"Theta = %.2f microS\"%(theta*10**6)\n",
    "print\"Neta = %.2f\"%neta\n",
    "print\"Alpha = %.2f \"%a\n",
    "print\"T1 = %.2f microS\"%round(T1,2) \n",
    "print\"T2 = %.2f microS\"%round(T2,2) \n",
    "\n",
    "# Answers greatly vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 16.7.11 pgno:564"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R = 1.97 ohm\n",
      "y = 1.23e+05 s**-1\n",
      "I(t) =  15.62* exp(-1.23e+05t) * sin(20000.00t) A\n"
     ]
    }
   ],
   "source": [
    "#Determine the equation generated by impulse\n",
    "from math import sqrt\n",
    "\n",
    "w = 0.02*10**6 # s**-1 obtained by solving eq 16.47 iteratively\n",
    "R = sqrt(4-(sqrt(8*8*4)*0.02)**2) # solved the simplified equation\n",
    "L = 8*10**-6\n",
    "V = 25*10**3\n",
    "# In equation 16.46\n",
    "y = R/(2.*L)\n",
    "# Deriving the equation\n",
    "a = V/(w*L)\n",
    "print\"R = %.2f ohm\"%R\n",
    "print\"y = %.2e s**-1\"%y\n",
    "print\"I(t) =  %.2f* exp(%.2et) * sin(%.2ft) A\"%(a/10000,round(-y,1),w)\n",
    "\n",
    "# Answers may vary due to round off error"
   ]
  }
 ],
 "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
}
