#input-file #file-format #castep #chemistry #cell #edit #save

castep-cell-io

A crate helping to parse, edit and save castep input file format .cell

25 releases

0.2.15 Jan 21, 2025
0.2.14 Jan 21, 2025
0.2.11 Dec 24, 2024
0.2.9 Oct 28, 2024
0.1.5 May 22, 2024

#701 in Parser implementations

Download history 191/week @ 2024-10-22 70/week @ 2024-10-29 24/week @ 2024-11-05 4/week @ 2024-11-19 1/week @ 2024-12-03 10/week @ 2024-12-10 240/week @ 2024-12-24 2/week @ 2025-01-07 404/week @ 2025-01-21 6/week @ 2025-01-28 50/week @ 2025-02-04

461 downloads per month
Used in 2 crates

MIT license

155KB
4.5K SLoC

castep-cell-io

A crate helping to parse, edit and save .cell of Castep.

Development

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.

Usage

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();

Dependencies

~7.5MB
~162K SLoC