OpenFreeEnergy / openfe

The Open Free Energy toolkit
https://docs.openfree.energy
MIT License
124 stars 14 forks source link

Frequent "Should have \sum_n W_nk = 1" errors in analysis #833

Open tlhr opened 2 months ago

tlhr commented 2 months ago

I've noticed that for some systems legs fail due to:

ParameterError: Warning: Should have \sum_n W_nk = 1.  Actual column sum for state 0 was 0.990260. 15 other columns have similar problems

This example was an RBFE solvent leg running for 10 ns with 15 lambda windows, so I would have expected adequate sampling. Could it be related to this PyMBAR issue? My analysis succeeds when I force an update to PyMBAR 4.0.3 and modify MultistateEquilFEAnalysis to pass analysis_kwargs={"solver_protocol": "robust"} to MultiStateSamplerAnalyzer as suggested in the last comment. Maybe this could be made the default? I guess this is also related to #443.

IAlibay commented 2 months ago

@tlhr are you getting these failures with pymbar 3 or just solely with pymbar 4?

If it's happening with pymbar 3 then we definitely would love more details - this is something we haven't observed as much on our end.

As you mention the current solver protocol for pymbar 4 isn't set to the robust one by default - it's on ours (and the OpenMMTools' team) todo list to validate enforcing the use of the robust solver, we will hopefully do this soon enough. For now, we recommend that folks stick to pymbar 3 unless they have a specific use case that prevents them from doing this.

tlhr commented 2 months ago

@IAlibay it's indeed happening with pymbar 3 and all the default settings. Unfortunately I can't share the structure, but is there any other information I can give you on the transformation that might help?

IAlibay commented 2 months ago

@tlhr possible things to try;

  1. confirm this issue happens on a system you can share
  2. confirm if this happens on both solvent and complex phases or just one of the two
  3. Post the mbar overlap matrix and the forward and reverse analysis if possible

Sorry for the very quick responses, we'll try to triage this properly a bit later in the week.

IAlibay commented 2 months ago

Post the mbar overlap matrix and the forward and reverse analysis if possible

Apologies, I'm realising this isnt possible, if the simulation is failing 😅

@tlhr could you report the OpenFE version you're using? There's a known bug in versions 0.14 to pre 1.0 that could be the cause of this.