Reference

NTECARS.CARSSimulatorType
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 of CARSSpecies such as CO2Species or N2Species
  • conditions::GasConditions: bulk gas parameters used for calculating linewidths
  • lasers::LaserConfiguration: information on laser wavelengths and profiles
  • instrument::InstrumentConfiguration: inforamtino on instrumental broadening profile
  • grid_type ::Symbol: Can be :adaptive or :uniform. the resolutions are automatically determined from the linewidths of the given CARSSpecies at the temperature and pressure given in GasConditions
  • vertical_shift::Float64 A 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.
source
NTECARS.GasConditionsType
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   
)
source
NTECARS.InstrumentConfigurationType
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))
source
NTECARS.LaserConfigurationType
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!). A FlatProfile should be used if the experimental data is already normalized by the stokes-proflie/non-resonant background.

Notes

  • Spectrum can 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)
)
source
NTECARS.SpectrumType
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 of x have to be specified by unit=:wavelength (meter) or unit=:wavenumber (cm^-1) to allow for spectra to be created from both.
  • I::Vector{T}: intensities as spectral positions x.
  • unit::Symbol: Can be wavelength or wavenumber. Specifies the units of x

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)
source
NTECARS.fit_spectrumMethod
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 fitted
  • sim::CARSSimulator: Should contain all required inputs such as linewidths
  • parameter_update_function!::Function: A function with the signature f(sim::CARSSimulator, param) that take a param array of length N and updates sim using these parameters.
  • initial::Vector{Float64}: Initial values of the fit parameters. Has to be of length N.
  • lower::Vector{Float64}: Lower boundary of the fit parameters. Has to be of length N.
  • upper::Vector{Float64}: upper boundary of the fit parameters. Has to be of length N.
  • 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 :LM for LevenbergMarquardt and :IPOPT for 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!
)
source
NTECARS.intervals_around_pointsMethod
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 merged
source
NTECARS.parameters_that_modify_distributionsMethod
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.

source
NTECARS.rovibrational_populations_databaseMethod
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 uncertainties
source
NTECARS.rovibrational_populations_databaseMethod
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 uncertainties
source
NTECARS.sampling_points_from_intervalsMethod
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_coarse
source