Skip to main content

DcdWriter

Struct DcdWriter 

Source
pub struct DcdWriter {
    pub path: PathBuf,
    pub n_atoms: u32,
    pub delta: f32,
    /* private fields */
}
Expand description

DCD trajectory writer — produces files in the standard CHARMM/NAMD binary DCD format that can be read by DcdReader and common molecular dynamics visualisation tools (VMD, NAMD, etc.).

§Usage

use oxiphysics_io::DcdWriter;

let mut w = DcdWriter::new("/tmp/traj.dcd", 10, 2.0e-3).unwrap();
// write frames …
w.finalize().unwrap();  // patches the frame count in the header

Fields§

§path: PathBuf

Output path.

§n_atoms: u32

Number of atoms per frame.

§delta: f32

Integration time-step (ps).

Implementations§

Source§

impl DcdWriter

Source

pub fn new(path: impl Into<PathBuf>, n_atoms: u32, delta: f32) -> Result<Self>

Create a new DcdWriter, truncating / creating the output file and writing an initial DCD header.

Source

pub fn write_frame(&mut self, frame: &ParticleFrame) -> Result<()>

Append one coordinate frame to the DCD file.

The frame must contain at least n_atoms positions; extra positions are silently ignored, missing ones are padded with 0.0.

Source

pub fn finalize(&self) -> Result<()>

Patch the frame count stored in the DCD header (byte offset 8) with the actual number of frames written, then flush the file.

Call this once after all frames have been written.

Trait Implementations§

Source§

impl Debug for DcdWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.