madgui.model.madx module¶
MAD-X backend for madgui.
Classes
|
Contains the whole global state of a MAD-X instance and (possibly) loaded metadata. |
|
Provide the following features on top of |
Functions
|
Create a direction reversed copy of the sequence. |
|
-
class
madgui.model.madx.
Model
(madx, data, *, filename=None, undo_stack=None, interpolate=0)[source]¶ Bases:
object
Contains the whole global state of a MAD-X instance and (possibly) loaded metadata.
- Variables
Attributes
dict() -> new empty dictionary
Get the beam parameter dictionary.
bool(x) -> bool
Return dict-like global variables.
Access to the low level cpymad API.
Return the dictionary of parameters for the MAD-X TWISS command.
list() -> new empty list
Signal<>
Methods
adjust_match_pos
(el, pos)backtrack
(**twiss_init)Backtrack final orbit through the reversed sequence.
call
(name)can_match_at
(element)contains
(element)destroy
()Annihilate current model.
el_pos
(el)Position for matching / output.
ex
()export_globals
([var_type])ey
()get_best_match_pos
(pos)Find optics element by longitudinal position.
get_elem_knobs
(elem)get_elem_sigma
(elem)get_elem_twiss
(elem)Find optics element by longitudinal position.
Get list of knobs.
get_orbit_response_matrix
(monitors, knobs[, …])Compute the orbit response matrix Δx/Δφ numerically (by varying knobs) and return as M×2×K matrix (monitors × x|y × knobs).
get_transfer_maps
(elems[, interval])Get the transfer matrices R(i,j) between the given elements.
get_twiss
(elem, name, pos)Return beam envelope at element.
Invalidate twiss and sectormap computations.
load_file
(filename[, madx, undo_stack, …])Load model from .madx or .yml file and pass additional arguments to the Model constructor.
load_strengths
(filename)match
(vary, constraints[, mirror_mode])Return model data as dictionary.
parse_range
(range)Convert a range str/tuple to a tuple of
Element
.read_monitor
(name)Mitigates read access to a monitor.
read_param
(expr)Read element attribute.
reverse
()save
(filename)Save model to file.
sector
()Compute sectormaps of all elements.
sectormap
(elem_from[, elem_to, interval])Return SECTORMAP|KICKS in the closed range [from,to] as 7x7 matrix.
set_element_attribute
(elem, attr, value)survey
()Recalculate survey coordinates.
track_one
([x, px, y, py, range])Track a particle through the sequence.
twiss
(**kwargs)Recalculate TWISS parameters.
update_beam
(beam[, text])update_element
(data, elem_index[, text])update_globals
(globals[, text])update_twiss_args
(twiss[, text])write_params
(globals[, text])-
ELEM_KNOBS
= {'hkicker': ['kick'], 'kicker': ['hkick', 'vkick'], 'multipole': ['knl', 'ksl'], 'quadrupole': ['k1', 'k1s'], 'sbend': ['angle', 'k0'], 'solenoid': ['ks'], 'srotation': ['angle'], 'vkicker': ['kick']}¶
-
backseq
= None¶
-
property
beam
¶ Get the beam parameter dictionary.
-
continuous_matching
= False¶
-
get_orbit_response_matrix
(monitors, knobs, errors=(), values=()) → numpy.array[source]¶ Compute the orbit response matrix Δx/Δφ numerically (by varying knobs) and return as M×2×K matrix (monitors × x|y × knobs).
-
get_transfer_maps
(elems, interval=1, 1)[source]¶ Get the transfer matrices R(i,j) between the given elements.
The
interval
parameter can be used to select open/closedness of the individual intervals between the elements by adding offsets to the first and second element in every interval, counted from the entry end of the element.For example, by setting the
interval
parameter, the callget_transfer_maps([e0, e1, e2], interval)
will retrieve the transfer maps in the following intervals:interval=(0, 0)
retrieves[e0, e1)
and[e1, e2)
interval=(0, 1)
retrieves[e0, e1]
and[e1, e2]
interval=(1, 0)
retrieves(e0, e1)
and(e1, e2)
interval=(1, 1)
retrieves(e0, e1]
and(e1, e2]
-
property
globals
¶ Return dict-like global variables.
-
property
libmadx
¶ Access to the low level cpymad API.
-
classmethod
load_file
(filename, madx=None, *, undo_stack=None, interpolate=0, **madx_kwargs)[source]¶ Load model from .madx or .yml file and pass additional arguments to the Model constructor.
-
sectormap
(elem_from, elem_to=None, interval=None)[source]¶ Return SECTORMAP|KICKS in the closed range [from,to] as 7x7 matrix.
If only one parameter is given, return its transfer map.
Elements can be specified by name or index.
For a description of the
interval
parameter, seeget_transfer_maps()
.
-
track_one
(x=0, px=0, y=0, py=0, range='#s/#e', **kwargs)[source]¶ Track a particle through the sequence. Handles backward tracking (sort of) by specifying a negative range.
Currently uses TWISS for tracking internally (to allow tracking through thick sequences). This might change.
-
property
twiss_args
¶ Return the dictionary of parameters for the MAD-X TWISS command.
-
twiss_columns
= ['alfx', 'alfy', 'betx', 'bety', 'gamx', 'gamy', 'ex', 'ey', 'x', 'y', 'px', 'py', 'envx', 'envy']¶
-
updated
¶ Signal<>
-
write_params
(globals, text='Change knobs: {}')¶
-
class
madgui.model.madx.
TwissTable
(name, libmadx, _check=True)[source]¶ Bases:
cpymad.madx.Table
Provide the following features on top of
cpymad.madx.Table
:add columns for one-sigma beam envelopes: envx, envy
add columns for gamma optical function: gamx, gamy
add aliases for beam position: posx, posy
override twiss alfa/beta parameters and emittances from the sigma matrix, i.e. in the local reference rather than normal coordinates.