Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinRJDagleish committed Jan 2, 2024
1 parent 3271daa commit ac65a44
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 66 deletions.
29 changes: 19 additions & 10 deletions src/basisset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<f64> = (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::<i32>() as f64;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions src/calc_type/rhf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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::<f64>() / 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}",
Expand Down
13 changes: 4 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");

//##################################
Expand Down
15 changes: 2 additions & 13 deletions src/mol_int_and_deriv/oe_int.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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;
}

///////////////////////////////////////
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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);
// }
}
21 changes: 0 additions & 21 deletions src/molecule/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ impl IndexMut<usize> 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];
Expand Down
14 changes: 7 additions & 7 deletions src/print_utils/print_rhf.rs
Original file line number Diff line number Diff line change
@@ -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}", "");
Expand All @@ -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}", "");
}

0 comments on commit ac65a44

Please sign in to comment.