Search in sources :

Example 1 with IntegerSchedule

use of edu.rit.pj.IntegerSchedule in project ffx by mjschnie.

the class ParticleMeshEwaldCart method ligandElec.

/**
 * 3.) Aperiodic ligand electrostatics.
 *
 * A.) Real space with an Ewald coefficient of 0.0 (no reciprocal space).
 *
 * B.) Polarization scaled as in Step 2 by (1 - lambda).
 */
private double ligandElec() {
    for (int i = 0; i < nAtoms; i++) {
        use[i] = atoms[i].applyLambda();
    }
    /**
     * Scale the permanent vacuum electrostatics. The softcore alpha is not
     * necessary (nothing in vacuum to collide with).
     */
    doPermanentRealSpace = true;
    permanentScale = 1.0 - lPowPerm;
    dEdLSign = -1.0;
    double lAlphaBack = lAlpha;
    double dlAlphaBack = dlAlpha;
    double d2lAlphaBack = d2lAlpha;
    lAlpha = 0.0;
    dlAlpha = 0.0;
    d2lAlpha = 0.0;
    /**
     * If we are past the end of the polarization lambda window, then only
     * the condensed phase is necessary.
     */
    if (lambda <= polLambdaEnd) {
        doPolarization = true;
        polarizationScale = 1.0 - lPowPol;
    } else {
        doPolarization = false;
        polarizationScale = 0.0;
    }
    /**
     * Save the current real space PME parameters.
     */
    double offBack = off;
    double aewaldBack = aewald;
    off = Double.MAX_VALUE;
    aewald = 0.0;
    setEwaldParameters(off, aewald);
    /**
     * Save the current parallelization schedule.
     */
    IntegerSchedule permanentScheduleBack = permanentSchedule;
    IntegerSchedule ewaldScheduleBack = realSpaceSchedule;
    Range[] rangesBack = realSpaceRanges;
    permanentSchedule = vaporPermanentSchedule;
    realSpaceSchedule = vaporEwaldSchedule;
    realSpaceRanges = vacuumRanges;
    /**
     * Use vacuum crystal / vacuum neighborLists.
     */
    Crystal crystalBack = crystal;
    int nSymmBack = nSymm;
    int[][][] listsBack = neighborLists;
    neighborLists = vaporLists;
    crystal = vaporCrystal;
    nSymm = 1;
    /**
     * Turn off GK if in use.
     */
    boolean gkBack = generalizedKirkwoodTerm;
    /**
     * Turn off Pre-conditioned conjugate gradient SCF solver.
     */
    SCFAlgorithm scfBack = scfAlgorithm;
    scfAlgorithm = SCFAlgorithm.SOR;
    if (doLigandGKElec) {
        generalizedKirkwoodTerm = true;
        generalizedKirkwood.setNeighborList(vaporLists);
        generalizedKirkwood.setLambda(lambda);
        generalizedKirkwood.setCutoff(off);
        generalizedKirkwood.setCrystal(vaporCrystal);
        generalizedKirkwood.setLambdaFunction(polarizationScale, dEdLSign * dlPowPol, dEdLSign * d2lPowPol);
    } else {
        generalizedKirkwoodTerm = false;
    }
    double energy = computeEnergy(false);
    /**
     * Revert to the saved parameters.
     */
    off = offBack;
    aewald = aewaldBack;
    setEwaldParameters(off, aewald);
    neighborLists = listsBack;
    crystal = crystalBack;
    nSymm = nSymmBack;
    permanentSchedule = permanentScheduleBack;
    realSpaceSchedule = ewaldScheduleBack;
    realSpaceRanges = rangesBack;
    lAlpha = lAlphaBack;
    dlAlpha = dlAlphaBack;
    d2lAlpha = d2lAlphaBack;
    generalizedKirkwoodTerm = gkBack;
    scfAlgorithm = scfBack;
    fill(use, true);
    return energy;
}
Also used : Range(edu.rit.util.Range) IntegerSchedule(edu.rit.pj.IntegerSchedule) Crystal(ffx.crystal.Crystal)

Example 2 with IntegerSchedule

use of edu.rit.pj.IntegerSchedule in project ffx by mjschnie.

the class ParticleMeshEwaldQI method ligandElec.

/**
 * 3.) Ligand in vapor A.) Real space with an Ewald coefficient of 0.0 (no
 * reciprocal space). B.) Polarization scaled as in Step 2 by (1 - lambda).
 */
private double ligandElec() {
    for (int i = 0; i < nAtoms; i++) {
        use[i] = atoms[i].applyLambda();
    }
    /**
     * Scale the permanent vacuum electrostatics. The softcore alpha is not
     * necessary (nothing in vacuum to collide with).
     */
    doPermanentRealSpace = true;
    permanentScale = 1.0 - lPowPerm;
    dEdLSign = -1.0;
    double lAlphaBack = lAlpha;
    double dlAlphaBack = dlAlpha;
    double d2lAlphaBack = d2lAlpha;
    lAlpha = 0.0;
    dlAlpha = 0.0;
    d2lAlpha = 0.0;
    /**
     * If we are past the end of the polarization lambda window, then only
     * the condensed phase is necessary.
     */
    if (lambda <= polLambdaEnd) {
        doPolarization = true;
        polarizationScale = 1.0 - lPowPol;
    } else {
        doPolarization = false;
        polarizationScale = 0.0;
    }
    /**
     * Save the current real space PME parameters.
     */
    double offBack = off;
    double aewaldBack = aewald;
    off = Double.MAX_VALUE;
    aewald = 0.0;
    setEwaldParameters(off, aewald);
    /**
     * Save the current parallelization schedule.
     */
    IntegerSchedule permanentScheduleBack = permanentSchedule;
    IntegerSchedule ewaldScheduleBack = realSpaceSchedule;
    Range[] rangesBack = realSpaceRanges;
    permanentSchedule = vaporPermanentSchedule;
    realSpaceSchedule = vaporEwaldSchedule;
    realSpaceRanges = vacuumRanges;
    /**
     * Use vacuum crystal / vacuum neighborLists.
     */
    Crystal crystalBack = crystal;
    int nSymmBack = nSymm;
    int[][][] listsBack = neighborLists;
    neighborLists = vaporLists;
    crystal = vaporCrystal;
    nSymm = 1;
    for (LambdaFactors lf : lambdaFactors) {
        lf.setFactors();
    }
    /**
     * Turn off GK if it is in use, unless it's being used as the decoupling
     * target. If so, set its parameters and lambda (derivative) factors.
     */
    boolean gkBack = generalizedKirkwoodTerm;
    if (doLigandGKElec) {
        generalizedKirkwoodTerm = true;
        generalizedKirkwood.setNeighborList(vaporLists);
        generalizedKirkwood.setLambda(lambda);
        generalizedKirkwood.setCutoff(off);
        generalizedKirkwood.setCrystal(vaporCrystal);
        // TODO Decide whether to send LambdaFactors into generalizedKirkwood.
        generalizedKirkwood.setLambdaFunction(polarizationScale, dEdLSign * dlPowPol, dEdLSign * d2lPowPol);
    } else {
        generalizedKirkwoodTerm = false;
    }
    double energy = computeEnergy(false);
    /**
     * Revert to the saved parameters.
     */
    off = offBack;
    aewald = aewaldBack;
    setEwaldParameters(off, aewald);
    neighborLists = listsBack;
    crystal = crystalBack;
    nSymm = nSymmBack;
    permanentSchedule = permanentScheduleBack;
    realSpaceSchedule = ewaldScheduleBack;
    realSpaceRanges = rangesBack;
    lAlpha = lAlphaBack;
    dlAlpha = dlAlphaBack;
    d2lAlpha = d2lAlphaBack;
    generalizedKirkwoodTerm = gkBack;
    for (LambdaFactors lf : lambdaFactors) {
        lf.setFactors();
    }
    fill(use, true);
    return energy;
}
Also used : Range(edu.rit.util.Range) IntegerSchedule(edu.rit.pj.IntegerSchedule) Crystal(ffx.crystal.Crystal)

Aggregations

IntegerSchedule (edu.rit.pj.IntegerSchedule)2 Range (edu.rit.util.Range)2 Crystal (ffx.crystal.Crystal)2