Database Helpers (Internal)
These functions support the database API by handling database generation from .npz files.
Overview
The database helper layer is responsible for:
- Generating the database from .npz files to ASE
Atoms - Getting the correct structure by its molecular formula or point group key
Notes
- These functions are internal to the database layer and not intended for direct use
collections
MolSymPy reference-structure collections.
Usage
from molsympy.collections import symmetrized, unsymmetrized
# idealized / symmetrized structures
for name in symmetrized.names:
atoms = symmetrized[name]
# raw / unsymmetrized structures
atoms = unsymmetrized['C2v_1']
print(unsymmetrized.point_groups)
MolSymPyCollection
MolSymPyCollection(db, is_symmetrized: bool = False)
Collection of molecular reference structures indexed by point group.
Keys have the form '{PointGroup}_{index}' (e.g. 'C2v_1',
'Td_3', 'Ih_1').
Attributes:
-
symmetrized(bool) –True if this collection contains idealized/symmetrized structures.
-
names(list[str]) –Sorted list of all available keys.
-
point_groups(list[str]) –Sorted list of unique Schoenflies symbols in the collection.
Examples:
from molsympy.collections import symmetrized, unsymmetrized
for name in symmetrized.names:
atoms = symmetrized[name]
atoms = unsymmetrized['C2v_1']
-
API
Public API
High-level database API
collections
Source code in molsympy/collections/__init__.py
77 78 79 80 81 82 83 84 85 86 87 | |
names
property
names: list[str]
Sorted list of all keys in the collection.
point_groups
property
point_groups: list[str]
Sorted list of unique Schoenflies symbols.
formulas
property
formulas: list[str]
Sorted list of molecular formulas available in the collection.
__getitem__
__getitem__(key: str) -> Atoms
Return the structure for key as an ASE Atoms object.
Parameters:
-
key(str) –Database key of the form
'{PointGroup}_{index}', e.g.'C2v_1'.
Returns:
-
Atoms–Atoms object with
atoms.infopopulated:'point_group','index','energy','dataset'.
Raises:
-
KeyError–If key is not in the collection.
Source code in molsympy/collections/__init__.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
get
get(key: str, symbol: str | None = None) -> Atoms
Like __getitem__ but optionally override all chemical symbols.
Parameters:
-
key(str) –Database key (e.g.
'Td_1'). -
symbol(str or None, default:None) –If given, replace every element with this symbol (e.g.
'Mo').
Returns:
-
Atoms–
Source code in molsympy/collections/__init__.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |