use of ffx.potential.bonded.ROLS in project ffx by mjschnie.
the class MolecularAssembly method renderWire.
private Shape3D renderWire() {
ArrayList<ROLS> bonds = getBondList();
int numbonds = bonds.size();
if (numbonds < 1) {
return null;
}
Vector3d bondmidpoint = new Vector3d();
double[] mid = { 0, 0, 0 };
Vector3d v1 = new Vector3d();
Vector3d v2 = new Vector3d();
float[] a1 = { 0, 0, 0 };
float[] a2 = { 0, 0, 0 };
float[] col = new float[4];
Bond bond;
Atom atom1, atom2;
LineArray la = new LineArray(4 * numbonds, GeometryArray.COORDINATES | GeometryArray.COLOR_4 | GeometryArray.NORMALS);
la.setCapability(LineArray.ALLOW_COORDINATE_WRITE);
la.setCapability(LineArray.ALLOW_COORDINATE_READ);
la.setCapability(LineArray.ALLOW_COLOR_WRITE);
la.setCapability(LineArray.ALLOW_COUNT_READ);
la.setCapability(LineArray.ALLOW_INTERSECT);
la.setCapability(LineArray.ALLOW_FORMAT_READ);
atomLookUp = new Atom[4 * numbonds];
int i = 0;
col[3] = 0.9f;
for (ListIterator<ROLS> li = bonds.listIterator(); li.hasNext(); ) {
bond = (Bond) li.next();
bond.setWire(la, i);
atom1 = bond.getAtom(0);
atom2 = bond.getAtom(1);
atom1.getV3D(v1);
atom2.getV3D(v2);
a1[0] = (float) v1.x;
a1[1] = (float) v1.y;
a1[2] = (float) v1.z;
a2[0] = (float) v2.x;
a2[1] = (float) v2.y;
a2[2] = (float) v2.z;
// Find the bond center
bondmidpoint.add(v1, v2);
bondmidpoint.scale(0.5d);
bondmidpoint.get(mid);
// Atom #1
Atom.AtomColor.get(atom1.getAtomicNumber()).get(col);
atomLookUp[i] = atom1;
la.setCoordinate(i, a1);
la.setColor(i, col);
la.setNormal(i, a2);
i++;
atomLookUp[i] = atom1;
la.setCoordinate(i, mid);
la.setColor(i, col);
la.setNormal(i, a2);
i++;
// Atom #2
Atom.AtomColor.get(atom2.getAtomicNumber()).get(col);
atomLookUp[i] = atom2;
la.setCoordinate(i, a2);
la.setColor(i, col);
la.setNormal(i, a1);
i++;
atomLookUp[i] = atom2;
la.setCoordinate(i, mid);
la.setColor(i, col);
la.setNormal(i, a1);
i++;
}
ColoringAttributes cola = new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_GOURAUD);
Appearance app = new Appearance();
lineAttributes = new LineAttributes();
lineAttributes.setLineWidth(RendererCache.bondwidth);
lineAttributes.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
lineAttributes.setLineAntialiasingEnable(true);
app.setLineAttributes(lineAttributes);
app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
RenderingAttributes ra = new RenderingAttributes();
ra.setAlphaTestValue(0.1f);
ra.setAlphaTestFunction(RenderingAttributes.GREATER);
ra.setDepthBufferEnable(true);
ra.setDepthBufferWriteEnable(true);
app.setRenderingAttributes(ra);
app.setColoringAttributes(cola);
Shape3D wireframe = new Shape3D(la, app);
// PickTool.setCapabilities(wire, PickTool.INTERSECT_COORD);
wireframe.setUserData(this);
wireframe.setBounds(new BoundingSphere(new Point3d(0, 0, 0), 1000.0));
try {
wireframe.setBoundsAutoCompute(false);
} catch (Exception e) {
e.printStackTrace();
}
wireframe.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
wireframe.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
wireframe.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
return wireframe;
}
use of ffx.potential.bonded.ROLS in project ffx by mjschnie.
the class PhMD method meltdown.
private void meltdown() {
writeSnapshot(".meltdown-");
ffe.energy(false, true);
if (ffe.getBondEnergy() > 1000) {
for (ROLS rols : previousTarget.getBondList()) {
((Bond) rols).log();
}
}
if (ffe.getAngleEnergy() > 1000) {
for (ROLS rols : previousTarget.getAngleList()) {
((Angle) rols).log();
}
}
if (ffe.getVanDerWaalsEnergy() > 1000) {
for (Atom a1 : previousTarget.getAtomList()) {
for (Atom a2 : mola.getAtomArray()) {
if (a1 == a2 || a1.getBond(a2) != null) {
continue;
}
double dist = sqrt(pow((a1.getX() - a2.getX()), 2) + pow((a1.getY() - a2.getY()), 2) + pow((a1.getZ() - a2.getZ()), 2));
if (dist < 0.8 * (a1.getVDWR() + a2.getVDWR())) {
logger.warning(String.format("Close vdW contact for atoms: \n %s\n %s", a1, a2));
}
}
}
}
logger.severe(String.format("Temperature above critical threshold: %f", thermostat.getCurrentTemperature()));
}
use of ffx.potential.bonded.ROLS in project ffx by mjschnie.
the class RosenbluthChiAllMove method measureLysine.
public double[] measureLysine(Residue residue, boolean print) {
if (!residue.getName().contains("LY") || (residue.getAminoAcid3() != AminoAcid3.LYS && residue.getAminoAcid3() != AminoAcid3.LYD)) {
logger.severe("Yeah that ain't a lysine.");
}
double[] chi = new double[4];
ArrayList<ROLS> torsions = residue.getTorsionList();
Atom N = (Atom) residue.getAtomNode("N");
Atom CA = (Atom) residue.getAtomNode("CA");
Atom CB = (Atom) residue.getAtomNode("CB");
Atom CD = (Atom) residue.getAtomNode("CD");
Atom CE = (Atom) residue.getAtomNode("CE");
Atom CG = (Atom) residue.getAtomNode("CG");
Atom NZ = (Atom) residue.getAtomNode("NZ");
logger.info(String.format(" Here's the atoms I found: \n%s\n%s\n%s\n%s\n%s\n%s\n%s", N, CA, CB, CD, CE, CG, NZ));
logger.info(String.format(" Num torsions: %d", torsions.size()));
int count = 0;
for (ROLS rols : torsions) {
Torsion torsion = (Torsion) rols;
torsion.energy(false);
logger.info(String.format(" Torsion numba %d: %s", count++, torsion));
if (torsion.compare(N, CA, CB, CG)) {
chi[0] = torsion.getValue();
if (print) {
logger.info(torsion.toString());
}
}
if (torsion.compare(CA, CB, CG, CD)) {
chi[1] = torsion.getValue();
if (print) {
logger.info(torsion.toString());
}
}
if (torsion.compare(CB, CG, CD, CE)) {
chi[2] = torsion.getValue();
if (print) {
logger.info(torsion.toString());
}
}
if (torsion.compare(CG, CD, CE, NZ)) {
chi[3] = torsion.getValue();
if (print) {
logger.info(torsion.toString());
}
}
}
return chi;
}
use of ffx.potential.bonded.ROLS 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;
}
Aggregations