-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include examples as notebooks in the documentation (#197)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3ab8552
commit 9eaa975
Showing
6 changed files
with
160 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
{ | ||
"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.profiles.gaussian_profile import GaussianProfile\n", | ||
"from lasy.laser import Laser" | ||
] | ||
}, | ||
{ | ||
"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(wavelength,polarization,energy,spot_size,pulse_duration,t_peak)" | ||
] | ||
}, | ||
{ | ||
"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": "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": "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.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ Tutorials | |
========= | ||
|
||
.. toctree:: | ||
:hidden: | ||
:maxdepth: 4 | ||
:maxdepth: 1 | ||
|
||
initialise_gaussian | ||
gaussian_laser.ipynb |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters