Repository navigation
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
ELSEPA uses the radial electron density to compute the static electronic potential
The editor supports three primary data sources:
-
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.
- Extracts densities directly from ELSEPA for any element
-
File Upload:
- Imports external tables in
.den,.dat,.txt, or.csvformats. - Automatically parses numerical columns, supports Fortran
Dexponential notation, strips comments and headers, and verifies grid ordering.
- Imports external tables in
-
Workbench Density:
- Pulls the custom density file currently loaded into the Atomic Workbench.
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.
- Users can click and drag directly on the logarithmic density plot (
-
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'}$$
- Rescales
-
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.
- Modifies the net charge by removing (
-
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.
- Compresses (
-
Truncate at
$r_{\max}$ :- Sets density strictly to zero beyond a specified cutoff radius
$r_{\max}$ , modeling atomic confinement or muffin-tin boundary conditions.
- Sets density strictly to zero beyond a specified cutoff radius
-
Smooth (
$k$ -point window):- Applies a moving-average filter across
$k$ adjacent radial points to suppress numerical noise or discretization artifacts.
- Applies a moving-average filter across
-
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)$$
- Performs linear interpolation between the active density
-
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.
- An expandable data table listing every
-
History Controls:
- Full multi-level Undo and Redo history stack.
- Reset to Source: Restores the unaltered initial density profile.
The editor continuously evaluates physical moments and validates compliance with ELSEPA requirements:
-
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.
-
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.
When saving or supplying custom density files to ELSEPA, the file must satisfy the following criteria:
-
Header Lines:
- Exactly three header lines prefixed with
#or text (ELSEPA'sEFIELDsubroutine skips exactly 3 lines before reading data).
- Exactly three header lines prefixed with
-
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)$ .
-
Column 1: Radial distance
- Two columns of numbers separated by whitespace or commas:
-
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').
-
Minimum points: 5 (ELSEPA requires
-
Normalization Condition:
$$4\pi \int_0^\infty \rho(r) r^2 , dr = \text{NELEC} = Z - q$$
# 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
-
Download .den: Formats the active density into the standard ELSEPA
.denstructure and downloads it asz_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.
Application licensed under MIT; ELSEPA 2021 licensed under CC BY-NC 3.0. Found an issue? Report it on GitHub.