You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide.rst
+14-19Lines changed: 14 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,14 +116,14 @@ Its length should be 16 times the length of the :code:`dba_cell`::
116
116
>>> dba_ring.length
117
117
192.0
118
118
119
-
The Base Tree
119
+
Direct children
120
120
---------------
121
121
122
-
The structure which defines the order of elements in our DBA ring can be thought of as a `Tree <https://wikipedia.org/wiki/Tree_structure>`_, where :code:`dba_ring` is the root, the :code:`dba_cell` objects are the nodes and the :code:`bend`, :code:`drift` and :code:`quad` elements are the leafes. The attribute which stores the order of objects within a lattice is therefore called :attr:`~Lattice.tree`. Try to output the tree for the :code:`dba_ring` and :code:`dba_cell` objects::
122
+
The structure which defines the order of elements in our DBA ring can be thought of as a `Tree <https://wikipedia.org/wiki/Tree_structure>`_, where :code:`dba_ring` is the root, the :code:`dba_cell` objects are the nodes and the :code:`bend`, :code:`drift` and :code:`quad` elements are the leafes. The attribute which stores the order of objects within a lattice is called :attr:`~Lattice.chilldren`. Try to pritn the children for the :code:`dba_ring` and :code:`dba_cell` objects::
@@ -149,23 +149,23 @@ This can be also visualized by calling the :meth:`Lattice.print_tree` method::
149
149
├─── Dipole
150
150
└─── Drift
151
151
152
-
As a nested structure is not always convenient to work with, there are three other representations of :attr:`~Lattice.tree` (internally called :code:`tree_properties`):
152
+
As a nested structure is not always convenient to work with, there are three other representations of the nested :attr:`~Lattice.children` attribute:
153
153
154
-
#. The :attr:`~Lattice.lattice` attribute
154
+
#. The :attr:`~Lattice.sequence` attribute
155
155
156
-
To loop over the exact arrangement of objects there is the :attr:`Lattice.lattice` attribute, which is a list of :class:`~Element` objects. It can be thought of a flattened version of the tree. The :attr:`~Lattice.lattice` attribute can be used in regular Python :code:`for ... in` loops::
156
+
To loop over the exact sequence of objects there is the :attr:`Lattice.sequence` attribute, which is a list of :class:`~Element` objects. It can be thought of a flattened version of :attr:`~Lattice.children`. The :attr:`~Lattice.sequence` attribute can be used in regular Python :code:`for ... in` loops::
157
157
158
-
>>> sum(element.length for element in dba_ring.lattice)
158
+
>>> sum(element.length for element in dba_ring.sequence)
159
159
192
160
160
161
-
As the :code:`dba_cell` does not contain any other lattices, the :attr:`~Lattice.lattice` and :attr:`~Lattice.tree` attributes should be equal::
161
+
As the :code:`dba_cell` does not contain any other lattices, the :attr:`~Lattice.sequence` and :attr:`~Lattice.children` attributes should be equal::
162
162
163
-
>>> dba_cell.tree == dba_cell.arrangement
163
+
>>> dba_cell.children == dba_cell.sequence
164
164
True
165
165
166
-
On the other hand, the :attr:`~Lattice.lattice` attribute of the :code:`dba_ring` should look different then its :attr:`~Lattice.tree`::
166
+
On the other hand, the :attr:`~Lattice.sequence` attribute of the :code:`dba_ring` should look different then its :attr:`~Lattice.children`::
@@ -192,7 +192,7 @@ As a nested structure is not always convenient to work with, there are three oth
192
192
193
193
#. The :attr:`~Lattice.sub_lattices` attribute
194
194
195
-
This attribute is equivalent to the :attr:`~Lattice.elements` attribute but for lattices. It contains all lattices within a given lattice, including grandchildren, great grandchildren, etc.
195
+
This attribute is equivalent to the :attr:`~Lattice.elements` attribute but for lattices. It contains all sub-lattices within a given lattice, including grandchildren, great grandchildren, etc.
196
196
The :attr:`~Lattice.sub_lattices` attribute should be empty for the :code:`dba_cell` as it does not contain any other lattices::
197
197
198
198
>>> dba_cell.sub_lattices
@@ -201,11 +201,7 @@ As a nested structure is not always convenient to work with, there are three oth
201
201
Adding and Removing Objects
202
202
---------------------------
203
203
204
-
As adding and removing objects from the :attr:`~Lattice.tree` significantly increased the
205
-
code complextetiy, it was decided that :attr:`~Lattice.tree` cannont be altered after the
206
-
:class:`Lattice` was created. If you needed to add/remove an object just create a new
207
-
:class:`Lattice` object or initially add an :class:`Element` with length zero, which can
208
-
be altered when needed.
204
+
As adding and removing objects from the :attr:`~Lattice.children` significantly increased the code complextetiy, so it was decided that :attr:`~Lattice.children` cannont be altered after a :class:`Lattice` instance was created. If you needed to add/remove an object just create a new :class:`Lattice` instance or add an :class:`Element` with length zero, which can be altered when needed.
209
205
210
206
Load and Save Lattice Files
211
207
---------------------------
@@ -289,7 +285,6 @@ Signals and Events
289
285
290
286
As we have already seen in the :ref:`parent-lattices` section, the :attr:`~Lattice.length` of of a :class:`Lattice` gets updated whenever the length of one of its :class:`Element` objects changes. The same happens for the transfer matrices of the :class:`Twiss` object. This is not only convenient - as one does not have to call an :func:`update` function every time an attribute changes - but is also more efficient, because apace has internal knowledge about which elements have changed and can accordingly only update the transfer matrices which have actually changed.
291
287
292
-
293
288
This is achieved by a so called `Observer Pattern <https://wikipedia.org/wiki/Observer_pattern>`_, where an **subject** emits an **event** to all its **observers** whenever its state changes.
294
289
295
290
These events are implemented by the :class:`Signal` class. A callback can be connected to a given :class:`Signal` through the :meth:`~Signal.connect` method. Calling an instance of the :class:`Signal` will have the same effect as calling all connected callbacks.
0 commit comments