Function Repository Resource:

OpticalFieldModeling

Source Notebook

Model non-paraxial optical field interference and diffraction experiments under arbitrary spatial coherence

Contributed by: Julián Laverde

ResourceFunction["OpticalFieldModeling"][points]

returns a point array object representing real points points and their corresponding virtual points.

ResourceFunction["OpticalFieldModeling"][points,λ,z]

returns a power spectrum object representing the power spectrum of points at wavelength λ and propagation distance z.

Details and Options

The points can be a list of numeric or Quantity coordinates or a QuantityArray.
If points is given as a numeric List, the values are taken to be in micrometers.
ResourceFunction["OpticalFieldModeling"] takes the following options:
"CoherenceFunction"Nonecalculates the phase of every real point light source
"PhaseFunction"Nonecalculates the complex degree of spatial coherence of every virtual point
"PhaseFunction" is supplied with the coordinates of each real point and should return a numerical value in radians.
With the default setting "PhaseFunction"None, the phase value of every real point is set to 0, representing a plane wavefront.
"CoherenceFunction" is supplied with the distance vector of every length-two subset of real points and should return a numerical value between 0 and 1.
With the default setting "CoherenceFunction"None, the coherence value of every virtual point is set to 1, representing a fully spatially coherent light source.
The PointArrayObject expression returned by ResourceFunction["OpticalFieldModeling"] supports the following properties:
"PointPlot"a plot showing the locations of the real points and their corresponding virtual points
"PowerSpectrum"a PowerSpectrumObject based on the given wavelength and propagation distance
The "PowerSpectrum" property requires the arguments λ (wavelength) and z (propagation distance): PointArrayObject[]["PowerSpectrum",λ,z].
The "PointPlot" property of PointArrayObject accepts the same options as the NumberLinePlot (for 1D point arrays) or ListPlot (for 2D point arrays) functions.
The PowerSpectrumObject expression returned by the "PowerSpectrum" property of a PointArrayObject supports the following properties:
"Expression"complete power spectrum expression
"Plot"power spectrum 1D plot along the horizontal axis
"DensityPlot"power spectrum density plot
The "Plot" and "DensityPlot" properties accept arguments for angle (in degrees) and plotting step: PowerSpectrumObject[]["Plot",angle,step].
The angle specifies the maximum half-angle of the cone of light. If unspecified or set to Automatic, angle is taken by default to be 65°.
If unspecified or set to Automatic, step is calculated based on a fraction of the propagation distance of the PowerSpectrumObject.
The "Plot" and "DensityPlot" properties of PowerSpectrumObject accept the same options as the ListPlot and DensityPlot functions.

Examples

Basic Examples (3) 

Create a PointArrayObject with a set of real points:

In[1]:=
pointArray = ResourceFunction["OpticalFieldModeling"][N@CirclePoints[1, 4]]
Out[1]=

Calculate the power spectrum for a given wavelength and propagation distance:

In[2]:=
\[Lambda] = 0.632;
powerSpectrum = pointArray["PowerSpectrum", \[Lambda], 10 \[Lambda]]
Out[3]=

Plot the power spectrum using "DensityPlot":

In[4]:=
powerSpectrum["DensityPlot", 70, \[Lambda]/3]
Out[4]=

Scope (2) 

Plot the given 2D real points array with its corresponding virtual points:

In[5]:=
circularPointArray = ResourceFunction["OpticalFieldModeling"][N@CirclePoints[1, 10]];
circularPointArray["PointPlot"]
Out[2]=

Plot the given 1D real points array with its corresponding virtual points:

In[6]:=
circularPointArray = ResourceFunction["OpticalFieldModeling"][N@Range[-1, 1]];
circularPointArray["PointPlot"]
Out[4]=

Plot the 1D power spectrum with "Plot":

In[7]:=
\[Lambda] = 0.632;
pointArray1D = ResourceFunction["OpticalFieldModeling"][
   N@Range[-2 \[Lambda], 2 \[Lambda], 2 \[Lambda]]];
powerSpectrum1D = pointArray1D["PowerSpectrum", \[Lambda], 100 \[Lambda]];
powerSpectrum1D["Plot", 60, 1.6]
Out[4]=

Options (7) 

PhaseFunction (3) 

The phase function can be given as a symbol:

In[8]:=
phaseF[\[Xi]A_] := RandomReal[{0, 2 \[Pi]}];
ResourceFunction["OpticalFieldModeling"][Range[-3, 3], "PhaseFunction" -> phaseF]
Out[2]=

Or as a pure function:

In[9]:=
ResourceFunction["OpticalFieldModeling"][RandomReal[3, {5, 2}], "PhaseFunction" -> (#1^2 + 1.5 #2 &)]
Out[9]=

By default, uniform phase distribution is assumed:

In[10]:=
ResourceFunction["OpticalFieldModeling"][Range[-3, 3]]
Out[10]=

CoherenceFunction (4) 

Use PDF to utilize a statistical distribution function as the coherence function:

In[11]:=
\[Sigma] = 2;
ResourceFunction["OpticalFieldModeling"][Range[-3, 3], "CoherenceFunction" -> PDF@MaxwellDistribution[\[Sigma]]]
Out[2]=

The coherence function can be given as a symbol:

In[12]:=
\[Sigma] = 2;
coherenceF[\[Xi]D_] := N@Exp[-\[Xi]D^2/(2 \[Sigma]^2)];
ResourceFunction["OpticalFieldModeling"][Range[-3, 3], "CoherenceFunction" -> coherenceF]
Out[6]=

Os as a pure function:

In[13]:=
\[Sigma] = 2000;
ResourceFunction["OpticalFieldModeling"][
 QuantityArray[RandomReal[3, {5, 2}], "Millimeters"], "CoherenceFunction" -> (Exp[-((#1^2 + #2^2)/(2 \[Sigma]^2))] &)]
Out[2]=

By default, a fully coherent optical field is assumed:

In[14]:=
ResourceFunction["OpticalFieldModeling"][Range[-3, 3]]
Out[14]=

Applications (3) 

Simulate a vortex generation using a spiral phase mask:

In[15]:=
m = 5;
vortexPointArray = ResourceFunction["OpticalFieldModeling"][
  N@CirclePoints[2 \[Lambda], 15], "PhaseFunction" -> Function[{\[Xi]A, \[Eta]A}, Mod[m ArcTan[\[Xi]A, \[Eta]A] + \[Pi], 2 \[Pi]]]]
Out[2]=

Show the plot of real and virtual points superimposed over the phase mask:

In[16]:=
Show[DensityPlot[
  Mod[m ArcTan[x, y] + \[Pi], 2 \[Pi]], {x, -2.5 \[Lambda], 2.5 \[Lambda]}, {y, -2.5 \[Lambda], 2.5 \[Lambda]}], vortexPointArray["PointPlot"]]
Out[16]=

Plot the power spectrum:

In[17]:=
\[Lambda] = 0.632;
z = 10 \[Lambda];
vortexPowerSpectrum = vortexPointArray["PowerSpectrum", \[Lambda], z];
vortexPowerSpectrum["DensityPlot", 70, z/40]
Out[20]=

Simulate the interference pattern produced by a grating illuminated with partially coherent light:

In[21]:=
\[Sigma] = 4 \[Lambda]; gratingPointArray = ResourceFunction["OpticalFieldModeling"][
  Flatten[Table[{i, 0}, {i, -6 \[Lambda], 6 \[Lambda], 2 \[Lambda]}, {j, 1}], 1], "CoherenceFunction" -> Function[{\[Xi]D, \[Eta]D}, E^(-(\[Xi]D^2 + \[Eta]D^2)/(
    2 \[Sigma]^2))]]
Out[21]=

Plot the power spectrum:

In[22]:=
\[Lambda] = 0.632;
z - 10 \[Lambda];
gratingPowerSpectrum = gratingPointArray["PowerSpectrum", \[Lambda], z];
gratingPowerSpectrum["DensityPlot", 60, z/40]
Out[23]=

Reproduce a speckle pattern:

In[24]:=
phaseF[\[Xi]A_, \[Eta]A_] := RandomReal[{-\[Pi], \[Pi]}]; \[Lambda] = 0.632;
speckleArray = ResourceFunction["OpticalFieldModeling"][
   RandomPoint[Disk[{0, 0}, 20 \[Lambda]], 150], "PhaseFunction" -> phaseF];
specklePS = speckleArray["PowerSpectrum", \[Lambda], 1000 \[Lambda]];
specklePS["DensityPlot", 50, ColorFunction -> GrayLevel]
Out[17]=

Properties and Relations (3) 

Use QuantityArray to specify the units of the input real points list:

In[25]:=
ResourceFunction["OpticalFieldModeling"][
  QuantityArray[RandomReal[1, {20, 2}], "Millimeters"]]["PointPlot"]
Out[25]=

Use Quantity to specify the units of the wavelength and propagation distance:

In[26]:=
\[Lambda] = 520; z = 10 \[Lambda];
ResourceFunction["OpticalFieldModeling"][
 QuantityArray[RandomReal[1, {20, 2}], "Millimeters"], Quantity[\[Lambda], "Nanometers"], Quantity[z, "Micrometers"]]
Out[16]=

Use "Expression" to get the complete symbolic expression from a power spectrum object:

In[27]:=
\[Lambda] = 0.632;
pointArray = ResourceFunction["OpticalFieldModeling"][{{-1, -1}, {1, 1}}];
powerSpectrum = pointArray["PowerSpectrum", \[Lambda], 5 \[Lambda]];
powerSpectrum["Expression"]
Out[17]=

The expression can be supplied to any suitable visualization function:

In[28]:=
Plot3D[powerSpectrum["Expression"], {\[FormalX], -10 \[Lambda], 10 \[Lambda]}, {\[FormalY], -10 \[Lambda], 10 \[Lambda]}, PlotRange -> All, ColorFunction -> "Rainbow", PlotPoints -> 40]
Out[28]=

Possible Issues (1) 

The arguments supplied to the phase and coherence functions are given in micrometers, regardless of the units of the input point array, which can result in arithmetic errors:

In[29]:=
\[Sigma] = 20;
ResourceFunction["OpticalFieldModeling"][
 QuantityArray[RandomReal[3, {5, 2}], "Millimeters"], "CoherenceFunction" -> (Exp[-((#1^2 + #2^2)/(2 \[Sigma]^2))] &)]
Out[26]=

Publisher

Wolfram Summer School

Version History

  • 1.0.0 – 16 July 2020

Source Metadata

License Information