stk.GraphState

class stk.GraphState(building_block_vertices, edges, lattice_constants)[source]

Bases: object

The topology graph of a molecule under construction.

Initialize a _GraphState instance.

Parameters:

Methods

clone

Get a clone.

get_building_block

Get the building block to be placed on a given vertex.

get_building_blocks

Yield the building blocks.

get_edge

Get an edge.

get_edges

Get the edges connect to a vertex.

get_lattice_constants

Get the lattice constants of the state.

get_num_building_block

Get the number of times building_block is present.

get_num_edges

Get the number of edges in the topology graph.

get_num_vertices

Get the number of vertices in the topology graph.

get_vertices

Yield the topology graph vertices.

with_lattice_constants

Return a clone holding the lattice_constants.

with_vertices

Returns a clone holding vertices.

clone()[source]

Get a clone.

Returns:

The clone. Has the same type as the original instance.

Return type:

_GraphState

get_building_block(vertex_id)[source]

Get the building block to be placed on a given vertex.

Parameters:

vertex_id (int) – The id of the vertex, on which the building block is to be placed.

Returns:

The building block.

Return type:

BuildingBlock

get_building_blocks()[source]

Yield the building blocks.

Building blocks are yielded in an order based on their position in the topology graph. For two equivalent topology graphs, but with different building blocks, equivalently positioned building blocks will be yielded at the same time.

Yields:

BuildingBlock – A building block of the topology graph.

get_edge(edge_id)[source]

Get an edge.

Parameters:

edge_id (int) – The id of an edge.

Returns:

An edge.

Return type:

Edge

get_edges(vertex_id)[source]

Get the edges connect to a vertex.

Parameters:

vertex_id (class:int) – The id of a vertex.

Returns:

The connected edges.

Return type:

tuple of Edge

get_lattice_constants()[source]

Get the lattice constants of the state.

Returns:

The lattice constants.

Return type:

tuple of numpy.ndarray

get_num_building_block(building_block)[source]

Get the number of times building_block is present.

Parameters:

building_block (BuildingBlock) – The building block whose frequency in the topology graph is desired.

Returns:

The number of times building_block is present in the topology graph.

Return type:

int

get_num_edges()[source]

Get the number of edges in the topology graph.

Returns:

The number of edges.

Return type:

int

get_num_vertices()[source]

Get the number of vertices in the topology graph.

Returns:

The number of vertices in the topology graph.

Return type:

int

get_vertices(vertex_ids=None)[source]

Yield the topology graph vertices.

Parameters:

vertex_ids (iterable of int, optional) – The ids of vertices to yield. If None, all vertices will be yielded. Can be a single int if a single vertex is to be yielded.

Yields:

Vertex – A vertex.

with_lattice_constants(lattice_constants)[source]

Return a clone holding the lattice_constants.

Parameters:

lattice_constants (tuple of numpy.ndarray) – The lattice constants of the clone. Requires 3 arrays of size``(3, )``.

Returns:

The clone holding the new lattice constants. Has the same type as the original instance.

Return type:

_GraphState

with_vertices(vertices)[source]

Returns a clone holding vertices.

Parameters:

vertices (iterable of Vertex) – The vertices the clone should hold.

Returns:

The clone. Has the same type as the original instance.

Return type:

_GraphState