39 Commits

Author SHA1 Message Date
Christian Clauss
82703dff73 Fix typos discovered by codespell in Python files (#5173) 2025-12-30 12:21:00 -08:00
Evan Pretti
adfd84c273 Add LCPO method (#5130)
* Basic LCPO support

* Add basic test for LCPO from a prmtop file

* API for LCPOForce

* Started LCPO reference implementation

* Finished reference forces & test cases

* Use other test for finite difference since grid might have discontinuous forces

* Reference platform formatting

* Initial implementation of CPU platform

* Bugfixes

* More vectorization and improve neighbor list query speed

* Parallelize part of neighbor search

* Check box size for LCPO with periodic boundary conditions

* Fixes for updating parameters in context

* GBSAOBCForce doesn't use first & last indices for updates, so no need for this optimization here

* Changes to neighbor checking and optimization

* Fixes and minor changes

* Add global surface tension parameter

* Only process half of the pairs in the neighbor list

* Remove unnecessary checks

* Initial version of common platform implementation

* Asynchronously download neighbor list size

* Debugging

* Do pair precomputation in copyPairsToNeighborList

* Recompute interactions instead of scanning neighbor list in inner loop

* Condense position array before computations

* Also make neighbor count download asynchronous on device

* Fixes for kernel launching

* Topology-based LCPO parameter assignment

* Fixes, and use test system for LCPO with nucleic acids

* Always raise instead of warn when LCPO parameters can't be assigned

* Use Amber convention for phosphates
2025-12-11 13:28:36 -08:00
Peter Eastman
58378cceac Fixed errors in computeCurrentPressure() (#5114) 2025-10-21 18:19:33 -07:00
Evan Pretti
f55abcaa5f Add constant potential method (#4870)
* Initial implementation of C++ API

* Add kernel interface and information for API generation

* API updates for updating electrode parameters

* Add serialization proxy for ConstantPotentialForce

* Update file headers

* Add CG error tolerance and fix units on getCharges() return value

* Initial implementation of matrix solver

* Fixes and conjugate gradient solver

* Try to fix Linux and Windows builds

* Make sure charge constraint target is on total charge

* Restore handling of exceptions like NonbondedForce since they won't involve electrode atoms

* Ameliorate numerical instability in constrained conjugate gradient

* Fix uninitialized pointers, memory leak, and style

* Set CG tolerance units in Python API

* Test ConstantPotentialForce serialization

* Read/write ExceptionsUsePeriodicBoundaryConditions as bool

* Improve constrained conjugate gradient robustness to roundoff error accumulation

* Recompute matrix if electrode atoms move due to setPositions()

* Tolerance is now in gradient (potential) units again

* Add neutralizing background correction

* Add Python API tests

* Fixes for CG and nonbonded exceptions

* Add initial tests checking against existing NonbondedForce behavior

* Expand test suite and fix some implementation issues

* Add additional tests using larger reference system

* Add Gaussian test

* Finish test against reference computation

* CPU platform implementation

* Fixes for compilation on some platforms

* Fixes for constant potential with AVX/AVX2

* Test linking CPU PME library to constant potential test directly

* Older SWIG versions don't support Python set to C++ set conversion

* Add user guide entry

* Increase speed of reference test

* Conditional building constant potential CPU test is unreliable

* Debugging

* Miscellaneous fixes and improvements for CI

* Cache charges so solver will not run if system and coordinates have not changed

* Preconditioner flag, stability, and automatic detection improvements

* Add GPU platform-specific constant potential kernel classes

* PME and device-host I/O changes to support constant potential

* Initial common constant potential implementation

* Constant potential fixes:

* Fix preconditioner PME position/charge save/restore logic

* Fix reduction synchronization in constant potential solver kernels

* Add double-float accumulation for conjugate gradient solver when
  double unsupported by hardware

* Improve conditioning of a test system, and make sure particles are in or
out of cutoff for consistency and ease of comparing between platforms

* Reorder guess charges for CG when atom reordering changes positions

* Remove PME queue for now

* Trying to debug optimized direct space derivative kernel

* Remove extraneous debugging lines

* Style updates; just make CPU preconditioner double precision

* Debugging updated optimized direct derivatives kernel for all but OpenCL CPU

* OpenCL CPU implementation of direct space derivatives, and cleanup

* Try to make test even shorter to not time out on CI

* Temporary - Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Remove debugging code and fix reduction synchronization

* Fix other reductions

* Debugging - are tests hanging or just slow on CI?

* Debugging

* Debugging

* Fix macro for case when double precision is available on hardware

* Remove changes for debugging again

* Try to improve matrix solver cache locality by uploading transpose

* Fixes for atom ordering and periodic images

* Can't rely on reorder listener for cell offset updates

* Test reducing number of contexts and timing for CI

* Debugging

* Remove timing code and revert debugging changes

* Matrix solver and plasma term optimizations

* Reduce CG solver kernel calls and downloads

* Don't read back convergence flag from global memory

* Update PME due to refactoring in master branch

* Faster matrix solver (1st step)

* Faster matrix solver for CUDA

* Faster matrix solver compatibility with non-CUDA platforms

* Matrix solver fixes

* Use warp shuffle reductions when possible

* Attempt to work around intermittent compiler crash in Intel CPU OpenCL

* Optimize CG solver kernel 1

* Rework CG solver so some kernels can use more than 1 block

* Don't run out of shared memory

* Asynchronously download convergence flag while clearing buffers

---------

Co-authored-by: Evan Pretti <pretti@sh03-17n15.int>
2025-09-12 13:55:50 -07:00
Emilio Gallicchio
3645e1eeb7 Variable distance-based displacements for ATMForce (#4776)
* Variable displacements based on particle positions

* set variable displacements when adding particles

* update documentation

* address compilation error in OpenMMFortranWrapper

* update python API tests

* fix stray 'and'

* addParticle() without arguments add a particle that is not displaced

* pack displacement particles into int4

* put back default displacement removed in error

* ATMForce interface with coordinate transformation objects

* revise variable displacement API

* documentation, formatting, serialization

* Fixed C and Fortran wrappers

* Fixed Python wrappers

* Fixed factory

* Sort files to ensure classes are listed in the correct order

* Converted APIUnits test to new ATMForce API

* write class name

* skip the documentation for forward declarations

* undo 9e91d0b since it does not fix the doc build

* remove temporary doc files for nested classes

* Clean away tabs

---------

Co-authored-by: Peter Eastman <peastman@stanford.edu>
2025-08-12 12:22:58 -07:00
Peter Eastman
2af004b652 Adaptive quantum thermal bath (#4995)
* Began implementing QTBIntegrator

* Adaptation and deconvolution

* Continuing reference implementation

* Continuing to implement QTBIntegrator

* Use common thread pool

* More tests, documentation, and threading

* Fix segfault

* Serialize adapted friction when creating a State

* Beginning of GPU implementation

* Added missing files

* Bug fixes

* Fixed inverse FFT

* Continuing GPU implementation

* Checkpointing

* Bug fixes

* Test cases run faster

* Changes needed for latest main branch

* Minor optimizations

* Documentation

* Fixed atom reordering

* Added parahydrogen test case

* Workaround for bug in Microsoft's compiler

* Added a Python test

* Normalize kernel in deconvolution

* Minor documentation improvements
2025-08-11 08:03:06 -07:00
Michael J. Schnieders
61a908cd1c Updates to AmoebaVdwForce, AmoebaGeneralizedKirkwoodForce and AmoebaWcaDispersionForce (#4647)
* Update the AMOEBA OpenMM API for vdW, GK and WCA

* Changes needed for the Corrigan et al Generalized Kirkwood model and minor changes to the vdW force to support CpHMD

* Add casts to real for uses of POW in GK; Pass force by reference within the WCA kernel

* Update swigInputConfig for Amoeba vdW and GK forces

* Update TestAPIUnits.testAmoebaVdwForce

* Set the units for getSolventDielectric and getSoluteDielectric to None

* Update default dispersion offset parameter for the AmoebaWcaDispersionForce

* Remove overloaded getParticleParameters and setParticleParameters from AmoebaGeneralizedKirkwoodForce

* Update the AmoebaWcaDispersionForce TestAPIUnits tests to reflect using the correct units for the C++ parameter default values; Update the alanine-dipeptide-amoeba-forces to reflect the updated GK model

* Move neck descreening constants into AmoebaGeneralizedKirkwoodForceImpl; set the default GK dielecticOffset to 0.09; set the default WCA shctd parameter to 0.82

* Fix Python test cases for WCA and GK

* Load AMOEBA/GK parameters into an array of float4

* Cleaned up the AmoebaGeneralizedKirkwoodForce based on feedback from Peter; the one case where backwards compatibility remains a challenge is application of the dielectric offset parameter - in the prior code this was only applied to the nonpolar cavity term, but not to calculation of Born radii; in this revision the dielectric offset is applied to BOTH the nonpolar cavity term and to calculation of Born radii. At this point I can't think of elegant way to maintain backwards compatibility that isn't confusing, nor does it make sense (at least to me) to only apply the concept of the dieletric offset to one aspect (i.e. only to nonpolar cavity or only to Born radii calculation) but not to both.

* Remove 'using std::vector' from AmoebaGeneralizedKirkwoodForceImpl.h; divide by 10 instead of multiplying by 0.1f in amoebaGk.cc

* Added a parameter called descreenOffset, which is applied during calculation of effective Born radii for GK. The parameter dielectricOffset is only used for the nonpolar cavity term consistent with its prior use. All tests in TestAmoebaGeneralizedKirkwoodForce.h are now backwards compatible with their behavior prior to this PR.

* Change two constants in amoebaGk.cc to single precision; Improved the documentation for getNeckConstants in AmoebaGeneralizedKirkwoodForceImpl.h

* Fix comment for setTanhRescaling in AmoebaGeneralizedKirkwoodForce.h, Fix comment for setTanhParameters in AmoebaReferenceGeneralizedKirkwoodForce.h; set the type of parameter GeneralizedKirkwoodTanhRescaling to bool in AmoebaGeneralizedKirkwoodForceProxy.cpp; In ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel return references of per particle parameters instead of copies; update AmoebaReferenceKernels.h method signatures for per particle parameters to return const vector references

* Minor tweaks to the documentation for the tanh rescaling flag

* Improve the comments for the get and setTanhParameters in AmoebaGeneralizedKirkwoodForce.h and AmoebaReferenceGeneralizedKirkwoodForce.h
2024-11-20 12:18:10 -08:00
Peter Eastman
d80ddda33b Faster algorithm for DrudeSCFIntegrator (#4354)
* Faster algorithm for DrudeSCFIntegrator

* Minor code simplification

* Reduced default error tolerance

* Fixed errors on NVIDIA
2023-12-14 19:55:56 -08:00
Peter Eastman
43f571d90f Fixes to Python API for ATMForce (#4319) 2023-11-16 15:15:40 -08:00
Peter Eastman
c36c76caa5 Fixed return type of getTabulatedFunction() (#3565) 2022-04-11 11:45:17 -07:00
Peter Eastman
f5eea2199f Max Drude distance defaults to 0.02 nm (#3508)
* Max Drude distance defaults to 0.2 nm

* Fixed incorrect number in docs

* Fixed a test case
2022-03-10 16:24:39 -08:00
Peter Eastman
1e42b8befa Replaced several AMOEBA bonded forces with custom forces (#3046)
* Replaced several AMOEBA bonded forces with custom forces

* Deleted obsolete AMOEBA forces

* Replaced AmoebaPiTorsionForce with custom force
2021-03-04 09:53:04 -08:00
Peter Eastman
e53bdc5eab Top level Python module is now "openmm" (#3000)
* Top level Python module is now "openmm"

* Updated module names in examples

* Updated module names in documentation

* Updated module in CI scripts

* Added deprecation warning
2021-02-01 09:40:37 -08:00
peastman
b4543a4633 Updated to latest values for physical constants (#2802)
* Updated to latest values for physical constants

* Updated documentation on physical constants

* Updated Python unit definitions

* Fixed constants in test case

* Added a comment
2020-08-18 10:53:24 -07:00
Peter Eastman
c2a049b089 Fixed errors 2020-07-16 13:22:00 -07:00
Andy Simmonett
9f46a7fc8e Add python interface tests 2019-11-01 12:18:31 -04:00
Andy Simmonett
b3be7aecfd Clean up NHC interface and fix bug in swig generator 2019-11-01 10:57:21 -04:00
peastman
c1e5ec2ff6 Add ability to enforce units on input arguments 2019-09-30 12:35:43 -07:00
Michael Schnieders
926e7b9ac1 Improve the performance of sending the AmoebaVdwLambda to Cuda using pinned host memory; Updated the AmoebaVdwForceProxy to version 3, and added backward compatibility to version 2; updated TestAPIUnits.py to handle the per particle lambda flag 2019-08-22 14:16:18 -05:00
Peter Eastman
c9fcabb5da More updates to dispersion PME 2017-01-26 14:18:25 -08:00
peastman
fce85f6d03 Fixed python API for DrudeLangevinIntegrator 2015-10-06 10:57:22 -07:00
Jason Swails
28423ca1af Fix units of returned dipoles and quadrupoles from AmoebaMultipoleForce.
Now that I have my head on straight, that is.
2015-10-01 15:11:23 -04:00
Jason Swails
e585fb6e2c Add a simple test for CustomIntegrator. 2015-09-29 00:40:20 -04:00
Jason Swails
8f1a60d4fa Add units to getters for DrudeForce and add a test case for it. 2015-09-29 00:40:19 -04:00
Jason Swails
c14055361e Add tests for BrownianIntegrator, AndersenThermostat, DrudeSCFIntegrator,
and DrudeLangevinIntegrator.
2015-09-29 00:40:19 -04:00
Jason Swails
7d0d0f43cc Add tests for VerletIntegrator, VariableVerletIntegrator, LangevinIntegrator,
and VariableLangevinIntegrator
2015-09-29 00:40:19 -04:00
Jason Swails
ad98f7648a Add units to AmoebaMultipoleForce.getMultipoleParameters (check that these are
right).  Add a test for AmoebaMultipoleForce.
2015-09-29 00:40:19 -04:00
Jason Swails
3e42a37290 - Update/finish Torsion-Torsion test
- Remove API change for AmoebaAngleForce so it goes back to only taking degrees.
  Handle conversion via a pythonprepend (since stripUnits is done in C++ now).
- Do the same thing for TorsionTorsionForce, since angles are in degrees again
- Add AmoebaVdwForce and AmoebaWcaForce tests
2015-09-29 00:40:19 -04:00
Jason Swails
f7e4653a34 Add a test for AmoebaTorsionTorsionForce that fails because stripUnits doesn't
work for the input variable type.
2015-09-29 00:40:18 -04:00
Jason Swails
ed3e8a110e Correct the returned units for StretchBendForce and add unit tests for it. 2015-09-29 00:40:18 -04:00
Jason Swails
df20dcacde Get the out of plane bend taylor coefficient units sorted out. 2015-09-29 00:40:18 -04:00
Jason Swails
1644cc458a Try to add tests for AmoebaOutOfPlaneBendForce. The units added to the
cubic/quartic/pentic/etc. terms are NOT working for some reason.
2015-09-29 00:40:18 -04:00
Jason Swails
751518909f Add tests for AmoebaInPlaneAngleForce and add return units to the Taylor
expansion coefficients.
2015-09-29 00:40:18 -04:00
Jason Swails
792b89eea7 Make return units for AmoebaGeneralizedKirkwoodForce consistent with what the
docstring says it should be (kJ/nm^2) -- the swig input generator had the
inverse.

Adds a test case for the AmoebaGeneralizedKirkwoodForce API.
2015-09-29 00:40:18 -04:00
Jason Swails
6281f23fc4 Add a test for AmoebaAngleForce. There's a problem here, though, since the input
angles are in degrees (unlike *every* other angle force out there), and
stripUnits automatically reduces all angles to radians if they come in with
units.

The approach here is to *slightly* change the API, so that
AmoebaAngleForce.addAngle interprets input angles <2*pi as radians, and >2*pi as
degrees. This is heuristic, but should work in every case out in the wild so
far.

I've also updated the documentation to reflect this behavior, and fixed the
units attached to the return value of AmoebaAngleForce.getAngleParameters() to
return degrees instead of radians.
2015-09-29 00:40:17 -04:00
Jason Swails
9e800ced94 Add units to the returned bond cubic and quartic terms and add tests for
AmoebaBondForce.
2015-09-29 00:40:17 -04:00
Jason Swails
d04154b4fd Add API tests for all of the Custom*Forces.
Turns out CustomManyParticleForce is broken when adding per-particle parameters
with units.
2015-09-29 00:40:17 -04:00
Jason Swails
f2301d3416 Add test for CMAPTorsionForce 2015-09-29 00:40:17 -04:00
Jason Swails
a2c6e62860 Add a set of unit tests for unit handling in the core API. 2015-09-29 00:40:17 -04:00