dtmm.tmm¶
4x4 and 2x2 transfer matrix method functions for 1D calculation.
The implementation is based on standard formulation of 4x4 transfer matrix method.
4x4 method¶
Layers are stacked in the z direction, field vectors describing the field are f = (Ex,Hy,Ey,Hx), Core functionality is defined by field matrix calculation functions:
Field vector creation/conversion functions¶
avec()for amplitude vector (eigenmode amplitudes).fvec()for field vector creation,avec2fvec()for amplitude to field conversion.fvec2avec()for field to amplitude conversion.
Field matrix functions¶
f_iso()for input and output field matrix caluclation.ffi_iso()computes the inverse of the field matrix.alphaf()for general field vectors and field coefficents calcualtion.alphaffi()computes the inverse of the field matrix.phase_mat()for phase matrix calculation.
Layer/stack computation¶
layer_mat()for layer matrix calculation Mi=Fi.Pi.Fi^-1stack_mat()for stack matrix caluclation M = M1.M2.M3….system_mat()for system matrix calculation Fin^-1.M.Fout
Transmission/reflection calculation¶
transmit4x4()to work with the computed system matrixtransfer4x4()ortransfer()for higher level interface
Intensity and Ez Hz field¶
poynting()the z component of the Poynting vector.intensity()the absolute value of the Poytning vector.EHz()for calculation of the z component of the E and H fields.
2x2 method¶
todo..
Module Contents¶
-
dtmm.tmm.alphaf(beta=None, phi=None, epsv=None, epsa=None, out=None)¶ Computes alpha and field arrays (eigen values and eigen vectors arrays).
Broadcasting rules apply.
- Parameters
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
out ((ndarray,ndarray), optional) – Output arrays.
- Returns
alpha, fieldmat – Eigen values and eigen vectors arrays.
- Return type
(ndarray, ndarray)
-
dtmm.tmm.alphaffi(beta=None, phi=None, epsv=None, epsa=None, out=None)¶ Computes alpha and field arrays (eigen values and eigen vectors arrays) and inverse of the field array. See also
alphaf()Broadcasting rules apply.
- Parameters
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
out ((ndarray,ndarray,ndarray), optional) – Output arrays.
- Returns
alpha, field, ifield – Eigen values and eigen vectors arrays and its inverse
- Return type
(ndarray, ndarray, ndarray)
Examples
This is equivalent to
>>> alpha,field = alphaf(0,0, [2,2,2], [0.,0.,0.]) >>> ifield = inv(field)
-
dtmm.tmm.phase_mat(alpha, kd, mode=None, out=None)¶ Computes a 4x4 or 2x2 diagonal matrix from eigenvalue matrix alpha and wavenumber.
The output is a diagonal, that is, a vector of length 2 or 4, depending on the input alpha array.
- Parameters
alpha (array) – The eigenvalue alpha array of shape (…,4) or (…,2).
kd (float) – The kd phase value (layer thickness times wavenumber in vacuum).
mode (int, optional) – If specified, converts the phase matrix to 2x2, taking either forward propagating mode (+1), or negative propagating mode (-1).
out (ndarray, optional) – Output array where results are written.
- Returns
diag – Phase diagonal matrix of shape (…,4) or (…,2).
- Return type
array
-
dtmm.tmm.poynting(fvec, out)¶ Calculates a z-component of the poynting vector from the field vector
- Parameters
fvec ((..,4,4) array) – Field matrix array.
out (ndarray, optional) – Output array where results are written.
Results –
------- –
poynting (array) – The z component of the poynting vector.
-
dtmm.tmm.intensity(fvec, out=None)¶ Calculates absolute value of the z-component of the poynting vector
- Parameters
fvec ((..,4) array) – Field vector array.
out (ndarray, optional) – Output array where results are written.
-
dtmm.tmm.EHz(fvec, beta=None, phi=None, epsv=None, epsa=None, out=None)¶ Constructs the z component of the electric and magnetic fields
- Parameters
fvec ((..,4,4) array) – Field matrix array.
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
out ((ndarray,ndarray), optional) – Output arrays where results are written.
- Returns
Ez,Hz – Ez and Hz arrays of shape (…,4)
- Return type
(ndarray,ndarray)
-
dtmm.tmm.f_iso(beta=0.0, phi=0.0, n=1.0)¶ Returns field matrix for isotropic layer of a given refractive index and beta, phi parameters
- Parameters
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
n (float) – Refractive index of the medium (1. by default).
-
dtmm.tmm.ffi_iso(beta=0.0, phi=0.0, n=1)¶ Returns field matrix and inverse of the field matrix for isotropic layer of a given refractive index and beta, phi parameters
- Parameters
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
n (float) – Refractive index of the medium (1. by default).
-
dtmm.tmm.layer_mat(kd, epsv, epsa, beta=0, phi=0, cfact=0.1, method='4x4', fmatin=None, retfmat=False, out=None)¶ Computes characteristic matrix of a single layer M=F.P.Fi,
Numpy broadcasting rules apply
- Parameters
kd (float) – The kd phase value (layer thickness times wavenumber in vacuum).
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
cfact (float, optional) – Coherence factor, only used in combination with 4x4_2 method.
method (str) – One of 4x4 (4x4 berreman - trasnmittance + reflectance), 2x2 (2x2 jones - transmittance only), 4x4_1 (4x4, single reflections - transmittance only), 2x2_1 (2x2, single reflections - transmittance only) 4x4_2 (4x4, partially coherent reflections - transmittance only)
fmatin (ndarray, optional) – Used in combination with 2x2_1 method. It specifies the field matrix of the input media in order to compute fresnel reflections. If not provided it reverts to 2x2 with no reflections.
out (ndarray, optional) –
- Returns
cmat – Characteristic matrix of the layer.
- Return type
ndarray
-
dtmm.tmm.stack_mat(kd, epsv, epsa, beta=0, phi=0, cfact=0.01, method='4x4', out=None)¶ Computes a stack characteristic matrix M = M_1.M_2….M_n if method is 4x4, 4x2(2x4) and a characteristic matrix M = M_n…M_2.M_1 if method is 2x2.
Note that this function calls
layer_mat(), so numpy broadcasting rules apply to kd[i], epsv[i], epsa[i], beta and phi.- Parameters
kd (array of floats) – A sequence of phase values (layer thickness times wavenumber in vacuum). len(kd) must match len(epsv) and len(epsa).
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
cfact (float) – Coherence factor, only used in combination with 4x4_r and 4x4_2 methods.
method (str) – One of 4x4 (4x4 berreman), 2x2 (2x2 jones), 4x4_1 (4x4, single reflections), 2x2_1 (2x2, single reflections) 4x4_r (4x4, incoherent to compute reflection) or 4x4_t (4x4, incoherent to compute transmission)
out (ndarray, optional) –
- Returns
cmat – Characteristic matrix of the stack.
- Return type
ndarray
-
dtmm.tmm.system_mat(cmat=None, fmatin=None, fmatout=None, fmatini=None, out=None)¶ Computes a system matrix from a characteristic matrix Fin-1.C.Fout
- Parameters
cmat ((..,4,4) array) – Characteristic matrix.
fmatin ((..,4,4) array) – Input field matrix array.
fmatout ((..,4,4) array) – Output field matrix array.
fmatini ((..,4,4) array) – Inverse of the input field matrix array.
out (ndarray, optional) – Output array where results are written.
-
dtmm.tmm.transmit4x4(fvec_in, cmat=None, fmatin=None, fmatout=None, fmatini=None, fmatouti=None, fvec_out=None)¶ Transmits field vector using 4x4 method.
This functions takes a field vector that describes the input field and computes the output transmited field and also updates the input field with the reflected waves.
- Parameters
fvec_in ((..,4) array) – Input field vector array. This function will update the input array with the calculated reflected field
cmat ((..,4,4) array) – Characteristic matrix.
fmatin ((..,4,4) array) – Input field matrix array.
fmatout ((..,4,4) array) – Output field matrix array.
fmatini ((..,4,4) array) – Inverse of the input field matrix array.
fmatouti ((..,4,4) array, optional) – Inverse of the output field matrix array. If not provided, it is computed from fmatout.
fvec_out ((..,4) array, optional) – The ouptut field vector array. This function will update the output array with the calculated transmitted field.
-
dtmm.tmm.transfer4x4(fvec_in, kd, epsv, epsa, beta=0.0, phi=0.0, nin=1.0, nout=1.0, method='4x4', reflect_in=False, reflect_out=False, fvec_out=None)¶ tranfers 4x4 field
- Parameters
fvec_in ((..,4) array) – Input field vector array. This function will update the input array with the calculated reflected field
kd (array of floats) – A sequence of phase values (layer thickness times wavenumber in vacuum). len(kd) must match len(epsv) and len(epsa).
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
nin (float) – Input layer refractive index.
nout (float) – Output layer refractive index.
method (str) – Any of 4x4, 4x4_1, 4x4_2, 4x4_r.
reflect_in (bool) – Defines how to treat reflections from the input media and the first layer. If specified it does an incoherent reflection from the first interface.
reflect_out (bool) – Defines how to treat reflections from the last layer and the output media. If specified it does an incoherent reflection from the last interface.
fvec_out ((..,4) array, optional) – The ouptut field vector array. This function will update the output array with the calculated transmitted field.
-
dtmm.tmm.transfer(fvec_in, kd, epsv, epsa, beta=0.0, phi=0.0, nin=1.0, nout=1.0, method='2x2', reflect_in=False, reflect_out=False, fvec_out=None)¶ Transfer input field vector through a layered material specified by the propagation constand k*d, eps tensor (epsv, epsa) and input and output isotropic media.
- Parameters
fvec_in ((..,4) array) – Input field vector array. This function will update the input array with the calculated reflected field
kd (array of floats) – A sequence of phase values (layer thickness times wavenumber in vacuum). len(kd) must match len(epsv) and len(epsa).
epsv ((..,3) array, optional) – Dielectric tensor eigenvalues array (defaults to unity).
epsa ((..,3) array, optional) – Euler rotation angles (psi, theta, phi) (defaults to (0.,0.,0.)).
beta (float, optional) – The beta parameter of the field (defaults to 0.)
phi (float, optional) – The phi parameter of the field (defaults to 0.)
nin (float) – Input layer refractive index.
nout (float) – Output layer refractive index.
method (str) – Any of 4x4, 2x2, 2x2_1 or 4x4_1, 4x4_2, 4x4_r
reflect_in (bool) – Defines how to treat reflections from the input media and the first layer. If specified it does an incoherent reflection from the first interface.
reflect_out (bool) – Defines how to treat reflections from the last layer and the output media. If specified it does an incoherent reflection from the last interface.
fvec_out ((..,4) array, optional) – The ouptut field vector array. This function will update the output array with the calculated transmitted field.
-
dtmm.tmm.avec(jones=(1, 0), amplitude=1.0, mode=+ 1, out=None)¶ Constructs amplitude vector.
Numpy broadcasting rules apply for jones, and amplitude parameters
- Parameters
jones (jonesvec) – A jones vector, describing the polarization state of the field.
amplitude (complex) – Amplitude of the field.
mode (int) – Either +1, for forward propagating mode, or -1 for negative propagating mode.
out (ndarray, optional) – Output array where results are written.
- Returns
avec – Amplitude vector of shape (4,).
- Return type
ndarray
Examples
X polarized light with amplitude = 1 >>> avec() array([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])
X polarized light with amplitude 1 and y polarized light with amplitude 2. >>> b = avec(jones = ((1,0),(0,1)),amplitude = (1,2)) >>> b[0] array([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]) >>> b[1] array([0.+0.j, 0.+0.j, 2.+0.j, 0.+0.j])
-
dtmm.tmm.fvec(fmat, jones=(1, 0), amplitude=1.0, mode=+ 1, out=None)¶ Build field vector form a given polarization state, amplitude and mode.
This function calls avec and then avec2fvec, see avec for details.
- Parameters
fmat ((..,4,4) array) – Field matrix array.
jones (jonesvec) – A jones vector, describing the polarization state of the field.
amplitude (complex) – Amplitude of the field.
mode (int) – Either +1, for forward propagating mode, or -1 for negative propagating mode.
out (ndarray, optional) – Output array where results are written.
- Returns
fvec – Field vector of shape (…,4).
- Return type
ndarray
Examples
X polarized light traveling at beta = 0.4 and phi = 0.2 in medium with n = 1.5
>>> fmat = f_iso(beta = 0.4, phi = 0.2, n = 1.5) >>> m = fvec(fmat, jones = jonesvec((1,0), phi = 0.2))
This is equivalent to
>>> a = avec(jones = jonesvec((1,0), phi = 0.2)) >>> ma = avec2fvec(a,fmat) >>> np.allclose(ma,m) True
-
dtmm.tmm.fvec2avec(fvec, fmat, normalize_fmat=True, out=None)¶ Converts field vector to amplitude vector
- Parameters
fvec (ndarray) – Input field vector
fmat (ndarray) – Field matrix
normalize_fmat (bool, optional) – Setting this to false will not normalize the field matrix. In this case user has to make sure that the normalization of the field matrix has been performed prior to calling this function by calling normalize_f.
out (ndarray, optional) – Output array
- Returns
avec – Amplitude vector
- Return type
ndarray
-
dtmm.tmm.avec2fvec(avec, fmat, normalize_fmat=True, out=None)¶ Converts amplitude vector to field vector
- Parameters
avec (ndarray) – Input amplitude vector
fmat (ndarray) – Field matrix
normalize_fmat (bool, optional) – Setting this to false will not normalize the field matrix. In this case user has to make sure that the normalization of the field matrix has been performed prior to calling this function by calling normalize_f.
out (ndarray, optional) – Output array
- Returns
fvec – Field vector.
- Return type
ndarray