Skip to content

Commit 88226bd

Browse files
committed
Merge branch 'dev'
2 parents b725265 + 1f2888a commit 88226bd

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsgrad"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
authors = ["Ionizing <[email protected]>"]
55
edition = "2018"
66

src/outcar.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,15 @@ impl Outcar {
348348
.skip(2)
349349
.take(3)
350350
.map(|l| {
351-
let v = l.split_whitespace()
352-
.map(|x| x.parse::<f64>().expect("Cannot parse lattice vectors as float values"))
353-
.collect::<Vec<f64>>();
351+
let v = Regex::new(r"[+-]?([0-9]*[.])?[0-9]+").unwrap()
352+
.captures_iter(l)
353+
.take(3)
354+
.map(|x| x.get(0)
355+
.expect("Cannot parse lattice vector as float numbers")
356+
.as_str()
357+
.parse::<f64>()
358+
.unwrap())
359+
.collect::<Vec<f64>>();
354360
[v[0], v[1], v[2]]
355361
})
356362
.collect::<Vec<[f64; 3]>>();
@@ -836,6 +842,18 @@ mod tests{
836842
[0.0, 7.0, 0.0],
837843
[0.0, 0.0, 8.0]];
838844
assert_eq!(Outcar::parse_cell(&input), output);
845+
846+
let input = r#"
847+
energy-cutoff : 194.45
848+
volume of cell : 30194.61
849+
direct lattice vectors reciprocal lattice vectors
850+
32.525610787-18.778670143 0.000000000 0.030745003 0.000000000 0.000000000
851+
0.000000000 37.557340287 0.000000000 0.015372501 0.026625954 0.000000000
852+
0.000000000 0.000000000 24.717759990 0.000000000 0.000000000 0.040456740 "#;
853+
let output = [[32.525610787, -18.778670143, 0.0],
854+
[ 0.0, 37.557340287, 0.0],
855+
[ 0.0, 0.0 , 24.71775999]];
856+
assert_eq!(Outcar::parse_cell(&input), output);
839857
}
840858

841859
#[test]

0 commit comments

Comments
 (0)