-
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
Fix wiggler radiation #822
Conversation
@lfarv , Not sure How @joanarenillas was compiling it, probably manually. He just worked on the Matlab part, sorry I should have stated that clearly. I'm not able to review this, specially not the compilation in the python part, but thanks for including me, I'll try to go through it and learn as much as possible. |
Hi all. Please have a look to this PR: without these small fixes, all the work done by @joanarenillas and @ZeusMarti is still not usable, the wiggler contribution still fails. There is no change in the wiggler code except for fixing a compilation bug on MacOS, removal of compiler warnings and triggering the compilation in atmexall. |
Dear @lfarv , >>> ring[-1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/oblanco/Documents/public/progs/pyenv/testwiggler/lib/python3.11/site-packages/at/lattice/elements.py", line 311, in __repr__
clsname, args, kwargs = self.definition
^^^^^^^^^^^^^^^
File "/home/oblanco/Documents/public/progs/pyenv/testwiggler/lib/python3.11/site-packages/at/lattice/elements.py", line 397, in definition
arguments = tuple(attrs.pop(
^^^^^^^^^^^^^^^^
File "/home/oblanco/Documents/public/progs/pyenv/testwiggler/lib/python3.11/site-packages/at/lattice/elements.py", line 398, in <genexpr>
k, getattr(self, k)) for k in self._BUILD_ATTRIBUTES
^^^^^^^^^^^^^^^^
AttributeError: 'Wiggler' object has no attribute 'Energy' Here is the python code: """This script test the wiggler use"""
# 2024sep06 oblanco
import at
print(f'at.__version__={at.__version__}')
ring = at.load_mat('ring.mat')
# create wiggler
wlength = 1e-4
wperiod = 1e-5
wbmax = 1e-3
wenergyineV=3e9 #eV
WIG = at.Wiggler('WIG',wlength,wperiod,wbmax,wenergyineV)
ring.insert(len(ring),WIG)
# ring[-1] # this line fails if lauched interactively In matlab AT I can create, add to ring, plot, track and use ohmienvelope. Here is the code I wrote for the test. clear; close all;
%% oblanco 2024sep06 test wiggler use
load('ring.mat');
%%
wlength = 0.00001;%3*i; % wiggler length
periodlength = 0.000001; % wiggler period
bmax = 1.6e-3;%1.5; % max field in Tesla
beamenergy = 3e9; % in eV
passmethod = 'GWigSymplecticRadPass'; % rad or no rad
thewiggler = atwiggler('WIG',wlength,periodlength,bmax,beamenergy,passmethod);
%%
[~,radindex,~] = atenable_6d(THERING);
%%
[ENVELOPE, RMSDP, RMSBL, M66, T, ORBIT] = ohmienvelope(THERING,radindex);
%%
THERING2 = [THERING; thewiggler];
%%
atplot(THERING2);
%%
Z0=ringpass(THERING2,zeros(6,1),1000);
%%
plot(Z0(1,:));
%%
[~,radindex2,~] = atenable_6d(THERING2);
[ENVELOPE_2, RMSDP_2, RMSBL_2, M66_2, T_2, ORBIT_2] = ohmienvelope(THERING2,radindex2); |
@oscarxblanco : thanks for testing. As far as I can see, Matlab is correct. In python, the wiggler is indeed created with an |
pyat now prints the wiggler without errors. I tested also at.plot_beta and ohmienvelope, both seem ok. |
The diffusion matrix of wigglers was recently introduced (#759) but has a few problems:
For Matlab
atmexall
, and so is missing when needed,For python
setup.py
(same as for Matlab),at.physics
module,This PR corrects all this. As mentioned before, we have no way of cross-checking the results (specially for the python implementation), so we trust the computation. This is anyway better than before when it was wrong.