-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.py
More file actions
106 lines (88 loc) · 2.4 KB
/
Copy pathtool.py
File metadata and controls
106 lines (88 loc) · 2.4 KB
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
from numpy import arccos, cos, sin, angle, pi, array, dot
from Trafo3 import Trafo3
def P_to_S(P,pf):
"""
Calculate complex power given real power and lagging power factor
"""
theta=arccos(pf)
Samp=P/pf
S=Samp*cos(theta)+1j*Samp*sin(theta)
return S
def printPolar(E,kabs=1.0):
"""
print polar form of a complex number E. angle is in degree
"""
for bbb in E:
print "%.0f %.1f " % (abs(bbb*kabs),angle(bbb)*180/pi)
def polarToRect(magnitude,degree):
"""
convert polar complex number to its rectangular form
"""
result=magnitude*(cos(degree)+1j*sin(degree))
return result
def printCurrent(kasus):
"""
Print currents in each line.
"""
print "Currents (magnitude in V/ angle in degree)"
BR=[br for br in kasus.branches if not type(br)==Trafo3 ]
for br in BR:
print
base_i=(kasus.base_mva)/br.from_bus.base_kv
for index in range(3):
brb=br.I_line[index]
print "%4.1f %.1f " % (abs(brb)*base_i[index]*1000,angle(brb)*180/pi)
def printResult(E,kasus):
printVoltage(E)
printCurrent(kasus)
def printVoltage(E):
"""
Print Line-to-neutral Voltage
"""
for bb in E:
printPolar(bb,1000)
print
print
def printVoltagell(E):
"""
Print line-to-line voltage
"""
D=array([[1.0,-1.0,0.0],[0.0,1.0,-1.0],[-1.0,0.0,1.0]])
## E=[b.E*b.base_kv for b in kasus.buses]
for bb in E:
bb=dot(D,bb)
for bbb in bb:
print "%.1f %.1f " % (abs(bbb*1000),angle(bbb)*180/pi)
print
print
def printVoltageln(E):
"""
Print line-to-neutral voltages
"""
W=array([
[2.0,1.0,0.0],[0.0,2.0,1.0],[1.0,0.0,2.0]
])/3.0
D=array([[1.0,-1.0,0.0],[0.0,1.0,-1.0],[-1.0,0.0,1.0]])
for bb in E:
print bb
bbll=dot(D,bb)
bbln=dot(W,bbll)
print
for bbb in bbln:
print "%.0f %.1f " % (abs(bbb*1000),angle(bbb)*180/pi)
print
I=[br.I_line for br in kasus.branches]
def printVoltageng():
"""
Print Line-to-Ground Voltage
"""
W=array([
[2.0,1.0,0.0],[0.0,2.0,1.0],[1.0,0.0,2.0]
])/3.0
D=array([[1.0,-1.0,0.0],[0.0,1.0,-1.0],[-1.0,0.0,1.0]])
Elg=bus2.E
Ell=dot(D,Elg)
Eln=dot(W,Ell)
Eng=Elg-Eln
for bbb in Eng:
print "%.0f %.1f " % (abs(bbb*1000),angle(bbb)*180/pi)