Bases: object
Contains methods for initializing, creating and manipulating Hamiltonian matrices.
Parameters: | N (int) – number of nodes to initialize the Hamiltonian object with. |
---|---|
Returns: | : creates an unallocated PETSc matrix on communicator petsc4py.PETSc.COMM_WORLD. This is accessed via the attribute Hamiltonian.mat. |
Return type: | petsc4py.PETSc.Mat |
Returns: | : an associated EigSolver object is also created at Hamiltonian.EigSolver. |
Return type: | EigSolver |
Hamiltonian.Emax(**kwargs) | Returns the maximum Eigenvalue of the matrix. |
Hamiltonian.Emin(**kwargs) | Returns the minimum Eigenvalue of the matrix. |
Hamiltonian.createLine([d, amp]) | Create a 1 particle infinite line Hamiltonian. |
Hamiltonian.createLine2P([d, amp, interaction]) | Create a 2 particle infinite line Hamiltonian. |
Hamiltonian.createLine3P([d, amp, interaction]) | Create a 3 particle infinite line Hamiltonian. |
Hamiltonian.destroy() | Destroys all associated PETSc matrices. |
Hamiltonian.importAdj(filename, filetype[, ...]) | Create a Hamiltonian from an imported adjacency matrix. |
Hamiltonian.importAdjToH(filename, filetype) | Create a Hamiltonian from an imported adjacency matrix. |
Hamiltonian.reinitialize() | Destroy and reinitialize the PETSc matrix Hamiltonian.mat. |
Returns the maximum Eigenvalue of the matrix.
Example
>>> Emax = Hamiltonian.Emax()
Returns the minimum Eigenvalue of the matrix.
Example
>>> Emin = Hamiltonian.Emin()
Create a 1 particle infinite line Hamiltonian.
Parameters: |
|
---|---|
Returns: | : Hamiltonian.mat, the Hamiltonian matrix. |
Return type: | petsc4py.PETSc.Mat() |
Important
Fortran interface
This function calls the Fortran function hamiltonian_p1_line().
Create a 2 particle infinite line Hamiltonian.
Parameters: |
|
---|---|
Returns: | : Hamiltonian.mat, the Hamiltonian matrix. |
Return type: | petsc4py.PETSc.Mat() |
Important
Fortran interface
This function calls the Fortran function hamiltonian_p2_line().
Create a 3 particle infinite line Hamiltonian.
Parameters: |
|
---|---|
Returns: | : Hamiltonian.mat, the Hamiltonian matrix. |
Return type: | petsc4py.PETSc.Mat() |
Important
Fortran interface
This function calls the Fortran function hamiltonian_p3_line().
Create a Hamiltonian from an imported adjacency matrix.
Parameters: |
|
---|---|
Returns: | :this allocates and builds a Hamiltonian matrix at Hamiltonian.mat. |
Return type: | petsc4py.PETSc.Mat() |
Returns: | : the original adjacency matrix is also stored as a PETSc matrix at Hamiltonian.Adj. |
Return type: | petsc4py.PETSc.Mat() |
Important
Note
Create a Hamiltonian from an imported adjacency matrix.
- Args:
filename (str): path to the file containing the adjacency matrix of the graph
filetype (str): the filetype of the imported adjacency matrix.
- 'txt' - an \(N\times N\) dense 2D array in text format.
- 'bin' - an \(N\times N\) PETSc binary matrix.
- d (array of ints): an array containing integers indicating the nodes
- where diagonal defects are to be placed (e.g. d=[0,1,4]).
- amp (array of floats): an array containing floats indicating the diagonal defect
- amplitudes corresponding to each element in d (e.g. amp=[0.5,-1,4.2]).
p (str) : ('1'``|‘2’|‘3’``) - specify whether to create a 1, 2 or 3 particle Hamiltonian.
layout (str): the format to store the position of the nodes.
- spring (default) - spring layout.
- circle - nodes are arranged in a circle.
- spectral - nodes are laid out according to the spectrum of the graph.
- random - nodes are arranged in a random pattern.
- delimiter (str): this is passed to numpy.genfromtxt
- in the case of strange delimiters in an imported txt file.
interaction (float): the amplitude of interaction between the walkers when located on the same vertex.
bosonic (bool): if true, a Bosonic Hamiltonian is generated.
- Returns:
- : * Hamiltonian.mat (petsc4py.PETSc.Mat) - the Hamiltonian matrix.
- Hamiltonian.Adj (petsc4py.PETSc.Mat) - the adjacency matrix stored as a PETSc matrix.
- Hamiltonian.nodePos (array) - the \((x,y)\) coordinates of the graph vertices.
- Hamiltonian.lineX (array) - the \(x\) coordinates of the edges connecting graph vertices.
- Hamiltonian.lineY (array) - the \(y\) coordinates of the edges connecting graph vertices.
Important
- The number of nodes in the imported adjacency matrix must match the number of nodes the Hamiltonian object is initialized with.
- The length of amp and d must be identical.
Fortran interface
This function calls the Fortran function importadjtoh() and is faster than importAdjToH(), but with a ‘pickier’ text file importer.