Repository navigation
Developer Guide
This guide provides technical specifications, architecture diagrams, build instructions, and release workflows for contributors and maintainers of the Electron Scattering Simulator.
The application combines a modern client-side React 19 interface with compiled Fortran 90 physics engines:
┌─────────────────────────────────────────┐
│ React 19 + Vite Frontend (Browser / PWA)│
│ fetch('/api/simulate') │
└───────────────────┬─────────────────────┘
│
src/utils/localApiFallback.ts
(intercepts /api/* requests made by app)
│
backend with ELSEPA binary? │
┌─────────── YES ──────────┴────────── NO ────────────┐
▼ ▼
┌──────────────────────────────┐ HTTP 5xx ┌──────────────────────────────────┐
│ Optional Express Server :3000│ ────────────────► │ ELSEPA WebAssembly (f2c + emcc) │
│ server.ts + fortranRunner.ts │ │ Isolated Web Worker in browser │
│ Native gfortran ELSEPA │ │ public/elsepa/elsepa.{js,wasm} │
└──────────────────────────────┘ └──────────────────────────────────┘
"TS Approximation" (Header toggle, opt-in): Simplified TypeScript model for qualitative demos
├── .github/workflows/
│ ├── ci.yml # Lint, build (Node 20/22), Docker, path-filter gate
│ ├── elsepa-parity.yml # Parity, feature, output, server, and browser tests
│ ├── pages.yml # Publishes project site to gh-pages branch
│ └── release.yml # Release packaging and GHCR container publishing
├── data/ # ELSEPA atomic data tables (z_NNN.den, z_NNN.dfs)
├── docs/ # Technical documentation and publication figures
├── fortran/ # Official ELSEPA 2021 Fortran 90 sources (CC BY-NC 3.0)
│ ├── elscata.f # ELSCATA atomic scattering driver
│ ├── elscatm.f # ELSCATM molecular scattering driver
│ ├── elsepa2020.f # Core Dirac partial-wave scattering subroutines
│ ├── radial.f # RADIAL radial wave equation package
│ ├── readme.txt # Upstream release notes
│ └── ELSEPA-LICENSE.txt # CC BY-NC 3.0 license and attribution terms
├── public/
│ ├── elsepa/ # Compiled WebAssembly: elsepa.js, elsepa.wasm, elsepa.data
│ ├── manifest.json # PWA Web App Manifest
│ └── sw.js # Service Worker for offline caching
├── server/
│ └── fortranRunner.ts # Native gfortran execution & temporary run isolation
├── server.ts # Optional Express API server (port 3000)
├── src/
│ ├── components/ # React UI components (Workbench, Editor, Plots)
│ ├── physics/ # Input deck builder, output parser, grid generators
│ └── utils/ # /api/ routing interceptor, dataset parser, storage
├── validations/ # Canonical reference ELSEPA output tables
└── wasm/ # WebAssembly build pipeline, patch script, and tests
To comply with the Creative Commons Attribution-NonCommercial 3.0 Unported License (CC BY-NC 3.0 Section 4(b)) and maintain reproducibility:
Core Rule: The files in
fortran/are the original, official upstream distribution. Never edit files infortran/directly.
All modifications, overrides, and enhancements are applied programmatically at build time using wasm/patch-elsepa.mjs onto temporary working copies before compilation:
-
Atomic Weight Override (
ATWGHT):- Introduces keyword
ATWGHTinelscata.fto override standard atomic weights (in g/mol), modifying nuclear radius evaluations.
- Introduces keyword
-
Nuclear Radius and Skin Overrides (
NUCRAD,NUCSKN):- Introduces keywords
NUCRAD($R_1$ , fm) andNUCSKN($R_2$ , fm) across the Fermi, Uniform, and Helm nuclear charge distribution models.
- Introduces keywords
-
Negative Ion Support (Anions):
- Removes
STOP 'Negative ion.'statements fromelscata.fandelsepa2020.f(subroutineEFIELD), enabling simulations for targets where$\text{NELEC} > Z$ ($q < 0$ ).
- Removes
-
Polarization Cutoff Mapping (
VPOLB):- Maps user-specified cutoff radius
$r_c$ to ELSEPA's internal cutoff parameter:$$b_{pol} = r_c^2 \sqrt{\frac{2 Z^{1/3}}{\alpha}}$$
- Maps user-specified cutoff radius
Unmodified input decks retain identical defaults and produce bit-for-bit identical outputs to upstream ELSEPA 2021.
The compiled WebAssembly binaries are committed in public/elsepa/. You only need to rebuild them if the Fortran sources, patch scripts, or compilation flags are modified.
- EMSDK: Activated Emscripten SDK (emscripten.org).
-
F2C: Netlib
f2csource tree containingsrc/andlibf2c/(netlib.org/f2c). - Python 3: For syntax adaptation scripts.
The build pipeline executes the following stages:
- Compiles the
f2ctranslator to a Node executable (wasm/build/f2c.cjs). - Compiles
libf2cruntime sources to WebAssembly objects usingemccand archives them intolibf2c.a. - Invokes
node wasm/patch-elsepa.mjsto prepare patched Fortran 90 sources inwasm/build/patched/. - Runs
wasm/f90to77.pyto translate Fortran 90 constructs into strict Fortran 77 (convertsMODULE CONSTANTSinto anINCLUDE 'constants.inc'). - Runs
wasm/f77fix.pyto reorder non-executableDATAstatements before executable code. - Translates Fortran 77 to C using
f2cwith prototype analysis (.Pfiles). - Compiles the C translation and packages
data/atomic tables intopublic/elsepa/elsepa.{js,wasm,data}.
# Execute build from repository root:
EMSDK=/path/to/emsdk F2C_DIR=/path/to/netlib-f2c bash wasm/build.shAll test scripts are located in wasm/ and run using npx tsx:
# Static type checking
npm run lint
# Production bundle verification
npm run build
# Unit and feature tests (custom grids, density parsing)
npx tsx wasm/features.test.ts
# Electron density editor numerical tests
npx tsx wasm/density.test.ts
# Nuclear parameter overrides and ion tests
npx tsx wasm/overrides.test.ts
# Output parser completeness
npx tsx wasm/outputs.test.ts
# Server engine execution and security checks
npx tsx wasm/server.test.ts
# Browser-only CDP integration and offline service worker test
npx tsx wasm/browser.test.ts
# Parity test (WebAssembly vs validations/ tables)
npx tsx wasm/parity.test.tsThe repository uses four coordinated GitHub Actions workflows in .github/workflows/:
-
ci.yml:- Runs on every pull request and push to
main. - Executes
npm run lintandnpm run buildacross Node.js 20 and 22. - Compiles the Dockerfile using buildx.
- Uses
dorny/paths-filterto detect changes to engine-related files (fortran/,data/,wasm/,server/,src/physics/). - Calls
elsepa-parity.ymlwhen engine files change. - Enforces the single required branch protection check:
CI result.
- Runs on every pull request and push to
-
elsepa-parity.yml:- Installs
gfortran, compiles native binaries, and executes all test suites. - Runs
wasm/benchmark.tsandwasm/browser.test.ts, attaching results to the GitHub Step Summary. - Includes the manual
referencesjob (triggered only viaworkflow_dispatch) to regenerate canonical tables invalidations/.
- Installs
-
pages.yml:- Deploys the project presentation website (
site/) and figures to the orphangh-pagesbranch, served athttps://the-studio-of-sadiq.github.io/Electron-Scattering/.
- Deploys the project presentation website (
-
release.yml:- Automatically triggered when a GitHub release is published.
- Verifies that the release tag matches the version in
package.json. - Builds the static web bundle, packages it with
LICENSEandfortran/ELSEPA-LICENSE.txt, and attacheselectron-scattering-X.X.X-web.zipto the release. - Builds and publishes the multi-architecture Docker container image to the GitHub Container Registry (
ghcr.io/the-studio-of-sadiq/electron-scattering).
To create a new official release:
-
Update Version: Bump the
versionfield inpackage.json(e.g.,2.0.0). -
Update Changelog: Document all additions, modifications, and fixes under the new release header in
CHANGELOG.md. -
Update Citation Metadata: Update
versionanddate-releasedinCITATION.cff. -
Commit and Merge: Commit changes, open a pull request, verify that the
CI resultcheck passes, and merge tomain. -
Publish GitHub Release:
- Create a new release in GitHub.
- Set the release tag exactly equal to the version string (e.g.,
2.0.0orv2.0.0). - Publish the release.
-
Automated Archiving & Artifacts:
- Zenodo automatically detects the GitHub release and assigns a permanent DOI according to
.zenodo.json. - The
release.ymlworkflow runs automatically to attach the static zip bundle to the release and publish the Docker image to GHCR.
- Zenodo automatically detects the GitHub release and assigns a permanent DOI according to
Application licensed under MIT; ELSEPA 2021 licensed under CC BY-NC 3.0. Found an issue? Report it on GitHub.