diff --git a/src/basisset/mod.rs b/src/basisset/mod.rs index e666264..14d92bc 100644 --- a/src/basisset/mod.rs +++ b/src/basisset/mod.rs @@ -157,13 +157,20 @@ impl<'a> Shell<'a> { ); pgtos.push(pgto); } - let cgto = CGTO { - pgto_vec: pgtos, - no_pgtos: no_prim, - ang_mom_type: curr_shell_def.ang_mom_char(), - ang_mom_vec: ang_mom_trip, - centre_pos: atom, - }; + // let cgto = CGTO { + // pgto_vec: pgtos, + // no_pgtos: no_prim, + // ang_mom_type: curr_shell_def.ang_mom_char(), + // ang_mom_vec: ang_mom_trip, + // centre_pos: atom, + // }; + let cgto = CGTO::new( + pgtos, + no_prim, + curr_shell_def.ang_mom_char(), + ang_mom_trip, + atom, + ); cgtos.push(cgto); } @@ -214,10 +221,12 @@ impl<'a> CGTO<'a> { fn calc_cart_norm_const_cgto(&mut self) { lazy_static! { static ref PI_3_2: f64 = PI.powf(1.5); + static ref POWERS_OF_2: Vec = (0..=10).map(|x| 2.0_f64.powi(x)).collect(); } + let mut norm_const_cgto = 0.0_f64; let L_tot = self.ang_mom_type as u32; - let pi_factor = *PI_3_2 / (2_i32.pow(L_tot) as f64) + let pi_factor = *PI_3_2 / (POWERS_OF_2[L_tot as usize]) * (self.ang_mom_vec.map(|x| double_fac(2 * x - 1))) .iter() .product::() as f64; @@ -313,12 +322,12 @@ mod tests { let test_basis = BasisSet::new("STO-3G", &mol); println!("{:?}", test_basis); } - + #[test] fn test_sh_len_offsets() { let mol = Molecule::new("data/xyz/water90.xyz", 0); let test_basis = BasisSet::new("STO-3G", &mol); - + println!("sh_len_offsets: {:?}", test_basis.sh_len_offsets); for shell in test_basis.shells.iter() { println!("Shell: {:?}\n", shell); diff --git a/src/calc_type/rhf.rs b/src/calc_type/rhf.rs index 7ccb52a..a399b8d 100644 --- a/src/calc_type/rhf.rs +++ b/src/calc_type/rhf.rs @@ -196,11 +196,8 @@ pub(crate) fn rhf_scf_normal( basis: &BasisSet, mol: &Molecule, ) -> SCF { - // TODO: - // - [ ] Print settings - // - [ ] Print initial header print_scf_header_and_settings(&calc_sett); - const show_all_conv_crit: bool = false; + const SHOW_ALL_CONV_CRIT: bool = false; let mut is_scf_conv = false; let mut scf = SCF::default(); @@ -247,7 +244,7 @@ pub(crate) fn rhf_scf_normal( // Print SCF iteration Header - match show_all_conv_crit { + match SHOW_ALL_CONV_CRIT { true => { println!( "{:>3} {:^20} {:^20} {:^20} {:^20} {:^20}", @@ -299,7 +296,7 @@ pub(crate) fn rhf_scf_normal( let delta_E = E_scf_curr - E_scf_prev; let rms_comm_val = (fps_comm.par_iter().map(|x| x * x).sum::() / fps_comm.len() as f64).sqrt(); - if show_all_conv_crit { + if SHOW_ALL_CONV_CRIT { let rms_p_val = calc_rms_2_matr(&P_matr, &P_matr_old.clone()); println!( "{:>3} {:>20.12} {:>20.12} {:>20.12} {:>20.12} {:>20.12}", diff --git a/src/main.rs b/src/main.rs index 697d248..0e533c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -#![allow(dead_code, clippy::upper_case_acronyms, non_snake_case)] +// #![allow(dead_code, clippy::upper_case_acronyms, non_snake_case)] +#![allow(clippy::upper_case_acronyms, non_snake_case)] #[macro_use] extern crate lazy_static; extern crate ndarray; @@ -26,20 +27,14 @@ fn main() { print_logo(); exec_times.start("Molecule"); - let mol = Molecule::new("data/xyz/furan.xyz", 0); - // let mol = Molecule::new("data/xyz/water90.xyz", 0); + let mol = Molecule::new("data/xyz/water90.xyz", 0); + // let mol = Molecule::new("data/xyz/furan.xyz", 0); // let mol = Molecule::new("data/xyz/calicheamicin_tinker_std.xtbopt.xyz", 0); // println!("Molecule: {:?}", _mol); exec_times.stop("Molecule"); exec_times.start("BasisSet"); let basis = BasisSet::new("STO-3G", &mol); - // println!("BasisSet: {:?}", _basis); - // println!("Molecule: {:?}", _basis); - // println!("\n\n"); - // for shell in basis.shell_iter() { - // println!("Shell: {:?}\n", shell); - // } exec_times.stop("BasisSet"); //################################## diff --git a/src/mol_int_and_deriv/oe_int.rs b/src/mol_int_and_deriv/oe_int.rs index 5fd97e8..3e90219 100644 --- a/src/mol_int_and_deriv/oe_int.rs +++ b/src/mol_int_and_deriv/oe_int.rs @@ -1,5 +1,5 @@ use ndarray::{array, Array1}; -use std::f64::consts::PI; +use std::f64::consts::{PI, TAU}; use std::vec; use crate::basisset::{CGTO, PGTO}; @@ -12,7 +12,6 @@ use crate::molecule::{ lazy_static! { pub static ref PI_FAC_OVERL: f64 = PI * PI.sqrt(); - pub static ref TWO_PI: f64 = 2.0 * PI; } /////////////////////////////////////// @@ -177,7 +176,7 @@ pub fn calc_pot_int_cgto(cgto1: &CGTO, cgto2: &CGTO, mol: &Molecule) -> f64 { * pgto1.pgto_coeff() * pgto2.pgto_coeff() * R_recurr_val - * *TWO_PI + * TAU / (pgto1.alpha() + pgto2.alpha()); } } @@ -338,14 +337,4 @@ mod tests { assert_relative_eq!(pot_val, POT_VAL_REF_2, epsilon = 1e-8); } - - // #[test] - // fn test_calc_eri_cgto_test1() { - // let atom = Atom::new(0.0, 0.0, 0.0, 8, crate::molecule::PseElemSym::O); - // let (cgto1, cgto2) = init_two_same_cgtos(&atom); - // let (cgto3, cgto4) = init_two_same_cgtos(&atom); - // - // let eri_val = calc_ERI_int_cgto(&cgto1, &cgto2, &cgto3, &cgto4); - // println!("ERI val: {}", eri_val); - // } } diff --git a/src/molecule/atom.rs b/src/molecule/atom.rs index 4439757..af977f9 100644 --- a/src/molecule/atom.rs +++ b/src/molecule/atom.rs @@ -77,27 +77,6 @@ impl IndexMut for Atom { } } -// impl Sub for Atom { -// type Output = f64; -// fn sub(self, other: Self) -> Self::Output { -// let dx = self.x - other.x; -// let dy = self.y - other.y; -// let dz = self.z - other.z; -// (dx * dx + dy * dy + dz * dz).sqrt() -// } -// } -// -// impl<'a> Sub for &'a Atom { -// type Output = f64; -// -// fn sub(self, other: Self) -> Self::Output { -// let dx = self.x - other.x; -// let dy = self.y - other.y; -// let dz = self.z - other.z; -// (dx * dx + dy * dy + dz * dz).sqrt() -// } -// } - impl Atom { pub(crate) fn new(x_inp: f64, y_inp: f64, z_inp: f64, z_val: u32, pse_sym: PseElemSym) -> Self { let mass = ATOMIC_MASSES_IN_AMU[z_val as usize]; diff --git a/src/print_utils/print_rhf.rs b/src/print_utils/print_rhf.rs index 7386290..caa700c 100644 --- a/src/print_utils/print_rhf.rs +++ b/src/print_utils/print_rhf.rs @@ -1,4 +1,4 @@ -use crate::{calc_type::CalcSettings, print_utils::{print_header_for_section, fmt_f64}}; +use crate::calc_type::CalcSettings; pub(crate) fn print_scf_header_and_settings(calc_sett: &CalcSettings) { println!("{:=>35}", ""); @@ -7,12 +7,12 @@ pub(crate) fn print_scf_header_and_settings(calc_sett: &CalcSettings) { println!("{:-20}", ""); println!("SCF settings:"); - println!(" {:<20} {:>10e}","ΔE THRESH", calc_sett.e_diff_thrsh); - println!(" {:<20} {:>10e}","RMS FPS THRESH", calc_sett.commu_conv_thrsh); + println!(" {:<20} {:>10e}", "ΔE THRESH", calc_sett.e_diff_thrsh); + println!( " {:<20} {:>10e}", "RMS FPS THRESH", calc_sett.commu_conv_thrsh); println!(" {:<20} {:>10}", "Direct SCF", calc_sett.use_direct_scf); - println!(" {:<20} {:>10}","Use DIIS", calc_sett.use_diis); - println!(" {:<20} {:>10}","DIIS Settings", ""); - println!(" {:<20} {:>8}","DIIS MIN", calc_sett.diis_sett.diis_min); - println!(" {:<20} {:>8}","DIIS MAX", calc_sett.diis_sett.diis_max); + println!(" {:<20} {:>10}", "Use DIIS", calc_sett.use_diis); + println!(" {:<20} {:>10}", "DIIS Settings", ""); + println!(" {:<20} {:>8}", "DIIS MIN", calc_sett.diis_sett.diis_min); + println!(" {:<20} {:>8}", "DIIS MAX", calc_sett.diis_sett.diis_max); println!("{:-20}", ""); }