How abinit/abipy works
Project type and purpose
• AbiPy is an open‐source Python library that (1) automates and manages workflows for Abinit (a Fortran‐based DFT code), (2) parses and analyzes the Abinit outputs (netCDF, text), and (3) provides plotting and user interfaces (CLI and GUI) for results exploration.
Top-level components
A. External Dependencies & Services (gray)
• Abinit executable (shell command)
• Python ecosystem libraries: numpy, scipy, netCDF4, pandas, matplotlib, pymatgen, ipython/jupyter
• HPC job schedulers (SLURM, PBS, etc.) configured via manager.yml
B. Core Library (blue)
1. IO Layer
• abipy.abio: input_tags, inputs, outputs, abivars_db
• abipy.iotools: xsf, cube, visualizer
2. Data Model / Domain Logic
• abipy.core: units, structures, kpoints, symmetries, restapi
• abipy.data: pseudopotentials, CIFs, reference datasets
3. Analysis Modules
• abipy.dfpt: phonons, elastic, QHA
• abipy.electrons: bands, GW, optics
• abipy.eph: electron–phonon coupling
• abipy.dynamics, abipy.embedding, abipy.ml, abipy.waves
4. Workflow Engine
• abipy.flowtk: flows, tasks, scheduler adapters, launcher
5. Visualization & UI
• abipy.display: low‐level plotting utilities
• abipy.panels: GUI widgets (Plotly/Bokeh)
6. Command-Line Scripts
• abicheck.py, abirun.py, abiopen.py, abiview.py, … (in abipy/scripts)
C. Examples, Tests & Documentation (green)
• abipy/examples: ready‐to‐run scripts & notebooks
• abipy/tests & integration_tests: pytest suites
• docs: Sphinx sources, user guides, API references
Component relationships and data flows
• Workflow launch: CLI (abirun.py) or Python API → Flowtk Engine → Scheduler Adapter → submit job script to HPC or local shell → invoke Abinit executable.
• Abinit run produces output netCDF/text → IO Layer (abio, iotools) parses files → Domain Model objects (core) → Analysis Modules perform computations → Visualization modules plot or panels GUI updates.
• Data may also flow: Examples → demonstrate API usage → end user / Jupyter notebook.
• External libs supply low‐level functionality (e.g. numpy arrays, pandas DataFrames, matplotlib figures).
• The installer (setup.py, conda) and CI (GitHub Actions, Travis) manage build/test → push docs to GitHub Pages.
Architectural patterns & design principles
• Layered architecture: clear separation of IO, domain logic, analysis, workflows, and presentation.
• Plugin / modular structure: each subpackage (dfpt, electrons,… ) can evolve independently.
• Factory pattern: input file generation via abipy.abio.factories.
• Adapter pattern: scheduler adapters decouple Flowtk from specific HPC schedulers.
• Observer / Event pattern: Flowtk events and scheduler error handlers.
Essential elements
• All main packages as components.
• External Abinit binary and Python libraries.
• Flow of control from CLI/API down to Abinit and back up to visualization.
• Data stores: pseudopotential files, reference datasets, output netCDF.
• CI/CD and documentation publishing as separate auxiliary components.
• Tests pipeline to show quality‐gate integration.