[−][src]Struct vasp_poscar::RawPoscar
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: String
scale: ScaleLine
lattice_vectors: [[f64; 3]; 3]
group_symbols: Option<Vec<String>>
group_counts: Vec<usize>
positions: Coords
velocities: 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
Auto Trait Implementations
impl RefUnwindSafe for RawPoscar
impl Send for RawPoscar
impl Sync for RawPoscar
impl Unpin for RawPoscar
impl UnwindSafe for RawPoscar
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,