forked from guilda-dev/guilda_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (31 loc) · 1.06 KB
/
main.py
File metadata and controls
45 lines (31 loc) · 1.06 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
import numpy as np
from cmath import phase
from component import LoadCurrent
from power_network import PowerNetwork
from bus.bus import BusSlack, BusPV, BusPQ, Bus
from branch import BranchPi
y12 = 1.3652 - 11.6040j
y23 = -10.5107j
net = PowerNetwork()
net.add_bus(BusSlack(2, 0, 0))
net.add_bus(BusPQ(-3, 0, 0))
net.add_bus(BusPV(0.5, 2, 0))
net.a_bus[0].set_component(LoadCurrent())
net.a_bus[1].set_component(LoadCurrent())
net.a_bus[2].set_component(LoadCurrent())
a = BranchPi(1, 2, 1/y12, 0)
net.add_branch(BranchPi(1, 2, 1/y12, 0))
net.add_branch(BranchPi(2, 3, 1/y23, 0))
# Y, _ = net.get_admittance_matrix()
# V, I = net.calculate_power_flow()
# PQ = V * I.conjugate()
# P = PQ.real
# Q = PQ.imag
# print(P)
# print(Q)
net.initialize()
for idx in range(len(net.a_bus)):
print(f"bus{idx+1}のVst:{net.a_bus[idx].V_equilibrium}")
print(f"bus{idx+1}のIst:{net.a_bus[idx].I_equilibrium}")
print(f"bus{idx+1}のcomponentのIst:{net.a_bus[idx].component.V_equilibrium}")
print(f"bus{idx+1}のcomponentのIst:{net.a_bus[idx].component.I_equilibrium}")