Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 0573ac2
Merge: 2b3f2a2 c2bdeb9
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jan 17 16:11:14 2024 +0100

    Merge branch 'master' into new_abf_for_merging

commit 2b3f2a2
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jan 17 16:03:57 2024 +0100

    Remove exptl feature linABF for now

    Needs to be better tested and documented

commit fc86e9a
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jan 5 17:57:00 2024 +0100

    Fix memory issues found by ASAN

    - alloc-dealloc mismatch
    - missing deallocation of features in derived class colvarbias_abf

commit f885638
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jan 5 17:42:45 2024 +0100

    Amend mwABF test script for NAMD-netlrts

commit e1bf0c0
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jan 5 17:12:07 2024 +0100

    Update mwABF documentation

commit c88525b
Merge: 15a4097 6bb881b
Author: Jérôme Hénin <[email protected]>
Date:   Wed Nov 29 12:15:33 2023 +0100

    Merge branch 'master' into new_abf_for_merging

commit 15a4097
Author: Jérôme Hénin <[email protected]>
Date:   Wed Nov 1 21:39:39 2023 +0100

    Adjust regtest for correct behavior of new ABF code

    as in d4b2b4c

commit 0aca6e8
Author: Jérôme Hénin <[email protected]>
Date:   Tue Oct 31 19:06:54 2023 +0100

    Appease compiler warnings

    - "possible" memory leak (really not possible, but what can I do)
    - "garbage values" which weren't but it took some persuading
    - hidden variable (that was actually a nice catch by the Sun compiler)

commit 0524fcc
Author: Jérôme Hénin <[email protected]>
Date:   Tue Oct 31 17:52:04 2023 +0100

    Add missing override qualifiers

commit 5a2c41a
Author: Jérôme Hénin <[email protected]>
Date:   Mon Oct 30 15:27:37 2023 +0100

    Remove branch README

commit 2e37866
Author: Jérôme Hénin <[email protected]>
Date:   Mon Oct 30 15:24:19 2023 +0100

    Add include for smart pointers

commit 0e3ff84
Author: Jérôme Hénin <[email protected]>
Date:   Mon Oct 30 11:38:31 2023 +0100

    Remove redundant lines from merge

commit 26cf5e8
Author: Jérôme Hénin <[email protected]>
Date:   Thu Oct 26 17:27:55 2023 +0200

    Remove dead code

    from ABF: adaptation_time, weights

commit d4b2b4c
Author: Jérôme Hénin <[email protected]>
Date:   Thu Oct 26 16:46:59 2023 +0200

    Adjust regtest reference for new ABF code

    The new code has the correct behavior, which is to ignore the duplicate
    total force value obtained at the beginning of a second run statement.

commit 6cb1f19
Author: Jérôme Hénin <[email protected]>
Date:   Thu Oct 26 14:50:49 2023 +0200

    Remove unnecessary include

commit ee34329
Author: Jérôme Hénin <[email protected]>
Date:   Wed Oct 18 17:19:49 2023 +0200

    Fix typos

commit fdc5fb5
Author: Jérôme Hénin <[email protected]>
Date:   Wed Oct 18 17:15:09 2023 +0200

    Merge changes to NAMD tests from master

commit 268f63c
Author: Jérôme Hénin <[email protected]>
Date:   Fri Oct 13 16:58:57 2023 +0200

    Remove experimental ABF-AR features

commit 32719e5
Merge: 1d5c2d9 46f1d6d
Author: Jérôme Hénin <[email protected]>
Date:   Fri Oct 13 11:30:16 2023 +0200

    Merge branch 'master' into new_abf_for_merging

commit 1d5c2d9
Merge: e396b02 7318e2c
Author: Jérôme Hénin <[email protected]>
Date:   Fri Oct 6 19:03:12 2023 +0200

    Merge branch 'master' into new_abf_for_merging

commit e396b02
Merge: 5e01a4f ab60dcb
Author: Jérôme Hénin <[email protected]>
Date:   Fri Oct 6 16:38:57 2023 +0200

    Merge branch 'master' into new_abf_for_merging

commit 5e01a4f
Author: Jérôme Hénin <[email protected]>
Date:   Fri Nov 11 23:55:02 2022 +0100

    Make ABF grids unique_ptr

commit 8efc8f6
Merge: 5e155e6 3af3d4e
Author: Jérôme Hénin <[email protected]>
Date:   Fri Nov 11 21:05:47 2022 +0100

    Merge branch 'master' into new_abf

commit 5e155e6
Author: Jérôme Hénin <[email protected]>
Date:   Fri Aug 12 23:28:59 2022 +0200

    Initial version of README for branch changes

commit 3bb83e2
Author: Jérôme Hénin <[email protected]>
Date:   Fri Aug 12 23:17:24 2022 +0200

    Remove uninitialized b_linabf Boolean

commit 19a7464
Merge: b215af1 732a460
Author: Jérôme Hénin <[email protected]>
Date:   Fri Aug 12 22:17:35 2022 +0200

    Merge branch 'master' into new_abf

commit b215af1
Author: Jérôme Hénin <[email protected]>
Date:   Tue Mar 29 18:14:00 2022 +0200

    Add one more fragment lost in merge

    (alternate integrate potential constructor)

commit 44dc35c
Author: Jérôme Hénin <[email protected]>
Date:   Tue Mar 29 18:05:00 2022 +0200

    Update script doc

commit d0cb0ba
Merge: 7770165 3d6c0e6
Author: Jérôme Hénin <[email protected]>
Date:   Tue Mar 29 17:38:17 2022 +0200

    Merge branch 'master' into new_abf

commit 7770165
Author: Jérôme Hénin <[email protected]>
Date:   Mon Mar 28 14:37:35 2022 +0200

    Add fragment lost in merge

commit 37b4124
Author: Jérôme Hénin <[email protected]>
Date:   Thu Mar 24 19:02:54 2022 +0100

    Fix error introduced by merge

commit 6255aa4
Author: Jérôme Hénin <[email protected]>
Date:   Thu Mar 24 18:54:33 2022 +0100

    Fix compiler warnings

commit 420eda8
Merge: ac0d189 f2a0dff
Author: Jérôme Hénin <[email protected]>
Date:   Thu Mar 24 18:31:52 2022 +0100

    Merge branch 'master' into new_abf

commit ac0d189
Author: Jérôme Hénin <[email protected]>
Date:   Mon Jun 28 14:44:15 2021 +0200

    WIP on ABF-AX: communicate and store local data

commit f0c836f
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jun 23 14:44:10 2021 +0200

    WIP on mwABF-AX

commit 115f946
Author: Jérôme Hénin <[email protected]>
Date:   Sun Dec 20 20:57:51 2020 +0100

    First version of Adiabatic Exploration

commit e43c8aa
Author: Jérôme Hénin <[email protected]>
Date:   Fri Nov 6 11:40:58 2020 +0100

    Parse updateBias after ABF-AR

commit 2df66d3
Author: Jérôme Hénin <[email protected]>
Date:   Thu Nov 5 12:42:26 2020 +0100

    WIP

commit 6aa102c
Author: Jérôme Hénin <[email protected]>
Date:   Tue Oct 20 11:51:24 2020 +0200

    ABF-AR in dimension > 1

    Including lambda contributions beyond grid edges.

    also:
    - user control of minSamples
    - still playing with adaptation parameter of exploration bias
    - calculate ABF bias energy beyond grid edges

commit 9899787
Author: Jérôme Hénin <[email protected]>
Date:   Sat Oct 17 21:45:57 2020 +0200

    First step towards multidim ABF-AR

commit 4954706
Author: Jérôme Hénin <[email protected]>
Date:   Fri Oct 16 13:12:39 2020 +0200

    Reset ext coordinate after jumps in colvar

    this would in particular break mw-eABF with selection
    as the selection process creates jumps in Cartesian coords
    and hence in colvar values.

commit cb1c0f1
Author: Jérôme Hénin <[email protected]>
Date:   Thu Oct 8 17:00:17 2020 +0200

    Common smoothing functions for ABF and ABF-AR

    using either fullSamples or adaptationTime

    Also implemented choice of cosine or Gaussian kernel in ABF-AR

commit 641242b
Author: Jérôme Hénin <[email protected]>
Date:   Thu Oct 1 12:27:53 2020 +0200

    WIP on ABF-AR

    - handle special file names in colvars_grid.py
    - introduce cosine kernel
    - rename adaptationRate to adaptationTime

commit 57f7f25
Author: Jérôme Hénin <[email protected]>
Date:   Tue Sep 29 09:59:14 2020 +0200

    WIP on optimization of ABF-AR loop, BC

commit 79d7e6f
Author: Jérôme Hénin <[email protected]>
Date:   Sat Sep 26 17:46:44 2020 +0200

    Update NAMD ABF test ref output

    for proper handling of zero step data
    previous reference had redundant data for one step

commit c5ac01c
Author: Jérôme Hénin <[email protected]>
Date:   Sat Sep 26 17:42:50 2020 +0200

    Enable dependency tree items for ABF

    more generally, for derived classes of colvarbias

commit f871fed
Author: Jérôme Hénin <[email protected]>
Date:   Fri Sep 25 18:53:19 2020 +0200

    Add back missing changes after rebase

commit 9e487af
Author: Jérôme Hénin <[email protected]>
Date:   Tue Apr 7 22:30:59 2020 +0200

    Merge ABF output improvements from master

commit 1058851
Author: Jérôme Hénin <[email protected]>
Date:   Mon Sep 16 19:12:17 2019 +0200

    Merge name changes from master

commit 50aaa94
Author: Jérôme Hénin <[email protected]>
Date:   Wed Aug 1 19:14:32 2018 +0200

    Reorder ABF function

commit bd1723b
Author: Jérôme Hénin <[email protected]>
Date:   Wed Aug 1 19:01:41 2018 +0200

    Merge improvements from linabf branch

commit 687d6ab
Author: Jérôme Hénin <[email protected]>
Date:   Fri Mar 9 11:08:46 2018 +0100

    First impl. of lin-ABF

commit 21628ab
Author: Jérôme Hénin <[email protected]>
Date:   Fri Mar 2 17:02:40 2018 +0100

    First version of Spring ABF (ABF-UI)

commit cc9051e
Author: Jérôme Hénin <[email protected]>
Date:   Fri Mar 2 16:54:47 2018 +0100

    Another layer of ABF-AR

commit 6fea359
Author: Jérôme Hénin <[email protected]>
Date:   Wed Feb 28 11:54:48 2018 +0100

    WIP on ABF-AR: fullSamples

commit 8f78f8f
Author: Jérôme Hénin <[email protected]>
Date:   Mon Feb 26 17:45:06 2018 +0100

    Another layer of WIP on ABF-AR

commit 879a2cf
Author: Jérôme Hénin <[email protected]>
Date:   Sun Feb 25 00:53:07 2018 +0100

    WIP on ABF-AR

commit 31853a6
Author: Jérôme Hénin <[email protected]>
Date:   Fri Feb 23 16:49:29 2018 +0100

    First version of ABF-AR

    for now, only 1D, not calculating expectation of biasing force

commit 7377412
Author: Jérôme Hénin <[email protected]>
Date:   Wed Aug 26 15:50:26 2020 +0200

    as_array method for colvars_grid.py

commit ac2c347
Author: Jérôme Hénin <[email protected]>
Date:   Tue Aug 11 18:03:15 2020 +0200

    Add two methods ro colvars-grid python class

    scalar_array
    numerical_gradient (in 2d only)

commit f4a3361
Author: Jérôme Hénin <[email protected]>
Date:   Mon Aug 10 14:26:59 2020 +0200

    Undo regression in grid::wrap()

commit 2ba510e
Author: Jérôme Hénin <[email protected]>
Date:   Mon Aug 10 14:26:39 2020 +0200

    Do not create unnecessary temp grid when no CZAR

commit 3b51d4e
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jul 8 16:45:46 2020 +0200

    Fix grid_RMSD: special version for gradients

commit b052949
Author: Jérôme Hénin <[email protected]>
Date:   Tue Jul 7 20:15:03 2020 +0200

    Support for CZAR files in ABF_dataset class

    for post-analysis in Python

commit 2550358
Author: Jérôme Hénin <[email protected]>
Date:   Tue Jul 7 20:11:24 2020 +0200

    Radius sampling for mwABF selection in d>1

    Implemented at C++ level, exposing local_sample_count scripting command
    and deprecating bincount
    Results in simplified mwABF_selection script

commit 748b0af
Author: Jérôme Hénin <[email protected]>
Date:   Mon Jul 6 15:29:34 2020 +0200

    Remove pointer aliasing when deleting ABF bias

commit 9143a7f
Author: Jérôme Hénin <[email protected]>
Date:   Sun Jul 5 23:23:43 2020 +0200

    colvars_grid: add marginal_count function

commit 9a9c588
Author: Jérôme Hénin <[email protected]>
Date:   Sun Jul 5 23:21:51 2020 +0200

    Dashboard: warn about bogus PBC lengths

    from NAMD runs without PBC
    NAMD writes {1 1 1} as lengths into DCD files by default
    Offer to overwrite to avoid computing wrong colvar values

commit 44bfdcd
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jul 1 20:59:15 2020 +0200

    Print rmsd from global grad and pmf in mwABF

commit 014c0d1
Author: Jérôme Hénin <[email protected]>
Date:   Tue Jun 30 22:20:50 2020 +0200

    Fix logic to maintain local CZAR data separately

    in shared eABF

commit 40dc0ca
Author: Jérôme Hénin <[email protected]>
Date:   Tue Jun 30 11:04:23 2020 +0200

    Correctly integrate local PMF in shared ABF

commit b8227f1
Author: Jérôme Hénin <[email protected]>
Date:   Tue Jun 30 11:03:28 2020 +0200

    First version of ABF_dataset python class

commit f295673
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jun 26 17:06:53 2020 +0200

    Correct logic for shared eABF/CZAR

    esp. for allocating the right grids at the right time

commit c51c04c
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jun 26 17:06:05 2020 +0200

    Integrate can_accumulate_data into ABF

commit 960dc34
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jun 26 14:05:36 2020 +0200

    Allocate shared ABF grids at init time if possible

    avoids rare cases where shared_freq is more than output_freq and
    output is attempted from unallocated grids, leading to segfault.

commit eaa8f70
Author: Giacomo Fiorin <[email protected]>
Date:   Thu Jun 25 15:31:44 2020 -0400

    Add test for multiple run commands

commit de7ab2b
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jun 26 09:58:30 2020 +0200

    mwABF script doc update

commit 314a1aa
Author: Jérôme Hénin <[email protected]>
Date:   Fri Jun 26 00:27:11 2020 +0200

    Save local data per replica in shared ABF

commit 69f53fd
Author: Jérôme Hénin <[email protected]>
Date:   Thu Jun 25 19:17:35 2020 +0200

    Do not write ABF history files twice for same ts

commit a3884dc
Author: Jérôme Hénin <[email protected]>
Date:   Thu Jun 25 18:21:15 2020 +0200

    Do not do sharing from mwABF selection script

    instead, expect shared ABF to be setup in Colvars config. This allows
    for better timing of ABF sharing vs. file IO (share first, write output
    files second). This is necessary now that output files are not written a
    second time at the end of a run if it coincides with outputFreq.

    The Tcl script is now only in charge of selection. It did not take any
    particular decision regarding sharing anyway, just duplicates the
    shareFreq behavior.

commit 1c8f38d
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jun 24 15:11:43 2020 +0200

    Fixes for colvars_grid.py

commit 0449812
Author: Jérôme Hénin <[email protected]>
Date:   Thu Jun 18 22:45:24 2020 +0200

    Improvements to mwABF

    - do sharing before force update for better mw-pABF
    - WIP on collecting and outputting local data per replica for variance
    analysis

commit a08fe5d
Author: Jérôme Hénin <[email protected]>
Date:   Thu Jun 18 22:45:00 2020 +0200

    Improvements to colvars_grid python class

commit 5dc48fb
Author: Jérôme Hénin <[email protected]>
Date:   Wed Jun 17 13:32:40 2020 +0200

    Write output files after a 0-step simulation

commit 8f600c8
Author: Jérôme Hénin <[email protected]>
Date:   Thu May 28 23:56:37 2020 +0200

    mwABF improvements

    - refactor mwABF selection scripts into single file
    - provide proc run_mwABF_selection with as many reasonable defaults as possible
    - toggle shareOn when sharing via scripting commands
    - make selection work in dimension > 1
    - fix divide by zero bug when computing weights for selection
    - include "replicaUniformPatchGrids on" in selection script
    - share data for CZAR estimator if doing eABF
  • Loading branch information
jhenin committed Jan 18, 2024
1 parent c2bdeb9 commit 503cab3
Show file tree
Hide file tree
Showing 35 changed files with 2,052 additions and 1,229 deletions.
2 changes: 1 addition & 1 deletion colvartools/colvars_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class colvars_grid:
Gradient files contain as many data series as there are dimensions.
Data can be obtained in array shape with as_array()
# Example: 3d surface plot for a 2d free energy surface ("PMF"), with contour plot at z=0
# Example: 3d surface plot for a 2d free energy surface (PMF), with contour plot at z=0
from mpl_toolkits.mplot3d import Axes3D
pmf = colvars_grid('run.pmf')
fig = plt.figure()
Expand Down
207 changes: 207 additions & 0 deletions colvartools/mwABF_selection.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# Scripts for multiple-walker ABF in NAMD with selection rules

# NOTE: this script does not perform shared ABF - sharing must be enabled
# separately in the ABF configuration (shared on, sharedFreq xxx)

# Source in NAMD config, and call:
# run_mwABF $cycleNum $selectFreq ($sampleRad $percentStop $biasName)

# cycleNum Number of cycles of sharing ABF data to be performed
# selectFreq Number of timesteps between between rounds of replica selection
# NOTE: Total simulation time is cycleNum * selectFreq
# sampleRad Half-length (in bins) of the interval around the current position of a replica
# in which to count samples for selection purposes (default: 0)
# percentStop Relative difference (in percent) between lowest and highest sample counts
# below which no selection is performed (recommended range: 20 to 90, default: 40)
# biasName Name of the ABF bias to perform selection on (default: "abf1", Colvars default)

# Author: Jeff Comer <jeffcomer at gmail>
# Comer et al. JCTC 2014 https://doi.org/10.1021/ct500874p
# With improvements by Jérôme Hénin <jerome.henin at cnrs dot fr>

# The following is needed for exchanging coordinates between NAMD replicas
# but cannot be "set from script", ie after a scripting command has been run
# So this file should be sourced before any script command (cv, run etc.)
replicaUniformPatchGrids on


proc run_mwABF_selection { cycleNum selectFreq {sampleRad 0} {percentStop 40} {biasName "abf1"}} {

set repNum [numReplicas]
if { $repNum < 2 } {
print "Error: cannot perform shared ABF with fewer than 2 replicas.\nUse the +replicas command-line flag of NAMD (MPI build).\n\n"
exit 1
}
set rep [myReplica]
set ncolvars 1
# Parse ABF config to find out number of colvars
set config [cv bias $biasName getconfig]
if { [regexp -nocase {^\s*colvars\s+([^\s{}#]+)} $config match colvars] } {
set ncolvars [llength $colvars]
print "Shared ABF $biasName running on $ncolvars colvars: $colvars"
}

set s "REPLICA_SETUP"
foreach var {cycleNum selectFreq repNum rep sampleRad percentStop} {
set s "$s $var [set $var]"
}
print "$s"

for {set i 0} {$i < $cycleNum} {incr i} {
print "CYCLE $i"
# Run the steps until next selection
# Bias sharing is controlled by the ABF bias at the C++ level
run $selectFreq

set count [cv bias $biasName local_sample_count $sampleRad]

replicaBarrier
if {$rep > 0} {
## Send the count to Replica 0.
replicaSend $count 0
## Receive the source and destination replicas.
set srcDestList [replicaRecv 0]
} else {
## Build the weight list.
# The weight is the inverse count + 1 to avoid divide by 0
set weightList [list [expr {1.0/($count + 1)}]]
print "REPLICA_COUNT $rep $count"
set countMin $count
set countMax $count
for {set r 1} {$r < $repNum} {incr r} {
set repCount [replicaRecv $r]
print "REPLICA_COUNT $r $repCount"
if {$repCount < $countMin} {
set countMin $repCount
}
if {$repCount > $countMax} {
set countMax $repCount
}
# The weight is the inverse count + 1 to avoid divide by 0
lappend weightList [expr {1.0/($repCount + 1)}]
}

## Normalize the weight list.
set weightList [normalizeWeights $weightList]
set s "REPLICA_WEIGHT_LIST"
foreach w $weightList {
set s "$s [format " %.3g" $w]"
}
print $s

print "REPLICA_MINMAX $countMin $countMax"
if {$countMin < 1} {set countMin 1}
set percentDif [expr {(100*($countMax - $countMin))/$countMax}]

## Generate the list of exchanges "srcDestList"
if {$percentDif < $percentStop} {
print "REPLICA_SELECTION_DISABLED $percentDif"
## If the relative difference between the min and max counts
##is less than the threshold, we don't do exchanges.
set srcDestList {}
} else {
print "REPLICA_SELECTION_ENABLED $percentDif"
set cloneList [resampleWalkers $weightList]
print "REPLICA_CLONE_LIST $cloneList"

set srcDestList [resampleExchanges $cloneList]
}
## Replica 0 sends the srcDestList to all other replicas,
## so they know who to receive from and who to send to.
for {set r 1} {$r < $repNum} {incr r} {
replicaSend $srcDestList $r
}
} ;# End Replica 0 work

## Everyone should have an identical copy of the srcDestList.
if {[llength $srcDestList] > 0} {
print "REPLICA_SRC_DEST_LIST $srcDestList"
print "REPLICA_BARRIER"
replicaBarrier

# Do the coordinate exchanges if this replica is the source or destination.
foreach srcDest $srcDestList {
set src [lindex $srcDest 0]
set dest [lindex $srcDest 1]

if {$src == $rep} {
print "REPLICA_ATOM_SEND $dest"
replicaAtomSend $dest
} elseif {$dest == $rep} {
print "REPLICA_ATOM_RECV $src"
replicaAtomRecv $src
}
}
} else {
print "REPLICA_SRC_DEST_EMPTY"
}
}
return $i ;# Number of cycles completed
}

proc normalizeWeights {weightList} {
## Normalize the weights.
set weightSum 0.0
foreach weight $weightList {
set weightSum [expr {$weightSum + $weight}]
}

set r 0
set wnList {}
foreach weight $weightList {
lappend wnList [expr {double($weight)/$weightSum}]
incr r
}
return $wnList
}


# Determine the number of clones for each walker.
# Weights must be normalized.
proc resampleWalkers {weightList} {
set num [llength $weightList]

## Get the number of clones for each walker.
set wbar(0) [lindex $weightList 0]
set u [expr {rand()}]
set cloneList [list [expr { int($num*$wbar(0)+$u) }] ]
for {set r 1} {$r < $num} {incr r} {
set r0 [expr {$r-1}]
set wbar($r) [expr {$wbar($r0) + [lindex $weightList $r]}]
lappend cloneList [expr {int($num*$wbar($r)+$u) - int($num*$wbar($r0)+$u) }]
}
return $cloneList
}

# Determine the minimal exchanges that must be made to resample.
proc resampleExchanges {cloneList} {
## Make a list of exchanges.
set cloneZeroList {}
set cloneMultList {}
set r 0
foreach cloneNum $cloneList {
if {$cloneNum == 0} { lappend cloneZeroList $r }
if {$cloneNum > 1} { lappend cloneMultList $r }
incr r
}

# Is nothing cloned?
if {[llength $cloneZeroList] == 0} {
return {}
}

## Walkers cloned multiple times are copied to walkers cloned zero times.
## Make the list of exchanges srcDestList
set srcDestList {}
set zeroInd 0
foreach mult $cloneMultList {
# We get one clone just by leaving the walker where it is.
set extraNum [expr {[lindex $cloneList $mult]-1}]
for {set j 0} {$j < $extraNum} {incr j} {
set dest [lindex $cloneZeroList $zeroInd]
lappend srcDestList [list $mult $dest]
incr zeroInd
}
}
return $srcDestList
}
55 changes: 36 additions & 19 deletions doc/colvars-refman-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5552,35 +5552,52 @@
\end{itemize}
\cvnamdonly{
\cvsubsubsec{Multiple-replica ABF}{sec:colvarbias_abf_shared}
\cvsubsubsec{Multiple-walker ABF}{sec:colvarbias_abf_shared}
\label{sec:mw-ABF}
This implements the multiple-walker ABF scheme described in \cite{Minoukadeh2010}. The reference for this
implementation is \cite{Comer2014c}.
This feature requires that \MDENGINE be compiled and executed with multiple-replica
support.
If \refkey{shared}{abf|shared} is enabled, the total force samples will be synchronized among all replicas
at intervals defined by \refkey{sharedFreq}{abf|sharedFreq}.
Each replica maintains a separate buffer of total force samples that determine the biasing force.
Every \refkey{sharedFreq}{abf|sharedFreq} steps, the replicas communicate the samples that have been gathered since the last synchronization time, ensuring all replicas apply a similar biasing force.
Thus, it is as if total force samples among all replicas are gathered in a single shared buffer.
Shared ABF allows all replicas to benefit from the sampling done by other replicas and can lead to faster convergence of the biasing force.
An implementation of the selection mechanism described in \cite{Comer2014c} is provided as a set of Tcl scripts in \texttt{colvartools/mwABF\_selection.tcl} in the Colvars repository.
Compared with the initial implementation, the current implementation supports selection on sets of up to 3 colvars.
To reduce noise, samples can be counted in a hybercube around the current bin (see Tcl script for details).
A set of example NAMD inputs can be found in the \texttt{namd/tests/library/multiple\_walker\_abf} directory.
\paragraph{Output files of multiple-walker ABF.}
In multiple-walker ABF runs, each walker now outputs gradient and count files containing only data collected locally (this is a change in version 2024-01-06).
In addition, the first walker outputs the collected data using the common prefix, with an additional \texttt{".all"} string (i.e. file names ending with \texttt{".all.count"}, \texttt{".all.grad"} etc.).
\begin{itemize}
\item \keydef{shared}{\texttt{abf}}{%
Apply multiple-replica ABF, sharing force samples among the replicas?}
\item
\labelkey{abf|shared}
\keydef{shared}{\texttt{abf}}{%
Apply multiple-walker ABF, sharing force samples among the replicas?}
{boolean}
{\texttt{no}}
{ This is command requires that NAMD be compiled and executed with multiple-replica
support.
If \texttt{shared} is set to yes, the total force samples will be synchronized among all replicas
at intervals defined by \texttt{sharedFreq}.
This implements the multiple-walker ABF scheme described in \cite{Minoukadeh2010}; this
implementation is documented in \cite{Comer2014c}.
Thus, it is as if total force samples among all replicas are
gathered in a single shared buffer, which why the algorithm is referred to as shared ABF.
Shared ABF allows all replicas to benefit from the sampling done by other replicas and can lead to faster convergence of the biasing force.
{
Enable sharing of ABF data between replicas, in a multi-replica simulation.
}
\item \keydef{sharedFreq}{\texttt{abf}}{%
\item
\labelkey{abf|sharedFreq}
\keydef{sharedFreq}{\texttt{abf}}{%
Frequency (in timesteps) at which force samples are synchronized among the replicas}
{positive integer}
{positive integer or zero}
{\refkey{outputFreq}{colvarbias|outputFreq}}
{
In the current implementation of shared ABF, each replica maintains a separate
buffer of total force samples that determine the biasing force.
Every \texttt{sharedFreq} steps, the replicas communicate the samples that
have been gathered since the last synchronization time, ensuring all replicas
apply a similar biasing force.
Every \texttt{sharedFreq} steps, the replicas communicate the samples that have been gathered since the last synchronization time.
Because this forces the replicas to synchronize, small values of this parameter may slightly reduce the overall throughput, especially on systems with unequal performance.
}
\end{itemize}
}
Expand Down
11 changes: 10 additions & 1 deletion doc/cvscript-fix-modify.tex
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
\begin{mdexampleinput}{}
\texttt{\textbf{fix\_modify Colvars bias name bin}}
\\
\-~~~~\texttt{Get the current grid bin index (1D ABF only for now)}
\-~~~~\texttt{Get the current grid bin index (flattened if more than 1d)}
\\
\-~~~~\texttt{\textbf{Returns}}
\\
Expand All @@ -615,6 +615,15 @@
\-~~~~\texttt{samples : integer - Number of samples}
\end{mdexampleinput}
\begin{mdexampleinput}{}
\texttt{\textbf{fix\_modify Colvars bias name local\_sample\_count [radius]}}
\\
\-~~~~\texttt{Get the number of samples around the current binsamples : integer - Number of samples}
\\
\-~~~~\texttt{\textbf{Parameters}}
\\
\-~~~~\texttt{radius : integer - Sum over radius bins around current bin (optional)}
\end{mdexampleinput}
\begin{mdexampleinput}{}
\texttt{\textbf{fix\_modify Colvars bias name binnum}}
\\
\-~~~~\texttt{Get the total number of grid points of this bias (1D ABF only for now)}
Expand Down
11 changes: 10 additions & 1 deletion doc/cvscript-tcl.tex
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@
\begin{mdexampleinput}{}
\texttt{\textbf{cv bias name bin}}
\\
\-~~~~\texttt{Get the current grid bin index (1D ABF only for now)}
\-~~~~\texttt{Get the current grid bin index (flattened if more than 1d)}
\\
\-~~~~\texttt{\textbf{Returns}}
\\
Expand All @@ -615,6 +615,15 @@
\-~~~~\texttt{samples : integer - Number of samples}
\end{mdexampleinput}
\begin{mdexampleinput}{}
\texttt{\textbf{cv bias name local\_sample\_count [radius]}}
\\
\-~~~~\texttt{Get the number of samples around the current binsamples : integer - Number of samples}
\\
\-~~~~\texttt{\textbf{Parameters}}
\\
\-~~~~\texttt{radius : integer - Sum over radius bins around current bin (optional)}
\end{mdexampleinput}
\begin{mdexampleinput}{}
\texttt{\textbf{cv bias name binnum}}
\\
\-~~~~\texttt{Get the total number of grid points of this bias (1D ABF only for now)}
Expand Down
Loading

0 comments on commit 503cab3

Please sign in to comment.