custom_electrostatics#
Electrostatic Potentials#
- shielded_interaction(dr, charge, alpha, alpha_max=None)[source]#
Gaussian (shielded) charge interaction.
The shielded interaction between gaussian charges is given by
\[V(r) = q_1 q_2 \frac{\operatorname{erf}(\alpha r) - \operatorname{erf}(\alpha_\mathrm{max} r)}{r},\]where $q_1$ and $q_2$ are the charges of the particles, r is the distance, $\alpha = 1 / \sqrt{2(\gamma_1^2 + \gamma_2^2)}$ depends on the width of the charges, and $alpha_{max}$ defines the strength of shielding, e.g., for Ewald summation or the PME method.
- Parameters:
dr – Distance between particles
charge – Charge of the particles
alpha – Shielding parameter for pairs of charges.
alpha_max – Shielding of interaction.
- Returns:
Returns the potential energy.
- shielded_interaction_neighbor_list(displacement_fn, r_onset, r_cutoff, box=None, alpha=4.5, grid=None, method='direct', fractional_coordinates=True)[source]#
Gaussian (shielded) charge interaction.
Applies the shielded interaction between gaussian charges using a neighborlist. The total interaction consists of a direct pairwise contribution in
shielded_interaction(), a self interaction inshielded_self(), and a (optionally) reciprocal space contribution set by themethodargument.- Parameters:
displacement_fn (
Callable[[Array,Array],Array]) – Displacement function.r_onset (
float) – Onset of the real space interaction truncation.r_cutoff (
float) – Cutoff of the real space interaction.box (
Array) – Simulation box, required by the reciprocal space methods.alpha (
float) – Shielding parameter for pairs of charges. Controls the tradeoff between reciprocal and real space contributions.grid (
Union[int,Iterable[int]]) – Grid dimensions for reciprocal space, can be an integer for an equal number of grid points in each dimension or a list.method (
str) – Method to compute the reciprocal space contribution. If “direct”, all interactions are computed in real space. If “ewald”, the Ewald summation is used, if “pme”, the PME method is used (more efficient).fractional_coordinates (
bool) – Whether positions are given in fractional coordinates.
- Return type:
- Returns:
Returns a function to compute the total electrostatic energy of a system of Gaussian charges.
Reciprocal Space Methods#
- structure_factor(g, R, q=1, mask=None)[source]#
Computes the complex structure factor.
Adapted from: jax-md/jax-md
- custom_coulomb_recip_ewald(charge, box, alpha, grid, fractional_coordinates=False)[source]#
Ewald summation for Coulomb interactions.
Modified implementation of
jax_md.energy.coulomb_recip_ewald()to specify wavevectors via grid dimensions. Adapted from jax-md/jax-md.- Parameters:
charge (
Array) – Charges of the particles.box (
Array) – Simulation box, required if fractional coordinates are used.alpha (
float) – Shielding parameter.grid (
Union[int,Iterable[int]]) – Grid dimensions for reciprocal space, can be an integer for an equal number of grid points in each dimension or a list.fractional_coordinates – Whether positions are given in fractional coordinates.
- Return type:
- Returns:
Returns a function to compute the reciprocal part of the coulomb interactions using the Ewald summation.
- custom_coulomb_recip_pme(charge, box, grid, fractional_coordinates=False, alpha=0.34)[source]#
Particle Mesh Ewald method for Coulomb interactions.
Adapted implementation from jax-md/jax-md.
- Parameters:
charge (
Array) – Charges of the particles.box (
Array) – Simulation box, required if fractional coordinates are used.grid (
Union[int,Iterable[int]]) – Grid dimensions for reciprocal space, can be an integer for an equal number of grid points in each dimension or a list.fractional_coordinates (
bool) – Whether positions are given in fractionalalpha (
float) – Shielding parameter of the screening charges.
- Return type:
- Returns:
Returns a function to compute the reciprocal part of the coulomb interactions using the SPME method.
Charge Equilibration#
- charge_eq_energy_neighborlist(displacement, r_onset, r_cutoff, solver='direct', method='direct', grid=None, alpha=4.5, fractional_coordinates=True, box=None)[source]#
Charge equilibration energy function.
Distributes charges globally to minimize the electrostatic energy and core-interaction energy respecting charge conservation [1].
- Parameters:
displacement (
Callable[[Array,Array],Array]) – Displacement function.r_onset (
float) – Onset of the real space interaction truncation.r_cutoff (
float) – Cutoff of the real space interaction.solver (
str) – Method to solve the linear system. Can be “direct” or “CG”.method (
str) – Method to compute long-range electrostatic interactions. Seeshielded_interaction_neighbor_list().grid (
Union[int,Iterable[int]]) – Grid dimensions for reciprocal space. Seeshielded_interaction_neighbor_list().alpha (
float) – Shielding parameter used by the long-range method. Seeshielded_interaction_neighbor_list().fractional_coordinates (
bool) – Whether positions are given in fractional coordinates.box (
Array) – Simulation box, required by the reciprocal space methods.
- Returns:
Returns a function to compute the total electrostatic energy of a system of Gaussian charges, given that the charges minimize the electrostatic energy and the core-interaction energy.
References