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

Docs warning for charge in DielectricConstant #4263

Merged
merged 4 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The rules for this file:
* release numbers follow "Semantic Versioning" http://semver.org

------------------------------------------------------------------------------
??/??/?? IAlibay, ianmkenney
??/??/?? IAlibay, ianmkenney, PicoCentauri

* 2.7.0

Expand All @@ -22,6 +22,8 @@ Fixes
their original type value (np.float64 and np.nan) (PR #4272)

Enhancements
* Added a warning about charge neutrality to the documentation of
`DielectricConstant` (Issue #4262, PR #4263)

Changes
* The `mda-xdrlib` module is now a core dependency of MDAnalysis
Expand Down
4 changes: 4 additions & 0 deletions package/MDAnalysis/analysis/dielectric.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class DielectricConstant(AnalysisBase):
the usual case if electrostatics are handled with a Ewald summation
technique. See [Neumann1983]_ for details on the derivation.
.. warning::
Applying this class requires that no free charges, such as ions or
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a stupid question, if this is relying on an Ewald style summation, how well does it handle a system with a net charge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, totally valid question. The answer will be a bit longer. sorry.

Ewald can handle systems with a net charge. You introduce a homogenous background charge that neutralizes the system, which will lead to an additional force an all atoms. This is unproblematic for homogenous systems but lead to severe artifacts in inhomogenous systems like membranes etc.

The equation we use here is derived for an Ewald boundary condition, meaning that the dielectric constant of sorrounding medium is a metal ($\varepsilon=\infty$). If you have other boundary conditions like when using reaction field or cutoff electrostatics the equation will change as described in the paper we cite. We use eq 26.4.3D because the derivation for an Ewald electrostatic leads to the same results as a reaction field with an dielectric constant of $\infty$.

Screenshot 2023-08-28 at 21 39 54

Now, why are charges a problem? The issue is that in the derivation you demand that Maxwell's equation for electric field

$$ \nabla \vec E = \frac{\rho}{\varepsilon_0} $$

where $\rho$ is the charge density is equal to zero: $\nabla \vec E = 0$. This means that no free charges are present. If you do not do this you will not end up with the equation we use.

Does this answer your question?

Copy link
Member

Choose a reason for hiding this comment

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

Do you think you could transfer this very insightful piece of writing to an issue for future reference. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we sure. If people find it there.

charged fragments, are present in the simulation.
Copy link
Member

Choose a reason for hiding this comment

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

@PicoCentauri perhaps I am misunderstanding but you can have no charged anything or is it that you need overall neutrality. Apologoies if silly q.

Copy link
Contributor Author

@PicoCentauri PicoCentauri Aug 29, 2023

Choose a reason for hiding this comment

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

Nono it is fine. This is really a bit tricky. There are even publications where people do this wrong.

As we do it in the assertion in the class' prepare function you need charge neutral molecules. In a classical MD world they can have of course have partial charges. In fact, they have to because otherwise the system's total dipole moment would be zero and with it the dielectric constant.

What you can not have are ions such as Na+ Cl- or other charged fragments i.e negative carboxylic acid groups COO- or positive amine groups H3N+.

Parameters
----------
atomgroup : MDAnalysis.core.groups.AtomGroup
Expand Down