Search in sources :

Example 11 with MultipoleType

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

the class ExtUtils method initializeBackgroundMultipoles.

public static void initializeBackgroundMultipoles(List<Atom> backgroundAtoms, ForceField ff) {
    for (int i = 0; i < backgroundAtoms.size(); i++) {
        Atom bg = backgroundAtoms.get(i);
        MultipoleType type = MultipoleType.multipoleTypeFactory(bg, ff);
        if (type == null) {
            logger.severe(format("No multipole could be assigned to atom %s of type %s.", bg.toString(), bg.getAtomType()));
        }
    }
}
Also used : MultipoleType(ffx.potential.parameters.MultipoleType) Atom(ffx.potential.bonded.Atom)

Example 12 with MultipoleType

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

the class ExtendedVariable method updateMultipoleTypes.

/**
 * Invoked by ExtendedSystem after lambda changes and by PME after multipole
 * rotation.
 */
protected final void updateMultipoleTypes() {
    if (!config.electrostatics) {
        return;
    }
    /* If not softcoring unshared atoms, then scale them as well
		 * (with an implied zero-multipole background atom).	  */
    List<Atom> iterate = ExtUtils.joinedListView(atomsShared, atomsUnshared);
    for (Atom fg : iterate) {
        // MultipoleType Ptype, Utype;
        Atom bg = fg2bg.get(fg);
        final MultipoleType Ptype = fg.getMultipoleType();
        final MultipoleType Utype;
        if (bg == null) {
            if (atomsUnshared.contains(fg)) {
                Utype = new MultipoleType(zeroM, Ptype.frameAtomTypes, Ptype.frameDefinition, false);
            } else {
                logger.warning("Error @ESV.updateMultipoles: bg null && !unshared.");
                Utype = null;
            }
        } else {
            Utype = bg.getMultipoleType();
        }
        MultipoleType[] types = new MultipoleType[] { Ptype, Utype };
        double[] mWeights, mdotWeights;
        if (config.allowLambdaSwitch && config.nonlinearMultipoles) {
            mWeights = new double[] { lSwitch, 1.0 - lSwitch };
            mdotWeights = new double[] { dlSwitch, -dlSwitch };
        } else {
            mWeights = new double[] { lambda, 1.0 - lambda };
            mdotWeights = new double[] { 1.0, -1.0 };
        }
        if (Ptype == null) {
            // Multipoles not yet defined.
            continue;
        }
        if (Utype == null) {
            SB.append(format("Error @ESV.updateMultipoleTypes: bgType null."));
            SB.append(format("   fg: %s, '%s'", fg.toString(), fg.getName()));
            SB.append(format(" Background atoms available for match: "));
            for (Atom debug : atomsBackground) {
                SB.append(format("   bg: %s, '%s'", debug.toString(), debug.getName()));
            }
            logger.warning(SB.toString());
            continue;
        }
        final double[] esvMultipole;
        final double[] esvMultipoleDot;
        final MultipoleType esvType;
        final MultipoleType esvDotType;
        try {
            esvType = MultipoleType.weightMultipoleTypes(types, mWeights, Ptype.frameAtomTypes);
            esvDotType = MultipoleType.weightMultipoleTypes(types, mdotWeights, Ptype.frameAtomTypes);
        } catch (IllegalArgumentException ex) {
            logger.warning(format("Multipole scaling failed for fg,bg atoms: %s %s", fg.describe(Descriptions.Trim), bg.describe(Descriptions.Trim)));
            throw ex;
        }
        if (esvType == null || esvDotType == null) {
            logger.severe("Error @ESV.updateMultipoleTypes: M or Mdot null.");
        }
        if (isTitratableHydrogen(fg)) {
            final double scaledAlpha = fg.getPolarizeType().polarizability * getLambda();
            fg.setEsv(this, esvType, esvDotType, scaledAlpha);
        } else {
            fg.setEsv(this, esvType, esvDotType);
        }
        SB.append(format(" Assigning ESV MultipoleTypes for atom %s\n", fg.describe(Atom.Descriptions.Resnum_Name)));
        SB.append(format("  U: %.2f*%s\n", lambda, Ptype.toCompactBohrString()));
        SB.append(format("  P: %.2f*%s\n", 1.0 - lambda, Utype.toCompactBohrString()));
        SB.append(format("  M:      %s\n", fg.getEsvMultipole().toCompactBohrString()));
        SB.append(format("  Mdot:   %s\n", fg.getEsvMultipoleDot().toCompactBohrString()));
        if (ExtUtils.verbose) {
            logger.info(SB.toString());
        }
    }
}
Also used : MultipoleType(ffx.potential.parameters.MultipoleType) Atom(ffx.potential.bonded.Atom)

Example 13 with MultipoleType

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

the class ForceFieldFilter method parseMultipole.

/**
 * Parse a single line multipole.
 *
 * @param input
 * @param tokens
 *
 * @since 1.0
 */
private void parseMultipole(String input, String[] tokens) {
    if (tokens.length < 14) {
        logger.log(Level.WARNING, "Invalid MULTIPOLE type:{0}", Arrays.toString(tokens));
        return;
    }
    try {
        int numTypes = tokens.length - 11;
        int[] atomTypes = new int[numTypes];
        for (int i = 0; i < numTypes; i++) {
            atomTypes[i] = Integer.parseInt(tokens[i + 1]);
        }
        MultipoleType.MultipoleFrameDefinition frameDefinition = MultipoleType.MultipoleFrameDefinition.ZTHENX;
        if (atomTypes.length == 3 && (atomTypes[1] < 0 || atomTypes[2] < 0)) {
            frameDefinition = MultipoleType.MultipoleFrameDefinition.BISECTOR;
        } else if (atomTypes.length == 4 && atomTypes[2] < 0 && atomTypes[3] < 0) {
            if (atomTypes[1] < 0) {
                frameDefinition = MultipoleType.MultipoleFrameDefinition.TRISECTOR;
            } else {
                frameDefinition = MultipoleType.MultipoleFrameDefinition.ZTHENBISECTOR;
            }
        }
        for (int i = 0; i < numTypes; i++) {
            atomTypes[i] = abs(atomTypes[i]);
        }
        double[] dipole = new double[3];
        double[][] quadrupole = new double[3][3];
        double c = new Double(tokens[1 + numTypes]);
        dipole[0] = new Double(tokens[2 + numTypes]);
        dipole[1] = new Double(tokens[3 + numTypes]);
        dipole[2] = new Double(tokens[4 + numTypes]);
        quadrupole[0][0] = new Double(tokens[5 + numTypes]);
        quadrupole[1][0] = new Double(tokens[6 + numTypes]);
        quadrupole[1][1] = new Double(tokens[7 + numTypes]);
        quadrupole[2][0] = new Double(tokens[8 + numTypes]);
        quadrupole[2][1] = new Double(tokens[9 + numTypes]);
        quadrupole[2][2] = new Double(tokens[10 + numTypes]);
        // Fill in symmetric components.
        quadrupole[0][1] = quadrupole[1][0];
        quadrupole[0][2] = quadrupole[2][0];
        quadrupole[1][2] = quadrupole[2][1];
        MultipoleType multipoleType = new MultipoleType(c, dipole, quadrupole, atomTypes, frameDefinition, true);
        forceField.addForceFieldType(multipoleType);
    } catch (NumberFormatException e) {
        String message = "Exception parsing MULTIPOLE type:\n" + input + "\n";
        logger.log(Level.SEVERE, message, e);
    }
}
Also used : ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) MultipoleType(ffx.potential.parameters.MultipoleType) ForceFieldDouble(ffx.potential.parameters.ForceField.ForceFieldDouble)

Example 14 with MultipoleType

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

the class ForceFieldFilter method parseMultipole.

private void parseMultipole(String input, String[] tokens, BufferedReader br) {
    if (tokens.length < 5) {
        logger.log(Level.WARNING, "Invalid MULTIPOLE type:\n{0}", input);
        return;
    }
    try {
        int numTypes = tokens.length - 2;
        int[] atomTypes = new int[numTypes];
        for (int i = 0; i < numTypes; i++) {
            atomTypes[i] = Integer.parseInt(tokens[i + 1]);
        }
        MultipoleType.MultipoleFrameDefinition frameDefinition = MultipoleType.MultipoleFrameDefinition.ZTHENX;
        if (atomTypes.length == 3 && (atomTypes[1] < 0 || atomTypes[2] < 0)) {
            frameDefinition = MultipoleType.MultipoleFrameDefinition.BISECTOR;
        } else if (atomTypes.length == 4 && atomTypes[2] < 0 && atomTypes[3] < 0) {
            if (atomTypes[1] < 0) {
                frameDefinition = MultipoleType.MultipoleFrameDefinition.TRISECTOR;
            } else {
                frameDefinition = MultipoleType.MultipoleFrameDefinition.ZTHENBISECTOR;
            }
        }
        for (int i = 0; i < numTypes; i++) {
            atomTypes[i] = abs(atomTypes[i]);
        }
        double c = Double.parseDouble(tokens[1 + numTypes]);
        input = br.readLine().split("#")[0];
        tokens = input.trim().split(" +");
        if (tokens.length != 3) {
            logger.log(Level.WARNING, "Invalid MULTIPOLE type:\n{0}", input);
            return;
        }
        double[] dipole = new double[3];
        dipole[0] = Double.parseDouble(tokens[0]);
        dipole[1] = Double.parseDouble(tokens[1]);
        dipole[2] = Double.parseDouble(tokens[2]);
        input = br.readLine().split("#")[0];
        tokens = input.trim().split(" +");
        if (tokens.length != 1) {
            logger.log(Level.WARNING, "Invalid MULTIPOLE type:\n{0}", input);
            return;
        }
        double[][] quadrupole = new double[3][3];
        quadrupole[0][0] = Double.parseDouble(tokens[0]);
        input = br.readLine().split("#")[0];
        tokens = input.trim().split(" +");
        if (tokens.length != 2) {
            logger.log(Level.WARNING, "Invalid MULTIPOLE type:\n{0}", input);
            return;
        }
        quadrupole[1][0] = Double.parseDouble(tokens[0]);
        quadrupole[1][1] = Double.parseDouble(tokens[1]);
        input = br.readLine().split("#")[0];
        tokens = input.trim().split(" +");
        if (tokens.length != 3) {
            logger.log(Level.WARNING, "Invalid MULTIPOLE type:\n{0}", input);
            return;
        }
        quadrupole[2][0] = Double.parseDouble(tokens[0]);
        quadrupole[2][1] = Double.parseDouble(tokens[1]);
        quadrupole[2][2] = Double.parseDouble(tokens[2]);
        // Fill in symmetric components.
        quadrupole[0][1] = quadrupole[1][0];
        quadrupole[0][2] = quadrupole[2][0];
        quadrupole[1][2] = quadrupole[2][1];
        MultipoleType multipoleType = new MultipoleType(c, dipole, quadrupole, atomTypes, frameDefinition, true);
        forceField.addForceFieldType(multipoleType);
    } catch (NumberFormatException | IOException e) {
        String message = "Exception parsing MULTIPOLE type:\n" + input + "\n";
        logger.log(Level.SEVERE, message, e);
    }
}
Also used : IOException(java.io.IOException) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) MultipoleType(ffx.potential.parameters.MultipoleType)

Aggregations

MultipoleType (ffx.potential.parameters.MultipoleType)14 Atom (ffx.potential.bonded.Atom)10 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)8 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)8 GeneralizedKirkwood (ffx.potential.nonbonded.GeneralizedKirkwood)6 PointerByReference (com.sun.jna.ptr.PointerByReference)5 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)4 Bond (ffx.potential.bonded.Bond)3 ParticleMeshEwald (ffx.potential.nonbonded.ParticleMeshEwald)3 PolarizeType (ffx.potential.parameters.PolarizeType)3 DoubleByReference (com.sun.jna.ptr.DoubleByReference)2 IntByReference (com.sun.jna.ptr.IntByReference)2 Crystal (ffx.crystal.Crystal)2 Angle (ffx.potential.bonded.Angle)2 RestraintBond (ffx.potential.bonded.RestraintBond)2 VanDerWaals (ffx.potential.nonbonded.VanDerWaals)2 VanDerWaalsForm (ffx.potential.nonbonded.VanDerWaalsForm)2 VDWType (ffx.potential.parameters.VDWType)2 OpenMM_AmoebaBondForce_addBond (simtk.openmm.AmoebaOpenMMLibrary.OpenMM_AmoebaBondForce_addBond)2 OpenMM_CustomBondForce_addBond (simtk.openmm.OpenMMLibrary.OpenMM_CustomBondForce_addBond)2