accinv


Nameaccinv JSON
Version 0.1.0.post1 PyPI version JSON
download
home_page
SummaryPython project for inverse modeling of accelerator lattices
upload_time2022-12-05 15:01:27
maintainer
docs_urlNone
authorDominik Vilsmeier
requires_python
licenseGNU General Public License 3
keywords inverse modeling accelerator lattice linear-optics-from-closed-orbits loco orbit-response-matrix orm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!---
SPDX-FileCopyrightText: 2022 Dominik Vilsmeier

SPDX-License-Identifier: GPL-3.0-or-later
-->


[![Documentation Status](https://readthedocs.org/projects/accinv/badge/?version=latest)](https://accinv.readthedocs.io/en/latest/)
[![PyPI versions](https://img.shields.io/pypi/v/accinv.svg)](https://pypi.org/project/accinv/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/accinv.svg)](https://pypi.org/project/accinv/)


# (acc)<sup>-1</sup>

*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`](https://pypi.org/project/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:

```py
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](https://accinv.readthedocs.io/en/latest/api/accinv.loco.html#accinv.loco.Loco)
for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "accinv",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "inverse,modeling,accelerator,lattice,linear-optics-from-closed-orbits,loco,orbit-response-matrix,orm",
    "author": "Dominik Vilsmeier",
    "author_email": "d.vilsmeier@gsi.de",
    "download_url": "https://files.pythonhosted.org/packages/05/c4/5fbaa981a01d7a86b748878c10167320d4787bb0482f75705c227503bab6/accinv-0.1.0.post1.tar.gz",
    "platform": null,
    "description": "<!---\nSPDX-FileCopyrightText: 2022 Dominik Vilsmeier\n\nSPDX-License-Identifier: GPL-3.0-or-later\n-->\n\n\n[![Documentation Status](https://readthedocs.org/projects/accinv/badge/?version=latest)](https://accinv.readthedocs.io/en/latest/)\n[![PyPI versions](https://img.shields.io/pypi/v/accinv.svg)](https://pypi.org/project/accinv/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/accinv.svg)](https://pypi.org/project/accinv/)\n\n\n# (acc)<sup>-1</sup>\n\n*accinv - Python project for inverse modeling of accelerator lattices*\n\n-----\n\n**Note:** This project is in proof-of-concept stage and therefore lacks more advanced features\nof some of the implemented methods.\n\n-----\n\nIn its current state, the package provides functionality for inverse modeling of linear optics\nvia fitting of orbit response matrix (ORM) data, typically referred to as linear optics\nfrom closed orbits. It supports [`cpymad`](https://pypi.org/project/cpymad/) as a backend.\n\nThe main class is `accinv.loco.Loco` which requires one of the models from `accinv.model`, as well as\na method for computing Jacobians, as an argument.\nTwo methods for Jacobian computation are available.\n\n* `AnalyticalJacobianMethod`: This method uses an analytical formula to compute the Jacobian of the ORM\n  with respect to quadrupole gradient errors and BPM and steerer gain errors. The data for the\n  analytical formula is obtained from a single Twiss call for the current lattice configuration.\n* `NumericalMJacobianMethod`: This method uses a finite difference approximation scheme to compute the Jacobian of\n  the ORM with respect to the quadrupole gradient errors. Thus, the number of ORMs that will be computed \n  is proportional to the number of quadrupoles.\n\nThe inverse modeling process can be started by creating a `Loco` object and calling its `run` method:\n\n```py\nfrom accinv.jacobian import AnalyticalJacobianMethod\nfrom accinv.loco import Loco, OrmMeasurement\nfrom accinv.model import Madx\n\nmodel = Madx(path='path/to/script.madx')\nloco = Loco(\n    model_and_jacobian_method=(model, AnalyticalJacobianMethod),\n    quadrupoles=[...],  # names of quadrupoles\n    hbpms=[...],        # names of horizontal BPMs\n    hsteerers=[...],    # names of horizontal steerers\n    vbpms=[...],        # names of vertical BPMs\n    vsteerers=[...],    # names of vertical steerers\n    orm_measurement=OrmMeasurement(\n      orm=np.load('path/to/measured_orm.npy'),\n      uncertainty=np.load('path/to/orm_uncertainty.npy'),\n  ),\n)\nresult = loco.run()\n```\n\nPlease consider the documentation of the\n[`Loco` class](https://accinv.readthedocs.io/en/latest/api/accinv.loco.html#accinv.loco.Loco)\nfor more details.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License 3",
    "summary": "Python project for inverse modeling of accelerator lattices",
    "version": "0.1.0.post1",
    "split_keywords": [
        "inverse",
        "modeling",
        "accelerator",
        "lattice",
        "linear-optics-from-closed-orbits",
        "loco",
        "orbit-response-matrix",
        "orm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "6cf614ebcea2b632a39952b28cfc0980",
                "sha256": "ccc367bad22f8322b469593c4f1ba1ae1759374f9fac9dd0aa5b0996699c1383"
            },
            "downloads": -1,
            "filename": "accinv-0.1.0.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cf614ebcea2b632a39952b28cfc0980",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 26943,
            "upload_time": "2022-12-05T15:01:25",
            "upload_time_iso_8601": "2022-12-05T15:01:25.559848Z",
            "url": "https://files.pythonhosted.org/packages/a0/0b/63e01bd1462b3a1c5bdcd18523264d5ff85e4a99130795ab2c374d2c6ca3/accinv-0.1.0.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "490c21867664fd01ac72e6bceddf95a3",
                "sha256": "70a0c14afe95f0a198a26df4e42991dd7a5e73da62be281899cc18ea22e52653"
            },
            "downloads": -1,
            "filename": "accinv-0.1.0.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "490c21867664fd01ac72e6bceddf95a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 24989,
            "upload_time": "2022-12-05T15:01:27",
            "upload_time_iso_8601": "2022-12-05T15:01:27.265487Z",
            "url": "https://files.pythonhosted.org/packages/05/c4/5fbaa981a01d7a86b748878c10167320d4787bb0482f75705c227503bab6/accinv-0.1.0.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-05 15:01:27",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "accinv"
}
        
Elapsed time: 0.01834s