ECP-WarpX / impactx

high-performance modeling of beam dynamics in particle accelerators with collective effects
https://impactx.readthedocs.io
Other
27 stars 20 forks source link

Reduced beam diagnostic output - kinetic energy #533

Open SchroederSa opened 8 months ago

SchroederSa commented 8 months ago

Hi, I was trying to extract the kinetic energy of the particle beam using the reduced diagnostic file output. Doing so for the apochromatic example, I get the following outputs:

red_diag = pd.read_csv('.../impactx/examples/apochromatic/diags/reduced_beam_characteristics.0.0', sep=' ', header=0)
print(red_diag['px_mean'][0]*0.511)  # Should be 0
>> -1.882738482372865e-09            # Ok!
print(red_diag['py_mean'][0]*0.511)  # Should be 0
>> 4.0816649768864856e-09            # Ok!
print(red_diag['pt_mean'][0]*0.511)  # Kinetic energy of electron beam is 10GeV
>> 1.2226565625060562e-06            <------------------ ?
print(red_diag['sig_pt'][0])         # 0.01% energy spread    
>> 0.0099944213575608                # Ok!
red_diag = pd.read_csv('.../impactx/examples/apochromatic/diags/ref_particle.0.0', sep=' ', header=0)
print(red_diag['pt'][0]*0.511)       # Kinetic energy of electron beam is 10GeV
>> -100000.7164806249                # Ok!

In the reduced beam characteristics file, _ptmean is essentially 0. For the reference particle, however, pt is 100GeV. How can I understand mean_pt other than as longitudinal momentum?

Thanks! Sarah

p.s.: The terminology ptmean, ptmin, pt_max but sig_pt is a bit confusing.

ax3l commented 8 months ago

We have the reference beta * gamma in the reduced diagnostics, but we could add all reference particle info there and explicitly also add kinetic energy.

ax3l commented 8 months ago

Commented: https://impactx.readthedocs.io/en/latest/dataanalysis/dataanalysis.html#reduced-beam-characteristics

px_mean/min/max, py_mean/min/max, pt_mean/min/max

Not explicit / clear enough.

cemitch99 commented 8 months ago

In general, I would suggest we avoid mixing beam particle data and reference particle data in the output. The organization/philosophy of the code is such that these objects are treated separately--using independent tracking algorithms, coordinate systems, and normalization conventions--and beam particle data is always expressed relative to the reference particle. (In a similar way, the reduced diagnostics for the beam particle data and the data for the reference particle are output to separate files in IMPACT-Z.)

SchroederSa commented 8 months ago

I very much like the approach of expressing beam data relative to the reference particle. I just think it requires a mention in the docs of the reduced diagnostics. https://impactx.readthedocs.io/en/latest/dataanalysis/dataanalysis.html Reading the first sentence ImpactX calculates reduced beam characteristics like averaged positions, momenta, beam emittances and Courant-Snyder (Twiss) parameters during runtime. gave me the impression I got the absolute beam information.

ax3l commented 8 months ago

That sounds like a good improvement to do!

Just as a note for completion, the reference particle is also written in a text file, named diags/ref_particle.*.