[][src]Struct vasp_poscar::RawPoscar

pub struct RawPoscar {
    pub comment: String,
    pub scale: ScaleLine,
    pub lattice_vectors: [[f64; 3]; 3],
    pub group_symbols: Option<Vec<String>>,
    pub group_counts: Vec<usize>,
    pub positions: Coords,
    pub velocities: Option<Coords>,
    pub dynamics: Option<Vec<[bool; 3]>>,
    // some fields omitted
}

Unencumbered struct form of a Poscar with public data members.

This is basically the Poscar type, minus all the type-protected invariants which ensure that it can be printed.

General notes

Working with this type requires you to be familiar with the POSCAR format. Its fields map one-to-one with the sections of a POSCAR file. Please see the VASP documentation for help regarding its semantics.

Important: not mentioned on that page is the symbols line, which may appear right after the lattice vectors, before the counts. The number of symbols must match the number of counts. Example with a symbols line:

Cubic BN
   3.57
 0.0 0.5 0.5
 0.5 0.0 0.5
 0.5 0.5 0.0
   B N
   1 1
Direct
 0.00 0.00 0.00
 0.25 0.25 0.25

Construction

From data

A RawPoscar can be constructed using the Builder API.

use vasp_poscar::{Builder, ScaleLine, Coords};

let poscar =
    Builder::new()
    .comment("Cubic BN")
    .scale(ScaleLine::Factor(3.57))
    .lattice_vectors(&[
        [0.0, 0.5, 0.5],
        [0.5, 0.0, 0.5],
        [0.5, 0.5, 0.0],
    ])
    .group_symbols(vec!["B", "N"])
    .group_counts(vec![1, 1])
    .positions(Coords::Frac(vec![
        [0.00, 0.00, 0.00],
        [0.25, 0.25, 0.25],
    ]))
    .build_raw();

From a file

You may parse the file into a Poscar first.

let poscar = Poscar::from_path("tests/POSCAR")?.into_raw();

Manipulation

All fields are public, barring a single trivial private field used to prevent construction. You can freely access and manipulate the data fields as you see fit.

Display

Because it may contain invalid data, a RawPoscar object cannot be printed. To write a RawPoscar to a file, use the validate method to obtain a Poscar first.

// suppose you have a RawPoscar
let raw = get_raw_poscar();

// validate() will "upgrade" it into a Poscar...
let poscar = raw.validate()?;
// ...which can be printed.
print!("{}", poscar);

Fields

comment: Stringscale: ScaleLinelattice_vectors: [[f64; 3]; 3]group_symbols: Option<Vec<String>>group_counts: Vec<usize>positions: Coordsvelocities: Option<Coords>dynamics: Option<Vec<[bool; 3]>>

Methods

impl RawPoscar[src]

pub fn validate(self) -> Result<Poscar, ValidationError>[src]

Convert into a Poscar object after checking its invariants.

To see what those invariants are, check the docs for ValidationError.

Trait Implementations

impl Clone for RawPoscar[src]

impl Debug for RawPoscar[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.