system
The atomic configuration a calculator is asked about.
System holds atomic numbers, Cartesian positions, lattice vectors,
periodicity, and a dictionary of whatever else a model wants (a charge, a spin,
an external field). Everything chemical -- bonding, symmetry, molecules --
stays in Crystal and Molecule, which convert to and from a System.
Two invariants are worth knowing before using it.
The arrays are read-only, and changing a geometry goes through a setter
which installs a new array and increments version. That makes
(id(system), version) a complete identifier for a geometry, so a cached
result can be validated in constant time, and it makes a stale read impossible
rather than merely unlikely -- system.positions[0] += 0.1 raises rather than
quietly leaving a cache valid.
The cell is always a (3, 3) array with the lattice vectors as rows,
matching chmpy.crystal.UnitCell.direct. Non-periodic directions carry a zero
row, so "is there a cell" and "is it periodic" are the same question.
System
An atomic configuration: numbers, positions, cell, periodicity.
Lengths are Angstroms and positions are Cartesian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numbers
|
(N,) atomic numbers |
required | |
positions
|
(N, 3) Cartesian positions in Angstroms |
required | |
cell
|
(3, 3) lattice vectors as rows, or None for an isolated system |
None
|
|
pbc
|
(3,) booleans, or a single bool for all three directions. Defaults to True in every direction when a cell is given, False otherwise. |
None
|
|
info
|
model inputs that are not geometry, e.g. |
None
|
Examples:
>>> s = System([8, 1, 1], [[0, 0, 0], [0.76, 0.59, 0], [-0.76, 0.59, 0]])
>>> len(s), s.periodic
(3, False)
Source code in chmpy/calc/system.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
cell
property
(3, 3) lattice vectors as rows in Angstroms, read-only; zeros if isolated
n_atoms
property
Number of atoms
numbers
property
(N,) atomic numbers, read-only
pbc
property
(3,) which directions are periodic, read-only
periodic
property
True if every direction is periodic
positions
property
(N, 3) Cartesian positions in Angstroms, read-only
scaled_positions
property
(N, 3) fractional coordinates. Raises for an isolated system.
version
property
Bumped by every geometry change.
(id(system), system.version) identifies a geometry, so a cached
result can be validated in constant time.
volume
property
Cell volume in Angstrom^3, or 0.0 for an isolated system
copy()
from_ase(atoms)
classmethod
from_crystal(crystal, **info)
classmethod
The P1 unit cell of a Crystal, with no symmetry attached.
Source code in chmpy/calc/system.py
from_molecule(molecule, **info)
classmethod
set_cell(cell, scale_atoms=False)
Replace the lattice vectors (rows, Angstroms) and bump version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
(3, 3) new lattice vectors as rows |
required | |
scale_atoms
|
bool
|
carry the atoms along in fractional coordinates rather than leaving them where they are in Cartesian space |
False
|
Source code in chmpy/calc/system.py
set_positions(positions)
Replace the Cartesian positions (Angstroms) and bump version.
set_scaled_positions(scaled)
to_ase()
Convert to an ase.Atoms.
Source code in chmpy/calc/system.py
to_crystal(space_group=1)
A Crystal in the given space group, the atoms taken as its asymmetric unit.
The default, P1, is the honest reading of a System: it carries no
symmetry, so anything higher is a claim the caller is making.
Source code in chmpy/calc/system.py
to_molecule()
wrapped()
A copy with every atom brought into the [0, 1) fractional cell.