-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLoad3.py
More file actions
104 lines (90 loc) · 2.96 KB
/
Copy pathLoad3.py
File metadata and controls
104 lines (90 loc) · 2.96 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
from pylon.util import _Named
from numpy import array,conj,zeros
from numpy import dot
from Bus3 import Bus3
from constants import A
D=array([[1.0,-1.0,0.0],[0.0,1.0,-1.0],[-1.0,0.0,1.0]])
DI=D.transpose().copy()
class noConnectionSpecified(Exception):
def __init__(self, expr, msg):
self.expr = expr
self.msg = msg
class Load3(_Named):
def __init__(self,Sa=0.0,Sb=0.0,Sc=0.0,connection='delta',type='CS', bus=Bus3()):
"""
Load3 is a CONSTANT-POWER three-phase load model.
"""
self.S=array([Sa,Sb,Sc]) # complex power in kVA
self.connection=connection
self.type=type
self.bus=bus
self.E=self.bus.E
self.Ell=dot(D,self.E)
self.Iterm=0
self.calculateLineCurrent()
def calculateLineCurrent(self):
"""
Calculate the terminal current of this load.
"""
self.E=self.bus.E
self.Ell=dot(D,self.E)
if self.connection=='delta':
self.Ill=conj(self.S/self.Ell) # delta current
self.Iterm= dot(DI,self.Ill) # delta current to line current
elif self.connection=='wye':
self.Iln=conj(self.S/self.E)
self.Iterm=self.Iln
else:
raise noConnectionSpecified
class Load3CZ(Load3):
def __init__(self,Z,connection='delta',bus=Bus3()):
"""
Load3 is a CONSTANT-IMPEDANCE three-phase load model based on Load3.
"""
self.Za=Z[0]
self.Zb=Z[1]
self.Zc=Z[2]
self.Z=array([self.Za, self.Zb, self.Zc])
self.connection=connection
self.bus=bus
self.E=bus.E
def calculateLineCurrent(self):
"""
Calculate the terminal current of this load.
"""
self.E=self.bus.E
self.Ell=dot(D,self.E)
if self.connection=='delta':
self.Ill=self.Ell/self.Z # delta current
self.Iterm= dot(DI,self.Ill) # delta current to line current
elif self.connection=='wye':
self.Iln=self.E/self.Z
self.Iterm=self.Iln
else:
raise noConnectionSpecified
class Load3CI(Load3):
def __init__(self,I=zeros(3),connection='delta',bus=Bus3()):
"""
Load3 is a CONSTANT-CURRENT three-phase load model based on Load3.
"""
self.Ia=I[0]
self.Ib=I[1]
self.Ic=I[2]
self.I=array([self.Ia, self.Ib, self.Ic])
self.connection=connection
self.bus=bus
self.E=bus.E
def calculateLineCurrent(self):
"""
Calculate the terminal current of this load.
"""
self.E=self.bus.E
self.Ell=dot(D,self.E)
if self.connection=='delta':
self.Ill=self.I # delta current
self.Iterm= dot(DI,self.Ill) # delta current to line current
elif self.connection=='wye':
self.Iln=self.I
self.Iterm=self.Iln
else:
raise noConnectionSpecified