Tools for using Bmad in LUME
Project description
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("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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lume_bmad-0.1.0.tar.gz.
File metadata
- Download URL: lume_bmad-0.1.0.tar.gz
- Upload date:
- Size: 46.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92c998d60584e89f7e8bb8ebcd1b5e1979e834140b162dc27a68cedabac5005d
|
|
| MD5 |
3793bad9ecd7d7f5df89735598ab58e1
|
|
| BLAKE2b-256 |
d0c971f5f1448b4b955f3e907b2b08c9e388d44ddc64d3bb4024e78c6f012647
|
File details
Details for the file lume_bmad-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lume_bmad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
789c4df2bb52e8bebe74b2ee759987bd624665db7a46b76ae7c02ce4d15dc2db
|
|
| MD5 |
af3a3ea98387048bb2606505d3ec513f
|
|
| BLAKE2b-256 |
d4d595fd676a832bef2e0f6f4a7358dc32d1506fcb70f05c018d87b07c9b51c0
|