Search in sources :

Example 1 with NCSRestraint

use of ffx.potential.nonbonded.NCSRestraint in project ffx by mjschnie.

the class ForceFieldEnergy method setLambda.

/**
 * {@inheritDoc}
 */
@Override
public void setLambda(double lambda) {
    if (lambdaTerm) {
        if (lambda <= 1.0 && lambda >= 0.0) {
            this.lambda = lambda;
            if (vanderWaalsTerm) {
                vanderWaals.setLambda(lambda);
            }
            if (multipoleTerm) {
                particleMeshEwald.setLambda(lambda);
            }
            if (restraintBondTerm && restraintBonds != null) {
                for (int i = 0; i < restraintBonds.length; i++) {
                    restraintBonds[i].setLambda(lambda);
                }
            }
            if (ncsTerm && ncsRestraint != null) {
                ncsRestraint.setLambda(lambda);
            }
            if (restrainTerm && !coordRestraints.isEmpty()) {
                // autoCoordRestraint.setLambda(lambda);
                for (CoordRestraint restraint : coordRestraints) {
                    restraint.setLambda(lambda);
                }
            }
            if (comTerm && comRestraint != null) {
                comRestraint.setLambda(lambda);
            }
            if (lambdaTorsions) {
                for (int i = 0; i < nTorsions; i++) {
                    torsions[i].setLambda(lambda);
                }
                for (int i = 0; i < nPiOrbitalTorsions; i++) {
                    piOrbitalTorsions[i].setLambda(lambda);
                }
                for (int i = 0; i < nTorsionTorsions; i++) {
                    torsionTorsions[i].setLambda(lambda);
                }
            }
        } else {
            String message = String.format("Lambda value %8.3f is not in the range [0..1].", lambda);
            logger.warning(message);
        }
    } else {
        logger.fine(" Attempting to set a lambda value on a ForceFieldEnergy with lambdaterm false.");
    }
}
Also used : CoordRestraint(ffx.potential.nonbonded.CoordRestraint) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) COMRestraint(ffx.potential.nonbonded.COMRestraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint) NCSRestraint(ffx.potential.nonbonded.NCSRestraint)

Example 2 with NCSRestraint

use of ffx.potential.nonbonded.NCSRestraint in project ffx by mjschnie.

the class ForceFieldEnergy method getdEdXdL.

/**
 * {@inheritDoc}
 *
 * @param gradients
 */
@Override
public void getdEdXdL(double[] gradients) {
    if (!lambdaBondedTerms) {
        if (vanderWaalsTerm) {
            vanderWaals.getdEdXdL(gradients);
        }
        if (multipoleTerm) {
            particleMeshEwald.getdEdXdL(gradients);
        }
        if (restraintBondTerm) {
            for (int i = 0; i < nRestraintBonds; i++) {
                restraintBonds[i].getdEdXdL(gradients);
            }
        }
        if (ncsTerm && ncsRestraint != null) {
            ncsRestraint.getdEdXdL(gradients);
        }
        if (restrainTerm && !coordRestraints.isEmpty()) {
            for (CoordRestraint restraint : coordRestraints) {
                restraint.getdEdXdL(gradients);
            }
        // autoCoordRestraint.getdEdXdL(gradients);
        }
        if (comTerm && comRestraint != null) {
            comRestraint.getdEdXdL(gradients);
        }
        if (lambdaTorsions) {
            double[] grad = new double[3];
            int index = 0;
            for (int i = 0; i < nAtoms; i++) {
                Atom a = atoms[i];
                if (a.isActive()) {
                    a.getLambdaXYZGradient(grad);
                    gradients[index++] += grad[0];
                    gradients[index++] += grad[1];
                    gradients[index++] += grad[2];
                }
            }
        }
    }
}
Also used : CoordRestraint(ffx.potential.nonbonded.CoordRestraint) COMRestraint(ffx.potential.nonbonded.COMRestraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint) NCSRestraint(ffx.potential.nonbonded.NCSRestraint) Atom(ffx.potential.bonded.Atom)

Aggregations

COMRestraint (ffx.potential.nonbonded.COMRestraint)2 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)2 NCSRestraint (ffx.potential.nonbonded.NCSRestraint)2 Atom (ffx.potential.bonded.Atom)1 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)1