diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index faa8e3e26..3118ee625 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -51,7 +51,11 @@ jobs: exit 1 fi - - name: Build and test library (GCC) + - name: Build and test library (Clang) + env: + CMAKE_BUILD_DIR: build + CXX: clang++ + CC: clang run: cmake -P devel-tools/build_test_library.cmake - name: Check documentation of command-line scripting interface @@ -64,11 +68,11 @@ jobs: exit 1 fi - - name: Build and test library (Clang) + - name: Build and test library (GCC) env: - CMAKE_BUILD_DIR: build-clang - CXX: clang++ - CC: clang + CMAKE_BUILD_DIR: build-gcc + CXX: g++ + CC: gcc run: cmake -P devel-tools/build_test_library.cmake - name: Build library with debug code enabled (GCC) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 913d4bce2..8d004786b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -14,10 +14,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) if(NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -else() - if(${CMAKE_CXX_STANDARD} STREQUAL "98") - message(FATAL_ERROR "CMAKE_CXX_STANDARD must be 11 or later") - endif() endif() option(WARNINGS_ARE_ERRORS "Treats warnings as errors" OFF) @@ -88,11 +84,10 @@ option(COLVARS_OPENMP "Build Colvars with (still limited) OpenMP support" ${COLV if(COLVARS_OPENMP) find_package(OpenMP) if(OpenMP_CXX_FOUND) - target_link_libraries(colvars OpenMP::OpenMP_CXX) + target_link_libraries(colvars PRIVATE OpenMP::OpenMP_CXX) endif() endif() - include(buildColvarsLepton) @@ -137,13 +132,35 @@ if(COLVARS_TCL) else() target_compile_options(colvars PRIVATE -DCOLVARS_TCL) endif() - target_link_libraries(colvars ${TCL_LIBRARY}) + target_link_libraries(colvars PUBLIC ${TCL_LIBRARY}) +endif() + +option(COLVARS_TORCH "Link against the Torch library" OFF) + +if(COLVARS_TORCH) + if (CMAKE_CXX_STANDARD LESS 17) + message(STATUS "Increase the CMAKE_CXX_STANDARD to 17") + set_property(TARGET colvars PROPERTY CXX_STANDARD 17) + else() + message(STATUS "Keep the CMAKE_CXX_STANDARD as ${CMAKE_CXX_STANDARD}") + endif() + if(DEFINED LIBTORCH_PREFIX) + find_package(Torch REQUIRED PATHS file(JOIN ${LIBTORCH_PREFIX} "share/cmake/Torch")) + else() + find_package(Torch REQUIRED) + endif() + if(Torch_FOUND) + target_compile_definitions(colvars PRIVATE -DCOLVARS_TORCH) + target_compile_options(colvars PRIVATE ${TORCH_CXX_FLAGS}) + target_include_directories(colvars PRIVATE ${TORCH_INCLUDE_DIRS}) + target_link_libraries(colvars PUBLIC ${TORCH_LIBRARIES}) + endif() endif() option(BUILD_TOOLS "Build standalone tools" ON) option(BUILD_TESTS "Build tests" ON) - + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # TODO fix linkage errors with Visual Studio... set(BUILD_TOOLS OFF) diff --git a/cmake/buildColvarsLepton.cmake b/cmake/buildColvarsLepton.cmake index fe8d72670..70977ff1b 100644 --- a/cmake/buildColvarsLepton.cmake +++ b/cmake/buildColvarsLepton.cmake @@ -18,7 +18,7 @@ if(COLVARS_LEPTON) target_compile_options(colvars PRIVATE -DLEPTON) endif() target_include_directories(colvars PRIVATE ${LEPTON_DIR}/include) - target_link_libraries(colvars lepton) + target_link_libraries(colvars PRIVATE lepton) # Silence warnings for Lepton target_compile_options(lepton PRIVATE $<$:-Wno-tautological-undefined-compare -Wno-unknown-warning-option>) diff --git a/cmake/buildColvarsTests.cmake b/cmake/buildColvarsTests.cmake index cb18b87b4..b5e3ad52e 100644 --- a/cmake/buildColvarsTests.cmake +++ b/cmake/buildColvarsTests.cmake @@ -15,6 +15,11 @@ if(BUILD_TESTS) # Copy the Colvars configuration files file(GLOB TEST_CONFIG_FILES ${COLVARS_SOURCE_DIR}/tests/input_files/*/test.in) + if(NOT COLVARS_TORCH) + # TODO create a way to detect test dependencies at some point + list(REMOVE_ITEM TEST_CONFIG_FILES ${COLVARS_SOURCE_DIR}/tests/input_files/torchann-dihedral_harmonic-fixed/test.in) + endif() + foreach(TEST_CONFIG_FILE ${TEST_CONFIG_FILES}) get_filename_component(TEST_NAME ${TEST_CONFIG_FILE} DIRECTORY) get_filename_component(TEST_NAME ${TEST_NAME} NAME) diff --git a/devel-tools/build_test_library.cmake b/devel-tools/build_test_library.cmake index 7f2d9f7af..7b87043d7 100644 --- a/devel-tools/build_test_library.cmake +++ b/devel-tools/build_test_library.cmake @@ -7,13 +7,19 @@ else() get_filename_component(COLVARS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) endif() -set(COLVARS_LEPTON ON) +if(EXISTS "/opt/libtorch") + if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) + endif() + if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 17) + message("Enabling Torch interface, using library at /opt/libtorch") + set(DEFINE_TORCH "-DCOLVARS_TORCH=ON") + set(DEFINE_TORCH_PREFIX "-DLIBTORCH_PREFIX=/opt/libtorch") + endif() +endif() + if(NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) -else() - if(${CMAKE_CXX_STANDARD} GREATER 70) - set(COLVARS_LEPTON OFF) - endif() endif() if(NOT DEFINED BUILD_SHARED_LIBS) @@ -54,6 +60,8 @@ if(COLVARS_TCL AND DEFINED TCL_DIR) endif() +set(COLVARS_LEPTON ON) + if(COLVARS_LEPTON) if(NOT DEFINED LEPTON_DIR) set(LEPTON_DIR "${COLVARS_SOURCE_DIR}/openmm-source/libraries/lepton") @@ -82,8 +90,27 @@ else() endif() if(DEFINED ENV{CCACHE}) - set(DEFINE_CC_CCACHE "-DCMAKE_C_COMPILER_LAUNCHER=$ENV{CCACHE}") - set(DEFINE_CXX_CCACHE "-DCMAKE_CXX_COMPILER_LAUNCHER=$ENV{CCACHE}") + set(CCACHE $ENV{CCACHE}) +else() + find_program(CCACHE "ccache") + if(CCACHE) + set(CCACHE "ccache") + endif() +endif() + +if(NOT ${CCACHE} STREQUAL "CCACHE-NOTFOUND") + message(STATUS "Using ${CCACHE} as the compiler launcher") + set(DEFINE_CC_CCACHE "-DCMAKE_C_COMPILER_LAUNCHER=${CCACHE}") + set(DEFINE_CXX_CCACHE "-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE}") +endif() + +if(NOT DEFINED ENV{CXX}) + # Use Clang if available to catch more errors + find_program(CLANG "clang++") + if(CLANG) + message(STATUS "Clang is available, using it as the default compiler") + set(DEFINE_CXX_COMPILER "-DCMAKE_CXX_COMPILER=clang++") + endif() endif() execute_process( @@ -96,13 +123,18 @@ execute_process( -D WARNINGS_ARE_ERRORS=ON -D CMAKE_VERBOSE_MAKEFILE=ON -D CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + ${DEFINE_CXX_COMPILER} ${DEFINE_CC_CCACHE} ${DEFINE_CXX_CCACHE} + ${DEFINE_PYTHON} -D COLVARS_TCL=${COLVARS_TCL} ${DEFINE_TCL_DIR} ${DEFINE_TCL_LIBRARY} + ${DEFINE_TORCH} + ${DEFINE_TORCH_PREFIX} -D COLVARS_LEPTON=${COLVARS_LEPTON} -D LEPTON_DIR=${LEPTON_DIR} + -D CMAKE_PREFIX_PATH="/opt/libtorch/share/cmake" RESULT_VARIABLE result ) diff --git a/devel-tools/compile-gromacs.sh b/devel-tools/compile-gromacs.sh index 954ff362e..e95ead5aa 100755 --- a/devel-tools/compile-gromacs.sh +++ b/devel-tools/compile-gromacs.sh @@ -69,6 +69,10 @@ compile_gromacs_target() { fi fi + if [ -d "/opt/libtorch" ] ; then + GMX_BUILD_OPTS+=(-DGMX_NNPOT=TORCH -DTorch_DIR=/opt/libtorch/share/cmake/Torch) + fi + # When on GitHub Actions, build the tests as well if [ -n "${GITHUB_ACTION}" ] ; then export GROMACS_BUILD_TESTS=1 diff --git a/doc/colvars-code-refs.bib b/doc/colvars-code-refs.bib index 5f2fe9075..efda6d9c1 100644 --- a/doc/colvars-code-refs.bib +++ b/doc/colvars-code-refs.bib @@ -389,5 +389,6 @@ @article{Invernizzi2022 % coordNum pairlist % Custom functions (Lepton) % Scripted functions (Tcl) +% torchANN colvar component % ABMD bias % --- END --- diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.out b/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.out new file mode 100644 index 000000000..94e348144 --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.out @@ -0,0 +1,229 @@ +colvars: ---------------------------------------------------------------------- +colvars: Please cite Fiorin et al, Mol Phys 2013: +colvars: https://doi.org/10.1080/00268976.2013.813594 +colvars: as well as all other papers listed below for individual features used. +colvars: This version was built with the C++11 standard or higher. +colvars: Summary of compile-time features available in this build: +colvars: - SMP parallelism: enabled (num. threads = 2) +colvars: - Multiple replicas: not available +colvars: - Lepton custom functions: available +colvars: - Tcl interpreter: not available +colvars: ---------------------------------------------------------------------- +colvars: Start colvars Initialization. +colvars: ---------------------------------------------------------------------- +colvars: Reading new configuration: +colvars: # units = "" [default] +colvars: # indexFile = "index.ndx" +colvars: The following index groups are currently defined: +colvars: Protein (104 atoms) +colvars: Protein_noH (51 atoms) +colvars: Protein_Backbone (40 atoms) +colvars: Protein_C-alpha (10 atoms) +colvars: RMSD_atoms (10 atoms) +colvars: Protein_C-alpha_1_2 (2 atoms) +colvars: Protein_C-alpha_9_10 (2 atoms) +colvars: Protein_C-alpha_1 (1 atoms) +colvars: group1 (4 atoms) +colvars: Protein_C-alpha_2 (1 atoms) +colvars: group2 (4 atoms) +colvars: Protein_C-alpha_3 (1 atoms) +colvars: group3 (4 atoms) +colvars: Protein_C-alpha_4 (1 atoms) +colvars: group4 (4 atoms) +colvars: Protein_C-alpha_5 (1 atoms) +colvars: group5 (4 atoms) +colvars: Protein_C-alpha_6 (1 atoms) +colvars: group6 (4 atoms) +colvars: Protein_C-alpha_7 (1 atoms) +colvars: group7 (4 atoms) +colvars: Protein_C-alpha_8 (1 atoms) +colvars: group8 (4 atoms) +colvars: Protein_C-alpha_9 (1 atoms) +colvars: group9 (4 atoms) +colvars: Protein_C-alpha_10 (1 atoms) +colvars: group10 (4 atoms) +colvars: heavy_atoms (51 atoms) +colvars: prot_N (10 atoms) +colvars: prot_CA (10 atoms) +colvars: prot_C (10 atoms) +colvars: prot_O (10 atoms) +colvars: # smp = on [default] +colvars: # colvarsTrajFrequency = 1 +colvars: # colvarsRestartFrequency = 10 +colvars: # scriptedColvarForces = off [default] +colvars: # scriptingAfterBiases = off [default] +colvars: # defaultInputStateFile = "" [default] +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new collective variable. +colvars: # name = "nn_0" +colvars: Initializing a new "torchANN" component. +colvars: Warning: cannot cite unknown feature "torchANN colvar component (derived from linearCombination)" +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 360 +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 360 [default] +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: Initializing atom group "group1". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group1" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group1" defined with 4 atoms requested: total mass = 54.028, total charge = -0.72. +colvars: Initializing atom group "group2". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group2" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group2" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group3". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group3" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group3" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group4". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group4" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group4" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: # oneSiteSystemForce = off [default] +colvars: # oneSiteTotalForce = off [default] +colvars: # modelFile = "identity.pt" +colvars: torch model loaded. +colvars: # m_output_index = 0 +colvars: # doubleInputTensor = on +colvars: Input dimension of model: 1 +colvars: Model's dtype: kFloat64. +colvars: Evaluating model with zero tensor succeeded. +colvars: All components initialized. +colvars: # timeStepFactor = 1 [default] +colvars: # width = 5 +colvars: # lowerBoundary = -180 +colvars: # upperBoundary = 180 +colvars: # hardLowerBoundary = off [default] +colvars: # hardUpperBoundary = off [default] +colvars: # expandBoundaries = off [default] +colvars: # extendedLagrangian = on +colvars: Enabling the extended Lagrangian term for colvar "nn_0". +colvars: # extendedTemp = 300 +colvars: # extendedFluctuation = 5 +colvars: Computed extended system force constant: 0.0997735 [E]/U^2 +colvars: # extendedTimeConstant = 200 +colvars: Computed fictitious mass: 101.092 [E]/(U/fs)^2 (U: colvar unit) +colvars: # outputEnergy = off [default] +colvars: # extendedLangevinDamping = 0 +colvars: # reflectingLowerBoundary = off [default] +colvars: # reflectingUpperBoundary = off [default] +colvars: # outputValue = on [default] +colvars: # outputVelocity = on +colvars: # outputTotalForce = on +colvars: # outputAppliedForce = on +colvars: # subtractAppliedForce = off [default] +colvars: # runAve = off [default] +colvars: # corrFunc = off [default] +colvars: ---------------------------------------------------------------------- +colvars: Collective variables initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new "abf" instance. +colvars: # name = "abf1" [default] +colvars: # colvars = { nn_0 } +colvars: # stepZeroData = off [default] +colvars: # outputEnergy = off [default] +colvars: # outputFreq = 10 [default] +colvars: # timeStepFactor = 1 [default] +colvars: # applyBias = on [default] +colvars: # hideJacobian = off [default] +colvars: Jacobian (geometric) forces will be included in reported free energy gradients. +colvars: # fullSamples = 0 +colvars: # minSamples = 0 [default] +colvars: # inputPrefix = [default] +colvars: # historyFreq = 0 [default] +colvars: # shared = off [default] +colvars: # updateBias = on [default] +colvars: # maxForce = [default] +colvars: # CZARestimator = on [default] +colvars: # integrate = on [default] +colvars: # UIestimator = off [default] +colvars: Finished ABF setup. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables biases initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables module (re)initialized. +colvars: ---------------------------------------------------------------------- +colvars: Current simulation parameters: initial step = 0, integration timestep = 1 +colvars: Updating atomic parameters (masses, charges, etc). +colvars: Re-initialized atom group for variable "nn_0":0/0. 4 atoms: total mass = 54.028, total charge = -0.72. +colvars: Re-initialized atom group for variable "nn_0":0/1. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/2. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/3. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: +colvars: SUMMARY OF COLVARS FEATURES USED SO FAR AND THEIR CITATIONS: +colvars: +colvars: - GROMACS engine: +colvars: Abraham2015 https://doi.org/10.1016/j.softx.2015.06.001 +colvars: +colvars: - Colvars module: +colvars: - Optimal rotation via flexible fitting: +colvars: - dihedral colvar component: +colvars: Fiorin2013 https://doi.org/10.1080/00268976.2013.813594 +colvars: +colvars: - ABF colvar bias implementation: +colvars: Henin2010 https://doi.org/10.1021/ct9004432 +colvars: +colvars: - CZAR eABF estimator: +colvars: - eABF implementation: +colvars: Lesage2017 https://doi.org/10.1021/acs.jpcb.6b10055 +colvars: +colvars: - Colvars-GROMACS interface: +colvars: - linearCombination colvar component: +colvars: n/a +colvars: +colvars: The final output state file will be "test.colvars.state". +colvars: ---------------------------------------------------------------------- +colvars: End colvars Initialization. +colvars: +colvars: Initializing extended coordinate to colvar value. +colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj". +colvars: Saving collective variables state to "test.colvars.state". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj". +colvars: Saving collective variables state to "test.colvars.state". +colvars: Saving collective variables state to "test.colvars.state". diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.state.stripped b/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.state.stripped new file mode 100644 index 000000000..f2ef68528 --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.state.stripped @@ -0,0 +1,64 @@ +configuration { + step 20 + dt 1.000000e+00 +} + +colvar { + name nn_0 + x 60.355698290262 + v -0.015706917477928 + extended_x 63.006623393842 + extended_v -0.015706917477928 +} + +abf { + configuration { + step 20 + name abf1 + } + +samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 20 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +gradient + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0.12886246736985 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +z_samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 20 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +z_gradient + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0.12886246736985 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 +} + diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.traj b/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.traj new file mode 100644 index 000000000..4f93f046b --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.colvars.traj @@ -0,0 +1,22 @@ +# step nn_0 r_nn_0 v_nn_0 vr_nn_0 ft_nn_0 fa_nn_0 + 0 6.31129742229546e+01 6.31129742229546e+01 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 1 6.30691874446969e+01 6.31129742229546e+01 -4.37867782576902e-02 0.00000000000000e+00 -4.36876209965603e-03 0.00000000000000e+00 + 2 6.30026268509518e+01 6.31129310071366e+01 -6.65605937450664e-02 -4.32158179401623e-05 -8.82105566302571e-03 2.18438104982801e-03 + 3 6.29122391970703e+01 6.31128005333891e+01 -9.03876538815567e-02 -1.30473747504093e-04 -1.48859826170799e-02 5.12473293750325e-03 + 4 6.27980201916868e+01 6.31125228074224e+01 -1.14219005383504e-01 -2.77725966774810e-04 -2.25328123548414e-02 8.84622859177323e-03 + 5 6.26608705364834e+01 6.31120221867559e+01 -1.37149655203388e-01 -5.00620666507564e-04 -3.16602085077742e-02 1.33527910627415e-02 + 6 6.25028988465855e+01 6.31112083831383e+01 -1.57971689897870e-01 -8.13803617560741e-04 -4.20637065601368e-02 1.86294924807039e-02 + 7 6.23269353136299e+01 6.31099784851116e+01 -1.75963532955592e-01 -1.22989802671486e-03 -5.34883998455103e-02 2.46385934178663e-02 + 8 6.21367031137968e+01 6.31082194795489e+01 -1.90232199833119e-01 -1.75900556264962e-03 -6.56069886323548e-02 3.13246433985551e-02 + 9 6.19365098073803e+01 6.31058114893056e+01 -2.00193306416466e-01 -2.40799024335846e-03 -7.80510654118539e-02 3.86143088021500e-02 + 10 6.17311065289538e+01 6.31026314175078e+01 -2.05403278426502e-01 -3.18007179779695e-03 -9.04224851177263e-02 4.64194153433354e-02 + 11 6.15254648325149e+01 6.30985568860060e+01 -2.05641696438882e-01 -4.07453150180609e-03 -1.02313329839619e-01 5.46396412631287e-02 + 12 6.13246356643899e+01 6.30934702705009e+01 -2.00829168125033e-01 -5.08661550508676e-03 -1.13317147441039e-01 6.31657520830970e-02 + 13 6.11334444875817e+01 6.30872627211702e+01 -1.91191176808175e-01 -6.20754933064253e-03 -1.23056916109119e-01 7.18824557324077e-02 + 14 6.09563439770599e+01 6.30798378921705e+01 -1.77100510521797e-01 -7.42482899969757e-03 -1.31196280666724e-01 8.06722354544876e-02 + 15 6.07973256457293e+01 6.30711152688643e+01 -1.59018331330643e-01 -8.72262330627379e-03 -1.37445397573545e-01 8.94186541656025e-02 + 16 6.06596211125729e+01 6.30610330349537e+01 -1.37704533156388e-01 -1.00822339105498e-02 -1.41588389467531e-01 9.80089915139491e-02 + 17 6.05456409780450e+01 6.30495502079410e+01 -1.13980134527907e-01 -1.14828270126900e-02 -1.43486180419571e-01 1.06337720306157e-01 + 18 6.04567498377801e+01 6.30366480148680e+01 -8.88911402649413e-02 -1.29021930730277e-02 -1.43096412609170e-01 1.14309174773911e-01 + 19 6.03935912647340e+01 6.30223303113199e+01 -6.31585730460174e-02 -1.43177035481106e-02 -1.40438049172301e-01 1.21840564911235e-01 + 20 6.03556982902622e+01 6.30066233938419e+01 -3.78929744718022e-02 -1.57069174779283e-02 -1.35629728273974e-01 1.28862467369851e-01 diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.pmf b/gromacs/tests/library/000_torchann/AutoDiff/test.pmf new file mode 100644 index 000000000..07f23b719 --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.pmf @@ -0,0 +1,76 @@ +# 1 +# -1.82500000000000e+02 5.00000000000000e+00 73 0 + + -1.80000000000000e+02 0.00000000000000e+00 + -1.75000000000000e+02 0.00000000000000e+00 + -1.70000000000000e+02 0.00000000000000e+00 + -1.65000000000000e+02 0.00000000000000e+00 + -1.60000000000000e+02 0.00000000000000e+00 + -1.55000000000000e+02 0.00000000000000e+00 + -1.50000000000000e+02 0.00000000000000e+00 + -1.45000000000000e+02 0.00000000000000e+00 + -1.40000000000000e+02 0.00000000000000e+00 + -1.35000000000000e+02 0.00000000000000e+00 + -1.30000000000000e+02 0.00000000000000e+00 + -1.25000000000000e+02 0.00000000000000e+00 + -1.20000000000000e+02 0.00000000000000e+00 + -1.15000000000000e+02 0.00000000000000e+00 + -1.10000000000000e+02 0.00000000000000e+00 + -1.05000000000000e+02 0.00000000000000e+00 + -1.00000000000000e+02 0.00000000000000e+00 + -9.50000000000000e+01 0.00000000000000e+00 + -9.00000000000000e+01 0.00000000000000e+00 + -8.50000000000000e+01 0.00000000000000e+00 + -8.00000000000000e+01 0.00000000000000e+00 + -7.50000000000000e+01 0.00000000000000e+00 + -7.00000000000000e+01 0.00000000000000e+00 + -6.50000000000000e+01 0.00000000000000e+00 + -6.00000000000000e+01 0.00000000000000e+00 + -5.50000000000000e+01 0.00000000000000e+00 + -5.00000000000000e+01 0.00000000000000e+00 + -4.50000000000000e+01 0.00000000000000e+00 + -4.00000000000000e+01 0.00000000000000e+00 + -3.50000000000000e+01 0.00000000000000e+00 + -3.00000000000000e+01 0.00000000000000e+00 + -2.50000000000000e+01 0.00000000000000e+00 + -2.00000000000000e+01 0.00000000000000e+00 + -1.50000000000000e+01 0.00000000000000e+00 + -1.00000000000000e+01 0.00000000000000e+00 + -5.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 + 5.00000000000000e+00 0.00000000000000e+00 + 1.00000000000000e+01 0.00000000000000e+00 + 1.50000000000000e+01 0.00000000000000e+00 + 2.00000000000000e+01 0.00000000000000e+00 + 2.50000000000000e+01 0.00000000000000e+00 + 3.00000000000000e+01 0.00000000000000e+00 + 3.50000000000000e+01 0.00000000000000e+00 + 4.00000000000000e+01 0.00000000000000e+00 + 4.50000000000000e+01 0.00000000000000e+00 + 5.00000000000000e+01 0.00000000000000e+00 + 5.50000000000000e+01 0.00000000000000e+00 + 6.00000000000000e+01 0.00000000000000e+00 + 6.50000000000000e+01 6.44312336849253e-01 + 7.00000000000000e+01 6.44312336849253e-01 + 7.50000000000000e+01 6.44312336849253e-01 + 8.00000000000000e+01 6.44312336849253e-01 + 8.50000000000000e+01 6.44312336849253e-01 + 9.00000000000000e+01 6.44312336849253e-01 + 9.50000000000000e+01 6.44312336849253e-01 + 1.00000000000000e+02 6.44312336849253e-01 + 1.05000000000000e+02 6.44312336849253e-01 + 1.10000000000000e+02 6.44312336849253e-01 + 1.15000000000000e+02 6.44312336849253e-01 + 1.20000000000000e+02 6.44312336849253e-01 + 1.25000000000000e+02 6.44312336849253e-01 + 1.30000000000000e+02 6.44312336849253e-01 + 1.35000000000000e+02 6.44312336849253e-01 + 1.40000000000000e+02 6.44312336849253e-01 + 1.45000000000000e+02 6.44312336849253e-01 + 1.50000000000000e+02 6.44312336849253e-01 + 1.55000000000000e+02 6.44312336849253e-01 + 1.60000000000000e+02 6.44312336849253e-01 + 1.65000000000000e+02 6.44312336849253e-01 + 1.70000000000000e+02 6.44312336849253e-01 + 1.75000000000000e+02 6.44312336849253e-01 + 1.80000000000000e+02 6.44312336849253e-01 diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.out b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.out new file mode 100644 index 000000000..97425d356 --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.out @@ -0,0 +1,233 @@ +colvars: ---------------------------------------------------------------------- +colvars: Please cite Fiorin et al, Mol Phys 2013: +colvars: https://doi.org/10.1080/00268976.2013.813594 +colvars: as well as all other papers listed below for individual features used. +colvars: This version was built with the C++11 standard or higher. +colvars: Summary of compile-time features available in this build: +colvars: - SMP parallelism: enabled (num. threads = 2) +colvars: - Multiple replicas: not available +colvars: - Lepton custom functions: available +colvars: - Tcl interpreter: not available +colvars: ---------------------------------------------------------------------- +colvars: Start colvars Initialization. +colvars: ---------------------------------------------------------------------- +colvars: Reading new configuration: +colvars: # units = "" [default] +colvars: # indexFile = "index.ndx" +colvars: The following index groups are currently defined: +colvars: Protein (104 atoms) +colvars: Protein_noH (51 atoms) +colvars: Protein_Backbone (40 atoms) +colvars: Protein_C-alpha (10 atoms) +colvars: RMSD_atoms (10 atoms) +colvars: Protein_C-alpha_1_2 (2 atoms) +colvars: Protein_C-alpha_9_10 (2 atoms) +colvars: Protein_C-alpha_1 (1 atoms) +colvars: group1 (4 atoms) +colvars: Protein_C-alpha_2 (1 atoms) +colvars: group2 (4 atoms) +colvars: Protein_C-alpha_3 (1 atoms) +colvars: group3 (4 atoms) +colvars: Protein_C-alpha_4 (1 atoms) +colvars: group4 (4 atoms) +colvars: Protein_C-alpha_5 (1 atoms) +colvars: group5 (4 atoms) +colvars: Protein_C-alpha_6 (1 atoms) +colvars: group6 (4 atoms) +colvars: Protein_C-alpha_7 (1 atoms) +colvars: group7 (4 atoms) +colvars: Protein_C-alpha_8 (1 atoms) +colvars: group8 (4 atoms) +colvars: Protein_C-alpha_9 (1 atoms) +colvars: group9 (4 atoms) +colvars: Protein_C-alpha_10 (1 atoms) +colvars: group10 (4 atoms) +colvars: heavy_atoms (51 atoms) +colvars: prot_N (10 atoms) +colvars: prot_CA (10 atoms) +colvars: prot_C (10 atoms) +colvars: prot_O (10 atoms) +colvars: # smp = on [default] +colvars: # colvarsTrajFrequency = 1 +colvars: # colvarsRestartFrequency = 10 +colvars: # scriptedColvarForces = off [default] +colvars: # scriptingAfterBiases = off [default] +colvars: # defaultInputStateFile = "" [default] +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new collective variable. +colvars: # name = "nn_0" +colvars: Initializing a new "torchANN" component. +colvars: Warning: cannot cite unknown feature "torchANN colvar component (derived from linearCombination)" +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 360 +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 360 [default] +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: Initializing atom group "group1". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group1" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group1" defined with 4 atoms requested: total mass = 54.028, total charge = -0.72. +colvars: Initializing atom group "group2". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group2" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group2" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group3". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group3" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group3" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group4". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group4" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: # printAtomIDs = off [default] +colvars: Atom group "group4" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: # oneSiteSystemForce = off [default] +colvars: # oneSiteTotalForce = off [default] +colvars: # modelFile = "identity.pt" +colvars: torch model loaded. +colvars: # m_output_index = 0 +colvars: # doubleInputTensor = on +colvars: Input dimension of model: 1 +colvars: Model's dtype: kFloat64. +colvars: Evaluating model with zero tensor succeeded. +colvars: All components initialized. +colvars: # timeStepFactor = 1 [default] +colvars: # width = 5 +colvars: # lowerBoundary = -180 +colvars: # upperBoundary = 180 +colvars: # hardLowerBoundary = off [default] +colvars: # hardUpperBoundary = off [default] +colvars: # expandBoundaries = off [default] +colvars: # extendedLagrangian = on +colvars: Enabling the extended Lagrangian term for colvar "nn_0". +colvars: # extendedTemp = 300 +colvars: # extendedFluctuation = 5 +colvars: Computed extended system force constant: 0.0997735 [E]/U^2 +colvars: # extendedTimeConstant = 200 +colvars: Computed fictitious mass: 101.092 [E]/(U/fs)^2 (U: colvar unit) +colvars: # outputEnergy = off [default] +colvars: # extendedLangevinDamping = 0 +colvars: # reflectingLowerBoundary = off [default] +colvars: # reflectingUpperBoundary = off [default] +colvars: # outputValue = on [default] +colvars: # outputVelocity = on +colvars: # outputTotalForce = on +colvars: # outputAppliedForce = on +colvars: # subtractAppliedForce = off [default] +colvars: # runAve = off [default] +colvars: # corrFunc = off [default] +colvars: ---------------------------------------------------------------------- +colvars: Collective variables initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new "abf" instance. +colvars: # name = "abf1" [default] +colvars: # colvars = { nn_0 } +colvars: # stepZeroData = off [default] +colvars: # outputEnergy = off [default] +colvars: # outputFreq = 10 [default] +colvars: # timeStepFactor = 1 [default] +colvars: # applyBias = on [default] +colvars: # hideJacobian = off [default] +colvars: Jacobian (geometric) forces will be included in reported free energy gradients. +colvars: # fullSamples = 0 +colvars: # minSamples = 0 [default] +colvars: # inputPrefix = [default] +colvars: # historyFreq = 0 [default] +colvars: # shared = off [default] +colvars: # updateBias = on [default] +colvars: # maxForce = [default] +colvars: # CZARestimator = on [default] +colvars: # integrate = on [default] +colvars: # UIestimator = off [default] +colvars: Finished ABF setup. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables biases initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables module (re)initialized. +colvars: ---------------------------------------------------------------------- +colvars: Current simulation parameters: initial step = 0, integration timestep = 1 +colvars: Updating atomic parameters (masses, charges, etc). +colvars: Re-initialized atom group for variable "nn_0":0/0. 4 atoms: total mass = 54.028, total charge = -0.72. +colvars: Re-initialized atom group for variable "nn_0":0/1. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/2. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/3. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: +colvars: SUMMARY OF COLVARS FEATURES USED SO FAR AND THEIR CITATIONS: +colvars: +colvars: - GROMACS engine: +colvars: Abraham2015 https://doi.org/10.1016/j.softx.2015.06.001 +colvars: +colvars: - Colvars module: +colvars: - Optimal rotation via flexible fitting: +colvars: - dihedral colvar component: +colvars: Fiorin2013 https://doi.org/10.1080/00268976.2013.813594 +colvars: +colvars: - ABF colvar bias implementation: +colvars: Henin2010 https://doi.org/10.1021/ct9004432 +colvars: +colvars: - CZAR eABF estimator: +colvars: - eABF implementation: +colvars: Lesage2017 https://doi.org/10.1021/acs.jpcb.6b10055 +colvars: +colvars: - Colvars-GROMACS interface: +colvars: - linearCombination colvar component: +colvars: n/a +colvars: +colvars: The final output state file will be "test.restart.part0002.colvars.state". +colvars: ---------------------------------------------------------------------- +colvars: Loading state from unformatted memory. +colvars: Restarting collective variable "nn_0" from value: 60.3557 +colvars: Restarted abf bias "abf1" with step number 20. +colvars: ---------------------------------------------------------------------- +colvars: ---------------------------------------------------------------------- +colvars: End colvars Initialization. +colvars: +colvars: Synchronizing (emptying the buffer of) trajectory file "test.restart.part0002.colvars.traj". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.restart.part0002.colvars.traj". +colvars: Saving collective variables state to "test.restart.part0002.colvars.state". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.restart.part0002.colvars.traj". +colvars: Saving collective variables state to "test.restart.part0002.colvars.state". +colvars: Saving collective variables state to "test.restart.part0002.colvars.state". diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.state.stripped b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.state.stripped new file mode 100644 index 000000000..73d87e481 --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.state.stripped @@ -0,0 +1,64 @@ +configuration { + step 40 + dt 1.000000e+00 +} + +colvar { + name nn_0 + x 61.091270179413 + v -0.023937604269782 + extended_x 62.543842332389 + extended_v -0.023937604269782 +} + +abf { + configuration { + step 40 + name abf1 + } + +samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 40 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +gradient + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0.16458374325651 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +z_samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 40 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +z_gradient + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0.16458374325651 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 +} + diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.traj b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.traj new file mode 100644 index 000000000..727b4fc76 --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.colvars.traj @@ -0,0 +1,22 @@ +# step nn_0 r_nn_0 v_nn_0 vr_nn_0 ft_nn_0 fa_nn_0 + 20 6.03556982902622e+01 6.30066233938420e+01 0.00000000000000e+00 -1.57069174779280e-02 -1.35629728273979e-01 1.28862467369851e-01 + 21 6.03418730609519e+01 6.29895748263702e+01 -1.38252293103704e-02 -1.70485674718298e-02 -1.28849565908995e-01 1.35321025859088e-01 + 22 6.03500651663749e+01 6.29712516783066e+01 8.19210542306337e-03 -1.83231480635335e-02 -1.20347246616352e-01 1.41177824309496e-01 + 23 6.03776954677088e+01 6.29517380546391e+01 2.76303013338932e-02 -1.95136236675453e-02 -1.10411041100995e-01 1.46410313292816e-01 + 24 6.04218817028334e+01 6.29311322443654e+01 4.41862351245632e-02 -2.06058102737192e-02 -9.93460489849742e-02 1.51010773338691e-01 + 25 6.04795395481504e+01 6.29095437024464e+01 5.76578453170029e-02 -2.15885419189940e-02 -8.74655140267484e-02 1.54984615298090e-01 + 26 6.05475148928954e+01 6.28870899511971e+01 6.79753447450366e-02 -2.24537512492343e-02 -7.50790242983713e-02 1.58348673529888e-01 + 27 6.06227130017898e+01 6.28638935178400e+01 7.51981088943339e-02 -2.31964333571611e-02 -6.24811473859655e-02 1.61129378133531e-01 + 28 6.07021734326250e+01 6.28400790206404e+01 7.94604308352689e-02 -2.38144971996251e-02 -4.99455721361506e-02 1.63360847683030e-01 + 29 6.07830229161676e+01 6.28157704615754e+01 8.08494835425648e-02 -2.43085590650041e-02 -3.77313203107576e-02 1.65083108791173e-01 + 30 6.08625950742698e+01 6.27910886640890e+01 7.95721581022093e-02 -2.46817974863226e-02 -2.60718228835410e-02 1.66340819468198e-01 + 31 6.09383357545880e+01 6.27661489639920e+01 7.57406803181979e-02 -2.49397000970397e-02 -1.51855578527981e-02 1.67181846012829e-01 + 32 6.10077490628933e+01 6.27410590482759e+01 6.94133083052790e-02 -2.50899157161364e-02 -5.28208747645170e-03 1.67656394695729e-01 + 33 6.10684689018857e+01 6.27159168821223e+01 6.07198389924051e-02 -2.51421661535646e-02 3.44473243180521e-03 1.67816457952591e-01 + 34 6.11182499551973e+01 6.26908087912803e+01 4.97810533116620e-02 -2.51080908420164e-02 1.08153721812520e-02 1.67715142292832e-01 + 35 6.11549958276929e+01 6.26658076861574e+01 3.67458724955512e-02 -2.50011051228405e-02 1.66670764098739e-02 1.67406131659082e-01 + 36 6.11768684735809e+01 6.26409714518431e+01 2.18726458880241e-02 -2.48362343142926e-02 2.08644126352624e-02 1.66943157314363e-01 + 37 6.11824133132800e+01 6.26163416084097e+01 5.54483969911956e-03 -2.46298434334651e-02 2.33111447024902e-02 1.66379254270167e-01 + 38 6.11704780647566e+01 6.25919423589437e+01 -1.19352485234003e-02 -2.43992494660071e-02 2.39412710875282e-02 1.65765803093786e-01 + 39 6.11403005341279e+01 6.25677799366587e+01 -3.01775306287553e-02 -2.41624222849949e-02 2.27272436574744e-02 1.65151924347952e-01 + 40 6.10912701794129e+01 6.25438423323889e+01 -4.90303547150148e-02 -2.39376042697817e-02 1.96554698952972e-02 1.64583743256515e-01 diff --git a/gromacs/tests/library/000_torchann/AutoDiff/test.restart.pmf b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.pmf new file mode 100644 index 000000000..3984bd24a --- /dev/null +++ b/gromacs/tests/library/000_torchann/AutoDiff/test.restart.pmf @@ -0,0 +1,76 @@ +# 1 +# -1.82500000000000e+02 5.00000000000000e+00 73 0 + + -1.80000000000000e+02 0.00000000000000e+00 + -1.75000000000000e+02 0.00000000000000e+00 + -1.70000000000000e+02 0.00000000000000e+00 + -1.65000000000000e+02 0.00000000000000e+00 + -1.60000000000000e+02 0.00000000000000e+00 + -1.55000000000000e+02 0.00000000000000e+00 + -1.50000000000000e+02 0.00000000000000e+00 + -1.45000000000000e+02 0.00000000000000e+00 + -1.40000000000000e+02 0.00000000000000e+00 + -1.35000000000000e+02 0.00000000000000e+00 + -1.30000000000000e+02 0.00000000000000e+00 + -1.25000000000000e+02 0.00000000000000e+00 + -1.20000000000000e+02 0.00000000000000e+00 + -1.15000000000000e+02 0.00000000000000e+00 + -1.10000000000000e+02 0.00000000000000e+00 + -1.05000000000000e+02 0.00000000000000e+00 + -1.00000000000000e+02 0.00000000000000e+00 + -9.50000000000000e+01 0.00000000000000e+00 + -9.00000000000000e+01 0.00000000000000e+00 + -8.50000000000000e+01 0.00000000000000e+00 + -8.00000000000000e+01 0.00000000000000e+00 + -7.50000000000000e+01 0.00000000000000e+00 + -7.00000000000000e+01 0.00000000000000e+00 + -6.50000000000000e+01 0.00000000000000e+00 + -6.00000000000000e+01 0.00000000000000e+00 + -5.50000000000000e+01 0.00000000000000e+00 + -5.00000000000000e+01 0.00000000000000e+00 + -4.50000000000000e+01 0.00000000000000e+00 + -4.00000000000000e+01 0.00000000000000e+00 + -3.50000000000000e+01 0.00000000000000e+00 + -3.00000000000000e+01 0.00000000000000e+00 + -2.50000000000000e+01 0.00000000000000e+00 + -2.00000000000000e+01 0.00000000000000e+00 + -1.50000000000000e+01 0.00000000000000e+00 + -1.00000000000000e+01 0.00000000000000e+00 + -5.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 + 5.00000000000000e+00 0.00000000000000e+00 + 1.00000000000000e+01 0.00000000000000e+00 + 1.50000000000000e+01 0.00000000000000e+00 + 2.00000000000000e+01 0.00000000000000e+00 + 2.50000000000000e+01 0.00000000000000e+00 + 3.00000000000000e+01 0.00000000000000e+00 + 3.50000000000000e+01 0.00000000000000e+00 + 4.00000000000000e+01 0.00000000000000e+00 + 4.50000000000000e+01 0.00000000000000e+00 + 5.00000000000000e+01 0.00000000000000e+00 + 5.50000000000000e+01 0.00000000000000e+00 + 6.00000000000000e+01 0.00000000000000e+00 + 6.50000000000000e+01 8.22918716282573e-01 + 7.00000000000000e+01 8.22918716282573e-01 + 7.50000000000000e+01 8.22918716282573e-01 + 8.00000000000000e+01 8.22918716282573e-01 + 8.50000000000000e+01 8.22918716282573e-01 + 9.00000000000000e+01 8.22918716282573e-01 + 9.50000000000000e+01 8.22918716282573e-01 + 1.00000000000000e+02 8.22918716282573e-01 + 1.05000000000000e+02 8.22918716282573e-01 + 1.10000000000000e+02 8.22918716282573e-01 + 1.15000000000000e+02 8.22918716282573e-01 + 1.20000000000000e+02 8.22918716282573e-01 + 1.25000000000000e+02 8.22918716282573e-01 + 1.30000000000000e+02 8.22918716282573e-01 + 1.35000000000000e+02 8.22918716282573e-01 + 1.40000000000000e+02 8.22918716282573e-01 + 1.45000000000000e+02 8.22918716282573e-01 + 1.50000000000000e+02 8.22918716282573e-01 + 1.55000000000000e+02 8.22918716282573e-01 + 1.60000000000000e+02 8.22918716282573e-01 + 1.65000000000000e+02 8.22918716282573e-01 + 1.70000000000000e+02 8.22918716282573e-01 + 1.75000000000000e+02 8.22918716282573e-01 + 1.80000000000000e+02 8.22918716282573e-01 diff --git a/gromacs/tests/library/000_torchann/build_torch_model.py b/gromacs/tests/library/000_torchann/build_torch_model.py new file mode 100644 index 000000000..ef7ac787a --- /dev/null +++ b/gromacs/tests/library/000_torchann/build_torch_model.py @@ -0,0 +1,14 @@ +import torch + +class MyModel(torch.nn.Module): + def __init__(self): + super().__init__() + def forward(self, x): + return x + +print ("PyTorch Version:", torch.__version__) + +model = MyModel() +scripted_cv_filename = f'./identity.pt' +torch.jit.script(model).save(scripted_cv_filename) + diff --git a/gromacs/tests/library/000_torchann/identity.pt b/gromacs/tests/library/000_torchann/identity.pt new file mode 100644 index 000000000..939bd6813 Binary files /dev/null and b/gromacs/tests/library/000_torchann/identity.pt differ diff --git a/gromacs/tests/library/000_torchann/test.in b/gromacs/tests/library/000_torchann/test.in new file mode 100755 index 000000000..c23a25d10 --- /dev/null +++ b/gromacs/tests/library/000_torchann/test.in @@ -0,0 +1,47 @@ +colvarsTrajFrequency 1 +colvarsRestartFrequency 10 +indexFile index.ndx + +colvar { + name nn_0 + lowerBoundary -180.0 + upperBoundary 180 + width 5.0 + extendedLagrangian on + extendedFluctuation 5.0 + extendedTimeConstant 200 + extendedTemp 300 + extendedLangevinDamping 0.0 # suppress random friction term + + outputAppliedForce on + outputTotalForce on + outputVelocity on + + torchann { + modelFile identity.pt + m_output_index 0 + period 360 + doubleInputTensor on + + dihedral { + group1 { + indexGroup group1 + } + group2 { + indexGroup group2 + } + group3 { + indexGroup group3 + } + group4 { + indexGroup group4 + } + } + } +} + +abf { + colvars nn_0 + fullSamples 0 +} + diff --git a/lammps/COLVARS.cmake b/lammps/COLVARS.cmake new file mode 100644 index 000000000..ddce71d11 --- /dev/null +++ b/lammps/COLVARS.cmake @@ -0,0 +1,48 @@ +set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars) + +file(GLOB COLVARS_SOURCES CONFIGURE_DEPENDS ${COLVARS_SOURCE_DIR}/[^.]*.cpp) + +option(COLVARS_DEBUG "Enable debugging messages for Colvars (quite verbose)" OFF) + +option(COLVARS_LEPTON "Use the Lepton library for custom expressions" ON) + +option(COLVARS_TORCH "Enable torchann colvar components" OFF) + +if(COLVARS_LEPTON) + if(NOT LEPTON_SOURCE_DIR) + include(Packages/LEPTON) + endif() +endif() + + +add_library(colvars STATIC ${COLVARS_SOURCES}) +target_compile_definitions(colvars PRIVATE -DCOLVARS_LAMMPS) +separate_arguments(CMAKE_TUNE_FLAGS) +foreach(_FLAG ${CMAKE_TUNE_FLAGS}) + target_compile_options(colvars PRIVATE ${_FLAG}) +endforeach() +set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_MACHINE}) +target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars) +# The line below is needed to locate math_eigen_impl.h +target_include_directories(colvars PRIVATE ${LAMMPS_SOURCE_DIR}) +target_link_libraries(lammps PRIVATE colvars) + +if(COLVARS_DEBUG) + # Need to export the define publicly to be valid in interface code + target_compile_definitions(colvars PUBLIC -DCOLVARS_DEBUG) +endif() + +if(COLVARS_LEPTON) + target_compile_definitions(colvars PRIVATE -DLEPTON) + target_link_libraries(colvars PUBLIC lepton) +endif() + +if(COLVARS_TORCH) + find_package(Torch REQUIRED) + set_property(TARGET colvars PROPERTY CXX_STANDARD 17) + target_compile_definitions(colvars PRIVATE -DTORCH) + target_compile_options(colvars PRIVATE ${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}) + target_include_directories(colvars PRIVATE ${TORCH_INCLUDE_DIRS}) + target_link_libraries(lmp PRIVATE ${TORCH_LIBRARIES}) +endif() + diff --git a/lammps/lib/colvars/Makefile.common b/lammps/lib/colvars/Makefile.common index a838f4e68..9203f9d15 100644 --- a/lammps/lib/colvars/Makefile.common +++ b/lammps/lib/colvars/Makefile.common @@ -41,6 +41,7 @@ COLVARS_SRCS = \ colvarcomp_distances.cpp \ colvarcomp_gpath.cpp \ colvarcomp_neuralnetwork.cpp \ + colvarcomp_torchann.cpp \ colvarcomp_combination.cpp \ colvarcomp_protein.cpp \ colvarcomp_rotations.cpp \ diff --git a/lammps/lib/colvars/Makefile.deps b/lammps/lib/colvars/Makefile.deps index 6eec39238..82d36e53c 100644 --- a/lammps/lib/colvars/Makefile.deps +++ b/lammps/lib/colvars/Makefile.deps @@ -107,6 +107,11 @@ $(COLVARS_OBJ_DIR)colvarcomp_neuralnetwork.o: \ colvarproxy.h colvarproxy_io.h colvarproxy_system.h colvarproxy_tcl.h \ colvarproxy_volmaps.h colvar_geometricpath.h \ colvar_neuralnetworkcompute.h +$(COLVARS_OBJ_DIR)colvarcomp_torchann.o: \ + colvarcomp_torchann.cpp colvarmodule.h colvars_version.h \ + colvarvalue.h colvartypes.h colvarparse.h colvarparams.h colvar.h \ + colvardeps.h colvarcomp.h colvarcomp_torchann.h colvaratoms.h colvarproxy.h colvarproxy_io.h \ + colvarproxy_system.h colvarproxy_tcl.h $(COLVARS_OBJ_DIR)colvarcomp_combination.o: colvarcomp_combination.cpp \ colvarcomp.h colvarmodule.h colvars_version.h colvaratoms.h \ colvarproxy.h colvartypes.h ../../src/math_eigen_impl.h colvarproxy_io.h \ @@ -133,7 +138,7 @@ $(COLVARS_OBJ_DIR)colvarcomp_volmaps.o: colvarcomp_volmaps.cpp \ colvar_geometricpath.h $(COLVARS_OBJ_DIR)colvar.o: colvar.cpp colvarmodule.h colvars_version.h \ colvarvalue.h colvartypes.h ../../src/math_eigen_impl.h colvarparse.h \ - colvarparams.h colvarcomp.h colvaratoms.h colvarproxy.h colvarproxy_io.h \ + colvarparams.h colvarcomp.h colvarcomp_torchann.h colvaratoms.h colvarproxy.h colvarproxy_io.h \ colvarproxy_system.h colvarproxy_tcl.h colvarproxy_volmaps.h \ colvardeps.h colvar.h colvar_geometricpath.h colvarbias.h \ colvars_memstream.h diff --git a/namd/Makefile.patch b/namd/Makefile.patch index a1349b313..580c60b5b 100644 --- a/namd/Makefile.patch +++ b/namd/Makefile.patch @@ -1,19 +1,13 @@ diff --git a/Makefile b/Makefile -index 1456d146..4bae1b7a 100644 +index fb23fcac..541fe8ca 100644 --- a/Makefile +++ b/Makefile -@@ -404,13 +404,7 @@ SBLIB = \ - - include colvars/src/Makefile.namd - --LEPTONOBJS = \ -- $(DSTDIR)/CompiledExpression.o \ -- $(DSTDIR)/ExpressionProgram.o \ -- $(DSTDIR)/ExpressionTreeNode.o \ -- $(DSTDIR)/Operation.o \ -- $(DSTDIR)/ParsedExpression.o \ -- $(DSTDIR)/Parser.o -+include lepton/Makefile.namd - - # definitions for Charm routines - CHARMC = $(CHARM)/bin/charmc +@@ -446,7 +446,7 @@ CXXMICFLAGS = $(CXXBASEFLAGS) $(CXXOPTS) $(CXXMICOPTS) + CXXTHREADFLAGS = $(CXXBASEFLAGS) $(CXXTHREADOPTS) + CXXSIMPARAMFLAGS = $(CXXBASEFLAGS) $(CXXSIMPARAMOPTS) + CXXNOALIASFLAGS = $(CXXBASEFLAGS) $(CXXNOALIASOPTS) +-COLVARSCXXFLAGS = $(CXXBASEFLAGS) $(CXXOPTS) $(COPTI)$(LEPTONINCDIR) -DLEPTON -DLEPTON_USE_STATIC_LIBRARIES ++COLVARSCXXFLAGS = $(CXXBASEFLAGS) $(CXXOPTS) $(COPTI)$(LEPTONINCDIR) -DLEPTON -DLEPTON_USE_STATIC_LIBRARIES $(EXTRACOLVARSFLAGS) + GXXFLAGS = $(CXXBASEFLAGS) -DNO_STRSTREAM_H + CFLAGS = $(COPTI)$(SRCDIR) $(TCL) $(COPTS) $(RELEASE) $(EXTRADEFINES) $(TRACEOBJDEF) + PLUGINGCCFLAGS = $(COPTI)$(PLUGINSRCDIR) $(COPTI)$(PLUGININCDIR) $(COPTD)STATIC_PLUGIN diff --git a/namd/colvars/Make.depends b/namd/colvars/Make.depends index a6210a431..2b57e0bcf 100644 --- a/namd/colvars/Make.depends +++ b/namd/colvars/Make.depends @@ -8,6 +8,7 @@ obj/colvar.o: \ colvars/src/colvarparse.h \ colvars/src/colvarparams.h \ colvars/src/colvarcomp.h \ + colvars/src/colvarcomp_torchann.h \ colvars/src/colvaratoms.h \ colvars/src/colvarproxy.h \ colvars/src/colvarproxy_io.h \ @@ -465,6 +466,11 @@ obj/colvarcomp_neuralnetwork.o: \ colvars/src/colvar_geometricpath.h \ colvars/src/colvar_neuralnetworkcompute.h $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_neuralnetwork.o $(COPTC) colvars/src/colvarcomp_neuralnetwork.cpp +obj/colvarcomp_torchann.o: \ + obj/.exists \ + colvars/src/colvarcomp_torchann.h \ + colvars/src/colvarcomp_torchann.cpp + $(CXX) $(COLVARSCXXFLAGS) $(COPTO)obj/colvarcomp_torchann.o $(COPTC) colvars/src/colvarcomp_torchann.cpp obj/colvar_neuralnetworkcompute.o: \ obj/.exists \ colvars/src/colvar_neuralnetworkcompute.cpp \ diff --git a/namd/colvars/src/Makefile.namd b/namd/colvars/src/Makefile.namd index 5bdeedcf7..c3f341bae 100644 --- a/namd/colvars/src/Makefile.namd +++ b/namd/colvars/src/Makefile.namd @@ -22,6 +22,7 @@ COLVARSLIB = \ $(DSTDIR)/colvarcomp_volmaps.o \ $(DSTDIR)/colvarcomp_combination.o \ $(DSTDIR)/colvarcomp_neuralnetwork.o \ + $(DSTDIR)/colvarcomp_torchann.o \ $(DSTDIR)/colvar_neuralnetworkcompute.o \ $(DSTDIR)/colvardeps.o \ $(DSTDIR)/colvargrid.o \ diff --git a/namd/config.patch b/namd/config.patch new file mode 100644 index 000000000..c3ca6b9b6 --- /dev/null +++ b/namd/config.patch @@ -0,0 +1,59 @@ +diff --git a/config b/config +index ddf9f860..4148d87c 100755 +--- a/config ++++ b/config +@@ -57,6 +57,8 @@ function error_syntax { + echo ' --cuda-dlink arch=,code= (for cuFFT, may be repeated)' + echo ' --with-cuda-profiling (enables CUDA profiling with NVTX)' + echo ' --with-rocm-profiling (enables ROCm profiling with ROCtracer API)' ++ echo ' --with-colvars-torch (enables torchann in Colvars)' ++ echo ' --torch-prefix ' + echo '' + if [ -n "${PRINT_ARCH_LIST+set}" ]; then + ARCH_PAT='' +@@ -152,6 +154,7 @@ function error_exists { + use_mkl=0 + use_cuda=0 + use_hip=0 ++ use_colvars_torch=0 + use_cuda_prof=0 + use_rocm_prof=0 + use_memopt=0 +@@ -257,6 +260,19 @@ function error_exists { + ARCH_SUFFIX_ARG=$ARCH_SUFFIX_ARG-$1 + ;; + ++ --with-colvars-torch) ++ use_colvars_torch=1 ++ ;; ++ ++ --torch-prefix) ++ shift ++ if [ ! -d "$1" ]; then ++ echo "ERROR: No such directory $1" ++ error_syntax ++ fi ++ TORCH_PREFIX=$1 ++ ;; ++ + --with-debug) + use_debug=1 + ;; +@@ -1015,7 +1031,16 @@ function error_exists { + if [ -n "$CC_OPTS" ]; then + echo "COPTS = $CC_OPTS" >> Make.config + fi +- ++ if (( "$use_colvars_torch" )); then ++ echo "TORCHDIR = $TORCH_PREFIX" >> Make.config ++ echo 'TORCHINCFLAGS = $(COPTI)$(TORCHDIR)/include $(COPTI)$(TORCHDIR)/include/torch/csrc/api/include' >> Make.config ++ echo 'EXTRACOLVARSFLAGS = -std=c++17 -DTORCH $(TORCHINCFLAGS)' >> Make.config ++ if [[ $use_cuda && -f "${TORCH_PREFIX}/lib/libtorch_cuda.so" ]]; then ++ echo 'EXTRALINKLIBS = -Wl,-rpath,$(TORCHDIR)/lib -L$(TORCHDIR)/lib -ltorch -ltorch_cpu -lc10 -ltorch_cuda -lc10_cuda' >> Make.config ++ else ++ echo 'EXTRALINKLIBS = -Wl,-rpath,$(TORCHDIR)/lib -L$(TORCHDIR)/lib -ltorch -ltorch_cpu -lc10' >> Make.config ++ fi ++ fi + + if (( $use_debug )); then + echo 'CXXOPTS = -g' >> Make.config diff --git a/namd/tests/library/000_torchann/AutoDiff/test.colvars.out b/namd/tests/library/000_torchann/AutoDiff/test.colvars.out new file mode 100644 index 000000000..139290329 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.colvars.out @@ -0,0 +1,234 @@ +colvars: ---------------------------------------------------------------------- +colvars: Please cite Fiorin et al, Mol Phys 2013: +colvars: https://doi.org/10.1080/00268976.2013.813594 +colvars: as well as all other papers listed below for individual features used. +colvars: SMP parallelism is enabled; if needed, use "smp off" to override this. +colvars: This version was built with the C++11 standard or higher. +colvars: Redefining the Tcl "cv" command to the new script interface. +colvars: The restart output state file will be "test.tmp.colvars.state". +colvars: The final output state file will be "test.colvars.state". +colvars: ---------------------------------------------------------------------- +colvars: Reading new configuration from file "test.in": +colvars: # units = "" [default] +colvars: # indexFile = "index.ndx" +colvars: The following index groups are currently defined: +colvars: Protein (104 atoms) +colvars: Protein_noH (51 atoms) +colvars: Protein_Backbone (40 atoms) +colvars: Protein_C-alpha (10 atoms) +colvars: RMSD_atoms (10 atoms) +colvars: Protein_C-alpha_1_2 (2 atoms) +colvars: Protein_C-alpha_9_10 (2 atoms) +colvars: Protein_C-alpha_1 (1 atoms) +colvars: group1 (4 atoms) +colvars: Protein_C-alpha_2 (1 atoms) +colvars: group2 (4 atoms) +colvars: Protein_C-alpha_3 (1 atoms) +colvars: group3 (4 atoms) +colvars: Protein_C-alpha_4 (1 atoms) +colvars: group4 (4 atoms) +colvars: Protein_C-alpha_5 (1 atoms) +colvars: group5 (4 atoms) +colvars: Protein_C-alpha_6 (1 atoms) +colvars: group6 (4 atoms) +colvars: Protein_C-alpha_7 (1 atoms) +colvars: group7 (4 atoms) +colvars: Protein_C-alpha_8 (1 atoms) +colvars: group8 (4 atoms) +colvars: Protein_C-alpha_9 (1 atoms) +colvars: group9 (4 atoms) +colvars: Protein_C-alpha_10 (1 atoms) +colvars: group10 (4 atoms) +colvars: heavy_atoms (51 atoms) +colvars: # smp = on [default] +colvars: # colvarsTrajFrequency = 1 +colvars: # colvarsRestartFrequency = 10 +colvars: # scriptedColvarForces = off [default] +colvars: # scriptingAfterBiases = off [default] +colvars: # sourceTclFile = "" [default] +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new collective variable. +colvars: # name = "nn_0" +colvars: Initializing a new "torchANN" component. +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 360 +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 0 [default] +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: Initializing atom group "group1". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group1" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group1". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group1" defined with 4 atoms requested: total mass = 54.028, total charge = -0.72. +colvars: Initializing atom group "group2". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group2" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group2". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group2" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group3". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group3" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group3". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group3" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group4". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group4" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group4". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group4" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: # oneSiteSystemForce = off [default] +colvars: # oneSiteTotalForce = off [default] +colvars: # modelFile = "identity.pt" +colvars: torch model loaded. +colvars: # m_output_index = 0 +colvars: # doubleInputTensor = on +colvars: # useGPU = off [default] +colvars: Input dimension of model: 1 +colvars: Use CPU. +colvars: Model's dtype: kFloat64. +colvars: Evaluating model with zero tensor succeeded. +colvars: All components initialized. +colvars: # timeStepFactor = 1 [default] +colvars: # width = 5 +colvars: # lowerBoundary = -180 +colvars: # upperBoundary = 180 +colvars: # hardLowerBoundary = off [default] +colvars: # hardUpperBoundary = off [default] +colvars: # expandBoundaries = off [default] +colvars: # extendedLagrangian = on +colvars: Enabling the extended Lagrangian term for colvar "nn_0". +colvars: # extendedTemp = 300 +colvars: # extendedFluctuation = 5 +colvars: Computed extended system force constant: 0.0238463 [E]/U^2 +colvars: # extendedTimeConstant = 200 +colvars: Computed fictitious mass: 24.1613 [E]/(U/fs)^2 (U: colvar unit) +colvars: # outputEnergy = off [default] +colvars: # extendedLangevinDamping = 1 [default] +colvars: # reflectingLowerBoundary = off [default] +colvars: # reflectingUpperBoundary = off [default] +colvars: # outputValue = on [default] +colvars: # outputVelocity = off [default] +colvars: # outputTotalForce = off [default] +colvars: # outputAppliedForce = off [default] +colvars: # subtractAppliedForce = off [default] +colvars: # runAve = off [default] +colvars: # corrFunc = off [default] +colvars: ---------------------------------------------------------------------- +colvars: Collective variables initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new "abf" instance. +colvars: # name = "abf1" [default] +colvars: # colvars = { nn_0 } +colvars: # stepZeroData = off [default] +colvars: # outputEnergy = off [default] +colvars: # outputFreq = 10 [default] +colvars: # timeStepFactor = 1 [default] +colvars: WARNING: ABF should not be run without a thermostat or at 0 Kelvin! +colvars: # applyBias = on [default] +colvars: # updateBias = on [default] +colvars: # hideJacobian = off [default] +colvars: Jacobian (geometric) forces will be included in reported free energy gradients. +colvars: # fullSamples = 0 +colvars: # inputPrefix = [default] +colvars: # historyFreq = 0 [default] +colvars: # shared = off [default] +colvars: # maxForce = [default] +colvars: # CZARestimator = on [default] +colvars: # integrate = on [default] +colvars: # UIestimator = off [default] +colvars: Finished ABF setup. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables biases initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables module (re)initialized. +colvars: ---------------------------------------------------------------------- +colvars: Updating NAMD interface: +colvars: updating atomic data (0 atoms). +colvars: updating group data (4 scalable groups, 16 atoms in total). +colvars: updating grid object data (0 grid objects in total). +colvars: +colvars: SUMMARY OF COLVARS FEATURES USED SO FAR AND THEIR CITATIONS: +colvars: +colvars: - Colvars module: +colvars: - Colvars-NAMD interface: +colvars: - Optimal rotation via flexible fitting: +colvars: - dihedral colvar component: +colvars: Fiorin2013 https://doi.org/10.1080/00268976.2013.813594 +colvars: +colvars: - ABF colvar bias implementation: +colvars: Henin2010 https://doi.org/10.1021/ct9004432 +colvars: +colvars: - CZAR eABF estimator: +colvars: - eABF implementation: +colvars: Lesage2017 https://doi.org/10.1021/acs.jpcb.6b10055 +colvars: +colvars: - NAMD engine: +colvars: - Scalable center-of-mass computation (NAMD): +colvars: Phillips2020 https://doi.org/10.1063/5.0014475 +colvars: +colvars: - torchANN colvar component: +colvars: n/a +colvars: +colvars: updating target temperature (T = 0 K). +colvars: Updating NAMD interface: +colvars: updating atomic data (0 atoms). +colvars: updating group data (4 scalable groups, 16 atoms in total). +colvars: updating grid object data (0 grid objects in total). +colvars: updating target temperature (T = 0 K). +colvars: Re-initialized atom group for variable "nn_0":0/0. 4 atoms: total mass = 54.028, total charge = -0.72. +colvars: Re-initialized atom group for variable "nn_0":0/1. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/2. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/3. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: The restart output state file will be "test.tmp.colvars.state". +colvars: The final output state file will be "test.colvars.state". +colvars: Prepared sample and gradient buffers at step 0. +colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj". +colvars: Saving collective variables state to "test.tmp.colvars.state". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj". +colvars: Saving collective variables state to "test.tmp.colvars.state". +colvars: Saving collective variables state to "test.colvars.state". diff --git a/namd/tests/library/000_torchann/AutoDiff/test.colvars.state.stripped b/namd/tests/library/000_torchann/AutoDiff/test.colvars.state.stripped new file mode 100644 index 000000000..900e20572 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.colvars.state.stripped @@ -0,0 +1,63 @@ +configuration { + step 20 + dt 1.000000e+00 +} + +colvar { + name nn_0 + x 6.03180709798566e+01 + extended_x 6.32059993002439e+01 + extended_v -5.96718787692076e-03 +} + +abf { + configuration { + step 20 + name abf1 + } + +samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 20 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +gradient + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 3.08485663777976e-02 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + +z_samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 20 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +z_gradient + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 3.08485663777976e-02 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 +} + diff --git a/namd/tests/library/000_torchann/AutoDiff/test.colvars.traj b/namd/tests/library/000_torchann/AutoDiff/test.colvars.traj new file mode 100644 index 000000000..5e0ff37db --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.colvars.traj @@ -0,0 +1,22 @@ +# step nn_0 r_nn_0 + 0 6.31129478791928e+01 6.31129478791928e+01 + 1 6.30795952608635e+01 6.31117489747764e+01 + 2 6.30231689959512e+01 6.30985098136584e+01 + 3 6.29423605394204e+01 6.30958813243297e+01 + 4 6.28368059443607e+01 6.30922445707534e+01 + 5 6.27071689876227e+01 6.30966553337459e+01 + 6 6.25551533956062e+01 6.30976646128906e+01 + 7 6.23834363419271e+01 6.31014350203242e+01 + 8 6.21955482901660e+01 6.30996818251203e+01 + 9 6.19957062311755e+01 6.30933923393588e+01 + 10 6.17886236337608e+01 6.30920677049031e+01 + 11 6.15793103634744e+01 6.30974791546251e+01 + 12 6.13728677287057e+01 6.31064339086805e+01 + 13 6.11742855932599e+01 6.31126316934887e+01 + 14 6.09882466368870e+01 6.31241161964611e+01 + 15 6.08189466405346e+01 6.31476282566278e+01 + 16 6.06699314736364e+01 6.31675101863727e+01 + 17 6.05439532005244e+01 6.31870402824915e+01 + 18 6.04428690670993e+01 6.32043196804664e+01 + 19 6.03675877822053e+01 6.32119664881209e+01 + 20 6.03180709798566e+01 6.32059993002439e+01 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.count b/namd/tests/library/000_torchann/AutoDiff/test.count new file mode 100644 index 000000000..aa733077c --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.count @@ -0,0 +1,75 @@ +# 1 +# -1.80000000000000e+02 5.00000000000000e+00 72 1 + + -1.77500000000000e+02 0 + -1.72500000000000e+02 0 + -1.67500000000000e+02 0 + -1.62500000000000e+02 0 + -1.57500000000000e+02 0 + -1.52500000000000e+02 0 + -1.47500000000000e+02 0 + -1.42500000000000e+02 0 + -1.37500000000000e+02 0 + -1.32500000000000e+02 0 + -1.27500000000000e+02 0 + -1.22500000000000e+02 0 + -1.17500000000000e+02 0 + -1.12500000000000e+02 0 + -1.07500000000000e+02 0 + -1.02500000000000e+02 0 + -9.75000000000000e+01 0 + -9.25000000000000e+01 0 + -8.75000000000000e+01 0 + -8.25000000000000e+01 0 + -7.75000000000000e+01 0 + -7.25000000000000e+01 0 + -6.75000000000000e+01 0 + -6.25000000000000e+01 0 + -5.75000000000000e+01 0 + -5.25000000000000e+01 0 + -4.75000000000000e+01 0 + -4.25000000000000e+01 0 + -3.75000000000000e+01 0 + -3.25000000000000e+01 0 + -2.75000000000000e+01 0 + -2.25000000000000e+01 0 + -1.75000000000000e+01 0 + -1.25000000000000e+01 0 + -7.50000000000000e+00 0 + -2.50000000000000e+00 0 + 2.50000000000000e+00 0 + 7.50000000000000e+00 0 + 1.25000000000000e+01 0 + 1.75000000000000e+01 0 + 2.25000000000000e+01 0 + 2.75000000000000e+01 0 + 3.25000000000000e+01 0 + 3.75000000000000e+01 0 + 4.25000000000000e+01 0 + 4.75000000000000e+01 0 + 5.25000000000000e+01 0 + 5.75000000000000e+01 0 + 6.25000000000000e+01 20 + 6.75000000000000e+01 0 + 7.25000000000000e+01 0 + 7.75000000000000e+01 0 + 8.25000000000000e+01 0 + 8.75000000000000e+01 0 + 9.25000000000000e+01 0 + 9.75000000000000e+01 0 + 1.02500000000000e+02 0 + 1.07500000000000e+02 0 + 1.12500000000000e+02 0 + 1.17500000000000e+02 0 + 1.22500000000000e+02 0 + 1.27500000000000e+02 0 + 1.32500000000000e+02 0 + 1.37500000000000e+02 0 + 1.42500000000000e+02 0 + 1.47500000000000e+02 0 + 1.52500000000000e+02 0 + 1.57500000000000e+02 0 + 1.62500000000000e+02 0 + 1.67500000000000e+02 0 + 1.72500000000000e+02 0 + 1.77500000000000e+02 0 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.grad b/namd/tests/library/000_torchann/AutoDiff/test.grad new file mode 100644 index 000000000..cdf0b4df5 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.grad @@ -0,0 +1,75 @@ +# 1 +# -1.80000000000000e+02 5.00000000000000e+00 72 1 + + -1.77500000000000e+02 0.00000000000000e+00 + -1.72500000000000e+02 0.00000000000000e+00 + -1.67500000000000e+02 0.00000000000000e+00 + -1.62500000000000e+02 0.00000000000000e+00 + -1.57500000000000e+02 0.00000000000000e+00 + -1.52500000000000e+02 0.00000000000000e+00 + -1.47500000000000e+02 0.00000000000000e+00 + -1.42500000000000e+02 0.00000000000000e+00 + -1.37500000000000e+02 0.00000000000000e+00 + -1.32500000000000e+02 0.00000000000000e+00 + -1.27500000000000e+02 0.00000000000000e+00 + -1.22500000000000e+02 0.00000000000000e+00 + -1.17500000000000e+02 0.00000000000000e+00 + -1.12500000000000e+02 0.00000000000000e+00 + -1.07500000000000e+02 0.00000000000000e+00 + -1.02500000000000e+02 0.00000000000000e+00 + -9.75000000000000e+01 0.00000000000000e+00 + -9.25000000000000e+01 0.00000000000000e+00 + -8.75000000000000e+01 0.00000000000000e+00 + -8.25000000000000e+01 0.00000000000000e+00 + -7.75000000000000e+01 0.00000000000000e+00 + -7.25000000000000e+01 0.00000000000000e+00 + -6.75000000000000e+01 0.00000000000000e+00 + -6.25000000000000e+01 0.00000000000000e+00 + -5.75000000000000e+01 0.00000000000000e+00 + -5.25000000000000e+01 0.00000000000000e+00 + -4.75000000000000e+01 0.00000000000000e+00 + -4.25000000000000e+01 0.00000000000000e+00 + -3.75000000000000e+01 0.00000000000000e+00 + -3.25000000000000e+01 0.00000000000000e+00 + -2.75000000000000e+01 0.00000000000000e+00 + -2.25000000000000e+01 0.00000000000000e+00 + -1.75000000000000e+01 0.00000000000000e+00 + -1.25000000000000e+01 0.00000000000000e+00 + -7.50000000000000e+00 0.00000000000000e+00 + -2.50000000000000e+00 0.00000000000000e+00 + 2.50000000000000e+00 0.00000000000000e+00 + 7.50000000000000e+00 0.00000000000000e+00 + 1.25000000000000e+01 0.00000000000000e+00 + 1.75000000000000e+01 0.00000000000000e+00 + 2.25000000000000e+01 0.00000000000000e+00 + 2.75000000000000e+01 0.00000000000000e+00 + 3.25000000000000e+01 0.00000000000000e+00 + 3.75000000000000e+01 0.00000000000000e+00 + 4.25000000000000e+01 0.00000000000000e+00 + 4.75000000000000e+01 0.00000000000000e+00 + 5.25000000000000e+01 0.00000000000000e+00 + 5.75000000000000e+01 0.00000000000000e+00 + 6.25000000000000e+01 3.08485663777976e-02 + 6.75000000000000e+01 0.00000000000000e+00 + 7.25000000000000e+01 0.00000000000000e+00 + 7.75000000000000e+01 0.00000000000000e+00 + 8.25000000000000e+01 0.00000000000000e+00 + 8.75000000000000e+01 0.00000000000000e+00 + 9.25000000000000e+01 0.00000000000000e+00 + 9.75000000000000e+01 0.00000000000000e+00 + 1.02500000000000e+02 0.00000000000000e+00 + 1.07500000000000e+02 0.00000000000000e+00 + 1.12500000000000e+02 0.00000000000000e+00 + 1.17500000000000e+02 0.00000000000000e+00 + 1.22500000000000e+02 0.00000000000000e+00 + 1.27500000000000e+02 0.00000000000000e+00 + 1.32500000000000e+02 0.00000000000000e+00 + 1.37500000000000e+02 0.00000000000000e+00 + 1.42500000000000e+02 0.00000000000000e+00 + 1.47500000000000e+02 0.00000000000000e+00 + 1.52500000000000e+02 0.00000000000000e+00 + 1.57500000000000e+02 0.00000000000000e+00 + 1.62500000000000e+02 0.00000000000000e+00 + 1.67500000000000e+02 0.00000000000000e+00 + 1.72500000000000e+02 0.00000000000000e+00 + 1.77500000000000e+02 0.00000000000000e+00 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.pmf b/namd/tests/library/000_torchann/AutoDiff/test.pmf new file mode 100644 index 000000000..4dbac2266 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.pmf @@ -0,0 +1,75 @@ +# 1 +# -1.82500000000000e+02 5.00000000000000e+00 72 1 + + -1.80000000000000e+02 1.02828554592659e-01 + -1.75000000000000e+02 1.00686293038645e-01 + -1.70000000000000e+02 9.85440314846311e-02 + -1.65000000000000e+02 9.64017699306174e-02 + -1.60000000000000e+02 9.42595083766037e-02 + -1.55000000000000e+02 9.21172468225899e-02 + -1.50000000000000e+02 8.99749852685762e-02 + -1.45000000000000e+02 8.78327237145625e-02 + -1.40000000000000e+02 8.56904621605488e-02 + -1.35000000000000e+02 8.35482006065351e-02 + -1.30000000000000e+02 8.14059390525213e-02 + -1.25000000000000e+02 7.92636774985076e-02 + -1.20000000000000e+02 7.71214159444939e-02 + -1.15000000000000e+02 7.49791543904802e-02 + -1.10000000000000e+02 7.28368928364665e-02 + -1.05000000000000e+02 7.06946312824527e-02 + -1.00000000000000e+02 6.85523697284390e-02 + -9.50000000000000e+01 6.64101081744253e-02 + -9.00000000000000e+01 6.42678466204116e-02 + -8.50000000000000e+01 6.21255850663978e-02 + -8.00000000000000e+01 5.99833235123841e-02 + -7.50000000000000e+01 5.78410619583704e-02 + -7.00000000000000e+01 5.56988004043567e-02 + -6.50000000000000e+01 5.35565388503429e-02 + -6.00000000000000e+01 5.14142772963292e-02 + -5.50000000000000e+01 4.92720157423155e-02 + -5.00000000000000e+01 4.71297541883018e-02 + -4.50000000000000e+01 4.49874926342881e-02 + -4.00000000000000e+01 4.28452310802743e-02 + -3.50000000000000e+01 4.07029695262606e-02 + -3.00000000000000e+01 3.85607079722469e-02 + -2.50000000000000e+01 3.64184464182332e-02 + -2.00000000000000e+01 3.42761848642195e-02 + -1.50000000000000e+01 3.21339233102057e-02 + -1.00000000000000e+01 2.99916617561920e-02 + -5.00000000000000e+00 2.78494002021783e-02 + 0.00000000000000e+00 2.57071386481646e-02 + 5.00000000000000e+00 2.35648770941509e-02 + 1.00000000000000e+01 2.14226155401372e-02 + 1.50000000000000e+01 1.92803539861234e-02 + 2.00000000000000e+01 1.71380924321097e-02 + 2.50000000000000e+01 1.49958308780960e-02 + 3.00000000000000e+01 1.28535693240823e-02 + 3.50000000000000e+01 1.07113077700686e-02 + 4.00000000000000e+01 8.56904621605487e-03 + 4.50000000000000e+01 6.42678466204115e-03 + 5.00000000000000e+01 4.28452310802743e-03 + 5.50000000000000e+01 2.14226155401372e-03 + 6.00000000000000e+01 0.00000000000000e+00 + 6.50000000000000e+01 1.52100570334974e-01 + 7.00000000000000e+01 1.49958308780960e-01 + 7.50000000000000e+01 1.47816047226947e-01 + 8.00000000000000e+01 1.45673785672933e-01 + 8.50000000000000e+01 1.43531524118919e-01 + 9.00000000000000e+01 1.41389262564906e-01 + 9.50000000000000e+01 1.39247001010892e-01 + 1.00000000000000e+02 1.37104739456878e-01 + 1.05000000000000e+02 1.34962477902864e-01 + 1.10000000000000e+02 1.32820216348851e-01 + 1.15000000000000e+02 1.30677954794837e-01 + 1.20000000000000e+02 1.28535693240823e-01 + 1.25000000000000e+02 1.26393431686809e-01 + 1.30000000000000e+02 1.24251170132796e-01 + 1.35000000000000e+02 1.22108908578782e-01 + 1.40000000000000e+02 1.19966647024768e-01 + 1.45000000000000e+02 1.17824385470755e-01 + 1.50000000000000e+02 1.15682123916741e-01 + 1.55000000000000e+02 1.13539862362727e-01 + 1.60000000000000e+02 1.11397600808713e-01 + 1.65000000000000e+02 1.09255339254700e-01 + 1.70000000000000e+02 1.07113077700686e-01 + 1.75000000000000e+02 1.04970816146672e-01 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.out b/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.out new file mode 100644 index 000000000..1d7e8048b --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.out @@ -0,0 +1,239 @@ +colvars: ---------------------------------------------------------------------- +colvars: Please cite Fiorin et al, Mol Phys 2013: +colvars: https://doi.org/10.1080/00268976.2013.813594 +colvars: as well as all other papers listed below for individual features used. +colvars: SMP parallelism is enabled; if needed, use "smp off" to override this. +colvars: This version was built with the C++11 standard or higher. +colvars: Redefining the Tcl "cv" command to the new script interface. +colvars: The restart output state file will be "test.restart.tmp.colvars.state". +colvars: The final output state file will be "test.restart.colvars.state". +colvars: ---------------------------------------------------------------------- +colvars: Reading new configuration from file "test.in": +colvars: # units = "" [default] +colvars: # indexFile = "index.ndx" +colvars: The following index groups are currently defined: +colvars: Protein (104 atoms) +colvars: Protein_noH (51 atoms) +colvars: Protein_Backbone (40 atoms) +colvars: Protein_C-alpha (10 atoms) +colvars: RMSD_atoms (10 atoms) +colvars: Protein_C-alpha_1_2 (2 atoms) +colvars: Protein_C-alpha_9_10 (2 atoms) +colvars: Protein_C-alpha_1 (1 atoms) +colvars: group1 (4 atoms) +colvars: Protein_C-alpha_2 (1 atoms) +colvars: group2 (4 atoms) +colvars: Protein_C-alpha_3 (1 atoms) +colvars: group3 (4 atoms) +colvars: Protein_C-alpha_4 (1 atoms) +colvars: group4 (4 atoms) +colvars: Protein_C-alpha_5 (1 atoms) +colvars: group5 (4 atoms) +colvars: Protein_C-alpha_6 (1 atoms) +colvars: group6 (4 atoms) +colvars: Protein_C-alpha_7 (1 atoms) +colvars: group7 (4 atoms) +colvars: Protein_C-alpha_8 (1 atoms) +colvars: group8 (4 atoms) +colvars: Protein_C-alpha_9 (1 atoms) +colvars: group9 (4 atoms) +colvars: Protein_C-alpha_10 (1 atoms) +colvars: group10 (4 atoms) +colvars: heavy_atoms (51 atoms) +colvars: # smp = on [default] +colvars: # colvarsTrajFrequency = 1 +colvars: # colvarsRestartFrequency = 10 +colvars: # scriptedColvarForces = off [default] +colvars: # scriptingAfterBiases = off [default] +colvars: # sourceTclFile = "" [default] +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new collective variable. +colvars: # name = "nn_0" +colvars: Initializing a new "torchANN" component. +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 360 +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: # name = "" [default] +colvars: # componentCoeff = 1 [default] +colvars: # componentExp = 1 [default] +colvars: # period = 0 [default] +colvars: # wrapAround = 0 [default] +colvars: # forceNoPBC = off [default] +colvars: # scalable = on [default] +colvars: Initializing atom group "group1". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group1" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group1". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group1" defined with 4 atoms requested: total mass = 54.028, total charge = -0.72. +colvars: Initializing atom group "group2". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group2" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group2". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group2" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group3". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group3" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group3". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group3" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: Initializing atom group "group4". +colvars: # name = "" [default] +colvars: # centerToOrigin = off [default] +colvars: # centerToReference = off [default] +colvars: # rotateToReference = off [default] +colvars: # atomsOfGroup = "" [default] +colvars: # indexGroup = "group4" +colvars: # psfSegID = [default] +colvars: # atomsFile = "" [default] +colvars: # dummyAtom = ( 0 , 0 , 0 ) [default] +colvars: # enableFitGradients = on [default] +colvars: Enabling scalable calculation for group "group4". +colvars: # printAtomIDs = off [default] +colvars: Atom group "group4" defined with 4 atoms requested: total mass = 54.028, total charge = -0.4. +colvars: # oneSiteSystemForce = off [default] +colvars: # oneSiteTotalForce = off [default] +colvars: # modelFile = "identity.pt" +colvars: torch model loaded. +colvars: # m_output_index = 0 +colvars: # doubleInputTensor = on +colvars: # useGPU = off [default] +colvars: Input dimension of model: 1 +colvars: Use CPU. +colvars: Model's dtype: kFloat64. +colvars: Evaluating model with zero tensor succeeded. +colvars: All components initialized. +colvars: # timeStepFactor = 1 [default] +colvars: # width = 5 +colvars: # lowerBoundary = -180 +colvars: # upperBoundary = 180 +colvars: # hardLowerBoundary = off [default] +colvars: # hardUpperBoundary = off [default] +colvars: # expandBoundaries = off [default] +colvars: # extendedLagrangian = on +colvars: Enabling the extended Lagrangian term for colvar "nn_0". +colvars: # extendedTemp = 300 +colvars: # extendedFluctuation = 5 +colvars: Computed extended system force constant: 0.0238463 [E]/U^2 +colvars: # extendedTimeConstant = 200 +colvars: Computed fictitious mass: 24.1613 [E]/(U/fs)^2 (U: colvar unit) +colvars: # outputEnergy = off [default] +colvars: # extendedLangevinDamping = 1 [default] +colvars: # reflectingLowerBoundary = off [default] +colvars: # reflectingUpperBoundary = off [default] +colvars: # outputValue = on [default] +colvars: # outputVelocity = off [default] +colvars: # outputTotalForce = off [default] +colvars: # outputAppliedForce = off [default] +colvars: # subtractAppliedForce = off [default] +colvars: # runAve = off [default] +colvars: # corrFunc = off [default] +colvars: ---------------------------------------------------------------------- +colvars: Collective variables initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Initializing a new "abf" instance. +colvars: # name = "abf1" [default] +colvars: # colvars = { nn_0 } +colvars: # stepZeroData = off [default] +colvars: # outputEnergy = off [default] +colvars: # outputFreq = 10 [default] +colvars: # timeStepFactor = 1 [default] +colvars: WARNING: ABF should not be run without a thermostat or at 0 Kelvin! +colvars: # applyBias = on [default] +colvars: # updateBias = on [default] +colvars: # hideJacobian = off [default] +colvars: Jacobian (geometric) forces will be included in reported free energy gradients. +colvars: # fullSamples = 0 +colvars: # inputPrefix = [default] +colvars: # historyFreq = 0 [default] +colvars: # shared = off [default] +colvars: # maxForce = [default] +colvars: # CZARestimator = on [default] +colvars: # integrate = on [default] +colvars: # UIestimator = off [default] +colvars: Finished ABF setup. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables biases initialized, 1 in total. +colvars: ---------------------------------------------------------------------- +colvars: Collective variables module (re)initialized. +colvars: ---------------------------------------------------------------------- +colvars: Updating NAMD interface: +colvars: updating atomic data (0 atoms). +colvars: updating group data (4 scalable groups, 16 atoms in total). +colvars: updating grid object data (0 grid objects in total). +colvars: +colvars: SUMMARY OF COLVARS FEATURES USED SO FAR AND THEIR CITATIONS: +colvars: +colvars: - Colvars module: +colvars: - Colvars-NAMD interface: +colvars: - Optimal rotation via flexible fitting: +colvars: - dihedral colvar component: +colvars: Fiorin2013 https://doi.org/10.1080/00268976.2013.813594 +colvars: +colvars: - ABF colvar bias implementation: +colvars: Henin2010 https://doi.org/10.1021/ct9004432 +colvars: +colvars: - CZAR eABF estimator: +colvars: - eABF implementation: +colvars: Lesage2017 https://doi.org/10.1021/acs.jpcb.6b10055 +colvars: +colvars: - NAMD engine: +colvars: - Scalable center-of-mass computation (NAMD): +colvars: Phillips2020 https://doi.org/10.1063/5.0014475 +colvars: +colvars: - torchANN colvar component: +colvars: n/a +colvars: +colvars: updating target temperature (T = 0 K). +colvars: ---------------------------------------------------------------------- +colvars: Loading state from file "test.colvars.state". +colvars: Restarting collective variable "nn_0" from value: 60.3181 +colvars: Restarting abf bias "abf1" from step number 0. +colvars: ---------------------------------------------------------------------- +colvars: Updating NAMD interface: +colvars: updating atomic data (0 atoms). +colvars: updating group data (4 scalable groups, 16 atoms in total). +colvars: updating grid object data (0 grid objects in total). +colvars: updating target temperature (T = 0 K). +colvars: Re-initialized atom group for variable "nn_0":0/0. 4 atoms: total mass = 54.028, total charge = -0.72. +colvars: Re-initialized atom group for variable "nn_0":0/1. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/2. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: Re-initialized atom group for variable "nn_0":0/3. 4 atoms: total mass = 54.028, total charge = -0.4. +colvars: The restart output state file will be "test.restart.tmp.colvars.state". +colvars: The final output state file will be "test.restart.colvars.state". +colvars: Prepared sample and gradient buffers at step 20. +colvars: Synchronizing (emptying the buffer of) trajectory file "test.restart.colvars.traj". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.restart.colvars.traj". +colvars: Saving collective variables state to "test.restart.tmp.colvars.state". +colvars: Synchronizing (emptying the buffer of) trajectory file "test.restart.colvars.traj". +colvars: Saving collective variables state to "test.restart.tmp.colvars.state". +colvars: Saving collective variables state to "test.restart.colvars.state". diff --git a/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.state.stripped b/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.state.stripped new file mode 100644 index 000000000..0d53e75a0 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.state.stripped @@ -0,0 +1,63 @@ +configuration { + step 40 + dt 1.000000e+00 +} + +colvar { + name nn_0 + x 6.10928497232544e+01 + extended_x 6.30822534838836e+01 + extended_v -9.27365358158408e-03 +} + +abf { + configuration { + step 40 + name abf1 + } + +samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 40 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +gradient + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 4.37003484947485e-02 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + +z_samples + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 40 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 + +z_gradient + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 4.37003484947485e-02 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 + 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 0.00000000000000e+00 +} + diff --git a/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.traj b/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.traj new file mode 100644 index 000000000..9a3b245b2 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.restart.colvars.traj @@ -0,0 +1,22 @@ +# step nn_0 r_nn_0 + 20 6.03180709798566e+01 6.32059993002439e+01 + 21 6.02933940366307e+01 6.31972487403216e+01 + 22 6.02918651376722e+01 6.31749648990958e+01 + 23 6.03111781818707e+01 6.31619154771102e+01 + 24 6.03485971886878e+01 6.31466338086565e+01 + 25 6.04011294265083e+01 6.31383554674303e+01 + 26 6.04656826759230e+01 6.31258359575602e+01 + 27 6.05391782009168e+01 6.31154615685509e+01 + 28 6.06186227370198e+01 6.30991859720543e+01 + 29 6.07011318959895e+01 6.30782435910137e+01 + 30 6.07839234617788e+01 6.30623857291809e+01 + 31 6.08642980309294e+01 6.30536306422912e+01 + 32 6.09396216109374e+01 6.30490225504585e+01 + 33 6.10073291205745e+01 6.30424814830796e+01 + 34 6.10649594135405e+01 6.30422486396636e+01 + 35 6.11102265573578e+01 6.30552342613269e+01 + 36 6.11411071204466e+01 6.30659169588987e+01 + 37 6.11559144998929e+01 6.30776739719732e+01 + 38 6.11533494140551e+01 6.30886654644616e+01 + 39 6.11325074986868e+01 6.30915271374652e+01 + 40 6.10928497232544e+01 6.30822534838836e+01 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.restart.count b/namd/tests/library/000_torchann/AutoDiff/test.restart.count new file mode 100644 index 000000000..26baf3500 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.restart.count @@ -0,0 +1,75 @@ +# 1 +# -1.80000000000000e+02 5.00000000000000e+00 72 1 + + -1.77500000000000e+02 0 + -1.72500000000000e+02 0 + -1.67500000000000e+02 0 + -1.62500000000000e+02 0 + -1.57500000000000e+02 0 + -1.52500000000000e+02 0 + -1.47500000000000e+02 0 + -1.42500000000000e+02 0 + -1.37500000000000e+02 0 + -1.32500000000000e+02 0 + -1.27500000000000e+02 0 + -1.22500000000000e+02 0 + -1.17500000000000e+02 0 + -1.12500000000000e+02 0 + -1.07500000000000e+02 0 + -1.02500000000000e+02 0 + -9.75000000000000e+01 0 + -9.25000000000000e+01 0 + -8.75000000000000e+01 0 + -8.25000000000000e+01 0 + -7.75000000000000e+01 0 + -7.25000000000000e+01 0 + -6.75000000000000e+01 0 + -6.25000000000000e+01 0 + -5.75000000000000e+01 0 + -5.25000000000000e+01 0 + -4.75000000000000e+01 0 + -4.25000000000000e+01 0 + -3.75000000000000e+01 0 + -3.25000000000000e+01 0 + -2.75000000000000e+01 0 + -2.25000000000000e+01 0 + -1.75000000000000e+01 0 + -1.25000000000000e+01 0 + -7.50000000000000e+00 0 + -2.50000000000000e+00 0 + 2.50000000000000e+00 0 + 7.50000000000000e+00 0 + 1.25000000000000e+01 0 + 1.75000000000000e+01 0 + 2.25000000000000e+01 0 + 2.75000000000000e+01 0 + 3.25000000000000e+01 0 + 3.75000000000000e+01 0 + 4.25000000000000e+01 0 + 4.75000000000000e+01 0 + 5.25000000000000e+01 0 + 5.75000000000000e+01 0 + 6.25000000000000e+01 40 + 6.75000000000000e+01 0 + 7.25000000000000e+01 0 + 7.75000000000000e+01 0 + 8.25000000000000e+01 0 + 8.75000000000000e+01 0 + 9.25000000000000e+01 0 + 9.75000000000000e+01 0 + 1.02500000000000e+02 0 + 1.07500000000000e+02 0 + 1.12500000000000e+02 0 + 1.17500000000000e+02 0 + 1.22500000000000e+02 0 + 1.27500000000000e+02 0 + 1.32500000000000e+02 0 + 1.37500000000000e+02 0 + 1.42500000000000e+02 0 + 1.47500000000000e+02 0 + 1.52500000000000e+02 0 + 1.57500000000000e+02 0 + 1.62500000000000e+02 0 + 1.67500000000000e+02 0 + 1.72500000000000e+02 0 + 1.77500000000000e+02 0 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.restart.grad b/namd/tests/library/000_torchann/AutoDiff/test.restart.grad new file mode 100644 index 000000000..2e0c18645 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.restart.grad @@ -0,0 +1,75 @@ +# 1 +# -1.80000000000000e+02 5.00000000000000e+00 72 1 + + -1.77500000000000e+02 0.00000000000000e+00 + -1.72500000000000e+02 0.00000000000000e+00 + -1.67500000000000e+02 0.00000000000000e+00 + -1.62500000000000e+02 0.00000000000000e+00 + -1.57500000000000e+02 0.00000000000000e+00 + -1.52500000000000e+02 0.00000000000000e+00 + -1.47500000000000e+02 0.00000000000000e+00 + -1.42500000000000e+02 0.00000000000000e+00 + -1.37500000000000e+02 0.00000000000000e+00 + -1.32500000000000e+02 0.00000000000000e+00 + -1.27500000000000e+02 0.00000000000000e+00 + -1.22500000000000e+02 0.00000000000000e+00 + -1.17500000000000e+02 0.00000000000000e+00 + -1.12500000000000e+02 0.00000000000000e+00 + -1.07500000000000e+02 0.00000000000000e+00 + -1.02500000000000e+02 0.00000000000000e+00 + -9.75000000000000e+01 0.00000000000000e+00 + -9.25000000000000e+01 0.00000000000000e+00 + -8.75000000000000e+01 0.00000000000000e+00 + -8.25000000000000e+01 0.00000000000000e+00 + -7.75000000000000e+01 0.00000000000000e+00 + -7.25000000000000e+01 0.00000000000000e+00 + -6.75000000000000e+01 0.00000000000000e+00 + -6.25000000000000e+01 0.00000000000000e+00 + -5.75000000000000e+01 0.00000000000000e+00 + -5.25000000000000e+01 0.00000000000000e+00 + -4.75000000000000e+01 0.00000000000000e+00 + -4.25000000000000e+01 0.00000000000000e+00 + -3.75000000000000e+01 0.00000000000000e+00 + -3.25000000000000e+01 0.00000000000000e+00 + -2.75000000000000e+01 0.00000000000000e+00 + -2.25000000000000e+01 0.00000000000000e+00 + -1.75000000000000e+01 0.00000000000000e+00 + -1.25000000000000e+01 0.00000000000000e+00 + -7.50000000000000e+00 0.00000000000000e+00 + -2.50000000000000e+00 0.00000000000000e+00 + 2.50000000000000e+00 0.00000000000000e+00 + 7.50000000000000e+00 0.00000000000000e+00 + 1.25000000000000e+01 0.00000000000000e+00 + 1.75000000000000e+01 0.00000000000000e+00 + 2.25000000000000e+01 0.00000000000000e+00 + 2.75000000000000e+01 0.00000000000000e+00 + 3.25000000000000e+01 0.00000000000000e+00 + 3.75000000000000e+01 0.00000000000000e+00 + 4.25000000000000e+01 0.00000000000000e+00 + 4.75000000000000e+01 0.00000000000000e+00 + 5.25000000000000e+01 0.00000000000000e+00 + 5.75000000000000e+01 0.00000000000000e+00 + 6.25000000000000e+01 4.37003484947485e-02 + 6.75000000000000e+01 0.00000000000000e+00 + 7.25000000000000e+01 0.00000000000000e+00 + 7.75000000000000e+01 0.00000000000000e+00 + 8.25000000000000e+01 0.00000000000000e+00 + 8.75000000000000e+01 0.00000000000000e+00 + 9.25000000000000e+01 0.00000000000000e+00 + 9.75000000000000e+01 0.00000000000000e+00 + 1.02500000000000e+02 0.00000000000000e+00 + 1.07500000000000e+02 0.00000000000000e+00 + 1.12500000000000e+02 0.00000000000000e+00 + 1.17500000000000e+02 0.00000000000000e+00 + 1.22500000000000e+02 0.00000000000000e+00 + 1.27500000000000e+02 0.00000000000000e+00 + 1.32500000000000e+02 0.00000000000000e+00 + 1.37500000000000e+02 0.00000000000000e+00 + 1.42500000000000e+02 0.00000000000000e+00 + 1.47500000000000e+02 0.00000000000000e+00 + 1.52500000000000e+02 0.00000000000000e+00 + 1.57500000000000e+02 0.00000000000000e+00 + 1.62500000000000e+02 0.00000000000000e+00 + 1.67500000000000e+02 0.00000000000000e+00 + 1.72500000000000e+02 0.00000000000000e+00 + 1.77500000000000e+02 0.00000000000000e+00 diff --git a/namd/tests/library/000_torchann/AutoDiff/test.restart.pmf b/namd/tests/library/000_torchann/AutoDiff/test.restart.pmf new file mode 100644 index 000000000..024e82b47 --- /dev/null +++ b/namd/tests/library/000_torchann/AutoDiff/test.restart.pmf @@ -0,0 +1,75 @@ +# 1 +# -1.82500000000000e+02 5.00000000000000e+00 72 1 + + -1.80000000000000e+02 1.45667828315828e-01 + -1.75000000000000e+02 1.42633081892582e-01 + -1.70000000000000e+02 1.39598335469336e-01 + -1.65000000000000e+02 1.36563589046089e-01 + -1.60000000000000e+02 1.33528842622843e-01 + -1.55000000000000e+02 1.30494096199596e-01 + -1.50000000000000e+02 1.27459349776350e-01 + -1.45000000000000e+02 1.24424603353103e-01 + -1.40000000000000e+02 1.21389856929857e-01 + -1.35000000000000e+02 1.18355110506611e-01 + -1.30000000000000e+02 1.15320364083364e-01 + -1.25000000000000e+02 1.12285617660118e-01 + -1.20000000000000e+02 1.09250871236871e-01 + -1.15000000000000e+02 1.06216124813625e-01 + -1.10000000000000e+02 1.03181378390378e-01 + -1.05000000000000e+02 1.00146631967132e-01 + -1.00000000000000e+02 9.71118855438856e-02 + -9.50000000000000e+01 9.40771391206392e-02 + -9.00000000000000e+01 9.10423926973928e-02 + -8.50000000000000e+01 8.80076462741464e-02 + -8.00000000000000e+01 8.49728998508999e-02 + -7.50000000000000e+01 8.19381534276535e-02 + -7.00000000000000e+01 7.89034070044071e-02 + -6.50000000000000e+01 7.58686605811606e-02 + -6.00000000000000e+01 7.28339141579142e-02 + -5.50000000000000e+01 6.97991677346678e-02 + -5.00000000000000e+01 6.67644213114214e-02 + -4.50000000000000e+01 6.37296748881749e-02 + -4.00000000000000e+01 6.06949284649285e-02 + -3.50000000000000e+01 5.76601820416821e-02 + -3.00000000000000e+01 5.46254356184356e-02 + -2.50000000000000e+01 5.15906891951892e-02 + -2.00000000000000e+01 4.85559427719428e-02 + -1.50000000000000e+01 4.55211963486963e-02 + -1.00000000000000e+01 4.24864499254499e-02 + -5.00000000000000e+00 3.94517035022035e-02 + 0.00000000000000e+00 3.64169570789571e-02 + 5.00000000000000e+00 3.33822106557106e-02 + 1.00000000000000e+01 3.03474642324642e-02 + 1.50000000000000e+01 2.73127178092178e-02 + 2.00000000000000e+01 2.42779713859713e-02 + 2.50000000000000e+01 2.12432249627249e-02 + 3.00000000000000e+01 1.82084785394785e-02 + 3.50000000000000e+01 1.51737321162321e-02 + 4.00000000000000e+01 1.21389856929857e-02 + 4.50000000000000e+01 9.10423926973924e-03 + 5.00000000000000e+01 6.06949284649283e-03 + 5.50000000000000e+01 3.03474642324641e-03 + 6.00000000000000e+01 0.00000000000000e+00 + 6.50000000000000e+01 2.15466996050496e-01 + 7.00000000000000e+01 2.12432249627250e-01 + 7.50000000000000e+01 2.09397503204003e-01 + 8.00000000000000e+01 2.06362756780757e-01 + 8.50000000000000e+01 2.03328010357511e-01 + 9.00000000000000e+01 2.00293263934264e-01 + 9.50000000000000e+01 1.97258517511018e-01 + 1.00000000000000e+02 1.94223771087771e-01 + 1.05000000000000e+02 1.91189024664525e-01 + 1.10000000000000e+02 1.88154278241278e-01 + 1.15000000000000e+02 1.85119531818032e-01 + 1.20000000000000e+02 1.82084785394786e-01 + 1.25000000000000e+02 1.79050038971539e-01 + 1.30000000000000e+02 1.76015292548293e-01 + 1.35000000000000e+02 1.72980546125046e-01 + 1.40000000000000e+02 1.69945799701800e-01 + 1.45000000000000e+02 1.66911053278553e-01 + 1.50000000000000e+02 1.63876306855307e-01 + 1.55000000000000e+02 1.60841560432061e-01 + 1.60000000000000e+02 1.57806814008814e-01 + 1.65000000000000e+02 1.54772067585568e-01 + 1.70000000000000e+02 1.51737321162321e-01 + 1.75000000000000e+02 1.48702574739075e-01 diff --git a/namd/tests/library/000_torchann/build_torch_model.py b/namd/tests/library/000_torchann/build_torch_model.py new file mode 100644 index 000000000..3b6f56def --- /dev/null +++ b/namd/tests/library/000_torchann/build_torch_model.py @@ -0,0 +1,12 @@ +import torch + +class MyModel(torch.nn.Module): + def __init__(self): + super().__init__() + def forward(self, x): + return x + +model = MyModel() +scripted_cv_filename = f'./identity.pt' +torch.jit.script(model).save(scripted_cv_filename) + diff --git a/namd/tests/library/000_torchann/identity.pt b/namd/tests/library/000_torchann/identity.pt new file mode 100644 index 000000000..1884b3752 Binary files /dev/null and b/namd/tests/library/000_torchann/identity.pt differ diff --git a/namd/tests/library/000_torchann/namd-version.txt b/namd/tests/library/000_torchann/namd-version.txt new file mode 100644 index 000000000..55d1740da --- /dev/null +++ b/namd/tests/library/000_torchann/namd-version.txt @@ -0,0 +1,3 @@ +Info: NAMD Git-2022-05-10 for Linux-x86_64-multicore +colvars: Initializing the collective variables module, version 2023-08-21. +colvars: Using NAMD interface, version "2023-07-06". diff --git a/namd/tests/library/000_torchann/test.in b/namd/tests/library/000_torchann/test.in new file mode 100755 index 000000000..64c3f3751 --- /dev/null +++ b/namd/tests/library/000_torchann/test.in @@ -0,0 +1,42 @@ +colvarsTrajFrequency 1 +colvarsRestartFrequency 10 +indexFile index.ndx + +colvar { + name nn_0 + lowerBoundary -180.0 + upperBoundary 180 + width 5.0 + extendedLagrangian on + extendedFluctuation 5.0 + extendedTimeConstant 200 + extendedTemp 300 + + torchann { + modelFile identity.pt + m_output_index 0 + period 360 + doubleInputTensor on + + dihedral { + group1 { + indexGroup group1 + } + group2 { + indexGroup group2 + } + group3 { + indexGroup group3 + } + group4 { + indexGroup group4 + } + } + } +} + +abf { + colvars nn_0 + fullSamples 0 +} + diff --git a/namd/tests/library/run_tests.sh b/namd/tests/library/run_tests.sh index 0fddf33c2..95f64c676 100755 --- a/namd/tests/library/run_tests.sh +++ b/namd/tests/library/run_tests.sh @@ -40,6 +40,8 @@ while [ $# -ge 1 ]; do shift done + + TOPDIR=$(git rev-parse --show-toplevel) if [ ! -d ${TOPDIR} ] ; then echo "Error: cannot identify top project directory." >& 2 @@ -113,6 +115,8 @@ cleanup_files() { declare -a failed_tests declare -a failed_tests_low_prec +TORCH_LINKED=false +if { ldd $(which $BINARY) | grep -q libtorch[_a-zA-Z]*.so ; } then TORCH_LINKED=true ; fi for dir in ${DIRLIST} ; do @@ -120,6 +124,11 @@ for dir in ${DIRLIST} ; do continue fi + if echo ${dir} | grep -q torchann && [ ${TORCH_LINKED} != "true" ] ; then + echo "Directory ${dir} skipped." + continue + fi + echo -ne "Entering $(${TPUT_BLUE})${dir}$(${TPUT_CLEAR}) ..." cd $dir diff --git a/src/Makefile b/src/Makefile index 96ba79d22..eebc27403 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ COLVARS_OBJS := $(COLVARS_SRCS:.cpp=.o) $(LEPTON_OBJS) $(CXX) $(CXXFLAGS) $(COLVARS_INCFLAGS) $(LEPTON_INCFLAGS) -c -o $@ $< $(COLVARS_LIB): Makefile.deps $(COLVARS_OBJS) - $(AR) $(ARFLAGS) $(COLVARS_LIB) $(COLVARS_OBJS) $(LEPTON_OBJS) + $(AR) $(ARFLAGS) $(COLVARS_LIB) $(COLVARS_OBJS) $(LEPTON_OBJS) Makefile.deps: $(COLVARS_SRCS) @echo > $@ diff --git a/src/colvar.cpp b/src/colvar.cpp index 765454845..7e85eeb3b 100644 --- a/src/colvar.cpp +++ b/src/colvar.cpp @@ -21,6 +21,7 @@ #include "colvarbias.h" #include "colvars_memstream.h" +#include "colvarcomp_torchann.h" std::map> colvar::global_cvc_map = std::map>(); @@ -922,6 +923,8 @@ void colvar::define_component_types() add_component_type("neural network CV for other CVs", "neuralNetwork"); + add_component_type("CV defined by PyTorch artifical neural network models", "torchANN"); + if (proxy->check_volmaps_available() == COLVARS_OK) { add_component_type("total value of atomic map", "mapTotal"); } diff --git a/src/colvar.h b/src/colvar.h index 8a8bd72b6..3c08b5cc5 100644 --- a/src/colvar.h +++ b/src/colvar.h @@ -639,6 +639,7 @@ class colvar : public colvarparse, public colvardeps { class euler_psi; class euler_theta; class neuralNetwork; + class torchANN; class customColvar; // non-scalar components diff --git a/src/colvarcomp_torchann.cpp b/src/colvarcomp_torchann.cpp new file mode 100644 index 000000000..a776c0fe6 --- /dev/null +++ b/src/colvarcomp_torchann.cpp @@ -0,0 +1,226 @@ +// -*- c++ -*- + +// This file is part of the Collective Variables module (Colvars). +// The original version of Colvars and its updates are located at: +// https://github.com/Colvars/colvars +// Please update all Colvars source files before making any changes. +// If you wish to distribute your changes, please submit them to the +// Colvars repository at GitHub. + +#include "colvar.h" +#include "colvarcomp.h" +#include "colvarmodule.h" +#include "colvarparse.h" +#include "colvarvalue.h" + +#include "colvarcomp_torchann.h" + +#ifdef COLVARS_TORCH + +colvar::torchANN::torchANN() +{ + set_function_type("torchANN"); + provide(f_cvc_periodic); +} + +colvar::torchANN::~torchANN() {} + + +int colvar::torchANN::init(std::string const &conf) { + + int error_code = linearCombination::init(conf); + + std::string model_file ; + get_keyval(conf, "modelFile", model_file, std::string("")); + try { + nn = torch::jit::load(model_file); + nn.to(torch::kCPU); + cvm::log("torch model loaded.") ; + } catch (const std::exception & e) { + return cvm::error("Error: couldn't load libtorch model (see below).\n" + cvm::to_str(e.what()), + COLVARS_INPUT_ERROR); + } + get_keyval(conf, "m_output_index", m_output_index, 0); + get_keyval(conf, "doubleInputTensor", use_double_input, false); + //get_keyval(conf, "useGPU", use_gpu, false); + + cvc_indices.resize(cv.size(),0); + + size_t num_inputs = 0; + // compute total number of inputs of neural network + for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) + { + num_inputs += cv[i_cv]->value().size() ; + if (i_cv < cv.size() - 1) + cvc_indices[i_cv+1] = num_inputs; + } + cvm::log("Input dimension of model: " + cvm::to_str(num_inputs)); + + // initialize the input tensor + auto options = torch::TensorOptions().dtype(torch::kFloat32).requires_grad(true); + + /* + if (use_gpu) { + if (torch::cuda::is_available()) { + try { + nn.to(torch::kCUDA); + } catch(const std::exception & e) { + cvm::error("Failed to move model to GPU."); + use_gpu = false; + } + } else { + use_gpu = false; + cvm::log("GPU not available."); + } + } + + if (use_gpu) { + options = options.device(torch::kCUDA); + if (use_double_input) { + cvm::log("Data type reset to Float for GPU computation!"); + use_double_input = false; + } + } + */ + + if (use_double_input) { // set type to double + options = options.dtype(torch::kFloat64); + nn.to(torch::kFloat64); + cvm::log("Model's dtype: kFloat64."); + } else { + cvm::log("Model's dtype: kFloat32."); + } + + input_tensor = torch::zeros({1,(long int) num_inputs}, options); + + try { // test the model + std::vector inputs={input_tensor}; + nn_outputs = nn.forward(inputs).toTensor()[0][m_output_index]; + cvm::log("Evaluating model with zero tensor succeeded."); + } catch (const std::exception & e) { + error_code |= cvm::error("Error: evaluating model with zero tensor failed (see below).\n" + + cvm::to_str(e.what()), + COLVARS_INPUT_ERROR); + } + + return error_code; +} + + +void colvar::torchANN::calc_value() { + + for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) + cv[i_cv]->calc_value(); + + /* + if (use_gpu) + input_tensor = input_tensor.to(torch::kCPU); + */ + + // set input tensor with no_grad + { + torch::NoGradGuard no_grad; + size_t l = 0; + for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) { + const colvarvalue& current_cv_value = cv[i_cv]->value(); + if (current_cv_value.type() == colvarvalue::type_scalar) { + input_tensor[0][l++] = cv[i_cv]->sup_coeff * (cvm::pow(current_cv_value.real_value, cv[i_cv]->sup_np)); + } else { + for (size_t j_elem = 0; j_elem < current_cv_value.size(); ++j_elem) + input_tensor[0][l++] = cv[i_cv]->sup_coeff * current_cv_value[j_elem]; + } + } + } + + /* + if (use_gpu) + input_tensor = input_tensor.to(torch::kCUDA); + */ + + std::vector inputs={input_tensor}; + + // evaluate the value of function + nn_outputs = nn.forward(inputs).toTensor()[0][m_output_index]; + + input_grad = torch::autograd::grad({nn_outputs}, {input_tensor})[0][0]; + + /* + if (use_gpu) + input_grad = input_grad.to(torch::kCPU); + */ + + x = nn_outputs.item() ; + + this->wrap(x); + +} + +void colvar::torchANN::calc_gradients() { + for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) { + cv[i_cv]->calc_gradients(); + if (cv[i_cv]->is_enabled(f_cvc_explicit_gradient)) { + const cvm::real factor_polynomial = getPolynomialFactorOfCVGradient(i_cv); + // get the initial index of this cvc + size_t l = cvc_indices[i_cv]; + for (size_t j_elem = 0; j_elem < cv[i_cv]->value().size(); ++j_elem) { + // get derivative of neural network wrt its input + const cvm::real factor = input_grad[l+j_elem].item(); + for (size_t k_ag = 0 ; k_ag < cv[i_cv]->atom_groups.size(); ++k_ag) { + for (size_t l_atom = 0; l_atom < (cv[i_cv]->atom_groups)[k_ag]->size(); ++l_atom) { + (*(cv[i_cv]->atom_groups)[k_ag])[l_atom].grad = factor_polynomial * factor * (*(cv[i_cv]->atom_groups)[k_ag])[l_atom].grad; + } + } + } + } + } +} + +void colvar::torchANN::apply_force(colvarvalue const &force) { + + for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) { + // If this CV uses explicit gradients, then atomic gradients is already calculated + // We can apply the force to atom groups directly + if (cv[i_cv]->is_enabled(f_cvc_explicit_gradient)) { + for (size_t k_ag = 0 ; k_ag < cv[i_cv]->atom_groups.size(); ++k_ag) { + (cv[i_cv]->atom_groups)[k_ag]->apply_colvar_force(force.real_value); + } + } else { + const colvarvalue& current_cv_value = cv[i_cv]->value(); + colvarvalue cv_force(current_cv_value); + cv_force.reset(); + const cvm::real factor_polynomial = getPolynomialFactorOfCVGradient(i_cv); + // get the initial index of this cvc + size_t l = cvc_indices[i_cv]; + for (size_t j_elem = 0; j_elem < current_cv_value.size(); ++j_elem) { + cv_force[j_elem] = factor_polynomial * input_grad[l+j_elem].item() * force.real_value; + } + cv[i_cv]->apply_force(cv_force); + } + } +} + + +#else + +colvar::torchANN::torchANN() +{ + set_function_type("torchANN"); +} + +colvar::torchANN::~torchANN() {} + +int colvar::torchANN::init(std::string const &conf) { + + return cvm::error( + "torchANN requires the libtorch library, but it is not enabled during compilation.\n" + "Please refer to the Compilation Notes section of the Colvars manual for more " + "information.\n", + COLVARS_NOT_IMPLEMENTED); + +} + +void colvar::torchANN::calc_value() +{ +} + +#endif diff --git a/src/colvarcomp_torchann.h b/src/colvarcomp_torchann.h new file mode 100644 index 000000000..216279e67 --- /dev/null +++ b/src/colvarcomp_torchann.h @@ -0,0 +1,64 @@ +// -*- c++ -*- + +// This file is part of the Collective Variables module (Colvars). +// The original version of Colvars and its updates are located at: +// https://github.com/Colvars/colvars +// Please update all Colvars source files before making any changes. +// If you wish to distribute your changes, please submit them to the +// Colvars repository at GitHub. +// +#ifndef COLVARCOMP_TORCH_H +#define COLVARCOMP_TORCH_H + +// Declaration of torchann + +#include + +#include "colvar.h" +#include "colvarcomp.h" +#include "colvarmodule.h" + +#ifdef COLVARS_TORCH + +#include +#include + +class colvar::torchANN + : public colvar::linearCombination +{ +protected: + torch::jit::script::Module nn; + /// the index of nn output component + size_t m_output_index; + bool use_double_input; + //bool use_gpu; + // 1d tensor, concatenation of values of sub-cvcs + torch::Tensor input_tensor; + torch::Tensor nn_outputs; + torch::Tensor input_grad; + // record the initial index of of sub-cvcs in input_tensor + std::vector cvc_indices; +public: + torchANN(); + virtual ~torchANN(); + virtual int init(std::string const &conf); + virtual void calc_value(); + virtual void calc_gradients(); + virtual void apply_force(colvarvalue const &force); +}; + +#else + +class colvar::torchANN + : public colvar::cvc +{ +public: + torchANN(); + virtual ~torchANN(); + virtual int init(std::string const &conf); + virtual void calc_value(); +}; +#endif // COLVARS_TORCH checking + +#endif + diff --git a/src/colvarmodule_refs.h b/src/colvarmodule_refs.h index a28666728..fa702a0a7 100644 --- a/src/colvarmodule_refs.h +++ b/src/colvarmodule_refs.h @@ -653,5 +653,8 @@ feature_count_[std::string("Scripted functions (Tcl)")] = 0; feature_paper_map_[std::string("Scripted functions (Tcl)")] = "n/a"; + feature_count_[std::string("torchANN colvar component")] = 0; + feature_paper_map_[std::string("torchANN colvar component")] = "n/a"; + feature_count_[std::string("ABMD bias")] = 0; feature_paper_map_[std::string("ABMD bias")] = "n/a"; diff --git a/tests/build_tests.sh b/tests/build_tests.sh index 0485d6ac6..833afb149 100755 --- a/tests/build_tests.sh +++ b/tests/build_tests.sh @@ -216,6 +216,7 @@ for colvar in \ "tilt" \ "spinangle" \ "selfcoordnum" "selfcoordnum-pairlist" \ + "torchann-dihedral" \ "orientationangle" "orientationproj" \ ; do for bias in \ diff --git a/tests/input_files/identity.pt b/tests/input_files/identity.pt new file mode 100644 index 000000000..1884b3752 Binary files /dev/null and b/tests/input_files/identity.pt differ diff --git a/tests/input_files/torchann-dihedral_harmonic-fixed/build_torch_model.py b/tests/input_files/torchann-dihedral_harmonic-fixed/build_torch_model.py new file mode 100644 index 000000000..3b6f56def --- /dev/null +++ b/tests/input_files/torchann-dihedral_harmonic-fixed/build_torch_model.py @@ -0,0 +1,12 @@ +import torch + +class MyModel(torch.nn.Module): + def __init__(self): + super().__init__() + def forward(self, x): + return x + +model = MyModel() +scripted_cv_filename = f'./identity.pt' +torch.jit.script(model).save(scripted_cv_filename) + diff --git a/tests/input_files/torchann-dihedral_harmonic-fixed/test.in b/tests/input_files/torchann-dihedral_harmonic-fixed/test.in new file mode 100644 index 000000000..47a51d667 --- /dev/null +++ b/tests/input_files/torchann-dihedral_harmonic-fixed/test.in @@ -0,0 +1,42 @@ +colvarsTrajFrequency 1 +colvarsRestartFrequency 10 +indexFile index.ndx + +colvar { + name one + lowerBoundary -180.0 + upperBoundary 180 + width 5.0 + extendedLagrangian on + extendedFluctuation 5.0 + extendedTimeConstant 200 + extendedTemp 300 + + torchann { + modelFile identity.pt + m_output_index 0 + period 360 + doubleInputTensor on + + dihedral { + group1 { + indexGroup group1 + } + group2 { + indexGroup group2 + } + group3 { + indexGroup group3 + } + group4 { + indexGroup group4 + } + } + } +} + +harmonic { + colvars one + centers 0.1 + forceConstant 0.001 +} diff --git a/tests/torchann-dihedral.in b/tests/torchann-dihedral.in new file mode 100644 index 000000000..8f955dbfb --- /dev/null +++ b/tests/torchann-dihedral.in @@ -0,0 +1,33 @@ +colvar { + name one + lowerBoundary -180.0 + upperBoundary 180 + width 5.0 + extendedLagrangian on + extendedFluctuation 5.0 + extendedTimeConstant 200 + extendedTemp 300 + + torchann { + modelFile identity.pt + m_output_index 0 + period 360 + doubleInputTensor on + + dihedral { + group1 { + indexGroup group1 + } + group2 { + indexGroup group2 + } + group3 { + indexGroup group3 + } + group4 { + indexGroup group4 + } + } + } +} + diff --git a/vmd/src/colvars_files.pl b/vmd/src/colvars_files.pl index 75142015e..d362c72f9 100644 --- a/vmd/src/colvars_files.pl +++ b/vmd/src/colvars_files.pl @@ -24,6 +24,7 @@ 'colvar.C', 'colvarcomp_neuralnetwork.C', 'colvar_neuralnetworkcompute.C', + 'colvarcomp_torchann.C', 'colvarcomp.C', 'colvarcomp_alchlambda.C', 'colvarcomp_angles.C', @@ -71,6 +72,7 @@ 'colvarbias_restraint.h', 'colvarbias_opes.h', 'colvarcomp.h', + 'colvarcomp_torchann.h', 'colvardeps.h', 'colvargrid.h', 'colvargrid_def.h',