Skip to content

Commit e9ba0f5

Browse files
committed
"fixed warnings for log_file"
1 parent d544739 commit e9ba0f5

File tree

3 files changed

+88
-83
lines changed

3 files changed

+88
-83
lines changed
-12 KB
Binary file not shown.

examples/cppm/log_280_0.001.log

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[2025-01-13T13:00:57Z INFO duello::energy] Adding Coulomb potential to nonbonded matrix
2-
[2025-01-13T13:00:57Z INFO duello] Medium: 𝑇 = 280.00 K, εᵣ = 85.3, λᴮ = 7.0 Å, 𝐼 = 1.0 mM, λᴰ = 97.2 Å, 0.0 M 🧂Salt = NaCl
3-
[2025-01-13T13:00:57Z INFO duello] Molecular net-charges: [-8.00e, -8.00e]
4-
[2025-01-13T13:00:57Z INFO duello] Molecular masses (g/mol): [1000000066.00e, 1000000066.00e]
5-
[2025-01-13T13:00:57Z INFO duello] COM range: [37.0, 121.0) in 0.5 Å steps 🐾
6-
[2025-01-13T13:00:57Z INFO duello::icotable] Actual angle resolution = 0.55 radians
7-
[2025-01-13T13:00:57Z INFO duello::icoscan] 6D table: 𝑅(168) x 𝜔(12) x 𝜃𝜑(42) x 𝜃𝜑(42) = 3556224 poses 💃🕺 (463.7 MB)
8-
[2025-01-13T13:01:05Z INFO duello::report] Second virial coefficient, 𝐵₂ = 2479818.43 ų
9-
[2025-01-13T13:01:05Z INFO duello::report] = 1.49e-12 mol⋅ml/g²
10-
[2025-01-13T13:01:05Z INFO duello::report] Reduced second virial coefficient, 𝐵₂ / 𝐵₂hs = 23.38 using σ = 37.00 Å
11-
[2025-01-13T13:01:05Z INFO duello::report] Plot: free energy and mean energy along mass center separation. In units of kT and angstroms.
1+
[2025-01-13T13:29:07Z INFO duello::energy] Adding Coulomb potential to nonbonded matrix
2+
[2025-01-13T13:29:07Z INFO duello] Medium: 𝑇 = 280.00 K, εᵣ = 85.3, λᴮ = 7.0 Å, 𝐼 = 1.0 mM, λᴰ = 97.2 Å, 0.0 M 🧂Salt = NaCl
3+
[2025-01-13T13:29:07Z INFO duello] Molecular net-charges: [-8.00e, -8.00e]
4+
[2025-01-13T13:29:07Z INFO duello] Molecular masses (g/mol): [1000000066.00e, 1000000066.00e]
5+
[2025-01-13T13:29:07Z INFO duello] COM range: [37.0, 121.0) in 0.5 Å steps 🐾
6+
[2025-01-13T13:29:07Z INFO duello::icotable] Actual angle resolution = 0.55 radians
7+
[2025-01-13T13:29:07Z INFO duello::icoscan] 6D table: 𝑅(168) x 𝜔(12) x 𝜃𝜑(42) x 𝜃𝜑(42) = 3556224 poses 💃🕺 (463.7 MB)
8+
[2025-01-13T13:29:16Z INFO duello::report] Second virial coefficient, 𝐵₂ = 2479818.43 ų
9+
[2025-01-13T13:29:16Z INFO duello::report] = 1.49e-12 mol⋅ml/g²
10+
[2025-01-13T13:29:16Z INFO duello::report] Reduced second virial coefficient, 𝐵₂ / 𝐵₂hs = 23.38 using σ = 37.00 Å
11+
[2025-01-13T13:29:16Z INFO duello::report] Plot: free energy and mean energy along mass center separation. In units of kT and angstroms.

src/main.rs

Lines changed: 77 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ enum Commands {
121121

122122
/// Calculate energy of all two-body poses
123123
fn do_scan(cmd: &Commands) -> Result<(), Box<dyn std::error::Error>> {
124-
let Commands::Scan {
124+
if let Commands::Scan {
125125
mol1,
126126
mol2,
127127
resolution,
@@ -137,76 +137,81 @@ fn do_scan(cmd: &Commands) -> Result<(), Box<dyn std::error::Error>> {
137137
pmf_file,
138138
log_file,
139139
} = cmd
140-
else {
141-
return Err(Box::<dyn std::error::Error>::from("No command given"));
142-
};
143-
assert!(rmin < rmax);
144-
145-
let mut topology = Topology::from_file_partial(top_file)?;
146-
faunus::topology::set_missing_epsilon(topology.atomkinds_mut(), 2.479);
147-
148-
// Either use fixed dielectric constant or calculate it from the medium
149-
let medium = match fixed_dielectric {
150-
Some(dielectric_const) => Medium::new(
151-
*temperature,
152-
permittivity::Permittivity::Fixed(*dielectric_const),
153-
Some((Salt::SodiumChloride, *molarity)),
154-
),
155-
_ => Medium::salt_water(*temperature, Salt::SodiumChloride, *molarity),
156-
};
140+
{
141+
// Use the log_file here
142+
let mut file = File::create(log_file)?;
143+
writeln!(file, "Scan command executed")?;
144+
145+
assert!(rmin < rmax);
146+
147+
let mut topology = Topology::from_file_partial(top_file)?;
148+
faunus::topology::set_missing_epsilon(topology.atomkinds_mut(), 2.479);
149+
150+
// Either use fixed dielectric constant or calculate it from the medium
151+
let medium = match fixed_dielectric {
152+
Some(dielectric_const) => Medium::new(
153+
*temperature,
154+
permittivity::Permittivity::Fixed(*dielectric_const),
155+
Some((Salt::SodiumChloride, *molarity)),
156+
),
157+
_ => Medium::salt_water(*temperature, Salt::SodiumChloride, *molarity),
158+
};
157159

158-
let multipole = coulomb::pairwise::Plain::new(*cutoff, medium.debye_length());
159-
let nonbonded = NonbondedMatrix::from_file(top_file, &topology, Some(medium.clone()))?;
160-
let pair_matrix = energy::PairMatrix::new_with_coulomb(
161-
nonbonded,
162-
topology.atomkinds(),
163-
medium.permittivity().into(),
164-
&multipole,
165-
);
166-
let ref_a = Structure::from_xyz(mol1, topology.atomkinds());
167-
let ref_b = Structure::from_xyz(mol2, topology.atomkinds());
168-
169-
info!("{}", medium);
170-
info!(
171-
"Molecular net-charges: [{:.2}e, {:.2}e]",
172-
ref_a.net_charge(),
173-
ref_b.net_charge(),
174-
);
175-
info!(
176-
"Molecular masses (g/mol): [{:.2}e, {:.2}e]",
177-
ref_a.total_mass(),
178-
ref_b.total_mass(),
179-
);
160+
let multipole = coulomb::pairwise::Plain::new(*cutoff, medium.debye_length());
161+
let nonbonded = NonbondedMatrix::from_file(top_file, &topology, Some(medium.clone()))?;
162+
let pair_matrix = energy::PairMatrix::new_with_coulomb(
163+
nonbonded,
164+
topology.atomkinds(),
165+
medium.permittivity().into(),
166+
&multipole,
167+
);
168+
let ref_a = Structure::from_xyz(mol1, topology.atomkinds());
169+
let ref_b = Structure::from_xyz(mol2, topology.atomkinds());
170+
171+
info!("{}", medium);
172+
info!(
173+
"Molecular net-charges: [{:.2}e, {:.2}e]",
174+
ref_a.net_charge(),
175+
ref_b.net_charge(),
176+
);
177+
info!(
178+
"Molecular masses (g/mol): [{:.2}e, {:.2}e]",
179+
ref_a.total_mass(),
180+
ref_b.total_mass(),
181+
);
180182

181-
// Scan over mass center distances
182-
let distances = iter_num_tools::arange(*rmin..*rmax, *dr).collect_vec();
183-
info!(
184-
"COM range: [{:.1}, {:.1}) in {:.1} Å steps 🐾",
185-
rmin, rmax, dr
186-
);
187-
if *icotable {
188-
icoscan::do_icoscan(
189-
*rmin,
190-
*rmax,
191-
*dr,
192-
*resolution,
193-
ref_a,
194-
ref_b,
195-
pair_matrix,
196-
temperature,
197-
pmf_file,
183+
// Scan over mass center distances
184+
let distances = iter_num_tools::arange(*rmin..*rmax, *dr).collect_vec();
185+
info!(
186+
"COM range: [{:.1}, {:.1}) in {:.1} Å steps 🐾",
187+
rmin, rmax, dr
198188
);
189+
if *icotable {
190+
let _ = icoscan::do_icoscan(
191+
*rmin,
192+
*rmax,
193+
*dr,
194+
*resolution,
195+
ref_a,
196+
ref_b,
197+
pair_matrix,
198+
temperature,
199+
pmf_file,
200+
);
201+
} else {
202+
let _ = do_anglescan(
203+
distances,
204+
*resolution,
205+
ref_a,
206+
ref_b,
207+
pair_matrix,
208+
temperature,
209+
pmf_file,
210+
);
211+
};
199212
} else {
200-
do_anglescan(
201-
distances,
202-
*resolution,
203-
ref_a,
204-
ref_b,
205-
pair_matrix,
206-
temperature,
207-
pmf_file,
208-
);
209-
};
213+
return Err(Box::<dyn std::error::Error>::from("No command given"));
214+
}
210215
Ok(())
211216
}
212217

@@ -394,7 +399,7 @@ fn pqr_write_atom(
394399
Ok(())
395400
}
396401

397-
fn do_main() -> Result<(), Box<dyn std::error::Error>> {
402+
/* fn do_main2() -> Result<(), Box<dyn std::error::Error>> {
398403
if std::env::var("RUST_LOG").is_err() {
399404
std::env::set_var("RUST_LOG", "info");
400405
}
@@ -411,16 +416,16 @@ fn do_main() -> Result<(), Box<dyn std::error::Error>> {
411416
}
412417
};
413418
Ok(())
414-
}
419+
} */
415420

416421
fn main() {
417-
if let Err(e) = run() {
422+
if let Err(e) = do_main() {
418423
eprintln!("Application error: {}", e);
419424
std::process::exit(1);
420425
}
421426
}
422427

423-
fn run() -> Result<(), Box<dyn std::error::Error>> {
428+
fn do_main() -> Result<(), Box<dyn std::error::Error>> {
424429
let cli = Cli::parse();
425430

426431
// Set up logging
@@ -432,7 +437,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
432437
}
433438
};
434439

435-
let mut log_file = File::create(log_path)?;
440+
let log_file = File::create(log_path)?;
436441
// Initialize the logger
437442
let mut builder = Builder::new();
438443
builder

0 commit comments

Comments
 (0)