hqs_noise_app
HQS Noise App Python interface.
Copyright © 2021-2024 HQS Quantum Simulations GmbH. All Rights Reserved.
|
Create a new HqsNoiseApp. |
|
Utility for fitting effective open quantum systems to original open quantum systems. |
Functions
|
Given a device and a vector of bath qubits, this function returns a HashMap of the bath qubits and their corresponding broadening. |
Determine the bath excitation spectral function from a given Hamiltonian. |
|
|
Convert a physical coupling as described by a spin/fermion system coupled to a bosonic bath to a spectral function. |
|
Given a device and the length of a chain, this function finds all of the simple chains with the given number of system qubits (length of the chain), where each system qubit has an associated bath qubit. |
|
Given a device and the length of a chain, this function finds all of the simple chains with the given number of system qubits (length of the chain), where each system qubit has two associated bath qubits. |
Integrate a collection of spectral functions (represented by a SpinNoiseBROperator or a FermionBRNoiseOperator) over a set of input frequencies. |
|
|
Create the logical to physical mapping for system qubits and bath qubits, for a bilinear chain. |
|
Create the logical to physical mapping for system qubits and bath qubits, for a trilinear chain. |
|
Given a device and a list of of candidates, this function selects the best chain of system qubits with associated bath qubits in the list of candidates. |
|
Given a device and a list of of candidates, this function selects the best chain of system qubits with associated bath qubits in the list of candidates. |
Convert a spectral function to a physical coupling as described by a Spin-Boson-System or Fermion-Boson-System. |
Classes
|
Utility for fitting effective open quantum systems to original open quantum systems. |
|
A general struct encoding a spectral function coupled to a fermion system. |
|
Create a new HqsNoiseApp. |
|
A general struct encoding a spectral function coupled to a spin system. |
- class hqs_noise_app.BathFitter(number_boson_modes: int, spins_per_bosonic_mode: int = 1, broadening_constraint: List[float] | None = None, background_broadening_ratio: float = 0.0, minimum_eigenfrequencies: float | None = None, maximum_eigenfrequencies: float | None = None, fitting_window: Tuple[float, float, int] | None = None, coupling_types: Dict[Tuple[int, int], List[str]] | List[str] | None = None, coupling_indices: List[Tuple[int, int]] | None = None, max_fitting_iterations: int = 5, max_fitting_error: float = 0.05)[source]
Utility for fitting effective open quantum systems to original open quantum systems.
- fit_boson_bath_to_boson_bath(original_system: MixedLindbladOpenSystem, frequencies: ndarray) Tuple[MixedLindbladOpenSystem, float | None] [source]
Fits a model Spin-Boson system to an original Spin-Boson system.
- Parameters:
original_system (MixedLindbladOpenSystem) -- The spin-boson system bath model the effective model is fitted to
frequencies (ndarray) -- The frequencies for the spectral functions that is calculated from the Bosonic bath
- Returns:
- The Spin-Boson system and
for constrained broadenings the fitted prefactor.
- Return type:
(MixedHamiltonianSystem, Optional[float])
- fit_boson_bath_to_fermion_bath(original_system: MixedHamiltonianSystem, temperature: float, number_frequency_points: int) Tuple[Tuple[MixedLindbladOpenSystem, float | None], List[float]] [source]
Fits a model Spin-Boson system to an original Spin-Fermion system.
- Parameters:
original_system (MixedHamiltonianSystem) -- The spin-fermion system bath model the effective model is fitted to
temperature (float) -- The fermionic bath temperature assumed to obtain the spectral function
number_frequency_points (int) -- The number of frequency points used to discretize the spectral function obtained from the Fermion bath
- Returns:
- The Spin-Boson system,
the fitted prefactor (for constrained broadenings) and the corresponding frequencies.
- Return type:
((MixedLindbladOpenSystem, Optional[float]), List[float])
- fit_boson_bath_to_spectral_function(spin_system: SpinHamiltonianSystem, spectral_function: SpinBRNoiseOperator) Tuple[MixedLindbladOpenSystem, float | None] [source]
Fits a model Spin-Boson system to a Spin spectral function.
- Parameters:
spin_system (SpinHamiltonianSystem) -- The coherent spin system for which the spectral function determines the noise
spectral_function (SpinBRNoiseOperator) -- The Bloch-Redfield type spectral function that determines the decoherence in the open system the effective system is fitted to.
- Returns:
- The Spin-Boson system and
for constrained broadenings the fitted prefactor.
- Return type:
(MixedLindbladOpenSystem, Optional[float])
- fit_fermion_boson_system_to_fermion_boson_system(original_system: MixedLindbladOpenSystem, frequencies: ndarray) Tuple[MixedLindbladOpenSystem, float | None] [source]
Fits a model Fermion-Boson system to an original Fermion-Boson system.
- Parameters:
original_system (MixedLindbladOpenSystem) -- The fermion-boson system bath model the effective model is fitted to
frequencies (ndarray) -- The frequencies for the spectral functions that is calculated from the Bosonic bath
- Returns:
- The Fermion-Boson system and
for constrained broadenings the fitted prefactor.
- Return type:
(MixedHamiltonianSystem, Optional[float])
- fit_fermion_boson_system_to_spectral_function(fermionic_system: FermionHamiltonianSystem, spectral_function: FermionBRNoiseOperator) Tuple[MixedLindbladOpenSystem, float | None] [source]
Fits a model Fermion-Boson system to a Fermion spectral function.
- Parameters:
fermion_system (FermionHamiltonianSystem) -- The coherent fermion system for which the spectral function determines the noise
spectral_function (FermionBRNoiseOperator) -- The Bloch-Redfield type spectral function that determines the decoherence in the open system the effective system is fitted to.
- Returns:
- The Fermion-Boson system and
for constrained broadenings the fitted prefactor.
- Return type:
(MixedLindbladOpenSystem, Optional[float])
- fit_fermion_spin_system_to_fermion_boson_system(noise_app: Any, original_system: MixedLindbladOpenSystem, frequencies: ndarray, device: Any) Tuple[MixedHamiltonianSystem, float | None] [source]
Fits a model Fermion-Spin system to an original Fermion-Boson system.
- Parameters:
noise_app (HqsNoiseApp) -- The noise app used to construct simulation programs from the result of the fitting
original_system (MixedLindbladOpenSystem) -- The fermion-boson system bath model the effective model is fitted to
frequencies (ndarray) -- The frequencies for the spectral functions is calculated from the Bosonic bath
device (Device) -- The qoqo device on which the fermion-spin system bath model should be simulated. Used to calculate the circuit depth necessary to determine the Trotter timestep
- Returns:
- The Fermion-Spin system and
for constrained broadenings the trotter timestep that fixes the correct broadening prefactor.
- Return type:
(MixedHamiltonianSystem, Optional[float])
- fit_spin_bath_to_boson_bath(noise_app: Any, original_system: MixedLindbladOpenSystem, frequencies: ndarray, device: Any) Tuple[MixedHamiltonianSystem, float | None] [source]
Fits a model Spin-Spin system to an original Spin-Boson system.
- Parameters:
noise_app (HqsNoiseApp) -- The noise app used to construct simulation programs from the result of the fitting
original_system (MixedLindbladOpenSystem) -- The spin-boson system bath model the effective model is fitted to
frequencies (ndarray) -- The frequencies for the spectral functions is calculated from the Bosonic bath
device (Device) -- The qoqo device on which the spin-spin system bath model should be simulated. Used to calculate the circuit depth necessary to determine the Trotter timestep
- Returns:
- The Spin-Spin system and
for constrained broadenings the trotter timestep that fixes the correct broadening prefactor.
- Return type:
(MixedHamiltonianSystem, Optional[float])
- fit_spin_bath_to_fermion_bath(noise_app: Any, original_system: MixedHamiltonianSystem, temperature: float, number_frequency_points: int, device: Any) Tuple[Tuple[MixedHamiltonianSystem, float | None], List[float]] [source]
Fits a model Spin-Spin system to an original Spin-Fermion system.
- Parameters:
noise_app (HqsNoiseApp) -- The noise app used to construct simulation programs from the result of the fitting
original_system (MixedHamiltonianSystem) -- The spin-fermion system bath model the effective model is fitted to
temperature (float) -- The fermionic bath temperature assumed to obtain the spectral function
number_frequency_points (int) -- The number of frequency points used to discretize the spectral function opained from the Fermion bath
device (Device) -- The qoqo device on which the spin-spin system bath model should be simulated. Used to calculate the circuit depth necessary to determine the Trotter timestep
- Returns:
- The Spin-Spin system,
the trotter timestep that fixes the correct broadening prefactor for constrained broadenings, and the corresponding frequencies.
- Return type:
((MixedHamiltonianSystem, Optional[float]), List[float])
- fit_spin_bath_to_spectral_function(noise_app: Any, spin_system: SpinHamiltonianSystem, spectral_function: SpinBRNoiseOperator, device: Any) Tuple[MixedHamiltonianSystem, float | None] [source]
Fits a model Spin-Spin system to a Spin spectral function.
- Parameters:
noise_app (HqsNoiseApp) -- The noise app used to construct simulation programs from the result of the fitting
spin_system (SpinHamiltonianSystem) -- The coherent spin system for which the spectral function determines the noise
spectral_function (SpinBRNoiseOperator) -- The Bloch-Redfield type spectral function that determines the decoherence in the open system the effective system is fitted to.
device (Device) -- The qoqo device on which the spin-spin system bath model should be simulated. Used to calculate the circuit depth necessary to determine the Trotter timestep
- Returns:
- The Spin-Spin system and
for constrained broadenings the trotter timestep that fixes the correct broadening prefactor.
- Return type:
(MixedHamiltonianSystem, Optional[float])
- classmethod from_json(json_dict: Dict[str, Any]) BathFitter [source]
Initializes the object from a JSON representation.
- Parameters:
json_dict (Dict[str, Any]) -- JSON representation of the object.
- property last_fitted_broadenings: List[float] | None
The broadenings from the last fit of the spectrum.
- Returns:
The broadenings if a fit has been performed.
- Return type:
Optional[List[float]]
- property max_fitting_error: float
The maximum allowed fitting error in fitting the spectrum.
The bath fitter uses a simple metric for the quality of the fit: Let A be the sum of squares of the difference between the fitter and target and B be the sum of squares of the fitted spectral function. The quality of the fit is defined as the ratio A/B where a small ratio corresponds to a good fit. By default, a deviation of 5% is allowed. If the criterion is not met, the fitting is retried and if the number of retries exceeds the maximum the fit fails. By default, the number of retries is 5. This value can be changed using the max_fitting_iterations setter.
- Returns:
The maximum allowed fitting error as a ratio between spectrum deviation and the spectrum.
- Return type:
(float)
- property max_fitting_iterations: int
The number of retries allowed when fitting the spectrum.
The bath fitter uses a simple metric for the quality of the fit: Let A be the sum of squares of the difference between the fitter and target, and B be the sum of squares of the fitted spectral function. The quality of the fit is defined as the ratio A/B where a small ratio corresponds to a good fit. By default, a deviation of 5% is allowed. This value can be changed using the max_fitting_error setter. If the criterion is not met, the fitting is retried and if the number of retries exceeds the maximum, the fit fails.
- Returns:
The number of retries allowed when fitting the spectrum.
- Return type:
(int)
- spin_bath_trotterstep_from_boson_bath(noise_app: Any, spin_boson_system: MixedLindbladOpenSystem, prefactor: float | None, device: Any) Tuple[MixedHamiltonianSystem, float | None] [source]
Creates Spin-Spin Hamiltonian and Trotterstep from Spin-Boson system.
Converts a Spin-Boson open system and a fitting prefactor for the Bosonic mode broadening to a Spin-Spin system and a Trotter timestep that can be used to construct a quantum circuit to simulate the Spin part of the Spin-Boson circuit with an effective bath.
- Parameters:
noise_app (HqsNoiseApp) -- The noise app used to construct simulation programs from the result of the fitting
spin_boson_system (MixedLindbladOpenSystem) -- The Spin-Boson open system that is transformed to a Spin-Spin system
prefactor (Optional[float]) -- The fitted prefactor of the bosonic mode broadenings Is used to derive the Trotter timestep
device (Device) -- The qoqo device on which the spin-spin system bath model should be simulated. Used to calculate the circuit depth necessary to determine the Trotter timestep
- Returns:
- The Spin-Spin system and
for constrained broadenings the trotter timestep that fixes the correct broadening prefactor.
- Return type:
(MixedHamiltonianSystem, Optional[float])
- class hqs_noise_app.FermionBRNoiseOperator(frequencies)
A general struct encoding a spectral function coupled to a fermion system.
Can be used for many cases where a continuous function is coupled to a FermionSystem by up to two fermion operators.
Examples include:
The Bloch-Redfield spectral function
The effective temperature of a spectral function
- Parameters:
frequencies (List[float]) -- The frequencies on which the spectral functions are defined
- frequencies()
Get the frequencies the spectral function is defined for.
- Returns:
The start and end points of the frequencies.
- Return type:
List[float]
- from_bincode()
Convert the bincode representation of the FermionBRNoiseOperator to a FermionBRNoiseOperator using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized FermionBRNoiseOperator (in [bincode] form).
- Returns:
The deserialized FermionBRNoiseOperator.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to FermionBRNoiseOperator.
- from_json()
Convert the json representation of a FermionBRNoiseOperator to a FermionBRNoiseOperator.
- Parameters:
input (str) -- The serialized FermionBRNoiseOperator in json form.
- Returns:
The deserialized FermionBRNoiseOperator.
- Return type:
- Raises:
ValueError -- Input cannot be deserialized to FermionBRNoiseOperator.
- get()
Get the spectral function for a pair of FermionProducts.
- Parameters:
key (string, string) -- The string representation of the pair of FermionProducts for which to get the spectral function.
- Returns:
The spectral function for the input key.
- Return type:
List[complex]
- Raises:
ValueError -- Could not convert left key input to FermionProduct.
ValueError -- Could not convert right key input to FermionProduct.
- get_imag()
Get the imaginary part of the spectral function for a pair of FermionProducts.
- Parameters:
key (string, string) -- The string representation of the pair of FermionProducts for which to get the spectral function.
- Returns:
The imaginary part of the spectral function for the input key.
- Return type:
List[float]
- Raises:
ValueError -- Could not convert left key input to FermionProduct.
ValueError -- Could not convert right key input to FermionProduct.
- get_real()
Get the real part of the spectral function for a pair of FermionProducts.
- Parameters:
key (string, string) -- The string representation of the pair of FermionProducts for which to get the spectral function.
- Returns:
The real part of the spectral function for the input key.
- Return type:
List[float]
- Raises:
ValueError -- Could not convert left key input to FermionProduct.
ValueError -- Could not convert right key input to FermionProduct.
- get_spectral_function_matrix(number_fermions)
Get the matrix of the spectral function of a fermion-system at a specific energy index.
Assumes that the FermionBRNoiseOperator represents the spectral function coupled to a fermion system. A real spectral function needs to be symmetric in the coupling indices. The method will fail if the FermionBRNoiseOperator is not symmetric.
- Parameters:
spectral_function_index (int) -- The frequency index for which the matrix is returned
number_fermions (int) -- The number of fermions in the system.
- Returns:
the resulting complex matrix representation of the spectral function at the specified energy index.
- Return type:
np.ndarray
- Raises:
ValueError -- Spectral function matrix is not symmetric.
- resample()
Resample the FermionBRNoiseOperator on a new set of frequencies.
The function makes the base assumption that the spectra are flat within each bin corresponding to the original frequencies. To resample the original function is integrated and interpolated at the new frequencies.
- Parameters:
frequencies (List[float]) -- The new frequencies for which every datapoint in the spectral function is defined.
- Returns:
The resampled FermionBRNoiseOperator.
- Return type:
- Raises:
ValueError -- Cannot use resample_interpolate to extrapolate. Current minimum frequency is larger than new minimum frequency.
- resample_interpolate()
Resample the FermionBRNoiseOperator on a new set of frequencies by linear interpolation.
- Parameters:
frequencies (List[float]) -- The new frequencies for which every datapoint in the spectral function is defined.
- Returns:
The resampled FermionBRNoiseOperator.
- Return type:
- Raises:
ValueError -- Cannot use resample_interpolate to extrapolate. Current minimum frequency is larger than new minimum frequency.
- set(spectral_function, /)
Set the value of a spectral function for the input frequencies and a set of FermionProduct.
- Parameters:
key (string, string) -- The string representation of the pair of FermionProducts for which to set the spectral function.
spectral_function (List[float]) -- The frequency resolved spectral function as a vector of complex numbers.
- Raises:
ValueError -- Could not convert left key input to FermionProduct.
ValueError -- Could not convert right key input to FermionProduct.
ValueError -- Spectral function must define a value for each frequency.
- set_imag(spectral_function, /)
Set the imaginary part of the value of a spectral function for the input frequencies and a set of FermionProducts.
- Parameters:
key (string, string) -- The string representation of the pair of FermionProducts for which to set the spectral function.
spectral_function (List[float]) -- The frequency resolved spectral function as a vector of complex numbers.
- Raises:
ValueError -- Could not convert left key input to FermionProduct.
ValueError -- Could not convert right key input to FermionProduct.
ValueError -- Spectral function must define a value for each frequency.
- set_real(spectral_function, /)
Set the real part of the value of a spectral function for the input frequencies and a set of FermionProducts.
- Parameters:
key (string, string) -- The string representation of the pair of FermionProducts for which to set the spectral function.
spectral_function (List[float]) -- The frequency resolved spectral function as a vector of complex numbers.
- Raises:
ValueError -- Could not convert left key input to FermionProduct.
ValueError -- Could not convert right key input to FermionProduct.
ValueError -- Spectral function must define a value for each frequency.
- to_bincode()
Return the bincode representation of the FermionBRNoiseOperator using the [bincode] crate.
- Returns:
The serialized FermionBRNoiseOperator (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize FermionBRNoiseOperator to bytes.
- to_json()
Return the json representation of the FermionBRNoiseOperator.
- Returns:
The serialized form of FermionBRNoiseOperator.
- Return type:
str
- Raises:
ValueError -- Cannot serialize FermionBRNoiseOperator to json.
- class hqs_noise_app.HqsNoiseApp(noise_mode)
Create a new HqsNoiseApp.
Example
>>> from hqs_noise_app import HqsNoiseApp ... noise_app = HqsNoiseApp("active_qubits_only", ["RotateX", "RotateY", "RotateZ"], "ControlledPauliZ")
- Parameters:
noise_mode (str) --
The option for the noise mode that is set. Available options:
all_qubits - The noise model adds noise on all qubits that are involved in the whole quantum circuit after each gate operation. active_qubits_only - The noise model only adds noise on the qubits that are actively involved in the gate operation after each operation. parallelization_blocks - Parallelizes operations into blocks assuming that device supports it.
After each block of parallel operations noise is applied to all qubits
- Returns:
A new HqsNoiseApp object with provided input parameters.
- Raises:
ValueError -- Option not available.
- add_noise(program, device, noise_models)
Adds device specific noise to QuantumProgram created by HQSNoiseApp
- Parameters:
program (QuantumProgram) -- QuantumProgram without noise PRAGMA operations.
device (qoqo.Device) -- Device defining the connectivity and available gates.
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
- The QuantumProgram with added noise in the form of noise PRAGMA operations
in the circuits in the program
- Return type:
QuantumProgram
- Raises:
RuntimeError -- Inserting noise failed.
- after_trotter_wait_time()
Change the value of option after_trotter_wait_time. The prefered way of accessing this attribute is using the getter/setter wait_time_after_trotterstep.
When not None, this introduces an additional physical wait time after the Trotter circuit has been applied. This can be used to introduce additional decoherence when the decoherence in the Trotter step is too low or is dominated by the wrong type of decoherence compared to the background decoherence processes that are active during wait time.
- Parameters:
after_trotter_wait_time (Optional[float]) -- The option for the after_trotter_wait_time that is set
- algorithm()
Changes the algorithm setting for HqsNoiseApp The prefered way of accessing this attribute is using the getter/setter time_evolution_algorithm.
- Four Options are available:
- ParityBased: An algorithm that implements the time evolution under a product of PauliOperators
via the total Parity of the set of involved qubits. The total parity is perpared in the last involved qubit.
- QSWAP: Terms in the Hamiltonian involving two qubits are implemented using a swap network
that reorders the terms. Uses the ParityBased algorithm for multi qubit terms.
- QSWAPMolmerSorensen: The QSWAP algorithm using variable angle Mølmer Sørensen XX interaction
gates
- VariableMolmerSorensen: An algorithm that implements terms in the Hamiltonian
involving two qubits with a basis change and variable angle Mølmer Sørensen gates
- Parameters:
algorithm (str) -- The option for the algorithm that is set
- apply_virtual_z(program, device, noise_models)
Applied the virtual Z replacement optimization to the given QuantumProgram.
On platforms where the RotateXY gate is available and the natural two-qubit gate is diagonal in the Z-basis, RotateZ gates can be replaced by virtual changes (rotations) of the qubit basis in the XY-Plane. This is also referred to as VirtualRotateZ gates optimisation.
- Parameters:
program (QuantumProgram) -- QuantumProgram containing RotateZ gates to be transformed.
device (qoqo.Device) -- Device defining the connectivity and available gates.
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
The QuantumProgram with the VirtualZ replacement applied to the circuits in the program.
- Return type:
QuantumProgram
- Raises:
RuntimeError -- Inserting noise failed.
- bath_qubits_as_control_qubits
Setter for the value of option use_bath_as_control
Use bath qubits as control when solving system-bath problems and interacting between system and bath qubits with CNOT operations. Only used when using the ParityBased or QSWAP algorithm options for system_bath problems.
- Parameters:
use_bath_as_control (str) -- The new value
- estimate_decoherence_rate(trotter_timestep, device)
Calculates an estimate of the overall decoherence rate of the problem.
This will not perform full noise mapping but estimate the overall decoherence rate of the problem by summing up the decoherence rates of the individual noise contributions between the unitary gates, using the fact that the trace over the decoherence matris is invariant under unitary transformations.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.spins import PauliProduct, SpinHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = SpinHamiltonianSystem(3) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(0).x(1), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(1).x(2), 1.0) ... ... device = AllToAllDevice(4, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... rate = noise_app.estimate_decoherence_rate(hamiltonian, 0.001, device)
- Parameters:
hamiltonian (SpinHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
The estimated decoherence rate.
- Return type:
CalculatorFloat
- Raises:
ValueError -- Could not convert hamiltonian input.
ValueError -- Could not convert device input.
RuntimeError -- Extracting effective noise model failed.
TypeError -- Wrong input type for noisy_algorithm_model.
- static from_bincode(input)
Convert the bincode representation of the HqsNoiseApp to a HqsNoiseApp using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized HqsNoiseApp (in [bincode] form).
- Returns:
The deserialized HqsNoiseApp.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to HqsNoiseApp.
- static from_json(input)
Convert the json representation of a HqsNoiseApp to a HqsNoiseApp.
- Parameters:
input (str) -- The serialized HqsNoiseApp in json form.
- Returns:
The deserialized HqsNoiseApp.
- Return type:
- Raises:
ValueError -- Input cannot be deserialized to HqsNoiseApp.
- level_of_optimization
Setter for the optimization level for HqsNoiseApp
- Parameters:
optimization_level (int) -- The level of optimization when performing the algorithm. At level 0 no optimizations are applied. At level 1 SingleQubitGates are combined.
- Returns:
Updated HqsNoiseApp object with the modified optimization setting.
- Raises:
ValueError -- Option not available.
- noise_insertion_mode
Setter for the noise mode setting for HQSNoiseApp
- Posible options are:
all_qubits: The noise model adds noise on all qubits that are involved in the whole quantum circuit after each gate operation active_qubits_only: The noise model only adds noise on the qubits that are actively involved in the gate operation after each operation.
- Parameters:
noise_mode (str) --
The option for the noise mode that is set. Available options:
all_qubits - The noise model adds noise on all qubits that are involved in the whole quantum circuit after each gate operation. active_qubits_only - The noise model only adds noise on the qubits that are actively involved in the gate operation after each operation. parallelization_blocks - Parallelizes operations into blocks assuming that device supports it.
After each block of parallel operations noise is applied to all qubits
- noise_insertion_placement
Setter the noise placement setting for HQSNoiseApp
- Posible options are:
after: The noise is applied after the gate based on gate duration symmetric: The noise is applied before and after the gate based on gate duration
- Parameters:
noise_mode -- The option for the noise placement that is set
- noise_mode()
Changes the noise mode setting for HQSNoiseApp The prefered way of accessing this attribute is using the getter/setter noise_insertion_mode.
- Posible options are:
all_qubits: The noise model adds noise on all qubits that are involved in the whole quantum circuit after each gate operation active_qubits_only: The noise model only adds noise on the qubits that are actively involved in the gate operation after each operation.
- Parameters:
noise_mode (str) --
The option for the noise mode that is set. Available options:
all_qubits - The noise model adds noise on all qubits that are involved in the whole quantum circuit after each gate operation. active_qubits_only - The noise model only adds noise on the qubits that are actively involved in the gate operation after each operation. parallelization_blocks - Parallelizes operations into blocks assuming that device supports it.
After each block of parallel operations noise is applied to all qubits
- noise_placement()
Changes the noise placement setting for HQSNoiseApp The prefered way of accessing this attribute is using the getter/setter noise_insertion_placement.
- Posible options are:
after: The noise is applied after the gate based on gate duration symmetric: The noise is applied before and after the gate based on gate duration
- Parameters:
noise_mode -- The option for the noise placement that is set
- noise_symmetrization()
Set the noise symmetrization option for HqsNoiseApp The prefered way of accessing this attribute is using the getter/setter use_noise_symmetrization.
Noise symmetrization controls whether the Trotterstep is symmetrized with respect to damping noise. When the overall noise has the tendency to favor one state |0> or |1>, the Trotterstep can be symmetrized by doubling the Trotter circuit and flipping the definition of |0> and |1> for the second circuit. This process will bring the effective noise closer to a balanced noise at the cost of incuring larger decoherence overall.
- Parameters:
noise_symmetrization (bool) -- The option for the noise symmetrization that is set
- noisy_algorithm_model(trotter_timestep, device)
Returns the noisy algorithms noise model derived for a given Hamiltonian.
Constructs the quantum circuit for a time propagating under a Hamiltonian with the algorithm parameters set in the HQSNoiseApp. Performs the noise mapping from discrete noise operations after each operation in the circuit to the effective noise model. The function will automatically compile the Circuit to the available one and two-qubit gates, and apply noise.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.spins import PauliProduct, SpinHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = SpinHamiltonianSystem(3) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(0).x(1), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(1).x(2), 1.0) ... ... device = AllToAllDevice(4, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... noise_model = noise_app.noisy_algorithm_model(hamiltonian, 0.001, device)
Note that the superoperator corresponds to the continuous time evolution of a density matrix but has been derived from a Trotterstep with a discrete time-step. This approximation is only valid if the time-step is short enough compared to the energy scales in the system that the Trotterization errors of the unitary evolution and the noise terms are small.
- Parameters:
hamiltonian (SpinHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
The noise model.
- Return type:
SpinLindbladNoiseSystem
- Raises:
ValueError -- Could not convert hamiltonian input.
ValueError -- Could not convert device input.
RuntimeError -- Extracting effective noise model failed.
TypeError -- Wrong input type for noisy_algorithm_model.
- number_measurements()
Changes the number of projective measurements used when measuring observables. The prefered way of accessing this attribute is using the getter/setter number_of_measurments.
- Parameters:
number_measurements (int) -- The new number of measurements
- number_of_measurements
Setter for the number of projective measurements used when measuring observables
- Parameters:
number_measurements (int) -- The new number of measurements
- optimization_level()
The prefered way of accessing this attribute is using the getter/setter level_of_optimization.
- Parameters:
optimization_level (int) -- The level of optimization when performing the algorithm. At level 0 no optimizations are applied. At level 1 SingleQubitGates are combined.
- Returns:
Updated HqsNoiseApp object with the modified optimization setting.
- Raises:
ValueError -- Option not available.
- order_of_trotterization
Setter for the Trotterization order for HqsNoiseApp
Second order Trotterization order is only supported for the circuit function using the
ParityBased
andVariableMolmerSorensen
algorithm option. SWAP based algorithms and thesystem_bath
methods only support first order Trotterization- Parameters:
trotterization_order (int) -- The new trotterization order, that can be 1 or 2. In the case of the CNOT algorithm it gives the order to which the terms in the Suzuki-Trotter decomposition are kept.
- Returns:
Updated HqsNoiseApp object with the modified trotterization order setting.
- Raises:
ValueError -- Option not available.
- quantum_program(hamiltonian, trotter_timestep, initialisation, measured_operators, operator_names, device)
Creates a qoqo QuantumProgram for observable measurement after time propagation.
The QuantumProgram will
Initialize a spin state on a quantum computer
Time propagte the spin state with a quantum algorithm
Measure the values of spin observables
The parameters of the algorithm are taken from the NoiseApp. The hamiltonian, observables and the device the QuantumProgram is created for are parameters of the function.
The initialisation is not universal, but limited to manipulating single spins.
For a N-qubit probem the state starts out in N times |0> or |spin-up>. The initialisation proved N float values. One fj for each spin j. For each qubit j a RotateY(j, f * pi) is applied. So an fj value of 1.0 would flip the spin j from |spin-up> to |spin-down>
Note that a device needs to have at least N qubits or no quantum program can be constructed.
- Parameters:
hamiltonian (SpinHamiltonianSystem) -- The Spin Hamiltonian.
trotter_timestep (float) -- One Trotterstep propagates the system under the hamiltonian for this time. Smallest time increment when running simulations.
initialisation (List[float])
measured_operators (List[SpinSystem]) -- All the observables that are measured.
operator_names (List[str]) -- The names of the measured operators.
device (qoqo.Device) -- The device determining topology and noise.
- Returns:
the created quantum program from inputs.
- Return type:
QuantumProgram
- Raises:
TypeError -- Could not convert hamiltonian input.
TypeError -- Could not convert device input.
TypeError -- Could not convert measured_operators input.
- simulate_quantum_program(program, number_trottersteps, device, noise_models, number_qubits)
Inserts device noise and runs QuantumProgram on simulator backend.
The function assumes that the input circuit applies one Trotterstep to an initial state of the quantum computer. It will automatically compile the Circuit to the available one and two-qubit gates, apply noise and simulate the execution of the circuit with the [roqoqo_quest] QC simulator.
- Parameters:
program (QuantumProgram) -- The QuantumProgram for
number_trotterstep (int) -- The number of times a Trotterstep is applied. The total propagated time is number of Trottersteps times the fixed trotterstep compiled into the QuantumProgram.
device (qoqo.Device) -- The device determining noise
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
number_qubits (int) -- The number qubits that should be used in the Simulator backend.
- Returns:
The expecation values from the quantum program.
- Return type:
Dict[str, float]
- Raises:
RuntimeError -- Simulating time evolution failed.
- system_bath_estimate_decoherence_rate(trotter_timestep, device, logical_to_physical_system, logical_to_physical_bath, bath_qubit_connectivity)
Calculates an estimate of the overall decoherence rate of the problem.
This will not perform full noise mapping but estimate the overall decoherence rate of the problem by summing up the decoherence rates of the individual noise contributions between the unitary gates, using the fact that the trace over the decoherence matris is invariant under unitary transformations.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.mixed_systems import HermitianMixedProduct, MixedHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = MixedHamiltonianSystem([3, 3], [], []) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["0X1X", ""], [], []), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["1X2X", ""], [], []), 1.0) ... hamiltonian.set(HermitianMixedProduct(["0Z", "0Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["1Z", "1Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["2Z", "2Z"], [], []), 0.1) ... device = AllToAllDevice(9, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... rate = noise_app.system_bath_estimate_decoherence_rate(hamiltonian, 0.001, device) ```
Note that a device needs to have at least N qubits or no quantum program can be constructed.
- Parameters:
hamiltonian (MixedHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
logical_to_physical_system (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the system.
logical_to_physical_bath (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the bath.
bath_qubit_connectivity (Optional[Dict[int, List[int]]]) -- Optional connectivity between physical system and bath qubits.
- Returns:
The noise model.
- Return type:
SpinLindbladNoiseSystem
- Raises:
TypeError -- Could not convert hamiltonian input.
TypeError -- Input device is not a qoqo device.
TypeError -- Input noise models is not a list of qoqo noise models.
RuntimeError -- Extracting estimated decoherence rate failed.
- system_bath_execution_time(trotter_timestep, device, logical_to_physical_system, logical_to_physical_bath, bath_qubit_connectivity)
Returns the execution time of one Trotterstep.
Constructs the quantum circuit for a time propagating under a Hamiltonian with the algorithm parameters set in the HQSNoiseApp. The function will automatically compile the Circuit to the available one and two-qubit gates, and apply noise.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.mixed_systems import HermitianMixedProduct, MixedHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = MixedHamiltonianSystem([3, 3], [], []) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["0X1X", ""], [], []), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["1X2X", ""], [], []), 1.0) ... hamiltonian.set(HermitianMixedProduct(["0Z", "0Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["1Z", "1Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["2Z", "2Z"], [], []), 0.1) ... device = AllToAllDevice(9, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... _noise_model_execution_time = noise_app.system_bath_execution_time(hamiltonian, 0.001, device) ```
The number of qubits in the problem depends on the number of spins in system and bath and the algorithm chosen. For a QSWAP algorithms the number of qubits is three times the maximum of the number of system spins Nsys and the number of bath spins Nbath devided by 2. N = 3 * max(Nsys, Nbath / 2).
Note that a device needs to have at least N qubits or no quantum program can be constructed.
- Parameters:
hamiltonian (MixedHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
logical_to_physical_system (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the system.
logical_to_physical_bath (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the bath.
bath_qubit_connectivity (Optional[Dict[int, List[int]]]) -- Optional connectivity between physical system and bath qubits.
- Returns:
SpinLindbladNoiseSystem The noise model.
- Raises:
TypeError -- Could not convert hamiltonian input.
RuntimeError -- Extracting effective noise model failed.
- system_bath_noisy_algorithm_model(trotter_timestep, device, logical_to_physical_system, logical_to_physical_bath, bath_qubit_connectivity)
Returns the noisy algorithms noise model derived for a given Hamiltonian.
Constructs the quantum circuit for a time propagating under a Hamiltonian with the algorithm parameters set in the HQSNoiseApp. Performs the noise mapping from discrete noise operations after each operation in the circuit to the effective noise model. The function will automatically compile the Circuit to the available one and two-qubit gates, and apply noise.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.mixed_systems import HermitianMixedProduct, MixedHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = MixedHamiltonianSystem([3, 3], [], []) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["0X1X", ""], [], []), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["1X2X", ""], [], []), 1.0) ... hamiltonian.set(HermitianMixedProduct(["0Z", "0Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["1Z", "1Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["2Z", "2Z"], [], []), 0.1) ... device = AllToAllDevice(9, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... _noise_model = noise_app.system_bath_noisy_algorithm_model(hamiltonian, 0.001, device) ```
Note that the superoperator corresponds to the continuous time evolution of a density matrix but has been derived from a Trotterstep with a discrete time-step. This approximation is only valid if the time-step is short enough compared to the energy scales in the system that the Trotterization errors of the unitary evolution and the noise terms are small.
The number of qubits in the problem depends on the number of spins in system and bath and the algorithm chosen. For a QSWAP algorithms the number of qubits is three times the maximum of the number of system spins Nsys and the number of bath spins Nbath devided by 2. N = 3 * max(Nsys, Nbath / 2).
Note that a device needs to have at least N qubits or no quantum program can be constructed.
- Parameters:
hamiltonian (MixedHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
logical_to_physical_system (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the system.
logical_to_physical_bath (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the bath.
bath_qubit_connectivity (Optional[Dict[int, List[int]]]) -- Optional connectivity between physical system and bath qubits.
- Returns:
The noise model.
- Return type:
SpinLindbladNoiseSystem
- Raises:
TypeError -- Could not convert hamiltonian input.
RuntimeError -- Extracting effective noise model failed.
- system_bath_quantum_program(trotter_timestep, initialisation, measured_operators, operator_names, device, logical_to_physical_system, logical_to_physical_bath, bath_qubit_connectivity)
Creates a qoqo QuantumProgram for observable measurement after time propagation.
The QuantumProgram will
Initialize a spin state on a quantum computer
Time propagte the spin state with a quantum algorithm
Measure the values of spin observables
The parameters of the algorithm are taken from the NoiseApp. The hamiltonian, observables and the device the QuantumProgram is created for are parameters of the function.
The initialisation is not universal, but limited to manipulating single spins.
For a N-qubit probem the state starts out in N times |0> or |spin-up>. The initialisation proved N float values. One fj for each spin j. For each qubit j a RotateY(j, f * pi) is applied. So an fj value of 1.0 would flip the spin j from |spin-up> to |spin-down>
The number of qubits in the problem depends on the number of spins in system and bath and the algorithm chosen. For a QSWAP algorithms the number of qubits is three times the maximum of the number of system spins Nsys and the number of bath spins Nbath devided by 2. N = 3 * max(Nsys, Nbath / 2).
Note that a device needs to have at least N qubits or no quantum program can be constructed.
- Parameters:
hamiltonian (MixedHamiltonianSystem) -- The Spin Hamiltonian.
trotter_timestep (float) -- One Trotterstep propagates the system under the hamiltonian for this time. Smallest time increment when running simulations.
initialisation (List[float])
measured_operators (List[SpinSystem]) -- All the observables that are measured.
operator_names (List[str]) -- The names of the measured operators.
device (qoqo.Device) -- The device determining topology and noise.
logical_to_physical_system (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the system.
logical_to_physical_bath (Optional[Dict[int, int]]) -- Optional mapping from logical to physical qubits for the bath.
bath_qubit_connectivity (Optional[Dict[int, List[int]]]) -- Optional connectivity between physical system and bath qubits.
- Returns:
the created system-bath quantum program.
- Return type:
QuantumProgram
- Raises:
TypeError -- Could not convert hamiltonian input.
TypeError -- Could not convert device input.
TypeError -- Could not convert measured_operators input.
RuntimeError -- QuantumProgram creation failed.
- system_bath_trotter_circuit(trotter_timestep, system_bath_physical_definition)
Returns the circuit that implements one Trotter step.
The number of qubits in the problem depends on the number of spins in system and bath and the algorithm chosen. For a QSWAP algorithms the number of qubits is three times the maximum of the number of system spins Nsys and the number of bath spins Nbath devided by 2. N = 3 * max(Nsys, Nbath / 2).
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.mixed_systems import HermitianMixedProduct, MixedHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = MixedHamiltonianSystem([3, 3], [], []) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["0X1X", ""], [], []), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["1X2X", ""], [], []), 1.0) ... hamiltonian.set(HermitianMixedProduct(["0Z", "0Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["1Z", "1Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["2Z", "2Z"], [], []), 0.1) ... ... circuit = noise_app.system_bath_trotter_circuit(hamiltonian, 0.001)
- Parameters:
hamiltonian (MixedHamiltonianSystem) -- The Hamiltonian for which the circuit is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system.
system_bath_physical_definition (Tuple[List[int], List[int], Optional[Dict[int, List[int]]]]) -- A combination of lists defining the mapping of system and bath qubits to physical qubits.
- Returns:
The circuit that implements one Trotter step.
- Return type:
Circuit
- Raises:
TypeError -- Could not convert hamiltonian input.
RuntimeError -- Creating the circuit for one Trotter step failed.
- system_bath_trotter_circuit_depth(trotter_timestep, device, system_bath_physical_definition)
Returns the depth of the circuit that implements one Trotter step.
The depth of the circuit strongly depends on the device parameters and the chosen optimisations. The function constructs the circuit for one Trotter step and determines the depth.
The number of qubits in the problem depends on the number of spins in system and bath and the algorithm chosen. For a QSWAP algorithms the number of qubits is three times the maximum of the number of system spins Nsys and the number of bath spins Nbath devided by 2. N = 3 * max(Nsys, Nbath / 2).
Note that a device needs to have at least N qubits or no circuit depth can be constructed.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.mixed_systems import HermitianMixedProduct, MixedHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = MixedHamiltonianSystem([3, 3], [], []) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["0X1X", ""], [], []), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(HermitianMixedProduct(["1X2X", ""], [], []), 1.0) ... hamiltonian.set(HermitianMixedProduct(["0Z", "0Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["1Z", "1Z"], [], []), 0.1) ... hamiltonian.set(HermitianMixedProduct(["2Z", "2Z"], [], []), 0.1) ... device = AllToAllDevice(9, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... _noise_model = noise_app.system_bath_trotter_circuit_depth(hamiltonian, 0.001, device)
- Parameters:
hamiltonian (MixedHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
system_bath_physical_definition (Tuple[List[int], List[int], Optional[Dict[int, List[int]]]]) -- A combination of lists defining the mapping of system and bath qubits to physical qubits.
- Returns:
The depth.
- Return type:
float
- Raises:
TypeError -- Could not convert hamiltonian input.
RuntimeError -- Extracting effective noise model failed.
- time_evolution_algorithm
Setter for the algorithm` setting for HqsNoiseApp
- Four Options are available:
- ParityBased: An algorithm that implements the time evolution under a product of PauliOperators
via the total Parity of the set of involved qubits. The total parity is perpared in the last involved qubit.
- QSWAP: Terms in the Hamiltonian involving two qubits are implemented using a swap network
that reorders the terms. Uses the ParityBased algorithm for multi qubit terms.
- QSWAPMolmerSorensen: The QSWAP algorithm using variable angle Mølmer Sørensen XX interaction
gates
- VariableMolmerSorensen: An algorithm that implements terms in the Hamiltonian
involving two qubits with a basis change and variable angle Mølmer Sørensen gates
- Parameters:
algorithm (str) -- The option for the algorithm that is set
- to_bincode()
Return the bincode representation of the HqsNoiseApp using the [bincode] crate.
- Returns:
The serialized HqsNoiseApp (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize HqsNoiseApp to bytes.
- to_json()
Return the json representation of the HqsNoiseApp.
- Returns:
The serialized form of HqsNoiseApp.
- Return type:
str
- Raises:
ValueError -- Cannot serialize HqsNoiseApp to json.
- trotter_circuit(trotter_timestep)
Returns the circuit that implements one Trotter step.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.spins import PauliProduct, SpinHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = SpinHamiltonianSystem(3) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(0).x(1), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(1).x(2), 1.0) ... ... circuit = noise_app.trotter_circuit(hamiltonian, 0.001)
- Parameters:
hamiltonian (SpinHamiltonianSystem) -- The Hamiltonian for which the circuit is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system.
- Returns:
The circuit that implements one Trotter step.
- Return type:
Circuit
- Raises:
TypeError -- Could not convert hamiltonian input.
RuntimeError -- Creating the circuit for one Trotter step failed.
- trotter_circuit_depth(trotter_timestep, device)
Returns the depth of the circuit that implements one Trotter step.
The depth of the circuit strongly depends on the device parameters and the chosen optimisations. The function constructs the circuit for one Trotter step and determines the depth.
Example:
>>> from qoqo import Circuit ... from qoqo import operations ... from qoqo.devices import AllToAllDevice ... from hqs_noise_app import HqsNoiseApp ... from struqture_py.spins import PauliProduct, SpinHamiltonianSystem ... ... noise_app = HqsNoiseApp("active_qubits_only") ... hamiltonian = SpinHamiltonianSystem(3) ... # A XX interaction between spins 0 and 1 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(0).x(1), 1.0) ... # A XX interaction between spins 1 and 2 and spins 1 and 0 ... hamiltonian.set(PauliProduct().x(1).x(2), 1.0) ... ... device = AllToAllDevice(4, ["RotateX", "RotateY", "RotateZ"], ["CNOT"], 1.0) ... ... noise_model = noise_app.trotter_circuit_depth(hamiltonian, 0.001, device)
- Parameters:
hamiltonian (SpinHamiltonianSystem) -- The Hamiltonian for which the noise algorithm model is created.
trotter_timestep (float) -- The simulation time the circuit propagates the simulated system
device (qoqo.Device) -- The device determining the topology and the physical noise
- Returns:
The depth.
- Return type:
int
- Raises:
RuntimeError -- Extracting effective noise model failed.
- trotterization_order(trotterization_order)
Changes the Trotterization order for HqsNoiseApp The prefered way of accessing this attribute is using the getter/setter order_of_trotterization.
Second order Trotterization order is only supported for the circuit function using the
ParityBased
andVariableMolmerSorensen
algorithm option. SWAP based algorithms and thesystem_bath
methods only support first order Trotterization- Parameters:
trotterization_order (int) -- The new trotterization order, that can be 1 or 2. In the case of the CNOT algorithm it gives the order to which the terms in the Suzuki-Trotter decomposition are kept.
- Returns:
Updated HqsNoiseApp object with the modified trotterization order setting.
- Raises:
ValueError -- Option not available.
- unroll_quantum_program(program, number_trottersteps, measured_operators, operator_names, logical_to_physical_remapping=None)
Unrolls quantum program that has an internal PragmaLoop.
Unrolls a QuantumProgram with an internal PragmaLoop, transforming all real PauliZProduct measurements to cheated PauliZProduct measurements. This is meant to only be used for obtaining simulation speedups.
- Args
program (QuantumProgram): The quantum program to unroll. number_trottersteps (int): The number of trotter steps that gives the iterations of the unrolled circuit. measured_operators (List[SpinSystem]): The operators measured after each Trotter step. operator_names (List[str]) The main components of the names of teh measured operators.
will be appended with _tstep{n} where n is the trotter step.
logical_to_physical_remapping (Option[Dict[int,int]]): An optional mapping from logical qubit indices to physical qubits
- Returns:
A quantum program that measures the observables after each Trotter step.
- use_bath_as_control()
Changes the value of option use_bath_as_control The prefered way of accessing this attribute is using the getter/setter bath_qubits_as_control_qubits.
Use bath qubits as control when solving system-bath problems and interacting between system and bath qubits with CNOT operations. Only used when using the ParityBased or QSWAP algorithm options for system_bath problems.
- Parameters:
use_bath_as_control (str) -- The new value
- use_noise_symmetrization
Set the noise symmetrization option for HqsNoiseApp
Noise symmetrization controls whether the Trotterstep is symmetrized with respect to damping noise. When the overall noise has the tendency to favor one state |0> or |1>, the Trotterstep can be symmetrized by doubling the Trotter circuit and flipping the definition of |0> and |1> for the second circuit. This process will bring the effective noise closer to a balanced noise at the cost of incuring larger decoherence overall.
- Parameters:
noise_symmetrization (bool) -- The option for the noise symmetrization that is set
- static validate_device(device)
Checks if the provided device has a sufficient gate set for the hqs-noise-app
The hqs-noise-app can automatically create decompositions for gates when the gate set of a device has a suitable combination of single qubit gates and two qubit gates.
Suitable combinations of single-qubit gates are:
[RotateY, RotateX]
[RotateX, RotateZ]
[RotateY, RotateZ]
[SqrtPauliX, InvSqrtPauliX, RotateZ]
[RotateAroundSphericalAxis, RotateZ]
Suitable two-qubit gates are:
CNOT
ControlledPhaseShift
ControlledPauliZ
MolmerSorensenXX
VariableMSXX
- Parameters:
device (qoqo.Device) -- The device that is validated
- wait_time_after_trotterstep
Setter for the value of option after_trotter_wait_time.
When not None, this introduces an additional physical wait time after the Trotter circuit has been applied. This can be used to introduce additional decoherence when the decoherence in the Trotter step is too low or is dominated by the wrong type of decoherence compared to the background decoherence processes that are active during wait time.
- Parameters:
after_trotter_wait_time (Optional[float]) -- The option for the after_trotter_wait_time that is set
- class hqs_noise_app.SpinBRNoiseOperator(frequencies)
A general struct encoding a spectral function coupled to a spin system.
Can be used for many cases where a continuous function is coupled to a SpinSystem by up to two spin operators.
Examples include:
The Bloch-Redfield spectral function
The effective temperature of a spectral function#[pyclass(name = "SpinBRNoiseOperator", module = "bath_mapper")]
- Parameters:
frequencies (List[float]) -- The frequencies on which the spectral functions are defined
- frequencies()
Get the frequencies the spectral function is defined for.
- Returns:
The start and end points of the frequencies.
- Return type:
List[float]
- from_bincode()
Convert the bincode representation of the SpinBRNoiseOperator to a SpinBRNoiseOperator using the [bincode] crate.
- Parameters:
input (ByteArray) -- The serialized SpinBRNoiseOperator (in [bincode] form).
- Returns:
The deserialized SpinBRNoiseOperator.
- Return type:
- Raises:
TypeError -- Input cannot be converted to byte array.
ValueError -- Input cannot be deserialized to SpinBRNoiseOperator.
- from_json()
Convert the json representation of a SpinBRNoiseOperator to a SpinBRNoiseOperator.
- Parameters:
input (str) -- The serialized SpinBRNoiseOperator in json form.
- Returns:
The deserialized SpinBRNoiseOperator.
- Return type:
- Raises:
ValueError -- Input cannot be deserialized to SpinBRNoiseOperator.
- get()
Get the spectral function for a pair of PauliProducts.
- Parameters:
key (string, string) -- The string representation of the pair of PauliProducts for which to get the spectral function.
- Returns:
The spectral function functionum for the input key.
- Return type:
List[complex]
- Raises:
ValueError -- Could not convert left key input to PauliProduct.
ValueError -- Could not convert right key input to PauliProduct.
- get_imag()
Get the imaginary part of the spectral function for a pair of PauliProducts.
- Parameters:
key (string, string) -- The string representation of the pair of PauliProducts for which to get the spectral function.
- Returns:
The imaginary part of the spectral function for the input key.
- Return type:
List[float]
- Raises:
ValueError -- Could not convert left key input to PauliProduct.
ValueError -- Could not convert right key input to PauliProduct.
- get_real()
Get the real part of the spectral function for a pair of PauliProducts.
- Parameters:
key (string, string) -- The string representation of the pair of PauliProducts for which to get the spectral function.
- Returns:
The real part of the spectral function for the input key.
- Return type:
List[float]
- Raises:
ValueError -- Could not convert left key input to PauliProduct.
ValueError -- Could not convert right key input to PauliProduct.
- get_spectral_function_matrix(number_spins)
Get the matrix of the spectral function of a spin-system at a specific energy index.
Assumes that the SpinBRNoiseOperator represents the spectral function coupled to a spin system. A real spectral function needs to be symmetric in the coupling indices. The method will fail if the SpinBRNoiseOperator is not symmetric.
- Parameters:
spectral_function_index (int) -- The frequency index for which the matrix is returned
number_spins (int) -- The number of spins in the system.
- Returns:
the resulting complex matrix representation of the spectral function at the specified energy index.
- Return type:
np.ndarray
- Raises:
ValueError -- Spectral function matrix is not symmetric.
- resample()
Resample the SpinBRNoiseOperator on a new set of frequencies.
The function makes the base assumption that the spectra are flat within each bin corresponding to the original frequencies. To resample the original function is integrated and interpolated at the new frequencies.
- Parameters:
frequencies (List[float]) -- The new frequencies for which every datapoint in the spectral function is defined.
- Returns:
The resampled SpinBRNoiseOperator.
- Return type:
- Raises:
ValueError -- Cannot use resample_interpolate to extrapolate. Current minimum frequency is larger than new minimum frequency.
- resample_interpolate()
Resample the SpinBRNoiseOperator on a new set of frequencies by linear interpolation.
- Parameters:
frequencies (List[float]) -- The new frequencies for which every datapoint in the spectral function is defined.
- Returns:
The resampled SpinBRNoiseOperator.
- Return type:
- Raises:
ValueError -- Cannot use resample_interpolate to extrapolate. Current minimum frequency is larger than new minimum frequency.
- set(spectral_function, /)
Set the value of a spectral function for the input frequencies and a set of PauliProducts.
- Parameters:
key (string, string) -- The string representation of the pair of PauliProducts for which to set the spectral function.
spectral_function (List[float]) -- The frequency resolved spectral function as a vector of complex numbers.
- Raises:
ValueError -- Could not convert left key input to PauliProduct.
ValueError -- Could not convert right key input to PauliProduct.
ValueError -- Spectral function must define a value for each frequency.
- set_imag(spectral_function, /)
Set the imaginary part of the value of a spectral function for the input frequencies and a set of PauliProducts.
- Parameters:
key (string, string) -- The string representation of the pair of PauliProducts for which to set the spectral function.
spectral_function (List[float]) -- The frequency resolved spectral function as a vector of complex numbers.
- Raises:
ValueError -- Could not convert left key input to PauliProduct.
ValueError -- Could not convert right key input to PauliProduct.
ValueError -- Spectral function must define a value for each frequency.
- set_real(spectral_function, /)
Set the real part of the value of a spectral function for the input frequencies and a set of PauliProducts.
- Parameters:
key (string, string) -- The string representation of the pair of PauliProducts for which to set the spectral function.
spectral_function (List[float]) -- The frequency resolved spectral function as a vector of complex numbers.
- Raises:
ValueError -- Could not convert left key input to PauliProduct.
ValueError -- Could not convert right key input to PauliProduct.
ValueError -- Spectral function must define a value for each frequency.
- to_bincode()
Return the bincode representation of the SpinBRNoiseOperator using the [bincode] crate.
- Returns:
The serialized SpinBRNoiseOperator (in [bincode] form).
- Return type:
ByteArray
- Raises:
ValueError -- Cannot serialize SpinBRNoiseOperator to bytes.
- to_json()
Return the json representation of the SpinBRNoiseOperator.
- Returns:
The serialized form of SpinBRNoiseOperator.
- Return type:
str
- Raises:
ValueError -- Cannot serialize SpinBRNoiseOperator to json.
- hqs_noise_app.broadenings(bath_qubits, device, noise_models=None)
Given a device and a vector of bath qubits, this function returns a HashMap of the bath qubits and their corresponding broadening.
For each bath qubit, the broadening $ b $ is calculated according to: $ b = gamma_{damp} / 2 + gamma_{depol} + 2 gamma_{deph} $ where $ gamma_{damp} $ is the damping rate of the qubit, $ gamma_{depol} $ is the depolarising rate of the qubit, and $ gamma_{deph} $ is the dephasing rate of the qubit. Note that the bath mapping framework generally assumes that gamma_{depol}=0. A finite depolarising rate will introduce an error in the mapping, which is assumed to be reduced when using this formula.
- Parameters:
bath_qubits -- The bath qubits for which to calculate the broadenings.
device -- The device of the bath qubits.
noise_models -- The qoqo NoiseModels to use to calculate the broadenings.
- Returns:
The dictionary of qubits and their corresponding broadenings.
- Return type:
Dict[int, float]
- Raises:
TypeError -- Could not convert device to SquareLatticeDevice.
TypeError -- Could not convert noise models to ContinuousDecoherenceModel.
ValueError -- No decoherence rates in device for a given qubit.
- hqs_noise_app.calculate_excitation_spectral_function(mode_fermion_system, temperature, number_frequencies=None)
Determine the bath excitation spectral function from a given Hamiltonian.
If the system of the mixed Hamiltonian is a spin system: Core has arbitrary many spins and bath has free electrons, and spin-bath operator is of the form: t_sij * sigma_s * c_dag_i c_j, with summation over s, i, j and where sigma_s is a spin operator built from the X, Y, Z Pauli operators. We do not (need to) keep track of electron-spin transitions. Also the actual spin-operator can be sigma_s^-, sigma_s^+, or sigma_sz, but is not specified.
If the system of the mixed Hamiltonian is a fermionic system: Core has arbitrary many fermions and bath has free electrons, and system-bath operator is of the form: t_ijkl * c_dag_i c_j * c_dag_k c_l, with summation over i, j, k, l and where c_dag_i c_j is a system term and c_dag_k c_l is a bath term. We do not (need to) keep track of electron-system transitions.
- Parameters:
mode_fermion_system (MixedHamiltonianSystem) -- A MixedHamiltonianSystem composed of a spin/fermion system coupled to a noninteracting fermionic bath.
temperature (float) -- Bath temperature. Enters later via fermi distributions of bath.
number_frequencies (int) -- The number of frequency points on which the excitation spectral function is calculated. Defaults to 100.
- Returns:
(BRNoiseOperator, List[float]) - The SpinBRNoiseOperator/FermionBRNoiseOperator and corresponding frequencies from the input.
- Raises:
ValueError -- Could not convert mode_fermion_system to MixedHamiltonianSystem.
ValueError -- The incorrect number of spin/fermion subsystems have been specified.
ValueError -- The temperature input is not valid, as it is negative.
ValueError -- No interaction between system and bath. Cannot construct spectral function.
ValueError -- calculate_excitation_spectral_function only supports uniform coupling types.
ValueError -- This function cannot be run with symbolic values in the Hamiltonian.
- hqs_noise_app.coupling_to_spectral_function(mode_boson_system, frequencies, background=None, additional_damping=None, allow_empty_coupling=None)
Convert a physical coupling as described by a spin/fermion system coupled to a bosonic bath to a spectral function.
If the system part of the input MixedLindbladOpenSystem is a spin system, the MixedLindbladOpenSystem should adhere to the following assumptions: * The coherent system terms can be of any form as they are not taken into account here. * The coherent pure bosonic (bath) terms should be interaction-free, and should therefore only be of the form (omega * b^dagger b). * The coherent coupling terms between system and bath should be limited to one single Pauli operator coupling to a single bosonic creation operator
plus its hermitian conjugate: (sigma_{x, y, z} * (b + b^dagger)).
The noise terms should only act on the bosonic bath and should be limited to pure damping.
If the system part of the input MixedLindbladOpenSystem is a fermionic system, the MixedLindbladOpenSystem should adhere to the following assumptions: * The coherent system terms can be of any form as they are not taken into account here. * The coherent pure bosonic (bath) terms should be interaction-free, and should therefore only be of the form (omega * b^dagger b). * The coherent coupling terms between system and bath should be limited to c_i a_j operator coupling to a single bosonic creation operator
plus its hermitian conjugate: (c_i a_j * (b + b^dagger)).
The noise terms should only act on the bosonic bath and should be limited to pure damping.
- Parameters:
mode_boson_system (MixedLindbladOpenSystem) -- A struqture_py coupled open spin-boson system or fermion-boson system in the form of a MixedLindbladOpenSystem. The coupling between fermion/spin and bosonic subsystem is limited to one single Pauli operator (in the case of a SpinBRNoiseOperator) or a c_i a_j operator (in the case of a FermionBRNoiseOperator) coupling to a single bosonic creation operator plus its Hermitian conjugate. The bosonic subsystem is limited to an interaction-free system, with the eigenfrequencies directly given by the coefficients of the occupation operators in the Hamiltonian (omega * b^dagger b). The Lindblad terms of the open system can only act on the bosonic subsystem and are limited to pure damping.
frequencies (List[float]) -- The frequencies for which every datapoint in the spectral function is defined.
background (Optional[float]) -- A constant background/offset that is included in the on-diagonal spectral functions. Defaults to 0.0
additional_damping (Optional[float]) -- An optional constant damping to be added to the one calculated from the open system.
allow_empty_coupling (Optional[bool]) -- Allow a mixed system input with no coupling between subsystems.Will produce a zero spectral function.
- Returns:
The calculated spectral function.
- Return type:
BRNoiseOperator
- Raises:
ValueError -- Frequencies must increase monotonically.
ValueError -- The coupling type has been incorrectly specified.
ValueError -- Spectral function must define a value for each frequency.
ValueError -- Could not construct the products needed to index the mode_boson_system.
- hqs_noise_app.create_candidates_bilinear(number_system, device)
Given a device and the length of a chain, this function finds all of the simple chains with the given number of system qubits (length of the chain), where each system qubit has an associated bath qubit.
Only simple chains are found in this function: horizontal chains and vertical chains. Each chain represents the qubits of the system. The bath qubits are not part of the chain. For each system qubit in the chain a neighbouring qubit (outside of the chain) is used as its associated bath qubit. No optimization happens here, so in the worst case scenario this should scale to produce $mathcal{O}(N)$ candidates where N is the number of qubits in the device.
- Parameters:
number_system -- The number of qubits in the system part of the chain, which corresponds to the length of the chain. For each system qubit, a bath qubit will be found above or below it on the device.
device -- The device on which to find all the chains of a given length.
- Returns:
The vector of candidates, where each element in the vector is a Tuple, containing the vector of system qubits in the chain and a HashMap linking each system qubit in the vector to a bath qubit.
- Return type:
List[(List[int], Dict[int, int])]
- Raises:
TypeError -- Could not convert device to SquareLatticeDevice.
ValueError -- Could not fit a chain of length number_system on the given device.
- hqs_noise_app.create_candidates_trilinear(number_system, device)
Given a device and the length of a chain, this function finds all of the simple chains with the given number of system qubits (length of the chain), where each system qubit has two associated bath qubits.
Only simple chains are found in this function: horizontal chains and vertical chains. Each chain represents the qubits of the system. The bath qubits are not part of the chain. For each system qubit in the chain two neighbouring qubits (outside of the chain) are used as its two associated bath qubits. No optimization happens here, so in the worst case scenario this should scale to produce $mathcal{O}(N)$ candidates where N is the number of qubits in the device.
- Parameters:
number_system -- The number of qubits in the system part of the chain, which corresponds to the length of the chain. For each system qubit, two bath qubits will be found above or below it on the device.
device -- The device on which to find all the chains of a given length.
- Returns:
The vector of candidates, where each element in the vector is a Tuple, containing the vector of system qubits in the chain and two HashMaps linking each system qubit in the vector to a bath qubit.
- Return type:
List[(List[int], Dict[int, int], Dict[int, int])]
- Raises:
TypeError -- Could not convert device to SquareLatticeDevice.
ValueError -- Could not fit a chain of length number_system on the given device.
- hqs_noise_app.integrate_over_frequency_intervals(spectral_function, new_frequencies)
Integrate a collection of spectral functions (represented by a SpinNoiseBROperator or a FermionBRNoiseOperator) over a set of input frequencies.
- Parameters:
spectral_function (Union[SpinBRNoiseOperator, FermionBRNoiseOperator]) -- The spectral functions to integrate.
new_frequencies (List[float]) -- The frequencies over which to integrate the spectral functions.
- Returns:
The resulting BRNoiseOperator.
- Return type:
- Raises:
ValueError -- Could not convert the input to either SpinBRNoiseNoiseOperator or FermionBRNoiseOperator.
ValueError -- Error in integration.
- hqs_noise_app.logical_to_physical_mappings_bilinear(candidate)
Create the logical to physical mapping for system qubits and bath qubits, for a bilinear chain.
The system qubits will have the logical qubits 0 to N - 1, where N is the number of system qubits. As there is only one line of bath qubits, they will also be numbered (logical qubit) 0 to N - 1, where N is the number of bath qubits.
- Parameters:
candidate -- The bilinear chain of qubits to create the logical to physical mapping for.
- Returns:
The dictionary of system logical to physical qubits and the dictionary of bath logical to physical qubits.
- Return type:
(Dict[int, int], Dict[int, int])
- hqs_noise_app.logical_to_physical_mappings_trilinear(candidate)
Create the logical to physical mapping for system qubits and bath qubits, for a trilinear chain.
The system qubits will have the logical qubits 0 to N - 1, where N is the number of system qubits. The first line of bath qubits will be numbered (logical qubit) 0 to N - 1 and the second line of bath qubits will be numbered N to 2N - 1, where N is the number of bath qubits.
- Parameters:
candidate -- The trilinear chain of qubits to create the logical to physical mapping for.
- Returns:
The dictionary of system logical to physical qubits and the two dictionaries of bath logical to physical qubits.
- Return type:
(Dict[int, int], Dict[int, int], Dict[int, int])
- hqs_noise_app.select_optimised_bilinear_chain(candidates, device, optimisation='zz', normalise_by_bath=False, noise_models=None)
Given a device and a list of of candidates, this function selects the best chain of system qubits with associated bath qubits in the list of candidates.
- The optimisation options are defined as follows:
XXYYZZ finds the chain with the smallest contribution of all Lindblad noise operators combined.
XXYY finds the chain with the smallest contribution of only the X and Y Lindblad operators.
ZZ finds the chain with the smallest contribution of ZZ Lindblad operators (corresponding to only searching for the chain with smallest dephasing).
- Parameters:
candidates (List[Tuple[List[int], List[int]]]) -- The candidates in which to find the best bilinear chain.
device (Device) -- The device for which to find the best chain.
optimisation (str) -- Which type of optimisation to use (zz, xxyy or xxyyzz). Defaults to zz.
normalise_by_bath (bool) -- Whether or not to normalise the chain minimum as the smallest noise on the system chain divided by the noise on the bath sites.
noise_models (Optional[List[NoiseModel]])
- Returns:
The best candidate in the given list of candidates.
- Return type:
(List[int], Dict[int, int])
- Raises:
TypeError -- Could not convert device to SquareLatticeDevice.
ValueError -- Candidates list is empty.
ValueError -- No decoherence rates in device for given qubit.
- hqs_noise_app.select_optimised_trilinear_chain(candidates, device, optimisation='zz', normalise_by_bath=False, noise_models=None)
Given a device and a list of of candidates, this function selects the best chain of system qubits with associated bath qubits in the list of candidates.
- The optimisation options are defined as follows:
XXYYZZ finds the chain with the smallest contribution of all Lindblad noise operators combined.
XXYY finds the chain with the smallest contribution of only the X and Y Lindblad operators.
ZZ finds the chain with the smallest contribution of ZZ Lindblad operators (corresponding to only searching for the chain with smallest dephasing).
- Parameters:
candidates (List[Tuple[List[int], List[int], List[int]]]) -- The candidates in which to find the best trilinear chain.
device (Device) -- The device for which to find the best chain.
optimisation (str) -- Which type of optimisation to use (zz, xxyy or xxyyzz). Defaults to zz.
normalise_by_bath (bool) -- Whether or not to normalise the chain minimum as the smallest noise on the system chain divided by the noise on the bath sites.
noise_models (Optional[List[NoiseModel]])
- Returns:
The best candidate in the given list of candidates.
- Return type:
(List[int], Dict[int, int], Dict[int, int])
- Raises:
TypeError -- Could not convert device to SquareLatticeDevice.
ValueError -- Candidates list is empty.
ValueError -- No decoherence rates in device for given qubit.
- hqs_noise_app.spectral_function_to_coupling(spectral_function, number_modes)
Convert a spectral function to a physical coupling as described by a Spin-Boson-System or Fermion-Boson-System.
If the input spectral function is a SpinBRNoiseOperator, the MixedLindbladOpenSystem constructed has one spin subsystem (with number_modes spins) and 3 * number_modes bosonic subsystems each with frequencies.len() modes. This is because each spin is coupled to 3 bosonic baths, one for each of the X, Y, Z couplings. Additionally, each energy interval (and therefore each frequency) contains one bosonic mode. If the input spectral function is a FermionBRNoiseOperator, the MixedLindbladOpenSystem constructed has one fermionic subsystem (with number_modes fermions) and number_modes * number_modes bosonic subsystems each with frequencies.len() modes. This is because each fermion is coupled to number_modes bosonic baths, as c0 can couple to all a0...aN terms. Additionally, each energy interval (and therefore each frequency) contains one bosonic mode.
- Parameters:
spectral_function (Union[SpinBRNoiseOperator, FermionBRNoiseOperator]) -- A set of spectral functions for number_modes baths, represented by either a SpinBRNoiseOperator or a FermionBRNoiseOperator.
number_modes (int) -- The number of the spins or fermions in the system.
- Returns:
The successfully converted spectral function as as MixedLindbladOpenSystem.
- Return type:
MixedLindbladOpenSystem
- Raises:
ValueError -- Spectral function matrix is not symmetric.
ValueError -- Could not construct MixedLindbladOpenSystem.