QutipEmulator
- class pulser_simulation.QutipEmulator(sampled_seq, register, device, sampling_rate=1.0, config=None, evaluation_times='Full')
Bases:
object
Emulator of a pulse sequence using QuTiP.
- Parameters:
sampled_seq (
SequenceSamples
) – A pulse sequence samples used in the emulation.register (
BaseRegister
) – The register associating coordinates to the qubits targeted by the pulses within the samples.device (
BaseDevice
) – The device specifications used in the emulation. Register and samples have to satisfy its constraints.sampling_rate (
float
, default:1.0
) – The fraction of samples that we wish to extract from the samples to simulate. Has to be a value between 0.05 and 1.0.config (
SimConfig
|None
, default:None
) – Configuration to be used for this simulation.evaluation_times (
float
|str
| ArrayLike, default:'Full'
) –Choose between:
”Full”: The times are set to be the ones used to define the Hamiltonian to the solver.
”Minimal”: The times are set to only include initial and final times.
An ArrayLike object of times in µs if you wish to only include those specific times.
A float to act as a sampling rate for the resulting state.
Attributes
The basis in which result is expressed.
The name of the basis.
The current configuration, as a SimConfig instance.
The dimension of the basis.
The times at which the results of this simulation are returned.
The initial state of the simulation.
The times at which hamiltonian is sampled.
Methods
Updates the current configuration with parameters of another one.
Creates an operator with non-trivial actions on some qubits.
Draws the samples of a sequence of operations used for simulation.
Simulation of a pulse sequence using QuTiP.
Get the Hamiltonian created from the sequence at a fixed time.
Resets configuration to default.
Simulates the sequence using QuTiP's solvers.
Sets current config to cfg and updates simulation parameters.
Sets times at which the results of this simulation are returned.
Sets the initial state of the simulation.
Shows current configuration.
Signatures
- add_config(config)
Updates the current configuration with parameters of another one.
Mostly useful when dealing with multiple noise types in different configurations and wanting to merge these configurations together. Adds simulation parameters to noises that weren’t available in the former SimConfig. Noises specified in both SimConfigs will keep former noise parameters.
- Parameters:
config (
SimConfig
) – SimConfig to retrieve parameters from.- Return type:
None
- build_operator(operations)
Creates an operator with non-trivial actions on some qubits.
Takes as argument a list of tuples
[(operator_1, qubits_1), (operator_2, qubits_2)...]
. Returns the operator given by the tensor product of {operator_i
applied onqubits_i
} and Id on the rest.(operator, 'global')
returns the sum for allj
of operator applied atqubit_j
and identity elsewhere.Example for 4 qubits:
[(Z, [1, 2]), (Y, [3])]
returns ZZYI and[(X, 'global')]
returns XIII + IXII + IIXI + IIIX- Parameters:
operations (
list
|tuple
) – List of tuples (operator, qubits). operator can be aqutip.Quobj
or a string key forself.op_matrix
. qubits is the list on which operator will be applied. The qubits can be passed as their index or their label in the register.- Return type:
Qobj
- Returns:
The final operator.
- draw(draw_phase_area=False, draw_phase_shifts=False, draw_phase_curve=False, fig_name=None, kwargs_savefig={})
Draws the samples of a sequence of operations used for simulation.
- Parameters:
draw_phase_area (
bool
, default:False
) – Whether phase and area values need to be shown as text on the plot, defaults to False.draw_phase_shifts (
bool
, default:False
) – Whether phase shift and reference information should be added to the plot, defaults to False.draw_phase_curve (
bool
, default:False
) – Draws the changes in phase in its own curve (ignored if the phase doesn’t change throughout the channel).fig_name (
str
|None
, default:None
) – The name on which to save the figure. If None the figure will not be saved.kwargs_savefig (
dict
, default:{}
) – Keywords arguments formatplotlib.pyplot.savefig
. Not applicable if fig_name isNone
.
- Return type:
None
See also
Sequence.draw(): Draws the sequence in its current state.
- classmethod from_sequence(sequence, sampling_rate=1.0, config=None, evaluation_times='Full', with_modulation=False)
Simulation of a pulse sequence using QuTiP.
- Parameters:
sequence (
Sequence
) – An instance of a Pulser Sequence that we want to simulate.sampling_rate (
float
, default:1.0
) – The fraction of samples that we wish to extract from the pulse sequence to simulate. Has to be a value between 0.05 and 1.0.config (
SimConfig
|None
, default:None
) – Configuration to be used for this simulation.evaluation_times (
float
|str
| ArrayLike, default:'Full'
) –Choose between:
”Full”: The times are set to be the ones used to define the Hamiltonian to the solver.
”Minimal”: The times are set to only include initial and final times.
An ArrayLike object of times in µs if you wish to only include those specific times.
A float to act as a sampling rate for the resulting state.
with_modulation (
bool
, default:False
) – Whether to simulate the sequence with the programmed input or the expected output.
- Return type:
- get_hamiltonian(time)
Get the Hamiltonian created from the sequence at a fixed time.
Note
The whole Hamiltonian is divided by \(\hbar\), so its units are rad/µs.
- Parameters:
time (
float
) – The specific time at which we want to extract the Hamiltonian (in ns).- Return type:
Qobj
- Returns:
A new Qobj for the Hamiltonian with coefficients extracted from the effective sequence (determined by self.sampling_rate) at the specified time.
- reset_config()
Resets configuration to default.
- Return type:
None
- run(progress_bar=False, **options)
Simulates the sequence using QuTiP’s solvers.
Will return NoisyResults if the noise in the SimConfig requires it. Otherwise will return CoherentResults.
- Parameters:
progress_bar (
bool
, default:False
) – If True, the progress bar of QuTiP’s solver will be shown. If None or False, no text appears.options (
Any
) –Given directly to the Qutip Solver. If specified, will override SimConfig solver_options. If no max_step value is provided, an automatic one is calculated from the Sequence’s schedule (half of the shortest duration among pulses and delays). Refer to the QuTiP docs (external) for an overview of the parameters.
- Return type:
- set_config(cfg)
Sets current config to cfg and updates simulation parameters.
- Parameters:
cfg (
SimConfig
) – New configuration.- Return type:
None
- set_evaluation_times(value)
Sets times at which the results of this simulation are returned.
- Parameters:
value (
str
| ArrayLike |float
) –Choose between:
”Full”: The times are set to be the ones used to define the Hamiltonian to the solver.
”Minimal”: The times are set to only include initial and final times.
An ArrayLike object of times in µs if you wish to only include those specific times.
A float to act as a sampling rate for the resulting state.
- Return type:
None
- set_initial_state(state)
Sets the initial state of the simulation.
- Parameters:
state (
str
|ndarray
|Qobj
) –The initial state. Choose between:
”all-ground” for all atoms in ground state
An ArrayLike with a shape compatible with the system
A Qobj object
- Return type:
None
- show_config(solver_options=False)
Shows current configuration.
- Return type:
None
- property basis: dict[Literal['u', 'd', 'r', 'g', 'h', 'x'], Any]
The basis in which result is expressed.
- property basis_name: str
The name of the basis.
- property config: SimConfig
The current configuration, as a SimConfig instance.
- property dim: int
The dimension of the basis.
- property evaluation_times: ndarray
The times at which the results of this simulation are returned.
- property initial_state: Qobj
The initial state of the simulation.
- property sampling_times: ndarray
The times at which hamiltonian is sampled.