Skip to main content
← OpenMECP Documentation

modify_method_for_run_mode

Function modify_method_for_run_mode 

Source
pub fn modify_method_for_run_mode(
    method: &str,
    program: QMProgram,
    run_mode: RunMode,
) -> String
Expand description

Dynamically modifies a QM method string based on run mode and program.

This function implements the core logic, adding program-specific keywords and run mode-specific modifications to the method string. This ensures that calculations use the correct keywords for each scenario.

§Method Modification Logic

  1. Syntax Correction (added for ORCA):

    • Replaces Gaussian-style basis set separators (/) with spaces.
    • E.g., “B3LYP/6-31G*” -> “B3LYP 6-31G*”
  2. Program-specific keywords (always added):

    • Gaussian: force (for gradient calculations)
    • ORCA: engrad (for energy and gradient calculations)
    • XTB/BAGEL: No modification needed
  3. Stability keywords (added for Stable mode):

    • Gaussian: stable=opt (perform stability analysis and reoptimize if unstable)
    • ORCA: %scf stabperform true StabRestartUHFifUnstable true end (stability analysis)
  4. Guess keywords (added for all modes except NoRead):

    • Gaussian: guess=read (read initial guess from checkpoint)
    • ORCA: !moread with %moinp "***" (read molecular orbitals)

§Arguments

  • method - The base QM method string (e.g., “B3LYP/6-31G*”)
  • program - The quantum chemistry program being used
  • run_mode - The execution mode for the calculation

§Returns

Returns a String containing the modified method with appropriate keywords added.

§Examples

use omecp::config::{QMProgram, RunMode};
use omecp::io;

// Normal mode with Gaussian
let modified = io::modify_method_for_run_mode("B3LYP/6-31G*", QMProgram::Gaussian, RunMode::Normal);
assert_eq!(modified, "B3LYP/6-31G* force guess=read");

// Normal mode with ORCA (handling Gaussian syntax)
let modified = io::modify_method_for_run_mode("B3LYP/6-31G*", QMProgram::Orca, RunMode::Normal);
assert!(modified.contains("B3LYP 6-31G*"));
assert!(modified.contains("engrad"));