State

Functions for preparing initial quantum states.

Module Reference

Predefined Initial State Functions .

See set_initial_state().

quop_mpi.state.array(local_i: int, local_i_offset: int, MPI_COMM: Intracomm, state: np.ndarray[np.complex128], normalize: bool = True) np.ndarray[np.complex128]

Define the initial state using a Numpy array.

An Initial State Function. The normalize argument can be specified by passing a FunctionDict to set_initial_state() .

Parameters:
local_iint

size of the local system state partitions, quop_mpi.Ansatz attribute

local_i_offsetint

global index offset of the local system state partitions, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator of the QVA simulation, quop_mpi.Ansatz attribute

statendarray[complex128]

A 1-D array of system size initial state values

normalizebool, optional

wether to normalize state, by default True

Returns:
ndarray[complex128]

1-D complex array of local_i initial state values with global index offset local_i_offset (see quop_mpi.Ansatz)

quop_mpi.state.basis(local_i: int, local_i_offset: int, basis_states: list[int] = None) np.ndarray[np.complex128]

Generate an equal superposition over a subset of basis states.

An Initial State Function. The basis_states argument can be specified by passing a FunctionDict to quop_mpi.Ansatz.set_initial_state().

Parameters:
local_iint

size of the local system state partitions, quop_mpi.Ansatz attribute

local_i_offsetint

global index offset of the local system state partitions, quop_mpi.Ansatz attribute

basis_stateslist[int], optional

global indexes specifying an equal superposition over a subset of states, by default [0]

Returns:
ndarray[complex128]

1-D complex array of local_i initial state values with global index offset local_i_offset (see quop_mpi.Ansatz )

quop_mpi.state.equal(system_size: int, local_i: int) np.ndarray[np.complex128]

Generate an equal superposition over all system states.

The default Initial State Function of the quop_mpi.Ansatz class.

Parameters:
system_sizeint

size of the simulated QVA, quop_mpi.Ansatz attribute

local_iint

size of the local system state partitions, quop_mpi.Ansatz attribute

Returns:
ndarray[complex128]

1-D complex array of local_i initial state values with global index offset local_i_offset (see quop_mpi.Ansatz)

quop_mpi.state.position_grid(alloc_local: int, local_i: int, local_i_offset: int, MPI_COMM: Intracomm, Ns: list[int], deltas: list[float], mins: list[float], function: Callable) np.ndarray[np.complex128]

Generate an initial state discrete Cartesian coordinates.

An Observables Function. Arguments Ns, deltas, mins and function must be passed to quop_mpi.Ansatz.set_observables() in a FunctionDict.

The function argument must take an len(Ns) -dimensional coordinate and return the complex amplitude of the initial state at that coordinate.

If function is None, position_grid generates a squeezed Gaussian state with its mean situated at a randomly generated coordinate that has a distance of at least length * 0.125 from the boundaries of the grid (where length is the length in each coordinate).

Parameters:
alloc_localint

size of the array containing the local partition of the system, quop_mpi.Ansatz attribute

local_iint

number of initial state values in local partition of the system state, quop_mpi.Ansatz attribute

local_i_offsetint

global index offset of the local system state partition, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator, quop_mpi.Ansatz attribute

Nslist[int]

number of grid points in each dimension of the Cartesian grid

deltaslist[float]

step size in each coordinate

minslist[float]

minimum value in each coordinate

functionCallable

a Python function returning the value of the initial state at each grid point

Returns:
ndarray[complex128]

1-D complex array of local_i initial state values with global index offset local_i_offset (see quop_mpi.Ansatz)

quop_mpi.state.serial(partition_table: list[int], MPI_COMM: Intracomm, function: Callable, *args, **kwargs) np.ndarray[np.complex128]

Generate the initial state using a serial Python function.

An Initial State Function. The function argument must be specified by passing a FunctionDict to set_initial_state(). Additional positional and keyword arguments in the FunctionDict are passed to function.

Parameters:
partition_tablelist[int]

1-D array describing the global partitioning scheme, quop_mpi.Ansatz attribute

MPI_COMMIntracomm

MPI communicator of the QVA simulation, quop_mpi.Ansatz attribute

functionCallable

a Python function returning a 1-D complex array of system size initial state values

Returns:
ndarray[complex128]

1-D complex array of local_i initial state values with global index offset local_i_offset (see quop_mpi.Ansatz)