aryafallahi / mithra

MITHRA is a full-wave numerical solver for free-electron lasers.
17 stars 7 forks source link

[Enhancement] Calculation of total time from total distance #50

Closed arnaualba closed 4 years ago

arnaualba commented 4 years ago

The current calculation of mesh_.totalTime_ from a mesh_.totalDist_ given by the user, overestimates the necessary time, and the tail of the bunch ends much further downstream than the actual given totalDist_:

    mesh_.totalTime_ = ( mesh_.totalDist_ / gamma_ - zminG ) / ( beta_ * c0_ ) - dt_;

For the implementation in OPAL it really is necessary that the bunch's tail ends at totalDist_ in the lab frame, or very close to it. I propose a different way to calculate the total time. It is more accurate. I have attached a small note describing the derivation

computeTime.pdf

arnaualba commented 4 years ago

Note that for this calculation I assume that totalDist_ is longer than the undulator (or array of undulators). So the end point is somewhere after the last undulator

aryafallahi commented 4 years ago

Hi Arna, thanks for the correction. I think your implementation is better. I will just merge your pull request.