1 # Copyright (C) 2010 Richard Lincoln
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
17 from CIM14
.Element
import Element
19 class PhaseImpedanceData(Element
):
20 """Triplet of resistance, reactance, and susceptance matrix element values.
23 def __init__(self
, r
=0.0, x
=0.0, sequenceNumber
=0, b
=0.0, PhaseImpedance
=None, *args
, **kw_args
):
24 """Initialises a new 'PhaseImpedanceData' instance.
26 @param r: Resistance matrix element value, per length of unit.
27 @param x: Reactance matrix element value, per length of unit.
28 @param sequenceNumber: Column-wise element index, assuming a symmetrical matrix. Ranges from 1 to N + N*(N-1)/2.
29 @param b: Susceptance matrix element value, per length of unit.
30 @param PhaseImpedance: Conductor phase impedance to which this data belongs.
32 #: Resistance matrix element value, per length of unit.
35 #: Reactance matrix element value, per length of unit.
38 #: Column-wise element index, assuming a symmetrical matrix. Ranges from 1 to N + N*(N-1)/2.
39 self
.sequenceNumber
= sequenceNumber
41 #: Susceptance matrix element value, per length of unit.
44 self
._PhaseImpedance
= None
45 self
.PhaseImpedance
= PhaseImpedance
47 super(PhaseImpedanceData
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["r", "x", "sequenceNumber", "b"]
50 _attr_types
= {"r": float, "x": float, "sequenceNumber": int, "b": float}
51 _defaults
= {"r": 0.0, "x": 0.0, "sequenceNumber": 0, "b": 0.0}
53 _refs
= ["PhaseImpedance"]
56 def getPhaseImpedance(self
):
57 """Conductor phase impedance to which this data belongs.
59 return self
._PhaseImpedance
61 def setPhaseImpedance(self
, value
):
62 if self
._PhaseImpedance
is not None:
63 filtered
= [x
for x
in self
.PhaseImpedance
.PhaseImpedanceData
if x
!= self
]
64 self
._PhaseImpedance
._PhaseImpedanceData
= filtered
66 self
._PhaseImpedance
= value
67 if self
._PhaseImpedance
is not None:
68 if self
not in self
._PhaseImpedance
._PhaseImpedanceData
:
69 self
._PhaseImpedance
._PhaseImpedanceData
.append(self
)
71 PhaseImpedance
= property(getPhaseImpedance
, setPhaseImpedance
)