Skip to content

Commit

Permalink
trajectory: fix a bug in matching_configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ybyygu committed Feb 28, 2024
1 parent 034faf3 commit 595031d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/trajectory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,21 @@ pub struct Trajectory {

// [[file:../gchemol-core.note::a58ecc65][a58ecc65]]
fn matching(mol1: &Molecule, mol2: &Molecule) -> bool {
// check number of atoms
if mol1.natoms() == mol2.natoms() {
// check elements
let syms1 = mol1.symbols();
let syms2 = mol2.symbols();
if syms1.zip(syms2).all(|(s1, s2)| s1 == s2) {
// check lattice
let match_lat_none = mol1.lattice.is_none() && mol2.lattice.is_none();
let match_lat_some = mol1.lattice.is_some() && mol2.lattice.is_some();
return match_lat_none || match_lat_none;
}
// Check number of atoms
if mol1.natoms() != mol2.natoms() {
return false;
}

// Check elements
let syms1 = mol1.symbols();
let syms2 = mol2.symbols();
if !syms1.zip(syms2).all(|(s1, s2)| s1 == s2) {
return false;
}
false

// Check lattice
// Assuming the intention is to ensure both molecules are either periodic or not.
mol1.is_periodic() == mol2.is_periodic()
}
// a58ecc65 ends here

Expand Down

0 comments on commit 595031d

Please sign in to comment.