Laser#
- class lasy.laser.Laser(dim, lo, hi, npoints, profile, n_azimuthal_modes=1, n_theta_evals=None)[source]#
Evaluate a laser profile on a grid, propagate it, and write it to a file.
This is a top-level class.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- lo, hilist of scalars
Lower and higher end of the physical domain of the box. One element per direction (2 for
dim='rt', 3 fordim='xyt')- npointstuple of int
Number of points in each direction. One element per direction (2 for
dim='rt', 3 fordim='xyt') For the moment, the lower end is assumed to be (0,0) in rt and (0,0,0) in xyt- profilean object of type lasy.profiles.profile.Profile
Defines how to evaluate the envelope field
- n_azimuthal_modesint (optional)
Only used if
dimis'rt'. The number of azimuthal modes used in order to represent the laser field.- n_theta_evalsint (optional)
Only used if
dimis'rt'. The number of points in the theta (azimuthal) direction at which to evaluate the laser field, before decomposing it inton_azimuthal_modesazimuthal modes. By default, this is set to2*n_azimuthal_modes - 1. However, for highly asymmetrical profiles, it may be necessary to increase this number.For instance, using
n_theta_evals=20andn_azimuthal_modes=1will evaluate the laser field at 20 points in the azimuthal direction and then average the values to extract the amplitude of the azimuthal mode 0.
Examples
>>> import matplotlib.pyplot as plt >>> from lasy.backend import xp, to_cpu >>> from lasy.laser import Laser >>> from lasy.profiles.gaussian_profile import GaussianProfile >>> from lasy.utils.laser_utils import get_full_field >>> # Create profile. >>> profile = GaussianProfile( ... wavelength=0.6e-6, # m ... pol=(1, 0), ... laser_energy=1.0, # J ... w0=5e-6, # m ... tau=30e-15, # s ... t_peak=0.0, # s ... ) >>> # Create laser with given profile in `rt` geometry. >>> laser = Laser( ... dim="rt", ... lo=(0e-6, -60e-15), ... hi=(10e-6, +60e-15), ... npoints=(50, 400), ... profile=profile, ... ) >>> # Propagate and visualize. >>> n_steps = 3 >>> propagate_step = 1e-3 >>> fig, axes = plt.subplots(1, n_steps, sharey=True) >>> for step in range(n_steps): >>> laser.propagate(propagate_step) >>> E_rt, extent = get_full_field(laser) >>> extent[2:] *= 1e6 >>> extent[:2] *= 1e12 >>> tmin, tmax, rmin, rmax = extent >>> vmax = xp.abs(E_rt).max() >>> axes[step].imshow( ... to_cpu(E_rt), ... origin="lower", ... aspect="auto", ... vmax=vmax, ... vmin=-vmax, ... extent=[tmin, tmax, rmin, rmax], ... cmap='bwr', ... ) >>> axes[step].set(xlabel='t (ps)') >>> if step == 0: >>> axes[step].set(ylabel='r (µm)')
- add_propagator(propagator)[source]#
Apply a propagator object to the laser pulse.
- Parameters:
- propagator: a :class:`.Propagator` object (optional)
Represents a propagation method.
- apply_optics(optical_element)[source]#
Propagate the laser pulse through a thin optical element.
- Parameters:
- optical_element: an :class:`.OpticalElement` object (optional)
Represents a thin optical element, through which the laser propagates.
- normalize(value, kind='energy')[source]#
Normalize the pulse either to the energy, peak field amplitude, peak fluence, peak power, peak intensity, or average intensity. The average intensity option operates on the envelope.
- Parameters:
- valuescalar
Value to which to normalize the field property that is defined in
kind- kindstring (optional)
Options:
'energy’,'field','intensity','average_intensity','peak_fluence','peak_power', (default is'energy')
- propagate(distance, **kwargs)[source]#
Propagate the laser pulse by the distance specified.
- Parameters:
- distancescalar
Distance by which the laser pulse should be propagated
- gridGrid object (optional)
Resample the field onto a new grid of different radial size and/or different number of radial grid points. Only works for
'rt'.
- show(envelope_type='field', t_shift=0, show_lineout=True, show_max=False, udict={}, **kw)[source]#
Show a 2D image of the laser amplitude or intensity.
- Parameters:
- envelope_typestring, default: “field”
Options are: -
'field': Show the envelope of the laser field. -'intensity': Show the intensity of the laser field. -'vector_potential': Show the vector potential of the laser field.- t_shiftfloat, default: 0
Shift the temporal axis by t_shift seconds. It also can be a string with “left”, “right” or “center”, to shift the temporal axis such that the t=0 lies at the left, right or center of the x-axis.
- show_lineoutbool, default: True
Show the lineout of the laser field.
- show_maxbool, default: False
Print the maximum intensity of the laser field.
- udictdict, default: {}
Dictionary with the information of the unit scales of the axes, e.g.
{'t': {'value': 1e-15, 'label': 'fs'}, 'x': {'value': 1e-6, 'label': r'\mu m'}}Override the default unit scales.- **kwadditional arguments to be passed to matplotlib’s imshow command
- write_to_file(file_prefix='laser', file_format='h5', write_dir='diags', save_as_vector_potential=False)[source]#
Write the laser profile + metadata to file.
- Parameters:
- write_dirstring
The directory where the file will be written.
- file_prefixstring
The file name will start with this prefix.
- file_formatstring
Format to be used for the output file. Options are
"h5"and"bp".- save_as_vector_potentialbool (optional)
Whether the envelope is converted to normalized vector potential before writing to file.