mirror of
https://github.com/openmm/openmm
synced 2026-06-03 06:39:48 +09:00
Changes for 8.1.2 (#4578)
* Revert #3521; see #4405 (#4410) * Fixed memory leak (#4461) * Avoid overflow in large XTC files (#4485) * Avoid overflow in large XTC files * Also cast box indices to size_t * Fixed error when using both CustomNonbondedForce and LennardJonesForce (#4508) * Allow multiple registrations of the same atom type if definitions identical (#4531) * Allow multiple registrations of the same atom type if definitions identical * Different short-circuiting logic * Update version number to 8.1.2 --------- Co-authored-by: Daniel R. Roe <daniel.r.roe@gmail.com> Co-authored-by: Raul <raulppelaez@gmail.com> Co-authored-by: Matt Thompson <mattwthompson@protonmail.com>
This commit is contained in:
@@ -165,7 +165,7 @@ ENDIF (NOT CMAKE_CXX_FLAGS_RELEASE)
|
||||
SET(OPENMM_LIBRARY_NAME OpenMM)
|
||||
SET(OPENMM_MAJOR_VERSION 8)
|
||||
SET(OPENMM_MINOR_VERSION 1)
|
||||
SET(OPENMM_BUILD_VERSION 1)
|
||||
SET(OPENMM_BUILD_VERSION 2)
|
||||
|
||||
ADD_DEFINITIONS(-DOPENMM_LIBRARY_NAME=${OPENMM_LIBRARY_NAME}
|
||||
-DOPENMM_MAJOR_VERSION=${OPENMM_MAJOR_VERSION}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* https://github.com/Gallicchio-Lab/openmm-atmmetaforce-plugin *
|
||||
* with support from the National Science Foundation CAREER 1750511 *
|
||||
* *
|
||||
* Portions copyright (c) 2021-2023 by the Authors *
|
||||
* Portions copyright (c) 2021-2024 by the Authors *
|
||||
* Authors: Emilio Gallicchio *
|
||||
* Contributors: Peter Eastman *
|
||||
* *
|
||||
@@ -56,7 +56,8 @@
|
||||
using namespace OpenMM;
|
||||
using namespace std;
|
||||
|
||||
ATMForceImpl::ATMForceImpl(const ATMForce& owner) : owner(owner), innerIntegrator0(1.0), innerIntegrator1(1.0) {
|
||||
ATMForceImpl::ATMForceImpl(const ATMForce& owner) : owner(owner), innerIntegrator0(1.0), innerIntegrator1(1.0),
|
||||
innerContext0(NULL), innerContext1(NULL) {
|
||||
Lepton::ParsedExpression expr = Lepton::Parser::parse(owner.getEnergyFunction()).optimize();
|
||||
energyExpression = expr.createCompiledExpression();
|
||||
u0DerivExpression = expr.differentiate("u0").createCompiledExpression();
|
||||
@@ -81,6 +82,10 @@ ATMForceImpl::ATMForceImpl(const ATMForce& owner) : owner(owner), innerIntegrato
|
||||
}
|
||||
|
||||
ATMForceImpl::~ATMForceImpl() {
|
||||
if (innerContext0 != NULL)
|
||||
delete innerContext0;
|
||||
if (innerContext1 != NULL)
|
||||
delete innerContext1;
|
||||
}
|
||||
|
||||
void ATMForceImpl::copySystem(ContextImpl& context, const OpenMM::System& system, OpenMM::System& innerSystem) {
|
||||
|
||||
@@ -92,7 +92,7 @@ class DCDFile(object):
|
||||
raise ValueError('Cannot append to a DCD file that contains a different number of atoms')
|
||||
else:
|
||||
header = struct.pack('<i4c9if', 84, b'C', b'O', b'R', b'D', 0, firstStep, interval, 0, 0, 0, 0, 0, 0, dt)
|
||||
header += struct.pack('<13i', boxFlag, 0, 0, 0, 0, 0, 0, 0, 0, 21, 84, 164, 2)
|
||||
header += struct.pack('<13i', boxFlag, 0, 0, 0, 0, 0, 0, 0, 0, 24, 84, 164, 2)
|
||||
header += struct.pack('<80s', b'Created by OpenMM')
|
||||
header += struct.pack('<80s', b'Created '+time.asctime(time.localtime(time.time())).encode('ascii'))
|
||||
header += struct.pack('<4i', 164, 4, len(list(topology.atoms())), 4)
|
||||
|
||||
@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
|
||||
Biological Structures at Stanford, funded under the NIH Roadmap for
|
||||
Medical Research, grant U54 GM072970. See https://simtk.org.
|
||||
|
||||
Portions copyright (c) 2012-2022 Stanford University and the Authors.
|
||||
Portions copyright (c) 2012-2024 Stanford University and the Authors.
|
||||
Authors: Peter Eastman, Mark Friedrichs
|
||||
Contributors:
|
||||
|
||||
@@ -436,6 +436,10 @@ class ForceField(object):
|
||||
"""Register a new atom type."""
|
||||
name = parameters['name']
|
||||
if name in self._atomTypes:
|
||||
# allow multiple registrations of the same atom type provided the definitions are identical
|
||||
existing = self._atomTypes[name]
|
||||
if existing.atomClass == parameters['class'] and existing.mass == float(parameters['mass']) and existing.element.symbol == parameters['element']:
|
||||
return
|
||||
raise ValueError('Found multiple definitions for atom type: '+name)
|
||||
atomClass = parameters['class']
|
||||
mass = _convertParameterToNumber(parameters['mass'])
|
||||
@@ -3010,8 +3014,9 @@ class CustomNonbondedGenerator(object):
|
||||
# Create the exclusions.
|
||||
|
||||
bondIndices = _findBondsForExclusions(data, sys)
|
||||
nonbonded = [f for f in sys.getForces() if isinstance(f, mm.CustomNonbondedForce)][0]
|
||||
nonbonded.createExclusionsFromBonds(bondIndices, self.bondCutoff)
|
||||
for f in sys.getForces():
|
||||
if isinstance(f, mm.CustomNonbondedForce) and f.getEnergyFunction() == self.energy:
|
||||
f.createExclusionsFromBonds(bondIndices, self.bondCutoff)
|
||||
|
||||
parsers["CustomNonbondedForce"] = CustomNonbondedGenerator.parseElement
|
||||
|
||||
|
||||
@@ -123,20 +123,21 @@ void xtc_read(std::string filename, float* coords_arr, float* box_arr, float* ti
|
||||
throw std::runtime_error("xtc_read(): natoms is 0\n");
|
||||
}
|
||||
XDRFILE_RAII xd(filename, "r");
|
||||
int fidx = 0;
|
||||
size_t fidx = 0;
|
||||
size_t nframes_long = nframes;
|
||||
XTCFrame frame(natoms);
|
||||
while (exdrOK == frame.readNextFrame(xd)) {
|
||||
time_arr[fidx] = frame.time;
|
||||
step_arr[fidx] = frame.step;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
box_arr[fidx + (3 * i + j) * nframes] = frame.box[i][j];
|
||||
box_arr[fidx + (3 * i + j) * nframes_long] = frame.box[i][j];
|
||||
}
|
||||
}
|
||||
for (int aidx = 0; aidx < natoms; aidx++) {
|
||||
int xidx = Xf(aidx, fidx, nframes);
|
||||
int yidx = Yf(xidx, nframes);
|
||||
int zidx = Zf(yidx, nframes);
|
||||
for (size_t aidx = 0; aidx < natoms; aidx++) {
|
||||
size_t xidx = Xf(aidx, fidx, nframes_long);
|
||||
size_t yidx = Yf(xidx, nframes_long);
|
||||
size_t zidx = Zf(yidx, nframes_long);
|
||||
coords_arr[xidx] = frame.positions[3 * aidx + 0];
|
||||
coords_arr[yidx] = frame.positions[3 * aidx + 1];
|
||||
coords_arr[zidx] = frame.positions[3 * aidx + 2];
|
||||
@@ -145,9 +146,9 @@ void xtc_read(std::string filename, float* coords_arr, float* box_arr, float* ti
|
||||
}
|
||||
}
|
||||
|
||||
static void box_from_array(matrix& matrix_box, float* box, int frame, int nframes) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
static void box_from_array(matrix& matrix_box, float* box, size_t frame, size_t nframes) {
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
for (size_t j = 0; j < 3; j++) {
|
||||
matrix_box[i][j] = box[(3 * i + j) * nframes + frame];
|
||||
}
|
||||
}
|
||||
@@ -156,12 +157,13 @@ static void box_from_array(matrix& matrix_box, float* box, int frame, int nframe
|
||||
void xtc_write(std::string filename, int natoms, int nframes, int* step, float* timex, float* pos, float* box) {
|
||||
XDRFILE_RAII xd(filename, "a");
|
||||
XTCFrame frame(natoms);
|
||||
for (int f = 0; f < nframes; f++) {
|
||||
box_from_array(frame.box, box, f, nframes);
|
||||
for (int i = 0; i < natoms; i++) {
|
||||
int xidx = Xf(i, f, nframes);
|
||||
int yidx = Yf(xidx, nframes);
|
||||
int zidx = Zf(yidx, nframes);
|
||||
size_t nframes_long = nframes;
|
||||
for (size_t f = 0; f < nframes; f++) {
|
||||
box_from_array(frame.box, box, f, nframes_long);
|
||||
for (size_t i = 0; i < natoms; i++) {
|
||||
size_t xidx = Xf(i, f, nframes_long);
|
||||
size_t yidx = Yf(xidx, nframes_long);
|
||||
size_t zidx = Zf(yidx, nframes_long);
|
||||
frame.positions[3 * i + 0] = pos[xidx];
|
||||
frame.positions[3 * i + 1] = pos[yidx];
|
||||
frame.positions[3 * i + 2] = pos[zidx];
|
||||
|
||||
Reference in New Issue
Block a user