Skip to content

Commit 860d220

Browse files
authored
Merge pull request #43 from pyscal/update_cna_ids
Update cna ids
2 parents d9c3e5d + 8d88b03 commit 860d220

File tree

5 files changed

+38
-37
lines changed

5 files changed

+38
-37
lines changed

Diff for: .bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.2.3
2+
current_version = 3.2.4
33
commit = True
44
tag = True
55

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='pyscal3',
10-
version='3.2.3',
10+
version='3.2.4',
1111
author='Sarath Menon',
1212
author_email='[email protected]',
1313
description='Python library written in C++ for calculation of local atomic structural environment',

Diff for: src/pyscal3/cna.cpp

+24-23
Original file line numberDiff line numberDiff line change
@@ -551,47 +551,48 @@ void identify_diamond_cna(py::dict& atoms,
551551
vector<int> structure = atoms[py::str("structure")].cast<vector<int>>();
552552

553553
for (int ti=0; ti<nop; ti++){
554-
if (structure[ti] == 1){
555-
structure[ti] = 5;
556-
}
557-
else if (structure[ti] == 2){
558-
structure[ti] = 8;
554+
if (structure[ti] == 2){
555+
structure[ti] = 4;
559556
}
560557
}
561558

562-
//second pass
563-
for (int ti=0; ti<nop; ti++){
564-
if (structure[ti] < 5){
559+
for(int ti=0; ti<nop; ti++){
560+
if (structure[ti] == 1) continue;
561+
else if (structure[ti] == 4) continue;
562+
else {
565563
for(int i=0; i<4; i++){
566-
if(structure[first_shell[ti][i]] == 5){
567-
structure[ti] = 6;
564+
if(structure[first_shell[ti][i]] == 1){
565+
structure[ti] = 2;
568566
break;
569567
}
570-
else if(structure[first_shell[ti][i]] == 8){
571-
structure[ti] = 9;
568+
else if(structure[first_shell[ti][i]] == 4){
569+
structure[ti] = 5;
572570
break;
573-
}
571+
}
574572
}
575-
}
573+
}
574+
576575
}
577576

578-
for (int ti=0; ti<nop; ti++){
579-
if (structure[ti] < 5){
580-
//still unassigned
577+
for(int ti=0; ti<nop; ti++){
578+
if (structure[ti] == 1) continue;
579+
else if (structure[ti] == 2) continue;
580+
else if (structure[ti] == 4) continue;
581+
else if (structure[ti] == 5) continue;
582+
else {
581583
for (int j=0; j<neighbors[ti].size(); j++){
582584
int tj = neighbors[ti][j];
583-
if (structure[tj] == 5){
584-
structure[ti] = 7;
585+
if (structure[tj] == 1){
586+
structure[ti] = 3;
585587
break;
586588
}
587-
else if (structure[tj] == 8){
588-
structure[ti] = 10;
589+
else if (structure[tj] == 4){
590+
structure[ti] = 6;
589591
break;
590-
}
592+
}
591593
}
592594
}
593595
}
594-
595596
atoms[py::str("structure")] = structure;
596597

597598
}

Diff for: src/pyscal3/operations/cna.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ def identify_diamond(system):
9191
Notes
9292
-----
9393
Identify diamond structure using the algorithm mentioned in [1]. It is an
94-
extended CNA method. The integers 5, 6, 7, 8, 9 and 10 are assigned to the
95-
structure variable of the atom. 5 stands for cubic diamond, 6 stands for first
96-
nearest neighbors of cubic diamond and 7 stands for second nearest neighbors
97-
of cubic diamond. 8 signifies hexagonal diamond, the first nearest neighbors
98-
are marked with 9 and second nearest neighbors with 10.
94+
extended CNA method. The integers 1, 2, 3, 4, 5 and 6 are assigned to the
95+
structure variable of the atom. 1 stands for cubic diamond, 2 stands for first
96+
nearest neighbors of cubic diamond and 3 stands for second nearest neighbors
97+
of cubic diamond. 4 signifies hexagonal diamond, the first nearest neighbors
98+
are marked with 5 and second nearest neighbors with 6.
9999
100100
References
101101
----------
@@ -110,11 +110,11 @@ def identify_diamond(system):
110110

111111
res_dict = {
112112
"others": len([x for x in system.atoms.structure if x==0]),
113-
"cubic diamond": len([x for x in system.atoms.structure if x==5]),
114-
"cubic diamond 1NN": len([x for x in system.atoms.structure if x==6]),
115-
"cubic diamond 2NN": len([x for x in system.atoms.structure if x==7]),
116-
"hex diamond": len([x for x in system.atoms.structure if x==8]),
117-
"hex diamond 1NN": len([x for x in system.atoms.structure if x==9]),
118-
"hex diamond 2NN": len([x for x in system.atoms.structure if x==10]),
113+
"cubic diamond": len([x for x in system.atoms.structure if x==1]),
114+
"cubic diamond 1NN": len([x for x in system.atoms.structure if x==2]),
115+
"cubic diamond 2NN": len([x for x in system.atoms.structure if x==3]),
116+
"hex diamond": len([x for x in system.atoms.structure if x==4]),
117+
"hex diamond 1NN": len([x for x in system.atoms.structure if x==5]),
118+
"hex diamond 2NN": len([x for x in system.atoms.structure if x==6]),
119119
}
120120
return res_dict

Diff for: tests/test_cna.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ def test_ase_bulks():
5454
def test_cna_diamond():
5555
sys = pc.System.create.lattice.diamond(repetitions=(7,7,7), lattice_constant=4.00)
5656
sys.calculate.diamond_structure()
57-
assert sys.atoms.structure[0] == 5
57+
assert sys.atoms.structure[0] == 1

0 commit comments

Comments
 (0)