{
 "metadata": {
  "name": "",
  "signature": "sha256:76623e2b912c3ee572e7978144ba11bf11add72a64c001ac7cb23291cfabcb07"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 45: Transients and Laplace\n",
      "transforms</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 1, page no. 903</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "C  =  500E-9;#  in  Farad\n",
      "R  =  100000;#  in  Ohm\n",
      "V  =  50;#  in  VOlts\n",
      "ti  =  0.15;#  in  sec\n",
      "tc  =  0.08;#  in  sec\n",
      "Vrt  =  35;#  in  Volts\n",
      "\n",
      " #calculation:\n",
      " #Initial  current,  \n",
      "i0  =  (V/R)\n",
      " #when  time  t  =  150ms  current  is\n",
      "i150  =  (V/R)*math.e**(-1*ti/(R*C))\n",
      " #capacitor  voltage,  Vc\n",
      "Vc  =  V*(1  -  math.e**(-1*tc/(R*C)))\n",
      " #time,  t\n",
      "tvr  =  -1*R*C*math.log(Vrt/V)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  initial  value  of  current  flowing  is  \",round(i0*1E3,2),\"mA\"\n",
      "print  \"\\n  current  flowing  at  t  =  150ms  is  \",round(i150*1E6,2),\"uA\"\n",
      "print  \"\\n    value  of  capacitor  voltage  at  t  =  80ms  is  \",round(Vc,2),\"  V\"\n",
      "print  \"\\n    the  time  after  connection  when  the  resistor  voltage  is  35  V  is  \",round(tvr*1E3,2),\"msec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  initial  value  of  current  flowing  is   0.5 mA\n",
        "\n",
        "  current  flowing  at  t  =  150ms  is   24.89 uA\n",
        "\n",
        "    value  of  capacitor  voltage  at  t  =  80ms  is   39.91   V\n",
        "\n",
        "    the  time  after  connection  when  the  resistor  voltage  is  35  V  is   17.83 msec\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2, page no. 905</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "C  =  5E-6;#  in  Farad\n",
      "R  =  2000000;#  in  Ohm\n",
      "V  =  200;#  in  VOlts\n",
      "tc  =  20;#  in  sec\n",
      "\n",
      " #calculation:\n",
      " #capacitor  voltage,  Vc\n",
      "Vc  =  V*(math.e**(-1*tc/(R*C)))\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n    value  of  capacitor  voltage  at  t  =  20s  is  \",round(Vc,2),\"  V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "    value  of  capacitor  voltage  at  t  =  20s  is   27.07   V"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3, page no. 907</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "L  =  0.05;#  in  Henry\n",
      "R  =  5;#  in  Ohm\n",
      "V  =  110;#  in  VOlts\n",
      "ti  =  0.004;#  in  sec\n",
      "tvr  =  0.006;#  in  sec\n",
      "tvl  =  0.006;#  in  sec\n",
      "it  =  15;#  in  amperes\n",
      "\n",
      " #calculation:\n",
      " #steady  state  current  i\n",
      "i  =  V/R\n",
      " #when  time  t  =  4ms  current  is\n",
      "i4  =  (V/R)*(1  -  math.e**(-1*ti*R/L))\n",
      " #resistor  voltage,  VR\n",
      "VR6  =  V*(1  -  math.e**(-1*tvr*R/L))\n",
      " #inductor  voltage,  VL\n",
      "VL6  =  V*(math.e**(-1*tvl*R/L))\n",
      " #time,  t\n",
      "ti  =  (-1*L/R)*math.log(1  -  it*R/V)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  steady  state  current  i  is  \",round(i,2),\"  A\"\n",
      "print  \"\\n  when  time  t  =  4ms  current  is  is  \",round(i4,2),\"  A\"\n",
      "print  \"\\n    value  of  resistor  voltage  at  t  =  6ms  is  \",round(VR6,2),\"  V\"\n",
      "print  \"\\n    value  of  inductor  voltage  at  t  =  6ms  is  \",round(VL6,2),\"  V\"\n",
      "print  \"\\n    the  time  after  connection  when  the  current  is  15  V  is  \",round(ti,5),\"  sec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  steady  state  current  i  is   22.0   A\n",
        "\n",
        "  when  time  t  =  4ms  current  is  is   7.25   A\n",
        "\n",
        "    value  of  resistor  voltage  at  t  =  6ms  is   49.63   V\n",
        "\n",
        "    value  of  inductor  voltage  at  t  =  6ms  is   60.37   V\n",
        "\n",
        "    the  time  after  connection  when  the  current  is  15  V  is   0.01145   sec"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 4, page no. 909</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "i  =  5;#  in  Amperes\n",
      "L  =  2#  in  Henry\n",
      "i1  =  0.2;#  in  Amperes\n",
      "R  =  10;#  in  Ohm\n",
      "\n",
      " #calculation:\n",
      " #time  t\n",
      "ti  =  (-1*L/R)*math.log(i1/i)\n",
      " #voltage  across  the  resistor  is  a  maximum  \n",
      "VRm  =  i*R\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n    time  t  for  the  current  in  the  2  H  inductor  to  fall  to  200  mA  is  \",round(ti,3),\"  sec\"\n",
      "print  \"\\n    max  voltage  across  the  resistor  is  \",VRm,\"  V\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "    time  t  for  the  current  in  the  2  H  inductor  to  fall  to  200  mA  is   0.644   sec\n",
        "\n",
        "    max  voltage  across  the  resistor  is   50   V"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5, page no. 911</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "L  =  0.002#  in  Henry\n",
      "R  =  1000;#  in  Ohm\n",
      "C1  =  5E-6;#  in  farad\n",
      "C2  =  5E-9;#  in  farad\n",
      "\n",
      " #calculation:\n",
      "a  =  (R/(2*L))**2\n",
      "b  =  1/(L*C1)\n",
      "if  (a>b):\n",
      "\ts1  =  \"overdamped\";\n",
      "elif  (a<b):\n",
      "\ts1  =  \"underdamped\";\n",
      "else:\n",
      "\ts1  =  \"critically  damped\";\n",
      "c  =  1/(L*C2)\n",
      "if  (a>c):\n",
      "\ts2  =  \"overdamped\";\n",
      "elif  (a<c):\n",
      "\ts2  =  \"underdamped\";\n",
      "else:\n",
      "\ts2  =  \"critically  damped\";\n",
      "\t\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n    circuit  is  \",s1\n",
      "print  \"\\n    if  C  =  5  nF,  circuit  is  \",s2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "    circuit  is   overdamped\n",
        "\n",
        "    if  C  =  5  nF,  circuit  is   underdamped"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 6, page no. 912</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "L  =  0.002#  in  Henry\n",
      "R  =  1000;#  in  Ohm\n",
      "\n",
      " #calculation:\n",
      "a  =  (R/(2*L))**2\n",
      " #for  critically  damped\n",
      "C  =  4*L/R**2\n",
      "\t\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n    capacitance  C  is  \",C*1E9,\"nF\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "    capacitance  C  is   8.0 nF"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 7, page no. 913</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "L  =  1.5#  in  Henry\n",
      "R  =  90;#  in  Ohm\n",
      "C = 5*1E-6; # in Farad\n",
      "V = 10; # in Volts\n",
      "\n",
      "#calculation:\n",
      "a = -1*R/(2*L)\n",
      "b = (1/(L*C) - (R/(2*L))**2)**0.5\n",
      "V0 = V\n",
      "I0 = 0\n",
      "A = V0\n",
      "B = (I0 - C*a*V0)/(C*b)\n",
      "\n",
      "#Results\n",
      "print \"\\n\\n  Result  \\n\\n\"\n",
      "print \"Current, i = e^(\",a,\"t) (\",round((a*C*B - A*C*b),4),\"sin(\",round(b,1),\"t)  + (\",round((-1*a*C*A + B*C*C*b),0),\"cos(\",round(b,1),\"t) Amps.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "Current, i = e^( -30.0 t) ( -0.0183 sin( 363.9 t)  + ( 0.0 cos( 363.9 t) Amps.\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}