Skip to content

Commit

Permalink
Refactor element containers in Store
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-thom committed Nov 12, 2020
1 parent 9f1a8f5 commit 266cdef
Show file tree
Hide file tree
Showing 63 changed files with 695 additions and 649 deletions.
1 change: 0 additions & 1 deletion ditto/metric_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def compute(self):
self.reader.parse(self.m)

self.net = network_analyzer(self.m)
self.net.model.set_names()
# If we compute the metrics per feeder, we need to have the objects taged with their feeder_names
if self.by_feeder:
# Split the network into feeders (assumes objects have been taged)
Expand Down
27 changes: 10 additions & 17 deletions ditto/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,19 @@ class DiTToHasTraits(T.HasTraits):

response = T.Any(allow_none=True, help="default trait for managing return values")

def __init__(self, model, *args, **kwargs):
model.model_store.append(self)
self.build(model)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def set_name(self, model):
try:
name = self.name
if name in model.model_names:
warnings.warn("Duplicate name %s being set. Object overwritten." % name)
logger.debug("Duplicate name %s being set. Object overwritten." % name)
logger.debug(model.model_names[name], self)
model.model_names[name] = self
except AttributeError:
pass

def build(self, model):
raise NotImplementedError(
"Build function must be implemented by derived classes"
)
"""Optional function to perform post-init construction after an element
has been added to a model.
Parameters
----------
model : Store
"""
self._model = model

def notify_access(self, bunch):
if not isinstance(bunch, T.Bunch):
Expand Down
3 changes: 0 additions & 3 deletions ditto/models/capacitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,3 @@ class Capacitor(DiTToHasTraits):
help="""Flag that indicates wheter the element is inside a substation or not.""",
default_value=False,
)

def build(self, model):
self._model = model
4 changes: 0 additions & 4 deletions ditto/models/feeder_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,3 @@ class Feeder_metadata(DiTToHasTraits):
help="""Negative sequence reactance for the source equivalent.""",
default_value=None,
)

def build(self, model, Asset=None, ConnectivityNode=None, Location=None):

self._model = model
28 changes: 14 additions & 14 deletions ditto/models/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ class Line(DiTToHasTraits):
default_value=None,
)

def build(
self,
model,
Asset=None,
Line=None,
ACLineSegment=None,
PSRType=None,
baseVoltage=None,
wireSpacingInfo=None,
Location=None,
Terminal1=None,
Terminal2=None,
):
#def build(
# self,
# model,
# Asset=None,
# Line=None,
# ACLineSegment=None,
# PSRType=None,
# baseVoltage=None,
# wireSpacingInfo=None,
# Location=None,
# Terminal1=None,
# Terminal2=None,
#):

pass
# pass


#
Expand Down
3 changes: 0 additions & 3 deletions ditto/models/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,3 @@ class Load(DiTToHasTraits):
help="""Percentage of the load between active 1 and active 2. Should be a float between 0 and 1.""",
default_value=None,
)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/load_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ class LoadLayer(DiTToHasTraits):
Instance(Position),
help="""This parameter is a list of positional points describing the load data. The positions are objects containing elements of long, lat and elevation (See Position object documentation).""",
)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ class Meter(DiTToHasTraits):
Instance(Unicode),
help="""This parameter is a list of all the phases at the node. The Phases are Strings of 'A', 'B', 'C', 'N', 's1' or 's2' (for secondaries).""",
)

def build(self, model):
self._model = model
5 changes: 1 addition & 4 deletions ditto/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ class Node(DiTToHasTraits):
default_value=None,
)

def build(self, model, Asset=None, ConnectivityNode=None, Location=None):

self._model = model

#def build(self, model, Asset=None, ConnectivityNode=None, Location=None):

# if ConnectivityNode is None:
# self._cn = self._model.env.ConnectivityNode()
Expand Down
3 changes: 0 additions & 3 deletions ditto/models/phase_capacitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ class PhaseCapacitor(DiTToHasTraits):
help="""The normal number of sections connected to this phase""",
default_value=None,
)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/phase_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,3 @@ class PhaseLoad(DiTToHasTraits):
help="""This is the portion of reactive power load modeled as constant impedance. Reactive portions of current, power and impedance should all add to 1. Used for ZIP models.""",
default_value=None,
)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/phase_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,3 @@ class PhaseReactor(DiTToHasTraits):
reactance = Float(
help="""The total reactance of the phase reactor.""", default_value=None
)

def build(self, model):
self._model = model
6 changes: 0 additions & 6 deletions ditto/models/phase_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@ class PhaseStorage(DiTToHasTraits):
default_value=None,
)
q = Float(help="""Present var value. In vars.""", default_value=None)

def build(self, model):
"""
TODO...
"""
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/phase_winding.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ class PhaseWinding(DiTToHasTraits):
compensator_x = Float(
help="""The compensator reactance value for the phase""", default_value=None
)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/photovoltaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,3 @@ class Photovoltaic(DiTToHasTraits):
feeder_name = Unicode(
help="""The name of the feeder the object is on.""",
).tag(default=None)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ class Position(DiTToHasTraits):
long = Float(help="""Decimal Longitude""")
lat = Float(help="""Decimal Latitude""")
elevation = Float(help="""Decimal elevation (meters)""")

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/power_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,3 @@ class PowerSource(DiTToHasTraits):
zero_sequence_impedance = Complex(
help="""Zero-sequence impedance of the source.""", default_value=None
)

def build(self, model):
self._model = model
7 changes: 0 additions & 7 deletions ditto/models/powertransformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,3 @@ class PowerTransformer(DiTToHasTraits):
help="""The name of the substation to which the object is connected.""",
)
feeder_name = Unicode(help="""The name of the feeder the object is on.""",)

def build(self, model):
"""
The high and low properties are used to creat windings which are added to the windings list
Winding data (e.g. high_ground_reactance) should be referenced thorugh the windings list
"""
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,3 @@ class Reactor(DiTToHasTraits):
#
# impedance_matrix = List(List(Complex),help='''This provides the matrix representation of the reactor impedance in complex form. Computed from the values of GMR and distances of individual wires. Kron reduction is applied to make this a 3x3 matrix.''')
# capacitance_matrix = List(List(Complex),help='''This provides the matrix representation of the reactor capacitance in complex form. Computed from the values of diameters and distances of individual wires. Kron reduction is applied to make this a 3x3 matrix.''')

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/regulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,3 @@ class Regulator(DiTToHasTraits):
help="""Flag that indicates wheter the element is inside a substation or not.""",
default_value=False,
)

def build(self, model):
self._model = model
6 changes: 0 additions & 6 deletions ditto/models/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,3 @@ class Storage(DiTToHasTraits):
help="""Flag that indicates wheter the element is inside a substation or not.""",
default_value=False,
)

def build(self, model):
"""
TODO...
"""
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,3 @@ class Timeseries(DiTToHasTraits):
feeder_name = Unicode(
help="""The name of the feeder the object is on.""",
).tag(default=None)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/weather_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ class WeatherLayer(DiTToHasTraits):
Instance(Position),
help="""This parameter is a list of positional points describing the weather data. The positions are objects containing elements of long, lat and elevation (See Position object documentation).""",
)

def build(self, model):
self._model = model
3 changes: 0 additions & 3 deletions ditto/models/winding.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,3 @@ class Winding(DiTToHasTraits):
emergency_power = Float(
help="""The emergency power of the winding""", default_value=None
)

def build(self, model):
self._model = model
6 changes: 3 additions & 3 deletions ditto/models/wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ class Wire(DiTToHasTraits):
default_value=None,
)

def build(self, model):
self._model = model
pass
# def build(self, model):
# self._model = model
# pass


# self._wp = self._model.env.WirePosition()
Expand Down
Loading

0 comments on commit 266cdef

Please sign in to comment.