# Material Fitter
The Material Fitter is a tool for fitting refractive index data to get a dispersive medium described by the PoleResidue model.
TIP
A complete example on how to fit optical measurement data and use the results to create dispersion material models for Tidy3D is available in Fitting dispersive material models (opens new window).
# Upload Data from File
Click on Folder image or drag and drop a CSV or TXT file to that area to load the material optical data. The data file should include:
wl: Wavelengths. A list of wavelengths for dispersion data. Unit: μm.
n: Index of refraction. Real part of the complex index of refraction.
k: Extinction coefficient (optional). Imaginary part of the complex index of refraction.
Organize your data as below:
For lossless media:
wl n [float] [float] . . . . For lossy media:
wl n k [float] [float] [float] . . . . . .
Note:
- Delimiters are not displayed here. For .csv, use comma (,) as delimiter. For .txt, use tab (\t) as delimiter.
- The strings such as "wl", "n", "k" need to be included in the file.
- Click "View Example File" button to view and download data file template.
# Basic Fitting Parameters
# Number of Poles
min_num_poles: Minimum number of poles in the model.
Type: integer number
- Unit: unitless
- Constraint: greater than 0
- Default: 1
max_num_poles: Maximum number of poles in the model.
Type: integer number
- Unit: unitless
- Constraint: greater than 0
- Default: 5
# Tolerance
tolerance_rms: Weighted RMS error below which the fit is successful and the result is returned.
Type: floating-point number
- Unit: unitless
- Constraint: greater than 0
- Default: 0.00001
# Advanced Fitting Parameters
# Wavelength Range
wvl_min and wvl_max: Wavelength range [wvl_min, wvl_max] for fitting. Truncate the wavelength-nk data to wavelength range [wvl_min, wvl_max] for fitting.
Type: floating-point number
- Unit: m, μm (default), or nm
- Constraint: greater than 0
# Epsilon at Infinity
eps_inf: Value of to use in fit. If None, then is also fit. Note: fitting is not guaranteed to yield a global optimum, so the result may occasionally be better with a fixed value of .
Type: floating-point number
- Unit: unitless
# Bounds
loss_bounds: Bounds (lower, upper) on the imaginary part of eps. Default corresponds to only passivity. A lower bound of 0 or greater ensures passivity. To fit a gain medium without additional constraints, use loss_bounds=(-inf, inf). Increasing the lower bound could help with simulation stability. A finite upper bound may be helpful when fitting lossless materials. In this case, consider also increasing the weight for fitting the imaginary part.
Type: floating-point number
- Unit: unitless
- Default: (0, inf)
# Weights
weights: Weights (real, imag) in objective function for fitting. The weights are applied to the real and imaginary parts of the permittivity epsilon. The weights will be rescaled together so they average to 1. If None, the weights are calculated according to the typical value of the real and imaginary part, so that the relative error in the real and imaginary part of the fit should be comparable. More precisely, the RMS value of the real and imaginary parts are calculated, and the default weights are 1 / max(rms, RMS_MIN). Changing this can be helpful if fitting either the real or imaginary part is more important than the other.
Type: floating-point number
- Unit: unitless
- Constraint: greater than 0
- Default: (1, 1)
# Relaxed Fitting Algorithm
relaxed: Whether to use relaxed fitting algorithm, which has better pole relocation properties. If None, will try both original and relaxed algorithms.
Options:
- None
- True
- False
Default: None
# Real Starting Poles
smooth: Whether to use real starting poles, which can help when fitting smooth data. If None, will try both real and complex starting poles.
Options:
- None
- True
- False
Default: None
# Space Poles Logarithmically
logspacing: Whether to space the poles logarithmically. If None, will try both log and linear spacing.
Options:
- None
- True
- False
Default: None
# Number of Iterations
num_iters: Number of iterations of the fitting algorithm. Make this smaller to speed up fitter, or make it larger to try to improve fit.
Type: integer number
- Unit: unitless
- Constraint: greater than 0
- Default: 20
# Number of Loss Bounds Enforcement Iterations
passivity_num_iters: Number of loss bounds enforcement iterations of the fitting algorithm. Make this smaller to speed up fitter. There will be a warning if this value is too small. To fit a gain medium, use the loss_bounds parameter instead.
Type: integer number
- Unit: unitless
- Constraint: greater than 0
- Default: 50
# SLSQP Weight
slsqp_constraint_scale: Passivity constraint is weighted relative to fit quality by this factor, before running passivity optimization using the SLSQP algorithm. There will be a warning if this value is too small.
Type: floating-point number
- Unit: unitless
- Constraint: greater than 0
- Default: 1e+35