You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ At a high level the library walks through:
6
6
7
7
1.**Perception:** six ordered passes (rings → Kekulé expansion → electron bookkeeping → aromaticity → resonance → hybridization) that upgrade raw connectivity into a rich `AnnotatedMolecule`.
8
8
2.**Typing:** an iterative, priority-sorted rule engine that resolves the final DREIDING atom label for every atom.
9
-
3.**Building:** a pure graph traversal that emits canonical bonds, angles, and torsions as a `MolecularTopology`.
9
+
3.**Building:** a pure graph traversal that emits canonical bonds, angles, torsions, and inversions as a `MolecularTopology`.
10
10
11
11
## Features
12
12
13
13
-**Chemically faithful perception:** built-in algorithms cover SSSR ring search, strict Kekulé expansion, charge/lone pair templates for heteroatoms, aromaticity categorization (including anti-aromatic detection), resonance propagation, and hybridization inference.
14
14
-**Deterministic typing engine:** TOML rules are sorted by priority and evaluated until a fixed point, making neighbor-dependent rules (e.g., `H_HB`) converge without guesswork.
15
-
-**Engine-agnostic topology:** outputs canonicalized bonds, angles, proper and improper dihedrals ready for any simulator that consumes DREIDING-style terms.
15
+
-**Engine-agnostic topology:** outputs canonicalized bonds, angles, torsions, and inversions ready for any simulator that consumes DREIDING-style terms.
16
16
-**Extensible ruleset:** ship with curated defaults (`resources/default.rules.toml`) and load or merge custom rule files at runtime.
17
17
-**Rust-first ergonomics:** zero `unsafe`, comprehensive unit/integration tests, and precise error variants for validation, perception, and typing failures.
Copy file name to clipboardExpand all lines: docs/01_pipeline.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,13 +46,13 @@ Once a `MolecularGraph` enters the pipeline, it is immediately converted into an
46
46
47
47
The `MolecularTopology` is the final product of the pipeline. It is a clean, structured representation tailored specifically for consumption by molecular simulation engines.
48
48
49
-
-**Purpose:** To provide a complete list of all particles and interaction terms (bonds, angles, dihedrals) required to define a DREIDING force field model.
49
+
-**Purpose:** To provide a complete list of all particles and interaction terms (bonds, angles, torsions, inversions) required to define a DREIDING force field model.
50
50
-**Structure:**
51
51
- A list of final `Atom`s, now including their assigned `atom_type`.
52
-
- Deduplicated lists of `Bond`s, `Angle`s, `ProperDihedral`s, and `ImproperDihedral`s.
52
+
- Deduplicated lists of `Bond`s, `Angle`s, `Torsion`s, and `Inversion`s.
53
53
-**Design Rationale:**
54
54
-**Simulation-Oriented:** The structure directly maps to the needs of a simulation setup. It discards intermediate perception data (like `lone_pairs` or `steric_number`) that is not directly part of the final force field definition.
55
-
-**Canonical Representation:** Each topological component (`Angle`, `Dihedral`) is stored in a canonical form (e.g., atom indices are sorted). This simplifies consumption by downstream tools, as it eliminates ambiguity and the need for further deduplication.
55
+
-**Canonical Representation:** Each topological component (`Angle`, `Torsion`, `Inversion`) is stored in a canonical form (e.g., atom indices are sorted). This simplifies consumption by downstream tools, as it eliminates ambiguity and the need for further deduplication.
56
56
57
57
## 2. The Data Flow: A Deterministic Transformation
Copy file name to clipboardExpand all lines: docs/04_topology_builder.md
+18-10Lines changed: 18 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# Phase 3: The Topology Builder
2
2
3
-
With atom types resolved, the builder translates the annotated molecule into a `MolecularTopology`. This stage is pure graph traversal — no additional chemistry is inferred — but it’s where canonical force-field terms emerge.
3
+
With atom types resolved, the builder translates the annotated molecule into a `MolecularTopology`. This stage is pure graph traversal — no additional chemistry is inferred — but it's where canonical force-field terms emerge.
4
4
5
5
`builder::build_topology` takes two inputs:
6
6
7
7
1. The immutable `AnnotatedMolecule` output of perception.
8
8
2. The `Vec<String>` of atom types returned by the typing engine.
9
9
10
-
It produces `MolecularTopology { atoms, bonds, angles, propers, impropers }`, all deduplicated and ready for downstream MD engines.
10
+
It produces `MolecularTopology { atoms, bonds, angles, torsions, inversions }`, all deduplicated and ready for downstream MD engines.
11
11
12
12
```mermaid
13
13
graph TD
@@ -18,11 +18,11 @@ graph TD
18
18
19
19
## Atom Table
20
20
21
-
`build_atoms` walks the annotated atoms and copies their element, hybridization, and ID while splicing in the final type string (`atom_types[ann_atom.id]`). This produces the topology’s `atoms` vector.
21
+
`build_atoms` walks the annotated atoms and copies their element, hybridization, and ID while splicing in the final type string (`atom_types[ann_atom.id]`). This produces the topology's `atoms` vector.
22
22
23
23
## Connectivity Terms
24
24
25
-
Every interaction term uses the molecule’s adjacency lists and bond table, which already reflect Kekulé-expanded bond orders.
25
+
Every interaction term uses the molecule's adjacency lists and bond table, which already reflect Kekulé-expanded bond orders.
26
26
27
27
### Bonds
28
28
@@ -41,24 +41,32 @@ for center in atoms:
41
41
angles.insert(Angle::new(i, center, k))
42
42
```
43
43
44
-
### Proper Dihedrals (`build_propers`)
44
+
### Torsions (`build_torsions`)
45
45
46
-
Proper torsions are enumerated around each bond `j-k`:
46
+
Torsions are enumerated around each bond `j-k`:
47
47
48
48
1. Iterate over every stored bond.
49
-
2. For each neighbor `i` of `j` (excluding `k`) and each neighbor `l` of `k` (excluding `j` and `i`), emit `ProperDihedral::new(i, j, k, l)`.
49
+
2. For each neighbor `i` of `j` (excluding `k`) and each neighbor `l` of `k` (excluding `j` and `i`), emit `Torsion::new(i, j, k, l)`.
50
50
3. The constructor compares `(i, j, k, l)` to its reverse `(l, k, j, i)` and keeps the lexicographically smaller tuple to guarantee uniqueness.
51
51
52
52
This approach naturally covers both directions (i.e., `i-j-k-l` and `l-k-j-i`) without generating duplicates.
53
53
54
-
### Improper Dihedrals (`build_impropers`)
54
+
### Inversions (`build_inversions`)
55
55
56
-
Improper torsions enforce planarity at trigonal centers. The builder scans every atom and checks two conditions:
56
+
Inversions enforce planarity at trigonal centers. The builder scans every atom and checks two conditions:
57
57
58
58
1. Degree equals 3.
59
59
2. Hybridization equals `Hybridization::SP2` or `Hybridization::Resonant`.
60
60
61
-
If satisfied, the atom’s three neighbors form the outer atoms while the center occupies the third index of `ImproperDihedral::new(p1, p2, center, p3)`. The constructor sorts the three peripheral atoms but keeps the central atom fixed, delivering a canonical key.
61
+
Per the DREIDING paper, **each planar center generates three inversion terms**, with each neighbor taking turn as the "axis":
62
+
63
+
For center I with neighbors {J, K, L}:
64
+
65
+
- Inversion(center=I, axis=J, plane={K, L})
66
+
- Inversion(center=I, axis=K, plane={J, L})
67
+
- Inversion(center=I, axis=L, plane={J, K})
68
+
69
+
The constructor `Inversion::new(center, axis, plane1, plane2)` sorts only the two plane atoms (not the axis), ensuring the three terms per center remain distinct.
-**Phase 1: Perception (`perception::perceive`):** Takes the raw `MolecularGraph` and emits an `AnnotatedMolecule`. Six ordered passes (rings, kekulization, electrons, aromaticity, resonance, hybridization) enrich each atom with bonding, charge, lone-pair, ring, and delocalization metadata. The output is immutable and shared with later stages.
53
53
54
54
-**Phase 2: Typing (`typing::engine::assign_types`):** Runs a deterministic fixed-point solver over the `AnnotatedMolecule`. It evaluates TOML rules parsed via `typing::rules::parse_rules`, honoring priorities and neighbor-dependent constraints until every atom is assigned a DREIDING type.
55
55
56
-
-**Phase 3: Building (`builder::build_topology`):** Consumes the annotated atoms plus the final type vector to produce a canonical `MolecularTopology`. Helper routines enumerate bonds, angles, proper/ improper dihedrals, and collapse duplicates using canonical ordering so downstream engines receive stable identifiers.
56
+
-**Phase 3: Building (`builder::build_topology`):** Consumes the annotated atoms plus the final type vector to produce a canonical `MolecularTopology`. Helper routines enumerate bonds, angles, torsions, and inversions, and collapse duplicates using canonical ordering so downstream engines receive stable identifiers.
0 commit comments