Search in sources :

Example 6 with OpenMM_Vec3

use of simtk.openmm.OpenMM_Vec3 in project ffx by mjschnie.

the class ForceFieldEnergyOpenMM method setOpenMMPositions.

/**
 * setOpenMMPositions takes in an array of doubles generated by the DYN
 * reader method and appends these values to a Vec3Array. Finally this
 * method sets the created Vec3Array as the positions of the context.
 *
 * @param x
 * @param numberOfVariables
 */
public void setOpenMMPositions(double[] x, int numberOfVariables) {
    assert numberOfVariables == getNumberOfVariables();
    if (positions == null) {
        positions = OpenMM_Vec3Array_create(0);
    } else {
        OpenMM_Vec3Array_resize(positions, 0);
    }
    OpenMM_Vec3.ByValue pos = new OpenMM_Vec3.ByValue();
    for (int i = 0; i < numberOfVariables; i = i + 3) {
        pos.x = x[i] * OpenMM_NmPerAngstrom;
        pos.y = x[i + 1] * OpenMM_NmPerAngstrom;
        pos.z = x[i + 2] * OpenMM_NmPerAngstrom;
        OpenMM_Vec3Array_append(positions, pos);
    }
    OpenMM_Context_setPositions(context, positions);
}
Also used : OpenMM_Vec3(simtk.openmm.OpenMM_Vec3) OpenMM_System_addConstraint(simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint) CoordRestraint(ffx.potential.nonbonded.CoordRestraint)

Example 7 with OpenMM_Vec3

use of simtk.openmm.OpenMM_Vec3 in project ffx by mjschnie.

the class ForceFieldEnergyOpenMM method setDefaultPeriodicBoxVectors.

private void setDefaultPeriodicBoxVectors() {
    OpenMM_Vec3 a = new OpenMM_Vec3();
    OpenMM_Vec3 b = new OpenMM_Vec3();
    OpenMM_Vec3 c = new OpenMM_Vec3();
    Crystal crystal = super.getCrystal();
    if (!crystal.aperiodic()) {
        a.x = crystal.a * OpenMM_NmPerAngstrom;
        a.y = 0.0 * OpenMM_NmPerAngstrom;
        a.z = 0.0 * OpenMM_NmPerAngstrom;
        b.x = 0.0 * OpenMM_NmPerAngstrom;
        b.y = crystal.b * OpenMM_NmPerAngstrom;
        b.z = 0.0 * OpenMM_NmPerAngstrom;
        c.x = 0.0 * OpenMM_NmPerAngstrom;
        c.y = 0.0 * OpenMM_NmPerAngstrom;
        c.z = crystal.c * OpenMM_NmPerAngstrom;
        OpenMM_System_setDefaultPeriodicBoxVectors(system, a, b, c);
    }
}
Also used : OpenMM_Vec3(simtk.openmm.OpenMM_Vec3) Crystal(ffx.crystal.Crystal)

Aggregations

OpenMM_Vec3 (simtk.openmm.OpenMM_Vec3)7 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)6 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)6 Atom (ffx.potential.bonded.Atom)4 Crystal (ffx.crystal.Crystal)1 EnergyException (ffx.potential.utils.EnergyException)1