pub trait QMInterface {
// Required methods
fn write_input(
&self,
geom: &Geometry,
header: &str,
tail: &str,
path: &Path,
) -> Result<(), QMError>;
fn run_calculation(&self, input_path: &Path) -> Result<(), QMError>;
fn read_output(
&self,
output_path: &Path,
original_geometry: &Geometry,
state: usize,
) -> Result<State, QMError>;
}Expand description
Trait that defines the interface for all quantum chemistry programs.
This trait must be implemented by each QM program to provide a uniform interface for MECP calculations. It handles the complete lifecycle of a single-point calculation: input generation, execution, and output parsing.
Required Methods§
Sourcefn write_input(
&self,
geom: &Geometry,
header: &str,
tail: &str,
path: &Path,
) -> Result<(), QMError>
fn write_input( &self, geom: &Geometry, header: &str, tail: &str, path: &Path, ) -> Result<(), QMError>
Writes a calculation input file for the quantum chemistry program.
§Arguments
geom- Molecular geometry with element types and coordinatesheader- Program-specific header section (methods, basis sets, options)tail- Additional keywords or sections specific to the calculationpath- Output path for the input file
§Returns
Returns Ok(()) on success, or a QMError if file writing fails.
Sourcefn run_calculation(&self, input_path: &Path) -> Result<(), QMError>
fn run_calculation(&self, input_path: &Path) -> Result<(), QMError>
Executes the quantum chemistry calculation.
Runs the external QM program with the input file and waits for completion. The program output is captured and checked for success status.
§Arguments
input_path- Path to the input file to execute
§Returns
Returns Ok(()) if the calculation succeeds, or a QMError if:
- The program cannot be executed (not found, permissions)
- The calculation fails (non-zero exit status)
- Runtime errors occur during execution
Sourcefn read_output(
&self,
output_path: &Path,
original_geometry: &Geometry,
state: usize,
) -> Result<State, QMError>
fn read_output( &self, output_path: &Path, original_geometry: &Geometry, state: usize, ) -> Result<State, QMError>
Parses the calculation output file to extract results.
Reads and parses the program output file to extract the electronic state properties needed for MECP optimization.
§Arguments
output_path- Path to the output/log file to parsestate- Electronic state index to extract (0 = ground state, >0 = excited state)
§Returns
Returns a Result containing:
Ok(State)- Successfully parsed state with energy, forces, and geometryErr(QMError::Parse)- Failed to parse required data from outputErr(QMError::IO)- Cannot read output file
§State Selection
The state parameter selects which electronic state to extract:
state = 0: Ground state (S0 for singlet, S1 for triplet, etc.)state = n: n-th excited state (for TD-DFT calculations)
Different programs interpret this differently:
- Gaussian: State index for TD-DFT excited states
- ORCA: State index for excited state calculations
- Other programs: May ignore this parameter