-
Notifications
You must be signed in to change notification settings - Fork 225
Implement PICMI capability for TWTS and TWEAC lasers #5561
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
base: dev
Are you sure you want to change the base?
Implement PICMI capability for TWTS and TWEAC lasers #5561
Conversation
|
@BeyondEspresso The CI is seeing compile time errors with your TWTS implementation. For details please see CI log. Seems to be related to how you access fields. |
|
@PrometheusPi Thanks, I fixed a compile-time bug in the 2D branch. |
cc199e8 to
d317d30
Compare
PrometheusPi
left a comment
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.
Minor changes required and some questions.
| floatD_X laserOrigin = precisionCast<float_X>(halfSimSize); | ||
| laserOrigin.y() = float_X(focus_y_SI / cellDimensions.y()); | ||
| if constexpr(simDim == DIM3) | ||
| laserOrigin.z() += float_X(focus_z_offset_SI / cellDimensions.z()); |
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.
@psychocoderHPC why does the original version seems not to work?
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.
The compiler does attempt a name lookup despite the compile-time condition. Since the .z() do not exist in 2D, this throws an error.
| "exclusiveMinimum": 0 | ||
| }, | ||
| "pulse_init": { | ||
| "description": " The laser pulse will be initialized pulse_init times of the pulse_duration_si", |
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.
| "description": " The laser pulse will be initialized pulse_init times of the pulse_duration_si", | |
| "description": "The laser pulse will be initialized pulse_init times of the pulse_duration_si", |
| }, | ||
| "pulse_duration_si": { | ||
| "type": "number", | ||
| "description": "sigma of std. gauss for intensity (E^2) [s]", |
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.
| "description": "sigma of std. gauss for intensity (E^2) [s]", | |
| "description": "sigma of std. Gauss for intensity (E^2) [s]", |
| } | ||
| }, | ||
| "huygens_surface_positions": { | ||
| "description": "position of the huygens surface relative from domain boundaries", |
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.
| "description": "position of the huygens surface relative from domain boundaries", | |
| "description": "position of the Huygens surface relative from domain boundaries", |
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 fix it the original schema you copied them from.
| - a0 : float, optional | ||
| Normalized vector potential at focus [dimensionless]. | ||
| Specify either a0 or E0 (E0 takes precedence). |
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.
Does E0 take precedence, or is this an outdated comment? I added throwing an error if both were given for the Gauss and Dispersive pulse.
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.
It is outdated. See here:
picongpu/lib/python/picongpu/picmi/lasers/base_laser.py
Lines 42 to 43 in 4a42ebb
| if (E0 is not None) and (a0 is not None): | |
| raise ValueError("Only one of E0 or a0 should be specified. You set both.") |
Please update the comment.
| # def check(self): | ||
| # self._validate_common_properties() |
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.
Please remove commented out code.
| # self._validate_common_properties() | ||
| self.pulse_init = self._compute_pulse_init() | ||
|
|
||
| """PICMI object for TWTS Laser""" |
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 do you have this comment (string) at the bottom of the code?
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.
This was how it was structured for other PICMI lasers. However, I had to remove the general laser checks as they do not apply for TWTS lasers. These assume implicitly that lasers enter via the YMIN-plane and thus do not apply here.
| static constexpr float_64 FOCUS_Y_SI = focus_position[1];//56.0e-6; | ||
| static constexpr float_64 FOCUS_Z_OFFSET_SI = {{{focus_z_offset_si}}};//8.0e-6; | ||
| static constexpr float_64 PHI = {{{phi}}};//5.0 * (PI / 180.); | ||
| static constexpr float_64 BETA_0 = 1.0;//{{{beta0}}}; | ||
| static constexpr float_64 TDELAY = {{{time_offset_si}}};//124.535e-6 / sim.si.getSpeedOfLight(); | ||
| static constexpr bool AUTO_TDELAY = false; | ||
| static constexpr float_X Polarization = {{{polarizationAngle}}};//45.10716816968629 * (PI / 180.); | ||
| static constexpr float_X windowStart = 0.0; | ||
| static constexpr float_X windowEnd = 10.0e+20; | ||
| static constexpr float_X windowLength = 10000.0;//10000.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.
| static constexpr float_64 FOCUS_Y_SI = focus_position[1];//56.0e-6; | |
| static constexpr float_64 FOCUS_Z_OFFSET_SI = {{{focus_z_offset_si}}};//8.0e-6; | |
| static constexpr float_64 PHI = {{{phi}}};//5.0 * (PI / 180.); | |
| static constexpr float_64 BETA_0 = 1.0;//{{{beta0}}}; | |
| static constexpr float_64 TDELAY = {{{time_offset_si}}};//124.535e-6 / sim.si.getSpeedOfLight(); | |
| static constexpr bool AUTO_TDELAY = false; | |
| static constexpr float_X Polarization = {{{polarizationAngle}}};//45.10716816968629 * (PI / 180.); | |
| static constexpr float_X windowStart = 0.0; | |
| static constexpr float_X windowEnd = 10.0e+20; | |
| static constexpr float_X windowLength = 10000.0;//10000.0; | |
| static constexpr float_64 FOCUS_Y_SI = focus_position[1]; | |
| static constexpr float_64 FOCUS_Z_OFFSET_SI = {{{focus_z_offset_si}}} | |
| static constexpr float_64 PHI = {{{phi}}}; | |
| static constexpr float_64 BETA_0 = {{{beta0}}}; | |
| static constexpr float_64 TDELAY = {{{time_offset_si}}}; | |
| static constexpr bool AUTO_TDELAY = false; | |
| static constexpr float_X Polarization = {{{polarizationAngle}}}; | |
| static constexpr float_X windowStart = 0.0; | |
| static constexpr float_X windowEnd = 10.0e+20; | |
| static constexpr float_X windowLength = 10000.0; |
There was some commented-out code left and I think beta0was never applied.
| constexpr float_X a0 = 0.3635819; | ||
| constexpr float_X a1 = 0.4891775; | ||
| constexpr float_X a2 = 0.1365995; | ||
| constexpr float_X a3 = 0.0106411; |
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 these constants? Could you add a comment what these magic numbers represent?
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.
This is the window type. I should add a comment.
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 you need to add this file? I thought we already have a TWTS implementation.
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.
The one we have is only via background fields. There seems to be no incident field TWTS mainline yet. Correct @BeyondEspresso?
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.
Rest of file looks okay - I have to trust @BeyondEspresso that the equations are correct. Perhaps @steindev could have a second look at this file.
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.
@BeyondEspresso Since you added now this TWTS incident field pulse, please add the option to our incidentField.param files. E.g.
picongpu/include/picongpu/param/incidentField.param
Lines 36 to 37 in 4a42ebb
| * - profiles::Wavepacket<> : wavepacket with Gaussian spatial and temporal envelope profile with given | |
| * parameters |
and the examples and tests.
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.
The TWTS implementation can be used for both background and incidentFields. With TWTSPulse.def, I basically reduced the boiler plate code I had to include in the param-files production runs. The question here would be, whether a more extended version (not relying on the Free-profile and including metadata methods) should be included in this PR already or whether this can deferred to a later PR.
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.
@PrometheusPi Just to clarify: we already have a working incident field implementation in mainline. The TWEAC-FOM setup also makes use of that. This change is about reducing boiler plate code and does not change any equations of the existing TWTSTight model.
| static constexpr float_X windowStart = 0.0; | ||
| static constexpr float_X windowEnd = 10.0e+20; | ||
| static constexpr float_X windowLength = 10000.0;//10000.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 are there hardcoded numbers 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.
Only for initial testing, I will remove them an add these to the parameters.
| else: | ||
| self.phiPos = False | ||
| self.beta0 = beta0 | ||
| self.phi0 = 0.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's this? How is this different from phi?
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.
phi0 is the phase inherited from BaseModel and has no function for TWTSTight. I set it to zero to show what it would be for TWTSTight. However, it would be straightforward and easy to add such a capability to the TWTSTight-interface.
phi is the laser incident angle and as such a different physics quantity. I want to keep the naming to remain consistent with all my other code.
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 you will hate that, but it might be better to use laserIncidentAngle as variable name instead of phi, much less likely to cause confusion with the myriad other phi-s already in use in PICMI.
In general I prefer immediately understandable names even though they are longer.
| @typeguard.typechecked | ||
| class TWTSLaser(BaseLaser): | ||
| """ | ||
| Specifies a TWTS laser |
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 does TWTS stand for? Please add the full length form of the acronym at least one to the PICMI class definition to ensure that other users understand the difference to the other laser models.
It would also make sense to add one ore more reference and/or a short description of the TWTS laser model.
| - wavelength: float | ||
| Central wavelength of the laser [m]. |
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.
Current form is fine, but I would prefer doxygen style parameter definitions. That will make it easier to autogenerate a API documentation later.
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.
@BrianMarre @chillenzer We can use doxygen-style parameter definitions, but this is not yet used in our python code. Before I break some implicit design decision here, is there any style that we intend to enforce in the future?
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 would argue for doxygen, no need to support two different tools for auto generating API documentation.
| - phi: float | ||
| Laser incident angle [rad] | ||
| denoting the mean laser phase propagation direction | ||
| with respect to the y-axis. |
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.
magical axis definition, either requires a fixed coordinate system or should be defined relative to something like the focus movement direction.
Please remember that we may not assume that the focus moves parallel to the y-direction in PICMI, since this might not be true in other PIC-codes.
| "waist_si", | ||
| "pulse_duration_si", | ||
| "focus_pos_si", | ||
| "phase", |
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 thought the TWTS laser does not support a phase?
|
I converted the PR to draft to avoid merging accidentally |
|
@PrometheusPi @psychocoderHPC @BrianMarre @chillenzer Thanks for your feedback. In this update I included all suggestions except for the doxygen-style comments in order to avoid breaking style with the other existing python-scripts. In particular, the refactored TWEAC-FOM-benchmark now showcases reduced boiler plate code using |
|
I performed 3 compilation tests on the FOM setup (fieldBackground, incidentField w/o componentwise operators, incidentField with componentwise operators). The envisioned picmi-setup also compiles. |
|
The draft tag can now be removed. |
This draft of a PR implements PICMI capability for TWTS and TWEAC lasers. It successfully runs and builds the Laser-wakefield PICMI example using:
As already mentioned, this PR should be still considered a draft, but feedback is welcome!
Current working items and/or questions are:
freestill appropriate?centroid_positionandfocal_position? The semantics is not very intuitive for TWTS lasers here.