-
Notifications
You must be signed in to change notification settings - Fork 221
Refactor laser implementation #5318
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
Refactor laser implementation #5318
Conversation
36092a3
to
83ef24e
Compare
83ef24e
to
4568194
Compare
ac4d155
to
b01cbd0
Compare
@psychocoderHPC @PrometheusPi @chillenzer @ikbuibui PR is ready for review now. It is intentionally split in three commits each of which refactors a specific part of the old implementation. Test results have been discussed offline already and are documented in #5269. |
b01cbd0
to
3e9c742
Compare
d1c5a2f
to
e7ff6a8
Compare
ping @PrometheusPi @finnolec @psychocoderHPC @ikbuibui @chillenzer. No review within 3 weeks is actually quite bad... 😞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, here's my first batch of review. I've yet circumvented the two main files but you might want to start with what I've got here. It's mostly questions for getting an overview.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say much about the physical correctness but I've checked with the formulae from the given reference and it kinda makes sense to me. Some questions for my understanding and a few minor refactoring ideas are in the comments but they are mostly up to personal style I'd guess, so not blocking.
Wouldn't wanna merge myself in order to have a physicist have a look at this as well, so would you, @PrometheusPi, do the honours please?
float_X center = Unitless::SD * (Omega - Unitless::OMEGA0) | ||
- sim.pic.getSpeedOfLight() * alpha * pos[0] / (Unitless::W0 * Unitless::OMEGA0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be extracted into an own function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, could be. But I use it only once and its length is comparable to the other definitions. i.e. not as long as expandedWaveVectorX()
.
PS: Generally very nice documentation. With the given references and the additional hints in the comments it was quite straightforward to follow the formulae (mostly). |
@steindev Will you first implement @chillenzer's suggestions are do you want to have more reviews at the current state? |
@PrometheusPi please already start the review. @chillenzer mostly ask for renamings. |
Yes, definitely! Please review. My comments were at most low-priority colouring ideas concerning our new bike shed. Did you know that research has shown that bikes in a green shed are 12.657498% less likely to get stolen by people wearing a blue or yellow shirt? (If the shirt is blue and yellow, for example in stripes, the results are inconclusive and further research is needed.) |
Any movement here? |
@chillenzer soon (tomorrow) |
@chillenzer Thanks for your review 🙏 Also, it seems I do not see any need for changes from your comments, sorry 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only minor things and questions
@@ -1,4 +1,4 @@ | |||
/* Copyright 2020-2024 Sergei Bastrakov, Finn-Ole Carstens | |||
/* Copyright 2020-2024 Sergei Bastrakov, Finn-Ole Carstens, Klaus Steiniger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Year will be updated next year - fine with me to keep it
// unit: sim.unit.time() | ||
static constexpr float_X INIT_TIME = static_cast<float_X>( | ||
(Params::RAMP_INIT * Params::PULSE_DURATION_SI + Params::LASER_NOFOCUS_CONSTANT_SI) | ||
/ sim.unit.time()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my understanding: where does this get defined now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nowhere, because it has not been used. But RAMP_INIT
is used in the code further below again.
@@ -38,8 +38,9 @@ namespace picongpu | |||
* unit: seconds */ | |||
static constexpr float_64 LASER_NOFOCUS_CONSTANT_SI = 13.34e-15; | |||
|
|||
/** The laser pulse will be initialized after TIME_DELAY_SI half of PULSE_INIT times of the | |||
* PULSE_DURATION before and after the plateau unit: none */ | |||
/** The laser pulse will be initialized after TIME_DELAY_SI half of RAMP_INIT times of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I introduced this, but the factor half of ramp-init is confusing since the variable name already states init as the up-ramp in my opinion..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I see what you mean...will change it
* | ||
* unit: none | ||
*/ | ||
static constexpr float_X SPECTRAL_SUPPORT = 6._X; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steindev Why did the spectral support increase from 4 to 6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Results of numerical experiments. See #5269.
* | ||
* unit: none | ||
*/ | ||
static constexpr float_64 PULSE_INIT = 17.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change from 20 to 17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Results of numerical experiments. See #5269.
/** Calculate incident field E value for the given position | ||
* The implementation is based on a definition of the electric field E given in frequency-space domain, | ||
* which is printed in eq. (6) of ref. [1]. Compared to the reference, higher order derivatives of the | ||
* frequency dependent propagation angle are set to zero, i.e. theta'' = theta''' = 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the '
standing for here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read '
as 'prime' and it means derivative with respect to frequency. Standard notation. Obviously... 😒 😉
* (Unitless::OMEGA0 * Unitless::AD * (Omega - Unitless::OMEGA0) | ||
+ Unitless::AD * (Omega - Unitless::OMEGA0) * (Omega - Unitless::OMEGA0) | ||
- Unitless::OMEGA0 / 6.0_X * Unitless::AD * Unitless::AD * Unitless::AD | ||
* (Omega - Unitless::OMEGA0) * (Omega - Unitless::OMEGA0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this equation, I would suggest storing (Omega - Unitless::OMEGA0)
in a const variable before and use it here. This avoids 6-1=5 subtractions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also did it in the other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, 1970 just called: They are super-excited about their latest idea of Common Subexpression Elimination. They say that maybe in a distant future compilers might be capable of applying that to real-world code. I wonder how long we're gonna have to wait for this.
- sim.pic.getSpeedOfLight() * alpha * pos[0] / (Unitless::W0 * Unitless::OMEGA0); | ||
|
||
// gaussian envelope in frequency domain | ||
float_X const envFreqExp = -(Omega - Unitless::OMEGA0) * (Omega - Unitless::OMEGA0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
float_X alpha = expandedWaveVectorX(Omega); | ||
|
||
// Center of a frequency's spatial distribution | ||
float_X center = Unitless::SD * (Omega - Unitless::OMEGA0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
float_X phase = Omega * pos[0] / sim.pic.getSpeedOfLight() | ||
+ 0.5_X * Unitless::GDD * (Omega - Unitless::OMEGA0) * (Omega - Unitless::OMEGA0) | ||
+ Unitless::TOD / 6.0_X * (Omega - Unitless::OMEGA0) * (Omega - Unitless::OMEGA0) | ||
* (Omega - Unitless::OMEGA0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well
e7ff6a8
to
65ec0a4
Compare
Thanks for your review @PrometheusPi 🙏 |
* getCurrentTime() -> getTminusXoverC() for separable profiles * make focus the origin of internal coordinate system * fix language typos * rename Unitless::w -> Unitless::OMEGA0 * delete PulseFrontTilt laser * Perform parameter range checks in ExpRampWithPrepulse
* update, expand, and fix language typos in doc-strings * use currentTimeOrigin & evaluate for all times * take Unitless::TIME_DELAY into account * apply dispersions only along polarization axis * move doubly performed computations into common place and compute only once * rename Unitless::w -> Unitless::OMEGA0 * decrease indentation level by namespace nesting * Add metadata
* update, expand, and fix language typos in doc-strings * allow for elliptic transverse shape by having different W0 per axis * remove pulse-front tilt (use via DispersivePulse for TEM_00, for all other modes the propagation is not known anyways) * adapt to new definition of internalCoordinates and time * straighten expressions for field computation (implementation follows Pausch et al. paper now) * rename Unitless::w -> Unitless::OMEGA0
9fd531d
to
4115299
Compare
@PrometheusPi: The latest changes are force-pushed again and run through the CI now. Second, here is the comparison between 32bit and 64bit regarding the (no error in labels, really) |
@steindev Thanks for providing the comparison between 32bit and 64bit. This look excellent. |
Thanks @steindev Looks good. |
70a6709
into
ComputationalRadiationPhysics:dev
This refactoring straightens the implementation of laser profiles and removes confusing terms being added and later subtracted.
Major changes are:
origin
variable refers to the position on the Huygens surface where the field needs to be evaluated in order to feed it into the simulation=> This allows to implement expressions for laser fields as they are printed in publications and text books w/o additional phase and envelope terms
=> For pulse-front tilted standard Gaussian pulses the DispersivePulse can and should be used
Draft status of this PR will be removed when the following action items are performed
GaussianPulse
:DispersivePulse
:Close #5269