.. _sphx_glr_examples_electrostatics: Electrostatics ============== Examples demonstrating GPU-accelerated computation of long-range electrostatic interactions in periodic systems using Coulomb, Ewald summation, and Particle Mesh Ewald (PME). These examples show how to: * Compute direct Coulomb interactions (damped and undamped) * Use Ewald summation for periodic systems with automatic parameter estimation * Apply two-dimensional slab corrections for Ewald and PME interfacial systems * Apply Particle Mesh Ewald (PME) for O(N log N) scaling * Work with neighbor list and neighbor matrix formats * Perform batch evaluation for multiple systems * Leverage autograd for computing forces and gradients * Compute multipole Ewald and PME totals with charges, dipoles, and quadrupoles (l_max = 0 / 1 / 2), including stress tensors via the cell gradient and force-loss-style training via the second-order backward Warp kernel * Extract atom-centered multipole features by projecting the periodic potential onto receiver GTOs * Amortize the position-independent reciprocal-space state with the multipole SCF cache and reuse it across many step evaluations * Train on forces, stress, and charge gradients via the energy-derivative contract (the recommended replacement for the deprecated direct-output flags) The full Torch Ewald/PME APIs support first- and second-order energy-derived training workflows. The full JAX Ewald/PME APIs support first-order energy-derived gradients for positions, charges, and row-vector displacement virials. Higher-order JAX support is limited to tested position and charge scalar losses; PME cell/stress/strain higher-order derivatives are unsupported. Electrostatics does not expose public Hessian or Jacobian APIs. Point-charge Ewald/PME examples use ``float64`` for accuracy-sensitive reciprocal-space calculations and gradient checks. The APIs also support ``float32`` when throughput is the priority; keep all floating inputs and precomputed metadata in a call on a consistent dtype. .. raw:: html
.. thumbnail-parent-div-open .. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_01_coulomb_example_thumb.png :alt: :doc:`/examples/electrostatics/01_coulomb_example` .. raw:: html
Coulomb Electrostatic Interactions
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_02_ewald_summation_example_thumb.png :alt: :doc:`/examples/electrostatics/02_ewald_summation_example` .. raw:: html
Ewald Summation for Long-Range Electrostatics
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_03_pme_example_thumb.png :alt: :doc:`/examples/electrostatics/03_pme_example` .. raw:: html
Particle Mesh Ewald (PME) for Long-Range Electrostatics
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_04_jax_pme_example_thumb.png :alt: :doc:`/examples/electrostatics/04_jax_pme_example` .. raw:: html
Particle Mesh Ewald (PME) with JAX
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_05_slab_correction_example_thumb.png :alt: :doc:`/examples/electrostatics/05_slab_correction_example` .. raw:: html
2D Slab Correction for Ewald and PME
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_06_jax_slab_correction_example_thumb.png :alt: :doc:`/examples/electrostatics/06_jax_slab_correction_example` .. raw:: html
2D Slab Correction for Ewald and PME with JAX
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_07_multipole_ewald_summation_example_thumb.png :alt: :doc:`/examples/electrostatics/07_multipole_ewald_summation_example` .. raw:: html
Multipole Ewald Summation (charges + dipoles + quadrupoles)
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_08_multipole_pme_example_thumb.png :alt: :doc:`/examples/electrostatics/08_multipole_pme_example` .. raw:: html
Multipole Particle Mesh Ewald (charges + dipoles + quadrupoles)
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_09_multipole_features_example_thumb.png :alt: :doc:`/examples/electrostatics/09_multipole_features_example` .. raw:: html
Atom-Centered Multipole Electrostatic Features
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_10_multipole_scf_cache_example_thumb.png :alt: :doc:`/examples/electrostatics/10_multipole_scf_cache_example` .. raw:: html
Multipole SCF Cache + Step (amortized fixed-cell workflow)
.. raw:: html
.. only:: html .. image:: /examples/electrostatics/images/thumb/sphx_glr_11_pme_energy_derivative_training_thumb.png :alt: :doc:`/examples/electrostatics/11_pme_energy_derivative_training` .. raw:: html
Energy-Derivative Training Contract (Forces, Stress, Charge Gradients)
.. thumbnail-parent-div-close .. raw:: html
.. toctree:: :hidden: /examples/electrostatics/01_coulomb_example /examples/electrostatics/02_ewald_summation_example /examples/electrostatics/03_pme_example /examples/electrostatics/04_jax_pme_example /examples/electrostatics/05_slab_correction_example /examples/electrostatics/06_jax_slab_correction_example /examples/electrostatics/07_multipole_ewald_summation_example /examples/electrostatics/08_multipole_pme_example /examples/electrostatics/09_multipole_features_example /examples/electrostatics/10_multipole_scf_cache_example /examples/electrostatics/11_pme_energy_derivative_training