fn calculate_constraint_violation(
geometry: &Geometry,
constraint: &Constraint,
) -> f64Expand description
Calculates the constraint violation for a single geometric constraint.
This function evaluates how much the current geometry deviates from the target constraint value. The violation is the difference between the current coordinate value and the desired target value.
§Mathematical Definition
For a constraint g(x) = target, the violation is:
violation = g(x) - target§Arguments
geometry- Current molecular geometryconstraint- The geometric constraint to evaluate
§Returns
The constraint violation as a signed value:
- Positive: Current value exceeds target
- Negative: Current value is below target
- Zero: Constraint is perfectly satisfied
§Examples
For a bond constraint with target 1.5 Angstrom:
- Current bond = 1.8 Angstrom → violation = +0.3 Angstrom (too long)
- Current bond = 1.2 Angstrom → violation = -0.3 Angstrom (too short)
- Current bond = 1.5 Angstrom → violation = 0.0 Angstrom (satisfied)