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

Show progress bar in propagate #196

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lasy/laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def normalize(self, value, kind="energy"):
else:
raise ValueError(f'kind "{kind}" not recognized')

def propagate(self, distance, nr_boundary=None, backend="NP"):
def propagate(self, distance, nr_boundary=None, backend="NP", show_progress=True):
"""
Propagate the laser pulse by the distance specified.

Expand All @@ -154,6 +154,8 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
Only used for ``'rt'``.
backend : string (optional)
Backend used by axiprop (see axiprop documentation).
show_progress : bool (optional)
Whether to show a progress bar when performing the computation
"""
time_axis_indx = -1

Expand Down Expand Up @@ -210,7 +212,12 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
# Propagate the spectral image
for i_m in range(self.grid.azimuthal_modes.size):
transform_data = np.transpose(field_fft[i_m]).copy()
self.prop[i_m].step(transform_data, distance, overwrite=True)
self.prop[i_m].step(
transform_data,
distance,
overwrite=True,
show_progress=show_progress,
)
field_fft[i_m, :, :] = np.transpose(transform_data).copy()
else:
# Construct the propagator (check if exists)
Expand All @@ -227,7 +234,9 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
)
# Propagate the spectral image
transform_data = np.transpose(field_fft).copy()
self.prop.step(transform_data, distance, overwrite=True)
self.prop.step(
transform_data, distance, overwrite=True, show_progress=show_progress
)
field_fft[:, :, :] = np.transpose(transform_data).copy()

# Choose the time translation assuming propagation at v=c
Expand Down
4 changes: 2 additions & 2 deletions lasy/utils/phase_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def gerchberg_saxton_algo(
i = 0
while breakout(cond):
laser1.grid.field = amp1 * np.exp(1j * phase1)
laser1.propagate(dz)
laser1.propagate(dz, show_progress=False)

phase2 = np.angle(laser1.grid.field)
laser2.grid.field = amp2 * np.exp(1j * phase2)
laser2.propagate(-dz)
laser2.propagate(-dz, show_progress=False)

phase1 = np.angle(laser2.grid.field)
amp1_calc = np.abs(laser2.grid.field)
Expand Down
Loading