use of ffx.potential.bonded.MSNode in project ffx by mjschnie.
the class MolecularAssembly method setView.
/**
* {@inheritDoc}
*/
@Override
public void setView(RendererCache.ViewModel newViewModel, List<BranchGroup> newShapes) {
// Just Detach the whole system branch group
if (newViewModel == RendererCache.ViewModel.DESTROY) {
if (switchGroup != null) {
switchGroup.setWhichChild(Switch.CHILD_NONE);
}
visible = false;
} else if (newViewModel == RendererCache.ViewModel.SHOWVRML) {
switchGroup.setWhichChild(Switch.CHILD_ALL);
} else if (newViewModel == RendererCache.ViewModel.HIDEVRML) {
switchGroup.setWhichChild(0);
} else {
setWireWidth(RendererCache.bondwidth);
if (newViewModel == RendererCache.ViewModel.DETAIL && childNodes.isLive()) {
childNodes.detach();
}
/**
* We'll collect new Scenegraph Shapes in our newShapeNode This is
* to avoid the case where setView is called from the root node and
* all new shapes for every MolecularAssembly would then be put into
* the same ArrayList.
*/
super.setView(newViewModel, myNewShapes);
ArrayList<ROLS> moleculeList = getList(Molecule.class, new ArrayList<>());
for (ROLS m : moleculeList) {
m.setView(newViewModel, myNewShapes);
}
for (MSNode m : molecules.getChildList()) {
m.setView(newViewModel, myNewShapes);
}
for (MSNode m : water.getChildList()) {
m.setView(newViewModel, myNewShapes);
}
for (MSNode m : ions.getChildList()) {
m.setView(newViewModel, myNewShapes);
}
if (newViewModel == RendererCache.ViewModel.INVISIBLE) {
switchGroup.setWhichChild(0);
}
if (newViewModel == RendererCache.ViewModel.DETAIL) {
childNodes.compile();
base.addChild(childNodes);
}
}
}
use of ffx.potential.bonded.MSNode in project ffx by mjschnie.
the class MolecularAssembly method moveIntoUnitCell.
/**
* Move the center of each listed chemical entity into the primary unit cell.
* @param groups
*/
private void moveIntoUnitCell(List<MSNode> groups) {
Crystal cryst = getCrystal();
if (cryst.aperiodic()) {
return;
}
for (MSNode group : groups) {
double[] com = new double[3];
double[] xyz = new double[3];
double[] translate = new double[3];
List<Atom> atoms = group.getAtomList();
double totMass = 0;
for (Atom atom : atoms) {
double mass = atom.getMass();
totMass += mass;
xyz = atom.getXYZ(xyz);
for (int i = 0; i < 3; i++) {
double diff = xyz[i] - com[i];
diff /= totMass;
com[i] += diff;
}
}
cryst.toPrimaryCell(com, translate);
for (int i = 0; i < 3; i++) {
translate[i] -= com[i];
}
for (Atom atom : atoms) {
atom.move(translate);
}
}
}
use of ffx.potential.bonded.MSNode in project ffx by mjschnie.
the class MolecularAssembly method finalize.
/**
* {@inheritDoc}
*/
@Override
public void finalize(boolean finalizeGroups, ForceField forceField) {
setFinalized(false);
if (finalizeGroups) {
bondTime = 0;
angleTime = 0;
stretchBendTime = 0;
ureyBradleyTime = 0;
outOfPlaneBendTime = 0;
torsionTime = 0;
piOrbitalTorsionTime = 0;
torsionTorsionTime = 0;
ArrayList<MSNode> Polymers = getAtomNodeList();
for (ListIterator<MSNode> li = Polymers.listIterator(); li.hasNext(); ) {
MSGroup group = (MSGroup) li.next();
if (logger.isLoggable(Level.FINE)) {
logger.fine(" Finalizing bonded terms for polymer " + group.toString());
}
try {
group.finalize(true, forceField);
} catch (Exception e) {
String message = "Fatal exception finalizing " + group.toString();
logger.log(Level.SEVERE, message, e);
System.exit(-1);
}
if (logger.isLoggable(Level.FINE)) {
Runtime runtime = Runtime.getRuntime();
long occupiedMemory = runtime.totalMemory() - runtime.freeMemory();
long MB = 1024 * 1024;
logger.fine("\n In-Use Memory (Mb): " + occupiedMemory / MB + "\n Free Memory (Mb): " + runtime.freeMemory() / MB + "\n Total Memory (Mb): " + runtime.totalMemory() / MB);
}
}
for (MSNode m : molecules.getChildList()) {
Molecule molecule = (Molecule) m;
molecule.finalize(true, forceField);
}
for (MSNode m : water.getChildList()) {
Molecule molecule = (Molecule) m;
molecule.finalize(true, forceField);
}
for (MSNode m : ions.getChildList()) {
Molecule molecule = (Molecule) m;
molecule.finalize(true, forceField);
}
if (logger.isLoggable(Level.FINE)) {
StringBuilder sb = new StringBuilder("\n Time to create bonded energy terms\n\n");
sb.append(String.format(" Bond Streching %10.3f\n", bondTime * 1.0e-9));
sb.append(String.format(" Angle Bending %10.3f\n", angleTime * 1.0e-9));
sb.append(String.format(" Stretch-Bend %10.3f\n", stretchBendTime * 1.0e-9));
sb.append(String.format(" Urey-Bradley %10.3f\n", ureyBradleyTime * 1.0e-9));
sb.append(String.format(" Out-of-Plane Bend %10.3f\n", outOfPlaneBendTime * 1.0e-9));
sb.append(String.format(" Torsionanl Angle %10.3f\n", torsionTime * 1.0e-9));
sb.append(String.format(" Pi-Orbital Torsion %10.3f\n", piOrbitalTorsionTime * 1.0e-9));
sb.append(String.format(" Torsion-Torsion %10.3f\n", torsionTorsionTime * 1.0e-9));
logger.fine(sb.toString());
}
}
if (!java.awt.GraphicsEnvironment.isHeadless()) {
createScene(!finalizeGroups);
center();
}
removeLeaves();
setFinalized(true);
}
use of ffx.potential.bonded.MSNode in project ffx by mjschnie.
the class MolecularAssembly method getPolymer.
/**
* <p>
* getPolymer</p>
*
* @param chainID a {@link java.lang.Character} object.
* @param segID a {@link java.lang.String} object.
* @param create a boolean.
* @return a {@link ffx.potential.bonded.Polymer} object.
*/
public Polymer getPolymer(Character chainID, String segID, boolean create) {
for (ListIterator<MSNode> li = getAtomNodeList().listIterator(); li.hasNext(); ) {
MSNode node = li.next();
if (node instanceof Polymer) {
Polymer polymer = (Polymer) node;
if (polymer.getName().equals(segID) && polymer.getChainID().equals(chainID)) {
return (Polymer) node;
}
}
}
if (create) {
Polymer polymer = new Polymer(chainID, segID, true);
addMSNode(polymer);
return polymer;
}
return null;
}
use of ffx.potential.bonded.MSNode in project ffx by mjschnie.
the class ExtendedVariable method describe.
/**
* List all the atoms and bonded terms associated with each end state.
*/
public final void describe() {
SB.append(format(" %s", this.toString()));
SB.append(format(" %-50s %-50s", "Shared Atoms", "(Background)"));
for (int i = 0; i < atomsShared.size(); i++) {
Atom ai = atomsShared.get(i);
SB.append(format(" %-50s %-50s", ai.describe(Atom.Descriptions.Default).trim(), fg2bg.get(ai).describe(Atom.Descriptions.Trim)));
}
SB.append(format(" Unshared Atoms"));
for (Atom atom : atomsUnshared) {
SB.append(format("%s", atom));
}
SB.append(format(" %-50s %-50s", "Bonded Terms", "(Background)"));
MSNode extendedNode = termNode.getChildList().stream().filter(node -> node.toString().contains("Extended")).findAny().orElse(null);
for (MSNode term : termNode.getChildList()) {
if (term == extendedNode) {
continue;
}
MSNode background = (extendedNode == null) ? null : extendedNode.getChildList().stream().filter(node -> node.toString().startsWith(term.toString().substring(0, term.toString().indexOf("(")))).findAny().orElse(null);
String bgTermString = (background != null) ? background.toString() : "";
SB.append(format(" %-50s %-50s", term.toString(), bgTermString));
}
logger.info(SB.toString());
}
Aggregations