createH

Graph2P.createH(filename, filetype, d=None, amp=None, layout='spring', delimiter=None, interaction=0.0, bosonic=False)

Generate the Hamiltonian of the graph.

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]).
layout (str): the format to store the position of the nodes (only used

when running plotGraph()).

  • 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 two walkers when located on the same vertex.

bosonic (bool): if true, a Bosonic Hamiltonian is generated.

Returns:
:this creates a Hamiltonian object, accessed via the attibute
Graph2P.H.
rtype:pyCTQW.MPI.ctqw.Hamiltonian()
Note:
This needs to be called only if the filename and filetype of the graph were not already called when the Graph object was initialized.

Important

  • The number of nodes in the imported adjacency matrix must match the number of nodes the Graph2P object is initialized with.

  • The size of amp and d must be identical

    >>> amp = [0.5,-1.,4.2]
    >>> len(d) == len(amp)
    True