One Plus One

class OnePlusOne(building_blocks, vertex_alignments=None, reaction_factory=GenericReactionFactory(), num_processes=1, optimizer=<stk.molecular.topology_graphs.topology_graph.optimizers.null.NullOptimizer object>)[source]

Bases: stk.molecular.topology_graphs.cage.cage.Cage

Represents a capsule cage topology graph.

Unoptimized construction

Collapser optimized construction

Building blocks with three functional groups are required for this topology.

When using a dict for the building_blocks parameter, as in Examples: Multi-Building Block Cage Construction, a BuildingBlock, with the following number of functional groups, needs to be assigned to each of the following vertex ids:

3-functional groups: 0 to 1

See Cage for more details and examples.

Methods

clone()

Return a clone.

construct()

Construct a ConstructedMolecule.

get_building_blocks()

Yield the building blocks.

get_num_building_block(building_block)

Get the number of times building_block is present.

with_building_blocks(building_block_map)

Return a clone holding different building blocks.

__init__(building_blocks, vertex_alignments=None, reaction_factory=GenericReactionFactory(), num_processes=1, optimizer=<stk.molecular.topology_graphs.topology_graph.optimizers.null.NullOptimizer object>)

Initialize a Cage.

Parameters
  • building_blocks (Union[Iterable[BuildingBlock], dict[BuildingBlock, tuple[int, ...]]]) –

    Can be a iterable of BuildingBlock instances, which should be placed on the topology graph.

    Can also be a dict which maps the BuildingBlock instances to the ids of the vertices it should be placed on. A dict is required when there are multiple building blocks with the same number of functional groups, because in this case the desired placement is ambiguous.

  • vertex_alignments (Optional[dict[int, int]]) – 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).

  • 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.

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.

clone()

Return a clone.

Return type

Cage

Returns

The clone.

construct()

Construct a ConstructedMolecule.

Return type

ConstructionResult

Returns

The data describing the ConstructedMolecule.

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.

Return type

int

Returns

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

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.

Return type

Cage

Returns

The clone.

class OnePlusOneVertex(id, position, edge_normal, use_neighbor_placement=True, aligner_edge=0)[source]

Bases: stk.molecular.topology_graphs.cage.vertices.NonLinearVertex

Methods

clone()

Return a clone.

get_aligner_edge()

Return the aligner edge of the vertex.

get_cell()

Get the cell of the lattice in which the vertex is found.

get_id()

Get the id.

get_position()

Get the position.

init_at_center(id, vertices)

Initialize a _CageVertex in the middle of vertices.

map_functional_groups_to_edges(...)

Map functional groups to edges.

place_building_block(building_block, edges)

Place building_block on the Vertex.

use_neighbor_placement()

True if the position should be updated based on neighbors.

with_aligner_edge(aligner_edge)

Return a clone with a different aligner_edge.

with_position(position)

Get a clone at a certain position.

with_scale(scale)

Get a clone with a scaled position.

__init__(id, position, edge_normal, use_neighbor_placement=True, aligner_edge=0)[source]

Initialize a _CageVertex.

Parameters
  • id (int) – The id of the vertex.

  • position (tuple of float) – The position of the vertex.

  • use_neighbor_placement (bool, optional) – If True, the position of the vertex will be updated based on the neighboring functional groups.

  • aligner_edge (int, optional) – The edge which is used to align the BuildingBlock placed on the vertex. The first FunctionalGroup is rotated such that it lies exactly on this Edge. Must be between 0 and the number of edges the vertex is connected to.

clone()[source]

Return a clone.

Returns

The clone.

get_aligner_edge()

Return the aligner edge of the vertex.

Returns

The aligner edge.

Return type

int

get_cell()

Get the cell of the lattice in which the vertex is found.

Return type

ndarray

Returns

The cell of the lattice in which the vertex is found.

get_id()

Get the id.

Return type

int

Returns

The id.

get_position()

Get the position.

Return type

ndarray

Returns

The position of the Vertex.

classmethod init_at_center(id, vertices)

Initialize a _CageVertex in the middle of vertices.

Parameters
  • id (int) – The id of the initialized vertex.

  • vertices (tuple of Vertex) – The vertices at whose center this one needs to be.

Returns

The new vertex.

Return type

_CageVertex

map_functional_groups_to_edges(building_block, edges)

Map functional groups to edges.

Each functional group in building_block needs to be assigned to an edge in edges.

Parameters
  • building_blockBuildingBlock The building block which is needs to have functional groups assigned to edges.

  • edges – The edges to which the vertex is attached.

Returns

A mapping from the id of a functional group in building_block to the id of the edge in edges it is assigned to.

place_building_block(building_block, edges)[source]

Place building_block on the Vertex.

Parameters
  • building_block – The building block molecule which is to be placed on the vertex.

  • edges – The edges to which the vertex is attached.

Returns

The position matrix of building_block after being placed.

use_neighbor_placement()

True if the position should be updated based on neighbors.

Returns

True if the position of the vertex should be updated based on the positions of functional groups on neighboring vertices.

Return type

bool

with_aligner_edge(aligner_edge)

Return a clone with a different aligner_edge.

Parameters

aligner_edge (int) – The aligner edge of the clone.

Returns

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

Return type

_CageVertex

with_position(position)

Get a clone at a certain position.

Parameters

position (ndarray) – The desired position of the clone.

Return type

Vertex

Returns

The clone.

with_scale(scale)

Get a clone with a scaled position.

Parameters

scale (Union[float, tuple[float, float, float]]) – The value by which the position of the Vertex is scaled. Can be a single number if all axes are scaled by the same amount or a tuple of three numbers if each axis is scaled by a different value.

Return type

Vertex

Returns

The clone.