Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ionizing committed Dec 7, 2021
2 parents b725265 + 1f2888a commit 88226bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsgrad"
version = "0.2.3"
version = "0.2.4"
authors = ["Ionizing <PeterSmith_9@outlook.com>"]
edition = "2018"

Expand Down
24 changes: 21 additions & 3 deletions src/outcar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,15 @@ impl Outcar {
.skip(2)
.take(3)
.map(|l| {
let v = l.split_whitespace()
.map(|x| x.parse::<f64>().expect("Cannot parse lattice vectors as float values"))
.collect::<Vec<f64>>();
let v = Regex::new(r"[+-]?([0-9]*[.])?[0-9]+").unwrap()
.captures_iter(l)
.take(3)
.map(|x| x.get(0)
.expect("Cannot parse lattice vector as float numbers")
.as_str()
.parse::<f64>()
.unwrap())
.collect::<Vec<f64>>();
[v[0], v[1], v[2]]
})
.collect::<Vec<[f64; 3]>>();
Expand Down Expand Up @@ -836,6 +842,18 @@ mod tests{
[0.0, 7.0, 0.0],
[0.0, 0.0, 8.0]];
assert_eq!(Outcar::parse_cell(&input), output);

let input = r#"
energy-cutoff : 194.45
volume of cell : 30194.61
direct lattice vectors reciprocal lattice vectors
32.525610787-18.778670143 0.000000000 0.030745003 0.000000000 0.000000000
0.000000000 37.557340287 0.000000000 0.015372501 0.026625954 0.000000000
0.000000000 0.000000000 24.717759990 0.000000000 0.000000000 0.040456740 "#;
let output = [[32.525610787, -18.778670143, 0.0],
[ 0.0, 37.557340287, 0.0],
[ 0.0, 0.0 , 24.71775999]];
assert_eq!(Outcar::parse_cell(&input), output);
}

#[test]
Expand Down

0 comments on commit 88226bd

Please sign in to comment.