5. Example of light sources

5.1. Creating an instance

An instance must be created before starting to operate with light sources. The initialization accepts several arguments.

[1]:
%matplotlib inline
[2]:
from diffractio import degrees, mm, np, um
from diffractio.scalar_masks_XY import Scalar_mask_XY
from diffractio.scalar_sources_XY import Scalar_source_XY
from diffractio.vector_paraxial_masks_XY import Vector_paraxial_mask_XY
from diffractio.vector_paraxial_sources_XY import Vector_paraxial_source_XY
number of processors: 8
[3]:
from matplotlib import rcParams
rcParams['figure.figsize']=[8,6]
rcParams['figure.dpi']=125

5.2. Procedures to convert a scalar source into a vector source

When a light source is defined using Scalar_source_XY, it can be converted to vectorial using several functions with vector characteristics of the source:

  • constant_wave
  • azimuthal_wave
  • radial_wave
  • radial_inverse_wave
  • azimuthal_inverse_wave
  • local_polarized_vector_wave
  • local_polarized_vector_wave_radial
  • local_polarized_vector_wave_hybrid
  • spiral_polarized_beam

When the field u in the function is a float number, then it is considered as the amplitude of the wave. Also this functions are masked, with a circular mask, radius=(\(r_x\), \(r_y\)), when \(r_x\) and \(r_y\) >0.

When the parameter results u=1, then the intensity distribution is 1 in both \(E_x\) and \(E_y\) fields.

5.2.1. constant polarization wave

[4]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.constant_wave(u=1,v=(1,1.j), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_7_0.png

5.2.2. radial wave

[5]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.azimuthal_wave(u=1, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_9_0.png

5.2.3. transversal wave

[6]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.radial_wave(u=1, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_11_0.png

5.2.4. radial inverse wave

[7]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.radial_inverse_wave(u=1, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_13_0.png

5.2.5. transversal inverse wave

[8]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.azimuthal_inverse_wave(u=1, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_15_0.png

5.2.6. local polarized vector wave

[9]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave(u=1,m=2, fi0=np.pi/2, r0=(0,0), radius=250*um)
EM.draw('stokes');

../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_17_0.png

5.2.7. local polarized vector radial beam

[10]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave_radial(u=1,m=2, fi0=np.pi/2, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_19_0.png

5.2.8. local polarized vector hybrid beam

[11]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.local_polarized_vector_wave_hybrid(u=1,n=2, m=2, fi0=np.pi/2, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_21_0.png

5.2.9. spiral polarized beam

[12]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.spiral_polarized_beam(u=1,r0=(0,0), alpha=np.pi/5, radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_23_0.png
[13]:
EM.__draw_ellipses__(
    logarithm=False,
    normalize=False,
    cut_value=None,
    num_ellipses=(30, 30),
    amplification=0.5,
    color_line='r',
    line_width=1,
    draw_arrow=True,
    head_width=5,
    ax=False)
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_24_0.png

5.3. Generation of a structured beam with polarization

The same functions used previously, can be used to generate vector fields with spatial intensity distribution. In this case, the u parameter is a Scalar_source_XY.

Here, let us see the Gauss beam example.

[14]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

u0 = Scalar_source_XY(x0, y0, wavelength)
u0.gauss_beam(
    r0=(0, 0),
    w0=(150 * um, 150 * um),
    z0=0 * um,
    A=1,
    theta=0. * degrees,
    phi=0 * degrees)
[15]:
EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.azimuthal_wave(u=u0, r0=(0,0), radius=250*um)
EM.draw('stokes');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_27_0.png
[16]:
EM.draw('ellipses', num_ellipses=(35,35))
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_28_0.png

5.4. Vector wave from a scalar source

All these methods to provide vector polarization to a constant wave, can be used for any other scalar source. Then we include in the \(u\) parameters the scalar field:

[17]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

u0 = Scalar_source_XY(x0, y0, wavelength)
u0.plane_wave(A=1, theta=90 * degrees, phi=1 * degrees)
[18]:
EM=Vector_paraxial_source_XY(x0,y0,wavelength)
EM.azimuthal_wave(u=u0, r0=(0,0), radius=(200,200))
EM.__draw_ellipses__(
    logarithm=False,
    normalize=False,
    cut_value=None,
    num_ellipses=(20,20),
    amplification=0.5,
    color_line='r',
    line_width=1,
    draw_arrow=True,
    head_width=5)
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_31_0.png

This can also been done, for example to a Gauss beam:

[19]:
x0 = np.linspace(-250 * um, 250 * um, 512)
y0 = np.linspace(-250 * um, 250 * um, 512)

wavelength = 0.6328 * um

u0 = Scalar_source_XY(x0, y0, wavelength)
u0.vortex_beam(A=1,r0=(0,0), w0=100*um,m=3)
[20]:
EM=Vector_paraxial_source_XY(x0,y0,wavelength)
EM.azimuthal_wave(u0, r0=(0,0))
EM.__draw_ellipses__(
    logarithm=False,
    normalize=False,
    cut_value=None,
    num_ellipses=(30,30),
    amplification=0.5,
    color_line='r',
    line_width=1,
    draw_arrow=True,
    head_width=5)
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_34_0.png

5.5. Gauss Polarization

Since Gauss beams are very used, we have defined the main polarization classes for these beams

[25]:

x0 = np.linspace(-200*um, 200*um, 512)
y0 = np.linspace(-200*um, 200*um, 512)
wavelength = 0.6328 * um

u1 = Scalar_source_XY(x=x0, y=y0, wavelength=wavelength)
u1.gauss_beam(
    A=1,
    r0=(0 * um, 0 * um),
    w0=(100 * um, 100 * um),
    z0=0 * um,
    theta=0. * degrees,
    phi=0 * degrees)



EM = Vector_paraxial_source_XY(x0, y0, wavelength)
EM.constant_wave(u1,v=(1,1j))
EM.__draw_ellipses__(
    logarithm=False,
    normalize=False,
    cut_value=None,
    num_ellipses=(21, 21),
    amplification=0.75,
    color_line='w',
    line_width=.75,
    draw_arrow=True,
    head_width=3)
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_36_0.png

5.6. interferences

Vector fields also interfere. We can sum two vector beams using \(E_M = E_{M1} + E_{M2}\)

[22]:
length = 100 * um
num_data = 512
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328

u1=Scalar_source_XY(x0,y0,wavelength)
u1.plane_wave(A=1, theta=90*degrees, phi=5*degrees)

u2=Scalar_source_XY(x0,y0,wavelength)
u2.plane_wave(A=1, theta=90*degrees, phi=-5*degrees)

EM1 = Vector_paraxial_source_XY(x0, y0, wavelength)
EM1.constant_wave(u=u1, v=[1, 0])

EM2 = Vector_paraxial_source_XY(x0, y0, wavelength)
EM2.constant_wave(u=u2, v=[1, 0])

EM = EM1 + EM2
EM.draw(kind='intensity');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_38_0.png

Obviously, when the two beams are ortogonal, no interference is produced:

[23]:
length = 100 * um
num_data = 512
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328

u1=Scalar_source_XY(x0,y0,wavelength)
u1.plane_wave(A=1, theta=90*degrees, phi=5*degrees)

u2=Scalar_source_XY(x0,y0,wavelength)
u2.plane_wave(A=1, theta=90*degrees, phi=-5*degrees)

EM1 = Vector_paraxial_source_XY(x0, y0, wavelength)
EM1.constant_wave(u=u1, v=[1, 1j])

EM2 = Vector_paraxial_source_XY(x0, y0, wavelength)
EM2.constant_wave(u=u2, v=[1, -1j])

EM = EM1 + EM2
EM.draw(kind='intensity');
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_40_0.png

5.6.1. Partial polarization can also be possible.

[24]:
length = 100 * um
num_data = 512
x0 = np.linspace(-length / 2, length / 2, num_data)
y0 = np.linspace(-length / 2, length / 2, num_data)
wavelength = 0.6328

u1=Scalar_source_XY(x0,y0,wavelength)
u1.plane_wave(A=1, theta=90*degrees, phi=5*degrees)

u2=Scalar_source_XY(x0,y0,wavelength)
u2.plane_wave(A=1, theta=90*degrees, phi=-5*degrees)

EM1 = Vector_paraxial_source_XY(x0, y0, wavelength)
EM1.constant_wave(u=u1, v=[1, 0])

EM2 = Vector_paraxial_source_XY(x0, y0, wavelength)
EM2.constant_wave(u=u2, v=[0.05, .75])

EM = EM1 + EM2
EM.draw(kind='intensity');

intensity = EM.get(kind='intensity')
../../../_images/source_tutorial_vector_paraxial_XY_tutorial_vector_paraxial_sources_XY_42_0.png