vibesketcher.document.periodic_measure¶
Minimum-image measurements between the sites of a periodic structure (#189).
Distances, angles, torsions and least-squares planes are measured between
stored sites, each in a stated periodic image or, where none is stated, in
the image nearest the atom before it in the list (for a plane, nearest the
first atom). The first atom sits in its stored cell unless an image is given.
Images are integer cell translations of the stored fractional coordinates,
as in the bond graph: the position of site s in image I is
(f_s + I) @ lattice. Only periodic axes take a nonzero image.
The nearest image is found by a complete, bounded search. With a first
candidate at length d0 (the rounded fractional difference), any image
at length d <= d0 has fractional components t_k = r . b_k bounded by
d0 |b_k|, b_k the rows of the reciprocal basis (a_i . b_j =
delta_ij). Every integer image in those ranges is tried, so skewed and
triclinic cells are measured correctly; a cell needing more than
MAX_IMAGES candidates is refused (reduce it first, for example to its
Niggli cell). Images within TIE of the shortest are reported as ties;
the lexicographically smallest is used.
Conventions:
The torsion A-B-C-D follows IUPAC (Moss, Pure Appl. Chem. 68, 2193 (1996), doi:10.1351/pac199668122193): positive when, looking along B->C, the bond to A turns clockwise onto the bond to D; in (-180, 180]. It is computed as
atan2(|b2| b1 . (b2 x b3), (b1 x b2) . (b2 x b3))(Blondel and Karplus, J. Comput. Chem. 17, 1132 (1996), doi:10.1002/(SICI)1096-987X(19960715)17:9<1132::AID-JCC5>3.0.CO;2-T), which stays accurate near 0 and 180 degrees.The plane is the orthogonal least-squares plane of the atoms (Schomaker, Waser, Marsh and Bergman, Acta Cryst. 12, 600 (1959), doi:10.1107/S0365110X59001724): through the centroid, normal along the right singular vector of the centred positions with the smallest singular value. The residuals are the signed distances of the atoms from it; the rms is the smallest singular value over sqrt(n).
Measurements are read-only and never change the structure.
Functions
|
One measurement: its value, the atoms in their images and the formula's terms. |
|
Every measurement, in order, with the conventions they use. |
|
The image of |
|
|
|
Each atom with its image, Cartesian position and how the image was chosen. |
Classes
|
What to measure: a distance (2 atoms), angle (3), torsion (4) or plane (3 to 24). |
|
A site in one periodic image; with no image, the nearest one (see the module). |
- class vibesketcher.document.periodic_measure.Measurement(*, kind, atoms)¶
Bases:
BaseModelWhat to measure: a distance (2 atoms), angle (3), torsion (4) or plane (3 to 24).
Also accepted as text,
"angle: O1 Si1 O2@1,0,0": the kind (danddihedralare aliases), then site IDs separated by spaces, each with an optional@n1,n2,n3image.- Parameters:
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- kind: Kind¶
- class vibesketcher.document.periodic_measure.SiteRef(*, site, image=None)¶
Bases:
BaseModelA site in one periodic image; with no image, the nearest one (see the module).
- Parameters:
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- site: Annotated[str, StringConstraints(pattern=f'^{_SITE}$')]¶
- vibesketcher.document.periodic_measure.measure(structure, measurement)¶
One measurement: its value, the atoms in their images and the formula’s terms.
- Parameters:
structure (PeriodicStructure)
measurement (Measurement)
- Return type:
- vibesketcher.document.periodic_measure.measure_all(structure, measurements)¶
Every measurement, in order, with the conventions they use.
- Parameters:
structure (PeriodicStructure)
measurements (list[Measurement])
- Return type:
- vibesketcher.document.periodic_measure.nearest_image(structure, origin, site, *, exclude=None)¶
The image of
sitenearest the Cartesian pointorigin: image, length, ties.excludeskips one image (the same atom, when a site is measured to its own images). The search is complete for any cell (module docstring).
- vibesketcher.document.periodic_measure.parse_measurement(text)¶
"torsion: A B C@0,0,1 D"as the fields of aMeasurement.
- vibesketcher.document.periodic_measure.resolve(structure, measurement)¶
Each atom with its image, Cartesian position and how the image was chosen.
- Parameters:
structure (PeriodicStructure)
measurement (Measurement)
- Return type: