Search in sources :

Example 21 with ForceFieldEnergy

use of ffx.potential.ForceFieldEnergy in project ffx by mjschnie.

the class TimerTest method main.

public static void main(String[] args) {
    // Parameters collection from original Timer script
    String pdbname = System.getProperty("pdbFile", "1N7S.pdb");
    String mtzname = System.getProperty("mtzFile", null);
    String cifname = System.getProperty("cifFile", null);
    final boolean ciOnly = false;
    final String info = "SNARE complex";
    final double r = 19.412671496011;
    final double rfree = 21.555930987573;
    final double sigmaA = 0.9336853524690557;
    final double sigmaW = 0.13192537249786418;
    boolean ci = System.getProperty("ffx.ci", "false").equalsIgnoreCase("true");
    if (!ci && ciOnly) {
        crystalStats = null;
        return;
    }
    int index = pdbname.lastIndexOf(".");
    String name = pdbname.substring(0, index);
    // load the structure
    MolecularAssembly molecularAssembly;
    File structure, mtzFile, cifFile;
    structure = new File(pdbname);
    PotentialsFileOpener opener = new PotentialsFileOpener(structure);
    opener.run();
    molecularAssembly = opener.getAssembly();
    mtzFile = new File(mtzname);
    cifFile = new File(cifname);
    // load any properties associated with it
    CompositeConfiguration properties = Keyword.loadProperties(structure);
    // read in Fo/sigFo/FreeR
    MTZFilter mtzFilter = new MTZFilter();
    CIFFilter cifFilter = new CIFFilter();
    Crystal crystal = Crystal.checkProperties(properties);
    Resolution resolution = Resolution.checkProperties(properties);
    if (crystal == null || resolution == null) {
        if (mtzname != null) {
            reflectionList = mtzFilter.getReflectionList(mtzFile);
        } else {
            reflectionList = cifFilter.getReflectionList(cifFile);
        }
    } else {
        reflectionList = new ReflectionList(crystal, resolution);
    }
    refinementData = new DiffractionRefinementData(properties, reflectionList);
    if (mtzname != null) {
    // assertTrue(info + " mtz file should be read in without errors",
    // mtzFilter.readFile(mtzFile, reflectionList, refinementData,
    // properties));
    } else {
    // assertTrue(info + " cif file should be read in without errors",
    // cifFilter.readFile(cifFile, reflectionList, refinementData,
    // properties));
    }
    ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    // associate molecular assembly with the structure, set up forcefield
    molecularAssembly.setForceField(forceField);
    PDBFilter pdbFile = new PDBFilter(structure, molecularAssembly, forceField, properties);
    pdbFile.readFile();
    pdbFile.applyAtomProperties();
    molecularAssembly.finalize(true, forceField);
    ForceFieldEnergy energy = ForceFieldEnergy.energyFactory(molecularAssembly, pdbFile.getCoordRestraints());
    List<Atom> atomList = molecularAssembly.getAtomList();
    Atom[] atomArray = atomList.toArray(new Atom[atomList.size()]);
    // set up FFT and run it
    parallelTeam = new ParallelTeam();
    CrystalReciprocalSpace crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam, false);
    crs.computeDensity(refinementData.fc);
    refinementData.setCrystalReciprocalSpace_fc(crs);
    crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam, true);
    crs.computeDensity(refinementData.fs);
    refinementData.setCrystalReciprocalSpace_fs(crs);
    ScaleBulkMinimize scaleBulkMinimize = new ScaleBulkMinimize(reflectionList, refinementData, crs, parallelTeam);
    scaleBulkMinimize.minimize(6, 1.0e-4);
    SigmaAMinimize sigmaAMinimize = new SigmaAMinimize(reflectionList, refinementData, parallelTeam);
    sigmaAMinimize.minimize(7, 2.0e-2);
    SplineMinimize splineMinimize = new SplineMinimize(reflectionList, refinementData, refinementData.spline, SplineEnergy.Type.FOFC);
    splineMinimize.minimize(7, 1e-5);
    crystalStats = new CrystalStats(reflectionList, refinementData);
    scaleBulkMinimize = new ScaleBulkMinimize(reflectionList, refinementData, refinementData.crs_fs, parallelTeam);
    ScaleBulkEnergy scaleBulkEnergy = scaleBulkMinimize.getScaleBulkEnergy();
    int n = scaleBulkMinimize.getNumberOfVariables();
    double[] x = new double[n];
    double[] g = new double[n];
    scaleBulkMinimize.getCoordinates(x);
    scaleBulkEnergy.energyAndGradient(x, g);
    double delta = 1.0e-4;
    double tolerance = 1.0e-4;
    logger.info(String.format("SCATTER TEST"));
    for (int i = 0; i < 30; i++) {
        long time = -System.nanoTime();
        scaleBulkEnergy.energyAndGradient(x, g);
        time += System.nanoTime();
        logger.info(String.format(" Time %12.8f", time * 1.0e-9));
    }
}
Also used : ParallelTeam(edu.rit.pj.ParallelTeam) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) ReflectionList(ffx.crystal.ReflectionList) ForceField(ffx.potential.parameters.ForceField) PDBFilter(ffx.potential.parsers.PDBFilter) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) Atom(ffx.potential.bonded.Atom) PotentialsFileOpener(ffx.potential.utils.PotentialsFileOpener) MolecularAssembly(ffx.potential.MolecularAssembly) CIFFilter(ffx.xray.parsers.CIFFilter) File(java.io.File) MTZFilter(ffx.xray.parsers.MTZFilter) Crystal(ffx.crystal.Crystal) Resolution(ffx.crystal.Resolution)

Example 22 with ForceFieldEnergy

use of ffx.potential.ForceFieldEnergy in project ffx by mjschnie.

the class PotentialsMain method timer.

public void timer(int nEvals) {
    logger.info(String.format("\n N-Body Test: "));
    boolean gradient = true;
    boolean print = true;
    ForceFieldEnergy energy = molecularAssembly.getPotentialEnergy();
    long minTime = Long.MAX_VALUE;
    double sumTime2 = 0.0;
    // Halfway point
    int halfnEvals = (nEvals % 2 == 1) ? (nEvals / 2) : (nEvals / 2) - 1;
    for (int i = 0; i < nEvals; i++) {
        long time = -System.nanoTime();
        energy.energy(gradient, print);
        time += System.nanoTime();
        minTime = time < minTime ? time : minTime;
        if (i >= (int) (nEvals / 2)) {
            double time2 = time * 1.0E-9;
            sumTime2 += (time2 * time2);
        }
    }
    ++halfnEvals;
    double rmsTime = Math.sqrt(sumTime2 / halfnEvals);
    logger.info(String.format(" Minimum time: %14.5f (sec)", minTime * 1.0E-9));
    logger.info(String.format(" RMS time (latter half): %14.5f (sec)", rmsTime));
}
Also used : ForceFieldEnergy(ffx.potential.ForceFieldEnergy)

Example 23 with ForceFieldEnergy

use of ffx.potential.ForceFieldEnergy in project ffx by mjschnie.

the class PotentialsUtils method returnEnergy.

/**
 * Returns the energy of a MolecularAssembly in kcal/mol (as a double) and
 * prints the energy evaluation
 *
 * @param assembly To evaluate energy of
 * @return Potential energy (kcal/mol)
 */
@Override
public double returnEnergy(MolecularAssembly assembly) {
    if (assembly == null) {
        logger.info(" Molecular assembly was null - skipping energy");
        return 0.0;
    } else {
        ForceFieldEnergy energy = assembly.getPotentialEnergy();
        if (energy == null) {
            energy = ForceFieldEnergy.energyFactory(assembly);
            assembly.setPotential(energy);
        }
        return energy.energy(false, true);
    }
}
Also used : ForceFieldEnergy(ffx.potential.ForceFieldEnergy)

Example 24 with ForceFieldEnergy

use of ffx.potential.ForceFieldEnergy in project ffx by mjschnie.

the class ExtendedVariableTest method testSmoothness.

/**
 * Numerically ensure that the energy and lambda derivatives are smooth all
 * along both ESV coordinates in the dilysine system.
 */
public void testSmoothness() {
    ExtendedSystemConfig esvConfig = activateAll();
    MolecularAssembly mola = setupWithExtended(esvFilename, true, esvConfig);
    ForceFieldEnergy ffe = mola.getPotentialEnergy();
    ExtendedSystem esvSystem = ffe.getExtendedSystem();
    if (resultsOnly) {
        utils.setSilentPotential(true);
    }
    double[][] totalEnergies, totalDerivsA, totalDerivsB;
    double[][] vdwEnergies, vdwDerivsA, vdwDerivsB;
    double[][] permanentEnergies, permanentDerivsA, permanentDerivsB;
    double[][] inducedEnergies, inducedDerivsA, inducedDerivsB;
    totalEnergies = new double[11][11];
    totalDerivsA = new double[11][11];
    totalDerivsB = new double[11][11];
    if (smoothnessDecomposition) {
        vdwEnergies = new double[11][11];
        vdwDerivsA = new double[11][11];
        vdwDerivsB = new double[11][11];
        permanentEnergies = new double[11][11];
        permanentDerivsA = new double[11][11];
        permanentDerivsB = new double[11][11];
        inducedEnergies = new double[11][11];
        inducedDerivsA = new double[11][11];
        inducedDerivsB = new double[11][11];
    }
    for (int idxA = 0; idxA <= 10; idxA++) {
        double evA = idxA / 10.0;
        for (int idxB = 0; idxB <= 10; idxB++) {
            final double evB = idxB / 10.0;
            esvSystem.setLambda(0, evA);
            esvSystem.setLambda(1, evB);
            final double totalEnergy = ffe.energy(true, false);
            totalEnergies[idxA][idxB] = ffe.getEnergyComponent(PotentialComponent.ForceFieldEnergy);
            totalDerivsA[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.ForceFieldEnergy, 0);
            totalDerivsB[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.ForceFieldEnergy, 1);
            if (smoothnessDecomposition) {
                vdwEnergies[idxA][idxB] = ffe.getEnergyComponent(PotentialComponent.VanDerWaals);
                vdwDerivsA[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.VanDerWaals, 0);
                vdwDerivsB[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.VanDerWaals, 1);
                permanentEnergies[idxA][idxB] = ffe.getEnergyComponent(PotentialComponent.Permanent);
                permanentDerivsA[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.Permanent, 0);
                permanentDerivsB[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.Permanent, 1);
                inducedEnergies[idxA][idxB] = ffe.getEnergyComponent(PotentialComponent.Induced);
                inducedDerivsA[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.Induced, 0);
                inducedDerivsB[idxA][idxB] = esvSystem.getDerivativeComponent(PotentialComponent.Induced, 1);
            }
        }
    }
    /* TODO: improve upon the following arbitrary definition of approximate smoothness. */
    final int testRow = 2;
    final double min = Arrays.stream(totalEnergies[testRow]).min().getAsDouble();
    final double max = Arrays.stream(totalEnergies[testRow]).max().getAsDouble();
    final double maxChange = (max - min) * 0.5;
    final int maxDirectionSignChanges = 2;
    int directionSignChanges = 0;
    for (int idxB = 0; idxB < 10; idxB++) {
        final double here = totalEnergies[testRow][idxB];
        final double next = totalEnergies[testRow][idxB + 1];
        final double absChange = Math.abs(next - here);
        if (idxB > 0) {
            final double prev = totalEnergies[testRow][idxB - 1];
            if (Math.signum(next - here) != Math.signum(here - prev)) {
                directionSignChanges++;
            }
        }
        if (absChange > maxChange && assertions) {
            org.junit.Assert.fail(format("Failed max_change smoothness criterion: %g > %g. (change:%g->%g, range:{%g,%g})", absChange, maxChange, min, max, totalEnergies[testRow][idxB], totalEnergies[testRow][idxB + 1]));
        }
    }
    if (directionSignChanges > maxDirectionSignChanges && assertions) {
        org.junit.Assert.fail(format("Failed direction_changes smoothness criterion: %d > %d.", directionSignChanges, maxDirectionSignChanges));
    }
    sb.append(format("  Smoothness Verification: Total \n"));
    sb.append(format(" ******************************** \n"));
    printAsTable(totalEnergies, "U_Total", sb);
    printAsTable(totalDerivsA, "dU_dEsvA", sb);
    printAsTable(totalDerivsB, "dU_dEsvB", sb);
    if (smoothnessDecomposition) {
        sb.append(format("  Smoothness Verification: VdW \n"));
        sb.append(format(" ****************************** \n"));
        printAsTable(vdwEnergies, "vanWaals", sb);
        printAsTable(vdwDerivsA, "dVdw_dA", sb);
        printAsTable(vdwDerivsB, "dVdw_dB", sb);
        sb.append(format("  Smoothness Verification: PermReal \n"));
        sb.append(format(" *********************************** \n"));
        printAsTable(permanentEnergies, "permReal", sb);
        printAsTable(permanentDerivsA, "dPRealdA", sb);
        printAsTable(permanentDerivsB, "dPRealdB", sb);
        sb.append(format("  Smoothness Verification: PermRecip \n"));
        sb.append(format(" ************************************ \n"));
        printAsTable(inducedEnergies, "permRcp", sb);
        printAsTable(inducedDerivsA, "dPRcp_dA", sb);
        printAsTable(inducedDerivsB, "dPRcp_dB", sb);
    }
    utils.setSilentPotential(false);
    logger.info(sb.toString());
}
Also used : MolecularAssembly(ffx.potential.MolecularAssembly) ExtendedSystem(ffx.potential.extended.ExtendedSystem) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) ExtendedSystemConfig(ffx.potential.extended.ExtendedSystem.ExtendedSystemConfig)

Example 25 with ForceFieldEnergy

use of ffx.potential.ForceFieldEnergy in project ffx by mjschnie.

the class ExtendedVariableTest method testEndStates.

/**
 * Verify that a lys-lys system with two ESVs can exactly reproduce the
 * energy yielded by vanilla energy() calls on mutated PDB files.
 */
public void testEndStates() {
    ExtendedSystemConfig esvConfig = activateAll();
    MolecularAssembly mola = openResource(stateFilenames[3], true);
    ExtendedSystem esvSystem = (esvConfig != null) ? new ExtendedSystem(mola, esvConfig) : new ExtendedSystem(mola);
    esvSystem.setConstantPh(7.4);
    esvSystem.populate(esvResidueIDs);
    mola.getPotentialEnergy().attachExtendedSystem(esvSystem);
    ForceFieldEnergy ffe = mola.getPotentialEnergy();
    if (resultsOnly) {
        utils.setSilentPotential(true);
    }
    ParticleMeshEwaldQI esvPme = ffe.getPmeQiNode();
    final double[] totalEsv = new double[4];
    final double[] vdwEsv = new double[4];
    final double[] permEsv = new double[4], permRealEsv = new double[4], permSelfEsv = new double[4], permRecipEsv = new double[4];
    final double[] directEsv = new double[4];
    final double[] mutualEsv = new double[4], indRealEsv = new double[4], indSelfEsv = new double[4], indRecipEsv = new double[4];
    final String[] esvStateNames = new String[4];
    final double[] decompPolarStateEsv = (decompPolarState == Polarization.MUTUAL) ? mutualEsv : directEsv;
    final double[] decompPolarCompEsv = (decompPolarComplement == Polarization.MUTUAL) ? mutualEsv : directEsv;
    esvSystem.setLambda(0, 0.0);
    esvSystem.setLambda(1, 0.0);
    esvStateNames[0] = format("L=%1.0f,%1.0f", esvSystem.getLambda(0), esvSystem.getLambda(1));
    esvPme.setPolarization(decompPolarState);
    ffe.energy(true, false);
    totalEsv[0] = ffe.getTotalEnergy() - esvSystem.getBiasEnergy();
    vdwEsv[0] = ffe.getVanDerWaalsEnergy();
    permEsv[0] = esvPme.getPermanentEnergy();
    permRealEsv[0] = esvPme.getPermRealEnergy();
    permSelfEsv[0] = esvPme.getPermSelfEnergy();
    permRecipEsv[0] = esvPme.getPermRecipEnergy();
    decompPolarStateEsv[0] = esvPme.getPolarizationEnergy();
    indRealEsv[0] = esvPme.getIndRealEnergy();
    indSelfEsv[0] = esvPme.getIndSelfEnergy();
    indRecipEsv[0] = esvPme.getIndRecipEnergy();
    ffe.getPmeNode().setPolarization(decompPolarComplement);
    ffe.energy(true, false);
    decompPolarCompEsv[0] = ffe.getPolarizationEnergy();
    ffe.getPmeNode().setPolarization(decompPolarState);
    esvSystem.setLambda(0, 0.0);
    esvSystem.setLambda(1, 1.0);
    esvStateNames[1] = format("L=%1.0f,%1.0f", esvSystem.getLambda(0), esvSystem.getLambda(1));
    esvPme.setPolarization(decompPolarState);
    ffe.energy(true, false);
    totalEsv[1] = ffe.getTotalEnergy() - esvSystem.getBiasEnergy();
    vdwEsv[1] = ffe.getVanDerWaalsEnergy();
    permEsv[1] = esvPme.getPermanentEnergy();
    permRealEsv[1] = esvPme.getPermRealEnergy();
    permSelfEsv[1] = esvPme.getPermSelfEnergy();
    permRecipEsv[1] = esvPme.getPermRecipEnergy();
    decompPolarStateEsv[1] = esvPme.getPolarizationEnergy();
    indRealEsv[1] = esvPme.getIndRealEnergy();
    indSelfEsv[1] = esvPme.getIndSelfEnergy();
    indRecipEsv[1] = esvPme.getIndRecipEnergy();
    ffe.getPmeNode().setPolarization(decompPolarComplement);
    ffe.energy(true, false);
    decompPolarCompEsv[1] = ffe.getPolarizationEnergy();
    ffe.getPmeNode().setPolarization(decompPolarState);
    esvSystem.setLambda(0, 1.0);
    esvSystem.setLambda(1, 0.0);
    esvStateNames[2] = format("L=%1.0f,%1.0f", esvSystem.getLambda(0), esvSystem.getLambda(1));
    esvPme.setPolarization(decompPolarState);
    ffe.energy(true, false);
    totalEsv[2] = ffe.getTotalEnergy() - esvSystem.getBiasEnergy();
    vdwEsv[2] = ffe.getVanDerWaalsEnergy();
    permEsv[2] = esvPme.getPermanentEnergy();
    permRealEsv[2] = esvPme.getPermRealEnergy();
    permSelfEsv[2] = esvPme.getPermSelfEnergy();
    permRecipEsv[2] = esvPme.getPermRecipEnergy();
    decompPolarStateEsv[2] = esvPme.getPolarizationEnergy();
    indRealEsv[2] = esvPme.getIndRealEnergy();
    indSelfEsv[2] = esvPme.getIndSelfEnergy();
    indRecipEsv[2] = esvPme.getIndRecipEnergy();
    ffe.getPmeNode().setPolarization(decompPolarComplement);
    ffe.energy(true, false);
    decompPolarCompEsv[2] = ffe.getPolarizationEnergy();
    ffe.getPmeNode().setPolarization(decompPolarState);
    esvSystem.setLambda(0, 1.0);
    esvSystem.setLambda(1, 1.0);
    esvStateNames[3] = format("L=%1.0f,%1.0f", esvSystem.getLambda(0), esvSystem.getLambda(1));
    esvPme.setPolarization(decompPolarState);
    ffe.energy(true, false);
    totalEsv[3] = ffe.getTotalEnergy() - esvSystem.getBiasEnergy();
    vdwEsv[3] = ffe.getVanDerWaalsEnergy();
    permEsv[3] = esvPme.getPermanentEnergy();
    permRealEsv[3] = esvPme.getPermRealEnergy();
    permSelfEsv[3] = esvPme.getPermSelfEnergy();
    permRecipEsv[3] = esvPme.getPermRecipEnergy();
    decompPolarStateEsv[3] = esvPme.getPolarizationEnergy();
    indRealEsv[3] = esvPme.getIndRealEnergy();
    indSelfEsv[3] = esvPme.getIndSelfEnergy();
    indRecipEsv[3] = esvPme.getIndRecipEnergy();
    ffe.getPmeNode().setPolarization(decompPolarComplement);
    ffe.energy(true, false);
    decompPolarCompEsv[3] = ffe.getPolarizationEnergy();
    ffe.getPmeNode().setPolarization(decompPolarState);
    /* Open vanilla end states. */
    MolecularAssembly qiMola, cartMola;
    ForceFieldEnergy qiPot, cartPot;
    final int numStates = stateFilenames.length;
    final double[] totalQi = new double[numStates], totalCart = new double[numStates];
    final double[] vdwQi = new double[numStates], vdwCart = new double[numStates];
    final double[] permQi = new double[numStates], permCart = new double[numStates];
    final double[] permRealQi = new double[numStates], permRealCart = new double[numStates];
    final double[] permSelfQi = new double[numStates], permSelfCart = new double[numStates];
    final double[] permRecipQi = new double[numStates], permRecipCart = new double[numStates];
    final double[] mutualQi = new double[numStates], mutualCart = new double[numStates];
    final double[] directQi = new double[numStates], directCart = new double[numStates];
    final double[] indRealQi = new double[numStates], indRealCart = new double[numStates];
    final double[] indSelfQi = new double[numStates], indSelfCart = new double[numStates];
    final double[] indRecipQi = new double[numStates], indRecipCart = new double[numStates];
    final double[] decompPolarStateQi = (decompPolarState == Polarization.MUTUAL) ? mutualQi : directQi;
    final double[] decompPolarCompQi = (decompPolarComplement == Polarization.MUTUAL) ? mutualQi : directQi;
    final double[] decompPolarStateCart = (decompPolarState == Polarization.MUTUAL) ? mutualCart : directCart;
    final double[] decompPolarCompCart = (decompPolarComplement == Polarization.MUTUAL) ? mutualCart : directCart;
    // Get manual (no ESVs) end state energy components from both vanilla-qi and cartesian PME.
    for (int i = 0; i < stateFilenames.length; i++) {
        String state = stateFilenames[i];
        setProp("pme.qi", true);
        qiMola = openResource(stateFilenames[i], true);
        qiPot = qiMola.getPotentialEnergy();
        ParticleMeshEwaldQI qiPme = qiPot.getPmeQiNode();
        qiPme.setPolarization(decompPolarState);
        qiPot.energy(true, false);
        totalQi[i] = qiPot.getTotalEnergy();
        vdwQi[i] = qiPot.getVanDerWaalsEnergy();
        permQi[i] = qiPme.getPermanentEnergy();
        permRealQi[i] = qiPme.getPermRealEnergy();
        permSelfQi[i] = qiPme.getPermSelfEnergy();
        permRecipQi[i] = qiPme.getPermRecipEnergy();
        decompPolarStateQi[i] = qiPme.getPolarizationEnergy();
        indRealQi[i] = qiPme.getIndRealEnergy();
        indSelfQi[i] = qiPme.getIndSelfEnergy();
        indRecipQi[i] = qiPme.getIndRecipEnergy();
        qiPme.setPolarization(decompPolarComplement);
        qiPot.energy(true, false);
        decompPolarCompQi[i] = qiPme.getPolarizationEnergy();
        utils.close(qiMola);
        setProp("pme.qi", false);
        cartMola = openResource(stateFilenames[i], true);
        cartPot = cartMola.getPotentialEnergy();
        ParticleMeshEwaldCart cartPme = (ParticleMeshEwaldCart) cartPot.getPmeNode();
        cartPme.setPolarization(decompPolarState);
        cartPot.energy(true, false);
        totalCart[i] = cartPot.getTotalEnergy();
        vdwCart[i] = cartPot.getVanDerWaalsEnergy();
        permCart[i] = cartPme.getPermanentEnergy();
        permRealCart[i] = cartPme.getPermRealEnergy();
        permSelfCart[i] = cartPme.getPermSelfEnergy();
        permRecipCart[i] = cartPme.getPermRecipEnergy();
        decompPolarStateCart[i] = cartPme.getPolarizationEnergy();
        indRealCart[i] = cartPme.getIndRealEnergy();
        indSelfCart[i] = cartPme.getIndSelfEnergy();
        indRecipCart[i] = cartPme.getIndRecipEnergy();
        cartPme.setPolarization(decompPolarComplement);
        cartPot.energy(true, false);
        decompPolarCompCart[i] = cartPme.getPolarizationEnergy();
        utils.close(cartMola);
        if (assertions) {
            assertEquals("Total" + i, totalCart[i], totalEsv[i], tolerance);
            assertEquals("VanDerWaals" + i, vdwCart[i], vdwEsv[i], tolerance);
            assertEquals("Permanent" + i, permCart[i], permEsv[i], tolerance);
            assertEquals("Ind.Direct" + i, directCart[i], directEsv[i], tolerance);
            assertEquals("Ind.Mutual" + i, mutualCart[i], mutualEsv[i], tolerance);
            assertEquals("PermReal" + i, permRealCart[i], permRealEsv[i], tolerance);
            assertEquals("PermSelf" + i, permSelfCart[i], permSelfEsv[i], tolerance);
            assertEquals("PermRecip" + i, permRecipCart[i], permRecipEsv[i], tolerance);
            assertEquals("IndReal" + i, indRealCart[i], indRealEsv[i], tolerance);
            assertEquals("IndSelf" + i, indSelfCart[i], indSelfEsv[i], tolerance);
            assertEquals("IndRecip" + i, indRecipCart[i], indRecipEsv[i], tolerance);
        }
    }
    sb.append(format("  Two-site End State Analysis \n"));
    sb.append(format(" ***************************** \n"));
    if (includeManualQiEndStates) {
        sb.append(format(" %-27s    %-22s    %-22s    %-22s\n", "Extended System (1 File, QI)", "Manual (4 Files, QI)", "Manual (4 Files, Cart)", "Error (Cart-ESV)"));
    } else {
        sb.append(format(" %-27s    %-22s    %-22s\n", "Extended System (1 File, QI)", "Manual (4 Files, Cart)", "Error (Cart-ESV)"));
    }
    double[][] esvResult = new double[][] { totalEsv, vdwEsv, permEsv, directEsv, mutualEsv, permRealEsv, permSelfEsv, permRecipEsv, indRealEsv, indSelfEsv, indRecipEsv };
    double[][] qiResult = new double[][] { totalQi, vdwQi, permQi, directQi, mutualQi, permRealQi, permSelfQi, permRecipQi, indRealQi, indSelfQi, indRecipQi };
    double[][] cartResult = new double[][] { totalCart, vdwCart, permCart, directCart, mutualCart, permRealCart, permSelfCart, permRecipCart, indRealCart, indSelfCart, indRecipCart };
    String[] names = new String[] { "Total", "VanWaals", "Permanent", "Direct", "Mutual", "PermReal", "PermSelf", "PermRecip", "IndReal", "IndSelf", "IndRecip" };
    for (int component = 0; component < names.length; component++) {
        for (int state = 0; state < numStates; state++) {
            String name = (state == 0) ? names[component] : "";
            sb.append(format(" %-27s", format("%-9s %-7.7s %10.5f", name, esvStateNames[state], esvResult[component][state])));
            if (includeManualQiEndStates) {
                sb.append(format("    %-22s", format("%-7.7s   %12.6f", stateFilenames[state], qiResult[component][state])));
            }
            sb.append(format("    %-22s", format("%-7.7s   %12.6f", stateFilenames[state], cartResult[component][state])));
            final double error = Math.abs(cartResult[component][state] - esvResult[component][state]);
            final String errorStr = (error < errorThreshold) ? format("< %.1e", errorThreshold) : format("%+g", error);
            sb.append(format("    %16s\n", errorStr));
        }
    }
    utils.setSilentPotential(false);
    logger.info(sb.toString());
}
Also used : MolecularAssembly(ffx.potential.MolecularAssembly) ParticleMeshEwaldCart(ffx.potential.nonbonded.ParticleMeshEwaldCart) ExtendedSystem(ffx.potential.extended.ExtendedSystem) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) ParticleMeshEwaldQI(ffx.potential.nonbonded.ParticleMeshEwaldQI) ExtendedSystemConfig(ffx.potential.extended.ExtendedSystem.ExtendedSystemConfig)

Aggregations

ForceFieldEnergy (ffx.potential.ForceFieldEnergy)25 MolecularAssembly (ffx.potential.MolecularAssembly)11 File (java.io.File)6 ForceField (ffx.potential.parameters.ForceField)5 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)5 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)4 PDBFilter (ffx.potential.parsers.PDBFilter)4 ParallelTeam (edu.rit.pj.ParallelTeam)3 Crystal (ffx.crystal.Crystal)3 ReflectionList (ffx.crystal.ReflectionList)3 Resolution (ffx.crystal.Resolution)3 Atom (ffx.potential.bonded.Atom)3 ExtendedSystem (ffx.potential.extended.ExtendedSystem)3 PotentialsUtils (ffx.potential.utils.PotentialsUtils)3 RealSpaceData (ffx.realspace.RealSpaceData)3 RealSpaceEnergy (ffx.realspace.RealSpaceEnergy)3 Test (org.junit.Test)3 HKL (ffx.crystal.HKL)2 ComplexNumber (ffx.numerics.ComplexNumber)2 ExtendedSystemConfig (ffx.potential.extended.ExtendedSystem.ExtendedSystemConfig)2