Closed phfmatias closed 7 months ago
Implemented a function that reorders the atoms in the molecule based on their distance from the first atom. This appears to effectively address the issue of inconsistent dihedral angles.
void Molecule::reorderMolecule()
{
//create a function that reorders the molecule based on the distance with the first atom
vector <int> temp;
vector <double> distances;
vector <double> atom1 = this->molecule[0].getPos();
for (int i = 1; i < (int) this->molecule.size(); i++){
vector <double> atom2 = this->molecule[i].getPos();
distances.push_back(Vector3D(atom1, atom2).magnitude());
}
vector <double> distancesCopy = distances;
sort(distances.begin(), distances.end());
for (int i = 0; i < (int) distances.size(); i++){
for (int j = 0; j < (int) distancesCopy.size(); j++){
if (distances[i] == distancesCopy[j]){
temp.push_back(j+1);
distancesCopy[j] = -1;
break;
}
}
}
AtomList tempMolecule;
tempMolecule.push_back(this->molecule[0]);
for (int i = 0; i < (int) temp.size(); i++){
tempMolecule.push_back(this->molecule[temp[i]]);
}
this->molecule = tempMolecule;
};
I Was testing MoleKing's new feature
mol.toGJF(zmatrix=True)
with an graphene sheet, but the results was nasty. The graphene sheet was folded after MoleKing's operation.For medium~small systems the functions works fine.
Testing code:
matrix_testing.txt
PS: The file actually is a python, but GitHub do not allow uploading python files at Issues. So, just change the extension for .py.