Search in sources :

Example 16 with AtomType

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

the class VanDerWaals method initAtomArrays.

/**
 * Allocate coordinate arrays and set up reduction indices and values.
 */
private void initAtomArrays() {
    if (esvTerm) {
        atoms = esvSystem.getExtendedAtoms();
        nAtoms = atoms.length;
    }
    if (atomClass == null || nAtoms > atomClass.length || lambdaTerm || esvTerm) {
        atomClass = new int[nAtoms];
        coordinates = new double[nAtoms * 3];
        reduced = new double[nSymm][nAtoms * 3];
        reducedXYZ = reduced[0];
        reductionIndex = new int[nAtoms];
        reductionValue = new double[nAtoms];
        bondMask = new int[nAtoms][];
        angleMask = new int[nAtoms][];
        if (vdwForm.vdwType == VanDerWaalsForm.VDW_TYPE.LENNARD_JONES) {
            torsionMask = new int[nAtoms][];
        } else {
            torsionMask = null;
        }
        use = new boolean[nAtoms];
        isSoft = new boolean[nAtoms];
        softCore = new boolean[2][nAtoms];
        lambdaGradX = null;
        lambdaGradY = null;
        lambdaGradZ = null;
        switch(atomicDoubleArrayImpl) {
            case MULTI:
                gradX = new MultiDoubleArray(threadCount, nAtoms);
                gradY = new MultiDoubleArray(threadCount, nAtoms);
                gradZ = new MultiDoubleArray(threadCount, nAtoms);
                if (lambdaTerm) {
                    lambdaGradX = new MultiDoubleArray(threadCount, nAtoms);
                    lambdaGradY = new MultiDoubleArray(threadCount, nAtoms);
                    lambdaGradZ = new MultiDoubleArray(threadCount, nAtoms);
                }
                break;
            case PJ:
                gradX = new PJDoubleArray(threadCount, nAtoms);
                gradY = new PJDoubleArray(threadCount, nAtoms);
                gradZ = new PJDoubleArray(threadCount, nAtoms);
                if (lambdaTerm) {
                    lambdaGradX = new PJDoubleArray(threadCount, nAtoms);
                    lambdaGradY = new PJDoubleArray(threadCount, nAtoms);
                    lambdaGradZ = new PJDoubleArray(threadCount, nAtoms);
                }
                break;
            case ADDER:
            default:
                gradX = new AdderDoubleArray(threadCount, nAtoms);
                gradY = new AdderDoubleArray(threadCount, nAtoms);
                gradZ = new AdderDoubleArray(threadCount, nAtoms);
                if (lambdaTerm) {
                    lambdaGradX = new AdderDoubleArray(threadCount, nAtoms);
                    lambdaGradY = new AdderDoubleArray(threadCount, nAtoms);
                    lambdaGradZ = new AdderDoubleArray(threadCount, nAtoms);
                }
                break;
        }
    }
    /**
     * Initialize all atoms to be used in the energy.
     */
    fill(use, true);
    fill(isSoft, false);
    fill(softCore[HARD], false);
    fill(softCore[SOFT], false);
    softCoreInit = false;
    // Needs initialized regardless of esvTerm.
    esvAtoms = new boolean[nAtoms];
    esvLambda = new double[nAtoms];
    atomEsvID = new int[nAtoms];
    fill(esvAtoms, false);
    fill(esvLambda, 1.0);
    fill(atomEsvID, -1);
    if (esvTerm) {
        updateEsvLambda();
    }
    lambdaFactors = new LambdaFactors[threadCount];
    for (int i = 0; i < threadCount; i++) {
        if (esvTerm) {
            lambdaFactors[i] = new LambdaFactorsESV();
        } else if (lambdaTerm) {
            lambdaFactors[i] = new LambdaFactorsOSRW();
        } else {
            lambdaFactors[i] = new LambdaFactors();
        }
    }
    for (int i = 0; i < nAtoms; i++) {
        Atom ai = atoms[i];
        assert (i == ai.getXyzIndex() - 1);
        double[] xyz = ai.getXYZ(null);
        int i3 = i * 3;
        coordinates[i3 + XX] = xyz[XX];
        coordinates[i3 + YY] = xyz[YY];
        coordinates[i3 + ZZ] = xyz[ZZ];
        AtomType atomType = ai.getAtomType();
        if (atomType == null) {
            logger.severe(ai.toString());
            // Severe no longer guarantees program crash.
            continue;
        }
        String vdwIndex = forceField.getString(ForceField.ForceFieldString.VDWINDEX, "Class");
        if (vdwIndex.equalsIgnoreCase("Type")) {
            atomClass[i] = atomType.type;
        } else {
            atomClass[i] = atomType.atomClass;
        }
        VDWType type = forceField.getVDWType(Integer.toString(atomClass[i]));
        if (type == null) {
            logger.info(" No VdW type for atom class " + atomClass[i]);
            logger.severe(" No VdW type for atom " + ai.toString());
            return;
        }
        ai.setVDWType(type);
        ArrayList<Bond> bonds = ai.getBonds();
        int numBonds = bonds.size();
        if (type.reductionFactor > 0.0 && numBonds == 1) {
            Bond bond = bonds.get(0);
            Atom heavyAtom = bond.get1_2(ai);
            // Atom indexes start at 1
            reductionIndex[i] = heavyAtom.getIndex() - 1;
            reductionValue[i] = type.reductionFactor;
        } else {
            reductionIndex[i] = i;
            reductionValue[i] = 0.0;
        }
        bondMask[i] = new int[numBonds];
        for (int j = 0; j < numBonds; j++) {
            Bond bond = bonds.get(j);
            bondMask[i][j] = bond.get1_2(ai).getIndex() - 1;
        }
        ArrayList<Angle> angles = ai.getAngles();
        int numAngles = 0;
        for (Angle angle : angles) {
            Atom ak = angle.get1_3(ai);
            if (ak != null) {
                numAngles++;
            }
        }
        angleMask[i] = new int[numAngles];
        int j = 0;
        for (Angle angle : angles) {
            Atom ak = angle.get1_3(ai);
            if (ak != null) {
                angleMask[i][j++] = ak.getIndex() - 1;
            }
        }
        if (vdwForm.scale14 != 1.0) {
            ArrayList<Torsion> torsions = ai.getTorsions();
            int numTorsions = 0;
            for (Torsion torsion : torsions) {
                Atom ak = torsion.get1_4(ai);
                if (ak != null) {
                    numTorsions++;
                }
            }
            torsionMask[i] = new int[numTorsions];
            j = 0;
            for (Torsion torsion : torsions) {
                Atom ak = torsion.get1_4(ai);
                if (ak != null) {
                    torsionMask[i][j++] = ak.getIndex() - 1;
                }
            }
        }
    }
}
Also used : MultiDoubleArray(ffx.numerics.MultiDoubleArray) Atom(ffx.potential.bonded.Atom) PJDoubleArray(ffx.numerics.PJDoubleArray) VDWType(ffx.potential.parameters.VDWType) Angle(ffx.potential.bonded.Angle) AtomType(ffx.potential.parameters.AtomType) Bond(ffx.potential.bonded.Bond) Torsion(ffx.potential.bonded.Torsion) AdderDoubleArray(ffx.numerics.AdderDoubleArray)

Example 17 with AtomType

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

the class FormFactorTest method setUp.

@Before
public void setUp() {
    double[] d = new double[3];
    d[0] = d[1] = d[2] = 0.0;
    double[] anisou = new double[6];
    anisou[0] = anisou[1] = anisou[2] = 1.0;
    anisou[3] = anisou[4] = anisou[5] = 0.0;
    carbon = new Atom(1, "C", 'A', d, "ALA", 1, 'A', 1.0, 20.0, "A");
    AtomType atomType = new AtomType(1, 1, "C", null, 6, 12.01, 1);
    carbon.setAtomType(atomType);
    carbon.setAltLoc('A');
    carbon.setAnisou(anisou);
    carbonFormFactor = new XRayFormFactor(carbon, false);
}
Also used : AtomType(ffx.potential.parameters.AtomType) Atom(ffx.potential.bonded.Atom) Before(org.junit.Before)

Example 18 with AtomType

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

the class AtomTest method Atom_constructor3.

@Test(timeout = 500)
public void Atom_constructor3() {
    int index = 0;
    String i = "N";
    AtomType mmdata = null;
    Atom actualReturn = new Atom(index, i, mmdata, d);
    assertEquals("return value", 0, actualReturn.getIndex());
}
Also used : AtomType(ffx.potential.parameters.AtomType) Test(org.junit.Test)

Example 19 with AtomType

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

the class PotentialsUtils method analysis.

public static void analysis(MolecularAssembly mola) {
    StringBuilder sb = new StringBuilder();
    sb.append(String.format(" Atom Array: (array_pos, xyz_index, resName, atomName, typeNum, classNum) \n"));
    Atom[] atoms = mola.getAtomArray();
    for (int i = 0; i < atoms.length; i++) {
        String resName = atoms[i].getResidueName();
        String atomName = atoms[i].describe(Atom.Descriptions.Trim);
        AtomType atomType = atoms[i].getAtomType();
        int typeNum = atomType.type;
        int classNum = atomType.atomClass;
        int xyzIndex = atoms[i].getIndex();
        sb.append(String.format("   %d: %d %s %s %d %d\n", i, xyzIndex, resName, atomName, typeNum, classNum));
    }
    logger.info(sb.toString());
}
Also used : AtomType(ffx.potential.parameters.AtomType) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) Atom(ffx.potential.bonded.Atom)

Aggregations

AtomType (ffx.potential.parameters.AtomType)19 Atom (ffx.potential.bonded.Atom)11 Bond (ffx.potential.bonded.Bond)7 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)6 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)6 IOException (java.io.IOException)5 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)4 NucleicAcid3 (ffx.potential.bonded.ResidueEnumerations.NucleicAcid3)4 HashMap (java.util.HashMap)4 Residue (ffx.potential.bonded.Residue)3 ResiduePosition (ffx.potential.bonded.Residue.ResiduePosition)3 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)3 File (java.io.File)3 Angle (ffx.potential.bonded.Angle)2 BondedUtils.buildHydrogenAtom (ffx.potential.bonded.BondedUtils.buildHydrogenAtom)2 BondedUtils.findAtomType (ffx.potential.bonded.BondedUtils.findAtomType)2 MSNode (ffx.potential.bonded.MSNode)2 Molecule (ffx.potential.bonded.Molecule)2 Polymer (ffx.potential.bonded.Polymer)2 ResidueEnumerations.aminoAcidList (ffx.potential.bonded.ResidueEnumerations.aminoAcidList)2