Skip to main content

A standardized lattice format for particle accelerators

Project description

NALA: Not Another Lattice Architecture

NALA is a Python package for describing, simulating, and controlling particle accelerator lattices. It provides a standardized, extensible data model for elements, sections, layouts, and full machine models.


Architecture Overview

NALA organizes accelerator elements using a hierarchical structure:

Element Structure

NALA Element Structure

  • baseElement: Core identification (name, hardware_class, hardware_type, machine_area)
  • Element: Extends with simulation, controls, electrical, manufacturer info
  • PhysicalBaseElement: Adds position, rotation, length, error, survey

Lattice Structure

NALA Lattice Structure

  • ElementList: Container for elements
  • SectionLattice: Ordered list of elements (a section of the beamline)
  • MachineLayout: Sequence of sections (a full beam path)
  • MachineModel: All layouts, sections, and elements (the full accelerator)

Quick Examples

Create a Basic Element

from nala.models.element import baseElement

element = baseElement(
    name="QUAD-01",
    hardware_class="Magnet",
    hardware_type="Quadrupole",
    machine_area="LINAC-1"
)
print(element.name)  # "QUAD-01"

Element with Physical Properties

from nala.models.element import PhysicalBaseElement
from nala.models.physical import PhysicalElement, Position

cavity = PhysicalBaseElement(
    name="CAV-01",
    hardware_class="RF",
    hardware_type="Cavity",
    machine_area="LINAC-1",
    physical=PhysicalElement(
        length=1.0,
        middle=Position(x=0, y=0, z=5.0)
    )
)
print(cavity.physical.length)  # 1.0

Create a Section Lattice

from nala.models.elementList import SectionLattice, ElementList

section = SectionLattice(
    name="INJECTOR",
    order=["BPM-01", "QUAD-01"],
    elements=ElementList(elements={
        "BPM-01": element,
        "QUAD-01": cavity
    })
)
print(section.names)  # ["BPM-01", "QUAD-01"]

Build a Machine Layout

from nala.models.elementList import MachineLayout

layout = MachineLayout(
    name="MainBeamline",
    sections={"INJECTOR": section}
)
print(layout.names)  # ["INJECTOR"]

Full Machine Model

from nala.models.elementList import MachineModel

model = MachineModel(
    elements={"QUAD-01": element, "CAV-01": cavity}
)
print(list(model.sections.keys()))  # ["LINAC-1"]

Translator Module

NALA includes a translator system for exporting accelerator models to various simulation codes, such as ASTRA, GPT, Elegant, CSRTrack, Ocelot, Xsuite, Wake-T, and Genesis.

  • Translate individual elements, sections, layouts, or full machine models.
  • Export to code-specific formats and objects.
  • Automatically manage drift spaces, field maps, and code-specific configuration.

Example: Export a section to Elegant and Ocelot

from nala.translator.converters.section import SectionLatticeTranslator

translator = SectionLatticeTranslator.from_section(section)
translator.directory = "./output"

elegant_string = translator.to_elegant(charge=1e-9)
ocelot_lattice = translator.to_ocelot(save=True)

See the Translator documentation for details and more examples.


Features

  • Hierarchical lattice structure: elements → sections → layouts → machine
  • Flexible element definition: physical, simulation, controls, electrical, manufacturer
  • Extensible API: add new element types and metadata
  • Simulation & controls integration: store simulation parameters and control variables
  • Export to simulation codes via the Translator module


Installation

Install NALA from PyPI:

pip install nala-accelerator

Or add to your requirements.txt:

nala-accelerator

Documentation


Contributing

Issues and pull requests are welcome! See GitHub Issues.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nala_accelerator-0.1.0.tar.gz (643.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nala_accelerator-0.1.0-py3-none-any.whl (303.2 kB view details)

Uploaded Python 3

File details

Details for the file nala_accelerator-0.1.0.tar.gz.

File metadata

  • Download URL: nala_accelerator-0.1.0.tar.gz
  • Upload date:
  • Size: 643.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for nala_accelerator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 50fdf93931b2bfa5d98540a39adb735b7ad5a2575d422a00e4318112e2444f82
MD5 265e5570f299c585b210ec69f9fdbc6a
BLAKE2b-256 45605cf09422e6a63609361c5d3399d5bf87411afa2aa97c549b7b65144aa349

See more details on using hashes here.

File details

Details for the file nala_accelerator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nala_accelerator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac2b6297f23a936357e2e5406bafada021a1b96b0d8ecbbf9d767dca1c908307
MD5 770a4087a483a4d1685b0a0898b5efa2
BLAKE2b-256 83f796e5ad22bf23fd4d6e86d7cab47c6d3e9758069b9d4ef22fd819dbff0a78

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page