(NLAYERS, HEIGHT, WIDTH), radius=20, pitch=7, no=1.5, ne=1.65, nhost=1.5) #approx 50*7*1.5 nm bragg reflection #: create right-handed polarized input light beta = 0.3 #make it off-axis #window = dtmm.aperture((HEIGHT, WIDTH),0.9,0.) window = None #jones = dtmm.jonesvec((1,1j)) jones = None focus = 20 #this will focus field diaphragm in the middle of the stack field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, jones=jones, beta=beta, pixelsize=PIXELSIZE, n=1.5, focus=focus, window=window) #: transfer input light through stackt field_data_out = dtmm.transfer_field(field_data_in, optical_data, beta=beta, phi=0, diffraction=1, method="4x4", smooth=0.1, reflection=2, nin=1.5, nout=1.5,
NLAYERS, HEIGHT, WIDTH = 60, 96, 96 #: illumination wavelengths in nm WAVELENGTHS = np.linspace(380, 780, 9) #: create some experimental data (stack) optical_data = [ dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius=30, profile="r", no=1.5, ne=1.6, nhost=1.5) ] #: create non-polarized input light field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize=PIXELSIZE) #: transfer input light through stack field_data_out = dtmm.transfer_field(field_data_in, optical_data, diffraction=0, betamax=1) #: visualize output field # no diffraction to simulate output of standard jones method viewer1 = dtmm.field_viewer(field_data_out, diffraction=False) viewer1.set_parameters(sample=0, intensity=2, polarizer=0, analyzer=90) fig, ax = viewer1.plot() ax.set_title("diffraction = 0") field_data_out = dtmm.transfer_field(field_data_in,
optical_data = dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius=30, profile="r", no=1.5, ne=1.6, nhost=1.5) #optical_data[0][...]=1 #optical_data[1][0,...]=1 #optical_data[1][-1,...]=1 window = dtmm.aperture((96, 96), 0.95, 0.) window = None #: create non-polarized input light field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, beta=0., pixelsize=PIXELSIZE, window=window) f, w, p = dtmm.transfer_field(field_data_in, optical_data, beta=0., phi=0., betamax=0.8, method="4x4", ret_bulk=True, npass=4, reflection=2, smooth=0.1) #must be even for 4x4 method viewer_bulk = dtmm.field_viewer((f, w, p), bulk_data=True)
"""EM field example""" import dtmm import numpy as np import matplotlib.pyplot as plt WAVELENGTHS = [500, 600] SIZE = (128, 128) window = dtmm.aperture((128, 128)) field_data = dtmm.illumination_data(SIZE, WAVELENGTHS, window=window, jones=(1, 0), pixelsize=200, beta=(0, 0.1, 0.2), phi=(0., 0., np.pi / 6)) field = field_data[0] #500nm Ex = field[:, 0, 0] #Ex of the x-polarized light subplots1 = [plt.subplot(i) for i in (231, 232, 233)] subplots2 = [plt.subplot(i) for i in (234, 235, 236)] for i, ax in enumerate(subplots1): ax.imshow(Ex[i].real, origin="lower")
d = np.ones(shape=(NLAYERS, )) epsv = np.empty(shape=(NLAYERS, HEIGHT, 3), dtype=dtmm.conf.CDTYPE) epsv[..., 0] = no**2 epsv[..., 1] = no**2 epsv[..., 2] = ne**2 beta, phi, intensity = 0, 0, 1 #we use 3D non-polarized data and convert it to 2D field_data_in = dtmm.illumination_data((HEIGHT, 1), WAVELENGTHS, jones=None, beta=beta, phi=phi, intensity=intensity, pixelsize=PIXELSIZE, n=nin, betamax=0.8) field_data_in2d = field_data_in[0][..., 0], field_data_in[1], field_data_in[2] optical_data2d = [(d, epsv, epsa)] f, w, p = field_data_in2d shape = f.shape[-1] k0 = wave.k0(w, p) mask, fmode_in = field.field2modes1(f, k0)
radius=30, profile="r", no=1.5, ne=1.6, nhost=1.5) #NA 0.25, diaphragm with diameter 4 pixels, around 2*2*pi rays beta, phi, intensity = dtmm.illumination_rays(0.25, 4) window = dtmm.aperture((HEIGHT, WIDTH), 1, 0.1) field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, PIXELSIZE, beta, phi, intensity, window=window, n=1.5, focus=30) field_data_out = dtmm.transfer_field(field_data_in, optical_data, multiray=True, nin=1.5, nout=1.5) viewer = dtmm.field_viewer(field_data_out, sample=0, intensity=2, n=1.5,
radius=30, profile="r", no=1.5, ne=1.6, nhost=1.5) ] #using annular aperture, approximate ratio of aperture dimaters is inner/outer = 6/7 #: max NA is set to 0.7., this means input rays from NA of 0.6 to 0.7 beta, phi, intensity = dtmm.illumination_rays(0.7, (6, 7)) #: care must be taken when using high NA light source, we must usee a high betamax parameter field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, PIXELSIZE, beta, phi, intensity, focus=30, betamax=1) #: also in the calculation, we must perform it at high betamax field_data_out = dtmm.transfer_field(field_data_in, optical_data, multiray=True, betamax=1) # we must set the numarical aperture of the objective lower than the minimum NA of the illumination. viewer = dtmm.pom_viewer(field_data_out, intensity=10, NA=0.5, focus=-20,
r = _r(shape).flatten() #radial coordinate for fitting def gauss(r, w, a): return a * np.exp(-2 * (r / w)**2) def beam_waist(z, w0, k): z0 = w0**2 * k / 2. return w0 * (1 + (z / z0)**2)**0.5 window = dtmm.window.gaussian_beam(shape, w0, dtmm.k0(600, 50), n=n, z=0) field, w, p = dtmm.illumination_data(shape, [w], pixelsize=50, n=n, window=window, jones=(1, 0)) ks = dtmm.k0(w, p) epsv = dtmm.refind2eps([n] * 3) power = dtmm.field2intensity(field) plt.subplot(121) plt.imshow(power[0]) plt.title("z=0") waist = [] z = np.linspace(-512, 512, 13) for d in z:
import numpy as np dtmm.conf.set_verbose(2) #: pixel size in nm PIXELSIZE = 200 #: compute box dimensions NLAYERS, HEIGHT, WIDTH = 60,96,96 #: illumination wavelengths in nm WAVELENGTHS = np.linspace(380,780,9) #: create some experimental data (stack) d, epsv, epsa = dtmm.nematic_droplet_data((NLAYERS, HEIGHT, WIDTH), radius = 30, profile = "x", no = 1.5, ne = 1.6, nhost = 1.5) #: create non-polarized input light f,w,p = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, pixelsize = PIXELSIZE, beta = 0., phi = 0.) field_data_in = f,w,p #transpose to field vector ft = dtmm.field.field2fvec(f) # build kd phase values kd = [x*(dtmm.k0(WAVELENGTHS, PIXELSIZE))[...,None,None] for x in d] #build stack matrix and transmit... cmat = dtmm.tmm.stack_mat(kd, epsv, epsa, method = "2x2") #convert field vector to E vector (assuming vacuum) Ein_2x2 = dtmm.tmm.fvec2E(ft) Eout_2x2 = dtmm.linalg.dotmv(cmat,Ein_2x2) #convert E vector to field vector (assuming vacuum)
NLAYERS, HEIGHT, WIDTH = 1,96,96 #: illumination wavelengths in nm WAVELENGTHS = np.linspace(400,700,9) #: some experimental data BETA = 0.4 epsv = dtmm.refind2eps([4,4,4]) #high reflective index medium, to increase reflections. epsa = (0.,0.,0.) optical_data = [(THICKNESS, epsv, epsa)] window = dtmm.aperture((HEIGHT, WIDTH),0.2,1) #illumination data is focused at the top (exit) surface (actual focus = focus * ref_ind = 25*4=100) field_data_in = dtmm.illumination_data((HEIGHT, WIDTH), WAVELENGTHS, window = window, beta = BETA, pixelsize = PIXELSIZE,focus = 25.,n=1) #illumination filed is defined in vacuum, so we make input and output medium with n = 1. field_data_out = dtmm.transfer_field(field_data_in, optical_data, beta = BETA, phi = 0., reflection = 2, diffraction =1, npass = 3, method = "2x2",nin = 1, nout = 1) #we are viewing computed data in vacuum, so set n = 1. viewer4 = dtmm.field_viewer(field_data_in, mode = "t", intensity = 1,n = 1.) fig4,ax4 = viewer4.plot() ax4.set_title("Input field") #: visualize output field viewer1 = dtmm.field_viewer(field_data_out, mode = "t",intensity = 1,n = 1.) fig1,ax1 = viewer1.plot() ax1.set_title("Transmitted field")