at.lattice.lattice_variables#
Variables are references to scalar attributes of lattice elements. There are 2 kinds of element variables:
an
ElementVariable
is 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
RefptsVariable
is 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:
VariableBase
A reference to a scalar attribute of
Lattice
elements.It can refer to:
a scalar attribute or
an element of an array attribute
of one or several
Element
s of a lattice.An
ElementVariable
is 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:
- property elements#
Return the set of elements acted upon by the variable
- class RefptsVariable(refpts, attrname, index=None, **kwargs)[source]#
Bases:
VariableBase
A reference to a scalar attribute of
Lattice
elements.It can refer to:
a scalar attribute or
an element of an array attribute
of one or several
Element
s of a lattice.A
RefptsVariable
is not associated to element objets themselves, but to the location of these elements in a lattice. So aRefptsVariable
will act equally on any copy of the initial ring. As a consequence, a ring keyword argument (Lattice
object) 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) – If specified, it is used to get and store the initial value of the variable. Otherwise, the initial value is set to None