qsym2/interfaces/qchem/
mod.rs1use std::path::PathBuf;
4
5use anyhow::Context;
6use serde::{Deserialize, Serialize};
7
8use crate::drivers::representation_analysis::angular_function::AngularFunctionRepAnalysisParams;
9use crate::drivers::representation_analysis::slater_determinant::SlaterDeterminantRepAnalysisParams;
10use crate::drivers::QSym2Driver;
11use crate::drivers::representation_analysis::vibrational_coordinate::VibrationalCoordinateRepAnalysisParams;
12use crate::interfaces::input::analysis::{
13 SlaterDeterminantSourceHandle, VibrationalCoordinateSourceHandle,
14};
15use crate::interfaces::input::SymmetryGroupDetectionInputKind;
16use crate::interfaces::qchem::hdf5::slater_determinant::QChemSlaterDeterminantH5Driver;
17use crate::interfaces::qchem::hdf5::vibrational_coordinate::QChemVibrationH5Driver;
18
19pub mod hdf5;
20
21#[derive(Clone, Serialize, Deserialize)]
28pub struct QChemArchiveSlaterDeterminantSource {
29 pub path: PathBuf,
31}
32
33impl Default for QChemArchiveSlaterDeterminantSource {
34 fn default() -> Self {
35 QChemArchiveSlaterDeterminantSource {
36 path: PathBuf::from("path/to/qchem/qarchive.h5"),
37 }
38 }
39}
40
41impl SlaterDeterminantSourceHandle for QChemArchiveSlaterDeterminantSource {
42 type Outcome = Vec<(String, String)>;
43
44 fn sd_source_handle(
45 &self,
46 pd_params_inp: &SymmetryGroupDetectionInputKind,
47 afa_params: &AngularFunctionRepAnalysisParams,
48 sda_params: &SlaterDeterminantRepAnalysisParams<f64>,
49 ) -> Result<Self::Outcome, anyhow::Error> {
50 let qchemarchive_path = &self.path;
51 let mut qchem_h5_driver = QChemSlaterDeterminantH5Driver::builder()
52 .filename(qchemarchive_path.into())
53 .symmetry_group_detection_input(&pd_params_inp)
54 .angular_function_analysis_parameters(&afa_params)
55 .rep_analysis_parameters(&sda_params)
56 .build()
57 .with_context(|| "Unable to construct a Q-Chem HDF5 driver when handling Q-Chem archive Slater determinant source")?;
58 qchem_h5_driver.run().with_context(|| "Unable to execute the Q-Chem HDF5 driver successfully when handling Q-Chem archive Slater determinant source")?;
59 qchem_h5_driver.result().cloned()
60 }
61}
62
63#[derive(Clone, Serialize, Deserialize)]
70pub struct QChemArchiveVibrationalCoordinateSource {
71 pub path: PathBuf,
73}
74
75impl Default for QChemArchiveVibrationalCoordinateSource {
76 fn default() -> Self {
77 QChemArchiveVibrationalCoordinateSource {
78 path: PathBuf::from("path/to/qchem/qarchive.h5"),
79 }
80 }
81}
82
83impl VibrationalCoordinateSourceHandle for QChemArchiveVibrationalCoordinateSource {
84 type Outcome = Vec<(String, String)>;
85
86 fn vc_source_handle(
87 &self,
88 pd_params_inp: &SymmetryGroupDetectionInputKind,
89 afa_params: &AngularFunctionRepAnalysisParams,
90 vca_params: &VibrationalCoordinateRepAnalysisParams<f64>,
91 ) -> Result<Self::Outcome, anyhow::Error> {
92 let qchemarchive_path = &self.path;
93 let mut qchem_h5_driver = QChemVibrationH5Driver::builder()
94 .filename(qchemarchive_path.into())
95 .symmetry_group_detection_input(&pd_params_inp)
96 .angular_function_analysis_parameters(&afa_params)
97 .rep_analysis_parameters(&vca_params)
98 .build()
99 .with_context(|| "Unable to construct a Q-Chem HDF5 driver when handling Q-Chem archive vibrational coordinate source")?;
100 qchem_h5_driver.run().with_context(|| "Unable to execute the Q-Chem HDF5 driver successfully when handling Q-Chem archive vibrational coordinate source")?;
101 qchem_h5_driver.result().cloned()
102 }
103}