Bases: object
Methods providing a very basic framework of a 1 particle CTQW.
Caution
This object constructs some of the framework of a 1 particle quantum walk, but is not feature complete. For a feature complete construction, see pyCTQW.MPI.Graph() or pyCTQW.MPI.Line() for which this is a base.
QuantumWalkP1.destroy() | Destroys the 1 particle quantum walk object, and all associated PETSc matrices/vectors. |
QuantumWalkP1.exportState(filename, filetype) | Exports the final state of the quantum walk to a file. |
QuantumWalkP1.importInitState(filename, filetype) | Imports the initial state of the quantum walk from a file. |
QuantumWalkP1.marginal(vec) | |
QuantumWalkP1.plotNodes(filename[, t]) | Creates a plot of the node probablities over time. |
QuantumWalkP1.propagate(t[, method]) | Propagates the quantum walk for time t. |
QuantumWalkP1.psiToInit() | Copies the state self.psi to self.psi0. |
QuantumWalkP1.watch(nodes) | Creates a handle that watches node probability during propagation. |
Destroys the 1 particle quantum walk object, and all associated PETSc matrices/vectors.
Exports the final state of the quantum walk to a file.
Parameters: |
|
---|
Imports the initial state of the quantum walk from a file.
Parameters: |
|
---|---|
Returns: | : this creates a PETSc vector containing the initial state, accessed via Graph.psi0. |
Return type: | petsc4py.PETSc.Vec() |
Warning
The number of elements in the imported input state vector must match the number of nodes the 1P CTQW object is initialized with.
Creates a plot of the node probablities over time.
Parameters: | filename (str) – the absolute/relative path to the desired output file. |
---|
Important
watch() must be called prior to propagation in order for the probabilities at the specified nodes to be stored.
Note
Propagates the quantum walk for time t.
Parameters: |
|
---|---|
Keyword Arguments: | |
|
|
Returns: | : this creates a PETSc vector containing the propagated state, accessed via the attribute psi, as well as a PETSc vector containing the marginal probabilities, prob. |
Return type: | petsc4py.PETSc.Vec() |
Note
The EigSolver properties only take effect if method=’chebyshev’.
Fortran interface
This function calls the Fortran function expm(). for the Krylov method, and the function qw_cheby() for the Chebyshev method.
Copies the state self.psi to self.psi0.
Example
This can be used to iterate the propagation over discrete timesteps:
for i in range(10):
walk.propagate(0.01,method='chebyshev')
walk.psiToInit()
Creates a handle that watches node probability during propagation.
Parameters: | nodes (array of ints) – the nodes to watch (e.g. [0,1,4]). |
---|---|
Returns: | : creates a handle that can be accessed to retrieve node probabilities for various \(t\) |
Return type: | pyCTQW.MPI.ctqw.nodeHandle() |
Example
>>> walk.watch([0,1,2,3,4])
>>> walk.propagate(5.,method='chebyshev')
>>> timeArray, probArray = walk.handle.getLocalNodes()
Warning
Note that walk.handle attributes are not collective; if running on multiple nodes, only local values will be returned.