fn adjust_bond_length(
geometry: &mut Geometry,
atom1: usize,
atom2: usize,
target_length: f64,
)Expand description
Adjusts the bond length between two atoms to a target value.
This function modifies the molecular geometry by moving one atom to achieve a specific bond length. It’s a simplified constraint satisfaction method used in path optimization when geometric constraints must be maintained.
§Algorithm Description
The method uses a scaling approach:
- Current distance: Calculate existing bond length
- Scaling factor: Compute ratio of target to current length
- Position adjustment: Move atom2 along the bond vector
- Coordinate update: Apply the new position to the geometry
§Mathematical Implementation
The new position of atom2 is calculated as:
r₂_new = r₁ + (target_length / current_length) × (r₂ - r₁)where:
- r₁, r₂ are the current positions of atoms 1 and 2
- target_length is the desired bond length
- current_length is the existing bond length
§Arguments
geometry- Mutable reference to the molecular geometryatom1- Index of the first atom (remains fixed)atom2- Index of the second atom (will be moved)target_length- Desired bond length in same units as coordinates
§Behavior Details
§Fixed Atom Choice
- Atom1: Remains at its original position (anchor point)
- Atom2: Moved along the bond vector to achieve target distance
§Direction Preservation
- The bond direction (unit vector) remains unchanged
- Only the magnitude (bond length) is modified
- No rotation or angular changes occur
§Edge Cases
- Zero distance: Function returns early to avoid division by zero
- Negative target: Would invert bond direction (not physically meaningful)
§Applications
- Constraint enforcement: Maintain specific bond lengths during optimization
- Geometry correction: Fix unreasonable bond distances
- Path optimization: Apply bond constraints in NEB calculations
- Structure preparation: Set up initial geometries with desired bond lengths
§Limitations
§Simplified Approach
- Single bond focus: Only considers the specified bond
- No connectivity: Ignores effects on other bonds and angles
- No energy consideration: Purely geometric adjustment
- Fixed anchor: Always keeps atom1 stationary
§Potential Issues
- Steric clashes: May create unrealistic atomic overlaps
- Angle distortion: Can distort bond angles involving these atoms
- Chain effects: Changes may propagate through molecular structure
§Future Improvements
- Mass-weighted adjustment: Move both atoms based on their masses
- Connectivity awareness: Consider effects on neighboring bonds
- Energy minimization: Combine with local energy optimization
- Multiple constraint handling: Simultaneously satisfy several constraints