Skip to content
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

Add thin optical elements in lasy #199

Merged
merged 28 commits into from
Jul 16, 2024

Conversation

RemiLehe
Copy link
Member

@RemiLehe RemiLehe commented Oct 25, 2023

This PR is one suggested way to add thin optical elements in lasy, through which the laser profiles can be propagated. This is heavily inspired by examples in axiprop.

Thin elements are represented by their complex multiplying factor T(x, y, omega) and are therefore applied after performing one Fourier transform on the laser profile, along the time axis. This PR only implements one optical element (ParabolicMirror), but more will be added next.

For this reason, I chose to have the user pass the optical element to the propagate function (since this function starts by performing a Fourier transform along the time axis) In the latest version, the API has been changed.

tests/test_parabolic_mirror.py Fixed Show fixed Hide fixed
lasy/optical_elements/axiparabola.py Fixed Show fixed Hide fixed
@RemiLehe RemiLehe force-pushed the optical_elements branch 2 times, most recently from e9d758b to 682b058 Compare October 26, 2023 17:23
@AngelFP
Copy link
Member

AngelFP commented Nov 3, 2023

This is great. I know it's early work, but would it make sense to be able to define something like an OpticalBeamline that can have several OpticalElements? Then we could pass this beamline to propagate.

@AngelFP AngelFP added the new feature request or implementation of a new feature label Jan 15, 2024
"""
# Transform the field from temporal to frequency domain
time_axis_indx = -1
field_fft = np.fft.ifft(self.grid.field, axis=time_axis_indx, norm="backward")
Copy link
Member Author

@RemiLehe RemiLehe Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation is not efficient currently, as it performs FFTs forward and backward.
This will be fixed in #256, by keeping the Fourier-space fields in memory and having a flag that keeps track of this.

@RemiLehe RemiLehe changed the title [WIP] Attempt to add thin optical elements in lasy Attempt to add thin optical elements in lasy Jul 15, 2024
@RemiLehe RemiLehe closed this Jul 15, 2024
@RemiLehe RemiLehe reopened this Jul 15, 2024
@@ -160,6 +160,46 @@ def normalize(self, value, kind="energy"):
else:
raise ValueError(f'kind "{kind}" not recognized')

def apply_optics(self, optical_element):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New API

@RemiLehe RemiLehe mentioned this pull request Jul 15, 2024
@RemiLehe RemiLehe changed the title Attempt to add thin optical elements in lasy Add thin optical elements in lasy Jul 15, 2024
@RemiLehe RemiLehe requested review from MKirchen and MaxThevenet July 15, 2024 19:33
Copy link
Contributor

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR!

lasy/optical_elements/optical_element.py Show resolved Hide resolved
lasy/optical_elements/optical_element.py Outdated Show resolved Hide resolved
lasy/laser.py Outdated

# Apply optical element
if self.dim == "rt":
r, w = np.meshgrid(self.grid.axes[0], omega, indexing="ij")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment: might be a bit dangerous to mix w and omega.

lasy/laser.py Outdated Show resolved Hide resolved
lasy/laser.py Outdated

# Apply optical element
if self.dim == "rt":
r, w = np.meshgrid(self.grid.axes[0], omega, indexing="ij")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same as comment in optical_element.py: should the meshgrid be done in the optical element? Could just be an option)

lasy/laser.py Outdated Show resolved Hide resolved
# along theta (FT_theta). Because the multiplier is assumed to be
# cylindrically symmetric (i.e. theta-independent):
# FT_theta[ multiplier * field ] = multiplier * FT_theta[ field ]
# Thus, we can simply multiply each azimuthal mode by the multiplier.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added more explanations here.

@MaxThevenet MaxThevenet merged commit e2982ac into LASY-org:development Jul 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request or implementation of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants