stk.cage.M4L4Square

class stk.cage.M4L4Square(corners, linkers, vertex_alignments=None, vertex_positions=None, reaction_factory=GenericReactionFactory(), num_processes=1, optimizer=<stk._internal.optimizers.null.NullOptimizer object>, scale_multiplier=1.0)[source]

Bases: Cage

Represents a cage topology graph.

Unoptimized construction

MCHammer optimized construction

Both corner and linker vertices require building blocks with two functional groups for this topology. This class replaces the building_blocks parameter with the corner and linker parameters.

See Cage for more details and examples.

Parameters:
  • corners (Iterable[BuildingBlock] | dict[BuildingBlock, tuple[int, ...]]) –

    Can be a dict which maps the BuildingBlock instances to the ids of the vertices it should be placed on.

    Can also be a BuildingBlock instance, which should be placed on all corner vertices on the topology graph.

  • linkers (Iterable[BuildingBlock] | dict[BuildingBlock, tuple[int, ...]]) –

    Can be a dict which maps the BuildingBlock instances to the ids of the vertices it should be placed on.

    Can also be a BuildingBlock instance, which should be placed on all linker vertices on the topology graph.

  • vertex_alignments (dict[int, int] | None) – A mapping from the id of a Vertex to an Edge connected to it. The Edge is used to align the first FunctionalGroup of a BuildingBlock placed on that vertex. Only vertices which need to have their default edge changed need to be present in the dict. If None then the default edge is used for each vertex. Changing which Edge is used will mean that the topology graph represents different structural isomers. The edge is referred to by a number between 0 (inclusive) and the number of edges the vertex is connected to (exclusive).

  • vertex_positions (dict[int, ndarray] | None) – A mapping from the id of a Vertex to a custom BuildingBlock position. The default vertex alignment algorithm is still applied. Only vertices which need to have their default position changed need to be present in the dict. Note that any vertices with modified positions will not be scaled like the rest of the building block positions and will not use neighbor placements in its positioning if requested by the default topology. If None then the default placement algorithm is used for each vertex.

  • reaction_factory (ReactionFactory) – The reaction factory to use for creating bonds between building blocks.

  • num_processes (int) – The number of parallel processes to create during construct().

  • optimizer (Optimizer) – Used to optimize the structure of the constructed molecule.

  • scale_multiplier (float) – Scales the positions of the vertices.

Raises:
  • AssertionError – If the any building block does not have a valid number of functional groups.

  • ValueError – If the there are multiple building blocks with the same number of functional_groups in building_blocks, and they are not explicitly assigned to vertices. The desired placement of building blocks is ambiguous in this case.

  • UnoccupiedVertexError – If a vertex of the cage topology graph does not have a building block placed on it.

  • OverlyOccupiedVertexError – If a vertex of the cage topology graph has more than one building block placed on it.

Methods

clone

Return a clone.

construct

Construct a ConstructedMolecule.

get_building_blocks

Yield the building blocks.

get_num_building_block

Get the number of times building_block is present.

get_vertex_alignments

Get the vertex alignments.

with_building_blocks

Return a clone holding different building blocks.

clone()

Return a clone.

Returns:

The clone.

Return type:

Self

construct()

Construct a ConstructedMolecule.

Returns:

The data describing the ConstructedMolecule.

Return type:

ConstructionResult

get_building_blocks()

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:

A building block of the topology graph.

Return type:

Iterator[BuildingBlock]

get_num_building_block(building_block)

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_vertex_alignments()

Get the vertex alignments.

Returns:

The vertex alignments.

Return type:

dict[int, int]

with_building_blocks(building_block_map)

Return a clone holding different building blocks.

Parameters:

building_block_map (dict[BuildingBlock, BuildingBlock]) – Maps a building block in the current topology graph to the building block which should replace it in the clone. If a building block should be not replaced in the clone, it can be omitted from the map.

Returns:

The clone.

Return type:

Self