Skip to content

Update cna ids #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3
current_version = 3.2.4
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.3',
version='3.2.4',
author='Sarath Menon',
author_email='[email protected]',
description='Python library written in C++ for calculation of local atomic structural environment',
Expand Down
47 changes: 24 additions & 23 deletions src/pyscal3/cna.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,47 +551,48 @@ 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] == 1){
structure[ti] = 5;
}
else if (structure[ti] == 2){
structure[ti] = 8;
if (structure[ti] == 2){
structure[ti] = 4;
}
}

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

}

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

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

}
22 changes: 11 additions & 11 deletions src/pyscal3/operations/cna.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ def identify_diamond(system):
Notes
-----
Identify diamond structure using the algorithm mentioned in [1]. It is an
extended CNA method. The integers 5, 6, 7, 8, 9 and 10 are assigned to the
structure variable of the atom. 5 stands for cubic diamond, 6 stands for first
nearest neighbors of cubic diamond and 7 stands for second nearest neighbors
of cubic diamond. 8 signifies hexagonal diamond, the first nearest neighbors
are marked with 9 and second nearest neighbors with 10.
extended CNA method. The integers 1, 2, 3, 4, 5 and 6 are assigned to the
structure variable of the atom. 1 stands for cubic diamond, 2 stands for first
nearest neighbors of cubic diamond and 3 stands for second nearest neighbors
of cubic diamond. 4 signifies hexagonal diamond, the first nearest neighbors
are marked with 5 and second nearest neighbors with 6.

References
----------
Expand All @@ -110,11 +110,11 @@ def identify_diamond(system):

res_dict = {
"others": len([x for x in system.atoms.structure if x==0]),
"cubic diamond": len([x for x in system.atoms.structure if x==5]),
"cubic diamond 1NN": len([x for x in system.atoms.structure if x==6]),
"cubic diamond 2NN": len([x for x in system.atoms.structure if x==7]),
"hex diamond": len([x for x in system.atoms.structure if x==8]),
"hex diamond 1NN": len([x for x in system.atoms.structure if x==9]),
"hex diamond 2NN": len([x for x in system.atoms.structure if x==10]),
"cubic diamond": len([x for x in system.atoms.structure if x==1]),
"cubic diamond 1NN": len([x for x in system.atoms.structure if x==2]),
"cubic diamond 2NN": len([x for x in system.atoms.structure if x==3]),
"hex diamond": len([x for x in system.atoms.structure if x==4]),
"hex diamond 1NN": len([x for x in system.atoms.structure if x==5]),
"hex diamond 2NN": len([x for x in system.atoms.structure if x==6]),
}
return res_dict
2 changes: 1 addition & 1 deletion tests/test_cna.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def test_ase_bulks():
def test_cna_diamond():
sys = pc.System.create.lattice.diamond(repetitions=(7,7,7), lattice_constant=4.00)
sys.calculate.diamond_structure()
assert sys.atoms.structure[0] == 5
assert sys.atoms.structure[0] == 1
Loading