1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 from CIM14
.CDPSM
.Balanced
.IEC61970
.Wires
.ACLineSegment
import ACLineSegment
23 class DistributionLineSegment(ACLineSegment
):
24 """Extends ACLineSegment with references to a library of standard types from which electrical parameters can be calculated, as follows:
- calculate electrical parameters from asset data, using associated ConductorInfo, with values then multiplied by Conductor.length to produce a matrix model.
- calculate unbalanced electrical parameters from associated PerLengthPhaseImpedance, then multiplied by Conductor.length to produce a matrix model.
- calculate transposed electrical parameters from associated PerLengthSequenceImpedance, then multiplied by Conductor.length to produce a sequence model.
For symmetrical, transposed 3ph lines, it is sufficient to use inherited ACLineSegment attributes, which describe sequence impedances and admittances for the entire length of the segment.
Known issue: Attributes expressing impedances and admittances in PerLengthSequenceImpedance and PhaseImpedanceData use Resistance, etc., which describe pre-calculated, full length of segment, while we should have a longitudinal unit, per length. Taking 'r' as example, its 'unit'=Ohm, but the value is effectively in Ohm/m, so the value needs to be multiplied by Conductor.length. This is against the whole idea of unit data types and is semantically wrong, but base CIM does not have the required data types at this moment. Until the revision of unit modelling in CIM, applications need to deduce and locally handle appending '/m' for units and ensure they multiply the values by Conductor.length.At least one of the Associations must exist.
27 def __init__(self
, ConductorInfo
=None, SequenceImpedance
=None, PhaseImpedance
=None, *args
, **kw_args
):
28 """Initialises a new 'DistributionLineSegment' instance.
30 @param ConductorInfo: Conductor data of this conductor segment.
31 @param SequenceImpedance: Sequence impedance of this conductor segment; used for balanced model.
32 @param PhaseImpedance: Phase impedance of this conductor segment; used for unbalanced model.
34 self
._ConductorInfo
= None
35 self
.ConductorInfo
= ConductorInfo
37 self
._SequenceImpedance
= None
38 self
.SequenceImpedance
= SequenceImpedance
40 self
._PhaseImpedance
= None
41 self
.PhaseImpedance
= PhaseImpedance
43 super(DistributionLineSegment
, self
).__init
__(*args
, **kw_args
)
49 _refs
= ["ConductorInfo", "SequenceImpedance", "PhaseImpedance"]
52 def getConductorInfo(self
):
53 """Conductor data of this conductor segment.
55 return self
._ConductorInfo
57 def setConductorInfo(self
, value
):
58 if self
._ConductorInfo
is not None:
59 filtered
= [x
for x
in self
.ConductorInfo
.ConductorSegments
if x
!= self
]
60 self
._ConductorInfo
._ConductorSegments
= filtered
62 self
._ConductorInfo
= value
63 if self
._ConductorInfo
is not None:
64 if self
not in self
._ConductorInfo
._ConductorSegments
:
65 self
._ConductorInfo
._ConductorSegments
.append(self
)
67 ConductorInfo
= property(getConductorInfo
, setConductorInfo
)
69 def getSequenceImpedance(self
):
70 """Sequence impedance of this conductor segment; used for balanced model.
72 return self
._SequenceImpedance
74 def setSequenceImpedance(self
, value
):
75 if self
._SequenceImpedance
is not None:
76 filtered
= [x
for x
in self
.SequenceImpedance
.ConductorSegments
if x
!= self
]
77 self
._SequenceImpedance
._ConductorSegments
= filtered
79 self
._SequenceImpedance
= value
80 if self
._SequenceImpedance
is not None:
81 if self
not in self
._SequenceImpedance
._ConductorSegments
:
82 self
._SequenceImpedance
._ConductorSegments
.append(self
)
84 SequenceImpedance
= property(getSequenceImpedance
, setSequenceImpedance
)
86 def getPhaseImpedance(self
):
87 """Phase impedance of this conductor segment; used for unbalanced model.
89 return self
._PhaseImpedance
91 def setPhaseImpedance(self
, value
):
92 if self
._PhaseImpedance
is not None:
93 filtered
= [x
for x
in self
.PhaseImpedance
.ConductorSegments
if x
!= self
]
94 self
._PhaseImpedance
._ConductorSegments
= filtered
96 self
._PhaseImpedance
= value
97 if self
._PhaseImpedance
is not None:
98 if self
not in self
._PhaseImpedance
._ConductorSegments
:
99 self
._PhaseImpedance
._ConductorSegments
.append(self
)
101 PhaseImpedance
= property(getPhaseImpedance
, setPhaseImpedance
)