Skip to content

Commit

Permalink
Thermodriver printing outputs nicely
Browse files Browse the repository at this point in the history
Both A^3 and cm^3/mol values.
Now to print to file.
  • Loading branch information
2AUK committed Nov 6, 2023
1 parent 720447d commit 7295be3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
19 changes: 18 additions & 1 deletion src/thermodynamics/thermo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<f64> = Vec::new();
for i in solutions
Expand Down Expand Up @@ -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<f64>,
Expand Down

0 comments on commit 7295be3

Please sign in to comment.