trnsystor.collections.ConstantCollection¶
-
class
trnsystor.collections.ConstantCollection(mutable=None, name=None, **kwargs)[source]¶ A class that behaves like a dict and collects one or more
Constants.You can pass a dict of Equation or you can pass a list of Equation. In the latter, the
Equation.nameattribute will be used as a key.Initialize a new ConstantCollection.
Example
>>> c_1 = Constant.from_expression("A = 1") >>> c_2 = Constant.from_expression("B = 2") >>> ConstantCollection([c_1, c_2])
- Parameters
mutable (Iterable, optional) – An iterable.
name (str) – A user defined name for this collection of constants. This name will be used to identify this block of constants in the .dck file;
-
update(E=None, **F)[source]¶ Update D from a dict/list/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[ k] = E[k] If E is present and lacks a .keys() method, then does: for cts.name, cts in E: D[cts.name] = cts In either case, this is followed by: for k in F: D[k] = F[k]
-
property
size¶ Return len(self).
-
property
unit_number¶ Return the unit_number of self. Negative by design.
Hint
Only
TrnsysModelobjects have a positive unit_number.
-
property
centroid¶ Returns the model’s center Point().
- Type
Point
-
clear() → None. Remove all items from D.¶
-
connect_to(other, mapping=None, link_style_kwargs=None)¶ Connect the outputs of
selfto the inputs ofother.Important
Keep in mind that since python traditionally uses 0-based indexing, the same logic is used in this package even though TRNSYS uses traditionally 1-based indexing. The package will internally handle the 1-based index in the output .dck file.
Examples
Connect two
TrnsysModelobjects together by creating a mapping of the outputs of pipe_1 to the intputs of pipe_2. In this example we connect output_0 of pipe_1 to input_0 of pipe_2 and output_1 of pipe_1 to input_1 of pipe_2:>>> pipe_1.connect_to(pipe_2, mapping={0:0, 1:1})
The same can be acheived using input/output names.
>>> pipe_1.connect_to(pipe_2, mapping={'Outlet_Air_Temperature': >>> 'Inlet_Air_Temperature', 'Outlet_Air_Humidity_Ratio': >>> 'Inlet_Air_Humidity_Ratio'})
-
copy()¶ Return copy of self.
-
get(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
property
inputs¶ returns the model’s inputs.
- Type
-
invalidate_connections()¶ Iterate over successors and predecessors and remove the edges.
Todo: restore paths in self.studio_canvas.grid
-
property
is_connected¶ Whether or not this Component is connected to another TypeVariable.
Connected to or connected by.
-
items() → a set-like object providing a view on D’s items¶
-
keys() → a set-like object providing a view on D’s keys¶
-
property
link_styles¶ Return
LinkStylesof self.
-
property
model¶ Return the path of this model’s proforma.
-
property
outputs¶ returns the model’s outputs.
- Type
-
pop(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem() → (k, v), remove and return some (key, value) pair¶ as a 2-tuple; but raise KeyError if D is empty.
-
property
predecessors¶ Other objects from which this TypeVariable is connected. Predecessors.
-
set_canvas_position(pt, trnsys_coords=False)¶ Set position of self in the canvas.
Use cartesian coordinates: origin 0,0 is at bottom-left.
Hint
The Studio Canvas origin corresponds to the top-left of the canvas. The x coordinates increase from left to right, while the y coordinates increase from top to bottom.
top-left = “* $POSITION 0 0”
bottom-left = “* $POSITION 0 2000”
top-right = “* $POSITION 2000” 0
bottom-right = “* $POSITION 2000 2000”
For convenience, users should deal with cartesian coordinates. trnsystor will deal with the transformation.
- Parameters
pt (Point or 2-tuple) – The Point geometry or a tuple of (x, y) coordinates.
trnsys_coords (bool) – Set to True of
ptis given in Trnsys Studio coordinates: origin 0,0 is at top-left.
-
set_component_layer(layers)¶ Change the layer of self. Pass a list to change multiple layers.
-
set_link_style(other, loc='best', color='#1f78b4', linestyle='-', linewidth=1, path=None)¶ Set outgoing link styles between self and other.
- Parameters
other (Component) – The destination model.
loc (str or tuple) – loc (str): The location of the anchor. The strings ‘top-left’, ‘top-right’, ‘bottom-left’, ‘bottom-right’ place the anchor point at the corresponding corner of the
TrnsysModel. The strings ‘top-center’, ‘center-right’, ‘bottom-center’, ‘center-left’ place the anchor point at the edge of the correspondingTrnsysModel. The string ‘best’ places the anchor point at the location, among the eight locations defined so far, with the shortest distance with the destinationTrnsysModel(other). The location can also be a 2-tuple giving the coordinates of the originTrnsysModeland the destinationTrnsysModel.color (str or tuple) – The color of the line. Accepts any matplotlib color. You can specify colors in many ways, including full names (‘green’), hex strings (‘#008000’), RGB or RGBA tuples ((0,1,0,1)) or grayscale intensities as a string (‘0.8’).
linestyle (str) – Possible values: ‘-‘ or ‘solid’, ‘–’ or ‘dashed’, ‘-.’ or ‘dashdot’, ‘:’ or ‘dotted’, ‘-.’ or ‘dashdotdot’.
linewidth (float) – The width of the line in points.
path (LineString or MultiLineString, optional) – The path of the link.
-
setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶
-
property
successors¶ Other objects to which this TypeVariable is connected. Successors.
-
property
type_number¶ 104for Type104.- Type
Return the model’s type number, eg.
-
property
unit_name¶ ‘Type104’.
- Type
Return the model’s unit name, eg.
-
values() → an object providing a view on D’s values¶