Skip to content

Electron Density Editor

Golam Kuadir Khan Prince edited this page Nov 19, 2026 · 1 revision

Electron Density Editor

The Electron Density Editor (src/components/DensityEditor.tsx) is a visual interactive tool for inspecting, modifying, and synthesizing radial atomic electron densities $\rho(r)$ for use in ELSEPA simulations.

ELSEPA uses the radial electron density to compute the static electronic potential $V_{\text{st}}(r)$, the local exchange potential $V_{\text{ex}}(r)$, and the correlation-polarization potential $V_{\text{cp}}(r)$. By supplying custom or modified densities, researchers can study non-standard atomic configurations, ionization states, solid-state chemical bonding compressions, or densities calculated from external quantum chemistry and DFT packages.


Loading Density Sources

The editor supports three primary data sources:

  1. ELSEPA Built-in Model Densities:
    • Extracts densities directly from ELSEPA for any element $Z = 1$ to $103$ and net ion charge $q$.
    • Dirac-Fock (numerical): Tabulated densities from numerical relativistic Dirac-Fock calculations (data/z_NNN.den).
    • Dirac-Hartree-Fock-Slater (DHFS): Analytical Dirac-Hartree-Fock-Slater density distributions.
    • Thomas-Fermi-Dirac (TFD): Statistical Thomas-Fermi-Dirac model.
    • Thomas-Fermi-Molière (TFM): Analytical three-exponential Thomas-Fermi-Molière approximation.
  2. File Upload:
    • Imports external tables in .den, .dat, .txt, or .csv formats.
    • Automatically parses numerical columns, supports Fortran D exponential notation, strips comments and headers, and verifies grid ordering.
  3. Workbench Density:

Visual Editing Tools

All transformations operate in logarithmic density space where appropriate to ensure numerical stability and prevent negative density artifacts:

  • Interactive Curve Dragging:
    • Users can click and drag directly on the logarithmic density plot (DensityPlot.tsx).
    • A Gaussian displacement kernel with adjustable influence radius $\sigma$ smoothly alters the surrounding radial profile while maintaining monotonicity and continuity.
  • Normalize to Target $N$:
    • Rescales $\rho(r)$ so that the total integrated electron count matches a specified target number of bound electrons: $$N_{\text{target}} = Z - q$$ $$\rho_{\text{norm}}(r) = \rho(r) \cdot \frac{N_{\text{target}}}{4\pi \int_0^\infty \rho(r') r'^2 dr'}$$
  • Ionize / Add Electrons:
    • Modifies the net charge by removing ($\Delta q > 0$) or adding ($\Delta q < 0$) electrons. The transformation preferentially modulates the outer valence tails of the radial distribution.
  • Radial Scaling ($r \to s \cdot r$):
    • Compresses ($s < 1$) or expands ($s > 1$) the radial distribution to model pressure-induced or lattice-compression effects. Automatically renormalizes to conserve total charge.
  • Truncate at $r_{\max}$:
    • Sets density strictly to zero beyond a specified cutoff radius $r_{\max}$, modeling atomic confinement or muffin-tin boundary conditions.
  • Smooth ($k$-point window):
    • Applies a moving-average filter across $k$ adjacent radial points to suppress numerical noise or discretization artifacts.
  • Mix Densities:
    • Performs linear interpolation between the active density $\rho_1(r)$ and a second reference element density $\rho_2(r)$ with mixing weight $w \in [0, 1]$: $$\rho_{\text{mix}}(r) = (1 - w)\rho_1(r) + w\rho_2(r)$$
  • Point Table Inspection & Editing:
    • An expandable data table listing every $(r_i, \rho_i)$ pair with pagination.
    • Allows manual cell editing, insertion of new sorted points, and deletion of existing points.
  • History Controls:
    • Full multi-level Undo and Redo history stack.
    • Reset to Source: Restores the unaltered initial density profile.

Live Physical Metrics and Checks

The editor continuously evaluates physical moments and validates compliance with ELSEPA requirements:

Calculated Metrics (DensityStats)

  • Data Point Count ($N$): Total number of radial grid points.
  • Integrated Electrons ($N$): $$N = 4\pi \int_0^\infty \rho(r) r^2 , dr$$ Evaluated using trapezoidal integration across sorted radial points.
  • Mean Radial Expectation Value ($\langle r \rangle$): $$\langle r \rangle = \frac{4\pi}{N} \int_0^\infty \rho(r) r^3 , dr$$
  • Root-Mean-Square Radius ($\sqrt{\langle r^2 \rangle}$): $$\sqrt{\langle r^2 \rangle} = \left[ \frac{4\pi}{N} \int_0^\infty \rho(r) r^4 , dr \right]^{1/2}$$
  • Median Enclosing Radius ($R_{50}$): Radius enclosing exactly 50% of total bound electron charge.
  • 90% Enclosing Radius ($R_{90}$): Radius enclosing 90% of total bound electron charge.

Automated Validation Warnings

  • Normalization Deviation: Displays a warning alert if the integrated electron count differs from the expected bound charge ($Z - q$) by more than 1%.
  • Positivity: Flags any non-positive radius ($r \le 0$) or non-positive density ($\rho \le 0$).
  • Monotonicity: Verifies that radial distance coordinates are strictly increasing ($r_{i+1} > r_i$).
  • Grid Limits: Verifies that the point count is between 5 and 999.

File Format Specification (MELEC 5)

When saving or supplying custom density files to ELSEPA, the file must satisfy the following criteria:

  1. Header Lines:
    • Exactly three header lines prefixed with # or text (ELSEPA's EFIELD subroutine skips exactly 3 lines before reading data).
  2. Numeric Columns:
    • Two columns of numbers separated by whitespace or commas:
      • Column 1: Radial distance $r$ in bohr ($a_0$). Units: $1 a_0 \approx 5.291772 \times 10^{-9}\text{ cm}$. Must be strictly positive ($r > 0$) and strictly increasing ($r_{i+1} > r_i$).
      • Column 2: Electron density $\rho(r)$ in electrons/bohr$^3$ ($e/a_0^3$). Must be strictly positive ($\rho > 0$) because ELSEPA fits cubic splines to $\ln \rho(r)$.
  3. Grid Limits:
    • Minimum points: 5 (ELSEPA requires $>4$ points to construct a natural cubic spline).
    • Maximum points: 999 (ELSEPA's internal loop dimension is NDIN = 1000; if 1000 lines are read without encountering EOF, the subroutine aborts with 'File is too large').
  4. Normalization Condition: $$4\pi \int_0^\infty \rho(r) r^2 , dr = \text{NELEC} = Z - q$$

Example Formatted .den File

 # User-supplied electron density
 # Target: Gold (Au, Z=79, q=0)
 #      R (a0)           RHO(R) (e/a0^3)
  1.00000000E-04  2.41829310E+05
  1.12000000E-04  2.34102940E+05
  1.25000000E-04  2.25910480E+05
  ...
  2.50000000E+01  1.02481020E-12

Action Buttons

  • Download .den: Formats the active density into the standard ELSEPA .den structure and downloads it as z_NNN_qN_edited.den.
  • Send to Simulation: Automatically sets the Atomic Workbench density model to User-supplied (upload file) (MELEC 5), transfers the serialized density table into active workbench state, and navigates immediately to the Atomic Workbench for execution.

Clone this wiki locally