QEqSolver

Struct QEqSolver 

Source
pub struct QEqSolver<'p> { /* private fields */ }
Expand description

The QEqSolver struct for performing charge equilibration calculations.

This is the main solver that implements the SCF iterative procedure to compute partial atomic charges based on the QEq method. The main solver for charge equilibration calculations.

This struct holds references to atomic parameters and solver options, providing methods to perform QEq calculations on molecular systems. It implements an iterative SCF procedure to solve the non-linear charge equilibration equations.

Implementations§

Source§

impl<'p> QEqSolver<'p>

Source

pub fn new(parameters: &'p Parameters) -> Self

Creates a new QEqSolver with default options.

§Arguments
  • parameters - A reference to the Parameters containing element data.
§Returns

A new QEqSolver instance with default SolverOptions.

§Examples
use cheq::{get_default_parameters, QEqSolver};

let params = get_default_parameters();
let solver = QEqSolver::new(&params);
Source

pub fn with_options(self, options: SolverOptions) -> Self

Configures the solver with custom options.

This method allows setting non-default solver parameters such as tolerance and maximum iterations. It consumes the solver and returns a new instance with the updated options.

§Arguments
  • options - The SolverOptions to apply to the solver.
§Returns

A new QEqSolver instance with the specified options.

§Examples
use cheq::{get_default_parameters, QEqSolver, SolverOptions};

let params = get_default_parameters();
let options = SolverOptions { tolerance: 1e-8, max_iterations: 50, lambda_scale: 1.0 };
let solver = QEqSolver::new(&params).with_options(options);
Source

pub fn solve<A: AtomView>( &self, atoms: &[A], total_charge: f64, ) -> Result<CalculationResult, CheqError>

Solves the charge equilibration equations for a given molecular system.

This method performs the SCF iterative procedure to compute partial atomic charges that equalize the chemical potential across all atoms, subject to the total charge constraint. The process involves building and solving a linear system in each iteration, with special handling for hydrogen atoms whose hardness depends on their charge.

§Arguments
  • atoms - A slice of atom data implementing the AtomView trait.
  • total_charge - The desired total charge of the system.
§Returns

A Result containing CalculationResult with the computed charges and metadata on success, or a CheqError on failure.

§Errors

This function can return the following errors:

  • CheqError::NoAtoms if the atom slice is empty.
  • CheqError::ParameterNotFound if parameters for an atom’s element are missing.
  • CheqError::LinalgError if the linear system cannot be solved due to numerical issues.
  • CheqError::NotConverged if the SCF procedure does not converge within the maximum iterations.
§Examples
use cheq::{get_default_parameters, QEqSolver, Atom};

let params = get_default_parameters();
let solver = QEqSolver::new(&params);
let atoms = vec![
    Atom { atomic_number: 6, position: [0.0, 0.0, 0.0] },
    Atom { atomic_number: 8, position: [1.128, 0.0, 0.0] },
];
let result = solver.solve(&atoms, 0.0).unwrap();
assert_eq!(result.charges.len(), 2);

Auto Trait Implementations§

§

impl<'p> Freeze for QEqSolver<'p>

§

impl<'p> RefUnwindSafe for QEqSolver<'p>

§

impl<'p> Send for QEqSolver<'p>

§

impl<'p> Sync for QEqSolver<'p>

§

impl<'p> Unpin for QEqSolver<'p>

§

impl<'p> UnwindSafe for QEqSolver<'p>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V