Unverified Commit fc21fd19 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Compile correctly under newer C++ standards (#5296)

parent c6f9fab2
...@@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
#include <exception>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <complex> #include <complex>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2025 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman, Evan Pretti * * Authors: Peter Eastman, Evan Pretti *
* Contributors: * * Contributors: *
* * * *
...@@ -116,15 +116,11 @@ public: ...@@ -116,15 +116,11 @@ public:
/** /**
* Get the number of particles for which force field parameters have been defined. * Get the number of particles for which force field parameters have been defined.
*/ */
int getNumParticles() const { int getNumParticles() const;
return particles.size();
}
/** /**
* Get the number of special interactions that should be calculated differently from other interactions. * Get the number of special interactions that should be calculated differently from other interactions.
*/ */
int getNumExceptions() const { int getNumExceptions() const;
return exceptions.size();
}
/** /**
* Get the cutoff distance (in nm) being used for nonbonded interactions. * Get the cutoff distance (in nm) being used for nonbonded interactions.
* *
...@@ -362,9 +358,7 @@ public: ...@@ -362,9 +358,7 @@ public:
/** /**
* Get the number of electrodes that have been added. * Get the number of electrodes that have been added.
*/ */
int getNumElectrodes() const { int getNumElectrodes() const;
return electrodes.size();
}
/** /**
* Add a new electrode from a set of particles. The specified particles * Add a new electrode from a set of particles. The specified particles
* will have their charges solved for such that they are held at the * will have their charges solved for such that they are held at the
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2025 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman, Evan Pretti * * Authors: Peter Eastman, Evan Pretti *
* Contributors: * * Contributors: *
* * * *
...@@ -47,6 +47,18 @@ ConstantPotentialForce::ConstantPotentialForce() : constantPotentialMethod(CG), ...@@ -47,6 +47,18 @@ ConstantPotentialForce::ConstantPotentialForce() : constantPotentialMethod(CG),
nx(0), ny(0), nz(0), numContexts(0) { nx(0), ny(0), nz(0), numContexts(0) {
} }
int ConstantPotentialForce::getNumParticles() const {
return particles.size();
}
int ConstantPotentialForce::getNumExceptions() const {
return exceptions.size();
}
int ConstantPotentialForce::getNumElectrodes() const {
return electrodes.size();
}
double ConstantPotentialForce::getCutoffDistance() const { double ConstantPotentialForce::getCutoffDistance() const {
return cutoffDistance; return cutoffDistance;
} }
......
...@@ -44,9 +44,7 @@ namespace OpenMM { ...@@ -44,9 +44,7 @@ namespace OpenMM {
class CommonIntegrateCustomStepKernel : public IntegrateCustomStepKernel { class CommonIntegrateCustomStepKernel : public IntegrateCustomStepKernel {
public: public:
enum GlobalTargetType {DT, VARIABLE, PARAMETER}; enum GlobalTargetType {DT, VARIABLE, PARAMETER};
CommonIntegrateCustomStepKernel(std::string name, const Platform& platform, ComputeContext& cc) : IntegrateCustomStepKernel(name, platform), cc(cc), CommonIntegrateCustomStepKernel(std::string name, const Platform& platform, ComputeContext& cc);
hasInitializedKernels(false), deviceGlobalsAreCurrent(false), needsEnergyParamDerivs(false) {
}
/** /**
* Initialize the kernel. * Initialize the kernel.
* *
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2025 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -113,6 +113,10 @@ private: ...@@ -113,6 +113,10 @@ private:
string param; string param;
}; };
CommonIntegrateCustomStepKernel::CommonIntegrateCustomStepKernel(std::string name, const Platform& platform, ComputeContext& cc) : IntegrateCustomStepKernel(name, platform), cc(cc),
hasInitializedKernels(false), deviceGlobalsAreCurrent(false), needsEnergyParamDerivs(false) {
}
void CommonIntegrateCustomStepKernel::initialize(const System& system, const CustomIntegrator& integrator) { void CommonIntegrateCustomStepKernel::initialize(const System& system, const CustomIntegrator& integrator) {
cc.initializeContexts(); cc.initializeContexts();
ContextSelector selector(cc); ContextSelector selector(cc);
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman * * Authors: Mark Friedrichs, Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -59,9 +59,7 @@ public: ...@@ -59,9 +59,7 @@ public:
/** /**
* Get the number of particles in the system. * Get the number of particles in the system.
*/ */
int getNumParticles() const { int getNumParticles() const;
return particles.size();
}
/** /**
* Add the parameters for a particle. This should be called once for each particle * Add the parameters for a particle. This should be called once for each particle
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman * * Authors: Mark Friedrichs, Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -105,9 +105,7 @@ public: ...@@ -105,9 +105,7 @@ public:
/** /**
* Get the number of particles in the potential function * Get the number of particles in the potential function
*/ */
int getNumMultipoles() const { int getNumMultipoles() const;
return multipoles.size();
}
/** /**
* Get the method used for handling long-range nonbonded interactions. * Get the method used for handling long-range nonbonded interactions.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman * * Authors: Mark Friedrichs, Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -59,16 +59,12 @@ public: ...@@ -59,16 +59,12 @@ public:
/** /**
* Get the number of torsion-torsion terms in the potential function * Get the number of torsion-torsion terms in the potential function
*/ */
int getNumTorsionTorsions(void) const { int getNumTorsionTorsions(void) const;
return torsionTorsions.size();
}
/** /**
* Get the number of torsion-torsion grids * Get the number of torsion-torsion grids
*/ */
int getNumTorsionTorsionGrids(void) const { int getNumTorsionTorsionGrids(void) const;
return torsionTorsionGrids.size();
}
/** /**
* Add a torsion-torsion term to the force field. * Add a torsion-torsion term to the force field.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2020 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman * * Authors: Mark Friedrichs, Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -143,23 +143,17 @@ public: ...@@ -143,23 +143,17 @@ public:
/** /**
* Get the number of particles * Get the number of particles
*/ */
int getNumParticles() const { int getNumParticles() const;
return parameters.size();
}
/** /**
* Get the number of particle types. * Get the number of particle types.
*/ */
int getNumParticleTypes() const { int getNumParticleTypes() const;
return types.size();
}
/** /**
* Get the number of type pairs. * Get the number of type pairs.
*/ */
int getNumTypePairs() const { int getNumTypePairs() const;
return pairs.size();
}
/** /**
* Set the force field parameters for a vdw particle. * Set the force field parameters for a vdw particle.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman * * Authors: Mark Friedrichs, Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -57,9 +57,7 @@ public: ...@@ -57,9 +57,7 @@ public:
/** /**
* Get the number of particles * Get the number of particles
*/ */
int getNumParticles() const { int getNumParticles() const;
return parameters.size();
}
/** /**
* Set the force field parameters for a WCA dispersion particle. * Set the force field parameters for a WCA dispersion particle.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs * * Authors: Peter Eastman, Mark Friedrichs *
* Contributors: * * Contributors: *
* * * *
...@@ -79,15 +79,11 @@ public: ...@@ -79,15 +79,11 @@ public:
/** /**
* Get the number of particles in the potential function. * Get the number of particles in the potential function.
*/ */
int getNumParticles() const { int getNumParticles() const;
return particles.size();
}
/** /**
* Get the number of exceptions. * Get the number of exceptions.
*/ */
int getNumExceptions() const { int getNumExceptions() const;
return exceptions.size();
}
/** /**
* Get the method used for handling long-range nonbonded interactions. * Get the method used for handling long-range nonbonded interactions.
*/ */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -40,6 +40,10 @@ AmoebaGeneralizedKirkwoodForce::AmoebaGeneralizedKirkwoodForce() : ...@@ -40,6 +40,10 @@ AmoebaGeneralizedKirkwoodForce::AmoebaGeneralizedKirkwoodForce() :
surfaceAreaFactor = -6.0* 3.1415926535*0.0216*1000.0*0.4184; surfaceAreaFactor = -6.0* 3.1415926535*0.0216*1000.0*0.4184;
} }
int AmoebaGeneralizedKirkwoodForce::getNumParticles() const {
return particles.size();
}
int AmoebaGeneralizedKirkwoodForce::addParticle(double charge, double radius, double scalingFactor) { int AmoebaGeneralizedKirkwoodForce::addParticle(double charge, double radius, double scalingFactor) {
particles.push_back(ParticleInfo(charge, radius, scalingFactor, radius, 0.0)); particles.push_back(ParticleInfo(charge, radius, scalingFactor, radius, 0.0));
return particles.size()-1; return particles.size()-1;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: * * Authors: *
* Contributors: * * Contributors: *
* * * *
...@@ -46,6 +46,10 @@ AmoebaMultipoleForce::AmoebaMultipoleForce() : nonbondedMethod(NoCutoff), polari ...@@ -46,6 +46,10 @@ AmoebaMultipoleForce::AmoebaMultipoleForce() : nonbondedMethod(NoCutoff), polari
extrapolationCoefficients.push_back(0.474); extrapolationCoefficients.push_back(0.474);
} }
int AmoebaMultipoleForce::getNumMultipoles() const {
return multipoles.size();
}
AmoebaMultipoleForce::NonbondedMethod AmoebaMultipoleForce::getNonbondedMethod() const { AmoebaMultipoleForce::NonbondedMethod AmoebaMultipoleForce::getNonbondedMethod() const {
return nonbondedMethod; return nonbondedMethod;
} }
......
...@@ -39,6 +39,13 @@ using namespace std; ...@@ -39,6 +39,13 @@ using namespace std;
AmoebaTorsionTorsionForce::AmoebaTorsionTorsionForce() : usePeriodic(false) { AmoebaTorsionTorsionForce::AmoebaTorsionTorsionForce() : usePeriodic(false) {
} }
int AmoebaTorsionTorsionForce::getNumTorsionTorsions(void) const {
return torsionTorsions.size();
}
int AmoebaTorsionTorsionForce::getNumTorsionTorsionGrids(void) const {
return torsionTorsionGrids.size();
}
int AmoebaTorsionTorsionForce::addTorsionTorsion(int particle1, int particle2, int particle3, int AmoebaTorsionTorsionForce::addTorsionTorsion(int particle1, int particle2, int particle3,
int particle4, int particle5, int chiralCheckAtomIndex, int particle4, int particle5, int chiralCheckAtomIndex,
int gridIndex) { int gridIndex) {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2020 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: * * Authors: *
* Contributors: * * Contributors: *
* * * *
...@@ -42,6 +42,18 @@ AmoebaVdwForce::AmoebaVdwForce() : nonbondedMethod(NoCutoff), potentialFunction( ...@@ -42,6 +42,18 @@ AmoebaVdwForce::AmoebaVdwForce() : nonbondedMethod(NoCutoff), potentialFunction(
useTypes(false), alchemicalMethod(None), n(5), alpha(0.7) { useTypes(false), alchemicalMethod(None), n(5), alpha(0.7) {
} }
int AmoebaVdwForce::getNumParticles() const {
return parameters.size();
}
int AmoebaVdwForce::getNumParticleTypes() const {
return types.size();
}
int AmoebaVdwForce::getNumTypePairs() const {
return pairs.size();
}
int AmoebaVdwForce::addParticle(int parentIndex, double sigma, double epsilon, double reductionFactor, bool isAlchemical, double scaleFactor) { int AmoebaVdwForce::addParticle(int parentIndex, double sigma, double epsilon, double reductionFactor, bool isAlchemical, double scaleFactor) {
if (useTypes) if (useTypes)
throw OpenMMException("AmoebaVdwForce: must use the same version of addParticle() for all particles"); throw OpenMMException("AmoebaVdwForce: must use the same version of addParticle() for all particles");
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: * * Authors: *
* Contributors: * * Contributors: *
* * * *
...@@ -54,6 +54,10 @@ AmoebaWcaDispersionForce::AmoebaWcaDispersionForce() { ...@@ -54,6 +54,10 @@ AmoebaWcaDispersionForce::AmoebaWcaDispersionForce() {
shctd = 0.82; shctd = 0.82;
} }
int AmoebaWcaDispersionForce::getNumParticles() const {
return parameters.size();
}
int AmoebaWcaDispersionForce::addParticle(double radius, double epsilon) { int AmoebaWcaDispersionForce::addParticle(double radius, double epsilon) {
parameters.push_back(WcaDispersionInfo(radius, epsilon)); parameters.push_back(WcaDispersionInfo(radius, epsilon));
return parameters.size()-1; return parameters.size()-1;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2026 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,6 +42,14 @@ HippoNonbondedForce::HippoNonbondedForce() : nonbondedMethod(NoCutoff), cutoffDi ...@@ -42,6 +42,14 @@ HippoNonbondedForce::HippoNonbondedForce() : nonbondedMethod(NoCutoff), cutoffDi
extrapolationCoefficients = {0.042, 0.635, 0.414}; extrapolationCoefficients = {0.042, 0.635, 0.414};
} }
int HippoNonbondedForce::getNumParticles() const {
return particles.size();
}
int HippoNonbondedForce::getNumExceptions() const {
return exceptions.size();
}
HippoNonbondedForce::NonbondedMethod HippoNonbondedForce::getNonbondedMethod() const { HippoNonbondedForce::NonbondedMethod HippoNonbondedForce::getNonbondedMethod() const {
return nonbondedMethod; return nonbondedMethod;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2013-2024 Stanford University and the Authors. * * Portions copyright (c) 2013-2026 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -59,15 +59,11 @@ public: ...@@ -59,15 +59,11 @@ public:
/** /**
* Get the number of particles for which force field parameters have been defined. * Get the number of particles for which force field parameters have been defined.
*/ */
int getNumParticles() const { int getNumParticles() const;
return particles.size();
}
/** /**
* Get the number of special interactions that should be calculated differently from other interactions. * Get the number of special interactions that should be calculated differently from other interactions.
*/ */
int getNumScreenedPairs() const { int getNumScreenedPairs() const;
return screenedPairs.size();
}
/** /**
* Add a Drude particle to which forces should be applied. * Add a Drude particle to which forces should be applied.
* *
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* This is part of the OpenMM molecular simulation toolkit. * * This is part of the OpenMM molecular simulation toolkit. *
* See https://openmm.org/development. * * See https://openmm.org/development. *
* * * *
* Portions copyright (c) 2013-2024 Stanford University and the Authors. * * Portions copyright (c) 2013-2026 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -39,6 +39,14 @@ using namespace std; ...@@ -39,6 +39,14 @@ using namespace std;
DrudeForce::DrudeForce() : usePeriodic(false) { DrudeForce::DrudeForce() : usePeriodic(false) {
} }
int DrudeForce::getNumParticles() const {
return particles.size();
}
int DrudeForce::getNumScreenedPairs() const {
return screenedPairs.size();
}
int DrudeForce::addParticle(int particle, int particle1, int particle2, int particle3, int particle4, double charge, double polarizability, double aniso12, double aniso34) { int DrudeForce::addParticle(int particle, int particle1, int particle2, int particle3, int particle4, double charge, double polarizability, double aniso12, double aniso34) {
if (polarizability <= 0) if (polarizability <= 0)
throw OpenMMException("Polarizability must be positive"); throw OpenMMException("Polarizability must be positive");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment