API Reference
This page provides a detailed list of all functions and types exported by AttenuatedTotalReflectance.jl.
Index
AttenuatedTotalReflectance.layerAttenuatedTotalReflectance.angular_ATRAttenuatedTotalReflectance.complex_nAttenuatedTotalReflectance.compute_transfer_coefficientsAttenuatedTotalReflectance.epsilon_to_nkAttenuatedTotalReflectance.material_stackAttenuatedTotalReflectance.nk_to_epsilonAttenuatedTotalReflectance.refl_coeff_PAttenuatedTotalReflectance.refl_coeff_SAttenuatedTotalReflectance.snells_lawAttenuatedTotalReflectance.target_layerAttenuatedTotalReflectance.trans_coeff_PAttenuatedTotalReflectance.trans_coeff_SAttenuatedTotalReflectance.wavelength_ATR
Core Simulation
These are the high-level functions used to generate reflectivity and field enhancement data.
AttenuatedTotalReflectance.compute_transfer_coefficients — Function
computetransfercoefficients(stack, theta, wavelength, layer_j=0; S=false)
Calculate the optical transfer matrices and transmission coefficients for a multilayer thin-film stack using the Transfer Matrix Method (TMM).
Arguments
stack::Vector: A vector of layer objects. Each element must have fields.n(refractive index),.k(extinction coefficient), and.thickness. Seematerial_stackfunction in utils.jltheta::Number: Incident angle in radians.wavelength::Number: Wavelength of the incident light (units must matchstack[i].thickness).layer_j::Int: (Optional) The index of a specific layer of intrest. If provided, the function calculates partial matrices and coefficients split at this layer.S::Bool: (Keyword) Iftrue, computes coefficients for S-polarization (TE). Iffalse(default), computes for P-polarization (TM).
Returns
A Tuple containing:
C::SMatrix{2,2,ComplexF64}: The total system transfer matrix.D0::SMatrix{2,2,ComplexF64}: The partial transfer matrix from the ambient tolayer_j.Dj::SMatrix{2,2,ComplexF64}: The partial transfer matrix fromlayer_jto the substrate.t_total::ComplexF64: The total Fresnel transmission coefficient for the entire stack.t0::ComplexF64: Partial transmission coefficient from ambient tolayer_j.tj::ComplexF64: Partial transmission coefficient fromlayer_jto substrate.
Mathematical Note
The transfer matrix $ M$ for an interface and subsequent layer propagation is defined such that: $ egin{pmatrix} E{i-1}^+ \ E{i-1}^- nd{pmatrix} = Mi egin{pmatrix} E{i}^+ \ E_{i}^- nd{pmatrix}$ where $ E^+$ and $ E^-$ represent the forward and backward traveling electric field components.
This algorithm is based on the work by Koji Ohta and Hatsuo Ishida (DOI: 10.1364/ao.29.001952)
This method also assumes that the system is not magnetic
AttenuatedTotalReflectance.angular_ATR — Function
angular_ATR(stack, theta_range, wavelength, d=0.0, metal_layer=0; S=false)Perform an angle dependant Attenuated Total Reflection (ATR) simulation, calculating reflectivity, transmittance, and the electric field enhancement at a specific location for each angle.
Arguments
stack::Vector: A vector of layer objects. Each must contain.n,.k, and.thickness. Seematerial_stacktheta_range::AbstractVector: A range or vector of incident angles in radians.wavelength::Number: The vacuum wavelength of the incident light in meters.d::Number: The distance from the interface of thetarget_layer(in the same units aswavelength) at which to compute the electric field.metal_layer::Int: An index used byTarget_Layerto identify the specific layer of interest (e.g., the gold layer in a Kretschmann configuration).S::Bool: Iftrue, calculates for S-polarization (TE). Iffalse(default), calculates for P-polarization (TM).
Returns
A Tuple containing eight vectors (each of length length(theta_range)):
reflectivity: Intensity reflection coefficient (R).transmittance: Intensity transmission coefficient (T) into the final medium.f_x: Normalized field intensity component $|E_x/E_0|^2$.f_y: Normalized field intensity component $|E_y/E_0|^2$.f_z: Normalized field intensity component $|E_z/E_0|^2$.f_p: Total normalized field intensity enhancement $|E_{total}/E_0|^2$.
Physics Note
Field enhancement is calculated as the ratio of the local field intensity to the incident field intensity.
- For P-polarization, the field exists in the plane of incidence: $E_{total} = \sqrt{|E_x|^2 + |E_z|^2}$.
- For S-polarization, the field is perpendicular to the plane of incidence: $E_{total} = |E_y|$.
AttenuatedTotalReflectance.wavelength_ATR — Function
wavelength_ATR(stack, theta, wavelength_range, d=0.0, metal_layer=0; S=false)Perform a wavelength dependant Attenuated Total Reflection (ATR) simulation, calculating reflectivity, transmittance, and the electric field enhancement at a specific location for a fixed angle.
Arguments
stack::Vector: A vector of layer objects. Each must contain.n,.k, and.thickness. Seematerial_stacktheta::Number: A range or vector of incident angles in radians.wavelength_range::AbstractVector: The vacuum wavelength of the incident light.d::Number: The distance from the interface of thetarget_layer(in the same units aswavelength) at which to compute the electric field.metal_layer::Int: An index used byTarget_Layerto identify the specific layer of interest (e.g., the gold layer in a Kretschmann configuration). Used for plasmonic systemsS::Bool: Iftrue, calculates for S-polarization (TE). Iffalse(default), calculates for P-polarization (TM).
Returns
A Tuple containing eight vectors (each of length length(theta_range)):
reflectivity: Intensity reflection coefficient (R).transmittance: Intensity transmission coefficient (T) into the final medium.f_x: Normalized field intensity component $|E_x/E_0|^2$.f_y: Normalized field intensity component $|E_y/E_0|^2$.f_z: Normalized field intensity component $|E_z/E_0|^2$.f_p: Total normalized field intensity enhancement $|E_{total}/E_0|^2$.
Physics Note
Field enhancement is calculated as the ratio of the local field intensity to the incident field intensity.
- For P-polarization, the field exists in the plane of incidence: $E_{total} = \sqrt{|E_x|^2 + |E_z|^2}$.
- For S-polarization, the field is perpendicular to the plane of incidence: $E_{total} = |E_y|$.
Simulation Configuration
Use these to define your material layers and the geometry of your simulation.
AttenuatedTotalReflectance.layer — Type
Struct object used to hold information on each layer in the overall system to be simulated
Arguments:
- `material::String`: Name of the current layer
- `n::Float64`: Refractive index of the current layer
- `k::Float64`: Extinction coefficient of the current layer
- `thickness::Float64`: Thickness of the current layer in meters [m]. Must be positive.Example:
```julia-repl
julia> thin_film = layer("Silver", 0.051585, 3.9046, 20e-9)
julia> thin_film.n
0.051585
julia> thin_film.thickness
20e-9
```AttenuatedTotalReflectance.material_stack — Function
Helper function to assemble an array of layer objects to hold information on the material layers of the system to be simulated with the addition of perfectly matched layer.
Arguments:
- `materials::Vector{<:NamedTuple}`: A vector containing information on the materials to use. (Name, n, k, thickness [m])Return:
- `stack`: Array of layer objects of length number_layers+1Mathematical Note:
Perfectly matched layer is required to absorb reflections from the last layer of the system. Both the PML must be larger than the thin films simulated to avoid oscillations in the output of the fresnel calculations
Example:
```julia-repl
julia> mats = [
(material="Glass", n=1.5, k=0.0, thickness=5e-6),
(material="Gold", n=0.18, k=3.0, thickness=50e-9),
(material="Air", n=1.0, k=0.0, thickness=5e-6),
]
julia> stack = material_stack(mats)
julia> stack[1].material
"Substrate: Glass"
julia> stack[2].n
0.18
julia> stack[2].thickness
50e-9
```AttenuatedTotalReflectance.target_layer — Function
target_layer(stack, d, metal_layer_index)Helper function which evaluates the correct layer and its complex refractive index for field enhancement calculations.
Arguments
stack::Vector{Layer}: The multilayer stack.depth::Number: Distance above the layer of intrest (0.0 represents the interface).layer_of_intrest::Int: The index of the layer of interest (e.g., a gold thin film).
Returns
(layer_idx, n_complex): A tuple containing the resolved layer index and its complex refractive index.
Fresnel Coefficients
The underlying equations for reflection and transmission at single interfaces.
AttenuatedTotalReflectance.refl_coeff_P — Function
refl_coeff_P(theta_i, ni::ComplexF64, theta_j, nj::ComplexF64)Compute the Fresnel reflection coefficient $r_p$ at the interface between layer $i$ and layer $j$ for P-polarization (TM mode).
The reflection coefficient is defined by the formula:
\[r_p = rac{n_i cos( heta_j) - n_j cos( heta_i)}{n_i cos( heta_j) + n_j cos( heta_i)}\]
Arguments
theta_i: The angle of incidence in the first layer $i$ (radians).ni: The complex refractive index of the incident layer $n_i$.theta_j: The angle of refraction in the second layer $j$ (radians).nj: The complex refractive index of the transmitted layer $n_j$.
Returns
- A
ComplexF64representing the amplitude reflection coefficient.
AttenuatedTotalReflectance.refl_coeff_S — Function
refl_coeff_S(theta_i, ni::ComplexF64, theta_j, nj::ComplexF64)Compute the Fresnel reflection coefficient $r_s$ at the interface between layer $i$ and layer $j$ for S-polarization (TE mode).
The reflection coefficient is defined by the formula:
\[r_s = rac{n_i cos( heta_i) - n_j cos( heta_j)}{n_i cos( heta_i) + n_j cos( heta_j)}\]
Arguments
theta_i: The angle of incidence in the first layer $i$ (radians).ni: The complex refractive index of the incident layer $n_i$.theta_j: The angle of refraction in the second layer $j$ (radians).nj: The complex refractive index of the transmitted layer $n_j$.
Returns
- A
ComplexF64representing the amplitude reflection coefficient.
Example
ni = complex(1.5, 0.0)
nj = complex(1.0, 0.0)
theta_i = deg2rad(45.0)
theta_j = snells_law(theta_i, ni, nj)
r_s = refl_coeff_S(theta_i, ni, theta_j, nj)AttenuatedTotalReflectance.trans_coeff_P — Function
trans_coeff_P(theta_i, n_i::ComplexF64, theta_j, n_j::ComplexF64)Compute the Fresnel transmission coefficient $t_p$ at the interface between layer $i$ and layer $j$ for P-polarization (TM mode).
The transmission coefficient is defined by the formula:
\[t_p = rac{2 n_i cos( heta_i)}{n_i cos( heta_j) + n_j cos( heta_i)}\]
Arguments
theta_i: The angle of incidence in the first layer $i$ (radians).n_i: The complex refractive index of the incident layer $n_i$.theta_j: The angle of refraction in the second layer $j$ (radians).n_j: The complex refractive index of the transmitted layer $n_j$.
Returns
- A
ComplexF64representing the amplitude transmission coefficient.
AttenuatedTotalReflectance.trans_coeff_S — Function
trans_coeff_S(theta_i, n_i::ComplexF64, theta_j, n_j::ComplexF64)Compute the Fresnel transmission coefficient $t_s$ at the interface between layer $i$ and layer $j$ for S-polarization (TE mode).
The transmission coefficient is defined by the formula:
\[t_s = rac{2 n_i cos( heta_i)}{n_i cos( heta_i) + n_j cos( heta_j)}\]
Arguments
theta_i: The angle of incidence in the first layer $i$ (radians).n_i: The complex refractive index of the incident layer $n_i$.theta_j: The angle of refraction in the second layer $j$ (radians).n_j: The complex refractive index of the transmitted layer $n_j$.
Returns
- A
ComplexF64representing the amplitude transmission coefficient.
Optical Utilities
Helper functions for Snell's law and transforming optical constants
AttenuatedTotalReflectance.complex_n — Function
Helper function to take n & k values to produce singular complex refractive index
Arguments: - n: Refractive index - k: Extinction coefficient
Return: - Complex index of refraction
Example: Taking the refractive index of Silver @ 586.6 nm: n = 0.051585 & k = 3.9046
```julia-repl
julia> complex_n(0.051585, 3.9046)
0.051585 + 3.9046im
```AttenuatedTotalReflectance.snells_law — Function
Implimentation of Snell's Law to compute the angle of refraction. Computes the resulting angle due to the refraction between two materials of differing refractive indices. Returned angle can be complex.
Arguments:
- `theta_in::Number`: Angle of the incident light ray traveling through a material of refractive index, n_in, with repect to the normal prerpendicular to the interface.
- `n_in::Number`: Refractive index of the first material the light passes through.
- `n_out::Number`: Refractive index of the second material the light passes through.
All Arguments may be complexReturn:
Resulting angle due to refraction at the interface.Example:
Taking the refractive index of Silver @ 586.6 nm: e1 = -15.243 & e2 = 0.40284
```julia-repl
julia> snells_law(pi/3, 1, 1.33)
0.7091 + 0.0im
julia> snells_law(pi/4, 1.33, 1.0)
1.2239 + 0.0im
```AttenuatedTotalReflectance.epsilon_to_nk — Function
Helper function to convert dielectric constant into n and k.
Arguments:
- `e1::Float64`: Real component of dielectric constant.
- `e2::Float64`: Imaginary component of dielectric constant.Return:
- n: Refractive index
- k: Extinction coefficientExample:
Taking the refractive index of Silver @ 586.6 nm: e1 = -15.243 & e2 = 0.40284
```julia-repl
julia> epsilon_to_nk(-15.243, 0.40284)
(0.0516, 3.9045)
```AttenuatedTotalReflectance.nk_to_epsilon — Function
Helper function to convert n and k into the components of the dielectric constant.
Arguments:
- `n::Float64`: Refractive index
- `k::Float64`: Extinction coefficientReturn:
- e1: Real component of dielectric constant.
- e2: Imaginary component of dielectric constant.Example:
Taking the refractive index of Silver @ 586.6 nm: n = 0.051585 & k = 3.9046
```julia-repl
julia> nk_to_epsilon(0.051585, 3.9046)
(-15.243, 0.402)
```