Python类与对象
程序员文章站
2024-03-16 10:14:25
...
class input_net_args(object):
def __init__(self, arg_line, arg_node, arg_init_val):
self.Line = arg_line
self.Node = arg_node
self._Init_val = arg_init_val
self.Init_val = []
self.Node_infos = []
self._line_admittance = []
self.G = []
self.B = []
self.Order = 0
self._line_args_conv()
def _line_args_conv(self):
for item in self.Line:
temp = item
temp[2], temp[3] = self.impedance2admittance(item[2], item[3])
self._line_admittance.append(temp)
def impedance2admittance(self, R, X):
return self._complx_reciprocal(R, X)
def _complx_reciprocal(self, real, imag):
mod = real*real + imag*imag
return real/mod, imag/mod
class NL_Iteration(object):
def __init__(self, infos):
self.infos = infos
self.init_value = self.infos.Init_val
self._delta_P_PQ = []
self._delta_Q_PQ = []
self._delta_P_PV = []
self._delta_U_PV = []
self.delta_left = []
self.J = []
def infom(self):
for item in self.infos.Line:
print(item)
Line_arg = [
[1 , 2 , 0.00037 , 0.00404 , 0 , 0.12264],
[2 , 3 , 0.00023 , 0.00309 , 0 , 0.16046],
[2 , 4 , 0.000585 , 0.07445 , 0 , 1.61600],
[4 , 5 , 0.00006 , 0.00170 , 0 , 0.53379],
[5 , 3 , 0.00052 , 0.00702 , 0 , 1.46965],
[5 , 10 , 0.00030 , 0.00459 , 0 , 1.00998],
[5 , 9 , 0.00068 , 0.00830 , 0 , 1.63571],
[10 , 14 , 0.00005 , 0.00045 , 0 , 0.09629],
[10 , 9 , 0.00013 , 0.00148 , 0 , 0.30356],
[9 , 11 , 0.00243 , 0.00942 , 0 , 0.03080],
[9 , 13 , 0.00034 , 0.00455 , 0 , 0.40547],
[9 , 8 , 0.00070 , 0.00885 , 0 , 1.82756],
[8 , 12 , 0.00025 , 0.00046 , 0 , 0.97515],
[8 , 7 , 0.00046 , 0.00057 , 0 , 1.04222],
[7 , 15 , 0.00049 , 0.00511 , 0 , 0.24952],
[7 , 6 , 0.00046 , 0.00637 , 0 , 1.25707],
[6 , 16 , 0.00015 , 0.00187 , 0 , 0.09495],
[6 , 3 , 0.00113 , 0.01521 , 0 , 0.71247],
[17 , 14 , 0.00023 , 0.019500 , 0 , 0],
[18 , 4 , 0.00012 , 0.012199 , 0 , 0],
[19 , 15 , 0.00060 , 0.044110 , 0 , 0],
[20 , 16 , 0.00022 , 0.019280 , 0 , 0]
]
Node_args = [
[1 , "pq" , {"p":3.98600, "q":0.1640} ],
[2 , "pq" , {"P":3.46400, "Q":0.0000} ],
[3 , "pq" , {"P":8.31100, "Q":-0.686} ],
[4 , "pq" , {"P":0.00000, "Q":0.0000} ],
[5 , "pq" , {"P":1.17400, "Q":3.8850} ],
[6 , "pq" , {"p":15.0900, "q":-3.781} ],
[7 , "pq" , {"P":3.18600, "Q":0.7900} ],
[8 , "pq" , {"P":5.72100, "Q":3.6850} ],
[9 , "pq" , {"P":14.9710, "Q":-1.466} ],
[10, "pq" , {"P":9.07100, "Q":0.7590} ],
[11, "pq" , {"P":6.29200, "Q":-3.761} ],
[12, "pq" , {"P":5.47700, "Q":-2.305} ],
[13, "pq" , {"P":12.2850, "Q":1.2770} ],
[14, "pq" , {"P":0, "Q":0} ],
[15, "pq" , {"P":0, "Q":0} ],
[16, "pq" , {"P":0, "Q":0} ],
[17, "pv" , {"P":11.3330, "v":0.9931} ],
[18, "pv" , {"P":55.7030, "v":0.9884} ],
[19, "pv" , {"P":5.98600, "v":0.9815} ],
[20, "slack" , {"V":1.0, "Theta":-0.7828} ]
]
Init_val = [
[1, {"e":1.02, "f":0}],
[2, {"e":1, "f":0}],
[3, {"e":1, "f":0}],
[4, {"e":0.605533, "f":-0.781194}],
[5, {"e":0.556615, "f":-0.813259}],
[6, {"e":0.63727226, "f":-0.6927696}],
[7, {"e":0.561588141, "f":-0.786478}],
[8, {"e":0.4674631, "f":-0.8591612}],
[9, {"e":0.428363, "f":-0.8940802}],
[10, {"e":0.463429, "f":-0.87664366}],
[11, {"e":0.4069631, "f":-0.9118022}],
[12, {"e":0.4503565, "f":-0.8830939}],
[13, {"e":0.3723258, "f":-0.9114882}],
[14, {"e":0.4080243, "f":-0.9054081}],
[15, {"e":0.5949248, "f":-0.7806451}],
[16, {"e":1.02, "f":0}],
[17, {"e":0.3723258, "f":-0.9114882}],
[18, {"e":0.4080243, "f":-0.9054081}],
[19, {"e":0.5949248, "f":-0.7806451}],
[20, {"e":1.02, "f":0}]
]
args = input_net_args(Line_arg, Node_args, Init_val)
nl = NL_Iteration(args)
nl.infom()
上一篇: 详解Python类与对象