File:Grating Diffraction vs Period.webm

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (WebM audio/video file, VP9, length 20 s, 804 × 804 pixels, 651 kbps overall, file size: 1.58 MB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: Diffraction from a sinusoidal grating as a function of its period. For long to intermediate periods, light is diffracted in 2 well-defined directions, but for very short periods light is not diffracted anymore.
Date
Source https://twitter.com/j_bertolotti/status/1484182956964864007
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 12.0 code

[edit]
\[Lambda]0 = 1.; k0 = 
 N[(2 \[Pi])/\[Lambda]0]; (*The wavelength in vacuum is set to 1, so \
all lengths are now in units of wavelengths*)
\[Delta] = \[Lambda]0/50; \[CapitalDelta] =  20*\[Lambda]0; (*Parameters for the grid*)
\[Sigma] = 20 \[Lambda]0; (*width of the gaussian beam*)

sourcef[x_, y_] := E^(-(x^2/(2 \[Sigma]^2))) E^(-((y + \[CapitalDelta]/            2)^2/(2 (\[Lambda]0/2)^2))) E^(I k0 y);
\[Phi]in = Table[Chop[sourcef[x, y]], {x, -\[CapitalDelta]/2, \[CapitalDelta]/    2, \[Delta]}, {y, -\[CapitalDelta]/2, \[CapitalDelta]/2, \[Delta]}]; (*Discretized source*)
d = \[Lambda]0/2; (*typical scale of the absorbing layer*)

imn = Table[ Chop[5 (E^-((x + \[CapitalDelta]/2)/d) + E^((x - \[CapitalDelta]/2)/d) + E^-((y + \[CapitalDelta]/2)/d) + E^((y - \[CapitalDelta]/2)/d))], {x, -\[CapitalDelta]/2, \[CapitalDelta]/2, \[Delta]}, {y, -\[CapitalDelta]/2, \[CapitalDelta]/2, \[Delta]}]; (*Imaginary part of the refractive index (used to emulate absorbing boundaries)*)
dim = Dimensions[\[Phi]in][[1]];
L = -1/\[Delta]^2*KirchhoffMatrix[GridGraph[{dim, dim}]]; (*Discretized Laplacian*)

stopstep[t_] := 10 (t - 1)^4 + 0.5;
frames = Table[
   period = stopstep[t];
   ren = Table[
     If[-\[CapitalDelta]/2 < y < Cos[(2 \[Pi])/period x] - \[CapitalDelta]/2 + 3, 2, 1], {x, -\[CapitalDelta]/2, \[CapitalDelta]/2, \[Delta]}, {y, -\[CapitalDelta]/2, \[CapitalDelta]/2, \[Delta]}];
   n = ren + I imn;
   b = -(Flatten[n]^2 - 1) k0^2 Flatten[\[Phi]in]; (*Right-hand side of the equation we want to solve*)
M = L + DiagonalMatrix[SparseArray[Flatten[n]^2 k0^2]]; (*Operator on the left-hand side of the equation we want to solve*)
\[Phi]s = Partition[LinearSolve[M, b], dim]; (*Solve the linear system*)
   
ImageAdd[
    ArrayPlot[Transpose[(Abs[(\[Phi]in + \[Phi]s)]^2/Max[(Abs[\[Phi]in + \[Phi]s]^2)[[(4 d)/\[Delta] ;; (-4 d)/\[Delta], (4 d)/\[Delta] ;; (-4 d)/\[Delta]]]])][[(       4 d)/\[Delta] ;; (-4 d)/\[Delta], (4 d)/\[Delta] ;; (-4 d)/\[Delta]]],      ColorFunction -> "AvocadoColors", DataReversed -> True, Frame -> False, PlotRange -> {0, 1}]
    ,
ArrayPlot[ Transpose[Re[(n - 1)/5]] [[(4 d)/\[Delta] ;; (-4 d)/\[Delta], (4 d)/\[Delta] ;; (-4 d)/\[Delta]]], DataReversed -> True ,      ColorFunctionScaling -> False, ColorFunction -> GrayLevel, Frame -> False]
    ](*Plot everything*)
   , {t, 0, 1, 1/100}];

ListAnimate[Join[Table[frames[[1]], {2}], frames, Reverse@frames]]

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:10, 21 January 202220 s, 804 × 804 (1.58 MB)Berto (talk | contribs)Imported media from uploads:dc09b0a6-7aa0-11ec-be16-56dbdb266599

The following page uses this file:

Transcode status

Update transcode status
Format Bitrate Download Status Encode time
VP9 720P 437 kbps Completed 10:10, 21 January 2022 15 s
VP9 480P 240 kbps Completed 10:10, 21 January 2022 11 s
VP9 360P 148 kbps Completed 10:10, 21 January 2022 9.0 s
VP9 240P 88 kbps Completed 10:10, 21 January 2022 6.0 s
WebM 360P 485 kbps Completed 10:10, 21 January 2022 5.0 s
QuickTime 144p (MJPEG) 314 kbps Completed 16:54, 29 October 2024 1.0 s

Metadata