Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution function and PARAMETERS for SANS #972

Merged
merged 7 commits into from
Sep 25, 2023

Conversation

hmcezar
Copy link
Contributor

@hmcezar hmcezar commented Aug 29, 2023

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
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

@hmcezar hmcezar changed the title Resfunc Resolution function and PARAMETERS for SANS Aug 29, 2023
@@ -433,7 +464,7 @@
parse("SOLVATION_CORRECTION", correction);
rho_corr=rho-correction;
if(onebead) log.printf(" Solvation density contribution: %lf\n", correction);
if((atomistic||martini)&&(rho_corr!=rho)) log.printf(" Solvation density contribution is taken into account in ONEBEAD only\n");
if((atomistic||martini||fromfile)&&(rho_corr!=rho)) log.printf(" Solvation density contribution is taken into account in ONEBEAD only\n");

Check notice

Code scanning / CodeQL

Equality test on floating-point values

Equality checks on floating point values can yield unexpected results.
std::vector<Vector> old_deriv(deriv);
memset(&deriv[0][0], 0.0, deriv.size() * sizeof deriv[0]);

unsigned nt=OpenMP::getNumThreads();

Check notice

Code scanning / CodeQL

Declaration hides variable

Variable nt hides another variable of the same name (on [line 1100](1)).
std::vector<Vector> old_deriv(deriv);
memset(&deriv[0][0], 0.0, deriv.size() * sizeof deriv[0]);

unsigned nt=OpenMP::getNumThreads();

Check notice

Code scanning / CodeQL

Unused local variable

Variable nt is not used.
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 79.88% and project coverage change: -0.02% ⚠️

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

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

❗ 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
@@            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 Coverage Δ
src/isdb/Shadow.cpp 11.11% <ø> (ø)
src/tools/Tools.h 81.60% <ø> (ø)
src/isdb/SAXS.cpp 79.94% <79.39%> (-0.09%) ⬇️
src/tools/Tools.cpp 92.50% <100.00%> (+0.11%) ⬆️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@carlocamilloni
Copy link
Member

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

@hmcezar
Copy link
Contributor Author

hmcezar commented Sep 4, 2023

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

@carlocamilloni
Copy link
Member

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

@carlocamilloni carlocamilloni merged commit 948e8df into plumed:master Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants