# Re: Calculating 2D PMF from 1D eABF simulations using CZAR estimator.

From: Jérôme Hénin (jerome.henin_at_ibpc.fr)
Date: Mon Nov 16 2020 - 14:10:50 CST

Hi Abhishek,

----- On 11 Nov 20, at 23:13, Abhishek Acharya abhi117acharya_at_gmail.com wrote:

> Hello Jerome,
>
> Thank you for your quick response.
>
> Well it does look simpler that I thought. Pardon my ignorance; I am a
> biologist by training, so mathematics is not a strong suit (how I wish it
> was).
>
> I have another follow up question. Looks like I can collect the joint
> histogram for all the walkers using the histogram method. Easiest way is to
> combine all of these to obtain the full joint histogram, calculate the
> marginal and use the final full 1D PMF to obtain the 2D distribution. But I
> am concerned that sampling artefacts at the window edges may cause
> problems.

Do you see artefacts in both the "regular" PMF and CZAR PMF?

> A better way would be to calculate the 2D PMF separately for each
> window, drop the values at the edges and perform an interpolation to obtain
> the complete 2D PMF.
> A third way I thought is to define slightly broader (and overlapping)
> window ranges. This way I can simply combine the data across windows (for
> both 1D and 2D cases) after dropping the problematic bins at both ends.
> This would be slightly expensive but perhaps a bit cleaner.

Yes, overlapping windows always work as well.

At any rate, you are going to need the writeCZARwindowFile at some point to combine the windows.

Cheers
Jerome

> On Wed, Nov 11, 2020 at 8:53 PM Jérôme Hénin <jerome.henin_at_ibpc.fr> wrote:
>
>> Hello Abhishek,
>>
>> you're almost there, but it's simpler than you think. If you can collect
>> the joint histogram P(z1, z2), biased along z1, then you can obtain the 2d
>> PMF by reweighting using the 1d CZAR PMF:
>> A(z1, z2) = -kT ln( P(z1, z2) / P(z1) ) + A_CZAR(z1)
>>
>> where P(z1) is the observed (biased) histogram in z1 (aka the z1 marginal
>> of the 2d histogram).
>>
>> Best,
>> Jerome
>>
>>
>> ----- On 11 Nov 20, at 20:04, Abhishek Acharya abhi117acharya_at_gmail.com
>> wrote:
>>
>> > Hello,
>> >
>> > We are trying to run 1D eABF simulations on our system of interest.
>> > Specifically, the simulation is divided into 3 windows and we use 5
>> walkers
>> > per window for sampling.
>> >
>> > Obtaining the 1D PMF looks straightforward to do. Just to be sure we,
>> > 1) Combine data for walkers using the inputPrefix directive of ABF to get
>> > combined outputs for each window.
>> > 2) Combine the gradients for each window to obtain the full gradient,
>> > taking care of the edge values.
>> > 3) Integrate the gradient to obtain 1D PMF.
>> >
>> > However for better insights and comparison with methods used previously,
>> we
>> > would like to obtain a PMF projected along an additional CV to obtain a
>> 2D
>> > picture. So, the idea is to apply ABF bias along, say z1 CV, but also
>> > obtain samples along z2 (unbiased and defined without the Extended
>> > Largrangian directive) and somehow combine these to obtain the 2D PMF.
>> > Naively, I thought that maybe we can do a post-hoc estimation using the
>> > CZAR estimator; essentially obtain the biased 2D histogram, P(z1, z2) and
>> > the z1-averaged forces from the CV values and total forces printed out to
>> > the colvar traj file, and finally using the 1D CZAR expression to obtain
>> > the 2D PMF.
>> >
>> > 1. Is this at all a correct strategy? If not, some hints would be
>> >
>> > 2. Fu et al, *J. Chem. Theory Comput.* 2016 indicates that accurate
>> > post-hoc analysis would require printing out the CV and force values
>> every
>> > timestep. For the aforesaid procedure, I thought that maybe we can use
>> the
>> > histogram directive to obtain the final 2D counts and combine it with the
>> > 1D averaged forces.
>> >
>> > Any suggestions would be highly appreciated.
>> >