Skip to main content

Documentation Status PyPI versions PyPI pyversions

(acc)-1

accinv - Python project for inverse modeling of accelerator lattices


Note: This project is in proof-of-concept stage and therefore lacks more advanced features of some of the implemented methods.


In its current state, the package provides functionality for inverse modeling of linear optics via fitting of orbit response matrix (ORM) data, typically referred to as linear optics from closed orbits. It supports cpymad as a backend.

The main class is accinv.loco.Loco which requires one of the models from accinv.model, as well as a method for computing Jacobians, as an argument. Two methods for Jacobian computation are available.

  • AnalyticalJacobianMethod: This method uses an analytical formula to compute the Jacobian of the ORM with respect to quadrupole gradient errors and BPM and steerer gain errors. The data for the analytical formula is obtained from a single Twiss call for the current lattice configuration.
  • NumericalMJacobianMethod: This method uses a finite difference approximation scheme to compute the Jacobian of the ORM with respect to the quadrupole gradient errors. Thus, the number of ORMs that will be computed is proportional to the number of quadrupoles.

The inverse modeling process can be started by creating a Loco object and calling its run method:

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

model = Madx(path='path/to/script.madx')
loco = Loco(
    model_and_jacobian_method=(model, AnalyticalJacobianMethod),
    quadrupoles=[...],  # names of quadrupoles
    hbpms=[...],        # names of horizontal BPMs
    hsteerers=[...],    # names of horizontal steerers
    vbpms=[...],        # names of vertical BPMs
    vsteerers=[...],    # names of vertical steerers
    orm_measurement=OrmMeasurement(
      orm=np.load('path/to/measured_orm.npy'),
      uncertainty=np.load('path/to/orm_uncertainty.npy'),
  ),
)
result = loco.run()

Please consider the documentation of the Loco class for more details.

Metadata

Release files for accinv 0.1.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for accinv 0.1.0.post1
File Size Uploaded
accinv-0.1.0.post1.tar.gz 25.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for accinv 0.1.0.post1
File Interpreter ABI Platform
accinv-0.1.0.post1-py3-none-any.whl Python 3 none any Details

Total release size: 51.9 kB

Release files / accinv-0.1.0.post1.tar.gz

Download URL accinv-0.1.0.post1.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
70a0c14afe95f0a198a26df4e42991dd7a5e73da62be281899cc18ea22e52653
BLAKE2b-256 checksum
How to use checksums
05c45fbaa981a01d7a86b748878c10167320d4787bb0482f75705c227503bab6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Release files / accinv-0.1.0.post1-py3-none-any.whl

Download URL accinv-0.1.0.post1-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccc367bad22f8322b469593c4f1ba1ae1759374f9fac9dd0aa5b0996699c1383
BLAKE2b-256 checksum
How to use checksums
a00b63e01bd1462b3a1c5bdcd18523264d5ff85e4a99130795ab2c374d2c6ca3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.1.0.post1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page