Utilities
Collection of some utilities for simulations.
ITensor Utilities
QuantumDynamics.Utilities.convert_ITensor_to_matrix
— Functionconvert_ITensor_to_matrix(tens, sinit, sterm)
Converts an ITensor with two indices to a matrix. The index sinit
is mapped to the column and sterm
is mapped to the row.
QuantumDynamics.Utilities.identity_MPO
— Functionidentity_MPO(sites)
Returns the identity MPO based on the given sites
.
QuantumDynamics.Utilities.MPO_to_MPS
— FunctionMPO_to_MPS(ρ::MPO, fbcombiner)
Convert a given MPO to an MPS by combining the two site indices on every tensor into a single one using the vector of combiner tensors.
QuantumDynamics.Utilities.MPS_to_MPO
— FunctionMPS_to_MPO(ρ::MPS, fbcombiner)
Split a given MPS to an MPO by using the vector of combiner tensors.
ITensors.ITensorMPS.expect
— FunctionITensors.expect(ρ::MPO, ops; kwargs...)
Extends ITensors' expect
function to handle density matrices in the form of MPOs.
HDF5 Utilities
QuantumDynamics.Utilities.create_and_select_group
— Functioncreate_and_select_group(base, new_group)
Checks if new_group
exists in base
. Selects it if it does, else creates it.
QuantumDynamics.Utilities.check_or_insert_value
— Functioncheck_or_insert_value(base, variable, value)
Inserts value
into base[variable]
. If it already exists, checks if the value is correct, and throws if not.
QuantumDynamics.Utilities.merge_into
— Functionmerge_into(source::String, destination::String)
Merge data from the HDF5 file at source
to the one at destination
.
Generic Utilities
QuantumDynamics.Utilities.get_BLAS_implementation
— Functionget_BLAS_implementation()
Reports the BLAS implementation under use. The default implementation used by Julia is OpenBlas. MKL is supported through the external package MKL.jl, which needs to be installed and loaded before the loading of QuantumDynamics.jl
QuantumDynamics.Utilities.trapezoid
— Functiontrapezoid(x, y; discrete::Bool=false, exec=ThreadedEx())
Returns the trapezoidal integration of y with respect to x. If discrete is set to true
, then returns sum of y. exec
encodes the execution paradigm and is one of seq
or par
.
QuantumDynamics.Utilities.fourier_transform
— Functionfourier_transform(time::AbstractArray{<:Real}, corr::AbstractArray{<:Complex}; full=true, unitary=false)
Returns the Fourier transform of corr
:
$C(\omega) = \mathcal{N}\,\int_a^\infty C(t)\,e^{i\omega t}\,dt$
If unitary
is true, then $\mathcal{N}=\frac{1}{2\pi}$, else $\mathcal{N}=1$.
If full
is true, then $a=-\infty$, else $a=0$.
QuantumDynamics.Utilities.commutator
— Functioncommutator(A, B)
Returns the commutator A and B: AB - BA.
QuantumDynamics.Utilities.nh_commutator
— Functionnh_commutator(A, B)
Returns the commutator A and B: AB - BA'.
QuantumDynamics.Utilities.calculate_Liouvillian
— Functioncalculate_Liouvillian(H::OpSum, sites)
Returns the forward-backward space combiner and the Liouvillian MPO corresponding to the Hamiltonian provided as an ITensor OpSum
, to be built on the sites
.
calculate_Liouvillian(Hamiltonian::AbstractMatrix{Complex})
Returns the Liouvillian corresponding to the given Hamiltonian.
QuantumDynamics.Utilities.ExternalField
— TypeExternalField provides an abstract interface for encoding an external field, V(t)
, interacting with the system through the operator, coupling_op
.
QuantumDynamics.Utilities.density_matrix_to_vector
— Functiondensity_matrix_to_vector(ρ::AbstractMatrix{<:Complex})
Returns the vector representation of the density matrix ρ
compatible with the forward-backward propagators.
QuantumDynamics.Utilities.density_matrix_vector_to_matrix
— Functiondensity_matrix_vector_to_matrix(ρvec::AbstractVector{<:Complex})
Returns the matrix form of the vector ρvec
.
QuantumDynamics.Utilities.hash_path
— Functionhash_path(states, sdim)
Returns the hashed location of a path for a system with sdim
dimensions.
QuantumDynamics.Utilities.unhash_path
— Functionunhash_path(path_num::Int, ntimes::Int, sdim::Int)
Construct a path for a system with sdim
dimensions, corresponding to the number path_num
, with ntimes
time steps.
QuantumDynamics.Utilities.unhash_path_blips
— Functionunhash_path_blips(ntimes::Int, sdim::Int, nblips::Int)
Construct all the paths for a system with sdim
dimensions with ntimes
time steps and nblips
blips.
QuantumDynamics.Utilities.apply_propagator
— Functionapply_propagator(; propagators, ρ0, ntimes, dt)
Apply a series of ntimes
propagators to an initial reduced density matrix ρ0
and return the result as a tuple of (time, ρs)
.
There are a few utilities for creating specific kinds of Hamiltonians.
QuantumDynamics.Utilities.create_tls_hamiltonian
— Functioncreate_tls_hamiltonian(; ϵ::AbstractFloat, Δ::AbstractFloat)
Creates a two-level system Hamiltonian:
$H = \frac{ϵ}{2}σ_z - \frac{Δ}{2}σ_x$
QuantumDynamics.Utilities.create_nn_hamiltonian
— Functioncreate_nn_hamiltonian(; site_energies::AbstractVector{AbstractFloat}, couplings::AbstractVector{AbstractFloat}, periodic::Bool)
Creates a nearest neighbour Hamiltonian with the given site_energies
and couplings
. Periodic boundary conditions can also be used by passing true
into the periodic
argument.
Extra arguments
Many of the algorithms require extra, method-specific arguments. These are implemented as subtypes of Utilities.ExtraArgs
.
QuantumDynamics.Utilities.ExtraArgs
— TypeAbstract type for encoding all the method specific numerical parameters.
QuantumDynamics.Utilities.DiffEqArgs
— TypeExtra parameters for solving differential equations. Currently has a threshold for magnitude-based filtering. The default values are:
- reltol = 1e-10
- abstol = 1e-10
- solver = Tsit5()
QuantumDynamics.Utilities.TensorNetworkArgs
— TypeExtra parameters for tensor network algorithms. Currently has an SVD cutoff
, a maximum bond dimension maxdim
, and the contraction algorithm
. The default values are as follows:
- cutoff = 1e-8
- maxdim = 500
- algorithm = "naive"
Other options for algorithm are "densitymatrix" and "fit".