pub fn modify_method_for_run_mode(
method: &str,
program: QMProgram,
run_mode: RunMode,
) -> StringExpand 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
-
Syntax Correction (added for ORCA):
- Replaces Gaussian-style basis set separators (
/) with spaces. - E.g., “B3LYP/6-31G*” -> “B3LYP 6-31G*”
- Replaces Gaussian-style basis set separators (
-
Program-specific keywords (always added):
- Gaussian:
force(for gradient calculations) - ORCA:
engrad(for energy and gradient calculations) - XTB/BAGEL: No modification needed
- Gaussian:
-
Stability keywords (added for
Stablemode):- Gaussian:
stable=opt(perform stability analysis and reoptimize if unstable) - ORCA:
%scf stabperform true StabRestartUHFifUnstable true end(stability analysis)
- Gaussian:
-
Guess keywords (added for all modes except
NoRead):- Gaussian:
guess=read(read initial guess from checkpoint) - ORCA:
!moreadwith%moinp "***"(read molecular orbitals)
- Gaussian:
§Arguments
method- The base QM method string (e.g., “B3LYP/6-31G*”)program- The quantum chemistry program being usedrun_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"));