Tutorial T08: Primitive Cylindrical Polyelectrolyte Electrostatics & Manning Counterion Condensation
Scripts: tutorials/T08_dna_manning_condensation/run.jl · analyze.jl · plot.py
Double-stranded B-DNA carries two elementary negative charges per
Here we study a primitive-model (implicit-solvent) cylindrical polyelectrolyte rod calibrated to B-DNA's linear charge density (ParticleDynamics v1.2.0 electrostatics and constraint capabilities:
Immobile periodic charged rod via
FreezeGroup(rod; mode=:hold), pinning 160 charged monomers along the-axis ( ) while excluding frozen DOFs from the mobile-ion thermostat, observables, and automatic COM-momentum removal.Multi-type
WCAexcluded volume viaPairTableonClusterPairList(force_accumulation=:fixed64)(Float32), zeroing rod–rod steric work ( ) while retaining deterministic 64-bit fixed-point pair-force summation.ESP(continuity=:c2)+CompactFFTlong-range electrostatics (P = 6,mesh = (24, 24, 32)), audited directly against aFloat64( ) reference to relative counterion force error at per force call.Explicit
net_charge=:backgrounduniform jellium control vs. strict electroneutrality (net_charge=:error), verifying both the non-neutral safety guard and analytical background-energy matching ( ) under partial counterion neutralization.BAOABLangevin dynamics withTableWriter(thermodynamic traces) andInMemoryWriter(radial and condensed axial correlation histograms across 8 statistical blocks).
Trajectory Visualization
tutorials/render_movies.py --targets T08).
1. Physical Model & Analytical PB Cell Solution
All simulations use reduced Bjerrum / WCA units (
Primitive Rod Geometry & Coupling Regimes
A rigid, periodically continuous line of charged beads lies along
with an inscribed cylinder radius
Model scope note (r_0 and coupling parameter 1.47–1.76× (~1.5–1.8×) relative to atomistic B-DNA (amplifying both contact-layer steric crowding for
| Case | net_charge ( | Physical Regime (Primitive Rod Model) | ||||||
|---|---|---|---|---|---|---|---|---|
mono_bdna | :error ( | DNA-like | ||||||
diva_bdna | :error ( | DNA-like | ||||||
subcrit_weak | :error ( | Sub-critical weak rod ( | ||||||
bg_partial | :background ( | 50% explicit counterions + 50% uniform neutralizing jellium |
Analytical Cylindrical Poisson–Boltzmann Cell Model (Point-Ion Hard Wall)
For point counterions of valency
The analytical cylindrical Poisson–Boltzmann solution (Fuoss, Katchalsky & Lifson 1951; Deserno, Holm & May 2000) splits at the finite-cell threshold analyze.jl:
Branch A (
, trigonometric; Cases 1 & 2): Solve the 1-parameter transcendental equation for :Whenever
, the Deserno–Holm–May inflection radius where is given by , and the integrated charge fraction and radial density take closed form:At
, the tangent vanishes identically, yielding the Manning condensed fraction (for ;for ).Branch B (
, hyperbolic; Case 3, ): Substituting with solves:yielding a strictly convex curve in
( everywhere, zero inflection point) that approaches the uniform ideal-gas distribution as :
2. ParticleDynamics API Walkthrough
Multi-Type WCA Excluded Volume (PairTable) + ClusterPairList(:fixed64)
Because adjacent rod beads are spaced by FreezeGroup, zeroing PairTable eliminates rod–rod steric overlap and skips frozen–frozen pair evaluations while retaining WCA repulsion for all rod–ion and ion–ion pairs:
pt = PairTable(
sigma=[1.0 1.0; 1.0 1.0],
epsilon=[0.0 1.0; 1.0 1.0], # zero rod-rod WCA work
cutoff=[0.0 WCA_RC; WCA_RC WCA_RC], # WCA_RC = 2^(1/6) * sigma
type_names=[:Rod, :Ion],
)
wca = WCA(
pair_table=pt,
pairs=:neighborlist,
neighborlist=ClusterPairList(buffer=0.5, force_accumulation=:fixed64),
)With precision=Float32, ClusterPairList(force_accumulation=:fixed64) accumulates pair forces in 64-bit fixed point (use_fixed64 == true), ensuring associative, order-independent pair-force summation across launches.
ESP(continuity=:c2) + CompactFFT & net_charge=:background
Long-range electrostatics uses the ESP(continuity=:c2), backed by B2ProlateWindow in v1.2.0) with real_cutoff = 6.0 (tolerance = 1e-4, which resolves stencil width P = 6 and smooth FFT mesh (24, 24, 32), activating the fused shared-memory CompactFFT pipeline (compact_fft !== nothing) across all four cells:
esp = ESP(
coulomb_prefactor=c.l_B,
real_cutoff=6.0,
tolerance=1e-4,
order=6,
continuity=:c2,
mesh=(24, 24, 32),
net_charge=c.net_charge, # :error (Cases 1-3) or :background (Case 4)
boundary=:tin_foil,
)On Case 4 (run.jl first confirms that ESP(..., net_charge=:error) throws an ArgumentError refusing the non-neutral configuration, then switches to net_charge=:background, which inserts the explicit uniform neutralizing jellium background and contributes the analytical background energy correction:
FreezeGroup(:hold) + BAOAB + TableWriter / InMemoryWriter
Mobile counterions evolve under canonical BAOAB Langevin dynamics (FreezeGroup(rod_grp; mode=:hold):
sim = Simulation(
built.system;
groups=Groups(all_grp, rod_grp, ion_grp),
integrator=Integrator(
dt=0.004,
scheme=BAOAB(track_thermo=false),
forces=[wca, esp],
methods=[
Langevin(ion_grp; gamma=0.5, kT=1.0),
Langevin(rod_grp; gamma=0.5, kT=0.0),
],
constraints=[FreezeGroup(rod_grp; mode=:hold)],
),
observables=[thermo_ion, thermo_all],
writers=[table_w, mem_w], # TableWriter CSV + InMemoryWriter frames
precision=Float32,
)After GPU-batched step_many! equilibration (60,000 steps = 320,000 steps (40,000 steps/block), recording thermodynamic traces with TableWriter and coordinate/force frames with InMemoryWriter (every = 100, 3,200 frames total).
3. Results & Visual Verification
Manning Condensation Curves, Steric Crowding & Divalent Correlations

Monovalent rod (
; Panels a & b, Navy): Across the full inscribed cell ,follows the Branch A Poisson–Boltzmann curve closely ( RMSE = 0.0097 ± 0.0006). At the Deserno–Holm–May inflection radius , MD yields vs. Manning's ( ,). Panel (b) shows that near contact ( ), monovalent is non-zero, averaging-0.0156 ± 0.0013(-12.0σ) and dipping to right outside. This under-condensation relative to point-ion PB is a genuine physical finite-size effect documented by Deserno, Holm & May (2000): whereas analytical PB treats counterions as point particles against a hard cylinder at , the MD ions have finite WCA diameter and interact with the rod through a soft repulsive WCA wall (whose effective distance of closest approach slightly exceeds) plus inter-ion steric crowding in the dense condensed sheath. Both effects deplete the immediate contact layer relative to the singular point-ion PB density profile before catches up by .Divalent rod (
; Panels a & b, Crimson): Strong electrostatic correlations overwhelm the WCA steric depletion and drive pronounced over-condensation beyond mean-field PB near the rod, reproducing the headline result of Deserno, Holm & May (2000): vs. PB( ,; and higher than monovalent). In the near-rod window ,averages +0.1043 ± 0.0015(+69.5σ) with a sharp peakΔP_max = +0.1455 ± 0.0013at .Sub-critical weak-charge control (
; Panels a & b, Teal): MD matches the hyperbolic Branch B PB curve toRMSE = 0.0030 ± 0.0026, remains strictly convex in(outer/inner log-slope ratio , zero inflection point), gives vs. PB( ,), and exhibits negligible near-rod steric deviation ( ,) because the ion density at contact is low.
Local Counterion Density, Axial Correlation Hole & Uniform Jellium Background

Radial density enrichment/depletion & condensed axial correlation hole (Panel a): On a logarithmic scale, monovalent
(Navy) and sub-critical (Teal) track analytical (dashed) over more than three orders of magnitude outside the immediate WCA contact zone. By contrast, divalent (Crimson) exceeds in the immediate contact sheath ( ) and is depleted below PB by nearly a factor ofin the outer cell ( ). The inset displays the 1D axial pair correlation functionof condensed counterions ( ): divalent ions carve a deeper and wider electrostatic correlation hole ( vs.for , depressed out to ) followed by a liquid-like ordering peak ( at ), consistent with the lateral-correlation mechanism that lowers the chemical potential of the condensed layer below mean-field PB.Explicit partial counterions in uniform jellium (
net_charge=:background, Panel b): When half of the monovalent counterions are replaced by a uniform neutralizing background ( , ), the explicit rod-neutralization curve(Cobalt) rises steeply and saturates at while the remaining of charge is neutralized uniformly over the cell volume. Because the jellium encloses negligible charge near the rod ( ), even complete condensation of all explicit counterions leaves a super-critical residual charge ; consequently, of the available explicit counterions condense within (Amber dashed curve), compared toin the fully neutralized cell.
4. Quantitative Production Summary
Production parameters on NVIDIA V100 (Float32, ClusterPairList(:fixed64), C²-ESP P = 6, mesh = (24, 24, 32), CompactFFT): 60,000 equilibration + 320,000 production steps (25.2–25.9 s per warm production cell).
| Case | PB Branch ( | RMSE vs PB | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
mono_bdna | trig ( | |||||||||
diva_bdna | trig ( | |||||||||
subcrit_weak | hyp ( | none | ||||||||
bg_partial | :background | — | — | — |
Software/API Integrity Checks vs. Physical Validation
Software and API checks are reported separately from physical validation metrics:
| Category | Metric | Measured (ParticleDynamics) | Target / Reference |
|---|---|---|---|
| Software check | C²-ESP mobile-ion rel. force error vs Float64 ( | 0.288 ms/call) | |
| Software check | CompactFFT & ClusterPairList(:fixed64) active | 4 / 4 and 4 / 4 cells | 4 / 4 |
| Software check | Frozen rod displacement (FreezeGroup(:hold)) & NaN count | 0.0 σ, 0 NaNs | 0.0 σ, 0 NaNs |
| Software check | net_charge=:error guard & :background | Guard rejected | Analytical |
| Diagnostic | BAOAB mobile-ion temperature | Target | |
| Diagnostic | Monovalent contact steric depletion | Expected WCA finite-ion excluded volume (Deserno et al. 2000) | |
| Physics check | Monovalent PB curve fidelity | ||
| Physics check | Monovalent Manning fraction | ||
| Physics check | Divalent Manning fraction | ||
| Physics check | Divalent vs. monovalent condensation gap | ||
| Physics check | Divalent correlation excess | ||
| Physics check | Sub-critical Branch B PB fidelity | ||
| Physics check | Sub-critical no-condensation check | Branch B PB | |
| Physics check | Partial-neutralization available ion condensation at |
5. Running the Tutorial
# Quick GPU smoke verification (~16 s warm GPU compute across all 4 cells)
TUTORIAL_FAST=1 julia --project tutorials/T08_dna_manning_condensation/run.jl
TUTORIAL_FAST=1 julia --project tutorials/T08_dna_manning_condensation/analyze.jl
# Full production validation (320,000 steps / 1280 tau per cell + Float64 ESP audit)
julia --project tutorials/T08_dna_manning_condensation/run.jl
julia --project tutorials/T08_dna_manning_condensation/analyze.jl
# Regenerate 300-DPI documentation figures
python3 tutorials/T08_dna_manning_condensation/plot.pyReferences
G. S. Manning, "Limiting laws and counterion condensation in polyelectrolyte solutions I. Colligative properties," J. Chem. Phys. 51, 924–933 (1969).
R. M. Fuoss, A. Katchalsky & S. Lifson, "The potential of an infinite rod-like molecule and the distribution of the counter ions," Proc. Natl. Acad. Sci. USA 37, 579–589 (1951).
M. Deserno, C. Holm & S. May, "Fraction of condensed counterions around a charged rod: Comparison of Poisson–Boltzmann theory and computer simulations," Macromolecules 33, 199–206 (2000).
R. R. Netz, "Electrostatics of counter-ions at and between planar charged walls: From Poisson–Boltzmann to the strong-coupling theory," Eur. Phys. J. E 5, 557–574 (2001).