Construction State
- class ConstructionState(building_block_vertices, edges, lattice_constants=())[source]
Bases:
object
The state of the molecule and topology graph under construction.
Methods
clone
()Return a clone.
Yield the atom infos of the molecule being constructed.
Yield the atoms of the molecule being constructed.
Yield the bond infos of the molecule being constructed.
Yield the bonds of the molecule being constructed.
get_building_block
(vertex_id)Get the building block to be placed on a given vertex.
Yield the building blocks.
get_edge
(edge_id)Get an edge.
get_edge_group_functional_groups
(edge_group)Yield the functional groups associated with edge_group.
get_edges
(vertex_id)Get the edges connect to a vertex.
Get the lattice constants of the state.
get_num_building_block
(building_block)Get the number of times building_block is present.
Get the number of edges in the topology graph.
Get the number of vertices in the topology graph.
Get the position matrix of the molecule being constructed.
get_vertices
(vertex_ids)Get the building block to be placed on a given vertex.
with_lattice_constants
(lattice_constants)Return a clone holding the lattice_constants.
with_placement_results
(vertices, edges, ...)Return a clone holding the placement results.
with_position_matrix
(position_matrix)Return a clone holding the position_matrix.
with_reaction_results
(reactions, results)Return a clone holding the reaction results.
with_vertices
(vertices)Returns a clone holding vertices.
- __init__(building_block_vertices, edges, lattice_constants=())[source]
Initialize a
ConstructionState
instance.- Parameters
building_block_vertices (
dict
) – Maps eachBuildingBlock
to be placed, to atuple
ofVertex
instances, on which it should be placed.lattice_constants (
tuple
, optional) – Anumpy.ndarray
for each lattice constant. Can be an emptytuple
if the topology graph is not periodic.
- clone()[source]
Return a clone.
- Returns
The clone. Has the same type as the original instance.
- Return type
- 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
- 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_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_lattice_constants()[source]
Get the lattice constants of the state.
- Returns
The lattice constants.
- Return type
- 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
- get_num_edges()[source]
Get the number of edges in the topology graph.
- Returns
The number of edges.
- Return type
- get_num_vertices()[source]
Get the number of vertices in the topology graph.
- Returns
The number of vertices in the topology graph.
- Return type
- get_position_matrix()[source]
Get the position matrix of the molecule being constructed.
- Returns
The position matrix.
- Return type
- 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
- with_lattice_constants(lattice_constants)[source]
Return a clone holding the lattice_constants.
- Parameters
lattice_constants (
tuple
ofnumpy.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
- with_placement_results(vertices, edges, building_blocks, results)[source]
Return a clone holding the placement results.
- Parameters
vertices (
tuple
ofVertex
) – The vertices used for placement.edges (
tuple
) – For each vertex in vertices, atuple
ofEdge
instances connected to it.building_blocks (
tuple
ofBuildingBlock
) – 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
- 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
- with_reaction_results(reactions, results)[source]
Return a clone holding the reaction results.
- Parameters
results (
ReactionResult
) – For each reaction in reactions, its result.
- Returns
The clone holding the reaction results. Has the same type as the original instance.
- Return type