Skip to content

TMMC - biasing function not working as expected #39

@bartoszmazurwro

Description

@bartoszmazurwro

Hi,

I think that the implementation of biasing function is not working as expected. I did some test after discovering that the macrostate histogram is not flat at all. So below is basic tmmc input as from your example:

{
  "SimulationType" : "MonteCarloTransitionMatrix",
  "NumberOfCycles" : 100000,
  "NumberOfInitializationCycles" : 50000,
  "NumberOfEquilibrationCycles" : 0,
  "PrintEvery" : 500,

  "ForceField" : "../ff/",

  "Systems" : [
    {
      "Type" : "Framework",
      "Name" : "../ff/MOF-303-E4D4",
      "NumberOfUnitCells" : [3, 2, 3],
      "ExternalTemperature" : 298.0,
      "ExternalPressure" : 1700,
      "ChargeMethod" : "Ewald",
      "UseChargesFrom" : "CIF_File",
      "CutOff" : 12.8,
      "MacroStateUseBias" : true,
      "MacroStateMinimumNumberOfMolecules" : 0,
      "MacroStateMaximumNumberOfMolecules" : 34
    }
  ],

  "Components" : [
    {
      "Name" : "../ff/tip4p",
      "FugacityCoefficient" : 1.0,
      "TranslationProbability" : 1.0,
      "ReinsertionProbability" : 1.0,
      "RotationProbability" : 1.0,
      "SwapProbability" : 2.0,
      "CreateNumberOfMolecules" : 0
    }
  ]
}

and the resulting CM stats are:

N CM[-1] CM[0] CM[1] bias lnpi Forward_lnpi Reverse_lnpi histogram
0 0 0.9798638317672098 1.0201361682327903 110.09154929561329 -110.09154929561329 0 0 2
1 8.33886158284123e-06 40.66821608283711 3.3317755783013037 95.28598687383239 -95.28598687383239 -0.6732110639064248 14.80556242178091 44
2 1.4581865729514916 21.39749553115384 3.144317895894669 94.98576819153085 -94.98576819153085 12.22487815644791 15.105781104082439 26
3 1.1629900684278927 32.60437177947679 1.2326381520953094 93.69391402056682 -93.69391402056682 12.993281547442235 16.397635275046465 35
4 3.041823285388791e-08 1.9999999695817672 1 78.63326943839479 -78.63326943839479 13.05144392515958 31.458279857218503 3
5 0.04912851003652767 21.72771999059909 3.22315149936438 73.49969014197472 -73.49969014197472 30.359667568550393 36.591859153638566 25
6 1.456991897680902 40.31125157258416 1.2317565297349404 72.16338020996022 -72.16338020996022 34.54334293619685 37.92816908565307 43
7 1.0225722552291159 48.50404984571708 2.4733778990538093 71.78721665515812 -71.78721665515812 34.37541019357265 38.30433264045518 52
8 1.9408785036173766 130.19582722187627 2.8632942745063277 70.5907415159586 -70.5907415159586 35.25867370870797 39.500807779654686 135
9 2.929844242237539 121.37452517987691 3.6956305778855536 70.66696248624635 -70.66696248624635 35.64750580741739 39.42458680936694 128
10 2.038186310190209 107.41168592509209 3.5501277647177307 70.19651408331289 -70.19651408331289 35.87970774236045 39.8950352123004 113
11 3.1293659596753223 84.25025171759081 2.620382322733864 70.29793905403235 -70.29793905403235 36.43463098648908 39.79361024158094 90
12 0.5155578985064321 31.31659214646694 1.1678499550266215 69.67541526446993 -69.67541526446993 36.25712080308529 40.416134031143365 33
13 0.6153193938302746 36.26596610749466 1.1187144986750588 68.89355844679392 -68.89355844679392 37.07479088266868 41.19799084881937 38
14 0.3484242956357137 51.8782901359305 1.773285568433792 67.37564600133544 -67.37564600133544 37.67258494616853 42.71590329427785 54
15 0.0029196449646635733 13.940204491656186 1.0568758633791502 62.247452510030264 -62.247452510030264 39.299753326942536 47.84409678558303 15
16 0.44896055047849714 81.76283383175567 2.7882056177658363 59.656713941105245 -59.656713941105245 45.191363842068185 50.434835354508046 85
17 1.0025401920651529 20.910474718275673 1.0869850896591735 59.94100971172605 -59.94100971172605 47.017582339188586 50.15053958388724 23
18 0.2722606096750329 38.10681075178639 1.6209286385385777 58.003221034872645 -58.003221034872645 47.0984532590382 52.088328260740646 40
19 0.002217090135358515 12.897544814320003 1.1002380955446387 52.45848424797649 -52.45848424797649 48.88244802530113 57.6330650476368 14
20 0.021604643079789786 52.249302176788845 1.7290931801313725 47.17818389415568 -47.17818389415568 55.08953432489896 62.91336540145761 54
21 1.2180068418684273 40.32941475754074 1.4525784005908284 47.05558651384753 -47.05558651384753 59.471978452641686 63.03596278176576 43
22 0 1.94836841768999 0.051631582310009805 50.44344644494345 -50.44344644494345 59.648102850669844 59.648102850669844 2
23 1.6200612365477468e-10 20.466522366574747 1.5334776332632467 28.465785924528223 -28.465785924528223 55.99133393665429 81.62576337108507 22
24 0.04464490340888382 38.918563331272296 1.0367917653188246 24.331395681171205 -24.331395681171205 78.9622590367757 85.76015361444209 40
25 1.0541973213442057 63.658315088912495 1.2874875897433091 23.847268933573933 -23.847268933573933 82.10740526451167 86.24428036203936 66
26 0.0028298165316442084 17.126153962495714 2.871016220972641 18.92095528833514 -18.92095528833514 82.30731833448792 91.17059400727815 20
27 2.015556590106407 91.1552512543473 2.829192155546293 16.998568699993985 -16.998568699993985 89.22952778478535 93.09298059561931 96
28 2.0243382377362553 94.05040202724405 3.925259735019711 16.622998342942825 -16.622998342942825 89.56862361765175 93.46855095267047 100
29 2.028379478806071 173.0896483000939 3.881972221099961 15.380587387468996 -15.380587387468996 90.23081329025463 94.7109619081443 179
30 2.7154700833395142 345.4943688709777 4.7901610456827095 14.344126888910171 -14.344126888910171 90.879919431203 95.74742240670312 353
31 2.1622785999414984 211.87356231922266 1.9641590808358782 14.03991507912615 -14.03991507912615 91.44751838185559 96.05163421648714 216
32 0.9591740408427766 400.6701700412596 8.370655917897569 12.682289383094332 -12.682289383094332 91.351420013844 97.40925991251896 410
33 5.761196680098511 26232.853043947518 528.3857593726829 8.558278330656794 -8.558278330656794 93.5178349995918 101.5332709649565 26767
34 19.229613561038665 4968892.700914816 99913.06948870377 0.00019677992102925537 -0.00019677992102925537 97.68906566322951 110.09135251569226 5068826

you can see that most of the time simulation was stuck in last macrostate. To test probable solutions I've tried to run (i) much longer simulation (2e6 production cycles), (ii) more recent rescaling of WL ("RescaleWangLandauEvery": 10), and (iii) additional equilibration ("NumberOfEquilibrationCycles" : 50000). In all cases simulation results were similar. As you can see from the long simulation statistics, the acceptance rate of swap move was extremely low:

Monte-Carlo moves statistics
===============================================================================

Component 0 [../ff/tip4p]
    Translation all:            13571086
    Translation total:           4523870    4526086    4521130
    Translation constructed:     4523870    4526086    4521130
    Translation accepted:        2264899    2267953    2260924
    Translation fraction:       0.500655   0.501085   0.500079
    Translation max-change:     0.370002   0.355597   0.412830

    Rotation all:            13566883
    Rotation total:           4521368    4523669    4521846
    Rotation constructed:     4521368    4523669    4521846
    Rotation accepted:        2259439    2266684    2260390
    Rotation fraction:       0.499725   0.501072   0.499882
    Rotation max-change:     0.628360   0.515731   0.555165

    Reinsertion(CBMC) all:            13570922
    Reinsertion(CBMC) total:          13570922
    Reinsertion(CBMC) constructed:    13506180
    Reinsertion(CBMC) accepted:            755
    Reinsertion(CBMC) fraction:       0.000056
    Reinsertion(CBMC) max-change:     0.000000

    Swap Insertion (CBMC) all:            13568232
    Swap Insertion (CBMC) total:          13568232
    Swap Insertion (CBMC) constructed:    13502811
    Swap Insertion (CBMC) accepted:           3513
    Swap Insertion (CBMC) fraction:       0.000259
    Swap Insertion (CBMC) max-change:     0.000000

    Swap Deletion (CBMC) all:            13571135
    Swap Deletion (CBMC) total:          13571135
    Swap Deletion (CBMC) constructed:    13571135
    Swap Deletion (CBMC) accepted:           3513
    Swap Deletion (CBMC) fraction:       0.000259
    Swap Deletion (CBMC) max-change:     0.000000

Based on the acceptance criteria for swap moves:

https://github.com/iRASPA/RASPA3/blob/f2c71c56ea792639ee14625dbc28a3a6426b9e47/src/raspakit/mc_moves/component/deletion.cpp#L121C1-L150C7

I noticed that the solution uses biasTransitionMatrix * Pacc. I haven't seen this approach before - in this and this paper, the biased acceptance criteria is calculated as:

$$ acc(old → new) = \min\left( 1, \frac{\pi(new) \exp[\eta(New)]}{ \pi(old) \exp[\eta(Old)]} \right) $$

where $\pi(n)$ is the probability of observing the system in microstate $n$, and $\eta(n)$ is a biasing potential for state $n$.

I’m curious to understand the reasoning behind the current implementation. Could you please share some insights on how biasTransitionMatrix * Pacc was derived? Any additional context would be really helpful.

Best
Bartosz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions