Skip to main content
← OpenMECP Documentation

solve_constrained_step

Function solve_constrained_step 

Source
pub fn solve_constrained_step(
    hessian: &DMatrix<f64>,
    gradient: &DVector<f64>,
    constraint_jacobian: &DMatrix<f64>,
    constraint_violations: &DVector<f64>,
) -> Option<(DVector<f64>, DVector<f64>)>
Expand description

Solves the augmented Hessian system for a constrained optimization step.

This function implements the core of the Lagrange multiplier method by solving the following system of linear equations:

[ H Cᵀ ] [ Δx ] = [ -∇E ] [ C 0 ] [ λ ] [ -g ]

where:

  • H: The Hessian matrix (approximated by BFGS)
  • C: The constraint Jacobian matrix
  • Cᵀ: Transpose of the constraint Jacobian
  • Δx: The step to take in atomic coordinates
  • λ: The Lagrange multipliers
  • -∇E: The negative of the energy gradient
  • -g: The negative of the constraint violation values

The solution provides the optimal step Δx that minimizes the energy while satisfying the constraints, along with the Lagrange multipliers λ that represent the constraint forces.

§Arguments

  • hessian - The approximate Hessian matrix of the energy function.
  • gradient - The gradient of the energy function (∇E).
  • constraint_jacobian - The Jacobian of the constraint functions (C).
  • constraint_violations - The current values of the constraint functions (g).

§Returns

A tuple containing:

  • delta_x: The calculated step in Cartesian coordinates.
  • lambdas: The calculated Lagrange multipliers.

Returns None if the augmented Hessian matrix is singular and cannot be inverted.