Search in sources :

Example 31 with MSNode

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);
        }
    }
}
Also used : ROLS(ffx.potential.bonded.ROLS) MSNode(ffx.potential.bonded.MSNode)

Example 32 with MSNode

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);
        }
    }
}
Also used : MSNode(ffx.potential.bonded.MSNode) Atom(ffx.potential.bonded.Atom) Crystal(ffx.crystal.Crystal)

Example 33 with MSNode

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);
}
Also used : Molecule(ffx.potential.bonded.Molecule) MSNode(ffx.potential.bonded.MSNode) MSGroup(ffx.potential.bonded.MSGroup)

Example 34 with MSNode

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;
}
Also used : MSNode(ffx.potential.bonded.MSNode) Polymer(ffx.potential.bonded.Polymer)

Example 35 with MSNode

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());
}
Also used : Atom(ffx.potential.bonded.Atom) MSNode(ffx.potential.bonded.MSNode) FastMath.sin(org.apache.commons.math3.util.FastMath.sin) BondedTerm(ffx.potential.bonded.BondedTerm) HashMap(java.util.HashMap) FastMath.sqrt(org.apache.commons.math3.util.FastMath.sqrt) MultipoleType.zeroM(ffx.potential.parameters.MultipoleType.zeroM) Logger(java.util.logging.Logger) PI(org.apache.commons.math3.util.FastMath.PI) Descriptions(ffx.potential.bonded.Atom.Descriptions) MultiResidue(ffx.potential.bonded.MultiResidue) String.format(java.lang.String.format) ArrayList(java.util.ArrayList) ExtendedSystemConfig(ffx.potential.extended.ExtendedSystem.ExtendedSystemConfig) List(java.util.List) Residue(ffx.potential.bonded.Residue) SharedDouble(edu.rit.pj.reduction.SharedDouble) TitrationUtils.isTitratableHydrogen(ffx.potential.extended.TitrationUtils.isTitratableHydrogen) MultipoleType(ffx.potential.parameters.MultipoleType) RNG(ffx.potential.extended.ExtConstants.RNG) MultiplicativeSwitch(ffx.potential.nonbonded.MultiplicativeSwitch) Collections(java.util.Collections) MSNode(ffx.potential.bonded.MSNode) Atom(ffx.potential.bonded.Atom)

Aggregations

MSNode (ffx.potential.bonded.MSNode)39 Atom (ffx.potential.bonded.Atom)21 Polymer (ffx.potential.bonded.Polymer)20 Molecule (ffx.potential.bonded.Molecule)16 Residue (ffx.potential.bonded.Residue)13 ArrayList (java.util.ArrayList)9 MolecularAssembly (ffx.potential.MolecularAssembly)7 Bond (ffx.potential.bonded.Bond)7 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)6 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)6 IOException (java.io.IOException)6 Crystal (ffx.crystal.Crystal)5 File (java.io.File)5 MSGroup (ffx.potential.bonded.MSGroup)4 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 HashMap (java.util.HashMap)3 List (java.util.List)3 MSRoot (ffx.potential.bonded.MSRoot)2 ROLS (ffx.potential.bonded.ROLS)2