Analyzing the results

Contents

Index

Spectrum

These are the main functions for calculating the molecular spectrum.

In most cases, you should just call get_spectra to calculate the spectrum at each point in a field_scan::Vector{ExternalFields}.

A common pattern is to put the resulting spectra into transform_spectra to calculate quantities of interest at each point in the field_scan. transform_spectra groups spectra (the default is by :fields), then applies a transformation f to each subgroup. See the source for transitions for an example of this.

get_spectrum can be called to calculate the spectrum at a single value of external_fields.

TODO: get rid of get_spectrum?? When is it ever helpful? Then the utility functions might need to be extended to work on grouped dataframes as well?

Methods

BialkaliSpectrum.get_spectrumFunction
get_spectrum(
    hamiltonian_parts::HamiltonianParts,
    external_fields::ExternalFields,
)

Compute the energies and eigenstates under the external fields.

To avoid reconstructing the Hamiltonian each time, hamiltonian_parts can be reused over calls to get_spectrum. The output is a DataFrame, with the following fields:

Field nameDescription
fieldsvalue of external_fields
Bmagnitude of external_fields.B
Emagnitude of external_fields.E
indexindex of the eigenenergy (from lowest to highest energy)
energyenergy of the state (MHz)
eigenstatevector of state amplitudes
basis_indexthe index of nearest basis state (in wavefunction overlap) from hamiltonian_parts.basis
Nrotational number N of the nearest basis state
m_nrotational projection m_n of the nearest basis state
I_1nuclear angular momentum I_1 of the nearest basis state
m_i1nuclear projection m_i1 of the nearest basis state
I_2nuclear angular momentum I_2 of the nearest basis state
m_i2nuclear projection m_i2 of the nearest basis state

See also get_spectra, make_hamiltonian_parts, make_krb_hamiltonian_parts, ExternalFields.

source
BialkaliSpectrum.get_energyFunction
get_energy(spectrum, basis_state::State; tol = 0.5)

Find the row in spectrum whose :eigenstate has the highest overlap with basis_state.

Example!!!

source
BialkaliSpectrum.get_energy_differenceFunction
get_energy_difference(spectrum, basis_g::State, basis_e::State; tol = 0.5)

Find the row in spectrum whose :eigenstate has the highest overlap with basis_state.

Example!!!

source
BialkaliSpectrum.get_spectraFunction
get_spectra(hamiltonian_parts, fields_scan, df_transform)

Compute the energies and eigenstates at each point in fields_scan, applying df_transform to each intermediate spectrum.

The fields_scan can be conveniently generated with generate_fields_scan. The closure df_transform, which must have the signature DataFrame -> DataFrame, can be used to filter away unneeded rows (typically large N states), or to do further analysis.

Internally, this method calls get_spectrum for each point in fields_scan, calls df_transform on each point (if provided), and vertically concatenates the results. The output is a DataFrame, see get_spectrum for details on the dataframe columns.

See also make_hamiltonian_parts, make_krb_hamiltonian_parts, generate_fields_scan, get_spectrum.

source
BialkaliSpectrum.transform_spectraFunction
transform_spectra(spectra, f; groupby=:fields)

A generic function for transforming the output of get_spectra.

Returns the result of grouping spectra by groupby and applying f to each group, then combining the results into a new DataFrame. The signature of f must be DataFrame -> DataFrame.

Example??

source

DataFrame helpers

Utilities for working with the output of get_spectrum and get_spectra, both of which return a DataFrame.

These are mainly simple filters or transforms, defined for convenience. Anything more complicated should use the methods in the DataFrames.jl library.

Methods

BialkaliSpectrum.expand_fields!Method
expand_fields!(df; magnitude_only=true)
expand_fields!(df, col_names::Vector{Symbol}, expander::Function)

Expands the :fields column of df to new columns with the individual field parameters.

In the first variant, the optical fields are ignored. If magnitude_only=true (default), then the :fields column is expanded to new columns :B and :E contaning fields.B.magnitude and fields.E.magnitude, respectively. This is convenient for plotting, so the values of E can be accessed as df.E (and similarly for df.B). If magnitude_only=false, then new columns for the field angles :θ_B, :ϕ_B, :θ_E, and :ϕ_E are added, in addition to the field magnitudes.

The second variant allows full control of the behavior. col_names is the list of the columns to add to df. expander must be a function fields -> Vector, which defines how a value in the :fields column is transformed to the quantities named in col_names. This variant should be used for extracting the optical field parameters.

Add examples!

source
BialkaliSpectrum.filter_rotational!Method
filter_rotational!(df, N)    
filter_rotational!(df, N, m_n)

Retains the rows of df where (row.N in N) && (row.m_n in m_n), removing the rest. This mutates df.

source
BialkaliSpectrum.wide_formatMethod
wide_format(spectra, valuecol, renamecols::Function; groupby=:fields)

renamecols is a function row -> String, where row is a row of a DataFrame.

source

Extracting physical quantities

Functions for analyzing the output of get_spectrum or get_spectra.

Methods

BialkaliSpectrum.induced_dipole_momentsMethod
induced_dipole_moments(
    spectra,
    hamiltonian_parts::HamiltonianParts;
    groupby=:fields
)

Returns a new DataFrame containing spectra with an additional column :d_ind, the induced dipole moment parallel to the applied electric field.

source
BialkaliSpectrum.transitionsFunction
transitions(
    spectra,
    hamiltonian_parts::HamiltonianParts,
    ground_basis_state::State,
    frequency_range::Union{Vector,Nothing} = nothing;
    groupby=:fields,
    tol=0.5,
    restrict_N=true,
    keep_negatives=true,
    cutoff::Union{Float64,Nothing}=1e-3
)
source

Plotting

Methods for plotting data from get_spectrum and get_spectra using CairoMakie.

In a REPL session, entering using ElectronDisplay will plot the figures in a pop-up window.

Methods

BialkaliSpectrum.plot_induced_dipoleMethod
plot_induced_dipole(
    spectra,
    hamiltonian_parts::HamiltonianParts;
    groupby=:E,
    use_adiabatic=true
)

plot_induced_dipole(spectra; groupby=:E, use_adiabatic=true)
source
BialkaliSpectrum.plot_transition_dipoleMethod
plot_transition_dipole(
    spectra,
    hamiltonian_parts::HamiltonianParts,
    initial_state::State,
    p::Int;
    groupby=:E,
    use_adiabatic=true,
)

plot_transition_dipole(
    spectra,
    initial_state::State,
    p::Int;
    groupby=:E,
    use_adiabatic=true
)
source
BialkaliSpectrum.plot_transition_strengthsFunction
plot_transition_strengths(
    spectrum,
    hamiltonian_parts::HamiltonianParts,
    ground_basis_state::State,
    frequency_range::Union{Vector,Nothing} = nothing;
    groupby=:E,
    tol=0.5,
    restrict_N=true,
    keep_negatives=true,
    cutoff::Union{Float64,Nothing}=1e-3,
    normalization=1/sqrt(3)
)

plot_transition_strengths(
    spectra;
    groupby=:E,
)
source
BialkaliSpectrum.plot_transitions_adiabaticFunction
plot_transitions_adiabatic(
    spectra,
    hamiltonian_parts::HamiltonianParts,
    ground_basis_state::State,
    frequency_range::Union{Vector,Nothing} = nothing;
    groupby=:E,
    tol=0.5,
    restrict_N=true,
    radius::Union{Int,Nothing}=nothing 
)
source