Reference
NTECARS.CARSSimulator — Type
CARSSimulator(; species, conditions, lasers, instrument, grid_type, vertical_shift)struct that contains all information for the calculation of a CARS spectrum.
Arguments
species::Vector{T} where {T<:CARSSpecies}: Array ofCARSSpeciessuch asCO2SpeciesorN2Speciesconditions::GasConditions: bulk gas parameters used for calculating linewidthslasers::LaserConfiguration: information on laser wavelengths and profilesinstrument::InstrumentConfiguration: inforamtino on instrumental broadening profilegrid_type ::Symbol: Can be:adaptiveor:uniform. the resolutions are automatically determined from the linewidths of the givenCARSSpeciesat the temperature and pressure given inGasConditionsvertical_shift::Float64A vertical offset that is added to the spectrum at the end. The spectra are normalized to the maximum so ∈ [0,1]wavelength_shift::Float64: Units of meters. Shifts the anti-Stokes wavelength toλ_aS + wavelength_shift.
NTECARS.GasConditions — Type
GasConditions(;pressure::AbstractFloat, T_gas::AbstractFloat)Contains the basis information of the pressure in Pa and translational temperature in K.
The pressure and translational temperature are used for calculating linewidths. When fitting, it should be remembered to update T_gas accordingly.
Examples
conditions = GasConditions(
pressure = 15000.0,
T_gas = 600.0
)NTECARS.InstrumentConfiguration — Type
InstrumentConfiguration(;profile::Union{DeltaProfile,Spectrum} = DeltaProfile())Contains information about the broadening profile introduced by physical measurement devices (spectrometer).
When no instrumental broadening is present, it should contain the default DeltaProfile(). Otherwise, profile can be given profiles created by existing functions such as Gaussian(σ), Voigt(σ, γ) or PowerVoigt(σ, γ, n). Alternatively, a Spectrum containing a discrete spectrum can be used. The profiles should be centered around 0 but do not have to be symmetric.
Examples
InstrumentConfiguration(profile = Gaussian(0.2/2.35))NTECARS.LaserConfiguration — Type
LaserConfiguration(; wavelength_1, wavelength_2, stokes_range,
profile_1=DeltaProfile(),
profile_2=DeltaProfile(),
stokes_profile=FlatProfile())Stores the laser wavelengths and spectral profiles.
Arguments
wavelength_1::Float64: Central wavelength of the first laser (in meters).wavelength_2::Float64: Central wavelength of the second laser (in meters).stokes_range::Tuple{Float64,Float64}: Wavelength range over which the Stokes spectrum is defined (in meters). This determines the range of anti-Stokes frequencies together with the central wavelengths.profile_1::Union{DeltaProfile, Spectrum}: Spectral profile of the first laser.profile_2::Union{DeltaProfile, Spectrum}: Spectral profile of the second laser.stokes_profile::Spectrum: Stokes spectral profile. The Stokes-spectrum has to be defined at the correct physical spectral range (not around 0!). AFlatProfileshould be used if the experimental data is already normalized by the stokes-proflie/non-resonant background.
Notes
Spectrumcan be created from user data or Gaussian(σ), Voigt(σ, γ), PowerVoigt(σ, γ, n)- Internally, wavelengths are converted to wavenumbers.
- The anti-Stokes limits are computed as
extrema(ν₁ + ν₂ − stokes_range).
Examples
lasers = LaserConfiguration(
wavelength_1 = 532e-9,
wavelength_2 = 561e-9,
stokes_range = (600e-9, 610e-9),
profile_1 = Gaussian(0.2), # inputs are σ in cm^-1
profile_2 = Voigt(0.1, 0.05), # inputs are σ, γ in cm^-1
stokes_profile = Spectrum([600e-9, 605e-9, 610e-0], [0.0, 1.0, 0.0], :wavelength)
)NTECARS.Spectrum — Type
Spectrum(x::Vector{N}, I::Vector{T}, unit::Symbol) where {N,T}create a Spectrum from spectral positions x with intensitiy I.
Arguments
x::Vector{N}: spectral positions at which the intensities are given. The units ofxhave to be specified byunit=:wavelength(meter) orunit=:wavenumber(cm^-1) to allow for spectra to be created from both.I::Vector{T}: intensities as spectral positionsx.unit::Symbol: Can bewavelengthorwavenumber. Specifies the units ofx
Notes
- Internally, the spectral positions are stored in wavenumber sorted from lowest to highest values.
Example
Spectrum([404e-9, 405e-9, 406e-9], [0.0, 1.0, 0.0], :wavelength)
Spectrum([20000, 21000], [0.5, 1.0], :wavenumber)NTECARS.average_to_detector_pixels — Method
Bins a finely resolved spectrum defined at wavelengths ν with intensity I to the wavelengths ν_pixel
NTECARS.fit_spectrum — Method
fit_spectrum(; spec_exp, sim, parameter_update_function!, initial, lower, upper,
intensity_eval_function = x -> abs.(x ./ maximum(x)).^(1/2) , parameter_scaling_factor = initial,
solver::Symbol = :LM, maxiters= 200)Fits the the model to a measured spectrum.
Arguments
spec_exp::Spectrum: The measured spectrum that should be fittedsim::CARSSimulator: Should contain all required inputs such as linewidthsparameter_update_function!::Function: A function with the signaturef(sim::CARSSimulator, param)that take aparamarray of lengthNand updatessimusing these parameters.initial::Vector{Float64}: Initial values of the fit parameters. Has to be of lengthN.lower::Vector{Float64}: Lower boundary of the fit parameters. Has to be of lengthN.upper::Vector{Float64}: upper boundary of the fit parameters. Has to be of lengthN.intensity_eval_function::Function = x -> abs.(x ./ maximum(x)).^(1/2),a function that is applied to both the simulated and experimental spectrum before calculating the residuals. The default represents a fitting of the normalized sqaure-root of the CARS-intensity.solver::Symbol: Options are:LMfor LevenbergMarquardt and:IPOPTfor the IPOPT solver.maxiters::Int64: Maximum number of iterations
return
FitResult: contains parameters, spectra, uncertainties etc...
Example
Which parameters are fitted toegther is determined by the parameter_update_function!.
For a sim::CARSSimulator that contains the species N2Species as the first element in sim.species, the rotational and vibrational temperature can for example be fitted by defining the update function
function update_function!(sim::CARSSimulator, param)
T_vib, T_rot = param
sim.conditions.T_gas = T_rot
sim.species[1].distribution = N2.MultiTemperatureDistribution(
T_vib = T_N2vib, T_rot = T_rot)
end
result = fit_spectrum(;
spec_exp = experimental_spectrum,
sim = sim,
initial = [500.0, 500.0],
lower = [0.0, 0.0],
upper = [3000.0, 3000.0],
parameter_update_function! = update_function!
)NTECARS.intervals_around_points — Method
creates an array of intervals that consist of (start_point, end_point) for all points
in the positions array array with a width of window_width. Overlapping intervals ar mergedNTECARS.parameters_that_modify_distributions — Method
parameters_that_modify_distributions(sim_, parameter_update_function!, parameters)Find out which parameters modify the distrution function of CO2 or N2 This is needed the know which paraeters can be extended with uncertainties via Measurements.jl since this is only supported for the distribution functions right now.
NTECARS.raman_shifts — Method
NTECARS.resample_to_resolution — Method
Samples the given spectrum at a given resolution via interpolation. Used for convolutions with
the instrumental broadening profile.NTECARS.rovibrational_populations_database — Method
Generate vibrational and rovibrational populations for a distribution function. If any parameter has
an uncertainty using measurements.jl, then the results will have the corresponding uncertaintiesNTECARS.rovibrational_populations_database — Method
Generate vibrational and rovibrational populations for a distribution function. If any parameter has
an uncertainty using measurements.jl, then the results will have the corresponding uncertaintiesNTECARS.sampling_points_from_intervals — Method
creates an array of sampling points in the range specified by "limits".
In the specified intervals, the points are sampled with the fine resolution
Δx_fine and inbetween them with Δx_coarseNTECARS.total_susceptibility — Method
total_susceptibility(sim::CARSSimulator)test2