-
Notifications
You must be signed in to change notification settings - Fork 33
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
Loading of MAD and Elegant files #844
base: master
Are you sure you want to change the base?
Conversation
Parsing of Elegant files is also rebuilt and should now be fully compliant with the Elegant reference. |
@lfarv, what you propose is to have an object |
@swhite2401 : you are right, the parser is just an image in memory of the MAD-X file, as it is already the case in the present version. So after modifying a variable, you need indeed to instantiate a new lattice (like you need to call the "USE" command in MAD) to take new values into account. But:
The new point in this version is that the expansion of deferred variables was previously done while parsing the file, while it is now done when the variable is used (as in MAD). So in the previous version, modifying parameters had no interest. Note that in simple cases, the |
I may test the mad files, but I have no elegant files. May be @carmignani has an elegant file we could use as test? |
Dear @lfarv, in this branch it is now possible to save mad and elegant files? This would bring a full omni-directional converter feature to pyAT! I will try the features added in this branch. best regards |
@simoneliuzzo: You noticed the new feature even before I mentioned it ! Yes, you are right, both loading and saving are now available. I still need to document the limitations on saving (limited to elements available on both sides, tilt not yet taken into account…), but I tested on a few files that when loading a MAD (or elegant) file, and then saving it back to MAD, the resulting file is of course completely different from the initial one, but MAD gives identical results. However, this needs to be tried on many files. I have about 10 MAD test files and ~5 elegant files. Every test you can perform is welcome, and is likely to show some problems, which will have to be fixed step by step. The code is simple and flexible enough so that should be easy. |
Dear @lfarv, I tested I tested also on EBS lattices, that I thought simpler. In fact the lattice I chose has bpms names "BPM_C03-08" and I think those are source of an issue for load_madx and load_mad8 work as expected. I understood from the output that the Some additional help in the load / save methods could be nice. I am unable to test if the elegant files produced by AT are usable in elegant |
@simoneliuzzo : Excellent, thanks a lot ! Can you post the lattice file with problems ?
|
Dear @lfarv, if you have access to ESRF's machfs, those are the lines I am running:
|
The processing of MAD files is improved:
1. more robustness for malformed files
2. handling of deferred assignments:
deferred assignments are correctly handled when MAD parameters are interactively modified. Example:
assuming an input files containing:
And the following PyAT commands:
One can now interactively modify any parameter, and the updated values will be taken into account when generating lattices.
With this, one can automatise the generation of AT lattices with variable conditions. Note however that this is much slower than using AT
Variable
objects when it is possible.In the present state, MAD format may be used as a native input format for PyAT.