Search in sources :

Example 6 with PolarizeType

use of ffx.potential.parameters.PolarizeType in project ffx by mjschnie.

the class ParticleMeshEwald method assignPolarizationGroups.

protected void assignPolarizationGroups() {
    /**
     * Find directly connected group members for each atom.
     */
    List<Integer> group = new ArrayList<>();
    for (int i = 0; i < nAtoms; i++) {
        Atom a = atoms[i];
        if (a.getIndex() - 1 != i) {
            logger.severe(" Atom indexing is not consistent in PME.");
        }
    }
    for (Atom ai : atoms) {
        group.clear();
        Integer index = ai.getIndex() - 1;
        group.add(index);
        PolarizeType polarizeType = ai.getPolarizeType();
        if (polarizeType != null) {
            if (polarizeType.polarizationGroup != null) {
                growGroup(group, ai);
                Collections.sort(group);
                ip11[index] = new int[group.size()];
                int j = 0;
                for (int k : group) {
                    ip11[index][j++] = k;
                }
            } else {
                ip11[index] = new int[group.size()];
                int j = 0;
                for (int k : group) {
                    ip11[index][j++] = k;
                }
            }
        } else {
            String message = "The polarize keyword was not found for atom " + (index + 1) + " with type " + ai.getType();
            logger.severe(message);
        }
    }
    /**
     * Find 1-2 group relationships.
     */
    int[] mask = new int[nAtoms];
    List<Integer> list = new ArrayList<>();
    List<Integer> keep = new ArrayList<>();
    for (int i = 0; i < nAtoms; i++) {
        mask[i] = -1;
    }
    for (int i = 0; i < nAtoms; i++) {
        list.clear();
        for (int j : ip11[i]) {
            list.add(j);
            mask[j] = i;
        }
        keep.clear();
        for (int j : list) {
            Atom aj = atoms[j];
            ArrayList<Bond> bonds = aj.getBonds();
            for (Bond b : bonds) {
                Atom ak = b.get1_2(aj);
                int k = ak.getIndex() - 1;
                if (mask[k] != i) {
                    keep.add(k);
                }
            }
        }
        list.clear();
        for (int j : keep) {
            for (int k : ip11[j]) {
                list.add(k);
            }
        }
        Collections.sort(list);
        ip12[i] = new int[list.size()];
        int j = 0;
        for (int k : list) {
            ip12[i][j++] = k;
        }
    }
    /**
     * Find 1-3 group relationships.
     */
    for (int i = 0; i < nAtoms; i++) {
        mask[i] = -1;
    }
    for (int i = 0; i < nAtoms; i++) {
        for (int j : ip11[i]) {
            mask[j] = i;
        }
        for (int j : ip12[i]) {
            mask[j] = i;
        }
        list.clear();
        for (int j : ip12[i]) {
            for (int k : ip12[j]) {
                if (mask[k] != i) {
                    if (!list.contains(k)) {
                        list.add(k);
                    }
                }
            }
        }
        ip13[i] = new int[list.size()];
        Collections.sort(list);
        int j = 0;
        for (int k : list) {
            ip13[i][j++] = k;
        }
    }
}
Also used : PolarizeType(ffx.potential.parameters.PolarizeType) ArrayList(java.util.ArrayList) Bond(ffx.potential.bonded.Bond) Atom(ffx.potential.bonded.Atom)

Example 7 with PolarizeType

use of ffx.potential.parameters.PolarizeType in project ffx by mjschnie.

the class ParticleMeshEwald method growGroup.

/**
 * A recursive method that checks all atoms bonded to the seed atom for
 * inclusion in the polarization group. The method is called on each newly
 * found group member.
 *
 * @param group XYZ indeces of current group members.
 * @param seed The bonds of the seed atom are queried for inclusion in the
 * group.
 */
private void growGroup(List<Integer> group, Atom seed) {
    List<Bond> bonds = seed.getBonds();
    for (Bond bi : bonds) {
        Atom aj = bi.get1_2(seed);
        int tj = aj.getType();
        boolean added = false;
        PolarizeType polarizeType = seed.getPolarizeType();
        for (int type : polarizeType.polarizationGroup) {
            if (type == tj) {
                Integer index = aj.getIndex() - 1;
                if (!group.contains(index)) {
                    group.add(index);
                    added = true;
                    break;
                }
            }
        }
        if (added) {
            growGroup(group, aj);
        }
    }
}
Also used : PolarizeType(ffx.potential.parameters.PolarizeType) Bond(ffx.potential.bonded.Bond) Atom(ffx.potential.bonded.Atom)

Example 8 with PolarizeType

use of ffx.potential.parameters.PolarizeType in project ffx by mjschnie.

the class ForceFieldFilter method parsePolarize.

private void parsePolarize(String input, String[] tokens) {
    if (tokens.length < 4) {
        logger.log(Level.WARNING, "Invalid POLARIZE type:\n{0}", input);
    }
    try {
        int atomType = Integer.parseInt(tokens[1]);
        double polarizability = Double.parseDouble(tokens[2]);
        double thole = Double.parseDouble(tokens[3]);
        int entries = tokens.length - 4;
        int[] polarizationGroup = null;
        if (entries > 0) {
            polarizationGroup = new int[entries];
            for (int i = 4; i < tokens.length; i++) {
                polarizationGroup[i - 4] = Integer.parseInt(tokens[i]);
            }
        }
        PolarizeType polarizeType = new PolarizeType(atomType, polarizability, thole, polarizationGroup);
        forceField.addForceFieldType(polarizeType);
    // polarizeType.log();
    } catch (NumberFormatException e) {
        String message = "Exception parsing POLARIZE type:\n" + input + "\n";
        logger.log(Level.SEVERE, message, e);
    }
}
Also used : PolarizeType(ffx.potential.parameters.PolarizeType) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString)

Aggregations

PolarizeType (ffx.potential.parameters.PolarizeType)8 Atom (ffx.potential.bonded.Atom)7 MultipoleType (ffx.potential.parameters.MultipoleType)5 Bond (ffx.potential.bonded.Bond)4 PointerByReference (com.sun.jna.ptr.PointerByReference)2 Angle (ffx.potential.bonded.Angle)2 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)2 ParticleMeshEwald (ffx.potential.nonbonded.ParticleMeshEwald)2 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)2 ArrayList (java.util.ArrayList)2 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)2 Crystal (ffx.crystal.Crystal)1 ImproperTorsion (ffx.potential.bonded.ImproperTorsion)1 PiOrbitalTorsion (ffx.potential.bonded.PiOrbitalTorsion)1 RestraintBond (ffx.potential.bonded.RestraintBond)1 Torsion (ffx.potential.bonded.Torsion)1 TorsionTorsion (ffx.potential.bonded.TorsionTorsion)1 GeneralizedKirkwood (ffx.potential.nonbonded.GeneralizedKirkwood)1 ReciprocalSpace (ffx.potential.nonbonded.ReciprocalSpace)1 AtomType (ffx.potential.parameters.AtomType)1