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
normalizeargument can be specified by passing a FunctionDict toset_initial_state().- Parameters:
- local_iint
size of the local system state partitions,
quop_mpi.Ansatzattribute- local_i_offsetint
global index offset of the local system state partitions,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI communicator of the QVA simulation,
quop_mpi.Ansatzattribute- 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_iinitial state values with global index offsetlocal_i_offset(seequop_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_statesargument can be specified by passing a FunctionDict toquop_mpi.Ansatz.set_initial_state().- Parameters:
- local_iint
size of the local system state partitions,
quop_mpi.Ansatzattribute- local_i_offsetint
global index offset of the local system state partitions,
quop_mpi.Ansatzattribute- 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_iinitial state values with global index offsetlocal_i_offset(seequop_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.Ansatzclass.- Parameters:
- system_sizeint
size of the simulated QVA,
quop_mpi.Ansatzattribute- local_iint
size of the local system state partitions,
quop_mpi.Ansatzattribute
- Returns:
- ndarray[complex128]
1-D complex array of
local_iinitial state values with global index offsetlocal_i_offset(seequop_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,minsandfunctionmust be passed toquop_mpi.Ansatz.set_observables()in a FunctionDict.The
functionargument must take anlen(Ns)-dimensional coordinate and return the complex amplitude of the initial state at that coordinate.If
functionisNone,position_gridgenerates a squeezed Gaussian state with its mean situated at a randomly generated coordinate that has a distance of at leastlength * 0.125from the boundaries of the grid (wherelengthis the length in each coordinate).- Parameters:
- alloc_localint
size of the array containing the local partition of the system,
quop_mpi.Ansatzattribute- local_iint
number of initial state values in local partition of the system state,
quop_mpi.Ansatzattribute- local_i_offsetint
global index offset of the local system state partition,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI communicator,
quop_mpi.Ansatzattribute- 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_iinitial state values with global index offsetlocal_i_offset(seequop_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
functionargument must be specified by passing a FunctionDict toset_initial_state(). Additional positional and keyword arguments in theFunctionDictare passed tofunction.- Parameters:
- partition_tablelist[int]
1-D array describing the global partitioning scheme,
quop_mpi.Ansatzattribute- MPI_COMMIntracomm
MPI communicator of the QVA simulation,
quop_mpi.Ansatzattribute- 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_iinitial state values with global index offsetlocal_i_offset(seequop_mpi.Ansatz)