State
Functions for preparing initial quantum states.
Module Reference
Predefined Initial State Functions .
See set_initial_state().
- quop_mpi.state.array(local_i, local_i_offset, MPI_COMM, state, normalize=True)
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, local_i_offset, basis_states=None)
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, local_i)
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, local_i, local_i_offset, MPI_COMM, Ns, deltas, mins, function)
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, MPI_COMM, function, *args, **kwargs)
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)