at.lattice.lattice_variables#
Definition of variables.
Variables are references to scalar attributes of lattice elements. There are 2 kinds of element variables:
an
ElementVariableis associated to an element object, and acts on all occurences of this object. But it will not affect any copy, neither shallow nor deep, of the original object,a
RefptsVariableis not associated to an element object, but to an element location in aLattice. It acts on any copy of the initial lattice. A ring argument must be provided to the set and get methods to identify the lattice, which may be a possibly modified copy of the original lattice
Classes
|
A reference to a scalar attribute of |
|
A reference to a scalar attribute of |
- class ElementVariable(elements, attrname, index=None, **kwargs)[source]#
Bases:
VariableBaseA reference to a scalar attribute of
Latticeelements.It can refer to:
a scalar attribute or
an element of an array attribute
of one or several
Elements of a lattice.An
ElementVariableis associated to an element object, and acts on all occurrences of this object. But it will not affect any copy, neither shallow nor deep, of the original object.- Parameters:
- Keyword Arguments:
- class RefptsVariable(refpts, attrname, index=None, **kwargs)[source]#
Bases:
VariableBaseA reference to a scalar attribute of
Latticeelements.It can refer to:
a scalar attribute or
an element of an array attribute
of one or several
Elements of a lattice.A
RefptsVariableis not associated to element objets themselves, but to the location of these elements in a lattice. So aRefptsVariablewill act equally on any copy of the initial ring. As a consequence, a ring keyword argument (Latticeobject) must be supplied for getting or setting the variable.- Parameters:
- Keyword Arguments:
name (str) – Name of the Variable. Default:
''bounds (tuple[float, float]) – Lower and upper bounds of the variable value. Default: (-inf, inf)
delta (float) – Step. Default: 1.0
ring (Lattice) – Default lattice. It will be used if ring is not provided to the
get()orset()methods. Note that if ring is fixed, you should consider using aElementVariableinstead.
- refpts: Refpts#