Laser#

class lasy.laser.Laser(dim, lo, hi, npoints, profile, n_azimuthal_modes=1)[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 for dim='xyt')

npointstuple of int

Number of points in each direction. One element per direction (2 for dim='rt', 3 for dim='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 dim is 'rt'. The number of azimuthal modes used in order to represent the laser field.

Examples

>>> import matplotlib.pyplot as plt
>>> 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.,  # J
...     w0=5e-6,  # m
...     tau=30e-15,  # s
...     t_peak=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 = np.abs(E_rt).max()
>>>     axes[step].imshow(
...         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)')
../_images/laser-1.png
normalize(value, kind='energy')[source]#

Normalize the pulse either to the energy, peak field amplitude or peak intensity.

Parameters:
value: scalar

Value to which to normalize the field property that is defined in kind

kind: string (optional)

Distance by which the laser pulse should be propagated Options: 'energy’, 'field', 'intensity' (default is 'energy')

propagate(distance, nr_boundary=None, backend='NP', show_progress=True)[source]#

Propagate the laser pulse by the distance specified.

Parameters:
distancescalar

Distance by which the laser pulse should be propagated

nr_boundaryinteger (optional)

Number of cells at the end of radial axis, where the field will be attenuated (to assert proper Hankel transform). Only used for 'rt'.

backendstring (optional)

Backend used by axiprop (see axiprop documentation).

show_progressbool (optional)

Whether to show a progress bar when performing the computation

show(**kw)[source]#

Show a 2D image of the laser amplitude.

Parameters:
**kw: additional arguments to be passed to matplotlib’s imshow command
write_to_file(file_prefix='laser', file_format='h5', save_as_vector_potential=False)[source]#

Write the laser profile + metadata to file.

Parameters:
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.