Mateus-RB / MoleKing

MoleKing is a python module for chemists aiming to add common principles to python. This module adds new types of python variables, MoleKing_Molecule; MoleKing_Atom; MoleKing_SupraMolecule, and MoleKing_Output, alongside many features considered common knowledge among chemists.
MIT License
1 stars 0 forks source link

Z Matrix function for big systems. #75

Closed phfmatias closed 7 months ago

phfmatias commented 7 months ago

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.

Screenshot from 2024-02-20 17-04-41

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.

Mateus-RB commented 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;

};