2. Reflection and refraction

2.1. Refection and refraction at a surface

[1]:
from diffractio import degrees, mm, plt, sp, um, np
from diffractio.scalar_masks_X import Scalar_mask_X
from diffractio.scalar_masks_XZ import Scalar_mask_XZ
from diffractio.scalar_sources_X import Scalar_source_X
number of processors: 8
[2]:
%matplotlib inline

from matplotlib import rcParams
rcParams['figure.figsize']=(7,5)
rcParams['figure.dpi']=125
[3]:
x0 = np.linspace(-100 * um, 100 * um, 2048)
z0 = np.linspace(-100 * um, 100 * um, 2048)

wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1, x0=0 * um, z0=100 * um, w0=15 * um, theta=0 * degrees)

u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1)
u1.incident_field(u0)
u1.semi_plane(r0=(0, 0), refraction_index=1.5, angle=60 * degrees)

u1.draw_refraction_index()

[3]:
<matplotlib.image.AxesImage at 0x7fb5c7e702b0>
../../../_images/source_examples_optics_reflection_refraction_4_1.png
[4]:
u1.WPM(verbose=False)
[5]:
u1.draw(kind='phase', draw_borders=True);
../../../_images/source_examples_optics_reflection_refraction_6_0.png
[6]:
u1.draw(kind='intensity', logarithm=True, draw_borders=True);
../../../_images/source_examples_optics_reflection_refraction_7_0.png

2.2. Refraction

[7]:
x0 = np.linspace(-110 * um, 110 * um, 2048)
z0 = np.linspace(-110 * um, 110 * um, 2048)
wavelength = 1 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1, x0=25 * um, z0=150 * um, w0=40 * um, theta=0 * degrees)

u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.layer(r0=(50, 0), depth=80 * um, refraction_index=2, angle=45 * degrees)

u1.draw_refraction_index()

[7]:
<matplotlib.image.AxesImage at 0x7fb5d0459880>
../../../_images/source_examples_optics_reflection_refraction_9_1.png
[8]:
u1.WPM(verbose=False)
u1.draw(kind='intensity', draw_borders=True);
../../../_images/source_examples_optics_reflection_refraction_10_0.png
[19]:
%matplotlib widget

u1.draw_profiles_interactive(
    kind='intensity', logarithm=False, normalize=False);

2.3. Total refraction

[10]:
%matplotlib inline
rcParams['figure.figsize']=(7,5)
rcParams['figure.dpi']=125
[11]:
x0 = np.linspace(-100 * um, 100 * um, 2048)
z0 = np.linspace(-100 * um, 100 * um, 2048)

wavelength = 5 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(A=1, x0=0 * um, z0=100 * um, w0=15 * um, theta=0 * degrees)

u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength, n_background=1.5)
u1.incident_field(u0)
u1.semi_plane(r0=(0, 0), refraction_index=1, angle=60 * degrees)

u1.draw_refraction_index()
[11]:
<matplotlib.image.AxesImage at 0x7fb5d5eaa280>
../../../_images/source_examples_optics_reflection_refraction_14_1.png
[12]:
u1.WPM(verbose=False)
[13]:
u1.draw(kind='phase', draw_borders=True)
plt.ylim(ymin=-60)
plt.xlim(xmax=75);
../../../_images/source_examples_optics_reflection_refraction_16_0.png
[14]:
u1.draw(kind='intensity', logarithm=True, draw_borders=True);
plt.xlim(-50, 50)
plt.ylim(-30, 30)
[14]:
(-30.0, 30.0)
../../../_images/source_examples_optics_reflection_refraction_17_1.png

2.4. Total refraction at a layer

[15]:
x0 = np.linspace(-150 * um, 300 * um, 2048)
z0 = np.linspace(-150 * um, 500 * um, 2048)
wavelength = 1 * um
u0 = Scalar_source_X(x=x0, wavelength=wavelength)
u0.gauss_beam(
    A=1, x0=-100 * um, z0=150 * um, w0=15 * um, theta=0 * degrees)

u1 = Scalar_mask_XZ(x=x0, z=z0, wavelength=wavelength)
u1.incident_field(u0)
u1.layer(
    r0=(50, 0), depth=100 * um, refraction_index=1.5, angle=60 * degrees)
u1.draw_refraction_index()
u1.filter_refraction_index(type_filter=2, pixels_filtering=3);
../../../_images/source_examples_optics_reflection_refraction_19_0.png
[16]:
u1.BPM(verbose=False)
u1.draw(kind='intensity', logarithm=True, draw_borders=True);
../../../_images/source_examples_optics_reflection_refraction_20_0.png
[17]:
u1.draw(kind='intensity', logarithm=True, draw_borders=True)
plt.xlim(-100, 0)
plt.ylim(-125, -65);
../../../_images/source_examples_optics_reflection_refraction_21_0.png
[18]:
%matplotlib widget
u1.draw_profiles_interactive(
    kind='intensity', logarithm=False, normalize=False);
../../../_images/source_examples_optics_reflection_refraction_22_1.png