{ "cells": [ { "cell_type": "markdown", "id": "996ae31d-192b-4988-bd6b-649c833ae967", "metadata": {}, "source": [ "# Gaussian laser pulse" ] }, { "cell_type": "markdown", "id": "f25efcc9-1ed0-4f9a-8c62-da36f56ba02f", "metadata": {}, "source": [ "We will try a simple example to get familiar with the code structure and to verify the installation was successful.\n", "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.\n", "\n", "First let's load in the required functions from the library." ] }, { "cell_type": "code", "execution_count": null, "id": "ed0a409c-3c02-4fc4-b41b-ef41d0fb5a3a", "metadata": {}, "outputs": [], "source": [ "from lasy.laser import Laser\n", "from lasy.profiles.gaussian_profile import GaussianProfile" ] }, { "cell_type": "markdown", "id": "83519896-2653-4895-8d90-789c4f0729ae", "metadata": {}, "source": [ "Next, define the physical parameters of the laser pulse and create the laser profile object." ] }, { "cell_type": "code", "execution_count": null, "id": "15491762-c2d5-4b65-8cd3-4633a4cb7eff", "metadata": {}, "outputs": [], "source": [ "wavelength = 800e-9 # Laser wavelength in meters\n", "polarization = (1, 0) # Linearly polarized in the x direction\n", "energy = 1.5 # Energy of the laser pulse in joules\n", "spot_size = 25e-6 # Waist of the laser pulse in meters\n", "pulse_duration = 30e-15 # Pulse duration of the laser in seconds\n", "t_peak = 0.0 # Location of the peak of the laser pulse in time\n", "\n", "laser_profile = GaussianProfile(\n", " wavelength, polarization, energy, spot_size, pulse_duration, t_peak\n", ")" ] }, { "cell_type": "markdown", "id": "c303d3b6-2422-445b-a332-bc3f48388612", "metadata": {}, "source": [ "Now create a full laser object containing the above physical parameters together with the computational settings." ] }, { "cell_type": "code", "execution_count": null, "id": "84cb6fd2-2f44-4cc9-a5c1-6dd1e0d72c67", "metadata": {}, "outputs": [], "source": [ "dimensions = \"rt\" # Use cylindrical geometry\n", "lo = (0, -2.5 * pulse_duration) # Lower bounds of the simulation box\n", "hi = (5 * spot_size, 2.5 * pulse_duration) # Upper bounds of the simulation box\n", "num_points = (300, 500) # Number of points in each dimension\n", "\n", "laser = Laser(dimensions, lo, hi, num_points, laser_profile)" ] }, { "cell_type": "markdown", "id": "8ac8f985-4a09-4b9a-a9ff-11ce2ef94caa", "metadata": {}, "source": [ "The laser pulse can be visualized with the `show` method." ] }, { "cell_type": "code", "execution_count": null, "id": "bb8dc634-b3c4-4448-834b-fe9acb6c9645", "metadata": {}, "outputs": [], "source": [ "laser.show()" ] }, { "cell_type": "markdown", "id": "292c6e63-0480-4fb9-b1ad-6b679a3472d0", "metadata": {}, "source": [ "By default, the values of the laser envelope are injected on the focal plan. One can propagate it backwards by one Rayleigh length (optional)." ] }, { "cell_type": "code", "execution_count": null, "id": "00b4f258-ca10-4bc7-b550-75fb10c3603a", "metadata": {}, "outputs": [], "source": [ "z_R = 3.14159 * spot_size**2 / wavelength # The Rayleigh length\n", "laser.propagate(-z_R) # Propagate the pulse upstream of the focal plane" ] }, { "cell_type": "code", "execution_count": null, "id": "3158e51d-e331-438d-90c1-5f8c63bf9841", "metadata": {}, "outputs": [], "source": [ "laser.show()" ] }, { "cell_type": "markdown", "id": "8df816dc-9b47-4cb0-8716-600352fafb72", "metadata": {}, "source": [ "Output the result to a file. Here we utilise the openPMD standard." ] }, { "cell_type": "code", "execution_count": null, "id": "b6a4c66b-651e-40b7-b15e-53f8a27caeb2", "metadata": {}, "outputs": [], "source": [ "file_prefix = \"test_output\" # The file name will start with this prefix\n", "file_format = \"h5\" # Format to be used for the output file\n", "\n", "laser.write_to_file(file_prefix, file_format)" ] }, { "cell_type": "markdown", "id": "1edc3e0b-f88a-4a8a-8802-3d5ec9098f9c", "metadata": {}, "source": [ "The generated file may now be viewed or used as a laser input to a variety of other simulation tools." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.6" } }, "nbformat": 4, "nbformat_minor": 5 }