use of ffx.potential.nonbonded.CoordRestraint in project ffx by mjschnie.
the class ForceFieldEnergy method getPDBHeaderString.
/**
* <p>
* getPDBHeaderString</p>
*
* @return a {@link java.lang.String} object.
*/
public String getPDBHeaderString() {
energy(false, false);
StringBuilder sb = new StringBuilder();
sb.append("REMARK 3 CALCULATED POTENTIAL ENERGY\n");
if (bondTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "BOND STRETCHING : ", bondEnergy, nBonds));
sb.append(String.format("REMARK 3 %s %g\n", "BOND RMSD : ", bondRMSD));
}
if (angleTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "ANGLE BENDING : ", angleEnergy, nAngles));
sb.append(String.format("REMARK 3 %s %g\n", "ANGLE RMSD : ", angleRMSD));
}
if (stretchBendTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "STRETCH-BEND : ", stretchBendEnergy, nStretchBends));
}
if (ureyBradleyTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "UREY-BRADLEY : ", ureyBradleyEnergy, nUreyBradleys));
}
if (outOfPlaneBendTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "OUT-OF-PLANE BEND : ", outOfPlaneBendEnergy, nOutOfPlaneBends));
}
if (torsionTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "TORSIONAL ANGLE : ", torsionEnergy, nTorsions));
}
if (piOrbitalTorsionTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "PI-ORBITAL TORSION : ", piOrbitalTorsionEnergy, nPiOrbitalTorsions));
}
if (torsionTorsionTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "TORSION-TORSION : ", torsionTorsionEnergy, nTorsionTorsions));
}
if (improperTorsionTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "IMPROPER TORSION : ", improperTorsionEnergy, nImproperTorsions));
}
if (restraintBondTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "RESTRAINT BOND STRETCHING : ", restraintBondEnergy, nRestraintBonds));
}
if (ncsTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "NCS RESTRAINT : ", ncsEnergy, nAtoms));
}
if (restrainTerm && !coordRestraints.isEmpty()) {
int nRests = 0;
for (CoordRestraint restraint : coordRestraints) {
nRests += restraint.getNumAtoms();
}
sb.append(String.format("REMARK 3 %s %g (%d)\n", "COORDINATE RESTRAINTS : ", restrainEnergy, nRests));
}
if (comTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "COM RESTRAINT : ", comRestraintEnergy, nAtoms));
}
if (vanderWaalsTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "VAN DER WAALS : ", vanDerWaalsEnergy, nVanDerWaalInteractions));
}
if (multipoleTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "ATOMIC MULTIPOLES : ", permanentMultipoleEnergy, nPermanentInteractions));
}
if (polarizationTerm) {
sb.append(String.format("REMARK 3 %s %g (%d)\n", "POLARIZATION : ", polarizationEnergy, nPermanentInteractions));
}
sb.append(String.format("REMARK 3 %s %g\n", "TOTAL POTENTIAL (KCAL/MOL) : ", totalEnergy));
int nsymm = crystal.getUnitCell().spaceGroup.getNumberOfSymOps();
if (nsymm > 1) {
sb.append(String.format("REMARK 3 %s %g\n", "UNIT CELL POTENTIAL : ", totalEnergy * nsymm));
}
if (crystal.getUnitCell() != crystal) {
nsymm = crystal.spaceGroup.getNumberOfSymOps();
sb.append(String.format("REMARK 3 %s %g\n", "REPLICATES CELL POTENTIAL : ", totalEnergy * nsymm));
}
sb.append("REMARK 3\n");
return sb.toString();
}
use of ffx.potential.nonbonded.CoordRestraint in project ffx by mjschnie.
the class ForceFieldEnergyOpenMM method addHarmonicRestraintForce.
/**
* Adds harmonic restraints (CoordRestraint objects) to OpenMM as a custom
* external force.
*/
private void addHarmonicRestraintForce() {
for (CoordRestraint restraint : super.getCoordRestraints()) {
double forceConst = restraint.getForceConstant();
forceConst *= OpenMM_KJPerKcal;
forceConst *= (OpenMM_AngstromsPerNm * OpenMM_AngstromsPerNm);
Atom[] restAtoms = restraint.getAtoms();
int nRestAts = restraint.getNumAtoms();
double[][] oCoords = restraint.getOriginalCoordinates();
for (int i = 0; i < nRestAts; i++) {
oCoords[i][0] *= OpenMM_NmPerAngstrom;
oCoords[i][1] *= OpenMM_NmPerAngstrom;
oCoords[i][2] *= OpenMM_NmPerAngstrom;
}
PointerByReference theRestraint = OpenMM_CustomExternalForce_create("k*periodicdistance(x,y,z,x0,y0,z0)^2");
OpenMM_CustomExternalForce_addGlobalParameter(theRestraint, "k", forceConst);
OpenMM_CustomExternalForce_addPerParticleParameter(theRestraint, "x0");
OpenMM_CustomExternalForce_addPerParticleParameter(theRestraint, "y0");
OpenMM_CustomExternalForce_addPerParticleParameter(theRestraint, "z0");
PointerByReference xyzOrigArray = OpenMM_DoubleArray_create(3);
for (int i = 0; i < nRestAts; i++) {
int ommIndex = restAtoms[i].getXyzIndex() - 1;
for (int j = 0; j < 3; j++) {
OpenMM_DoubleArray_set(xyzOrigArray, j, oCoords[i][j]);
}
OpenMM_CustomExternalForce_addParticle(theRestraint, ommIndex, xyzOrigArray);
}
OpenMM_DoubleArray_destroy(xyzOrigArray);
OpenMM_System_addForce(system, theRestraint);
}
}
use of ffx.potential.nonbonded.CoordRestraint in project ffx by mjschnie.
the class SystemFilter method applyAtomProperties.
/**
* Automatically sets atom-specific flags, particularly nouse and inactive,
* and apply harmonic restraints. Intended to be called at the end of
* readFile() implementations.
*/
public void applyAtomProperties() {
/**
* What may be a more elegant implementation is to make readFile() a
* public concrete, but skeletal method, and then have readFile() call a
* protected abstract readFile method for each implementation.
*/
Atom[] molaAtoms = activeMolecularAssembly.getAtomArray();
int nmolaAtoms = molaAtoms.length;
String[] nouseKeys = properties.getStringArray("nouse");
for (String nouseKey : nouseKeys) {
/*try {
int[] nouseRange = parseAtNumArg("nouse", nouseKey, nmolaAtoms);
logger.log(Level.INFO, String.format(" Atoms %d-%d set to be not "
+ "used", nouseRange[0] + 1, nouseRange[1] + 1));
for (int i = nouseRange[0]; i <= nouseRange[1]; i++) {
molaAtoms[i].setUse(false);
}
} catch (IllegalArgumentException ex) {
logger.log(Level.INFO, ex.getLocalizedMessage());
}*/
String[] toks = nouseKey.split("\\s+");
for (String tok : toks) {
try {
int[] nouseRange = parseAtNumArg("restraint", tok, nmolaAtoms);
logger.info(String.format(" Setting atoms %d-%d to not be used", nouseRange[0] + 1, nouseRange[1] + 1));
for (int j = nouseRange[0]; j <= nouseRange[1]; j++) {
molaAtoms[j].setUse(false);
}
} catch (IllegalArgumentException ex) {
boolean atomFound = false;
for (Atom atom : molaAtoms) {
if (atom.getName().equalsIgnoreCase(tok)) {
atomFound = true;
atom.setUse(false);
}
}
if (atomFound) {
logger.info(String.format(" Setting atoms with name %s to not be used", tok));
} else {
logger.log(Level.INFO, ex.getLocalizedMessage());
}
}
}
}
String[] inactiveKeys = properties.getStringArray("inactive");
for (String inactiveKey : inactiveKeys) {
try {
int[] inactiveRange = parseAtNumArg("inactive", inactiveKey, nmolaAtoms);
logger.log(Level.INFO, String.format(" Atoms %d-%d set to be not " + "used", inactiveRange[0] + 1, inactiveRange[1] + 1));
for (int i = inactiveRange[0]; i <= inactiveRange[1]; i++) {
molaAtoms[i].setActive(false);
}
} catch (IllegalArgumentException ex) {
logger.log(Level.INFO, ex.getLocalizedMessage());
}
/*Matcher m = intrangePattern.matcher(inactiveKey);
if (m.matches()) {
int start = Integer.parseInt(m.group(1)) - 1;
int end = Integer.parseInt(m.group(2)) - 1;
if (start > end) {
logger.log(Level.INFO, String.format(" Input %s not valid; "
+ "start > end", inactiveKey));
} else if (start < 0) {
logger.log(Level.INFO, String.format(" Input %s not valid; "
+ "atoms should be indexed starting from 1", inactiveKey));
} else {
logger.log(Level.INFO, String.format(" Atoms %s set to be "
+ "inactive", inactiveKey));
for (int i = start; i <= end; i++) {
if (i >= nmolaAtoms) {
logger.log(Level.INFO, String.format(" Atom index %d is "
+ "out of bounds for molecular assembly of "
+ "length %d", i + 1, nmolaAtoms));
break;
}
molaAtoms[i].setActive(false);
}
}
} else {
try {
int atNum = Integer.parseUnsignedInt(inactiveKey) - 1;
if (atNum >= nmolaAtoms) {
logger.log(Level.INFO, String.format(" Atom index %d is "
+ "out of bounds for molecular assembly of "
+ "length %d", atNum + 1, nmolaAtoms));
} else if (atNum < 0) {
logger.log(Level.INFO, String.format(" Input %s not valid; "
+ "atoms should be indexed starting from 1", inactiveKey));
} else {
logger.log(Level.INFO, String.format(" Atom %s set to be "
+ "inactive", inactiveKey));
molaAtoms[atNum].setActive(false);
}
} catch (NumberFormatException ex) {
logger.log(Level.INFO, String.format(" inactive key %s cannot "
+ "be interpreted as an atom number or range of atom "
+ "numbers.", inactiveKey));
}
}*/
}
coordRestraints = new ArrayList<>();
String[] cRestraintStrings = properties.getStringArray("restraint");
for (String coordRestraint : cRestraintStrings) {
String[] toks = coordRestraint.split("\\s+");
double forceconst;
try {
forceconst = Double.parseDouble(toks[0]);
} catch (NumberFormatException ex) {
logger.log(Level.INFO, " First argument to coordinate restraint must be a positive force constant; discarding coordinate restraint.");
continue;
}
if (forceconst < 0) {
logger.log(Level.INFO, " Force constants must be positive. Discarding coordinate restraint.");
continue;
}
logger.info(String.format(" Adding lambda-disabled coordinate restraint " + "with force constant %10.4f kcal/mol/A", forceconst));
Set<Atom> restraintAtoms = new HashSet<>();
for (int i = 1; i < toks.length; i++) {
try {
int[] restrRange = parseAtNumArg("restraint", toks[i], nmolaAtoms);
logger.info(String.format(" Adding atoms %d-%d to restraint", restrRange[0] + 1, restrRange[1] + 1));
for (int j = restrRange[0]; j <= restrRange[1]; j++) {
restraintAtoms.add(molaAtoms[j]);
}
} catch (IllegalArgumentException ex) {
boolean atomFound = false;
for (Atom atom : molaAtoms) {
if (atom.getName().equalsIgnoreCase(toks[i])) {
atomFound = true;
restraintAtoms.add(atom);
}
}
if (atomFound) {
logger.info(String.format(" Added atoms with name %s to restraint", toks[i]));
} else {
logger.log(Level.INFO, ex.getLocalizedMessage());
}
}
}
if (!restraintAtoms.isEmpty()) {
Atom[] ats = restraintAtoms.toArray(new Atom[restraintAtoms.size()]);
coordRestraints.add(new CoordRestraint(ats, forceField, false, forceconst));
} else {
logger.warning(String.format(" Empty or unparseable restraint argument %s", coordRestraint));
}
}
String[] lamRestraintStrings = properties.getStringArray("lamrestraint");
for (String coordRestraint : lamRestraintStrings) {
String[] toks = coordRestraint.split("\\s+");
double forceconst = Double.parseDouble(toks[0]);
logger.info(String.format(" Adding lambda-enabled coordinate restraint " + "with force constant %10.4f kcal/mol/A", forceconst));
Set<Atom> restraintAtoms = new HashSet<>();
for (int i = 1; i < toks.length; i++) {
try {
int[] restrRange = parseAtNumArg("restraint", toks[i], nmolaAtoms);
logger.info(String.format(" Adding atoms %d-%d to restraint", restrRange[0] + 1, restrRange[1] + 1));
for (int j = restrRange[0]; j <= restrRange[1]; j++) {
restraintAtoms.add(molaAtoms[j]);
}
} catch (IllegalArgumentException ex) {
boolean atomFound = false;
for (Atom atom : molaAtoms) {
if (atom.getName().equalsIgnoreCase(toks[i])) {
atomFound = true;
restraintAtoms.add(atom);
}
}
if (atomFound) {
logger.info(String.format(" Added atoms with name %s to restraint", toks[i]));
} else {
logger.log(Level.INFO, String.format(" Restraint input %s " + "could not be parsed as a numerical range or " + "an atom type present in assembly", toks[i]));
}
}
}
if (!restraintAtoms.isEmpty()) {
Atom[] ats = restraintAtoms.toArray(new Atom[restraintAtoms.size()]);
coordRestraints.add(new CoordRestraint(ats, forceField, true, forceconst));
} else {
logger.warning(String.format(" Empty or unparseable restraint argument %s", coordRestraint));
}
}
String[] xyzRestStrings = properties.getStringArray("xyzRestraint");
// Variables to let sequential and otherwise identical xyzRestraint strings to be globbed into one restraint.
List<Atom> restraintAts = new ArrayList<>();
List<double[]> coords = new ArrayList<>();
double lastForceConst = 0;
boolean lastUseLam = false;
for (String xR : xyzRestStrings) {
String[] toks = xR.split("\\s+");
int nToks = toks.length;
if (nToks != 6) {
logger.info(" XYZ restraint rejected: must have force constant, lambda boolean (true/false), 3 coordinates, and an atom number");
logger.info(" For a coordinate restraint centered on original coordinates, use restraint or lamrestraint keys.");
logger.info(String.format(" Rejected restraint string: %s", xR));
} else {
try {
double forceConst = Double.parseDouble(toks[0]);
boolean useLambda = Boolean.parseBoolean(toks[1]);
if (forceConst != lastForceConst || useLambda != lastUseLam) {
int nAts = restraintAts.size();
if (nAts != 0) {
double[][] restXYZ = new double[3][nAts];
Atom[] atArr = restraintAts.toArray(new Atom[nAts]);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < nAts; j++) {
restXYZ[i][j] = coords.get(j)[i];
}
}
CoordRestraint thePin = new CoordRestraint(atArr, forceField, lastUseLam, lastForceConst);
thePin.setCoordinatePin(restXYZ);
thePin.setIgnoreHydrogen(false);
coordRestraints.add(thePin);
}
restraintAts = new ArrayList<>();
coords = new ArrayList<>();
lastForceConst = forceConst;
lastUseLam = useLambda;
}
double[] atXYZ = new double[3];
for (int i = 0; i < 3; i++) {
atXYZ[i] = Double.parseDouble(toks[i + 2]);
}
int atNum = Integer.parseInt(toks[5]) - 1;
restraintAts.add(molaAtoms[atNum]);
coords.add(atXYZ);
} catch (Exception ex) {
logger.info(String.format(" Exception parsing xyzRestraint %s: %s", xR, ex.toString()));
}
}
}
int nAts = restraintAts.size();
if (nAts != 0) {
double[][] restXYZ = new double[3][nAts];
Atom[] atArr = restraintAts.toArray(new Atom[nAts]);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < nAts; j++) {
restXYZ[i][j] = coords.get(j)[i];
}
}
CoordRestraint thePin = new CoordRestraint(atArr, forceField, lastUseLam, lastForceConst);
thePin.setCoordinatePin(restXYZ);
thePin.setIgnoreHydrogen(false);
coordRestraints.add(thePin);
}
String[] noElStrings = properties.getStringArray("noElectro");
for (String noE : noElStrings) {
String[] toks = noE.split("\\s+");
for (String tok : toks) {
try {
int[] noERange = parseAtNumArg("noElectro", tok, nmolaAtoms);
for (int i = noERange[0]; i <= noERange[1]; i++) {
molaAtoms[i].setElectrostatics(false);
}
logger.log(Level.INFO, String.format(" Disabled electrostatics " + "for atoms %d-%d", noERange[0] + 1, noERange[1] + 1));
} catch (IllegalArgumentException ex) {
boolean atomFound = false;
for (Atom atom : molaAtoms) {
if (atom.getName().equalsIgnoreCase(tok)) {
atomFound = true;
atom.setElectrostatics(false);
}
}
if (atomFound) {
logger.info(String.format(" Disabled electrostatics for atoms with name %s", tok));
} else {
logger.log(Level.INFO, String.format(" No electrostatics " + "input %s could not be parsed as a numerical " + "range or atom type present in assembly", tok));
}
}
}
}
}
use of ffx.potential.nonbonded.CoordRestraint in project ffx by mjschnie.
the class ForceFieldEnergy method toString.
/**
* {@inheritDoc}
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (printCompact) {
double totalBondedEnergy = bondEnergy + angleEnergy + stretchBendEnergy + ureyBradleyEnergy + outOfPlaneBendEnergy + torsionEnergy + piOrbitalTorsionEnergy + torsionTorsionEnergy + improperTorsionEnergy;
int totalBondedInteractions = nBonds + nAngles + nStretchBends + nUreyBradleys + nOutOfPlaneBends + nTorsions + nPiOrbitalTorsions + nTorsionTorsions + nImproperTorsions;
double totalBondedTime = (bondTime + angleTime) * toSeconds;
sb.append(String.format(" %s %16.8f %12d %12.3f (%6.4f, %6.4f)\n", "Bonded Terms ", totalBondedEnergy, totalBondedInteractions, totalBondedTime, bondRMSD, angleRMSD));
} else {
if (bondTerm && nBonds > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f (%8.5f)\n", "Bond Stretching ", bondEnergy, nBonds, bondTime * toSeconds, bondRMSD));
}
if (angleTerm && nAngles > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f (%8.5f)\n", "Angle Bending ", angleEnergy, nAngles, angleTime * toSeconds, angleRMSD));
}
if (stretchBendTerm && nStretchBends > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Stretch-Bend ", stretchBendEnergy, nStretchBends, stretchBendTime * toSeconds));
}
if (ureyBradleyTerm && nUreyBradleys > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Urey-Bradley ", ureyBradleyEnergy, nUreyBradleys, ureyBradleyTime * toSeconds));
}
if (outOfPlaneBendTerm && nOutOfPlaneBends > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Out-of-Plane Bend ", outOfPlaneBendEnergy, nOutOfPlaneBends, outOfPlaneBendTime * toSeconds));
}
if (torsionTerm && nTorsions > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Torsional Angle ", torsionEnergy, nTorsions, torsionTime * toSeconds));
}
if (piOrbitalTorsionTerm && nPiOrbitalTorsions > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Pi-Orbital Torsion", piOrbitalTorsionEnergy, nPiOrbitalTorsions, piOrbitalTorsionTime * toSeconds));
}
if (torsionTorsionTerm && nTorsionTorsions > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Torsion-Torsion ", torsionTorsionEnergy, nTorsionTorsions, torsionTorsionTime * toSeconds));
}
if (improperTorsionTerm && nImproperTorsions > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Improper Torsion ", improperTorsionEnergy, nImproperTorsions, improperTorsionTime * toSeconds));
}
}
if (restraintBondTerm && nRestraintBonds > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Bond Restraint ", restraintBondEnergy, nRestraintBonds, restraintBondTime * toSeconds));
}
if (ncsTerm) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "NCS Restraint ", ncsEnergy, nAtoms, ncsTime * toSeconds));
}
if (restrainTerm && !coordRestraints.isEmpty()) {
int nRests = 0;
for (CoordRestraint restraint : coordRestraints) {
nRests += restraint.getNumAtoms();
}
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Coord. Restraints ", restrainEnergy, nRests, coordRestraintTime * toSeconds));
}
if (comTerm) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "COM Restraint ", comRestraintEnergy, nAtoms, comRestraintTime * toSeconds));
}
if (vanderWaalsTerm && nVanDerWaalInteractions > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Van der Waals ", vanDerWaalsEnergy, nVanDerWaalInteractions, vanDerWaalsTime * toSeconds));
}
if (multipoleTerm && nPermanentInteractions > 0) {
String pmeTitle = (particleMeshEwald instanceof ParticleMeshEwaldQI) ? "Q.Int. Multipoles " : "Atomic Multipoles ";
if (polarizationTerm) {
sb.append(String.format(" %s %16.8f %12d\n", pmeTitle, permanentMultipoleEnergy, nPermanentInteractions));
} else {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", pmeTitle, permanentMultipoleEnergy, nPermanentInteractions, electrostaticTime * toSeconds));
}
}
if (polarizationTerm && nPermanentInteractions > 0) {
sb.append(String.format(" %s %16.8f %12d %12.3f\n", "Polarization ", polarizationEnergy, nPermanentInteractions, electrostaticTime * toSeconds));
}
if (generalizedKirkwoodTerm && nGKInteractions > 0) {
sb.append(String.format(" %s %16.8f %12d\n", "Solvation ", solvationEnergy, nGKInteractions));
}
if (relativeSolvationTerm) {
sb.append(String.format(" %s %16.8f %12d\n", "Relative Solvation", relativeSolvationEnergy, nRelativeSolvations));
}
if (esvTerm) {
sb.append(String.format(" %s %16.8f %s\n", "ExtendedSystemBias", esvBias, esvSystem.getLambdaList()));
sb.append(esvSystem.getBiasDecomposition());
}
sb.append(String.format(" %s %16.8f %s %12.3f (sec)", "Total Potential ", totalEnergy, "(Kcal/mole)", totalTime * toSeconds));
int nsymm = crystal.getUnitCell().spaceGroup.getNumberOfSymOps();
if (nsymm > 1) {
sb.append(String.format("\n %s %16.8f", "Unit Cell ", totalEnergy * nsymm));
}
if (crystal.getUnitCell() != crystal) {
nsymm = crystal.spaceGroup.getNumberOfSymOps();
sb.append(String.format("\n %s %16.8f", "Replicates Cell ", totalEnergy * nsymm));
}
sb.append("\n");
return sb.toString();
}
use of ffx.potential.nonbonded.CoordRestraint 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.");
}
}
Aggregations