diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a914949b..31c044b5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -56,7 +56,7 @@ repos: # Python: Ruff linter & formatter # https://docs.astral.sh/ruff/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.6.2 hooks: # Run the linter - id: ruff diff --git a/docs/source/tutorials/axiparabola.ipynb b/docs/source/tutorials/axiparabola.ipynb index ab9f2fec..0b345265 100644 --- a/docs/source/tutorials/axiparabola.ipynb +++ b/docs/source/tutorials/axiparabola.ipynb @@ -44,17 +44,19 @@ "from lasy.profiles.longitudinal import GaussianLongitudinalProfile\n", "from lasy.profiles.transverse import SuperGaussianTransverseProfile\n", "\n", - "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 = 1e-3 # Spot size in the near-field: millimeter-scale\n", + "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 = 1e-3 # Spot size in the near-field: millimeter-scale\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", + "t_peak = 0.0 # Location of the peak of the laser pulse in time\n", "\n", "laser_profile = CombinedLongitudinalTransverseProfile(\n", - " wavelength, polarization, energy,\n", + " wavelength,\n", + " polarization,\n", + " energy,\n", " GaussianLongitudinalProfile(wavelength, pulse_duration, t_peak),\n", - " SuperGaussianTransverseProfile(spot_size, n_order=16)\n", + " SuperGaussianTransverseProfile(spot_size, n_order=16),\n", ")" ] }, @@ -75,12 +77,12 @@ "metadata": {}, "outputs": [], "source": [ - "dimensions = 'rt' # Use cylindrical geometry\n", - "lo = (0,-2.5*pulse_duration) # Lower bounds of the simulation box\n", - "hi = (1.1*spot_size,2.5*pulse_duration) # Upper bounds of the simulation box\n", - "num_points = (3000, 30) # Number of points in each dimension\n", + "dimensions = \"rt\" # Use cylindrical geometry\n", + "lo = (0, -2.5 * pulse_duration) # Lower bounds of the simulation box\n", + "hi = (1.1 * spot_size, 2.5 * pulse_duration) # Upper bounds of the simulation box\n", + "num_points = (3000, 30) # Number of points in each dimension\n", "\n", - "laser = Laser(dimensions,lo,hi,num_points,laser_profile)" + "laser = Laser(dimensions, lo, hi, num_points, laser_profile)" ] }, { @@ -112,10 +114,10 @@ "source": [ "from lasy.optical_elements import Axiparabola\n", "\n", - "f0 = 3e-2 # Focal distance\n", + "f0 = 3e-2 # Focal distance\n", "delta = 1.5e-2 # Focal range\n", - "R = spot_size # Radius\n", - "axiparabola = Axiparabola( f0, delta, R )" + "R = spot_size # Radius\n", + "axiparabola = Axiparabola(f0, delta, R)" ] }, { @@ -133,8 +135,8 @@ "metadata": {}, "outputs": [], "source": [ - "laser.apply_optics( axiparabola )\n", - "laser.propagate( f0 )" + "laser.apply_optics(axiparabola)\n", + "laser.propagate(f0)" ] }, { @@ -165,7 +167,7 @@ "metadata": {}, "outputs": [], "source": [ - "laser.write_to_file('flying_focus', 'h5')" + "laser.write_to_file(\"flying_focus\", \"h5\")" ] }, { @@ -188,9 +190,9 @@ "source": [ "import math\n", "\n", - "ZR = math.pi*wavelength*f0**2/spot_size**2\n", - "print('Rayleigh length: %.f mm' %(1.e3*ZR))\n", - "print('Focal range: %.f mm' %(1.e3*delta))" + "ZR = math.pi * wavelength * f0**2 / spot_size**2\n", + "print(\"Rayleigh length: %.f mm\" % (1.0e3 * ZR))\n", + "print(\"Focal range: %.f mm\" % (1.0e3 * delta))" ] }, { @@ -200,10 +202,10 @@ "metadata": {}, "outputs": [], "source": [ - "laser.propagate(2*ZR)\n", + "laser.propagate(2 * ZR)\n", "laser.show()\n", "plt.ylim(-0.25e-3, 0.25e-3)\n", - "plt.title('Laser field after 2 Rayleigh range')" + "plt.title(\"Laser field after 2 Rayleigh range\")" ] }, { @@ -213,10 +215,10 @@ "metadata": {}, "outputs": [], "source": [ - "laser.propagate(2*ZR)\n", + "laser.propagate(2 * ZR)\n", "laser.show()\n", "plt.ylim(-0.25e-3, 0.25e-3)\n", - "plt.title('Laser field after 4 Rayleigh range')" + "plt.title(\"Laser field after 4 Rayleigh range\")" ] } ], diff --git a/docs/source/tutorials/gaussian_laser.ipynb b/docs/source/tutorials/gaussian_laser.ipynb index 570f782a..37219687 100644 --- a/docs/source/tutorials/gaussian_laser.ipynb +++ b/docs/source/tutorials/gaussian_laser.ipynb @@ -45,14 +45,16 @@ "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", + "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", + "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)" + "laser_profile = GaussianProfile(\n", + " wavelength, polarization, energy, spot_size, pulse_duration, t_peak\n", + ")" ] }, { @@ -70,12 +72,12 @@ "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", + "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)" + "laser = Laser(dimensions, lo, hi, num_points, laser_profile)" ] }, { @@ -111,8 +113,8 @@ "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" + "z_R = 3.14159 * spot_size**2 / wavelength # The Rayleigh length\n", + "laser.propagate(-z_R) # Propagate the pulse upstream of the focal plane" ] }, { @@ -140,8 +142,8 @@ "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", + "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)" ]