TWISS causes crash?

Moderators: cyao, michael_borland

JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

TWISS causes crash?

Post by JoelFrederico » 20 Apr 2011, 22:24

I think I've tracked this down to a twiss problem. When I put TWISS elements into my beamline, I get the following error:

Code: Select all

tracking through MATCHBETA
error: final coordinate pointer is NULL for particle 0 (track_particles)
It only seems to be my complicated sim. I've tried to reproduce this in a simple beamline that only contains particle loading, a TWISS element and a drift, and it goes through. It has a different problem with a generated beam:

Code: Select all

central momentum is 2.328461e+03    zstart = 5.503655e+01m  zend = 5.503655e+01m
tracking through MATCHBETA

Terminated by SIGSEGVProgram trace-back:
--------------------------------------------------------------------------
mpirun has exited due to process rank 0 with PID 24503 on
node oak001 exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------
I'm very confused. Of course, this all works in regular elegant.

Files at: http://stanford.edu/~joelfred/twiss.tar.gz

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: TWISS causes crash?

Post by michael_borland » 21 Apr 2011, 08:24

Joel,

Does it matter if I use genbeam.ele or loadbeam.ele ?

--Michael

JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

Re: TWISS causes crash?

Post by JoelFrederico » 21 Apr 2011, 08:49

Loadbeam.ele gives me the first error, genbeam.ele the second.

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: TWISS causes crash?

Post by michael_borland » 21 Apr 2011, 09:03

Joel,

I confirmed both problems. We'll look into a fix.

In the meantime, you might be able to break your simulation into three parts:
1. Run Pelegant up to the offending element.
2. Run elegant for the offending element (MATCHBETA)
3. Run Pelegant up to the end.

--Michael

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: TWISS causes crash?

Post by michael_borland » 21 Apr 2011, 09:09

Joel,

I noticed that if I set FROM_BEAM=1, it runs ok. Is there a reason you need FROM_BEAM=0?

If you are doing simulations with errors, you can use FROM_BEAM=1 and COMPUTE_ONCE=1 to ensure the same transformation is used for all beams. If you also suppress errors for the first beam (recommended in any case), this should be equivalent to FROM_BEAM=0.

--Michael

JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

Re: TWISS causes crash?

Post by JoelFrederico » 21 Apr 2011, 16:08

I see, thanks for checking it out! If you could re-post when you know what version it's fixed in so I know I can use it again, I'd appreciate it.

I'm using FROM_BEAM=0 because of how the beamline was designed. Different people are responsible for different sections and passed on Twiss parameters. The point with the Twiss matching is used because of some residual dispersion, and the source of it is unclear. In practice, it can easily be taken out, but in simulation it's easier just to tell it to go away than to tune upstream elements. The accompanying matrix appears to be a relatively small correction and so we aren't too worried about it.

I'm thinking about using the matrix calculated from the elegant version (which I can get from a matrix output file) in a MATR element, since the Twiss correction shouldn't change between runs. It's a kludge on a kludge, but it shouldn't make things worse if I understand it correctly.

michael_borland
Posts: 1927
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: TWISS causes crash?

Post by michael_borland » 21 Apr 2011, 17:46

Joel,

I don't think you need to use FROM_BEAM=0. The only reason to use it is if you are simulating errors in the incoming beam parameters. (Even in that case, using COMPUTE_ONCE=1 and no errors on the first seed can get around it.) If you just want to coerce the beam to have given parameters, then FROM_BEAM=1 is the best choice.

--Michael

JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

Re: TWISS causes crash?

Post by JoelFrederico » 21 Apr 2011, 17:57

Won't FROM_BEAM=1 cause the Twiss parameters to be calculated from the beam distribution? Our distribution comes from a ring simulated in LiTrack, and I'm a bit worried that Pelegant will find different parameters than are expected with its fit, since the distribution isn't necessarily gaussian. Then the transformation would be wrong. Using FROM_BEAM=0 guarantees that the fix is correct because the incoming and outgoing Twiss are set. (The MATCHBETA Twiss element that is causing the problem is right before the point where we know what the Twiss parameters should be.)

FYI, using a MATR with the same numbers given by the TWISS element in an elegant simulation works perfectly, so that's a successful workaround.

ywang25
Posts: 52
Joined: 10 Jun 2008, 19:48

Re: TWISS causes crash?

Post by ywang25 » 25 Apr 2011, 10:16

Joel,

I have fixed the bug in Pelegant, which caused the problem in the PFILTER element when the deltalimit>0. You can update the attached file under the elegant directory and build Pelegant. The fix will be in the next Pelegant release.

Yusong
Attachments
limit_amplitudes.c
Bug fix for the PFILTER element
(27.72 KiB) Downloaded 812 times

JoelFrederico
Posts: 60
Joined: 05 Aug 2010, 11:32
Location: SLAC National Accelerator Laboratory

Re: TWISS causes crash?

Post by JoelFrederico » 25 Apr 2011, 14:02

Yusong,

I'm a bit confused, I was reporting on an error in TWISS. Was the error not in TWISS? Is this posted in the right place?

Joel

Post Reply