stk.ConstructionState

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

Bases: object

The state of the molecule and topology graph under construction.

Initialize a ConstructionState instance.

Parameters:
  • building_block_vertices (dict) – Maps each BuildingBlock to be placed, to a tuple of Vertex instances, on which it should be placed.

  • edges (tuple of Edge) – The edges of the topology graph.

  • lattice_constants (tuple, optional) – A numpy.ndarray for each lattice constant. Can be an empty tuple if the topology graph is not periodic.

Methods

clone

Return a clone.

get_atom_infos

Yield the atom infos of the molecule being constructed.

get_atoms

Yield the atoms of the molecule being constructed.

get_bond_infos

Yield the bond infos of the molecule being constructed.

get_bonds

Yield the bonds of the molecule being constructed.

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_edge_group_functional_groups

Yield the functional groups associated with edge_group.

get_edges

Get the edges connected 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_position_matrix

Get the position matrix of the molecule being constructed.

get_vertices

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

with_lattice_constants

Return a clone holding the lattice_constants.

with_placement_results

Return a clone holding the placement results.

with_position_matrix

Return a clone holding the position_matrix.

with_reaction_results

Return a clone holding the reaction results.

with_vertices

Returns a clone holding vertices.

clone()[source]

Return a clone.

Returns:

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

Return type:

ConstructionState

get_atom_infos()[source]

Yield the atom infos of the molecule being constructed.

Yields:

AtomInfo – An atom info of the molecule being constructed.

get_atoms()[source]

Yield the atoms of the molecule being constructed.

Yields:

Atom – An atom of the molecule being constructed.

get_bond_infos()[source]

Yield the bond infos of the molecule being constructed.

Yields:

BondInfo – The bond info of the molecule being constructed.

get_bonds()[source]

Yield the bonds of the molecule being constructed.

Yields:

Bond – A bond of the molecule being constructed.

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_edge_group_functional_groups(edge_group)[source]

Yield the functional groups associated with edge_group.

Parameters:

edge_group (EdgeGroup) – The edge group, whose functional groups are desired.

Yields:

FunctionalGroup – A functional group which belongs to edge_group.

get_edges(vertex_id)[source]

Get the edges connected to a vertex.

Parameters:

vertex_id (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_position_matrix()[source]

Get the position matrix of the molecule being constructed.

Returns:

The position matrix.

Return type:

numpy.ndarray

get_vertices(vertex_ids)[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

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:

ConstructionState

with_placement_results(vertices, edges, building_blocks, results)[source]

Return a clone holding the placement results.

Parameters:
  • vertices (tuple of Vertex) – The vertices used for placement.

  • edges (tuple) – For each vertex in vertices, a tuple of Edge instances connected to it.

  • building_blocks (tuple of BuildingBlock) – For each vertex in vertices, the building block placed on it.

  • results (tuple of _PlacementResult) – For every vertex in vertices, the result of the placement.

Returns:

The clone holding the placement results. Has the same type as the original instance.

Return type:

ConstructionState

with_position_matrix(position_matrix)[source]

Return a clone holding the position_matrix.

Parameters:

position_matrix (numpy.ndarray) – The position matrix of the clone. The shape of the matrix is (n, 3).

Returns:

The clone holding the new position matrix. Has the same type as the original instance.

Return type:

ConstructionState

with_reaction_results(reactions, results)[source]

Return a clone holding the reaction results.

Parameters:
Returns:

The clone holding the reaction results. Has the same type as the original instance.

Return type:

ConstructionState

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:

ConstructionState