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

[WIP] Modify charge neutrality verification in DielectricConstant #4249

Closed
wants to merge 2 commits into from

Conversation

orionarcher
Copy link
Contributor

@orionarcher orionarcher commented Aug 17, 2023

This PR allows DielectricConstant to check charge neutrality at a customizable granularity.

I work with electrolyte systems where fragments are molecules in the system. In the current scheme, DielectricConstant will fail on my systems because ions have non-zero charge. This adds a keyword to modify the level at which charge neutrality is enforced.

I think changing the hard-coded option to "group" to simplify the API would also be a good fix, it's unclear to me why "fragments" is desirable.

Fixes #

Changes made in this Pull Request:

  • add new check_neutrality_of kwarg to DielectricConstant

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4249.org.readthedocs.build/en/4249/

@github-actions
Copy link

Linter Bot Results:

Hi @orionarcher! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ✅ Passed

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/5885198950/job/15961265364


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (acfd122) 93.40% compared to head (5cf79a1) 93.41%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4249      +/-   ##
===========================================
+ Coverage    93.40%   93.41%   +0.01%     
===========================================
  Files          169      183      +14     
  Lines        22204    23310    +1106     
  Branches      4064     4064              
===========================================
+ Hits         20740    21776    +1036     
- Misses         948     1018      +70     
  Partials       516      516              
Files Changed Coverage Δ
package/MDAnalysis/analysis/dielectric.py 100.00% <100.00%> (ø)

... and 14 files with indirect coverage changes

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

@hmacdope
Copy link
Member

Seems reasonable to me, would need some tests ofc, but understand its WIP.

@orionarcher
Copy link
Contributor Author

Great thank you, wanted to get a second opinion before updating changelog and writing tests.

@PicoCentauri
Copy link
Contributor

@orionarcher if your system has free charges/ions you can not use this module because the equation does not hold if you have free charges.

@orionarcher
Copy link
Contributor Author

Got it. Thanks for the clarification @PicoCentauri.

@PicoCentauri
Copy link
Contributor

Yes, you are not the first one that run into these problems. It might be worth to explain this in the docstring.

@orionarcher
Copy link
Contributor Author

How challenging do you think it would be to implement a dielectric calculation that could handle free charges / ions?

@PicoCentauri
Copy link
Contributor

What you have to do is to calculate the frequency dependent dielectric spectrum and take the zero frequency limit to get the dielectric constant. I did the implementation once, but the code never made it into the main branch, because I branched off too far. 😅 It would be wonderful too have this in mda.

Details on the theory are i.e. explained here. See equation (10) and section S6 in the SI.

@orionarcher
Copy link
Contributor Author

Thanks for sharing! I'll need to implement this myself in the next couple months. I'll ping you when/if I pick it back up.

@PicoCentauri
Copy link
Contributor

PicoCentauri commented Aug 28, 2023

Sure! You can also always ask me on Discord!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants