-
Notifications
You must be signed in to change notification settings - Fork 3
Diamond2 conversion #54
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7a85003
Add octupole field, b3 to supported fields
ptsOSL 0df7949
Handle KickAngle for multipoles attached to correctors
ptsOSL 13916c6
Update THERING conversion script for DII lattice
ptsOSL 2f956ef
Refactored tests and added ringmode 48
ptsOSL c394b12
Regenerated ring with new AT Markers
ptsOSL 1b48c41
Remove mistakenly added disable_6d()
ptsOSL 03af6ab
Change default lattice from RING to THERING
ptsOSL 024b589
Remove if check for ThinCorrectorPass
ptsOSL 6997f55
Check HSTR/VSTR has length 0 removing
ptsOSL 087334a
Rename test fixtures and add back pytac_lattice
ptsOSL 6e6d4c6
Minor style fixes
ptsOSL 660c852
Add warning message to mml conversion script
ptsOSL 03c2619
Update create_lattice to use ATIP_RING instead of RING
ptsOSL a689bff
Minor changes for clearer code
ptsOSL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,70 +1,75 @@ | ||
| function create_lattice_matfile(filename) | ||
| % Creates a .mat file AT lattice compatible with ATIP. | ||
| % If a filename is given that file will be updated to ATIP standard. Otherwise | ||
| % the ring is taken from either of the 'RING' or 'THERING' global variables, | ||
| % with 'RING' taking priority. If a filename is not passed the updated lattice | ||
| % will be stored in 'lattice.mat'. | ||
| % ATIP_RING is initially taken from 'THERING' global variable and save as | ||
| % 'lattice.mat'. | ||
| if ~(nargin == 0) | ||
| load(filename, 'RING'); | ||
| load(filename, 'ATIP_RING'); | ||
| end | ||
| if ~exist('RING', 'var') | ||
| global RING; | ||
| if isempty(RING) | ||
| global THERING; | ||
| RING = THERING; | ||
|
|
||
| if ~exist('ATIP_RING', 'var') | ||
| global THERING; | ||
| if isempty(THERING) | ||
| disp('THERING global variable is empty, try running storageringinit(Ringmode). Exiting with error.'); | ||
| exit(1) | ||
| else | ||
| ATIP_RING=THERING | ||
| disp('Using global THERING and saving it to global ATIP_RING.'); | ||
| end | ||
| else | ||
| disp('Using loaded ATIP_RING from file.'); | ||
| end | ||
| if isempty(RING) | ||
| disp('Unable to load a ring from file or global variables.'); | ||
| return; | ||
| end | ||
|
|
||
| fprintf('Initial lattice has dimensions: %s\n', mat2str(size(ATIP_RING))) | ||
| % Correct dimension order if necessary. | ||
| if size(RING, 1) == 1 | ||
| RING = permute(RING, [2 1]); | ||
| if size(ATIP_RING, 1) == 1 | ||
| ATIP_RING = permute(ATIP_RING, [2 1]); | ||
| end | ||
|
|
||
| % Correct classes and pass methods. | ||
| for x = 1:length(RING) | ||
| if strcmp(RING{x, 1}.FamName, 'BPM10') | ||
| for x = 1:length(ATIP_RING) | ||
| if strcmp(ATIP_RING{x, 1}.FamName, 'BPM10') | ||
| % Wouldn't be correctly classed by class guessing otherwise. | ||
| RING{x, 1}.Class = 'Monitor'; | ||
| elseif (strcmp(RING{x, 1}.FamName, 'HSTR') || strcmp(RING{x, 1}.FamName, 'VSTR')) | ||
| RING{x, 1}.Class = 'Corrector'; | ||
| elseif (strcmp(RING{x, 1}.FamName, 'HTRIM') || strcmp(RING{x, 1}.FamName, 'VTRIM')) | ||
| RING{x, 1}.Class = 'Corrector'; | ||
| ATIP_RING{x, 1}.Class = 'Monitor'; | ||
| elseif (strcmp(ATIP_RING{x, 1}.FamName, 'HSTR') || strcmp(ATIP_RING{x, 1}.FamName, 'VSTR')) | ||
| ATIP_RING{x, 1}.Class = 'Corrector'; | ||
| elseif (strcmp(ATIP_RING{x, 1}.FamName, 'HTRIM') || strcmp(ATIP_RING{x, 1}.FamName, 'VTRIM')) | ||
| ATIP_RING{x, 1}.Class = 'Corrector'; | ||
| end | ||
| if isfield(RING{x, 1}, 'Class') | ||
| if strcmp(RING{x, 1}.Class, 'SEXT') | ||
| RING{x, 1}.Class = 'Sextupole'; | ||
|
|
||
| if isfield(ATIP_RING{x, 1}, 'Class') | ||
| if strcmp(ATIP_RING{x, 1}.Class, 'SEXT') | ||
| ATIP_RING{x, 1}.Class = 'Sextupole'; | ||
| end | ||
| end | ||
| if strcmp(RING{x, 1}.PassMethod, 'ThinCorrectorPass') | ||
| % ThinCorrectorPass no longer exists in AT. | ||
| RING{x, 1}.PassMethod = 'CorrectorPass'; | ||
| elseif strcmp(RING{x, 1}.PassMethod, 'GWigSymplecticPass') | ||
| RING{x, 1}.Class = 'Wiggler'; | ||
|
|
||
| if strcmp(ATIP_RING{x, 1}.PassMethod, 'GWigSymplecticPass') | ||
| ATIP_RING{x, 1}.Class = 'Wiggler'; | ||
| end | ||
| end | ||
|
|
||
| % Remove elements. Done this way because the size of RING changes during | ||
| % the loop. | ||
| % Remove elements. Done this way because the size of ATIP_RING changes | ||
| % during the loop. | ||
| y = 1; | ||
| while y < length(RING) | ||
| % I should probably transfer the attributes of the deleted corrector | ||
| % elements to the sextupole but cba. | ||
| if (strcmp(RING{y, 1}.FamName, 'HSTR') && strcmp(RING{y-1, 1}.Class, 'Sextupole')) | ||
| RING(y, :) = []; % Delete hstrs that are preceded by a sextupole. | ||
| elseif (strcmp(RING{y, 1}.FamName, 'VSTR') && strcmp(RING{y-1, 1}.Class, 'Sextupole')) | ||
| RING(y, :) = []; % Delete vstrs that are preceded by a sextupole. | ||
| while y < length(ATIP_RING) | ||
| % The data within the deleted elements is not needed | ||
| if strcmp(ATIP_RING{y, 1}.FamName, 'HSTR') && ATIP_RING{y, 1}.Length == 0 && (strcmp(ATIP_RING{y-1, 1}.Class, 'Sextupole') || strcmp(ATIP_RING{y-1, 1}.Class, 'Multipole')) | ||
| ATIP_RING(y, :) = []; % Delete hstrs that are preceded by a sextupole or multipole. | ||
| elseif strcmp(ATIP_RING{y, 1}.FamName, 'VSTR') && ATIP_RING{y, 1}.Length == 0 && (strcmp(ATIP_RING{y-1, 1}.Class, 'Sextupole') || strcmp(ATIP_RING{y-1, 1}.Class, 'Multipole')) | ||
| ATIP_RING(y, :) = []; % Delete vstrs that are preceded by a sextupole or multipole. | ||
| else | ||
| y = y + 1; | ||
| end | ||
| end | ||
| if isfield(RING{1, 1}, 'TwissData') | ||
| RING{1, 1} = rmfield(RING{1, 1}, 'TwissData'); | ||
|
|
||
| if isfield(ATIP_RING{1, 1}, 'TwissData') | ||
| ATIP_RING{1, 1} = rmfield(ATIP_RING{1, 1}, 'TwissData'); | ||
| end | ||
|
|
||
| fprintf('Converted ATIP_RING has dimensions: %s\n', mat2str(size(ATIP_RING))) | ||
| if nargin == 0 | ||
| save('lattice.mat', 'RING'); | ||
| save('lattice.mat', 'ATIP_RING'); | ||
| else | ||
| save(filename, 'RING'); | ||
| save(filename, 'ATIP_RING'); | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.