1.7. Example of light sources

1.7.1. Creating an instance

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

[1]:
from diffractio import degrees, mm, np, plt, um
from diffractio.scalar_sources_X import Scalar_source_X
number of processors: 8
[2]:
# size of figures
import matplotlib
matplotlib.rcParams['figure.dpi']=125

1.7.2. Plane wave

[3]:
x0 = np.linspace(-1000 * um, 1000 * um, 512)
wavelength = 0.6328 * um

u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_wave(theta=1 * degrees, z0=0 * um)
u0.draw(kind='field')
../../../_images/source_tutorial_scalar_X_sources_x_5_0.png

1.7.3. Gauss beam

[4]:
x0 = np.linspace(-500 * um, 500 * um, 2048)
wavelength = .5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(
    A=1, x0=0 * um, z0=-2000 * um, w0=25 * um, theta=0 * degrees)

u0.draw(kind='field')
../../../_images/source_tutorial_scalar_X_sources_x_7_0.png

1.7.4. Spherical wave

Convergent

[5]:
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um

u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.spherical_wave(
    A=1, x0=0 * um, z0=5 * mm, radius=200 * um, mask=True)
u0.draw(kind='phase')
../../../_images/source_tutorial_scalar_X_sources_x_10_0.png

Divergent

[6]:
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um

u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.spherical_wave(
    A=1, x0=0 * um, z0=-5 * mm, radius=200 * um, mask=True)
u0.draw(kind='phase')
../../../_images/source_tutorial_scalar_X_sources_x_12_0.png

1.7.5. Several plane waves with different inclination

[7]:
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um

u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.plane_waves_several_inclined(
    A=1, num_beams=5, max_angle=5 * degrees)
u0.draw(kind='field')
../../../_images/source_tutorial_scalar_X_sources_x_14_0.png

1.7.6. Several gauss beams with different position

[8]:
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um

u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beams_several_parallel(
    A=1,
    num_beams=5,
    w0=50 * um,
    z0=0 * um,
    x_central=0 * um,
    x_range=750 * um,
    theta=0 * degrees)
u0.draw(kind='amplitude')
../../../_images/source_tutorial_scalar_X_sources_x_16_0.png

1.7.7. Several Gauss beam with different inclination

[9]:
x0 = np.linspace(-500 * um, 500 * um, 1024)
wavelength = 0.6328 * um

u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beams_several_inclined(
    A=1,
    num_beams=5,
    w0=250 * um,
    x0=0 * um,
    z0=0 * um,
    max_angle=5 * degrees)
u0.draw(kind='amplitude')
../../../_images/source_tutorial_scalar_X_sources_x_18_0.png

1.7.8. Sum of two gauss beams with different inclination: interference

[10]:
length = 2 * mm
x0 = np.linspace(-length / 2, length / 2, 1024)
wavelength0 = 0.6238 * um

u1 = Scalar_source_X(x=x0, wavelength=wavelength0)
u2 = Scalar_source_X(x=x0, wavelength=wavelength0)

u1.gauss_beam(
    A=1, x0=0 * um, z0=0 * um, w0=500 * um, theta=.25 * degrees)
u2.gauss_beam(
    A=1, x0=0 * um, z0=0 * um, w0=500 * um, theta=-.25 * degrees)

u0 = u1 + u2
u0.draw(kind='intensity')
../../../_images/source_tutorial_scalar_X_sources_x_20_0.png