Search in sources :

Example 11 with ResidueState

use of ffx.potential.bonded.ResidueState in project ffx by mjschnie.

the class RosenbluthOBMC method mcStep.

/**
 * Does all the work for a move. Moveset is a continuous 360 degree spin of
 * the chi[0] torsion. U_or in Frenkel's notation (uDep here) is the
 * associated torsion energy. Evaluation criterion: P_accept = Min( 1,
 * (Wn/Wo)*exp(-beta(U[n]-U[o]) )
 */
private boolean mcStep() {
    numMovesProposed++;
    boolean accepted;
    // Select a target residue.
    int which = ThreadLocalRandom.current().nextInt(targets.size());
    Residue target = targets.get(which);
    ResidueState origState = target.storeState();
    List<ROLS> chiList = target.getTorsionList();
    Torsion chi0 = getChiZeroTorsion(target);
    writeSnapshot("orig");
    /* Create old and new trial sets, calculate Wn and Wo, and choose a move bn.
            When doing strictly chi[0] moves, Frenkel/Smit's 'old' and 'new' configurations
            are the same state. The distinction is made here only to aid in future generalization.
         */
    List<MCMove> oldTrialSet = createTrialSet(target, origState, trialSetSize - 1);
    List<MCMove> newTrialSet = createTrialSet(target, origState, trialSetSize);
    report = new StringBuilder();
    report.append(String.format(" Rosenbluth Rotamer MC Move: %4d\n", numMovesProposed));
    report.append(String.format("    residue:   %s\n", target.toString()));
    report.append(String.format("    chi0:      %s\n", chi0.toString()));
    MCMove proposal = calculateRosenbluthFactors(target, chi0, origState, oldTrialSet, origState, newTrialSet);
    /* Calculate the independent portion of the total old-conf energy.
            Then apply the move and calculate the independent total new-conf energy.
         */
    setState(target, origState);
    writeSnapshot("uIndO");
    double uIndO = getTotalEnergy() - getTorsionEnergy(chi0);
    proposal.move();
    writeSnapshot("uIndN");
    double uIndN = getTotalEnergy() - getTorsionEnergy(chi0);
    // Apply acceptance criterion.
    double temperature = thermostat.getCurrentTemperature();
    double beta = 1.0 / (BOLTZMANN * temperature);
    double dInd = uIndN - uIndO;
    double dIndE = FastMath.exp(-beta * dInd);
    double criterion = (Wn / Wo) * FastMath.exp(-beta * (uIndN - uIndO));
    double metropolis = Math.min(1, criterion);
    double rng = ThreadLocalRandom.current().nextDouble();
    report.append(String.format("    theta:     %3.2f\n", ((RosenbluthChi0Move) proposal).theta));
    report.append(String.format("    criterion: %1.4f\n", criterion));
    report.append(String.format("       Wn/Wo:     %.2f\n", Wn / Wo));
    report.append(String.format("       uIndN,O:  %7.2f\t%7.2f\n", uIndN, uIndO));
    report.append(String.format("       dInd(E):  %7.2f\t%7.2f\n", dInd, dIndE));
    report.append(String.format("    rng:       %1.4f\n", rng));
    if (rng < metropolis) {
        numMovesAccepted++;
        report.append(String.format(" Accepted.\n"));
        accepted = true;
    } else {
        proposal.revertMove();
        report.append(String.format(" Denied.\n"));
        accepted = false;
    }
    logger.info(report.toString());
    // Cleanup.
    Wn = 0.0;
    Wo = 0.0;
    return accepted;
}
Also used : ROLS(ffx.potential.bonded.ROLS) Residue(ffx.potential.bonded.Residue) ResidueState(ffx.potential.bonded.ResidueState) Torsion(ffx.potential.bonded.Torsion)

Aggregations

Residue (ffx.potential.bonded.Residue)11 ResidueState (ffx.potential.bonded.ResidueState)11 MultiResidue (ffx.potential.bonded.MultiResidue)10 Rotamer (ffx.potential.bonded.Rotamer)8 Atom (ffx.potential.bonded.Atom)6 RotamerLibrary.applyRotamer (ffx.potential.bonded.RotamerLibrary.applyRotamer)6 NACorrectionException (ffx.potential.bonded.NACorrectionException)5 IOException (java.io.IOException)5 Crystal (ffx.crystal.Crystal)3 PDBFilter (ffx.potential.parsers.PDBFilter)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 SymOp (ffx.crystal.SymOp)2 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)2 TitrationUtils.inactivateResidue (ffx.potential.extended.TitrationUtils.inactivateResidue)2 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2 ParallelTeam (edu.rit.pj.ParallelTeam)1 ROLS (ffx.potential.bonded.ROLS)1 Torsion (ffx.potential.bonded.Torsion)1