-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Bmad interface #51
base: master
Are you sure you want to change the base?
Conversation
@@ -377,6 +378,11 @@ def to_file( | |||
filename, | |||
) | |||
|
|||
@classmethod | |||
def from_tao(cls, tao): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a docstring
@@ -1004,6 +1006,14 @@ def from_elements( | |||
filename=pathlib.Path(filename) if filename else None, | |||
) | |||
|
|||
@classmethod | |||
def from_tao(cls, tao): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a docstring
def from_tao(cls, tao): | ||
elements, line_labels = genesis4_elements_and_line_from_tao(tao) | ||
|
||
line_label = tao.branch1(1, 0)["name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ix_uni
and ix_branch
should be arguments to from_tao
pytao.Tao.branch1(
self,
ix_uni,
ix_branch,
...
)
@@ -0,0 +1,317 @@ | |||
from ..input._lattice import Quadrupole, Corrector, Drift, Marker, Undulator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All input
-related classes should come from genesis.version4.input
So
from ..input import xyz
This applies to the line below as well
""" | ||
name = bmad_name.upper() | ||
label = name.split("\\")[-1] # Extracts text after backslash, if any | ||
return label.replace(".", "_").replace("#", "_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't be right
This would take bmad names:
X\1
X\2
and give 1
and 2
y_offset = info.get("Y_OFFSET", 0) | ||
|
||
if key == "beginning_ele": | ||
eles = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This either should be []
or the annotation for the function needs updating to say returns list or None
if y_offset != 0: | ||
raise NotImplementedError(f"y_offset not zero: {y_offset}") | ||
|
||
# aw calc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice for this to be a utility function and not baked into this large function
return eles | ||
|
||
|
||
def genesis4_elements_and_line_from_tao(tao, match="*"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should accept ix_uni
and ix_branch
Could this also have a track_start
and track_end
?
# shotnoise=False, | ||
) | ||
|
||
# TODO: Generalize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these just be parameters to the function for starters?
|
||
# Handle Tao universe @ branch >> sytax | ||
if ">>" not in ele_start: | ||
ele_start = f"{universe}@{branch}>>{ele_start}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be passed in as 1@ele
- there are many variations for element naming in Tao
This adds methods to create LUME-Genesis objects from Bmad via PyTao's Tao object
Lattice.from_tao
MainInput.from_tao
to create basic input. This:gamma0
Genesis4.from_tao
which simply calls these for convenience.