API

BVector

QuantumGraining.DVecFunction

" DVec(u::Vector; special=false) Creates a BVector with type :down. Assumes the frequency ordering is clockwise

source
QuantumGraining.UVecFunction

" UVec(u::Vector; special=false) Creates a BVector with type :up. Assumes the frequency ordering is clockwise

source
QuantumGraining.BVectorType
BVector{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.

source

Diagrams

QuantumGraining.DiagramNodeType
DiagramNode

The 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.
source
Missing docstring.

Missing docstring for node_decomp. Check Documenter's build log for details.

QuantumGraining.get_diagramsFunction
get_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.
source
QuantumGraining.DiagramType
Diagram{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.

source

Poles

Missing docstring.

Missing docstring for Contraction. Check Documenter's build log for details.

QuantumGraining.count_polesFunction
count_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

source
QuantumGraining.find_polesFunction

find_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

source
QuantumGraining.find_all_polesFunction
find_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 μ.special is true, it removes the first element from μ.
  • Reverses the order of elements in μ.
  • Calls the find_poles function to find the poles in μ and ν.
  • Appends the resulting poles to up_poles and down_poles respectively.

Arguments

  • d::Vector{Tuple{BVector{T1}, BVector{T2}}}: A vector of tuples, where each tuple contains two BVector objects.

Returns

  • A tuple (up_poles, down_poles) where up_poles is a vector of vectors containing the poles found in μ, and down_poles is a vector of vectors containing the poles found in ν.
source
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

source
QuantumGraining.find_integer_solutionsFunction
find_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.

source
QuantumGraining.reshape_solsFunction

reshapesols(sols, targetsum, numbubbles, numindices = 3)

Helper function that reshapes integer combinations from findintegersolutions() into vectors

source

Contractions

Missing docstring.

Missing docstring for diagram_correction. Check Documenter's build log for details.

Missing docstring.

Missing docstring for contraction_coeff. Check Documenter's build log for details.

Missing docstring.

Missing docstring for calc_pole_corrections. Check Documenter's build log for details.

QuantumGraining.CorrectionType
struct Correction

A 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 a Correction object with the given parameters. If poly is not provided, it defaults to [1]. If order is not provided, it defaults to the length of poly.
source
QuantumGraining.ContractionCoefficientType
struct ContractionCoefficient

A struct representing a contraction coefficient.

Fields

  • corrections::Vector{Correction}: Vector of Correction objects.
  • 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 a ContractionCoefficient object with given exponents, prefactors, and polynomials.
  • ContractionCoefficient(exponents, prefacs): Constructs a ContractionCoefficient object with given exponents and prefactors. Polynomials are set to [1] by default.
source
QuantumGraining.split_freqs_into_bubblesFunction
split_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)]

source
Missing docstring.

Missing docstring for to_qc_symbol. Check Documenter's build log for details.

Corrections

QuantumGraining.merge_duplicate_exponentsFunction
merge_duplicate_exponents(c::ContractionCoefficient)

Merge duplicate exponents in a ContractionCoefficient object.

Arguments

  • c::ContractionCoefficient: The ContractionCoefficient object 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.

source
QuantumGraining.simplify_contractionFunction
simplify_contraction(c::ContractionCoefficient)

Simplifies the given ContractionCoefficient by applying simplification operations to its components.

Arguments

  • c::ContractionCoefficient: The ContractionCoefficient to be simplified.

Returns

A new ContractionCoefficient object with simplified components.

source

Bubble

QuantumGraining.BubbleType
Bubble{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.

source
QuantumGraining.calculate_bubble_factorFunction
calculate_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.
source

Lindblad

QuantumGraining.effective_hamiltonian_termFunction
effective_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 order k.
  • merged_gs::Vector: A vector of merged coupling strengths.
  • ωs_eff::Vector: A vector of frequencies representing the effective Hamiltonian to order k.

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.

source
QuantumGraining.effective_dissipator_termFunction
effective_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.
source
QuantumGraining.repeated_combinationsFunction
repeated_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.

source
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 from h
  • g::Vector: Vector of elements for combination from g
  • Ω::Vector: Vector of elements for combination from Ω
  • n::Int: Length of combinations to generate

Returns

  • perm_h::Vector: Vector of combinations of elements from h
  • perm_g::Vector: Vector of combinations of elements from g
  • perm_Ω::Vector: Vector of combinations of elements from Ω
source
QuantumGraining.gaussian_to_cutoffFunction
gaussian_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 of ContractionCoefficient objects 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 is 0.1.
  • keep_small_exponents: A boolean indicating whether to keep small exponents or set them to zero. Default is true.

Returns

  • A list of ContractionCoefficient objects with the cutoff applied to the Gaussian exponents.
source
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 to ContractionCoefficient objects 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 is 0.1.
  • keep_small_exponents: A boolean indicating whether to keep small exponents or set them to zero. Default is true.

Returns

  • A dictionary mapping frequency keys to ContractionCoefficient objects with the cutoff applied to the Gaussian exponents.
source
QuantumGraining.drop_high_freqsFunction
drop_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.
source
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.
source
QuantumGraining.effective_hamiltonianFunction
effective_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: If true, the output will be returned as a dictionary of operators and frequencies.
  • remove_constants::Bool=true: If true, remove constant terms from the output.

Returns

  • If as_dict is true, returns a tuple (gs_eff, ωs_eff) where gs_eff is a dictionary of operators and ωs_eff is a dictionary of frequencies.
  • If as_dict is false, returns a tuple (unique_hs, unique_gs, ωs_eff) where unique_hs is a vector of unique operators, unique_gs is a vector of unique coupling strengths, and ωs_eff is a vector of frequencies.
source
QuantumGraining.effective_dissipatorFunction
effective_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) If true, returns the dissipator as a dictionary of operators and their corresponding dissipator terms. If false, returns the dissipator as separate vectors for operators, dissipator terms, and frequencies. Default is true.

Returns

  • If as_dict is true, returns a tuple (γs_dict, ωs_dict) where γs_dict is a dictionary of operators and their corresponding dissipator terms, and ωs_dict is a dictionary of operators and their corresponding frequencies.
  • If as_dict is false, returns a tuple (ops_eff, γs_eff, ωs_eff) where ops_eff is a vector of operators representing the effective dissipator, γs_eff is a vector of dissipator terms, and ωs_eff is a vector of frequencies.
source

Printing

QuantumGraining.symbolic_hamiltonianFunction
symbolic_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.
source
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.

source
QuantumGraining.to_symbolFunction
to_symbol(coeff::ContractionCoefficient, τ)

Give a symbolic representation of a ContractionCoefficient object.

Arguments

  • coeff::ContractionCoefficient: The ContractionCoefficient object to compute the symbol for.
  • τ: The value of τ.

Returns

Symbolic representation of the ContractionCoefficient object.

source
to_symbol(c::Correction, τ)

Give a symbolic representation of a Correction object.

Arguments

  • c::Correction: The Correction object to compute the symbol for.
  • τ: The value of τ.

Returns

Symbolic representation of the Correction object.

source

Convert

Missing docstring.

Missing docstring for convert_expressions. Check Documenter's build log for details.

QuantumGraining.hamiltonian_functionFunction
hamiltonian_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 is false.

Returns

  • If return_contraction_functions is false, returns a Hamiltonian function H_func that takes a time t and a state ψ as input and returns the Hamiltonian operator applied to the state.
  • If return_contraction_functions is true, returns a tuple (H_func, func_gs) where H_func is the Hamiltonian function and func_gs is a dictionary of contraction functions, where the keys are quantum numbers and the values are the corresponding contraction functions.
source
Missing docstring.

Missing docstring for normal_ordered_dictionary. Check Documenter's build log for details.

Missing docstring.

Missing docstring for qc_convert. Check Documenter's build log for details.

QuantumGraining.qnumber_to_qopFunction
qnumber_to_qop(qn::QuantumCumulants.QMul, op_subs, Id; mul = tensor)

Converts a QuantumCumulants.QMul object to a quantum operator.

Arguments

  • qn::QuantumCumulants.QMul: The QMul object representing the quantum number.
  • op_subs: The operator substitutions to be applied.
  • Id: The identity operator.
  • mul: The function used for tensor multiplication. Default is tensor.

Returns

The quantum operator obtained from the QMul object.

source
QuantumGraining.contraction_to_functionFunction
contraction_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 τ.

source
QuantumGraining.lindblad_functionFunction
lindblad_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.

source

Ordering

QuantumGraining.expand_operatorsFunction
expand_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.

source
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.
source
QuantumGraining.expand_operatorFunction
expand_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.
source
QuantumGraining.group_operatorsFunction
group_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 is true.

Returns

  • If as_dict is true, returns two dictionaries gs_dict and ωs_dict where the keys are the operators and the values are the grouped coefficients and elements respectively.
  • If as_dict is false, returns three arrays new_hs, new_gs, and new_ωs where new_hs contains the grouped operators, new_gs contains the grouped coefficients, and new_ωs contains the grouped elements.
source
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.
source