From 7295be3029e2431f3de8620c9c0ebc8bc74c92c3 Mon Sep 17 00:00:00 2001 From: Abdullah Ahmad Date: Mon, 6 Nov 2023 15:57:33 +0000 Subject: [PATCH] Thermodriver printing outputs nicely Both A^3 and cm^3/mol values. Now to print to file. --- src/main.rs | 2 ++ src/thermodynamics/thermo.rs | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index fcbcad49..56a4bcaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,5 +72,7 @@ fn main() -> Result<(), lexopt::Error> { let wv = &driver.solvent.borrow().wk; let wu = &driver.solute.as_ref().unwrap().borrow().wk; let td = TDDriver::new(solutions, wv.clone(), wu.clone()); + let thermo = td.execute(); + println!("{}", thermo); Ok(()) } diff --git a/src/thermodynamics/thermo.rs b/src/thermodynamics/thermo.rs index f8c38062..1ca7894a 100644 --- a/src/thermodynamics/thermo.rs +++ b/src/thermodynamics/thermo.rs @@ -34,7 +34,7 @@ impl std::fmt::Display for SFEs { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, - "Solvation Free Energies\nHNC: {}\nKH: {}\nGF: {}\nPW: {}\nPC+: {}", + "Solvation Free Energies:\nHNC: {}\nKH: {}\nGF: {}\nPW: {}\nPC+: {}", self.hypernettedchain, self.kovalenko_hirata, self.gaussian_fluctuations, @@ -63,6 +63,7 @@ impl Densities { let kt = solutions.config.data_config.kt; let ku = solutions.config.data_config.ku; let beta = 1.0 / kt / temp; + let density = { let mut dens_vec: Vec = Vec::new(); for i in solutions @@ -110,6 +111,22 @@ pub struct Thermodynamics { pub pressure: f64, } +impl std::fmt::Display for Thermodynamics { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "Thermodynamics:\nIsothermal Compressibility: {}\nMolecular KB PMV: {} A^3\n {} cm^3/mol\nRISM KB PMV: {} A^3\n {} cm^3/mol\nTotal Density (1/A^3): {}\nPressure: {}\n{}", + self.isothermal_compressibility, + self.molecular_kb_pmv, + self.molecular_kb_pmv / 1e24 * 6.022e23, + self.rism_kb_pmv, + self.rism_kb_pmv / 1e24 * 6.022e23, + self.total_density, + self.pressure, + self.sfe, + ) + } +} pub struct TDDriver { pub solutions: Solutions, pub(crate) wv: Array3,