pub fn write_xyz(geom: &Geometry, path: &Path) -> Result<()>Expand description
Writes a molecular geometry to an XYZ file.
The XYZ format is a simple plain-text format for molecular geometries, widely used in chemistry software. It consists of:
- Number of atoms
- A comment line (empty in this implementation)
- Lines for each atom: Element X Y Z
§Arguments
geom- The molecular geometry to writepath- The path to the output XYZ file
§Returns
Returns Ok(()) on success, or an std::io::Error if file writing fails.
§Examples
use omecp::geometry::Geometry;
use omecp::io;
use std::path::Path;
fn main() -> std::io::Result<()> {
let elements = vec!["C".to_string(), "H".to_string()];
let coords = vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0];
let geometry = Geometry::new(elements, coords);
io::write_xyz(&geometry, Path::new("molecule.xyz"))?;
std::fs::remove_file("molecule.xyz")?;
Ok(())
}