API
BVector
QuantumGraining.DVec — Function" DVec(u::Vector; special=false) Creates a BVector with type :down. Assumes the frequency ordering is clockwise
QuantumGraining.UVec — Function" UVec(u::Vector; special=false) Creates a BVector with type :up. Assumes the frequency ordering is clockwise
QuantumGraining.BVector — TypeBVector{T} <: AbstractVector{T}A struct representing the up- or down-modes. The poles are stored in the poles field.
Arguments: - freqs: A vector representing the frequencies of the vector. - poles: A vector of the indices of poles of the vector, if any. Does not include the special mode, if there is one. - special: A boolean representing whether the vector is the special mode. - type: A symbol representing the type of the vector. Must be :up or :down.
Diagrams
QuantumGraining.DiagramNode — TypeDiagramNodeThe DiagramNode struct is a type for one bubble in the diagram. It is defined as a recursive tree where the elements represent the different decompositions of one node into two.
Fields:
root::Tuple{Int, Int}: The root of the tree, the largest common bubble defining the contraction.val::Tuple{Int, Int}: The value of the current node, determines how much of the bubble was broken to the left.rightmost::Tuple{Int, Int}: The value of the rightmost bubble.right::DiagramNode: Pointer to the next right node of the tree, a diagram with one mode broken to the down-bubble.left::DiagramNode: Pointer to the next left node of the tree, a diagram with one mode broken to the up-bubble.
Missing docstring for node_decomp. Check Documenter's build log for details.
QuantumGraining.get_diagrams — Functionget_diagrams(init_diagram::Array)Uses the above node_decomp() to get all possible diagrams recursively.
Arguments
node::AbstractDiagramNode: The initial diagram including the first level of breakdowns (two bubble diagrams)
Returns
- A list of all possible diagrams for a given contractions.
QuantumGraining.Diagram — TypeDiagram{T1, T2} <: AbstractVector{Tuple{T1, T2}}A struct representing a diagram, also takes care of the edge mode.
Arguments: - bubbles: A vector of bubbles. - freqs: A vector of tuples of BVectors. The first element of the tuple is the up-bubble, the second is the down-bubble. - shape: A vector of tuples representing the shape of the bubbles. - uppoles: A vector of vectors representing the up-poles of the bubbles. - downpoles: A vector of vectors representing the down-poles of the bubbles. - num_poles: An integer representing the number of poles in the diagram.
Poles
Missing docstring for Contraction. Check Documenter's build log for details.
QuantumGraining.count_poles — Functioncount_poles(s_list::Vector{Int}, stag_list::Vector{Int})Given two lists of poles, counts the total number of poles by counting the non-empty lists.
Argument: - slist: list of upper poles - staglist: list of lower poles
QuantumGraining.find_poles — Functionfind_poles(u)
Finds all the factors of the vector factorial that evaluate to 0.
Argument: - ω = [(μ1, ν1), ..., (μ||d||, ν||d||)]
Returns: - poles_list: list of indices of poles
QuantumGraining.find_all_poles — Functionfind_all_poles(d::Vector{Tuple{BVector{T1}, BVector{T2}}}) where {T1, T2}Find all poles in the given vector of tuples d. Each tuple contains two BVector objects, μ and ν. The function iterates over each tuple and performs the following steps:
- If
μ.specialistrue, it removes the first element fromμ. - Reverses the order of elements in
μ. - Calls the
find_polesfunction to find the poles inμandν. - Appends the resulting poles to
up_polesanddown_polesrespectively.
Arguments
d::Vector{Tuple{BVector{T1}, BVector{T2}}}: A vector of tuples, where each tuple contains twoBVectorobjects.
Returns
- A tuple
(up_poles, down_poles)whereup_polesis a vector of vectors containing the poles found inμ, anddown_polesis a vector of vectors containing the poles found inν.
find_all_poles(d::Vector{Tuple{Vector{T1}, Vector{T2}}}) where {T1, T2}Finds all poles in vector factorial for frequency list d. Assumes that the first tuple in the list is the special mode.
Argument: - ω = [(μ1, ν1), ..., (μ||d||, ν||d||)] Returns: - uppoles: list of indices of poles in upper modes - downpoles: list of indices of poles in lower modes
QuantumGraining.find_integer_solutions — Functionfind_integer_solutions(num_vars::Int, target_sum::Int, combination::Vector{Int}=Vector{Int}(), sum_so_far::Int=0)Function that calculates combinations of k positive integers adding up to m, as detailed in the paper.
QuantumGraining.reshape_sols — Functionreshapesols(sols, targetsum, numbubbles, numindices = 3)
Helper function that reshapes integer combinations from findintegersolutions() into vectors
Contractions
Missing docstring for diagram_correction. Check Documenter's build log for details.
Missing docstring for contraction_coeff. Check Documenter's build log for details.
Missing docstring for calc_pole_corrections. Check Documenter's build log for details.
QuantumGraining.Correction — Typestruct CorrectionA struct representing a correction term.
Fields
prefac: The prefactor of the correction term.exponent: The exponent of the correction term.poly: A vector of coefficients for the polynomial term.order: The order of the polynomial term.
Constructors
Correction(prefac, exponent, poly=Num[1,], order=length(poly)): Constructs aCorrectionobject with the given parameters. Ifpolyis not provided, it defaults to[1]. Iforderis not provided, it defaults to the length ofpoly.
QuantumGraining.ContractionCoefficient — Typestruct ContractionCoefficientA struct representing a contraction coefficient.
Fields
corrections::Vector{Correction}: Vector ofCorrectionobjects.exponents::Vector{Number}: Vector of exponents.prefacs::Vector{Number}: Vector of prefactors.polys::Vector{Vector{Number}}: Vector of polynomials.
Constructors
ContractionCoefficient(exponents, prefacs, polys): Constructs aContractionCoefficientobject with given exponents, prefactors, and polynomials.ContractionCoefficient(exponents, prefacs): Constructs aContractionCoefficientobject with given exponents and prefactors. Polynomials are set to[1]by default.
QuantumGraining.split_freqs_into_bubbles — Functionsplit_freqs_into_bubbles(freqs, diagram)Splits an array of frequencies into an array of tuples of frequencies, matching the dimensions of each bubble in diagram.
Argument: freqs - an array of frequencies in the form ω = [μ1..., μ2..., ..., μl..., ν1..., ν2..., ..., νr] diagram - dimensions of each bubble, where each tuple is the dimension for the corresponding bubble. Returns: ω - an array of frequencies in the form [(μ1, ν1), (μ2, ν2), ..., (μl, νl), ([], ν(l+1)), ..., ([], νr)]
Missing docstring for to_qc_symbol. Check Documenter's build log for details.
Corrections
QuantumGraining.merge_duplicate_exponents — Functionmerge_duplicate_exponents(c::ContractionCoefficient)Merge duplicate exponents in a ContractionCoefficient object.
Arguments
c::ContractionCoefficient: TheContractionCoefficientobject to merge duplicate exponents.
Returns
A new ContractionCoefficient object with merged duplicate exponents.
Description
This function takes a ContractionCoefficient object and merges any duplicate exponents. It iterates over the exponents, prefactors, and polynomials in the ContractionCoefficient object and checks for duplicates. If duplicates are found, the prefactors and polynomials are merged into a single polynomial. The resulting unique exponents, merged prefactors, and merged polynomials are then used to create a new ContractionCoefficient object.
Note that the function uses the ordered_sum function to merge the polynomials and the simplify function to simplify the resulting polynomial.
QuantumGraining.simplify_contraction — Functionsimplify_contraction(c::ContractionCoefficient)Simplifies the given ContractionCoefficient by applying simplification operations to its components.
Arguments
c::ContractionCoefficient: TheContractionCoefficientto be simplified.
Returns
A new ContractionCoefficient object with simplified components.
Bubble
QuantumGraining.Bubble — TypeBubble{T1, T2} <: AbstractVector{Tuple{T1, T2}}A struct representing a bubble, also takes care of the edge case.
Arguments: - up: A BVector representing the up-bubble. - down: A BVector representing the down-bubble. - shape: A tuple representing the shape of the bubble. - special: A boolean representing whether the bubble is a special edge mode bubble.
QuantumGraining.calculate_bubble_factor — Functioncalculate_bubble_factor(ω, bubble_idx, total_num_poles, s, stag)Returns the bubble factor for a single bubble.
Arguments
- `ω`: the frequency values for the whole diagram.
- `total_num_poles`: the total number of singular poles in the diagram
- `bubble_idx`: the index of the bubble for which we want to calculate the correction factor.
- `s`: a list of the singular poles in the upper modes of the bubble.
- `stag`: a list of the singular poles in the lower modes of the bubble.Returns
- an array of all bubble factors.Lindblad
QuantumGraining.effective_hamiltonian_term — Functioneffective_hamiltonian(h::Vector, g::Vector{Number}, Ω::Vector{Number}, k::Int)Given a truncation order k, a list of frequencies Ω, couplings g, and operators h representing the raw Hamiltonian, this function returns new frequencies, coupling strengths, and operators representing the Hamiltonian to order k.
Arguments
h::Vector: A vector of operators representing the raw Hamiltonian.g::Vector{Number}: A vector of coupling strengths.Ω::Vector{Number}: A vector of frequencies.k::Int: The truncation order.
Returns
ops_eff::Vector: A vector of operators representing the effective Hamiltonian to orderk.merged_gs::Vector: A vector of merged coupling strengths.ωs_eff::Vector: A vector of frequencies representing the effective Hamiltonian to orderk.
Details
The function calculates the effective Hamiltonian by considering all possible combinations of operators, frequencies, and coupling strengths up to order k. It simplifies the expressions and merges duplicate coupling strengths.
QuantumGraining.effective_dissipator_term — Functioneffective_dissipator_term(h::Vector, gs::Vector, Ω::Vector, k::Int)Compute the effective dissipator term for a given set of parameters.
Arguments
h::Vector: Vector of coefficients for the Hamiltonian terms.gs::Vector: Vector of coefficients for the jump operators.Ω::Vector: Vector of coefficients for the frequencies.k::Int: Number of terms in the Hamiltonian.
Returns
J_list::Vector: Vector of tuples representing the jump operators.γ_list::Vector: Vector of complex numbers representing the dissipation coefficients.ω_list::Vector: Vector of sums of frequencies.
QuantumGraining.repeated_combinations — Functionrepeated_combinations(arr::Array, n::Int)Given a collection of terms and a number n, returns all possible n repetitions of the elements in the collection.
repeated_combinations(h::Vector, g::Vector, Ω::Vector, n::Int)Generate all possible combinations of elements from the input vectors h, g, and Ω with repetition, forming combinations of length n.
Arguments
h::Vector: Vector of elements for combination fromhg::Vector: Vector of elements for combination fromgΩ::Vector: Vector of elements for combination fromΩn::Int: Length of combinations to generate
Returns
perm_h::Vector: Vector of combinations of elements fromhperm_g::Vector: Vector of combinations of elements fromgperm_Ω::Vector: Vector of combinations of elements fromΩ
QuantumGraining.gaussian_to_cutoff — Functiongaussian_to_cutoff(gs, freq_vals; cutoff=0.1, keep_small_exponents=true)Apply a cutoff to Gaussian exponents based on their absolute value.
Arguments
gs: A list ofContractionCoefficientobjects representing Gaussian functions.freq_vals: A dictionary mapping frequency keys to their corresponding values.cutoff: The cutoff value for the absolute value of the Gaussian exponents. Default is0.1.keep_small_exponents: A boolean indicating whether to keep small exponents or set them to zero. Default istrue.
Returns
- A list of
ContractionCoefficientobjects with the cutoff applied to the Gaussian exponents.
gaussian_to_cutoff(gs::Dict, ωs::Dict, freq_vals; cutoff=0.1, keep_small_exponents=true)Apply a cutoff to Gaussian exponents based on their absolute value.
Arguments
gs: A dictionary mapping frequency keys toContractionCoefficientobjects representing Gaussian functions.ωs: A dictionary mapping frequency keys to their corresponding values.freq_vals: A dictionary mapping frequency keys to their corresponding values.cutoff: The cutoff value for the absolute value of the Gaussian exponents. Default is0.1.keep_small_exponents: A boolean indicating whether to keep small exponents or set them to zero. Default istrue.
Returns
- A dictionary mapping frequency keys to
ContractionCoefficientobjects with the cutoff applied to the Gaussian exponents.
QuantumGraining.drop_high_freqs — Functiondrop_high_freqs(freqs_list::Vector, freqs_subs, cutoff=0.1)Given a list of frequencies and a list of substitutions, returns only the low frequencies.
Arguments
freqs_list::Vector: A list of frequencies.freqs_subs: A list of substitutions.cutoff=0.1: The cutoff value for determining low frequencies.
Returns
rwa: A list of indices corresponding to the low frequencies.freqs_low: A list of low frequencies.
drop_high_freqs(gs_dict, freqs_dict, freqs_vals; cutoff=0.1)Given dictionaries holding the frequencies and couplings, drops all high-frequency contributions.
Arguments
gs_dict: A dictionary holding the coupling strengths.freqs_dict: A dictionary holding the frequencies.freqs_vals: A dictionary of substitutions for the frequencies.cutoff=0.1: The cutoff value for determining high frequencies.
Returns
gs_dict: The updated dictionary of coupling strengths after dropping high-frequency contributions.freqs_dict: The updated dictionary of frequencies after dropping high-frequency contributions.
QuantumGraining.effective_hamiltonian — Functioneffective_hamiltonian(h::Vector, gs::Vector, Ω::Vector, k::Int; as_dict=false, remove_constants=true)Compute the effective Hamiltonian for a given system.
Arguments
h::Vector: A vector of Hamiltonian terms.gs::Vector: A vector of coupling strengths.Ω::Vector: A vector of frequencies.k::Int: The number of terms to consider.
Keyword Arguments
as_dict::Bool=false: Iftrue, the output will be returned as a dictionary of operators and frequencies.remove_constants::Bool=true: Iftrue, remove constant terms from the output.
Returns
- If
as_dictistrue, returns a tuple(gs_eff, ωs_eff)wheregs_effis a dictionary of operators andωs_effis a dictionary of frequencies. - If
as_dictisfalse, returns a tuple(unique_hs, unique_gs, ωs_eff)whereunique_hsis a vector of unique operators,unique_gsis a vector of unique coupling strengths, andωs_effis a vector of frequencies.
QuantumGraining.effective_dissipator — Functioneffective_dissipator(h::Vector, gs::Vector, Ω::Vector, k::Int; as_dict=true)Compute the effective dissipator for a given set of parameters.
Arguments
h::Vector: A vector of operators representing the raw Hamiltonian.gs::Vector: A vector of coupling strengths.Ω::Vector: A vector of frequencies.k::Int: The truncation order.as_dict::Bool: (optional) Iftrue, returns the dissipator as a dictionary of operators and their corresponding dissipator terms. Iffalse, returns the dissipator as separate vectors for operators, dissipator terms, and frequencies. Default istrue.
Returns
- If
as_dictistrue, returns a tuple(γs_dict, ωs_dict)whereγs_dictis a dictionary of operators and their corresponding dissipator terms, andωs_dictis a dictionary of operators and their corresponding frequencies. - If
as_dictisfalse, returns a tuple(ops_eff, γs_eff, ωs_eff)whereops_effis a vector of operators representing the effective dissipator,γs_effis a vector of dissipator terms, andωs_effis a vector of frequencies.
Printing
QuantumGraining.symbolic_hamiltonian — Functionsymbolic_hamiltonian(gs::Vector, ops::Vector, Ω::Vector, t, τ)Constructs a symbolic Hamiltonian for a quantum system.
Arguments
gs::Vector: Vector of symbols representing the coefficients of the Hamiltonian terms.ops::Vector: Vector of operators corresponding to each Hamiltonian term.Ω::Vector: Vector of frequencies for each Hamiltonian term.t: Time parameter.τ: Symbolic time parameter.
Returns
terms: Vector of symbolic Hamiltonian terms.
symbolic_hamiltonian(gs::Dict, Ω::Dict, t, τ)Constructs a symbolic Hamiltonian for a quantum system.
Arguments
gs::Dict: A dictionary mapping operators to their corresponding coefficients.Ω::Dict: A dictionary mapping operators to their corresponding frequencies.t: The time parameter.τ: The time step parameter.
Returns
A symbolic Hamiltonian for the quantum system.
QuantumGraining.to_symbol — Functionto_symbol(coeff::ContractionCoefficient, τ)Give a symbolic representation of a ContractionCoefficient object.
Arguments
coeff::ContractionCoefficient: TheContractionCoefficientobject to compute the symbol for.τ: The value of τ.
Returns
Symbolic representation of the ContractionCoefficient object.
to_symbol(c::Correction, τ)Give a symbolic representation of a Correction object.
Arguments
c::Correction: TheCorrectionobject to compute the symbol for.τ: The value of τ.
Returns
Symbolic representation of the Correction object.
Convert
Missing docstring for convert_expressions. Check Documenter's build log for details.
QuantumGraining.hamiltonian_function — Functionhamiltonian_function(gs, ωs, h_src, h_tgt, ps; return_contraction_functions=false)Constructs a Hamiltonian function based on the given parameters for QuantumOptics.jl.
Arguments
gs: A dictionary of contraction functions, where the keys are quantum numbers and the values are the corresponding contraction functions.ωs: A dictionary of frequencies, where the keys are quantum numbers and the values are the corresponding frequencies.h_src: An array of source Hamiltonian operators.h_tgt: An array of target Hamiltonian operators.ps: A dictionary of parameters, where the keys are parameter names and the values are the corresponding parameter values.return_contraction_functions: (optional) A boolean indicating whether to return the contraction functions along with the Hamiltonian function. Default isfalse.
Returns
- If
return_contraction_functionsisfalse, returns a Hamiltonian functionH_functhat takes a timetand a stateψas input and returns the Hamiltonian operator applied to the state. - If
return_contraction_functionsistrue, returns a tuple(H_func, func_gs)whereH_funcis the Hamiltonian function andfunc_gsis a dictionary of contraction functions, where the keys are quantum numbers and the values are the corresponding contraction functions.
Missing docstring for normal_ordered_dictionary. Check Documenter's build log for details.
Missing docstring for qc_convert. Check Documenter's build log for details.
QuantumGraining.qnumber_to_qop — Functionqnumber_to_qop(qn::QuantumCumulants.QMul, op_subs, Id; mul = tensor)Converts a QuantumCumulants.QMul object to a quantum operator.
Arguments
qn::QuantumCumulants.QMul: TheQMulobject representing the quantum number.op_subs: The operator substitutions to be applied.Id: The identity operator.mul: The function used for tensor multiplication. Default istensor.
Returns
The quantum operator obtained from the QMul object.
QuantumGraining.contraction_to_function — Functioncontraction_to_function(g, ω, ps)Converts a contraction expression g into a Julia function that depends on the variables t and τ.
Arguments
g: The contraction expression to be converted.ω: The angular frequency.ps: Additional parameters.
Returns
A Julia function that represents the contraction expression g as a function of t and τ.
QuantumGraining.lindblad_function — Functionlindblad_function(gs, Ωs, γs, ωs, h_src, h_tgt, ps)Constructs a Lindblad function that represents the Lindblad master equation for a quantum system.
Arguments
gs: An array of complex numbers representing the coupling strengths between the system and the environment.Ωs: An array of complex numbers representing the Rabi frequencies of the system.γs: An array of tuples representing the jump operators and their corresponding decay rates.ωs: A dictionary mapping jump operators to their corresponding frequencies.h_src: An array of quantum operators representing the source Hamiltonian.h_tgt: An array of quantum operators representing the target Hamiltonian.ps: A dictionary mapping jump operators to their corresponding probabilities.
Returns
A function L_func that represents the Lindblad master equation for the given quantum system for QuantumOptics.jl.
The Lindblad master equation is given by: dρ/dt = -i[H(t, ρ), ρ] + ∑(J * ρ * J† - 0.5 * (J† * J * ρ + ρ * J† * J)) where H(t, ρ) is the time-dependent Hamiltonian, ρ is the density matrix, J is the jump operator, and J† is the adjoint of the jump operator.
The function L_func takes two arguments: t (time) and ρ (density matrix), and returns a tuple (H, J, J†, rates). H is the time-dependent Hamiltonian, J is an array of jump operators, J† is an array of adjoints of the jump operators, and rates is an array of decay rates.
The Lindblad function can be used to simulate the time evolution of a quantum system under the influence of the environment.
Ordering
QuantumGraining.expand_operators — Functionexpand_operators(hs)Expand a list of operators by applying the expand_operator function to each operator.
Arguments
hs: A list of operators to be expanded.
Returns
A list of expanded operators.
expand_operators(hs, gs, ωs)Goes over any sum of operators and breaks it into the constituent operators while preserving the order of the other vectors.
Arguments
hs: Array of operators to be expanded.gs: Array of coefficients corresponding to the operators.ωs: Array of weights corresponding to the operators.
Returns
unique_hs: Array of expanded operators.unique_gs: Array of coefficients corresponding to the expanded operators.unique_ωs: Array of weights corresponding to the expanded operators.
QuantumGraining.expand_operator — Functionexpand_operator(h)Expand a quantum operator into a list of individual operators and their corresponding coefficients.
Arguments
h: The quantum operator to be expanded.
Returns
ops: A list of individual operators.facs: A list of corresponding coefficients.
QuantumGraining.group_operators — Functiongroup_operators(hs, gs, ωs; as_dict=true)Group operators based on their values and return the grouped operators.
Arguments
hs: An array of operators.gs: An array of coefficients corresponding to the operators.ωs: An array of corresponding elements.as_dict: A boolean indicating whether to return the grouped operators as dictionaries. Default istrue.
Returns
- If
as_dictistrue, returns two dictionariesgs_dictandωs_dictwhere the keys are the operators and the values are the grouped coefficients and elements respectively. - If
as_dictisfalse, returns three arraysnew_hs,new_gs, andnew_ωswherenew_hscontains the grouped operators,new_gscontains the grouped coefficients, andnew_ωscontains the grouped elements.
group_operators(hs)Group operators in the given array hs by removing duplicates.
Arguments
hs: An array of operators.
Returns
new_hs: An array of operators with duplicates removed.