-
Notifications
You must be signed in to change notification settings - Fork 5
SpaceSolutionEMA
This function computes the solution space for a window range of two parameters, the optical thickness, and the porosity. It only works with these two parameters and for a single layer between the incident and emergent media. It is a brute force search over a window of parameters and it could be useful to give an idea of where the minimum could be.
The optical thickness is calculated multiplying the index of refraction times the thickness of the layer. Using the optical thickness instead of the geometrical thickness gives better results, especially for visualisation, check the Example 2.
It uses the mean(abs2.(Xexp .- X))
as the objective function, where Xexp
and X
are the experimental and modelled spectra.
sol = SpaceSolutionEMA(specType, b, beam, Xexp, layers)
specType::FitProcedure
, defines the type of spectrum to fit, taking values Reflectance()
or Transmittance()
. This indicates as well the input spectrum to compare to.
This sets the window over which to explore the solution space using the BoundariesFit
structure.
b::BoundariesFit
: lower and upper boundaries for the two parameters to explore, for instance
b = BoundariesFit(odi, odf, pi, pf; Nod=20, Np=20)
where odi
and odf
are the lower and upper boundaries of the first parameter, respectively, and pi
and pf
are the lower and upper boundaries of the optical thickness and the porosity, respectively. Nod
and Np
indicate the number of points to search in the solution space for each parameter.
beam::PlaneWave
can be constructed using the PlaneWave subtype of LightSource. It usually wraps the wavelength range, the angles of incidence and the polarisation. The main difference from the way used in TMMOptics.jl is that you have to define the optional parameter p for the polarisation, which defaults to 0.5. The reason is that the optimisation is carried out over a single modelled spectrum which is basically calculated as a polarisation averaged using beam.p
as weight. For more details see PlaneWave structure inside Common Structures.
Xexp:Array{Float64,1}
is the targeted spectrum to fit. Every iteration will compare the theoretical spectrum built up with the index of refraction model and thickness to Xexp
.
If you are fitting a specType = Reflectance()
then the input Xexp should be a reflectance spectrum, and if it is specType = Transmittance()
, then the input should be a transmittance spectrum.
This array has as many elements as beam.λ
, i.e., the spectrum ranges the whole input wavelength.
The layers
parameter has the information of the layers involved in the thin-film system. It is a column-wise array of three layers. For the SpaceSolutionEMA function, the system must be single-layered only: length(vec(layers)) = 3
. The typeof
first and third are LayerTMMO
while the typeof
of the second layer is ModelFit
.
The ModelFit
structure will tell the function to fit the parameters of the model for the second layer and not the others.
sol::NamedTuple
is the solution structure with the following fields:
-
solSpace
: The matrix with objective function values for the whole space -
objfunMin
: The minimum value of the objective function found -
optOD
: The optimum value of the optical thickness -
optParams
: The optimum value of the other parameter -
optThickness
: The optimum value of the thickness -
spectrumFit
: The optimum spectrum obtained with the optimal parameters -
spectrumExp
: experimental spectrum -
od
: whole range of optical thickness explored -
p
: whole range of porosities explored -
Beam
: information of the light used