Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ybyygu committed Mar 7, 2023
1 parent d689f08 commit f3de950
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [[file:lattice.note::ecbf527c][ecbf527c]]
[package]
name = "gchemol-lattice"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Wenping Guo <ybyygu@gmail.com>"]
description = "Periodic 3D crystal lattice"
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,33 @@ impl Lattice {
get_cell_angles(self.matrix).into()
}

/// Scale Lattice by a positive constant
/// Scale Lattice by a positive constant `v`
pub fn scale_by(&mut self, v: f64) {
assert!(v.is_sign_positive(), "invalid scale factor: {v}");
self.matrix *= v;
self.inv_matrix = get_inv_matrix(&self.matrix);
}

/// Scale Lattice in `a` direction by a positive constant
/// Scale Lattice in `a` direction by a positive constant `v`
pub fn scale_by_a(&mut self, v: f64) {
self.scale_by_abc(v, 0)
}

/// Scale Lattice in `b` direction by a positive constant
/// Scale Lattice in `b` direction by a positive constant `v`
pub fn scale_by_b(&mut self, v: f64) {
self.scale_by_abc(v, 1)
}

/// Scale Lattice in `c` direction by a positive constant
/// Scale Lattice in `c` direction by a positive constant `v`
pub fn scale_by_c(&mut self, v: f64) {
self.scale_by_abc(v, 2)
}

/// Scale Lattice in length direction by a positive constant
fn scale_by_abc(&mut self, v: f64, i: usize) {
assert!(v.is_sign_positive(), "invalid scale factor: {v}");
let x = self.matrix.column(i);
self.matrix.set_column(i, &(x * v));
let mut x = self.matrix.column_mut(i);
x *= v;
self.inv_matrix = get_inv_matrix(&self.matrix);
}

Expand Down

0 comments on commit f3de950

Please sign in to comment.