plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
357 stars 284 forks source link

Resolution function and PARAMETERS for SANS #972

Closed hmcezar closed 1 year ago

hmcezar commented 1 year ago
Description

This PR contains the implementation of a resolution function for the SAS spectra and enables using user-provided PARAMETERS for computing SANS. I also implemented an option called PARAMETERSFILE, that can be used to provide a text file containing all the PARAMETERS instead of including them in the main input (when you have to specify the PARAMETERS for thousands of beads, this makes the input more readable). To avoid increasing the computational cost too much when using the resolution function, splines are used to get the intensities and derivatives for q not provided by the user. A description of the resolution function implementation and on how one can use the PARAMETERS in case of CG simulations can be seen in this paper.

A bit of context in the paper and implementation: Last summer (before you pushed the SANS implementation in SAXS.cpp and reworked the code for the ONEBEAD implementation) I needed to perform metainference simulations biasing the SANS spectrum for a collaboration. I implemented it in my sans branch and have been using it ever since. The difference between what is implemented in SANS.cpp in that branch and this PR is basically the normalization, which used to set I(q_0) = 1, with q_0 being the lowest q, and now uses the same normalization you are using.

About the normalization, I performed a couple of tests, and it seems that in some cases, even when the spectra is flat for low q, the calculated curve is not set to 1 at q=0. Instead, one has to use a reasonably large SCALE with metainference (around 25 for one of my systems) to get a good match between the experimental curve with I(q=0)=1 and the computed curve. This is true for both SAXS and SANS, so this is not something that comes from my implementation. However, if you use a reasonable value for the SCALE, the curves match and everything works as it should.

Anyways, let me know if you need anything else regarding this PR.

Target release

I would like my code to appear in release 2.9

Type of contribution
Copyright
Tests
codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 79.88% and project coverage change: -0.02% :warning:

Comparison is base (ed80ed1) 85.11% compared to head (8bb3b14) 85.09%.

:exclamation: Current head 8bb3b14 differs from pull request most recent head f717167. Consider uploading reports for the commit f717167 to get more accurate results

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #972 +/- ## ========================================== - Coverage 85.11% 85.09% -0.02% ========================================== Files 601 601 Lines 55609 55758 +149 ========================================== + Hits 47331 47448 +117 - Misses 8278 8310 +32 ``` | [Files Changed](https://app.codecov.io/gh/plumed/plumed2/pull/972?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=plumed) | Coverage Δ | | |---|---|---| | [src/isdb/Shadow.cpp](https://app.codecov.io/gh/plumed/plumed2/pull/972?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=plumed#diff-c3JjL2lzZGIvU2hhZG93LmNwcA==) | `11.11% <ø> (ø)` | | | [src/tools/Tools.h](https://app.codecov.io/gh/plumed/plumed2/pull/972?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=plumed#diff-c3JjL3Rvb2xzL1Rvb2xzLmg=) | `81.60% <ø> (ø)` | | | [src/isdb/SAXS.cpp](https://app.codecov.io/gh/plumed/plumed2/pull/972?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=plumed#diff-c3JjL2lzZGIvU0FYUy5jcHA=) | `79.94% <79.39%> (-0.09%)` | :arrow_down: | | [src/tools/Tools.cpp](https://app.codecov.io/gh/plumed/plumed2/pull/972?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=plumed#diff-c3JjL3Rvb2xzL1Rvb2xzLmNwcA==) | `92.50% <100.00%> (+0.11%)` | :arrow_up: | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/plumed/plumed2/pull/972/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=plumed)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

carlocamilloni commented 1 year ago

@hmcezar thanks! I will look into the pull request and the i0 intensity issue possibly next week.

hmcezar commented 1 year ago

No problem! Let me know if you need anything from my side.

carlocamilloni commented 1 year ago

merging! @hmcezar could you send me a working example with the Iq0 normalisation issue? something that can be run with plumed driver would be great