Analyzing the results
Contents
Index
BialkaliSpectrum.adiabatic
BialkaliSpectrum.closest_basis_state
BialkaliSpectrum.expand_fields!
BialkaliSpectrum.filter_basis_state
BialkaliSpectrum.filter_basis_state!
BialkaliSpectrum.filter_hyperfine
BialkaliSpectrum.filter_hyperfine!
BialkaliSpectrum.filter_rotational
BialkaliSpectrum.filter_rotational!
BialkaliSpectrum.find_closest_eigenstate
BialkaliSpectrum.get_energy
BialkaliSpectrum.get_energy_difference
BialkaliSpectrum.get_spectra
BialkaliSpectrum.get_spectrum
BialkaliSpectrum.induced_dipole_moments
BialkaliSpectrum.plot_induced_dipole
BialkaliSpectrum.plot_states_adiabatic
BialkaliSpectrum.plot_states_adiabatic_weighted
BialkaliSpectrum.plot_transition_dipole
BialkaliSpectrum.plot_transition_strengths
BialkaliSpectrum.plot_transitions_adiabatic
BialkaliSpectrum.transform_spectra
BialkaliSpectrum.transitions
BialkaliSpectrum.wide_format
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_spectrum
— Functionget_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 name | Description |
---|---|
fields | value of external_fields |
B | magnitude of external_fields.B |
E | magnitude of external_fields.E |
index | index of the eigenenergy (from lowest to highest energy) |
energy | energy of the state (MHz) |
eigenstate | vector of state amplitudes |
basis_index | the index of nearest basis state (in wavefunction overlap) from hamiltonian_parts.basis |
N | rotational number N of the nearest basis state |
m_n | rotational projection m_n of the nearest basis state |
I_1 | nuclear angular momentum I_1 of the nearest basis state |
m_i1 | nuclear projection m_i1 of the nearest basis state |
I_2 | nuclear angular momentum I_2 of the nearest basis state |
m_i2 | nuclear projection m_i2 of the nearest basis state |
See also get_spectra
, make_hamiltonian_parts
, make_krb_hamiltonian_parts
, ExternalFields
.
BialkaliSpectrum.find_closest_eigenstate
— Functionfind_closest_eigenstate(spectrum, basis_state::State; tol=0.5)
Find the row in spectrum
whose :eigenstate
has the highest overlap with basis_state
.
Example!!!
BialkaliSpectrum.get_energy
— Functionget_energy(spectrum, basis_state::State; tol = 0.5)
Find the row in spectrum
whose :eigenstate
has the highest overlap with basis_state
.
Example!!!
BialkaliSpectrum.get_energy_difference
— Functionget_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!!!
BialkaliSpectrum.get_spectra
— Functionget_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
.
BialkaliSpectrum.transform_spectra
— Functiontransform_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??
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!
— Methodexpand_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!
BialkaliSpectrum.filter_basis_state!
— Methodfilter_basis_state!(df, basis_state::State)
Retains the rows of df
whose :eigenstate
is most overlapping with basis_state
. This mutates df
.
BialkaliSpectrum.filter_basis_state
— Methodfilter_basis_state(df, basis_state::State)
Returns a new DataFrame
containing the rows of df
whose :eigenstate
is most overlapping with basis_state
.
BialkaliSpectrum.filter_hyperfine!
— Methodfilter_hyperfine!(df, m_i1, m_i2)
Retains the rows of df
where (row.m_i1 in m_i1) && (row.m_i2 in m_i2)
, removing the rest. This mutates df
.
BialkaliSpectrum.filter_hyperfine
— Methodfilter_hyperfine(df, m_i1, m_i2)
Returns a new DataFrame
containing the rows of df
where (row.m_i1 in m_i1) && (row.m_i2 in m_i2)
.
BialkaliSpectrum.filter_rotational!
— Methodfilter_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
.
BialkaliSpectrum.filter_rotational
— Methodfilter_rotational(df, N)
filter_rotational(df, N, m_n)
Returns a new DataFrame
containing the rows of df
where (row.N in N) && (row.m_n in m_n)
.
BialkaliSpectrum.wide_format
— Methodwide_format(spectra, valuecol, renamecols::Function; groupby=:fields)
renamecols
is a function row -> String
, where row
is a row of a DataFrame
.
Extracting physical quantities
Functions for analyzing the output of get_spectrum
or get_spectra
.
Methods
BialkaliSpectrum.adiabatic
— Methodadiabatic(
spectra;
groupby=:fields,
radius::Union{Int,Nothing}=nothing
)
BialkaliSpectrum.closest_basis_state
— Methodclosest_basis_state(parts::HamiltonianParts, state)
BialkaliSpectrum.induced_dipole_moments
— Methodinduced_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.
BialkaliSpectrum.transitions
— Functiontransitions(
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
)
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_dipole
— Methodplot_induced_dipole(
spectra,
hamiltonian_parts::HamiltonianParts;
groupby=:E,
use_adiabatic=true
)
plot_induced_dipole(spectra; groupby=:E, use_adiabatic=true)
BialkaliSpectrum.plot_states_adiabatic
— Methodplot_states_adiabatic(
spectra;
groupby=:E,
radius::Union{Int,Nothing}=nothing
)
BialkaliSpectrum.plot_states_adiabatic_weighted
— Methodplot_states_adiabatic_weighted(
spectra,
states::Vector{State};
groupby=:E,
radius::Union{Int,Nothing}=nothing
)
BialkaliSpectrum.plot_transition_dipole
— Methodplot_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
)
BialkaliSpectrum.plot_transition_strengths
— Functionplot_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,
)
BialkaliSpectrum.plot_transitions_adiabatic
— Functionplot_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
)