Skip to content

Commit

Permalink
Merge pull request #44 from pyscal/update_cna_ids
Browse files Browse the repository at this point in the history
Update cna ids
  • Loading branch information
srmnitc authored Jul 9, 2024
2 parents 860d220 + f69eed1 commit d765e1f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.2.4
current_version = 3.2.5
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='pyscal3',
version='3.2.4',
version='3.2.5',
author='Sarath Menon',
author_email='[email protected]',
description='Python library written in C++ for calculation of local atomic structural environment',
Expand Down
69 changes: 45 additions & 24 deletions src/pyscal3/cna.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,48 +551,69 @@ void identify_diamond_cna(py::dict& atoms,
vector<int> structure = atoms[py::str("structure")].cast<vector<int>>();

for (int ti=0; ti<nop; ti++){
if (structure[ti] == 2){
structure[ti] = 4;
if (structure[ti] == 1){
structure[ti] = 5;
}
else if (structure[ti] == 2){
structure[ti] = 8;
}
}

for(int ti=0; ti<nop; ti++){
if (structure[ti] == 1) continue;
else if (structure[ti] == 4) continue;
else {
//second pass
for (int ti=0; ti<nop; ti++){
if (structure[ti] < 5){
for(int i=0; i<4; i++){
if(structure[first_shell[ti][i]] == 1){
structure[ti] = 2;
if(structure[first_shell[ti][i]] == 5){
structure[ti] = 6;
break;
}
else if(structure[first_shell[ti][i]] == 4){
structure[ti] = 5;
else if(structure[first_shell[ti][i]] == 8){
structure[ti] = 9;
break;
}
}
}
}

}
}

for(int ti=0; ti<nop; ti++){
if (structure[ti] == 1) continue;
else if (structure[ti] == 2) continue;
else if (structure[ti] == 4) continue;
else if (structure[ti] == 5) continue;
else {
for (int ti=0; ti<nop; ti++){
if (structure[ti] < 5){
//still unassigned
for (int j=0; j<neighbors[ti].size(); j++){
int tj = neighbors[ti][j];
if (structure[tj] == 1){
structure[ti] = 3;
if (structure[tj] == 5){
structure[ti] = 7;
break;
}
else if (structure[tj] == 4){
structure[ti] = 6;
else if (structure[tj] == 8){
structure[ti] = 10;
break;
}
}
}
}
}

//map ids
for (int ti=0; ti<nop; ti++){
if (structure[ti] == 5){
structure[ti] = 1;
}
else if (structure[ti] == 6){
structure[ti] = 2;
}
else if (structure[ti] == 7){
structure[ti] = 3;
}
else if (structure[ti] == 8){
structure[ti] = 4;
}
else if (structure[ti] == 9){
structure[ti] = 5;
}
else if (structure[ti] == 10){
structure[ti] = 6;
}
}

atoms[py::str("structure")] = structure;

}

0 comments on commit d765e1f

Please sign in to comment.