You're reading the documentation of the v0.11. For the latest released version, please have a look at v1.0.

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 (AStrongSimulationBackend) – A probability amplitude capable backend object

clear_postselection()

Clear the post-selection function

compute_physical_logical_perf(value)

Tells the simulator to compute or not the physical and logical performances when possible

Parameters:

value (bool) – True to compute the physical and logical performances, False otherwise.

evolve(input_state)

Evolve a state through the circuit. If the simulator has logical selection, the performance for this input state is stored in self.logical_perf, and only the states matching the logical selection are kept.

Parameters:

input_state (BasicState | 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 optics 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 optics circuit

Parameters:
  • svd (SVDistribution | StateVector | BasicState) – The input StateVector distribution

  • progress_callback (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

format_results(results, physical_perf, logical_perf)

Format the simulation results by computing the global performance, and returning the physical and logical performances only if needed.

Parameters:
  • results – the simulation results

  • physical_perf – the physical performance

  • logical_perf – the logical performance

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 used

  • extra_parameters (dict) –

    extra parameters to log

    Extra parameter can be:

    • n

property min_detected_photons_filter: int

The simulated minimum number of photons that a state needs to have to be counted as valid. Includes the expected photons from the heralds.

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

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

probs_svd(input_dist, detectors=None, progress_callback=None)

Compute the probability distribution from a SVDistribution input and as well as performance scores

Parameters:
  • input_dist (SVDistribution | tuple[Source, FockState]) – A state vector distribution describing the input to simulate

  • detectors (list[IDetector]) – An optional list of detectors

  • progress_callback (callable) – A function with the signature func(progress: float, message: str)

Return type:

dict[str, any]

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, m=None)

Set a circuit for simulation.

Parameters:
  • circuit (ACircuit) – a unitary circuit without polarized components

  • m – The number of modes in the circuit. Only used in LC and TD simulators. If not provided, it is inferred from the modes of the components of the circuit list.

set_heralds(heralds)

Set the output heralds of the simulator. Any output that does not match the heralds will be discarded. Only used in probs, probs_svd, evolve, evolve_svd

set_min_detected_photons_filter(value)

Set a minimum number of detected photons in the output distribution, counting only the non-heralded modes.

Parameters:

value (int) – The minimum photon count

set_postselection(postselect)

Set a post-selection function

Parameters:

postselect (PostSelect) – a PostSelect object

set_precision(precision)

Set the precision of the simulator. When using probs_svd, states having a probability inferior to the precision times the highest probability will be discarded.

set_selection(min_detected_photons_filter=None, postselect=None, heralds=None)

Set the min_detected_photons_filter, postselect, and heralds, if defined.

Parameters:
  • min_detected_photons_filter (Optional[int]) – The minimum photon count.

  • postselect (Optional[PostSelect]) – The postselect to apply at the end of the computation.

  • heralds (Optional[dict[int, int]]) – The heralds to apply at the end of the computation. Only the output heralds are considered here. dictionary of the form {mode: expected}