lume-bmad
Tools for using Bmad in LUME
Installation
This package expects bmad and pytao to be provided by conda.
conda create -n lume-bmad -c conda-forge python=3.11 bmad pytao
conda activate lume-bmad
pip install -e .
For development dependencies:
pip install -e ".[dev]"
Quick import check:
python -c "import pytao, lume_bmad; print('ok')"
Implementation example
The test fixtures in tests/ provide a minimal Tao setup you can use directly:
tests/fodo.init: Tao initialization file.tests/fodo.bmad: lattice file loaded byfodo.init.
Because tests/fodo.init references fodo.bmad with a relative path, keep those two files in the same directory.
from pathlib import Path
from pytao import Tao
from lume_bmad.actions import EleScalarVariable
from lume_bmad.model import LUMEBmadModel
# Reuse the fixture Tao setup from tests/
tao_init = Path("tests") / "fodo.init"
tao = Tao(init_file=str(tao_init), noplot=True)
control_variables = [
EleScalarVariable(
name="qf:B1_GRADIENT",
unit="1/m^2",
element_name="qf",
property_name="B1_GRADIENT",
),
EleScalarVariable(
name="qd:B1_GRADIENT",
unit="1/m^2",
element_name="qd",
property_name="B1_GRADIENT",
),
]
model = LUMEBmadModel(
tao=tao,
action_variables=control_variables,
dump_locations=["qf", "qd"],
)
# Read and set model variables
print(model.get(["qf:B1_GRADIENT", "qd:B1_GRADIENT"]))
model.set({"qf:B1_GRADIENT": 0.2})
# Enable beam tracking and read a dumped beam distribution
model.set({"track_type": "beam"})
qf_beam = model.get_value("qf_beam")
print(qf_beam.n_particle)
If you want to run this example from outside the repository, copy both fixture files together and pass the path to that copied fodo.init.
Release files for lume-bmad 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lume_bmad-0.1.1.tar.gz | 47.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lume_bmad-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.3 kB
Release files / lume_bmad-0.1.1.tar.gz
| Download URL | lume_bmad-0.1.1.tar.gz |
|---|---|
| Size | 47.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77ded461ff119a77db1829207c1395c8fb499293d49d43e1ab6156b7989afb95
|
|
BLAKE2b-256 checksum How to use checksums |
650637b82aff1a06fbfe669e386194112bc3ba842afaf0adb10aadb5153904c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / lume_bmad-0.1.1-py3-none-any.whl
| Download URL | lume_bmad-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe9eb0366b26f195fbe2643ff4c63e6074e6d171b5700fd7d1564ea1e9cf516f
|
|
BLAKE2b-256 checksum How to use checksums |
f77e71cabe0d4a289d8e34e50a86cbf4c0275a77132ff8bf84a68536097a4c93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|