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

Add new adjusted weight scheme to work with DCSF and CCF jobs #689

Merged
merged 15 commits into from
Mar 6, 2025

Conversation

ChiCheng45
Copy link
Collaborator

@ChiCheng45 ChiCheng45 commented Mar 3, 2025

Description of work
Some prefactors involving two atom types were not compatible with the MDANSE weight scheme, so the weighted total was not equal to (or equal to within a scaling factor) the proper total result.

The following changes have been made.

  • Currently in the DCSF
$$F_{\text{coh},\alpha\beta}{(\mathbf{q},t) = \frac{1}{N\sqrt{c_{\alpha}c_{\beta}}}}{\sum\limits_{i \in \alpha}{\sum\limits_{j \in \beta }\left\langle {\exp\left\lbrack {{- i}\mathbf{q}\cdot\mathbf{r}_{i}\left( 0 \right)} \right\rbrack\exp\left\lbrack {i\mathbf{q}\cdot\mathbf{r}_{j}\left( t \right)} \right\rbrack} \right\rangle}}.$$

A new adjusted weight scheme has been created

$$W_{\alpha\beta} = \frac{\sqrt{c_{\alpha} c_{\beta}} b_{\alpha} b_{\beta} }{\sum_{\gamma\delta} c_{\gamma} c_{\delta} b_{\gamma} b_{\delta}}$$

to be used with DCSF and CCF. With this weight scheme, the DCSF total is calculated properly

$$F_{\text{coh},\alpha\beta}(\mathbf{q},t) =\frac{1}{\sum_{\gamma\delta}c_{\gamma}c_{\delta}b_{\delta}b_{\gamma}} \sum_{\alpha\beta} \sqrt{c_{\alpha}c_{\beta}}b_{\alpha}b_{\beta}F_{\text{coh},\alpha\beta}(\mathbf{q},t) =\frac{1}{\sum_{\gamma\delta}c_{\gamma}c_{\delta}b_{\gamma}b_{\delta}} \frac{1}{N} \sum_{ij} b_{i}b_{j}\left\langle {\exp\left\lbrack {{- i}\mathbf{q}\cdot\mathbf{r}_{i}\left( 0 \right)} \right\rbrack\exp\left\lbrack {i\mathbf{q}\cdot\mathbf{r}_{j}\left( t \right)} \right\rbrack} \right\rangle$$

therefore

$$F_{\text{coh},\alpha\beta}(\mathbf{q},t) =\frac{1}{\sum_{\gamma\delta}c_{\gamma}c_{\delta}b_{\gamma}b_{\delta}} F_{\text{coh},\alpha\beta}^{\mathrm{NTDSF}}(\mathbf{q},t)$$

so the results from the DCSF are just a scaled version of the NTDSF results.

  • CCF has been corrected so that the prefactor goes ~ $1 / N \sqrt{c_{\alpha}c_{\beta}}$ so that it is the same as the DCSF.
  • The diagonal part of the distinct part of the van Hove function goes ~ $1 / \rho N c_{\alpha}c_{\alpha}$; previously, it was ~ $1 / \rho c_{\alpha} (N c_{\alpha} - 1)$. They are the same for large $N$, but the change is made for consistency with the weight scheme and everything else.
  • Similar changes made for the van Hove function were done for the SSF, PDF, X-ray, and coordination number jobs.
  • Fix X-Ray and SSF intra+inter partial results so that they can be plotted with or without the weights applied.
  • Added an NTDSF test.

This makes the MDANSE calculations consistent with itself. Results from the DCSF and DISF are consistent with the NTDSF results (they are the same up to some scaling factor). Here, I plot the $F_{\text{coh}}(q,0)$ results from the DCSF and NTDSF calculation using an Argon trajectory where I've randomly assigned the atom types to Test1 and Test2 which have the same b_inc and b_coh but with concentrations of 0.25 and 0.75.

image

Note that I plot the weighted partials $W_{\alpha\beta} F_{\text{coh},\alpha\beta}(q,0)$ from DCSF and $\sqrt{c_{\alpha}c_{\beta}}b_{\alpha} b_{\beta} F_{\text{coh},\alpha\beta}(q,0)$ from NTDSF so that you can see they are the same as the NTDSF except for some scaling factor. I have updated NTDSF results file so that you can also plot $F_{\text{coh},\alpha\beta}(q,t)$ by deselecting the "apply weight?" option in the plotter as with the DCSF results.

I also did the test for the SSF and DCSF for this system.

image

The blue plots are from the (unweighted) partials SSF results, and the orange plots are the partial intermediate scattering function from the DCSF for t=0 converted to the F-Z formalism using

$$S^{\text{A-L}}_{\alpha\beta}(Q) = \delta_{\alpha\beta} + \sqrt{c_{\alpha}c_{\beta}} (S^{\text{F-Z}}_{\alpha\beta}(Q) -1)$$

Fixes
Fixes #683

To test
Run the DCSF, DISF and NTDSF calculations. Compare the DCSF results with the coherent results in NTDSF they should be equivalent to some scaling factor.

…eight scheme and the SSF, van Hove function and PDF. Changed diagonal part of the partial PDF, SSF and van Hove function so that it is also consistent with the weight scheme.
…k with the MDANSE weight scheme. Corrected DCSF and DISF.
@gonzalezma
Copy link
Collaborator

I see a potential issue with this redefinition. The original definition (A-L scheme) is reported in the literature and the partials have a well defined limit, as F(Q --> infinity, t=0) = delta_alpha,beta. The new definition does not correspond to neither the F-Z nor the A-L definitions, so the users should be warned about how to proceed if they want to use the partials.

Copy link
Collaborator

@oerc0122 oerc0122 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fairly sensible. A couple of questions just for my own understanding of the changes.

@ChiCheng45
Copy link
Collaborator Author

ChiCheng45 commented Mar 5, 2025

I see a potential issue with this redefinition. The original definition (A-L scheme) is reported in the literature and the partials have a well defined limit, as F(Q --> infinity, t=0) = delta_alpha,beta. The new definition does not correspond to neither the F-Z nor the A-L definitions, so the users should be warned about how to proceed if they want to use the partials.

I had a think about this, we can change it so that MDANSE will have two weight schemes for properties that depend on two atom types. X-Ray, van Hove, SSF, coordination number, and PDF will use the current one, while DCSF and CCF will use a new one. DCSF and CCF will follow A-L definitions as in 1.5, but the weight scheme will be adjusted so the total is corrected.

The new weight scheme will be

$$W_{\alpha\beta} = \frac{\sqrt{c_{\alpha} c_{\beta}} b_{\alpha} b_{\beta} }{\sum_{\gamma\delta} c_{\gamma} c_{\delta} b_{\gamma} b_{\delta}}$$

where I think it's probably best to leave the denominator the same across the two weight schemes.

@gonzalezma is this preferable?

@gonzalezma
Copy link
Collaborator

I think so, but we will need to check the results. In particular, I don't know how the CCF is calculated now in MDANSE and I think that I have only seen the definition of the CCF for a monatomic liquid, so I am not completely sure of the best way to handle this in a polyatomic system.

… weight scheme has been changed for these jobs
@ChiCheng45 ChiCheng45 changed the title Adjusted prefactors so that they are consistent with the weight scheme Add new adjusted weight scheme to work with DCSF and CCF jobs Mar 6, 2025
ChiCheng45 and others added 4 commits March 6, 2025 09:47
…actor.py

Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com>
Signed-off-by: Chi Cheng <chi-yang.cheng@proton.me>
…h DCSF and DISF using the apply weight option in the plotter
@ChiCheng45 ChiCheng45 marked this pull request as ready for review March 6, 2025 13:46
@ChiCheng45 ChiCheng45 requested a review from oerc0122 March 6, 2025 13:47
@ChiCheng45 ChiCheng45 self-assigned this Mar 6, 2025
Copy link
Collaborator

@oerc0122 oerc0122 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good functionally.

Just to double check, are there comparison plots of these new factors?

@ChiCheng45
Copy link
Collaborator Author

ChiCheng45 commented Mar 6, 2025

All looks good functionally.

Just to double check, are there comparison plots of these new factors?

The plots will be the weighted versions, so they are scaled by the scaling factor. The recent changes allow you to plot the unweighed ones as well; previously, you could only plot the weighted ones, as the scaling factor was set to 1.

@ChiCheng45 ChiCheng45 requested a review from oerc0122 March 6, 2025 15:10
Copy link
Collaborator

@oerc0122 oerc0122 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this if it's working as it should. LGTM.

@ChiCheng45 ChiCheng45 merged commit 9f428f2 into protos Mar 6, 2025
38 checks passed
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.

[BUG] DCSF terms are not scaled similarly to the coherent results in the NDTSF calculations
3 participants