Skip to main content

solvate_structure

Function solvate_structure 

Source
pub fn solvate_structure(
    structure: &mut Structure,
    config: &SolvateConfig,
) -> Result<(), Error>
Expand description

Builds a solvent box, translates the solute to the padded origin, and inserts ions.

The function removes existing solvent when requested, computes an orthorhombic box from the solute bounds plus margins, packs waters on a regular grid while randomizing orientation, and finally replaces selected waters with ions to reach the target charge.

§Arguments

  • structure - Mutable structure containing the solute atoms to surround with solvent.
  • config - Parameters controlling padding, spacing, ion species, and RNG seeding.

§Returns

Ok(()) when solvent and ions are generated successfully.

§Errors

Returns Error::MissingInternalTemplate if the water template is absent, Error::BoxTooSmall when insufficient waters remain for ion swapping, or Error::IonizationFailed when the requested charge cannot be achieved.