Line

Group ordered sequence of elements or (nested) lines

class model.library.line.Line(name: str, sequence: list[Element | Line], propagate: bool = False, dp: float = 0.0, exact: bool = False, output: bool = False, matrix: bool = False)[source]

Line element

rtype:

Line

property angle: torch.Tensor

Get sequence angle

Parameters:

None

Return type:

Tensor

property dp: torch.Tensor

Get momentum deviation

Parameters:

None

Return type:

Tensor

property exact: bool

Get exact flag

Parameters:

None

Return type:

bool

property flag: bool

Get layout flag

Parameters:

None

Return type:

Tensor

get(attribute: str, *, kinds: list[str] | None = None, names: list[str] | None = None) list[str, Any][source]

Get given attribute from selected elements

Parameters:
  • attribute (str) – target attribute name

  • kinds (Optional[list[str]]) – list of kinds to select

  • names (Optional[list[str]]) – list of names to select

Return type:

list[str, Any]

layout() list[tuple[str, str, torch.Tensor, torch.Tensor]][source]

Generate data for layout plotting

Parameters:

None

Returns:

(name,type,length,angle)

Return type:

list[tuple[str,str,Tensor,Tensor]]

property length: torch.Tensor

Get sequence length

Parameters:

None

Return type:

Tensor

make_matrix()[source]

Generate transformation matrices (error element)

Parameters:

None

Return type:

tuple[Tensor, Tensor]

make_step()[source]

Generate integration step

Parameters:

None

Return type:

tuple[Mapping, ParametricMapping]

property matrix: bool

Get matrix flag

Parameters:

None

Return type:

bool

property name: str

Get name

Parameters:

None

Return type:

str

property ns: dict[str, int]

Get number of integration steps for all unique elements

Parameters:

None

Return type:

dict[str, int]

property order: dict[str, int]

Get integration order for all unique elements

Parameters:

None

Return type:

dict[str, int]

property output: bool

Get output flag

Parameters:

None

Return type:

bool

scan(attribute: str)[source]

Scan line and yeild (with duplicates) all elements with given attribute

Parameters:
  • attribute (str) – target attribute name

  • Yeilds

  • ------

  • Element

static select(elements: list[Element], *, kinds: list[str] | None = None, names: list[str] | None = None) list[Element][source]

Select (filter) elements with given kinds and/or names

Parameters:
  • kinds (Optional[list[str]]) – list of kinds to select

  • names (Optional[list[str]]) – list of names to select

Return type:

list[Element]

property sequence: list[Element | Line]

Get sequence

Parameters:

None

Return type:

list[Element|Line]

set(attribute: str, value: Any, *, kinds: list[str] | None = None, names: list[str] | None = None) None[source]

Set value to a given attribute for selected elements

Parameters:
  • attribute (str) – target attribute name

  • value (Any) – value to set

  • kinds (Optional[list[str]]) – list of kinds to select

  • names (Optional[list[str]]) – list of names to select

Return type:

None

table(*, name: bool = False, alignment: bool = True) dict[str, dict[str, torch.Tensor]] | dict[str, dict[str, dict[str, torch.Tensor]]][source]

Generate default deviation table for all unique elements

Parameters:

None

Return type:

dict[str,dict[str,Tensor]] | dict[str,dict[str,dict[str,Tensor]]]

model.library.line.accumulate(data: dict[str, Tensor | dict[str, Tensor]], attribute: str) float | Tensor[source]

Accumulate selected attibute value

Parameters:
  • data (dict[str, Tensor|dict[str, Tensor]]) – input data

  • attibute (str) – selected attribute