Crates.io | castep-cell-io |
lib.rs | castep-cell-io |
version | 0.2.9 |
source | src |
created_at | 2024-05-20 14:00:27.874285 |
updated_at | 2024-10-28 13:36:57.679267 |
description | A crate helping to parse, edit and save `castep` input file format `.cell` |
homepage | https://github.com/TonyWu20/castep-cell-io |
repository | https://github.com/TonyWu20/castep-cell-io |
max_upload_size | |
id | 1245746 |
size | 152,248 |
A crate helping to parse, edit and save .cell
of Castep
.
Currently, the parser can seek and parse the two required block entries in the .cell
regardless of their appearance orders in the file: lattice parameters (LATTICE_CART
or LATTICE_ABC
) and ionic positions (POSITIONS_FRAC
or POSITIONS_ABS
).
POSITIONS_XXX_INTERMEDIATE
and POSITIONS_XXX_PRODUCT
are supported if feature TS
is turned on.
Contents after comment marks (#
or !
) are supposed to be ignored. The comments should not break the valid format of the data. The parser fails when the comment cut the necessary data, just as how castep
fails when accepting such input .cell
.
More keywords and data are supported in the future.
Add the crate by cargo
cargo add castep-cell-parser
In your code:
use std::{fs, path::Path};
use castep_cell_parser::{CellParser, CellDocument};
let path = Path::new("SAC_GDY_V.cell");
let input = fs::read_to_string(path).unwrap();
let mut cell_parser = CellParser::from(&input.as_str());
let cell_doc: CellDocument = cell_parser.parse().unwrap();