API Reference

This page provides a detailed list of all functions and types exported by AttenuatedTotalReflectance.jl.

Index


Core Simulation

These are the high-level functions used to generate reflectivity and field enhancement data.

AttenuatedTotalReflectance.compute_transfer_coefficientsFunction

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. See material_stack function in utils.jl
  • theta::Number: Incident angle in radians.
  • wavelength::Number: Wavelength of the incident light (units must match stack[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) If true, computes coefficients for S-polarization (TE). If false (default), computes for P-polarization (TM).

Returns

A Tuple containing:

  1. C::SMatrix{2,2,ComplexF64}: The total system transfer matrix.
  2. D0::SMatrix{2,2,ComplexF64}: The partial transfer matrix from the ambient to layer_j.
  3. Dj::SMatrix{2,2,ComplexF64}: The partial transfer matrix from layer_j to the substrate.
  4. t_total::ComplexF64: The total Fresnel transmission coefficient for the entire stack.
  5. t0::ComplexF64: Partial transmission coefficient from ambient to layer_j.
  6. tj::ComplexF64: Partial transmission coefficient from layer_j to 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

source
AttenuatedTotalReflectance.angular_ATRFunction
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. See material_stack
  • theta_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 the target_layer (in the same units as wavelength) at which to compute the electric field.
  • metal_layer::Int: An index used by Target_Layer to identify the specific layer of interest (e.g., the gold layer in a Kretschmann configuration).
  • S::Bool: If true, calculates for S-polarization (TE). If false (default), calculates for P-polarization (TM).

Returns

A Tuple containing eight vectors (each of length length(theta_range)):

  1. reflectivity: Intensity reflection coefficient (R).
  2. transmittance: Intensity transmission coefficient (T) into the final medium.
  3. f_x: Normalized field intensity component $|E_x/E_0|^2$.
  4. f_y: Normalized field intensity component $|E_y/E_0|^2$.
  5. f_z: Normalized field intensity component $|E_z/E_0|^2$.
  6. 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|$.
source
AttenuatedTotalReflectance.wavelength_ATRFunction
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. See material_stack
  • theta::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 the target_layer (in the same units as wavelength) at which to compute the electric field.
  • metal_layer::Int: An index used by Target_Layer to identify the specific layer of interest (e.g., the gold layer in a Kretschmann configuration). Used for plasmonic systems
  • S::Bool: If true, calculates for S-polarization (TE). If false (default), calculates for P-polarization (TM).

Returns

A Tuple containing eight vectors (each of length length(theta_range)):

  1. reflectivity: Intensity reflection coefficient (R).
  2. transmittance: Intensity transmission coefficient (T) into the final medium.
  3. f_x: Normalized field intensity component $|E_x/E_0|^2$.
  4. f_y: Normalized field intensity component $|E_y/E_0|^2$.
  5. f_z: Normalized field intensity component $|E_z/E_0|^2$.
  6. 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|$.
source

Simulation Configuration

Use these to define your material layers and the geometry of your simulation.

AttenuatedTotalReflectance.layerType

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
```
source
AttenuatedTotalReflectance.material_stackFunction

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+1

Mathematical 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
```
source
AttenuatedTotalReflectance.target_layerFunction
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.
source

Fresnel Coefficients

The underlying equations for reflection and transmission at single interfaces.

AttenuatedTotalReflectance.refl_coeff_PFunction
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 ComplexF64 representing the amplitude reflection coefficient.
source
AttenuatedTotalReflectance.refl_coeff_SFunction
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 ComplexF64 representing 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)
source
AttenuatedTotalReflectance.trans_coeff_PFunction
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 ComplexF64 representing the amplitude transmission coefficient.
source
AttenuatedTotalReflectance.trans_coeff_SFunction
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 ComplexF64 representing the amplitude transmission coefficient.
source

Optical Utilities

Helper functions for Snell's law and transforming optical constants

AttenuatedTotalReflectance.complex_nFunction

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
    ```
source
AttenuatedTotalReflectance.snells_lawFunction

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 complex

Return:

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
```
source
AttenuatedTotalReflectance.epsilon_to_nkFunction

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 coefficient

Example:

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)
```
source
AttenuatedTotalReflectance.nk_to_epsilonFunction

Helper function to convert n and k into the components of the dielectric constant.

Arguments:

- `n::Float64`: Refractive index
- `k::Float64`: Extinction coefficient

Return:

- 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)
```
source