Crates.io | vasp-poscar |
lib.rs | vasp-poscar |
version | 0.3.2 |
source | src |
created_at | 2018-01-09 01:39:08.660232 |
updated_at | 2020-04-17 19:25:58.589291 |
description | read and write VASP POSCAR files |
homepage | |
repository | https://github.com/ExpHP/vasp-poscar |
max_upload_size | |
id | 46045 |
size | 164,651 |
[dependencies]
vasp-poscar = "0.3.2"
A parser and printer for the POSCAR file format for representing crystallographic compounds.
POSCAR is primarily an input file format used by the Vienna Ab initio Simulation Package (VASP), which has become fairly well-supported by a wide variety of software related to crystallography and molecular dynamics.
An example file:
cubic diamond
3.7
0.5 0.5 0.0
0.0 0.5 0.5
0.5 0.0 0.5
C
2
Direct
0.0 0.0 0.0
0.25 0.25 0.25
Example code:
extern crate vasp_poscar;
use vasp_poscar::{Poscar, ScaleLine};
// read from a BufRead instance, such as &[u8] or BufReader<File>
let file = io::BufReader::new(File::open("POSCAR")?);
let poscar = Poscar::from_reader(file)?;
// get a RawPoscar object with public fields you can freely match on and manipulate
let mut poscar = poscar.into_raw();
assert_eq!(poscar.scale, ScaleLine::Factor(3.7));
poscar.comment = "[Subject Name Here] was here".into();
poscar.scale = ScaleLine::Volume(10.0);
// Turn back into a Poscar for writing.
// Notice Poscar implements Display.
let poscar = poscar.validate()?;
print!("{}", poscar); // default uses dtoa crate to format floats (roundtrip precision)
print!("{:>9.6}", poscar); // you can also specify flags to format each float
The POSCAR format is primarily equipped with two to three key pieces of information:
The structure in a POSCAR is always periodic in 3 dimensions. Lower-dimensional structures are represented approximately by assigning a long periodic length (a "vacuum separation") to the aperiodic directions. One can contrast this with XYZ files, which are only capable of representing aperiodic structures.
POSCAR also has some optional sections that are probably mostly really only used by VASP itself:
The format also unfortunately suffers a great deal from being, well... underspecified.
VASP's own documentation can be found here: http://cms.mpi.univie.ac.at/vasp/guide/node59.html. Please refer to that page for questions regarding the purpose and semantics of each element in the file.
A somewhat fuller specification of the format's syntax (as implemented by this crate) can be found at doc/format.md.
vasp-poscar
is primarily a backend-level crate for reading and writing a file format. It aims to provide:
vasp-poscar
is secondarily a crate for managing the redundant forms of data that exist within the file. Notably:
vasp-poscar
is not really a crate for doing science. It will never provide things like symmetry analysis, primitive structure search, supercell construction, perturbation of positions, or cutting across a plane, etc. These things are simply not its job.
The expectation is that the data read by vasp-poscar
may be used to construct an instance of a more versatile—and more opinionated—Structure
type implemented in another crate. (of course, if you are designing such a type, you are invited to depend on this crate as a parsing backend!)
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.