Gaussian laser pulse#
We will try a simple example to get familiar with the code structure and to verify the installation was successful. Let’s generate a Gaussian pulse at focus, propagate it backwards by one Rayleigh length (the pulse is then located upstream of the focal plane) and then output it to a file.
First let’s load in the required functions from the library.
[1]:
from lasy.profiles.gaussian_profile import GaussianProfile
from lasy.laser import Laser
Next, define the physical parameters of the laser pulse and create the laser profile object.
[2]:
wavelength = 800e-9 # Laser wavelength in meters
polarization = (1,0) # Linearly polarized in the x direction
energy = 1.5 # Energy of the laser pulse in joules
spot_size = 25e-6 # Waist of the laser pulse in meters
pulse_duration = 30e-15 # Pulse duration of the laser in seconds
t_peak = 0.0 # Location of the peak of the laser pulse in time
laser_profile = GaussianProfile(wavelength,polarization,energy,spot_size,pulse_duration,t_peak)
Now create a full laser object containing the above physical parameters together with the computational settings.
[3]:
dimensions = 'rt' # Use cylindrical geometry
lo = (0,-2.5*pulse_duration) # Lower bounds of the simulation box
hi = (5*spot_size,2.5*pulse_duration) # Upper bounds of the simulation box
num_points = (300,500) # Number of points in each dimension
laser = Laser(dimensions,lo,hi,num_points,laser_profile)
The laser pulse can be visualized with the show
method.
[4]:
laser.show()
/home/docs/checkouts/readthedocs.org/user_builds/lasydoc/envs/latest/lib/python3.11/site-packages/IPython/core/pylabtools.py:77: DeprecationWarning: backend2gui is deprecated since IPython 8.24, backends are managed in matplotlib and can be externally registered.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/lasydoc/envs/latest/lib/python3.11/site-packages/IPython/core/pylabtools.py:77: DeprecationWarning: backend2gui is deprecated since IPython 8.24, backends are managed in matplotlib and can be externally registered.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/lasydoc/envs/latest/lib/python3.11/site-packages/IPython/core/pylabtools.py:77: DeprecationWarning: backend2gui is deprecated since IPython 8.24, backends are managed in matplotlib and can be externally registered.
warnings.warn(
By default, the values of the laser envelope are injected on the focal plan. One can propagate it backwards by one Rayleigh length (optional).
[5]:
z_R = 3.14159*spot_size**2/wavelength # The Rayleigh length
laser.propagate(-z_R) # Propagate the pulse upstream of the focal plane
[6]:
laser.show()
Output the result to a file. Here we utilise the openPMD standard.
[7]:
file_prefix = 'test_output' # The file name will start with this prefix
file_format = 'h5' # Format to be used for the output file
laser.write_to_file(file_prefix, file_format)
The generated file may now be viewed or used as a laser input to a variety of other simulation tools.