Accelerator models¶
The Madx class uses MADX via cpymad. Thus, it allows for usage
of the full spectrum of MADX features. Each model offers a few methods
for computing relevant quantities, such as compute_orm. In addition,
the Madx
model also offers a method for computing Twiss data via
compute_twiss.
Each of these methods computes the quantities for the current lattice
configuration but it is possible to specify temporary updates (for the
duration of the computation) to each of these methods; please refer to
the documentation of the different methods for details.
In general, each model offers a context manager temporary_update which allows to temporarily upate the model’s parameters until the context manager exits. For example:
with model.temporary_update(quadrupoles={'quad01': 0.1}):
orm = model.compute_orm()
This example uses the shorthand function parameter quadrupoles
to directly specify
quadrupoles names and the desired k1-values. Since each of the compute_*
methods
only expects a general configuration
object, the usage of the shorthand quadrupoles
is possible with the helper function build_configuration_from_parameter_values.
The following example is equivalent to the one above:
config = model.build_configuration_from_parameter_values(quadrupoles={'quad01': 0.1})
orm = model.compute_orm(config)