Code Documentation

class QuantumPolyspectra.simulation.System(h, psi_0, c_ops, sc_ops, e_ops, c_measure_strength, sc_measure_strength)

Class that will represent the system of interest. It contains the parameters of the system and the methods for calculating and storing the polyspectra.

hQobj

Hamiltonian of the system.

psi_0Qobj

Initial state of the system for the integration of the SME.

c_opsdict

Dictionary containing the collaps operators (as Qobj) with arbitrary str as keys.

sc_opsdict

Dictionary containing the stochastic collaps operators (as Qobj) with arbitrary str as keys.

e_opsdict

Dictionary containing the operators (as Qobj) used for the calculation of the expectation values with arbitrary str as keys.

c_measure_strengthdict

Dictionary containing the prefactor (float) of the collaps operators. Should have the same keys as the corresponding collaps operators in c_ops.

sc_measure_strengthdict

Dictionary containing the prefactor (float) of the stochastic collaps operators. Should have the same keys as the corresponding collaps operators in sc_ops.

Harray

Hamiltonian of the system

Larray

Liouvillian of the system

psi_0: array

Start state for the integration of the stochastic master equation

c_opsdict

Dictionary containing the collaps operators (as Qobj) with arbitrary str as keys.

sc_opsdict

Dictionary containing the stochastic collaps operators (as Qobj) with arbitrary str as keys.

e_opsdict

Dictionary containing the operators (as Qobj) used for the calculation of the expectation values with arbitrary str as keys.

c_measure_strengthdict

Dictionary containing the prefactor (float) of the collaps operators. Should have the same keys as the corresponding collaps operators in c_ops.

sc_measure_strengthdict

Dictionary containing the prefactor (float) of the stochastic collaps operators. Should have the same keys as the corresponding collaps operators in sc_ops.

time_series_data_emptydataframe

Empty version of the simulation results dataframe to reset any results.

time_series_datadataframe

Stores expectation values after the integration of the SME

freqdict

Stores the frequencies from the analytic spectra, order 2 to 4

Sdict

Stores the analytic spectra, order 2 to 4

numeric_f_datadict

Stores the frequencies from the numeric spectra, order 2 to 4

numeric_spec_datadict

Stores the numeric spectra, order 2 to 4

eigvalsarray

Stores eigenvalues of Liouvillian

eigvecsarray

Stores eigenvectors of Liouvillian

eigvecs_invarray

Stores the matrix inversion of the eigenvector matrix

zero_indint

Contains the index of the steady state in the eigvalues

A_primarray

Stores the measurement superoperator mathcal{A} as defined in 10.1103/PhysRevB.98.205143

rho_steadyarray

Steady state of the Liouvillian

s_karray

Stores small s (Eq. 7) from 10.1103/PhysRevB.102.119901

expect_datadict

Stores expectation values calculated during the integration of the SME (daemon view), keys as in e_ops

expect_with_noisedict

Stores expectation + detector noise values calculated during the integration of the SME, keys as in e_ops

Nint

Number of points in time series in window for the calculation of numerical spectra

fsfloat

Sampling rate of the simulated signal for numerical spectra

a_warray

Fourier coefficients of simulated signal for numerical spectra

a_w_cutarray

Contains only the frequencies of interest from a_w (to speed up calculations)

enable_gpubool

Set if GPU should be used for analytic spectra calculation

gpu_0int

Stores pointer to zero an the GPU

reshape_ind: array

Extracts the trace from a flatted matrix (to avoid reshaping)

calc_a_w3(a_w)

Preparation of a_(w1+w2) for the calculation of the bispectrum

a_warray

Fourier coefficients of signal

a_w3array

Matrix corresponding to a_(w1+w2)

calc_spectrum(f_data, order, measure_op=None, mathcal_a=None, g_prim=False, bar=True, beta=None, correction_only=False, beta_offset=True, enable_gpu=False, cache_trispec=True)

Calculates analytic polyspectra (order 2 to 4) as described in 10.1103/PhysRevB.98.205143 and 10.1103/PhysRevB.102.119901

f_dataarray

Frequencies at which the spectra are calculated

orderint {2,3,4}

Order of the polyspectra to be calculated

measure_opstr

Key of the operator in sc_ops to be used as measurement operator

mathcal_aarray

Stores the measurement superoperator mathcal{A} as defined in 10.1103/PhysRevB.98.205143

g_primbool

Set if mathcal_a should be applied twice/squared (was of use when defining the current operator) But unnecessary for standard polyspectra

barbool

Set if progress bars should be shown during calculation

betafloat

Measurement strength used for the calculation. If not set beta is the prefactor in sc_measure_strength[measure_op]

correction_onlybool

Set if only the correction terms of the S4 from erratum 10.1103/PhysRevB.102.119901 should be calculated

beta_offsetbool

Set if constant offset due to deetector noise should be added to the power spectrum

enable_gpubool

Set if GPU should be used for calculation

cache_trispecbool

Set if Matrix multiplication in the calculation of the trispectrum should be cached

S[order]array

Returns spectral value at specified frequencies

calc_transient(t, seed=None, _solver=None, progress_bar=None, _nsubsteps=1, _normalize=None, options=None, return_result=False)

Integrate the SME for the system definined by mathcal{L} and the starting state rho_0. Saves the results (daemon view and measurement with detector noise) in a dataframe

tarray

Times at which the SME is intergrated

seedint

Seed for the generation of the Wiener Process

_solverstr

Name of the solver used for the intergration of the SME (see the qutip docs for more information)

_nsubstepsint

Number of substeps between to point in t. Reduces numerical errors.

_normalizebool

Set if density matrix should be normalized after each integration step

progress_barbool

Set if progress bar should be shown during integration

optionsdict

Solver options (see qutip documentation)

return_resultbool

Set if solver result should be returned in addition to the dataframe

Return a dataframe containing the daemon view and measurement with detector noise. Additionally, returns solver result (see return_result parameter)

first_matrix_step(rho, omega)

Helper method to move function out of the class. njit is not working within classes

fourier_g_prim(omega)

Helper method to move function out of the class. njit is not working within classes

g_prim(t)

Helper method to move function out of the class. njit is not working within classes

matrix_step(rho, omega)

Helper method to move function out of the class. njit is not working within classes

numeric_spec(t_window_in, measure_op, f_max, power, order, max_samples, m=5, _solver='milstein', plot_after=12, title_in=None, with_noise=False, _normalize=None, roll=False, plot_simulation=False, backend='opencl')

Method for the automated calculation of the polyspectra from the numerical integration of the SME. Can be used as an alternative to the analytic quantum polyspectra or to estimated measurement time and noise levels of the spectra.

t_window_inarray

Times at with the SME will be integrated

measure_opstr

Key of the operator in sc_ops that should be used as measurement operator

f_maxfloat

Maximum frequency of interest to speed up calculation of polyspectra

powerfloat

Power to which the detector output should be raised before the calculation of the spectra (Was useful during the experimentation with the current operator.)

orderint {2,3,4}

Order of the polyspectra to be calculated

max_samplesint

Number of spectra with m windows to be calculated. The final result will be an average over all these spectra

mint

number of frames used from the calculation of one spectrum

_solverstr

Name of the solver used for the intergration of the SME (see the qutip docs for more information)

plot_afterint

Each number of spectra after with the current average spectrum should be displayed

title_instr

Add a str to customize title

with_noisebool

Set if detector output with noise should be used for the calculation of the spectra instead of the daemon view

_normalizebool

Set if density matrix should be normalized during integration of the SME

rollbool

Set if trace should be shifted against itself during squaring

plot_simulationbool

Set if simulation result / trace should be plot. Useful to check for numerical errors during integration

backendstr {cpu, opencl, cuda}

Backend to be used by arrayfire

Return frequencies and the spectral values as arrays

parallel_tranisent(seed, measure_op, t=None, _solver=None, with_noise=False, _nsubsteps=1, _normalize=None)

Method for the quick integration of the SME (avoids saving the results into dataframes). Is used for parallelization of the integration.

seedint

Seed for the generation of random numbers for the Wiener process

measure_opstr

Key of the measurement operator in sc_ops

tarray

Times at which the integration takes place

_solverstr

Name of the solver used for the intergration of the SME (see the qutip docs for more information)

with_noisebool

Set if detector noise should be added to the trace

_nsubstepsint

Number of substeps between to point in t. Reduces numerical errors.

_normalizebool

Set if density matrix should be normalized after each integration step

outarray

Simulated detector output

plot_all(f_max=None)

Method for quick plotting of polyspectra

f_maxfloat

Maximum frequencies upto which the spectra should be plotted

Returns matplotlib figure

plot_spectrum(order, title=None, log=False, x_range=False, imag_plot=False)

Method for the visualization of single spectra with an interactive plot

orderint {2,3,4}

Order of polyspectrum to be plotted

titlestr

Title of the plot

logbool

Set if log scales should be used

x_rangearray

Sets limits of x axis

imag_plotbool

Set if imaginary of the spectrum should be shown

Returns plotly figure

plot_transient(ops_with_power, title=None, shift=False)

Interactive plot of the integration results.

ops_with_powerdict

Key of the operators in e_ops as key with integer labels corresponding the exponent to with the corresponding trace should be raised to. (Was useful during the experimentation with the current operator.)

titlestr

Title of plot

shiftbool

Set if traces should be shifted up to avoid overlapping of multiple traces

Plotly figure

save_spec(path)

Save System class with spectral data

pathstr

Location of file

second_matrix_step(rho, omega, omega2)

Helper method to move function out of the class. njit is not working within classes

single_plot(order, f_max, f_min=0, arcsinh_plot=False, arcsinh_const=0.02, contours=False, s3_filter=0, s4_filter=0, s2_data=None, s3_data=None, s4_data=None, s2_f=None, s3_f=None, s4_f=None, imag_plot=False, title=None)

Generates plot of the polyspectum of order “order”

orderint {2,3,4}

Order of polyspectrum to be plotted

f_maxfloat

Maximum value of frequency axis

f_minfloat

Minimum value of frequency axis

arcsinh_plotbool

Set if spectral values should be scaled by an arcsinh function (improves visability of small features)

arcsinh_constfloat

Constant to customize the effenct of the scaling

contoursbool

Set if contours should be shown in the 2D plots

s3_filterint

Width of the Gaussian filter applied to the S3

s4_filterint

Width of the Gaussian filter applied to the S4

s2_dataarray

Spectral data for the S2

s3_dataarray

Spectral data for the S3

s4_dataarray

Spectral data for the S4

s2_farray

Frequencies corresponding to the spectral data of the S2

s3_farray

Frequencies corresponding to the spectral data of the S3

s4_farray

Frequencies corresponding to the spectral data of the S4

imag_plotbool

Set if imaginary part of the spectrum should be plotted

titleset

Title of the plot

Matplotlib figure

QuantumPolyspectra.simulation.calc_liou(rho_, h, c_ops_)

Calculates the outcome of applying the Liouvillain to the density matrix. Use to calculated the superoperator form of the Liouvillian.

rho_array

Test states ([1,0,0,……]) as inputs

harray

Hamilton operator

c_ops_array

Collapse operators for the Lindblad dampers

liouarray

mathcal{L} @ rho_

QuantumPolyspectra.simulation.calc_super_A(op)

Calculates the super operator of A as defined in 10.1103/PhysRevB.98.205143

oparray

Operator a for the calculation of A[a]

op_superarray

Superoperator A

QuantumPolyspectra.simulation.calc_super_liou(h_, c_ops)

Calculated the superoperator form of the Liouvillian, by checking one basis state of the desity matrix after the other: [1,0,0…], [0,1,0,0,….], …

h_array

Hamilton operator

c_opsarray

Collapse operators for the Lindblad dampers

op_superarray

Superoperator form of the Liouvillian

QuantumPolyspectra.simulation.cgw(len_y)

Creates an array corresponding to the approx. confined gaussian window function

len_yint

Length of the window

window : array

QuantumPolyspectra.simulation.pickle_save(path, obj)

Helper function to pickle system objects

pathstr

Location of saved data

obj : System obj

QuantumPolyspectra.simulation.plotly(x, y, title, domain, order=None, y_label=None, x_label=None, legend=None, filter_window=None)

Helper function for easy plotting with plotly.

x : array y : array title : str

Plot title

domainstr (‘freq’, ‘time’)

Changes the plot style depending on input in frequency or time domain.

orderint (2, 3, 4)

Order of the spectrum to be shown.

y_labelstr

Label of the y axis

x_labelstr

Label of the x axis

legendlist

List of trace names for the legend.

filter_windowint

For noisy data the spectra can be convoluted with a gaussian of length filter_window

Returns the figure.

QuantumPolyspectra.simulation.second_term(omega1, omega2, omega3, s_k, eigvals, enable_gpu)

For the calculation of the erratum correction terms of the S4. Calculates the second sum as defined in Eq. 109 in 10.1103/PhysRevB.102.119901.

enable_gpubool

Specify if GPU should be used

omega1float

Frequency of interest

omega2float

Frequency of interest

omega3float

Frequency of interest

s_karray

Array calculated with :func:small_s

eigvalsarray

Eigenvalues of the Liouvillian

out_sumarray

Second correction term as defined in Eq. 109 in 10.1103/PhysRevB.102.119901.

QuantumPolyspectra.simulation.small_s(rho_steady, a_prim, eigvecs, eigvec_inv, reshape_ind, enable_gpu, zero_ind, gpu_zero_mat)

For the calculation of the erratum correction terms of the S4. Calculates the small s (Eq. 7) from 10.1103/PhysRevB.102.119901

zero_indint

Index of the steadystate eigenvector

enable_gpubool

Specify if GPU should be used

gpu_zero_mataf array

Zero array stored on the GPU

rho_steadyarray

A @ Steadystate density matrix of the system

a_primarray

Super operator A’ as defined in 10.1103/PhysRevB.98.205143

eigvecsarray

Eigenvectors of the Liouvillian

eigvec_invarray

The inverse eigenvectors of the Liouvillian

reshape_indarray

Indices that give the trace of a flattened matrix.

s_karray

Small s (Eq. 7) from 10.1103/PhysRevB.102.119901

QuantumPolyspectra.simulation.third_term(omega1, omega2, omega3, s_k, eigvals, enable_gpu)

For the calculation of the erratum correction terms of the S4. Calculates the third sum as defined in Eq. 109 in 10.1103/PhysRevB.102.119901.

enable_gpubool

Specify if GPU should be used

omega1float

Frequency of interest

omega2float

Frequency of interest

omega3float

Frequency of interest

s_karray

Array calculated with :func:small_s

eigvalsarray

Eigenvalues of the Liouvillian

out_sumarray

Third correction term as defined in Eq. 109 in 10.1103/PhysRevB.102.119901.

QuantumPolyspectra.simulation.time_series_setup(sc_ops, e_ops)

Creates a dataframe for storing the simulation results.

sc_opsdict

Dictionary with all stochastic collapse operators with corresponding names as keys.

e_opsdict

Dictionary with all operators for the calculation of the expectation values with corresponding names as keys.

Returns a dataframe with columns names like the keys.

QuantumPolyspectra.analysis.c2(a_w, a_w_corr, m, coherent)

calculation of c2 for powerspectrum

QuantumPolyspectra.analysis.c3(a_w1, a_w2, a_w3, m)

calculation of c3 for bispectrum

QuantumPolyspectra.analysis.c4(a_w, a_w_corr, m)

calculation of c4 for trispectrum

QuantumPolyspectra.analysis.calc_a_w3(a_w_all, f_max_ind, m)

Preparation of a_(w1+w2) for the calculation of the bispectrum

QuantumPolyspectra.analysis.import_data(path, group_key, dataset)

Import of .h5 data with format group_key -> data + attrs[dt]