Computation of JacobiansΒΆ

There are two types of methods for computing Jacobians: AnalyticalJacobianMethod and NumericalJacobianMethod. The analytical method uses dedicated analytical formulas for computing Jacobians from Twiss data. The numerical method, on the other hand, uses finite difference approximation to obtain the Jacobian.

The different methods can be imported from accinv.jacobian. Typically, they are used together with a Model and then serve as an argument for the Loco class:

from accinv.jacobian import AnalyticalJacobianMethod, NumericalJacobianMethod
from accinv.loco import Loco
from accinv.model import Madx

model = Madx(path='path/to/script.madx')
loco = Loco(
    # Both of the following are valid choices:
    model_and_jacobian_method=(model, AnalyticalJacobianMethod),
    model_and_jacobian_method=(model, NumericalJacobianMethod),

    # Fill in remaining arguments here:
    ...,
)

The advantage of the analytical method is that it is faster to compute. However, at the moment, it is only available for quadrupole errors. The numerical method, on the other hand, works for any kind of parameters.