Skip to content

add ability to end the lattice at the beginning of an element - #63

Open
roussel-ryan wants to merge 3 commits into
mainfrom
slicing-improvements
Open

add ability to end the lattice at the beginning of an element#63
roussel-ryan wants to merge 3 commits into
mainfrom
slicing-improvements

Conversation

@roussel-ryan

Copy link
Copy Markdown
Collaborator

This pull request introduces a new option for controlling how the end element of a sliced lattice is determined when building a Bmad model. The main change is the addition of the end_mode parameter, allowing users to specify whether the slice should end at the provided element or at the element just before it. This provides more flexibility for users working with different lattice slicing requirements. The pull request also adds tests to ensure the new functionality works as expected and updates relevant documentation.

Enhancements to lattice slicing:

  • Added an end_mode parameter (default: "end") to build_bmad_model in factory.py, allowing users to specify whether the slice should end at the given element or the element before it. Raises a ValueError for invalid modes. (virtual_accelerator/bmad/factory.py) [1] [2]
  • Utilizes the new get_normalized_element_names function to determine the correct end element when end_mode="beginning". (virtual_accelerator/bmad/factory.py)

API and documentation updates:

  • Updated the get_cu_hxr_bmad_model function signature and docstring to accept and describe the new end_mode parameter. (virtual_accelerator/models/cu_hxr.py) [1] [2]
  • Ensured the new end_mode parameter is passed through to the model factory. (virtual_accelerator/models/cu_hxr.py)

Testing:

  • Added new tests to verify the behavior of the end_mode parameter, ensuring the model ends at the correct element for both "end" and "beginning" modes. (virtual_accelerator/tests/test_cu_hxr.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant