{
 "metadata": {
  "name": "",
  "signature": "sha256:2be08065faf70b8c9889fbaac9066fd5a40c67a58f214d2053087d37cdf109b8"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8 : First order Circuits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.1  Page No : 139"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#Example 8.1\")\n",
      "\n",
      "# Given\n",
      "#capacitance is 1uF\")\n",
      "#resistance is 1Mohm\")\n",
      "#Voltage across capacitor is 10V\")\n",
      "R = 1*10**6;\n",
      "C = 1*10**-6;\n",
      "V = 10\n",
      "#Let T be time consmath.tant\n",
      "T = R*C\n",
      "#v(t) = V*exp(-t/T)\n",
      "#v(t) = 10*exp(-t)      (1)\")\n",
      "#Substituting value of t = 5 in (1)\n",
      "v5 = 10*math.exp(-5)\n",
      "\n",
      "# Results\n",
      "print \"Time constant is %ds\"%(T)\n",
      "print \"v5) = %0.3fV\"%(v5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time constant is 1s\n",
        "v5) = 0.067V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.10  Page No : 142"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#Example 8.10\")\n",
      "\n",
      "# Given\n",
      "#vs =  5V         t<0\")\n",
      "#vs = 5*math.sin(w*t)  t>0\")\n",
      "vs = 5;\n",
      "R = 5;\n",
      "L = 10*10**-3;\n",
      "#At t<0\n",
      "\n",
      "# Calculation and Results\n",
      "#Inductor behaves as a short circuit\n",
      "#Let i(0-) = i\n",
      "i = vs/R;\n",
      "print \"i0-) = %dA\"%(i)\n",
      "#During the transition from t = 0- to t = 0+\n",
      "#Let i(0+) = i1\n",
      "i1 = i\n",
      "print \"i0+) = %dA\"%(i1)\n",
      "#Applying KVL equation to the loop\n",
      "#vs = i*R+v\")\n",
      "#Let v(0+) = v1 ; vs(0+) = vs1\n",
      "#From given vs(0+) = 0\n",
      "vs1 = 0;\n",
      "v1 = vs1-i*R\n",
      "print \"v0+) = %dV\"%(v1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i0-) = 1A\n",
        "i0+) = 1A\n",
        "v0+) = -5V\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}