pub struct AmberDcd {
pub frames: Vec<Vec<f32>>,
pub n_atoms: usize,
}Expand description
Simplified DCD trajectory writer (CHARMM/NAMD binary format).
Writes a self-contained binary header on construction, then one frame
at a time via AmberDcd::write_frame. The output is a valid DCD
(little-endian FORTRAN record format) readable by MDAnalysis / VMD.
Note: this implementation writes a simplified 84-byte header without the full CHARMM title block; it is intended for testing and round-trip verification in OxiPhysics.
Fields§
§frames: Vec<Vec<f32>>Accumulated frame data (flat x, y, z per frame, f32 LE).
n_atoms: usizeNumber of atoms (fixed across frames).
Implementations§
Source§impl AmberDcd
impl AmberDcd
Sourcepub fn write_frame(&mut self, positions: &[[f64; 3]]) -> Result<(), String>
pub fn write_frame(&mut self, positions: &[[f64; 3]]) -> Result<(), String>
Append one frame of coordinates.
positions must have length n_atoms; returns an error otherwise.
Sourcepub fn get_position(
&self,
frame_idx: usize,
atom_idx: usize,
) -> Option<[f32; 3]>
pub fn get_position( &self, frame_idx: usize, atom_idx: usize, ) -> Option<[f32; 3]>
Get position of atom atom_idx in frame frame_idx as f32.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to a simplified DCD binary representation.
Layout (little-endian):
- 4 bytes: n_atoms (u32)
- 4 bytes: n_frames (u32)
- For each frame: 4 bytes record_len (u32), then n_atoms34 bytes (f32 LE)
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, String>
pub fn from_bytes(data: &[u8]) -> Result<Self, String>
Deserialize from the simplified DCD binary representation produced by
AmberDcd::to_bytes.
Auto Trait Implementations§
impl Freeze for AmberDcd
impl RefUnwindSafe for AmberDcd
impl Send for AmberDcd
impl Sync for AmberDcd
impl Unpin for AmberDcd
impl UnsafeUnpin for AmberDcd
impl UnwindSafe for AmberDcd
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.