Skip to content

simulate

Simulates the evolution of a quantum state through a given quantum circuit.

Parameters:

Name Type Description Default
circuit Circuit

The quantum circuit to simulate. The circuit is composed of layers, each of which can generate unitary or Kraus operators.

required
initial_state Qarray

The initial quantum state to be evolved. This can be a state vector or a density matrix.

required
mode SimulateMode

The mode of simulation. It can be either SimulateMode.UNITARY for unitary evolution or SimulateMode.KRAUS for Kraus operator evolution. Defaults to SimulateMode.UNITARY.

UNITARY

Returns:

Name Type Description
Results Results

An object containing the results of the simulation, which includes the quantum states at each step of the circuit.

Source code in jaxquantum/circuits/simulate.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def simulate(
    circuit: Circuit, initial_state: Qarray, mode: SimulateMode = SimulateMode.UNITARY
) -> Results:
    """
    Simulates the evolution of a quantum state through a given quantum circuit.

    Args:
        circuit (Circuit): The quantum circuit to simulate. The circuit is composed of layers,
                           each of which can generate unitary or Kraus operators.
        initial_state (Qarray): The initial quantum state to be evolved. This can be a state vector
                                or a density matrix.
        mode (SimulateMode, optional): The mode of simulation. It can be either SimulateMode.UNITARY
                                       for unitary evolution or SimulateMode.KRAUS for Kraus operator
                                       evolution. Defaults to SimulateMode.UNITARY.

    Returns:
        Results: An object containing the results of the simulation, which includes the quantum states
                 at each step of the circuit.
    """

    results = Results.create([])
    state = initial_state
    results.append(Qarray.from_list([state]))

    for layer in circuit.layers:
        result = simulate_layer(layer, state, mode=mode)
        results.append(result)
        state = result[-1]

    return results