# grw **Repository Path**: d2denis/grw ## Basic Information - **Project Name**: grw - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-28 - **Last Updated**: 2025-12-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Pick Data From 2D Potential default pontential file: Meta_potential.txt default scatter_in file for pick Meta_directly.txt for output. # Interpolation Using the same default input setting in CV.txt Command line: ```bash ./interpolate [Meta_potential.txt] [scatter_in] ``` # PLUMEDOC OPES_BIAS OPES_METAD On-the-fly probability enhanced sampling with metadynamics-like target distribution. This On-the-fly probability enhanced sampling ("OPES") method with metadynamics-like target distribution is described in \cite Invernizzi2020rethinking. This OPES_METAD action samples target distributions defined via their marginal $p^{\text{tg}}(\mathbf{s})$ over some collective variables (CVs), $\mathbf{s}=\mathbf{s}(\mathbf{x})$. By default OPES_METAD targets the well-tempered distribution, $p^{\text{WT}}(\mathbf{s})\propto [P(\mathbf{s})]^{1/\gamma}$, where $\gamma$ is known as BIASFACTOR. Similarly to METAD, OPES_METAD optimizes the bias on-the-fly, with a given PACE. It does so by reweighting via kernel density estimation the unbiased distribution in the CV space, $P(\mathbf{s})$. A compression algorithm is used to prevent the number of kernels from growing linearly with the simulation time. The bias at step $n$ is $$ V_n(\mathbf{s}) = (1-1/\gamma)\frac{1}{\beta}\log\left(\frac{P_n(\mathbf{s})}{Z_n}+\epsilon\right)\, . $$ See Ref.\cite Invernizzi2020rethinking for a complete description of the method. As an intuitive picture, rather than gradually filling the metastable basins, OPES_METAD quickly tries to get a coarse idea of the full free energy surface (FES), and then slowly refines its details. It has a fast initial exploration phase, and then becomes extremely conservative and does not significantly change the shape of the deposited bias any more, reaching a regime of quasi-static bias. For this reason, it is possible to use standard umbrella sampling reweighting (see REWEIGHT_BIAS) to analyse the trajectory. At this link you can find some python scripts that work in a similar way to \ref sum_hills, but the preferred way to obtain a FES with OPES is via reweighting (see opes-metad). The estimated $c(t)$ is printed for reference only, since it should converge to a fixed value as the bias converges. This $c(t)$ should NOT be used for reweighting. Similarly, the $Z_n$ factor is printed only for reference, and it should converge when no new region of the CV-space is explored. Notice that OPES_METAD is more sensitive to degenerate CVs than METAD. If the employed CVs map different metastable basins onto the same CV-space region, then OPES_METAD will remain stuck rather than completely reshaping the bias. This can be useful to diagnose problems with your collective variable. If it is not possible to improve the set of CVs and remove this degeneracy, then you might instead consider to use OPES_METAD_EXPLORE or METAD. In this way you will be able to obtain an estimate of the FES, but be aware that you most likely will not reach convergence and thus this estimate will be subjected to systematic errors (see e.g. Fig.3 in \cite Pietrucci2017review). On the contrary, if your CVs are not degenerate but only suboptimal, you should converge faster by using OPES_METAD instead of METAD \cite Invernizzi2020rethinking. The parameter BARRIER should be set to be at least equal to the highest free energy barrier you wish to overcome. If it is much lower than that, you will not cross the barrier, if it is much higher, convergence might take a little longer. If the system has a basin that is clearly more stable than the others, it is better to start the simulation from there. By default, the kernels SIGMA is adaptive, estimated from the fluctuations over ADAPTIVE_SIGMA_STRIDE simulation steps (similar to METAD ADAPTIVE=DIFF, but contrary to that, no artifacts are introduced and the bias will converge to the correct one). However, notice that depending on the system this might not be the optimal choice for SIGMA. You can target a uniform flat distribution by explicitly setting BIASFACTOR=inf. However, this should be useful only in very specific cases. It is possible to take into account also of other bias potentials besides the one of OPES_METAD during the internal reweighting for $P(\mathbf{s})$ estimation. To do so, one has to add those biases with the EXTRA_BIAS keyword, as in the example below. This allows one to define a custom target distribution by adding another bias potential equal to the desired target free energy and setting BIASFACTOR=inf (see example below). Another possible usage of EXTRA_BIAS is to make sure that \ref OPES_METAD does not push against another fixed bias added to restrain the CVs range (e.g. \ref UPPER_WALLS). Through the EXCLUDED_REGION keywork, it is possible to specify a region of CV space where no kernels will be deposited. This can be useful for example for making sure the bias does not modify the transition region, thus allowing for rate calculation. See below for an example of how to use this keyword. Restart can be done from a KERNELS file, but it might be not perfect (due to limited precision when printing kernels to file, or if adaptive SIGMA is used). For an exact restart you must use STATE_RFILE to read a checkpoint with all the needed info. To save such checkpoints, define a STATE_WFILE and choose how often to print them with STATE_WSTRIDE. By default this file is overwritten, but you can instead append to it using the flag STORE_STATES. Multiple walkers are supported only with MPI communication, via the keyword WALKERS_MPI. - Examples Several examples can be found on the PLUMED-NEST website, by searching for the OPES keyword. The \ref opes-metad can also be useful to get started with the method. The following is a minimal working example: ```plumed cv: DISTANCE ATOMS=1,2 opes: OPES_METAD ARG=cv PACE=200 BARRIER=40 PRINT STRIDE=200 FILE=COLVAR ARG=* ``` Another more articulated one: ```plumed phi: TORSION ATOMS=5,7,9,15 psi: TORSION ATOMS=7,9,15,17 opes: OPES_METAD ... FILE=Kernels.data TEMP=300 ARG=phi,psi PACE=500 BARRIER=50 SIGMA=0.15,0.15 SIGMA_MIN=0.01,0.01 STATE_RFILE=Restart.data STATE_WFILE=State.data STATE_WSTRIDE=500*100 STORE_STATES WALKERS_MPI NLIST ... PRINT FMT=%g STRIDE=500 FILE=Colvar.data ARG=phi,psi,opes.* ``` Next is an example of how to define a custom target distribution different from the well-tempered one. Here we chose to focus more on the transition state, that is around $\phi=0$. Our target distribution is a Gaussian centered there, thus the target free energy we want to sample is a parabola, $F^{\text{tg}}(\mathbf{s})=-\frac{1}{\beta} \log [p^{\text{tg}}(\mathbf{s})]$. ```plumedfile phi: TORSION ATOMS=5,7,9,15 FtgValue: CUSTOM ARG=phi PERIODIC=NO FUNC=(x/0.4)^2 Ftg: BIASVALUE ARG=FtgValue opes: OPES_METAD ... ARG=phi PACE=500 BARRIER=50 SIGMA=0.2 BIASFACTOR=inf EXTRA_BIAS=Ftg.bias ... PRINT FMT=%g STRIDE=500 FILE=COLVAR ARG=phi,Ftg.bias,opes.bias ``` Notice that in order to reweight for the unbiased $P(\mathbf{s})$ during postprocessing, the total bias `Ftg.bias+opes.bias` must be used. Finally, an example of how to use the EXCLUDED_REGION keyword. It expects a characteristic function that is different from zero in the region to be excluded. You can use CUSTOM and a combination of the step function to define it. With the following input no kernel is deposited in the transition state region of alanine dipeptide, defined by the interval $\phi \in [-0.6, 0.7]$: ```plumedfile phi: TORSION ATOMS=5,7,9,15 psi: TORSION ATOMS=7,9,15,17 xx: CUSTOM PERIODIC=NO ARG=phi FUNC=step(x+0.6)-step(x-0.7) opes: OPES_METAD ... ARG=phi,psi PACE=500 BARRIER=30 EXCLUDED_REGION=xx NLIST ... PRINT FMT=%g STRIDE=500 FILE=COLVAR ARG=phi,psi,xx,opes.* ``` ## metad_explore **OPES_METAD_EXPLORE** is very similar from the point of view of the code, but conceptually it is better to make it a separate BIAS action On-the-fly probability enhanced sampling with well-tempered target distribution in exploreation mode. On-the-fly probability enhanced sampling with well-tempered target distribution ("OPES") with well-tempered target distribution, exploration mode \cite Invernizzi2022explore . This OPES_METAD_EXPLORE action samples the well-tempered target distribution, that is defined via its marginal $p^{\text{WT}}(\mathbf{s})\propto [P(\mathbf{s})]^{1/\gamma}$ over some collective variables (CVs), $\mathbf{s}=\mathbf{s}(\mathbf{x})$. While OPES_METAD does so by estimating the unbiased distribution $P(\mathbf{s})$, OPES_METAD_EXPLORE instead estimates on-the-fly the target $p^{\text{WT}}(\mathbf{s})$ and uses it to define the bias. The bias at step $n$ is $$ V_n(\mathbf{s}) = (\gamma-1)\frac{1}{\beta}\log\left(\frac{p^{\text{WT}}_n(\mathbf{s})}{Z_n}+\epsilon\right)\, . $$ See Ref.\cite Invernizzi2022explore for a complete description of the method. Intuitively, while OPES_METAD aims at quickly converging the reweighted free energy, OPES_METAD_EXPLORE aims at quickly sampling the target well-tempered distribution. Given enough simulation time, both will converge to the same bias potential but they do so in a qualitatively different way. Compared to OPES_METAD, OPES_METAD_EXPLORE is more similar to METAD, because it allows the bias to vary significantly, thus enhancing exploration. This goes at the expenses of a typically slower convergence of the reweight estimate. OPES_METAD_EXPLORE can be useful e.g.~for simulating a new system with an unknown BARRIER, or for quickly testing the effectiveness of a new CV that might be degenerate. Similarly to OPES_METAD, also OPES_METAD_EXPLORE uses a kernel density estimation with the same on-the-fly compression algorithm. The only difference is that the kernels are not weighted, since it estimates the sampled distribution and not the reweighted unbiased one. All the options of OPES_METAD are also available in OPES_METAD_EXPLORE, except for those that modify the target distribution, since only a well-tempered target is allowed in this case. - Examples The following is a minimal working example: ```plumedfile cv: DISTANCE ATOMS=1,2 opes: OPES_METAD_EXPLORE ARG=cv PACE=500 BARRIER=40 PRINT STRIDE=100 FILE=COLVAR ARG=cv,opes.* ```