summaryrefslogtreecommitdiff
path: root/Electrical_Network_by_R._Singh/Chapter8_1_1.ipynb
blob: f72a22fd5dd9335621c7f48b5a73e33212032807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
 "metadata": {
  "name": "",
  "signature": "sha256:443594b95e4699aa829647ef6201862e165405ad0d20cad94e2fc280e9a33ca5"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter8-Transient Analysis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex13-pg8.16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Transient analysis\n",
      "##pg no - 8.17\n",
      "##example no - 8.13\n",
      "import math\n",
      "import numpy\n",
      "a=((10.*30.)/(10.+30.));\n",
      "d=5./a;\n",
      "b=0.;\n",
      "c=5.*(20./30.);\n",
      "print\"%s %.2f %s\"%(\"iL(0-) = \",d,\" A\");\n",
      "print\"%s %.2f %s\"%(\"\\nvb(0-) = \", b,\"\");\n",
      "print\"%s %.2f %s\"%(\"\\nva(0-) = \",c,\" V\");\n",
      "print(\"Applying Kcl equations at t=0+\");\n",
      "print(\"((va(0+)-5)/10)+(va(0+)/10)+(va(0+)-vb(0+))/20 = 0\");        ##equation 1\n",
      "print(\"((vb(0+)-va(0+))/20)+((vb(0+)-5)/10)+(2/3) = 0\");            ##equation 2\n",
      "##solving 1 and 2\n",
      "M=numpy.matrix([[0.25, -0.05],[-0.05, 0.15]]);\n",
      "N=numpy.matrix([[0.5], [-0.167]]);\n",
      "\n",
      "X=numpy.dot(numpy.linalg.inv(M),N);\n",
      "print[X]\n",
      "print(\"va(0+)= 1.9 A\");\n",
      "print(\"vb(0+)= -0.477 A\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "iL(0-) =  0.67  A\n",
        "\n",
        "vb(0-) =  0.00 \n",
        "\n",
        "va(0-) =  3.33  V\n",
        "Applying Kcl equations at t=0+\n",
        "((va(0+)-5)/10)+(va(0+)/10)+(va(0+)-vb(0+))/20 = 0\n",
        "((vb(0+)-va(0+))/20)+((vb(0+)-5)/10)+(2/3) = 0\n",
        "[matrix([[ 1.90428571],\n",
        "        [-0.47857143]])]\n",
        "va(0+)= 1.9 A\n",
        "vb(0+)= -0.477 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex14-pg8.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Transient analysis\n",
      "##pg no - 8.17\n",
      "##example no - 8.13\n",
      "print(\"va(0+) = 5V\");\n",
      "print(\"vb(0+) = 5V\");\n",
      "print(\"vb(0+) = 5V\");\n",
      "print(\"Writing KCL Equation at t=0+\");\n",
      "print(\"0.25*va(0+) = 0.75\");\n",
      "x=(0.75)/(0.25);\n",
      "print\"%s %.2f %s\"%(\"va(0+) = \",x,\" V\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "va(0+) = 5V\n",
        "vb(0+) = 5V\n",
        "vb(0+) = 5V\n",
        "Writing KCL Equation at t=0+\n",
        "0.25*va(0+) = 0.75\n",
        "va(0+) =  3.00  V\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}