use of ffx.potential.bonded.BondedTerm in project ffx by mjschnie.
the class PhDiscount method crashDump.
/**
* Attempt to print sources of catastrophic system heating.
*/
private void crashDump(RuntimeException error) {
writeSnapshot(".meltdown-");
ffe.energy(false, true);
mola.getDescendants(BondedTerm.class).stream().filter(BondedTerm::isExtendedSystemMember).forEach(term -> {
try {
((Bond) term).log();
} catch (Exception ex) {
}
try {
((Angle) term).log();
} catch (Exception ex) {
}
try {
((Torsion) term).log();
} catch (Exception ex) {
}
});
if (ffe.getVanDerWaalsEnergy() > 1000) {
extendedAtoms = esvSystem.getExtendedAtoms();
nAtomsExt = esvSystem.getExtendedAtoms().length;
for (int i = 0; i < nAtomsExt; i++) {
Atom ai = extendedAtoms[i];
for (int j = 0; j < nAtomsExt; j++) {
Atom aj = extendedAtoms[j];
if (!esvSystem.isExtended(i) && !esvSystem.isExtended(j)) {
continue;
}
if (ai == aj || ai.getBond(aj) != null) {
continue;
}
double dist = FastMath.sqrt(FastMath.pow((aj.getX() - ai.getX()), 2) + FastMath.pow((aj.getY() - ai.getY()), 2) + FastMath.pow((aj.getZ() - ai.getZ()), 2));
if (dist < 0.8 * (aj.getVDWR() + ai.getVDWR())) {
logger.warning(String.format("Close vdW contact for atoms: \n %s\n %s", aj, ai));
}
}
}
}
throw error;
}
use of ffx.potential.bonded.BondedTerm in project ffx by mjschnie.
the class ExtendedSystem method getDerivative.
private double getDerivative(int esvID) {
final double temperature = (config.forceRoomTemp) ? ExtConstants.roomTemperature : currentTemperature;
final boolean p = config.decomposeDeriv;
ExtendedVariable esv = esvList.get(esvID);
double esvDeriv = 0.0;
final String format = " %-20.20s %2.2s %9.4f";
if (config.biasTerm) {
final double dBias = esv.getTotalBiasDeriv(temperature, true);
if (p) {
sb.append(format(" Biases:", "", dBias));
}
final double dDiscr = esv.getDiscrBiasDeriv();
if (p) {
sb.append(format(" Discretizer:", ">", dDiscr));
}
if (esv instanceof TitrationESV) {
final double dPh = ((TitrationESV) esv).getPhBiasDeriv(temperature);
if (p) {
sb.append(format(" Acidostat:", ">", dPh));
}
}
esvDeriv += dBias;
}
if (config.vanDerWaals) {
final double dVdw = vdw.getEsvDerivative(esvID);
if (p) {
sb.append(format(" VanDerWaals:", "", dVdw));
}
esvDeriv += dVdw;
}
if (config.electrostatics) {
final double permanent = pme.getEsvDeriv_Permanent(esvID);
esvDeriv += permanent;
if (p) {
sb.append(format(" PermanentElec:", "", permanent));
}
double permReal = pme.getEsvDeriv_PermReal(esvID);
double permSelf = pme.getEsvDeriv_PermSelf(esvID);
double permRecip = pme.getEsvDeriv_PermRecip(esvID);
if (p) {
sb.append(format(" PermReal:", ">", permReal));
}
if (p) {
sb.append(format(" PermRcpSelf:", ">", permSelf));
}
if (p) {
sb.append(format(" PermRecipMpole:", ">", permRecip));
}
if (config.polarization) {
final double induced = pme.getEsvDeriv_Induced(esvID);
esvDeriv += induced;
if (p) {
sb.append(format(" Polarization:", "", induced));
}
double indReal = pme.getEsvDeriv_IndReal(esvID);
double indSelf = pme.getEsvDeriv_IndSelf(esvID);
double indRecip = pme.getEsvDeriv_IndRecip(esvID);
if (p) {
sb.append(format(" IndReal:", ">", indReal));
}
if (p) {
sb.append(format(" IndSelf:", ">", indSelf));
}
if (p) {
sb.append(format(" IndRecip:", ">", indRecip));
}
}
}
if (config.bonded) {
final double dBonded = esv.getBondedDeriv();
if (p) {
sb.append(format(" Bonded:", "", dBonded));
}
esvDeriv += dBonded;
/* If desired, decompose bonded contribution into component types from foreground and background. */
if (config.decomposeBonded) {
// Foreground portion:
double fgSum = 0.0;
HashMap<Class<? extends BondedTerm>, SharedDouble> fgMap = esv.getBondedDerivDecomp();
for (SharedDouble dub : fgMap.values()) {
fgSum += dub.get();
}
if (p) {
sb.append(format(" Foreground:", ">", fgSum));
}
for (Class<? extends BondedTerm> clas : fgMap.keySet()) {
if (p) {
sb.append(format(" " + clas.getName().replaceAll("ffx.potential.bonded.", "") + ":", ">>", fgMap.get(clas).get()));
}
}
// Background portion:
double bgSum = 0.0;
HashMap<Class<? extends BondedTerm>, SharedDouble> bgMap = esv.getBackgroundBondedDerivDecomp();
for (SharedDouble dub : bgMap.values()) {
bgSum += dub.get();
}
if (p) {
sb.append(format(" Background:", ">", bgSum));
}
for (Class<? extends BondedTerm> clas : bgMap.keySet()) {
if (p) {
sb.append(format(" " + clas.getName().replaceAll("ffx.potential.bonded.", "") + ":", ">>", bgMap.get(clas).get()));
}
}
}
}
if (Double.isNaN(esvDeriv) || !Double.isFinite(esvDeriv)) {
logger.warning(format("NaN/Inf lambda derivative: %s", this));
}
if (p) {
sb.insert(0, format(" %-21.21s %-2.2s %9.4f", format("dUd%s:", esv.getName()), "", esvDeriv));
}
if (p) {
logger.info(sb.toString());
}
return esvDeriv;
}
use of ffx.potential.bonded.BondedTerm in project ffx by mjschnie.
the class ExtendedVariable method updateBondedLambdas.
private void updateBondedLambdas() {
if (!config.bonded) {
return;
}
bondedDeriv.set(0.0);
double Sl = getLambdaSwitch();
double dSldL = getSwitchDeriv();
for (BondedTerm bt1 : bondedFg) {
if (config.decomposeBonded) {
bt1.attachExtendedVariable(Sl, dSldL, bondedDeriv, fgBondedDerivDecomp);
fgBondedDerivDecomp.clear();
} else {
bt1.attachExtendedVariable(Sl, dSldL, bondedDeriv);
}
}
for (BondedTerm bt0 : bondedBg) {
if (config.decomposeBonded) {
bt0.attachExtendedVariable(1.0 - Sl, -dSldL, bondedDeriv, bgBondedDerivDecomp);
bgBondedDerivDecomp.clear();
} else {
bt0.attachExtendedVariable(1.0 - Sl, -dSldL, bondedDeriv);
}
}
}
Aggregations