You're reading the documentation of the v0.9. For the latest released version, please have a look at v0.11.
Simulator
List of simulation methods in the Simulator
method name |
parameters |
output |
prob_amplitude |
input_state: BasicState or StateVector, output_state: BasicState |
prob. amplitude (complex) |
probability |
input_state: BasicState or StateVector, output_state: BasicState |
probability (float [0;1]) |
probs |
input_state: BasicState or StateVector |
prob. distribution (BSD) |
probs_svd |
input_dist: SVDistribution |
Python dictionary |
evolve |
input_state: BasicState or StateVector |
evolved StateVector |
- class perceval.simulators.Simulator(backend)
A simulator class relying on a probability amplitude capable backend to simulate the output of a unitary non-polarized circuit given an BasicState, StateVector or SVDistribution input. The simulator is able to evolve or simulate the sampling a states with annotated photons.
- Parameters:
backend (
AProbAmpliBackend
) – A probability amplitude capable backend object
- clear_postselection()
Clear the post-selection function
- evolve(input_state)
Evolve a state through the circuit
- Parameters:
input_state (
Union
[FockState
,StateVector
]) – The input fock state or state vector- Return type:
StateVector
- Returns:
The output state vector
- evolve_density_matrix(dm)
Compute the DensityMatrix evolved from “dm” through a Linear optical circuit
- Parameters:
dm (
DensityMatrix
) – The density Matrix to evolve- Return type:
DensityMatrix
- Returns:
The evolved DensityMatrix
- evolve_svd(svd, progress_callback=None)
Compute the SVDistribution evolved through a Linear Optical circuit
- Parameters:
svd (
Union
[SVDistribution
,StateVector
,FockState
]) – The input StateVector distributionprogress_callback (
Optional
[Callable
]) – A function with the signature func(progress: float, message: str)
- Return type:
dict
- Returns:
A dictionary of the form { “results”: SVDistribution, “physical_perf”: float, “logical_perf”: float }
results is the post-selected output SVDistribution
physical_perf is the performance computed from the detected photon filter
logical_perf is the performance computed from the post-selection
- keep_heralds(value)
Tells the simulator to keep or discard ancillary modes in output states
- Parameters:
value (
bool
) – True to keep ancillaries/heralded modes, False to discard them (default is keep).
- log_resources(method, extra_parameters)
Log resources of the simulator
- Parameters:
method (
str
) – name of the method usedextra_parameters (
Dict
) –extra parameters to log
Extra parameter can be:
n
- probs_density_matrix(dm)
gives the output probability distribution, after evolving some density matrix through the simulator :type dm:
DensityMatrix
:param dm: the input DensityMatrix- Return type:
dict
- probs_svd(input_dist, progress_callback=None)
Compute the probability distribution from a SVDistribution input and as well as performance scores
- Parameters:
input_dist (
SVDistribution
) – A state vector distribution describing the input to simulateprogress_callback (
Optional
[Callable
]) – A function with the signature func(progress: float, message: str)
- Returns:
A dictionary of the form { “results”: BSDistribution, “physical_perf”: float, “logical_perf”: float }
results is the post-selected output state distribution
physical_perf is the performance computed from the detected photon filter
logical_perf is the performance computed from the post-selection
- set_circuit(circuit)
Set a circuit for simulation.
- Parameters:
circuit (
ACircuit
) – a unitary circuit without polarized components
- set_min_detected_photon_filter(value)
Set a minimum number of detected photons in the output distribution
- Parameters:
value (
int
) – The minimum photon count
- set_min_detected_photons_filter(value)
Set a minimum number of detected photons in the output distribution
- Parameters:
value (
int
) – The minimum photon count
- set_postselection(postselect)
Set a post-selection function
- Parameters:
postselect (
PostSelect
) – a PostSelect object
- set_selection(min_detected_photons_filter=None, postselect=None, heralds=None, min_detected_photon_filter=None)
Set multiple selection filters at once to remove unwanted states from computed output distribution
- Parameters:
min_detected_photons_filter (
Optional
[int
]) – minimum number of detected photons in the output distributionpostselect (
Optional
[PostSelect
]) – a post-selection functionheralds (
Optional
[dict
]) – expected detections (heralds). Only corresponding states will be selected, others are filtered out. Mapping of heralds. For instance {5: 0, 6: 1} means 0 photon is expected on mode 5 and 1 on mode 6.