File:WavefrontShaping.gif

Summary

Description
English: As elastic scattering is a linear process, you can make multiple scattered light interfere constructively at any point you want, if you control the phase of the incident wavefront. Only plotting the scattered intensity to make the figure less cluttered. Simulation done using coupled-dipole method for 2D scalar waves and iteratively optimizing the intensity in the selected target area.
Date
Source https://twitter.com/j_bertolotti/status/1063490538740072449
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 11.0 code

\[Lambda] = 10.;
k0 = (2 \[Pi])/\[Lambda];
\[Alpha] = 4/(k0^2 I);
\[Sigma] = (k0^3 Norm[\[Alpha]]^2)/4 // N
G[r_] := N[I/4 HankelH1[0, k0 Norm[r] ]];
dim = 100; (*Number of scatterers*)

rs = Table[{RandomReal[{-\[Lambda]*20, \[Lambda]*20}], 
    RandomReal[{\[Lambda]*5, \[Lambda]*15}]}, {dim}];

(**)
ns = 
  40; (*number of sources, i.e. number of degrees of freedom we can control*)
s[r_] := 
  Table[E^(I k0 Norm[r - {j, 0}])/
   Norm[r - {j, 
      0} ], {j, -\[Lambda]*10, \[Lambda]*10, (\[Lambda]*20)/(ns - 1)}];
E0 = Table[
   N[s[rs[[j]] ]], {j, 1, dim}]; (*source field on each scatterer*)

iME = Inverse@Table[
      If[k == j, 1, \[Alpha] k0^2 G[rs[[j]] - rs[[k]] ] ]
    , {j, 1, dim}, {k, 1, dim}];
Es = Table[
   iME.E0[[All, j]], {j, 1, ns}]; (*Total field on each scatterer*)
Etot = Table[(*s[{x,y}][[
   i]]+*)\[Alpha] k0^2 Sum[
     G[{x, y} - rs[[j]] ] Es[[i, j]], {j, 1 dim}], {i, 1, 
    ns}, {x, -\[Lambda]*10, \[Lambda]*10, 2}, {y, 2, \[Lambda]*20 + 2,
     2}]; (*Total field everywhere (this is the part that takes ages to compute)*)
(*If s[{x,y}][[j]] is commented out, only the scattered  field is computed.*)
target = {60, 65};
iterative = 
  Table[If[j == k, Etot[[j, target[[1]], target[[2]] ]] E^(I \[Phi]), 
    Etot[[j, target[[1]], target[[2]] ]] ], {k, 1, ns}, {j, 1, ns}];
\[Delta]\[Phi] = 
 Table[FindMaximum[Abs[Total@iterative[[j]] ]^2, {\[Phi], 0}][[2, 1, 
   2]], {j, 1, ns}];
sourcepos = 
  Table[{j, 1}, {j, -\[Lambda]*10, \[Lambda]*10, (\[Lambda]*20)/(
    ns - 1)}];
p1 = Table[
  GraphicsRow[{
    ArrayPlot[
     Reverse@Transpose@(
       Abs[Sum[Etot[[j]] E^(I \[Delta]\[Phi][[j]]), {j, 1, i}] + 
         Sum[Etot[[j]], {j, i + 1, ns}] ]^2) , 
     DataRange -> {{-\[Lambda]*10, \[Lambda]*10}, {2, \[Lambda]*20 + 
         2}}, ColorFunction -> "AvocadoColors", ImageSize -> Large, 
     Epilog -> {PointSize -> Medium, White, PointSize[0.02], 
       Point[rs], Red, Thickness[0.007], 
       Circle[{(target[[1]] - 1)*2 - \[Lambda]*10, (target[[2]] - 
             1)*2 + 2}, 8]
       ,
       Table[
        Line[{{sourcepos[[j, 1]] - \[CapitalDelta]s/
            2, -\[Delta]\[Phi][[j]] + 
            2}, {sourcepos[[j, 1]] + \[CapitalDelta]s/
            2, -\[Delta]\[Phi][[j]] + 2}}]
        , {j, 1, i}],
       Table[
        Line[{{sourcepos[[j, 1]] - \[CapitalDelta]s/2, 
           2}, {sourcepos[[j, 1]] + \[CapitalDelta]s/2, 2}}]
        , {j, i + 1, ns}]
       }]
    ,
    ListPlot[
     Abs[Sum[
        Etot[[j, All, target[[2]]]] E^(I \[Delta]\[Phi][[j]]), {j, 1, 
         i}] + Sum[Etot[[j, All, target[[2]]]], {j, i + 1, ns}] ]^2 , 
     Joined -> True, PlotRange -> {0, maxopt}, Axes -> False, 
     Frame -> True, FrameTicks -> None, PlotStyle -> {Thick, Green}]
    }],
  {i, 1, ns - 1, 1}];
ListAnimate[p1]

Licensing

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.

Category:CC-Zero#WavefrontShaping.gifCategory:Self-published work
This file, which was originally posted to https://twitter.com/j_bertolotti/status/1063490538740072449, was reviewed on 17 November 2018 by reviewer Ronhjones, who confirmed that it was available there under the stated license on that date.
Category:Files from external sources with reviewed licenses#WavefrontShaping.gif Category:Animations of vibrations and waves Category:Animations of optics Category:Animations of interference Category:Animations of interference patterns Category:Animated GIF files
Category:Animated GIF files Category:Animations of interference Category:Animations of interference patterns Category:Animations of optics Category:Animations of vibrations and waves Category:CC-Zero Category:Files from external sources with reviewed licenses Category:Self-published work