Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ionizing committed Mar 7, 2023
2 parents 5600a84 + fb9a0d3 commit 80af18f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 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.4.3"
version = "0.4.4"
authors = ["Ionizing <[email protected]>"]
edition = "2018"

Expand Down
7 changes: 6 additions & 1 deletion src/commands/gap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ pub struct Gap {

impl Gap {
fn bands_from_procar(procar: Procar, outcar: &PathBuf, efermi: Option<f64>) -> Result<(Array3<f64>, Array3<f64>, Array2<f64>)> {
let efermi = efermi.unwrap_or(fs::read_to_string(outcar)?.get_efermi()?);
// make it lazy loading
let efermi = efermi.context("")
.or_else(|_| fs::read_to_string(outcar)
.context("Reading OUTCAR failed.")
.and_then(|x| x.get_efermi())
)?;

let eigs = procar.pdos.eigvals - efermi;
let occs = procar.pdos.occupations;
Expand Down
13 changes: 9 additions & 4 deletions src/commands/wav1d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::{
Result,
OptProcess,
Axis,
range_parse,
},
commands::common::write_array_to_txt,
};
Expand All @@ -46,11 +47,15 @@ pub struct Wav1D {

#[clap(long, short = 'k', default_value = "1", multiple_values = true)]
/// Select kpoint index, starting from 1.
ikpoints: Vec<i32>,
///
/// You can input range directly: `-k 1..5 8..10`
ikpoints: Vec<String>,

#[clap(long, short = 'b', multiple_values = true)]
/// Select band index, starting from 1.
ibands: Vec<i32>,
///
/// You can input range directly: `-b 5..10 14..19`
ibands: Vec<String>,

#[clap(long, short = 'l')]
/// List the brief info of current WAVECAR.
Expand Down Expand Up @@ -147,11 +152,11 @@ I suggest you provide `gamma_half` argument to avoid confusion.");
.map(|v| v as u64 - 1)
.collect::<Vec<_>>();
let ikpoints = self.ikpoints.iter()
.cloned()
.flat_map(|x| range_parse(&x).unwrap().into_iter())
.map(|v| v as u64 - 1)
.collect::<Vec<_>>();
let ibands = self.ibands.iter()
.cloned()
.flat_map(|x| range_parse(&x).unwrap().into_iter())
.map(|v| v as u64 - 1)
.collect::<Vec<_>>();

Expand Down
13 changes: 9 additions & 4 deletions src/commands/wav3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::{
Result,
OptProcess,
Axis,
range_parse,
},
Poscar,
};
Expand All @@ -50,11 +51,15 @@ pub struct Wav3D {

#[clap(long, short = 'k', default_value = "1", multiple_values = true)]
/// Select kpoint index, starting from 1.
ikpoints: Vec<i32>,
///
/// You can input ranges directly: `-k 1..4 5..10`
ikpoints: Vec<String>,

#[clap(long, short = 'b', multiple_values = true)]
/// Select band index, starting from 1.
ibands: Vec<i32>,
///
/// You can input ranges directly: `-b 1..4 5..10`
ibands: Vec<String>,

#[clap(long, short = 'l')]
/// List the brief info of current WAVECAR.
Expand Down Expand Up @@ -167,11 +172,11 @@ I suggest you provide `gamma_half` argument to avoid confusion.");
.map(|v| v as u64 - 1)
.collect::<Vec<_>>();
let ikpoints = self.ikpoints.iter()
.cloned()
.flat_map(|x| range_parse(&x).unwrap().into_iter())
.map(|v| v as u64 - 1)
.collect::<Vec<_>>();
let ibands = self.ibands.iter()
.cloned()
.flat_map(|x| range_parse(&x).unwrap().into_iter())
.map(|v| v as u64 - 1)
.collect::<Vec<_>>();

Expand Down

0 comments on commit 80af18f

Please sign in to comment.