552 Commits

Author SHA1 Message Date
Peter Eastman
fc21fd1923 Compile correctly under newer C++ standards (#5296) 2026-05-27 11:01:05 -07:00
Peter Eastman
c6f9fab280 More barostats support scaling particles independently (#5278)
* More barostats support scaling particles independently

* Documentation update

* MonteCarloMembraneBarostat can scale particles independently
2026-05-26 07:37:26 -07:00
Peter Eastman
9aae4bb35c PythonForce can be restricted to a subset of particles (#5246)
* PythonForce can be restricted to a subset of particles

* Fix exception with CUDA
2026-04-06 14:11:45 -07:00
Peter Eastman
a157923823 Improved documentation on CMMotionRemover (#5219) 2026-02-24 09:14:45 -08:00
Evan Pretti
4ab645ea69 GPU implementation of L-BFGS (#5198)
* Make reference/CPU minimizer into a kernel

* Add per-platform support for GPU minimization

* Initial implementation of GPU minimization

* Fixes

* Increase robustness when initial gradient is huge

* Handle overflow leading to non-finite values gracefully

* Handle large forces in single precision more robustly

* Optimize kernels

* Fix kernel launch size

* Update banner years

* Don't create MinimizeKernel until first minimization requested

* Make some compile-time constants into kernel arguments

* Consolidate scale calculation kernel

* Condense alpha/beta reduction kernels using atomics

* Condense line search dot kernels with reductions

* Remove a download, and download grad norm separately

* Asynchronously check lbfgs convergence condition

* Restructure line search to avoid download waiting

* Start line search preemptively in case CPU evaluation is not needed

* In rare cases, constraint error might not decrease after one optimization round

* Better handling of unsupported 64-bit atomics, use FLT_MAX

* Pick gradient mode based on GPU vs. CPU evaluation

* Rework getDiff/getScale reduction, remove reduceBuffer

* Older CUDA might not like float hex literals

* Fix error in a comment
2026-02-10 09:22:10 -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
2fbed59258 Created PythonForce (#5122)
* Initial implementation of PythonForce

* Continuing implementation of PythonForce

* Tests for PythonForce

* Fix memory leaks

* Documentation for PythonForce

* Fixed incorrect return type

* Fix compilation error on Python older than 3.12

* Handle all dtypes

* Optimizations to PythonForce

* Optimized getPositions()

* Test all platforms

* Fix test failures
2025-11-12 09:14:19 -08:00
Peter Eastman
c24c619e4f Code cleanup (#5127) 2025-11-06 12:04:52 -08:00
Evan Pretti
05472c9a81 Update file headers (#5074)
* Replace SimTK-containing file headers

* Update file headers for new Tinker reader files added
2025-09-23 10:27:26 -07:00
Evan Pretti
0a5be952ce Update constant potential entry in user guide (#5073)
* Add note about polarizable force fields with constant potential

* Add notes about CG preconditioner
2025-09-17 09:48:12 -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
Peter Eastman
b4507392ff Drude integrators can find DrudeForce inside another force (#5054) 2025-08-29 09:11:58 -07:00
Peter Eastman
54fa65ed0d Created OrientationRestraintForce (#5048)
* Created OrientationRestraintForce

* Python API

* Documentation

* Serialization

* GPU implementation of OrientationRestraintForce

* Bug fix

* Remove unused code
2025-08-26 11:44:32 -07:00
Peter Eastman
1b6236a8cc Radius of gyration force (#5031)
* Reference implementation of RGForce

* GPU implementation of RGForce

* Serialization

* Documentation

* Fix compilation error

* Fixed error building API docs
2025-08-14 08:26:25 -07:00
Peter Eastman
6e2f213fa7 Replace C++ code examples in Python API docs (#5043)
* Replace C++ code examples in Python API docs

* Use newer Python for building docs

* Remove sphinx version pin

* Add Python versions of code examples

* Minor edit

* Add Python version of one more code example
2025-08-13 15:02:25 -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
Peter Eastman
bb3073d4f3 Virtual site for symmetric molecules (#4185)
* Reference implementation of SymmetrySite

* Common implementation of SymmetrySite

* Removed duplicated code

* Serialization for SymmetrySite

* Fixed compilation error building C wrapper

* Added SymmetrySite to user guide

* Bug fix

* Added P21 test case
2025-07-23 16:25:28 -07:00
Yannick Lemke
2abeb80165 fix(openmmapi): move getNum...() definitions to implementation files (#5009)
Fixes #5001.

Signed-off-by: Yannick Lemke <yannick.lemke@posteo.de>
2025-07-15 14:10:33 -07:00
Peter Eastman
baf7942c74 Created CustomVolumeForce (#4902)
* Created CustomVolumeForce

* Serialization for CustomVolumeForce

* Documentation for CustomVolumeForce

* Code simplification

* Removed unused code
2025-04-28 11:43:40 -07:00
Peter Eastman
bce0c133e0 Added computeCurrentPressure() to MonteCarloBarostat (#4881)
* Added computeCurrentPressure() to MonteCarloBarostat

* Use instantaneous temperature to compute pressure

* Added computeCurrentPressure() to MonteCarloAnisotropicBarostat

* Added computeCurrentPressure() to MonteCarloMembraneBarostat

* Fixed compilation error

* Fixed error in typemap

* Added documentation on computing pressure

* Fixed CUDA compilation errors

* Made test case more robust

* Made a test case more robust

* Added computeCurrentPressure() to MonteCarloFlexibleBarostat

* Fixed compilation error

* More documentation on computing pressure
2025-04-28 11:42:43 -07:00
Peter Eastman
de180e4e94 DPDIntegrator (#4799)
* Created DPDIntegrator class

* Reference implementation of DPDIntegrator

* Build neighbor list for DPDIntegrator

* Minor fixes

* Documentation for DPDIntegrator

* Python API for DPDIntegrator

* Preliminary OpenCL implementation of DPDIntegrator

* Enable USE_PERIODIC

* Use updated positions in DPD thermostat

* Working on neighbor list for OpenCL DPDIntegrator

* ReorderListener for particle types

* Serialization for DPDIntegrator

* CUDA implementation of DPDIntegrator

* HIP implementation of DPDIntegrator

* Fixed compile error in Python wrapper

* Fixed compile error in wrappers

* Fixed uninitialized memory in reference neighbor list

* Added DPDIntegrator to C++ API docs

* Fixed incorrect launch size

* Fixed nan in DPD random number generator

* Minor optimizations

* Improved load balancing

* Fixed an indexing error

* Neighbor list uses the maximum cutoff of any force

* Fixed HIP compilation error

* Fixed access to invalid memory

* Added test case for diffusion coefficient

* Try to debug segfaults on CI

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Possible fix

* Debugging

* Debugging

* Debugging

* Use correct block size on CPU OpenCL

* Workaround for bug in Intel's OpenCL for CPUs

* Removed an unnecessary define

* Removed debugging code

* Include Dart

* More Intel workarounds

* Workaround for error in NVIDIA OpenCL
2025-04-14 08:44:16 -07:00
Peter Eastman
68c97c5bfc Replace pthreads with C++ threads (#4833)
* Replace pthreads with C++ threads

* Try to fix CI errors

* Try including -pthread linker option
2025-03-10 11:58:37 -07:00
Peter Eastman
d7307530a0 Serialization records integration force groups (#4734) 2024-11-25 08:49:50 -08:00
Peter Eastman
ecbe32b026 updateParametersInContext() can modify parameter offsets (#4732)
* updateParametersInContext() can modify parameter offsets

* Reordering respects parameter offsets

* Implemented for CUDA and HIP
2024-11-22 07:59:35 -08:00
Peter Eastman
78902bed7e Optimize updateParametersInContext() (#4610)
* Optimize CustomNonbondedForce.updateParametersInContext()

* Optimized uploading changed values to GPU

* Optimized updateParametersInContext() for lots of bonded forces

* Optimized updateParametersInContext() for CustomExternalForce

* Optimized updateParametersInContext() for NonbondedForce

* Code changes for HIP platform
2024-09-06 09:34:11 -07:00
ZangRuochen
af229eb4d6 Add LoongArch architecture LSX support. (#4467)
LoongArch is a new architecture, already supported by linux-6.1, gcc-12.

Signed-off-by: Zang Ruochen <zangruochen@loongson.cn>
Co-authored-by: Zang Ruochen <zangruochen@loongson.cn>
2024-03-08 10:57:33 -08:00
Peter Eastman
faee23a23d vectorize_portable.h works on gcc (#4466) 2024-03-07 21:26:28 -08:00
Peter Eastman
86988b90b8 Use LF-Middle for LangevinIntegrator and VariableLangevinIntegrator (#4440)
* Made LangevinIntegrator identical to LangevinMiddleIntegrator

* Removed unused code

* VariableLangevinIntegrator uses LFMiddle
2024-02-16 16:01:45 -08:00
Peter Eastman
4717c840e7 Use portable SIMD vectors as a backup (#4328)
* Use portable SIMD vectors as a backup

* Remove old file

* Try to fix compilation error on Windows
2023-12-12 07:53:02 -08:00
Peter Eastman
31abb2f7a3 Fixed some incorrect comments (#4294)
* Fixed some incorrect comments

* Fixed some incorrect comments

* Fixed typo
2023-11-02 15:28:44 -07:00
Peter Eastman
726544fa59 Clarified documentation on virtual sites (#4292) 2023-11-01 15:20:29 -07:00
Peter Eastman
47496e3ceb Fixed errors in generating Python docstrings (#4290) 2023-11-01 13:59:43 -07:00
Matt Thompson
7a5c9736b2 Note that w_cross has units of inverse distance (#4263)
* Note that w_cross has units of inverse distance

* Grammar
2023-10-11 13:40:05 -07:00
Peter Eastman
b247e7d8cf Report status during minimization (#4207)
* Implemented MinimizationReporter

* PythonAPI for MinimizationReporter

* Improved test case

* SWIG fix

* Reporter returns a bool instead of throwing an exception
2023-09-19 15:43:53 -07:00
Peter Eastman
9a0db72533 CustomCPPForceImpl for writing forces in C++ (#4231)
* Implemented CustomCPPForceImpl

* Documentation for CustomCPPForceImpl

* Attempt at fixing Windows compilation error

* Improved documentation
2023-09-15 18:40:19 -07:00
Peter Eastman
065e34ab56 Optimized Context creation with complex CustomIntegrators (#4191) 2023-08-16 16:32:16 -07:00
Emilio Gallicchio
d8c6769914 Draft integration of the Alchemical Transfer Method (ATM) plugin (#4110)
* Draft integration of the Alchemical Transfer Method (ATM) plugin

* Attempt to store and retrieve forces--does not compile

* Implement addForce()/getForce() methods

* Throw exception when specifying properties without a Platform (#4130)

* Fixed DOF calculation for NoseHooverIntegrator (#4128)

* Fix variance in documentation of VerletIntegrator (#4138)

* Python API for ATMForce

* Fixed compilation error

* Minor cleanup of formatting and documentation

* Files for ATMForce test cases

* More cleanup

* Removed variable groups

* Test ATMForce with two particles

* More tests for ATMForce plus fixes

* Added missing header

* Rework interface to pass displacements as vector of parameters

* Revert "Rework interface to pass displacements as vector of parameters"

This reverts commit 5e092031f3.

* Test with nonbonded force

* Allow energy expression to be customized

* Optional displacements at the initial state

* Fixed compilation error build C wrapper

* Address edge case of default energy expression

* Consistent naming of the variables of the displacement states

* Test of soft core function of the default energy expression

* Mark addForce() as taking ownership

* initial python test for ATMForce

* Test custom expressions

* Expanded C++ API documentation for ATMForce

* Energy parameter derivatives

* Serialization for ATMForce

* Documentation, cleanup, and fixes

* Fixed typos

* getPerturbationEnergy() computes energy

* Another test case

* Minor edits

---------

Co-authored-by: Peter Eastman <peastman@stanford.edu>
Co-authored-by: Michael Plainer <plainer@ymail.com>
2023-08-02 14:55:56 -07:00
Peter Eastman
7af565ed09 Use more efficient version of updateContextState() (#4054) 2023-04-27 15:08:22 -07:00
Peter Eastman
3c7eef3d07 Check units for LocalEnergyMinimizer.minimize() (#4035) 2023-04-18 13:54:17 -07:00
Peter Eastman
4a26bca442 Ignore changes to force group after context creation (#4029) 2023-04-12 13:49:31 -07:00
Peter Eastman
ae34183149 CustomCVForce avoids breaking up molecules (#3711) 2022-07-25 21:00:57 -07:00
Peter Eastman
8292bb3ab5 Reduced the cost of updating tabulated functions (#3649) 2022-06-21 13:09:50 -07:00
Peter Eastman
c3c8ec55e8 Vectorized calculating long range correction coefficient (#3606) 2022-05-19 07:43:38 -07:00
Peter Eastman
fb03606048 Added FAQ links to error messages (#3600)
* Added FAQ links to error messages

* Added missing Windows export
2022-05-11 08:15:31 -07:00
Peter Eastman
0eb5bc0e1c Made getCollectiveVariableValues() const (#3599) 2022-05-09 16:48:43 -07:00
Peter Eastman
c8981916e7 Vectorized CpuCustomNonbondedForce (#3568)
* Began vectorizing CustomNonbondedForce

* Refactored CpuCustomNonbondedForce to support multiple vector sizes

* AVX implementation of CpuCustomNonbondedForce

* Fixed compilation errors
2022-04-14 12:28:51 -07:00
Peter Eastman
4479ffae77 Fixed minor error in documentation (#3559) 2022-04-08 15:22:54 -07:00
Peter Eastman
99a9fdc926 Improvements to vectorization on ARM (#3555) 2022-04-08 09:05:17 -07:00
Peter Eastman
a5e42f5728 Improved temperature reporting for Drude particles (#3486)
* DrudeLangevinIntegrator has getSystemTemperature()

* DrudeNoseHooverIntegrator has getSystemTemperature()

* StateDataReporter reports system temperature for Drude systems

* Fixed incorrect return type
2022-03-01 10:34:05 -08:00