PARSEC.py is a native Python implementation of isolated, real-space
Kohn–Sham DFT based on the algorithms in the PARSEC Fortran code. It reads
PARSEC-style parsec.in files and PARSEC *_POTRE.DAT norm-conserving
pseudopotentials directly. It does not call PARSEC, WSL, MPI, or Fortran at
runtime.
The maintained solver now has one canonical package: src/parsec_python.
Readable scientific modules and optimized execution backends live in that
package together. Normal calculations automatically select the fastest
accuracy-preserving combination available on the machine.
The former implementation is preserved in the Git branch
old_architecture and is intentionally absent from the default main
branch.
Contents
Getting started
Pseudopotentials
How the solver works
The code
Reference
Quick start
Linux users: see Linux installation below for Bash commands,
CPU-only setup, and optional C++/OpenMP + NVIDIA GPU acceleration.
Python 3.12 and the repository’s .venv312 environment are recommended on
Windows:
git clone https://github.com/QianGroupPage/PARSEC.py.git
Set-Location PARSEC.py
py -3.12 -m venv .venv312
.\.venv312\Scripts\Activate.ps1
python -m pip install -r src\parsec_python\requirements.txt
Place parsec.in and its pseudopotentials in one calculation directory:
calculation/
├── parsec.in
├── C_POTRE.DAT
└── H_POTRE.DAT
From the repository root, validate an input without building the grid:
python src\parsec_python\main.py path\to\calculation\parsec.in --dry-run
Run the calculation:
python src\parsec_python\main.py path\to\calculation\parsec.in --no-archive
The default text result is parsec.out beside the input. Unless
--no-archive is used, arrays and metadata are also stored in
parsec_python_results.npz.
A sphere input may leave Boundary_Sphere_Radius out. The radius and the
tolerance of the Hartree boundary are then chosen from the geometry and the
free atoms of the pseudopotential files, for an estimated energy error of
Domain_Energy_Tolerance (default 1e-3 Ry; this is not the SCF criterion
Convergence_Criterion). parsec.out and --dry-run print the choice and
the two input lines that reproduce it; after the SCF every sphere run
reports what its sphere adds to the energy, estimated from the converged
density. An input with a radius keeps its sphere. Its Hartree boundary
values differ from PARSEC’s, and from those of earlier versions of this
code, where an estimate from the geometry says PARSEC’s are inaccurate;
Hartree_Boundary_Tolerance: off in the input restores them. With
PARSEC_DOMAIN_REPORT=0 in the environment its report leaves the estimates
of the sphere out.
See “Sphere radius left to the code” in
the package README; the switches that came
with it for the GPU drivers, their defaults and the values that restore the
former behaviour are in one table in
the acceleration README.
When src is importable, the equivalent package command is:
$env:PYTHONPATH = (Resolve-Path src).Path
python -m parsec_python path\to\calculation\parsec.in --no-archive
For example:
python src\parsec_python\main.py `
examples\0d_naphthalene\parsec.in `
--no-archive
CPU or GPU, and how much of each
The same command runs on a CPU and on a GPU. By default (--device auto) it
takes the GPU when CuPy is installed and finds a usable NVIDIA GPU, and the
CPU otherwise. Name the device to be sure of it:
python src\parsec_python\main.py parsec.in # GPU if one is usable, otherwise CPU
python src\parsec_python\main.py parsec.in --device gpu # GPU; stops with a message if none is usable
python src\parsec_python\main.py parsec.in --device cpu # CPU only; no GPU is touched
How many GPUs and CPU threads it takes can be named as well. Each choice has
a default and a variable that a job script can set instead of the option; an
option outranks its variable:
| Choice |
Option |
Default |
Variable |
| Device |
--device auto|gpu|cpu |
auto |
PARSEC_DEVICE |
| GPUs |
--gpus N|all, or --gpu-ids 0,2 for particular ones |
all: every GPU the process can see |
PARSEC_CUPY_DEVICES |
| CPU threads |
--threads N|all|auto |
auto: the CPUs the process may use, less four kept free for Python and the GPU driver |
OMP_NUM_THREADS |
python src\parsec_python\main.py parsec.in --device gpu --gpus 2 --threads 16
python src\parsec_python\main.py parsec.in --device cpu --threads all
--gpus or --gpu-ids alone asks for a GPU run. --threads sets the team
of the C++/OpenMP kernels (setup and the Hartree boundary on a GPU run, whose
Hartree conjugate gradients run on the GPU since 2026-11-07, and the whole
solver on a CPU run with the native extension); the BLAS of NumPy keeps its
own variables (OPENBLAS_NUM_THREADS, MKL_NUM_THREADS).
What ran is at the top of parsec.out, and --dry-run prints the same plan
without starting a calculation:
Execution resources:
--------------------
Device = GPU (auto, the default: a usable GPU was found)
GPUs = 2 of 2 visible, index 0,1; all visible, the default
CPU threads = 28 of 32 CPUs allowed (affinity of the process); the default: allowed CPUs less 4
A GPU run needs an NVIDIA GPU with its driver and CuPy
(python -m pip install cupy-cuda12x; see
step 3 of the Linux installation,
the same command serves Windows), and is fastest with the
native extension beside it. A CPU run needs
neither; with the extension it uses the C++/OpenMP solver, without it SciPy.
Results are in double precision on either device.
On a cluster, ask the scheduler for the CPUs and GPUs and start the same
command inside the job. The defaults count what the job was given, not what
the node has: the GPUs are those the scheduler made visible
(CUDA_VISIBLE_DEVICES, which the code never changes; --gpu-ids counts
inside it), and the CPUs are those the process is bound to, or fewer where
SLURM_CPUS_PER_TASK (or PBS_NP, NCPUS, NSLOTS, LSB_DJOB_NUMPROC)
says so. For example with Slurm:
#!/bin/bash
#SBATCH --nodes=1 --ntasks=1 --cpus-per-task=16 --gpus=2
source .venv/bin/activate
python src/parsec_python/main.py path/to/calculation/parsec.in --device gpu
One command is one process on one node: it divides the symmetry sectors of
the system among its GPUs. Do not start it with mpirun or several srun
tasks, which would run the same calculation several times. For several nodes,
and for the settings the multi-GPU solver was measured with, use
scripts/run_multi_gpu_scf.sh
(section 5).
Other options
--symmetry auto is the default as well. On the GPU the Hamiltonian and
the eigensolver run in CuPy and, with the native extension, preparation and
Hartree in C++/OpenMP; every selection and every fallback is recorded in
parsec.out under “Acceleration backend”.
| Option |
Meaning |
--device auto|gpu|cpu, --gpus, --gpu-ids, --threads |
What the calculation runs on (above). |
--backend auto|scipy|native|cupy |
Which implementation executes, for controlled comparisons: scipy and native are CPU backends, cupy is the pure GPU backend, and none of the three falls back. auto follows --device. |
| `–symmetry auto |
on |
--symmetry-cache DIR |
Keep exact-key symmetry maps and operators in DIR. No cache is the default (--no-symmetry-cache says so explicitly): a first calculation is fastest without one. |
--pp-dir DIR |
Search an additional directory for *_POTRE.DAT. |
--dry-run |
Parse and validate without constructing the grid. |
--no-archive |
Write only the text output. |
--profile-operator |
Time individual Hamiltonian actions. |
--resident |
Submit to a warmed local worker while creating fresh SCF state. |
--debug |
Re-raise failures with a traceback. |
Linux installation
These commands use Bash and a source checkout. Python 3.12 is recommended;
the native extension requires Python 3.10 or newer. A GPU is optional. Neither
the PARSEC Fortran executable nor MPI is needed for this Python solver.
1. Create a Python environment (CPU-only is sufficient)
On Ubuntu 24.04 / recent Debian-based systems, install the prerequisites:
sudo apt update
sudo apt install git python3 python3-venv python3-dev build-essential
On other distributions, install the equivalent packages. On a university
cluster without administrator access, use the site’s Python/compiler modules
or a user-managed environment instead of sudo. Use matching Python development
headers when building the extension for a non-system Python.
git clone https://github.com/zeyizhang-berkeley/parsec_python.git PARSEC.py
cd PARSEC.py
python3 --version
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r src/parsec_python/requirements.txt
If you already have a checkout, skip cloning and enter its root directory.
This installs NumPy and SciPy; CPU calculations are now available:
python src/parsec_python/main.py examples/h2_canonical_nodg/parsec.in \
--backend scipy --dry-run
python src/parsec_python/main.py examples/h2_canonical_nodg/parsec.in \
--backend scipy --no-archive
--dry-run validates the input without running SCF. The second command writes
parsec.out beside the input and replaces an existing log of that name; copy a
case to a new calculation directory when preserving reference outputs.
2. Add the C++/OpenMP CPU kernels (recommended)
The extension needs a C++17 compiler with OpenMP and CMake 3.24 or newer.
GCC/G++ on Linux is a suitable toolchain. From the activated environment and
repository root:
python -m pip install --upgrade "cmake>=3.24" ninja
python -m pip install -v ./src/parsec_python/acceleration/native
python -c "import parsec_accelerated_native as n; print(n.build_info())"
Check that openmp_enabled is True. Rebuild the extension after updating its
C++ sources: this version is meant for extension 0.6.1 (build_info()['version']).
With an older build a cluster whose Hartree boundary is raised above order 9
stops with a message that asks for the rebuild, the stencils of the symmetry
sectors are built by a slower NumPy route, and the launch script of section 5
stops at its start, because the GPU Hartree boundary needs the newer
extension. Windows .pyd files and Windows wheels cannot be reused on Linux.
python src/parsec_python/main.py examples/h2_canonical_nodg/parsec.in \
--backend native --no-archive
The repository-root pyproject.toml also builds this extension: pip install .
is not an installation of the Python solver package. Use the launcher above,
or make the source directory importable for module/API use:
export PYTHONPATH="$PWD/src${PYTHONPATH:+:$PYTHONPATH}"
python -m parsec_python path/to/calculation/parsec.in --no-archive
3. Add NVIDIA GPU acceleration (optional)
First ensure the NVIDIA driver works, then choose a compatible CuPy/CUDA build.
For CUDA 12.x, with a suitable installed CUDA Toolkit:
nvidia-smi
python -m pip install cupy-cuda12x
If you do not have a system CUDA Toolkit, current CuPy releases also offer
python -m pip install "cupy-cuda12x[ctk]" to install CUDA component dependencies
in the environment; a compatible NVIDIA driver is still required. Choose one
installation route and do not install conflicting CuPy distributions together.
The CUDA version displayed by nvidia-smi describes driver capability, not
proof that a CUDA Toolkit is installed. See the
official CuPy installation guide
for driver/runtime compatibility and other CUDA versions.
Check device access and a small FP64 calculation:
python -c "import cupy as cp; print(cp.__version__); print('devices:', cp.cuda.runtime.getDeviceCount()); x = cp.arange(10, dtype=cp.float64); print('sum:', x.sum().item())"
With CuPy installed the default (--device auto) already takes the GPU.
Ask for it by name to have the run stop, instead of falling back to the CPU,
if the GPU cannot be used:
python src/parsec_python/main.py examples/h2_canonical_nodg/parsec.in \
--device gpu --no-archive
Execution resources: in parsec.out names the device, the GPUs and the CPU
threads. With the native extension installed as well this is the hybrid
policy: Acceleration backend: reports Selected backend = cupy and
hartree_backend = native. Explicit --backend cupy is a different
comparison policy (everything in CuPy), not a synonym for a GPU run.
Set Output_Level: 2 in parsec.in for full backend diagnostics; SCF output
and final timing tables remain available at the default level 1.
AMD ROCm support in CuPy is experimental and does not establish support for
this solver’s custom GPU kernels. These GPU instructions target NVIDIA CUDA;
an AMD CPU can still run the CPU/OpenMP path normally.
4. Threads, new terminals and clusters
In a new terminal, return to the checkout and activate the Linux environment:
cd /path/to/PARSEC.py
source .venv/bin/activate
Linux uses .venv/bin/activate, not Windows Scripts/Activate.ps1; the launcher
uses the active Linux interpreter. Do not share a Windows virtual environment
with Linux/WSL.
The native default is the number of CPUs the process may use minus four, with
a minimum of one thread; individual small kernels may use fewer workers. Name
the number when needed (--threads all takes every allowed CPU):
python src/parsec_python/main.py path/to/calculation/parsec.in --threads 8 --no-archive
export OMP_NUM_THREADS=8 # the same from the environment; --threads outranks it
On a cluster, request CPU/GPU resources with the site’s scheduler before running
jobs; “CPU or GPU, and how much of each”
has a job script. The defaults follow the allocation: the CPUs the process is
bound to (or SLURM_CPUS_PER_TASK and its like where a site does not bind
its jobs) and the GPUs the scheduler made visible; the “Execution resources”
lines of parsec.out, or of --dry-run inside the job, say what was found.
Do not use mpirun to launch this single-process command: that would start
independent calculations, potentially writing to the same files, rather than
distribute one SCF calculation.
For a new-system timing comparison, run without --resident and without
--symmetry-cache: no symmetry cache is read or written unless that option
names a directory. A cache pays only for repeated calculations of the same
structure and grid; src/parsec_python/acceleration/README.md gives the
measured figures. CuPy compilation/driver caches are separate, so this is
not a guarantee of a completely cold GPU runtime.
5. Several GPUs and several nodes
scripts/run_multi_gpu_scf.sh runs one SCF calculation of an isolated system,
or of a bulk cell at the Gamma point, on the GPUs of one node or of several
nodes, one MPI rank per node, with the launch settings the multi-GPU solver
was measured with (1 to 16 A100 80 GB GPUs). Most of these settings are not
defaults of the code: started without them, a calculation takes slower
routes. The script needs the native extension, CuPy and mpi4py built with the
MPI of the machine, and runs inside an existing Slurm allocation; call it by
its path in the checkout rather than handing it to sbatch:
scripts/run_multi_gpu_scf.sh parsec.in output_directory
scripts/run_multi_gpu_scf.sh --nodes 1 --gpus-per-node 2 parsec.in output_directory
The first form uses every node of the allocation with four GPUs each. A run
without point-group symmetry, such as molecular dynamics, has a single
symmetry sector; on several nodes add --rank-per-gpu, which starts one rank
per GPU that share its orbitals (C1653H508 MD: 40.5 s per step on one node,
23.0 s on four).
A bulk cell (Boundary_Conditions: bulk) runs at the Gamma point with real
orbitals, an orthorhombic cell, no spin and a native LDA or GGA, as one
sector whose orbitals all ranks share; on several nodes launch it with
--rank-per-gpu (bulk diamond with 5,832 atoms: 308 s on 16 A100,
examples/3d_diamond_benchmark). K-points of a cell run under
python -m parsec_python.main parsec.in --mpi (k-point pools, “Several GPUs
and nodes for one large eigenproblem (MPI)” below); spin, hybrids,
meta-GGAs, oblique cells, wires, slabs and the forces of a cell go to
main.py, and the runner refuses them by name. A spin-polarized cluster
runs its single point on several ranks; its forces, relaxation and
molecular dynamics need one rank (--serial-control) or main.py.
src/parsec_python/acceleration/MULTI_GPU.md (“Several nodes”, “Periodic
cells at the Gamma point on several nodes”) lists the settings and says
which ones the solver chooses for itself.
Troubleshooting
No module named parsec_python: use python src/parsec_python/main.py ...
from the repository root, or set PYTHONPATH as above. Installing the native
extension alone does not install the Python package.
- Missing Python headers, compiler or OpenMP: install the matching development
headers and a C++17/OpenMP toolchain; check the verbose build output. Avoid
-ffast-math when modifying build flags.
- CuPy import/NVRTC/CUDA library errors: check the active environment, driver,
CuPy distribution and CUDA library paths. On clusters, load the appropriate
CUDA module;
nvidia-smi succeeding is not a complete kernel test.
- The run used the CPU although the machine has a GPU:
Execution resources in parsec.out gives the reason (CuPy missing, no visible
device). --device gpu makes such a run stop with that reason instead.
- Unexpected SciPy fallback: examine the printed fallback reason and verify
the native and CuPy imports separately.
auto can fall back; --device gpu
and an explicit native or cupy backend fail if what they name is
unavailable.
- Out of GPU memory: try
--device cpu or a machine with more memory.
Do not silently coarsen the grid or loosen convergence to make a job fit.
Optional native extension
The C++/OpenMP extension is optional but recommended for fastest automatic
execution. Its source is in src/parsec_python/acceleration/native. A built
wheel can be installed into .venv312 with:
python -m pip install --force-reinstall --no-deps `
src\parsec_python\acceleration\native\dist\parsec_accelerated_native-*.whl
Verify the loaded binary:
python -c "import parsec_accelerated_native as n; print(n.__file__); print(n.build_info())"
The OpenMP default uses the logical processors the process may use minus four
unless --threads or OMP_NUM_THREADS names the number.
Pseudopotentials
PARSEC.py reads norm-conserving pseudopotentials in PARSEC’s *_POTRE.DAT
format. The repository ships libraries of them for the whole periodic table
in src/pp_generation.
Libraries in this repository
| Library |
Content |
Location |
| Ground state |
102 elements (H–No) for PBE, 101 for LDA (CA) |
src/pp_generation/NCPPs/{PBE,CA}/<Element>/ |
| Core hole |
One potential per core shell, generated with one electron removed from that shell. All elements, 1704 potentials. |
src/pp_generation/CoreHole_NCPPs/{PBE,CA}/<Element>/<Element>-<shell>/ |
Every potential comes in three formats: PARSEC/ for this solver, UPF/ for
Quantum ESPRESSO and ARES, and FHI/ (the FHI98PP table). Its input, log and
test reports are in diagnostics/. Each library has a manifest.csv with one
row per potential and a README that says what was chosen and what was checked:
ground state,
core hole.
Using a library potential
Point --pp-dir at the PARSEC folder of each species (or copy the
*_POTRE.DAT files beside parsec.in) and paste the lines of
PARSEC/parsec_atom_type.in into the species block of parsec.in:
Atom_Type: Si
Element_Symbol: Si
Pseudopotential_Format: martins_new
Local_Component: d
Atomic_Energy_Correction: -572.190341 Ry
Local_Component is the channel that passed the ghost-state test; do not
replace it by another one without testing. Use Correlation_Type: pbe with
the potentials of PBE/ and Correlation_Type: ca with those of CA/; the
self-consistent hybrid functionals (pbe0, hse06, b3lyp, hf, …; see
the package guide)
read those of PBE/.
Generating further potentials
pp_generation is an interface to an installed FHI98PP or ATOM for generating
and ghost-checking a potential and converting it; neither program is
distributed here. The input of every library potential is in its
diagnostics folder.
$env:PYTHONPATH = (Resolve-Path src).Path
python -m pp_generation Ni --backend fhi98pp --xc pbe --format parsec -o generated/Ni
See its README.
Core-hole potentials
A core-hole potential describes the atom whose core electron has been
removed, for the calculation of core-level binding energies. It is generated
with the same lmax, cutoff radii and local channel as the ground-state
potential of the element, so the two differ only by the hole. In parsec.in
the excited atom gets its own Atom_Type (for example Si-2p) with
Element_Symbol: Si; with the photoelectron removed, add 1 e to
Net_Charges. The binding energy is the difference of the two
reference-corrected all-electron totals that the solver prints.
Converting a UPF file
python src\tools\upf_to_parsec.py input.UPF output_POTRE.DAT
How the libraries were made, and what to cite
The potentials are Troullier–Martins potentials in the scheme of FHI98PP.
They were generated with a Python port of that program, which is not part of
this repository, and every one (1907 in all) was regenerated with the FHI98PP
program itself from the same input: all are reproduced, with tables agreeing
to 4e-9 and identical ghost-state verdicts. For work that uses them, cite
M. Fuchs and M. Scheffler, Comput. Phys. Commun. 119, 67 (1999)
together with the references listed in
src/pp_generation/README.md.
The potentials have been used in a molecule only for H, C and F; those of the
lanthanides and actinides, which have the f shell in the valence, are untested
starting points. The library READMEs list what is missing (Lr; Ho for CA; some
core holes of Ce, Th, Es, Fm and No).
Scientific flow
The isolated single-point workflow is:
-
Parse the atomic geometry and numerical settings from parsec.in.
-
Read each species’ *_POTRE.DAT file.
-
Center the cluster and build its spherical or box-shaped Cartesian grid.
-
Construct the high-order finite-difference representation of
-nabla^2.
-
Interpolate and superpose local ionic potentials; build separable
Kleinman–Bylander nonlocal projector factors.
-
Build the selected SAD, file, SCDP, or ChargE3Net starting density on the
exact DFT grid and normalize the electron count.
-
Detect exact supported spatial symmetry and, when useful, construct
representation-sector operators.
-
For each SCF iteration, solve Poisson’s equation for V_H, evaluate
V_xc, apply
H = -nabla_FD^2 + V_ion,local + V_H + V_xc + V_NL,
filter/diagonalize the occupied subspace, rebuild occupations and density,
mix the effective potential, and evaluate the energy.
-
Stop according to the translated PARSEC convergence criterion or
Max_Iter, then write the PARSEC-shaped report.
The Hamiltonian and nonlocal potential remain matrix-free during iterative
eigensolution. Static terms are prepared once; only density-dependent local
fields change during SCF.
Preparing a large periodic cell
The reference preparation of a periodic cell (local ionic potential, Kleinman-Bylander projectors, atomic
densities) measures the distance of every grid point to every atom image, so it costs atoms x grid points x
images: about 35 s for 64 atoms (47k points) and, extrapolated, almost two hours for 864 atoms (630k points).
With parsec_python.acceleration imported (the parsec_python.main entry point does) the projectors and
densities visit only the grid points inside the support radius of an atom (same rows and values as the scan),
and the local potential is evaluated as an Ewald split whose reciprocal part is one FFT of the structure
factor (the Gaussian width is chosen so the series ends below the Nyquist frequency of the grid, which makes
it exact on the grid). The 864-atom cell is prepared in about a minute. The potential equals the direct sum
once that sum is converged; the direct sum at its default tolerance leaves out images that still contribute a
few 1e-6 Ry, so the two differ by that much (acceleration/tests/test_periodic_setup.py). Both replacements
are for the orthorhombic grid with one spacing (with its shift, 0.5 steps unless Ignore_Symmetry or the
Grid_Shift block of PARSEC 1.5: the index boxes and the FFT phases follow it); Fortran’s general grid (oblique
cells, a step per lattice direction) and the wire/slab grids keep the direct scan and the direct Ewald sum. Where the FFT
potential is used, the periodic local forces differentiate the converged Ewald sum
(V_ion.ewald.local_potential_tolerance), so that they stay the derivative of the energy the SCF computed (with
the default truncation they missed about 1e-7 Ry/bohr in a Si2 cube and 5e-7 in the Si8 cube).
Since 8 November 2026 the other parts of the preparation scale to thousands of atoms as well (bulk diamond,
examples/3d_diamond_benchmark/profile_setup.py, one A100 node, the stages of prepare_periodic_single_point):
- Ewald ion-ion energy and forces (
V_ion/ewald.py: ewald_ion_ion_terms): the real-space terms over the atom
pairs within the cutoff (a k-d tree of the images of the atoms within the cutoff of the cell, any cell shape) and
the reciprocal terms from the structure factors on a box of reciprocal vectors (a product of one phase factor per
lattice direction, one matrix product per block of atoms), with the Ewald parameter of least estimated cost and
both truncations at 1e-18. 4,096 atoms: 0.5 s instead of 197 s for the sum over every translation and atom pair,
the same energy to 6e-14 relative (the old sum’s own truncation).
- Projectors: one radial spline per species and channel (it was rebuilt for every image) and only the images
whose support reaches the grid: the same operator, 10 times faster.
- Local ionic potential: the image balls of the atoms on worker threads (
PARSEC_PERIODIC_SETUP_THREADS, else
OMP_NUM_THREADS), added in the batches of the single-thread loop: the same potential bit for bit.
- Atomic densities (the SAD start and the core density of an orthorhombic bulk cell): on the GPU where one is
usable (
acceleration/V_ion/periodic_device.py: device_bulk_atomic_density), every grid point adding its terms in
the order and with the floating-point operations of the host’s image blocks (no fused multiply-add): the same
density bit for bit (--device cpu keeps the host sum).
- Gradient matrices (the
-2 i k.grad term of k-points, band structures, meta-GGAs) are built where they are
read (SCF.pbc.LazyGradient): a Gamma-point run never holds them.
Bulk diamond on one A100 node (CPUs shared with other runs): 2,744 atoms, 2.0 M points 102 s -> 26 s; 4,096 atoms,
3.0 M points 297 s -> 37 s (before the device densities), of which the atomic density 18 s, the local potential 9 s,
the finite-difference matrices 7 s, the projectors 3 s and the Ewald energy 0.5 s; a rank that shares the basis
(projectors and Laplacian only) 34 s -> 7 s.
Averages of the potential of a periodic cell
A 3-D periodic cell takes PARSEC 1.5’s two conventions for the constant parts of its potential (since 8 November 2026):
- The local ionic potential has a zero average. PARSEC builds it in G space without its
G = 0 term
(ionpbc.f90: vionz(1) = 0) and puts the average into the energy, E_alpha = (N_e/Omega) sum_a alpha_a with
alpha_a = int (V_a + 2 Z/r) d^3r. This code keeps its real-space Ewald split as the construction
(Periodic_Local_Potential: g_space is Fortran’s) and removes the average of the split
(SCF.pbc.zero_average_local_potential), sum_a alpha_a/V - 2 Z_tot/V^(1/3): its Ewald parameter
sqrt(pi)/V^(1/3) shrinks with the cell, and the average was -9.5 n^2 Ry for n^3 conventional cells of
diamond (-37 Ry for 64 atoms, -608 Ry for 4,096), with all the eigenvalues. The energy takes Fortran’s
E_alpha (the Alpha Energy of the report) in place of the term that cancelled that constant. On the grid the
average is zero up to the sampling of the short-ranged pieces (4e-4 Ry for carbon at 18 points per 3.567 A).
Zero_Average_Vxc (PARSEC’s potshift, the average of V_xc removed at every evaluation) is the default
of an unpolarized collinear 3-D cell; Zero_Average_Vxc: .false. restores the earlier potential. A
spin-polarized cell keeps it off unless the input asks for it (each channel losing its own average moves the
channels against each other: other occupations and another energy of a magnetic cell); wires and slabs never
take it (Fortran applies it for pbc%per == 3 only).
Neither changes the total energy, the density or the forces: the band energy loses N_e times each average and
the double-counting terms give it back (bulk diamond, 8 atoms: the total energy within 2.4e-13 Ry and the same 17
SCF iterations; the density within 2e-9, the SCF path). The eigenvalues and the Fermi level lose both averages
(+10.30 Ry for those 8 atoms: 9.35 from the local potential, 0.95 from V_xc) and now compare with Fortran’s.
Outputs written before the change print the earlier eigenvalues, and a parsec.dat written before it holds a
potential with the earlier constants.
SCF of large bulk cells
A bulk cell takes Smart_Subspace: .true. by default (since 8 November 2026; Subspace_Lower_Bound: monotone
restores the earlier PARSEC’s rule, Smart_Subspace: .false. selects PARSEC 1.5’s adaptive one). PARSEC’s later-SCF filter clips its lower bound at
0 Ry, which suits clusters (their unwanted states start near the vacuum level) but not a bulk cell, whose
eigenvalues lay tens of Ry below 0 with this code’s periodic potential before its averages were removed (bulk
diamond: -37 Ry at 64 atoms, -84 Ry at 216; Averages of the potential of a periodic cell): the filter then barely separates the occupied states from the conduction band, and the SCF test is met
while the energy is still far off (512 atoms: 65 iterations, 4.9 mRy/atom high; 1,000 atoms: 104 iterations, 13.9
mRy/atom high). PARSEC 1.5’s smart bound gives 8, 10, 16 and 17 iterations for 64, 216, 512 and 1,000 atoms, within
0.002 mRy/atom of the converged energy. A Kerker-type preconditioner of the
mixing (Mixing_Preconditioner: kerker, opt-in) is available for periodic cells; see
the package README for both.
Parallel k-points, band paths and GPUs (periodic systems)
The eigenproblems of different k-points (and spin channels) are independent: only the Fermi
level and the density couple them. A periodic SCF with k-points, and every point of a band path,
is therefore spread over workers (src/parsec_python/acceleration/Parallel, installed into the serial reference drivers of SCF/kpoint_solver.py) that each keep the Bloch projectors, eigenvectors and Ritz
subspaces of their own k-points; only potentials, eigenvalues and summed densities cross between
them. This covers the scalar, spin-polarized, spin-orbit, spin-orbit + collinear-spin and
non-collinear drivers and the bandstruc calculation. The results are the serial ones up to
round-off (the eigenvalues of a k-point are the same computation; densities differ only by the
order of the sum over k-points).
python -m parsec_python.main parsec.in --kpoint-workers 8 # CPU worker threads
python -m parsec_python.main parsec.in --kpoint-workers auto # default: half the CPUs
python -m parsec_python.main parsec.in --device gpu # GPUs, see below
python -m parsec_python.main parsec.in --device cpu # never touch a GPU
or the environment variables PARSEC_KPOINT_WORKERS (auto or a number; auto stays serial for a
single k-point and for small grids) and PARSEC_KPOINT_BACKEND (cpu, cupy, auto, numpy-device; an explicit override of --device).
The workers are threads of one process, as in the multi-GPU solver (there is no fork, which is
unsafe after the native OpenMP kernels or a CUDA context exist); the NumPy/SciPy/BLAS kernels release
the GIL, and each worker runs a single-threaded BLAS (a multi-threaded BLAS called from several threads at once gave wrong eigenpairs on Linux and an access violation on Windows; every BLAS library gets its former thread count back when the pool closes, so an OPENBLAS_NUM_THREADS of the launch is kept; the libraries are found on Linux and Windows, not on macOS). The sparse Bloch operators are
memory-bandwidth bound, so the gain depends on the machine: 2.9x for 8 workers and 1.9x for 4 on a
4-P-core + 8-E-core laptop (4-atom Co, 28^3 grid, 44 spinor states, 8 k-points, 3 SCF iterations),
more on a server with more memory channels. Memory grows with the number of workers only through
each worker’s own k-points.
GPUs. --device gpu (the default --device auto uses CuPy when it works, else the CPU; --device cpu
never does; --gpus/--gpu-ids choose the devices) puts the Bloch Hamiltonian, including the spin-orbit and Zeeman terms, and the whole
Chebyshev filter on the GPU, which is where almost all the matrix-vector products are. One worker
thread drives each CUDA device (PARSEC_CUPY_DEVICES=auto|current|0,1,... as in the multi-GPU
solver), and the k-points are dealt out round-robin. In an SCF the Ritz subspace of every k-point
stays on its device and each later SCF step (the SUBSPACE step: filter, QR, Rayleigh-Ritz) runs
there; the first solve is CHEBFF on the device, and for Eigensolver: chebdav it is CHEBFF with extra cycles
until CHEBDAV’s residual test (Diag_Tolerance, relative to the largest Ritz value) is met or
PARSEC_KPOINT_EXTRA_CYCLES (default 24) extra cycles were made: the device counterpart of CHEBDAV
(PARSEC_KPOINT_FIRST_SOLVE=chebdav runs the host CHEBDAV with the device filter instead). The same
converged first solve serves every k-point of a band path, with the existing retry from another random
start when the residual stays above the band tolerance. The eigenvectors come to the host only to form
the density. If the subspaces of a worker’s k-points would take more than 75% of the device memory they
stay on the host between solves (PARSEC_KPOINT_STATE_STORAGE=auto|device|host).
This device eigensolver is another path to the same SCF, so it agrees with the CPU to the convergence of
the SCF, not to round-off: on A100 with Convergence_Criterion 2e-5 (a gold cell, four k-points, the five
drivers) the total energy within 3e-10 Ry and the eigenvalues within 1.1e-5 Ry, with 2e-3 the
eigenvalues within 5.1e-4 Ry, after a different number of SCF steps at times.
PARSEC_KPOINT_SOLVER=host restores the former route (host eigensolver, only the filter on the
device), which equals the CPU to round-off; Eigensolver: arpack and diagla always take that route (they are host eigensolvers; the device
solver implements CHEBFF and CHEBDAV), and Dynamic_Diag_Tol hands the tolerance of every iteration to the
device workers (the residual test of the converged first solve). LDA+U keeps the k-point eigenproblems on the
CPU workers (the device operator has no LDA+U term). The k-point drivers print an SCF timing analysis (initial potentials, diagonalization,
density, Hartree, XC, mixing), the diagonalization time of every iteration and a K-point solver detail
block (worker start-up, Bloch projectors, operator upload, eigensolver, eigenvector download and the
device eigensolver’s own seconds and counters, summed over the workers). A Gamma-only periodic
spin-polarized run (no Kpoint_Method) goes through the 1x1x1 k-point driver when the k-points run on a
device, because the Gamma-point spin driver has no device path; python -m parsec_python.acceleration.benchmarks.check_kpoint_solver times the two routes on
an input. Static matrices (Laplacian, projectors) are uploaded
once per device; an SCF step uploads only the local potential and fields. The host BLAS runs one thread per device worker.
python -m parsec_python.acceleration.benchmarks.check_gpu_kpoints compares the device operator, the filter, a short non-collinear
spin-orbit SCF and a short band path against the CPU and times them; run it first on a GPU node.
It needs cupy; --backend numpy-device runs the same device code on the host. This is a first
version of the GPU path: check_gpu_kpoints passes on an NVIDIA A100-SXM4-80GB with CuPy 14.2.0
(operator, filter, a short non-collinear spin-orbit SCF and a band path against the CPU); other
devices and multi-GPU runs have not been checked yet.
Several GPUs and nodes for one large eigenproblem (MPI)
A k-point or non-collinear basis that does not fit one GPU (a two-component basis of a few thousand
states on a few million grid points is hundreds of GB) is split by blocks of grid rows over the GPUs of
several nodes. Start one MPI rank per GPU and add --mpi (or PARSEC_MPI=1; needs mpi4py):
srun --nodes=3 --ntasks=12 --ntasks-per-node=4 --gpus-per-node=4 --gpu-bind=none \
python -m parsec_python.main parsec.in --mpi --device gpu --gpus 4
Rank r holds rows [start_r, stop_r) of every orbital, of the finite-difference matrices, of the
projectors and of the local fields, and picks the GPU of its local index. Applying the Hamiltonian
exchanges the halo rows of the stencil with the neighbouring ranks and sums the overlaps with the
projectors (and the spin-orbit projectors) over the ranks. Each stencil matrix is split into the part on
the local rows and the part on the halo rows: the exchange is started, the local part is applied while it
runs, and the halo part is added when the rows have arrived. The two spin components are applied as one
block, so a spinor application makes one exchange and one projector sum. Orthonormalization is a shifted Cholesky QR
of the summed Gram matrix, the Rayleigh-Ritz projection and the residuals are summed states x states
matrices, and the root’s eigenvalues and rotations go to every rank. The SCF driver is replicated on
every rank (the ranks compare a checksum of the potentials every iteration and stop with a message
should they ever diverge); the density is formed from the local rows and joined on every rank, and only
rank 0 writes the log and the archive. Wavefunctions are not gathered. The tasks of a job (k-points,
spin channels) are solved one after the other, each over all the ranks; the independent points of a band
path are dealt out to the ranks instead.
A GPU needs about twice the local rows of one subspace plus a few states x states matrices, so a basis
of B GB needs at least 2B/(0.92 x GPU memory) GPUs; the run stops with that number if the GPUs are
too few. The halo rows and the sums go through the host unless the MPI library is CUDA aware and
PARSEC_MPI_CUDA_AWARE=1 (Cray MPICH also needs MPICH_GPU_SUPPORT_ENABLED=1): then they go between the GPUs and
the halo exchange overlaps the local product. Without GPU-aware MPI the exchange cannot overlap much, because
the copy to the host is synchronous. The log’s eigensolver detail gives the time rank 0 spent packing,
waiting for halo rows and summing over the ranks.
acceleration/tests/test_kpoint_mpi.py runs the distributed operator, the drivers and the command line
on 2 and 3 ranks (the device code on the host) against the single-process solver; it has not been run on
GPUs or on more than one node. Because no rank holds whole orbitals, --mpi refuses (input error) LDA+U,
Eigensolver: arpack/diagla, forces, relaxation and molecular dynamics of periodic runs at the Gamma point
alone, with spin, with spinors or with a hybrid functional, the Ylm-projected DOS and Output_GW; a
non-collinear cluster’s parsec.dat is written without wavefunction records. The forces of the scalar k-point
SCF (a cell sampled beyond the Gamma point) run with --mpi since 2026-11-17: the nonlocal force is a sum over
the states, so every rank of a k-point pool adds the terms of its columns (of the sectors of its k-points, made
whole on its GPU 32 states at a time) and the parts are summed over the ranks; relaxations and molecular dynamics
take them, rank 0 writes their files.
Band structures (periodic systems)
A bandstruc block adds a non-self-consistent band structure after the SCF, as in
Fortran PARSEC’s calc_bands. Each line is a path segment in relative
(reciprocal-lattice) coordinates followed by a label, and bandstruc_points is the number of
k-points on the shortest segment (default 20); longer segments get proportionally more, so the
density along the path is constant. Without the keyword a segment’s share is truncated to an
integer, as before; a written bandstruc_points rounds it to the nearest integer, as PARSEC 1.5
does (1.5’s own default is 100). Bands_FF_MaxIter (PARSEC 1.5) sets the CHEBFF filter cycles of
the band k-points (default FF_MaxIter):
begin bandstruc
1 0.0 0.0 0.0 0.5 0.0 0.0 gamma-X
2 0.5 0.0 0.0 0.5 0.5 0.0 X-M
3 0.5 0.5 0.0 0.0 0.0 0.0 M-gamma
end bandstruc
bandstruc_points 20
The Hamiltonian follows the SCF mode, so the same block gives scalar, collinear spin-polarized
(up and down channels), self-consistent spin-orbit (SO_from_scratch with SO_PSP),
spin-orbit plus collinear spin, and non-collinear bands. Running the same input with and
without the spin-orbit switches gives the effect of spin-orbit coupling. The perturbative
spin-orbit route (Spin_Polarization with SO_PSP but no SO_from_scratch) is rejected for
bands.
At each k-point the Bloch Hamiltonian is built from the converged SCF potential and solved from
scratch by the SCF’s first eigensolver (Eigensolver, default chebdav, which converges to
Diag_Tolerance; chebff only applies FF_MaxIter filter cycles and can leave the upper bands
poorly converged). The log reports the largest residual |Hv - ev| and warns when the bands are
not converged.
CHEBDAV adds Matvec_Blocksize vectors per step and, at a highly symmetric k-point whose
degenerate level is larger than that block (an 8-fold level in a folded cubic cell, 16-fold with
spin-orbit), can leave reported bands unconverged. This is an extension beyond Fortran: such a
k-point is re-solved with a larger block and a new random start (up to five attempts, keeping the
smallest residual), and the log and archive record how many k-points needed it.
The converged SCF potentials are stored in the SCF archive (parsec_python_results.npz), which is
written before the band step. To recompute bands (another path, States_Num, solver settings)
without repeating the SCF, pass the archive back with --bands-from (the log goes to
parsec_bands.out, so the SCF log is kept):
python -m parsec_python.main parsec.in --bands-from parsec_python_results.npz
Outputs (written next to parsec.in):
bands.dat and bands_plot.dat in Fortran’s formats (eigenvalues in Ry / eV, not shifted by
the Fermi level; bands.dat carries the SCF Fermi level),
parsec_python_bands.npz with the k-points, segment names, eigenvalues, residuals and (for
spinor Hamiltonians) <sigma> of every state,
bands_spin.dat for spinor bands (spin-orbit, non-collinear): for every band a gnuplot block of
k index, path length [1/bohr], E [eV], <S_x>, <S_y>, <S_z>, level size, with the spin in units of
hbar/2 (the Pauli expectation, between -1 and 1) in the axes of the cell. Only the sum of the spin over a
degenerate level is determined (Kramers pairs, every level of an inversion-symmetric crystal): any mixture
of the states of a level is an eigenvector. So states within 1e-4 Ry of each other show the mean spin of
their level, and the last column is the level’s size; the archive keeps the spin of each state as the
eigensolver returned it. For a Rashba or Dresselhaus system the bands are non-degenerate away from the
time-reversal-invariant points and carry a well-defined spin texture.
The plots below need matplotlib, which is not among the requirements (python -m pip install matplotlib);
the files above are written without it. Plot the spin texture (bands coloured by <S_x>, <S_y>, <S_z>,
energies relative to the Fermi level):
python -m parsec_python.Output.bands --spin parsec_python_bands.npz --components xyz \
--names "G-X,X-M,M-G" --window -2 2 -o bands_spin.png
(gnuplot: plot 'bands_spin.dat' using 2:3:4 with lines lc palette for S_x.) A surface Rashba state needs
a slab (non-periodic along the surface normal), which the periodic cells here do not have yet; bulk examples
are the Dresselhaus splitting of a zinc-blende crystal off the high-symmetry lines and non-centrosymmetric
Rashba-type semiconductors.
Overlay several runs, e.g. without and with spin-orbit coupling:
python -m parsec_python.Output.bands noso/bands.dat soc/bands.dat \
--labels "no SOC" "with SOC" --names "G-X,X-M,M-G" -o bands.png
With Use_Fortran_Routines: .true. (see “Two sets of periodic routines” below), primitive fcc, bcc,
hexagonal or triclinic cells (Cell_Shape with three lattice vectors, Coordinate_Unit: lattice_vectors,
Super_Cell, Super_Cell_Vac) use Fortran’s grid along the lattice directions with the auxiliary-direction
Laplacian of pbc_grid_coefs; they run on the reference solver (main.py hands them over), and their bands
follow the primitive Brillouin zone. An orthorhombic cell whose sides share one grid spacing keeps this port’s
original grid there.
Non-self-consistent runs, density of states, Calc_Hartree_G, BerkeleyGW files
nscf_kpoints (rows kx ky kz weight, nscf_kpoint_unit, nscf_states_num) with
Restart_Run: .true. is Fortran’s calc_nscf: no SCF loop, one eigensolve per k-point in
the potential of parsec.dat (also one written by Fortran PARSEC, any cell shape), the
eigenvalue table of every k-point in parsec.out, the levels in parsec_python_nscf.npz;
no parsec.dat/eigen.dat is written. The occupations use the Fermi level of the SCF that
wrote parsec.dat (Fortran without Output_GW uses an uninitialized 0 Ry). nscf_kgrid,
nscf_kgrid_shift and nscf_fermi_level belong to Output_GW and have no effect without it.
Output_GW: .true. writes BerkeleyGW’s WFN, RHO and VXC (binary, complex flavour,
BerkeleyGW 4.0 header) beside the input, as Fortran’s gw_write: after a non-self-consistent
run (which then needs nscf_kgrid, nscf_kgrid_shift and nscf_fermi_level, the Fermi level
of the NSCF occupations) or after an SCF with k-points. G-vector lists, star-averaged RHO
and VXC and the k-spheres follow Fortran record by record (tests/BGW_interface: identical
G lists, RHO/VXC to 5e-16). Spin-polarized files have BerkeleyGW’s layout (Fortran’s spin
records are not readable by BerkeleyGW); clusters, wire/slab, spinors, bandstruc, forces and
Gamma-only SCF runs are refused by name.
Create_DOS writes Fortran’s DOS file after the SCF: the linear-tetrahedron DOS of the
Monkhorst-Pack grid for a cell (DOS_Pnum, DOS_MP_Grid; with Restart_Run the SCF runs on
DOS_MP_Grid), with YLM_DOS_L (0-3) and the per-species ylm_dos_cutoff the s-f projected
DOS of every atom, and for a cluster the histogram of the occupations. The projection fixes two
defects of ylm_eig (s channel without the radial factor, no Bloch phase);
YLM_DOS_Fortran_Projection: .true. reproduces Fortran’s numbers.
Calc_Hartree_G (bulk) solves V_H(G) = 8 pi rho(G)/|G|^2 by FFT. Fortran’s own routine is
broken (it says so and diverges); the default finite-difference solve is unchanged.
These run on the reference solver (main.py hands them over); its k-point drivers and the
band machinery put their eigenproblems on the device k-point workers when a GPU is visible (the
NSCF k-points, the k-point SCF of the DOS and of Output_GW, band paths, and the k-point levels
that Save_Intermediate_Eigenvalues writes every iteration). The tetrahedron sums of a large DOS
(the Ylm-projected one on a fine mesh) run on the same GPU with the numbers of the host
(acceleration/Output/device_dos.py, PARSEC_DOS_DEVICE=auto|on|off); what stays on the host
(Bloch projectors, Ylm projections, the FFTs of WFN) is a few percent of such a run. Two
combinations run on the accelerated path instead: Create_DOS of a cluster and bandstruc after
the Gamma-point SCF of a scalar orthorhombic cell (the bands then on the device workers), both
without --mpi (acceleration/Output/post_scf.py).
The cell may have any shape (see “Periodic cells of any shape” below): fcc, bcc and hexagonal crystals can
use their primitive cells, and the k-points of a path are given in the primitive reciprocal-lattice
coordinates. Fortran’s nscf_kpoints (an explicit k-point list read from a parsec.dat restart) is not
implemented.
Periodic cells of any shape (the default routines)
Boundary_Conditions: bulk takes the three lattice vectors of a Cell_Shape block (one line with three
numbers still means an orthorhombic box), so primitive fcc, bcc, hexagonal and triclinic cells work like the
Fortran code’s:
begin Cell_Shape
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0
end Cell_Shape
Lattice_Vector_Scale: 3.567 ang
Coordinate_Unit: lattice_vectors # fractional coordinates, folded into the cell
The grid axes follow the lattice vectors, each with an even number of points 2*nint(|a_i|/(2h)) as in
Fortran, so the steps along the three axes may differ. The Laplacian carries the metric of the cell: its mixed
second derivatives are written as pure second derivatives along the shortest extra lattice directions (one
diagonal u+v for hexagonal cells, three for fcc, one body diagonal for bcc), after the Fortran pbc_grid_coefs
(Natan et al.); the gradient used by the Bloch term and by PBE follows from the same metric
(Laplacian/lattice_metric.py). The periodic Ewald sums, the nonlocal projector images, the
Monkhorst-Pack grid and the band paths use the lattice and reciprocal vectors directly. Atoms must lie in the
cell (fractional coordinates [0, 1)), which Coordinate_Unit: lattice_vectors does by folding.
Checked against the Fortran code on diamond in the fcc primitive cell (same grid, linear interpolation of the
tables): the band energies agree to 1e-5 Ry (a constant shift of the zero of the potential removed) and the total
energy to 7e-5 Ry for the two atoms on a 24-point grid; two descriptions of one crystal (cubic cell and sheared
cell on the same grid points) give the same energy to 1e-8 Ry. The GPU solvers use the same sparse operators; the
fast neighbour search and local-potential routines of the acceleration package fall back to the exact direct
sums for such cells, which is slower for large cells.
Two sets of periodic routines
Two implementations exist for the periodic cells (grid rule and shift, oblique-cell operator, local potential,
symmetry, forces, relaxation and molecular dynamics, slabs) and for the forces and ionic loops of spinor
orbitals: Andrew Grieder’s and the Fortran-derived routines of the parity round (Input/routines.py). The input
parameter Use_Fortran_Routines chooses:
-
not given: the default of each feature. That is Andrew Grieder’s routines, except for these inputs, whose
default is the Fortran-derived routines (parsec.out names that default in its routines line):
- slabs (
Boundary_Conditions: slab);
- a shifted Monkhorst-Pack grid of a bulk cell (
Monkhorst_Pack_Shift);
- a
Kpoint_List of unequal weights of a bulk cell (Andrew Grieder’s routines refused it before 8 November 2026;
with .false. they take it now, see “Irreducible k-points on the default routines”);
- forces, a relaxation or molecular dynamics of a bulk cell at the Gamma point (no k-point input), with or
without spin polarization, where the orthorhombic grid of the Fortran-derived routines has the points of
Andrew Grieder’s grid (the same counts, steps and shift) and every species uses
Cubic_Spline (his local
potential is the cubic spline), so that the run with forces has the energy of the run without them: the
accelerated path of the Fortran-derived routines is 2.5-5 times faster there, and their forces are the
derivative of their energy. Since the parity round of PARSEC 1.5 both orthorhombic grids are Fortran’s
(adjust_step’s even number of points, half a step off the origin unless Ignore_Symmetry), so this holds
for cells with and without symmetry; the grids differ where the space group’s fractional translations
change the number of points (Andrew Grieder’s grid has no space group) and where a side is an even multiple
of the spacing only up to round-off (PARSEC 1.5’s slack of adjust_step);
- a bulk cell on Fortran’s general grid whose space group’s fractional translations change the number of grid
points (diamond in the fcc cell: 16 points per vector at a spacing of 0.4 bohr, against 18 without the space
group), in a run with k-points, spin polarization or spinors and without forces.
Andrew Grieder’s routines stay the default where the grids differ, for linear radial tables, and where the Fortran-derived ones would be slower: an oblique
cell at the Gamma point (his accelerated oblique path), the Gamma point given as a one-point k-point grid,
forces on an oblique cell, forces with k-points, and the forces and ionic loops of spinor orbitals;
-
.false.: Andrew Grieder’s routines wherever his code accepts the input, his slab and his shifted mesh
included (see “Irreducible k-points on the default routines” below);
-
.true.: the Fortran-derived routines.
The Gamma point given as a one-point k-point grid (Kpoint_Method: mp, 1 1 1, or a list of one k = 0) is the
Gamma-point calculation of the accelerated path under both sets of routines (real orbitals, no k-point loop,
reported as such in parsec.out); with .true. it used to go to the reference k-point solver.
Irreducible k-points on the default routines
With Use_Fortran_Routines: .false. the Monkhorst_Pack_Shift mesh of a bulk single point (more than one point,
scalar orbitals with or without spin polarization, no hybrid functional, no forces or moving atoms) is reduced to
its irreducible wedge, as on the Fortran-derived routines, but on the grid of Grid_Spacing. The Fortran-derived
routines make their grid commensurate with the fractional translations of the space group (adjust_step), which
for diamond’s quarter translations means 16 points per cubic edge where Grid_Spacing asks for 18. The default
routines keep their grid and use the operations of the crystal that map that grid, and the k-point mesh, onto
themselves (Grid.space_group.find_grid_space_group, Grid.kpoints.mesh_preserving_operations), with time
reversal; the density is averaged over the same operations (Symmetrize_Charge_Density, true by default there as
on Fortran’s k-point path). For diamond at 18 points per edge, with an atom at the origin and the points half a
step off it, these are the 24 operations of Td about the atom: with time reversal they give the wedge of Oh,
4, 4 and 10 points for Gamma-centred 2x2x2, 3x3x3 and 4x4x4 meshes (8, 27 and 64 before). parsec.out names the
operations that were dropped (24 of the 48 operations ...). Since the operations map the mesh onto itself, the
wedge with the averaged density is the full mesh: the 8-atom cube at 18 points per edge (PBE, Convergence_Criterion
1e-8 Ry) gives the energy of the full mesh within 1e-10 Ry for 2x2x2, 3x3x3 and 4x4x4 (-91.1711622940,
-91.2224516198, -91.2250126608 Ry; 4x4x4 in 59 s against 263 s for the 64 points on a laptop CPU).
Ignore_Symmetry or Symmetrize_Charge_Density: .false. reduce by time reversal alone (k and -k have the same
density). Hybrids (their exchange sums over the full mesh), spinors and moving atoms keep the full mesh of equal
weights, as before 8 November 2026, when every input with .false. did. Without Use_Fortran_Routines a shifted
mesh still selects the Fortran-derived routines (above).
A Monkhorst_Pack_Grid without a Monkhorst_Pack_Shift block (more than one point) is, since 18 November 2026,
PARSEC 1.5’s mesh: PARSEC reads mpshift from the block only, so without it the shift is zero, and it reduces
every Monkhorst-Pack grid with irrbz (init_var.F90:281-289; the PARSEC 1.5 binary prints shift = 0.0000 0.0000 0.0000 and the same table as with a zero block). On either set of routines the input now runs exactly as with a
zero Monkhorst_Pack_Shift block, the Gamma-centred mesh (i-1)/n reduced to its irreducible wedge with the
density symmetrized (diamond and Si cubes: 4, 4 and 10 points for 2x2x2, 3x3x3 and 4x4x4), except that the missing
block does not select the Fortran-derived routines. Before, such an input ran this port’s own unreduced mesh
(2i-n-1)/(2n) (points at ±1/4 and ±3/4 of a step for even n, no time reversal, no symmetrization), which
PARSEC_MP_UNSHIFTED_MESH=port keeps; a mesh of one point is the Gamma point under both.
A Kpoint_List of unequal weights of a bulk single point runs on the default routines with .false. (before 8
November 2026 it went to the Fortran-derived routines by itself): every level is weighted by its point in the Fermi
level, the density and the band energy, and the density is that of the listed points, as in PARSEC, whose
Symmetrize_Charge_Density is false for a list (a warning says so). For a list that is an irreducible wedge,
Symmetrize_Charge_Density: .true. averages the density over the operations that map the grid onto itself (the
2x2x2 wedge of the 8-atom cube written as a list, weights 1, 3, 3, 1: -91.1711622940 Ry, the full mesh). Forces and
moving atoms with such a list, and the average with spinors or a hybrid, keep the Fortran-derived routines (the forces
of a wedge are completed over the space group there). Symmetrize_Charge_Density: .true. of any other input of these
routines selects the Fortran-derived ones as before.
The space group is found by a neighbour-tree search (Grid.space_group.fast_crystal_operations, the operations
and translations of Fortran’s atftmt; 0.8 s and a few MB for 4,096 atoms, where the statement-by-statement port
_crystal_operations needs (N, N) arrays), once per structure. The fractional translations that adjust_step
meets are snapped to fractions p/q (q <= 48) within 1e-8 (Grid.space_group.snapped_translation): coordinates
written with ten decimals gave 0.2499999999963 for diamond’s quarter, whose steps never settled. The density
table is built from the integer affine maps of the operations (3 M points and 24 operations: 1.5 s, 0.29 GB of
int32); acceleration/SCF/periodic_symmetry.py applies them on a GPU without the table.
An input that Andrew Grieder’s routines do not compute (wires, charged sheets, forces of a slab, unequal k-point
weights of a slab or with forces, LDA+U, NSCF, other pseudopotential formats or functionals, …) runs on the Fortran-derived routines by
itself, also with .false., with a warning in the log and in parsec.out. Labels that the shared eigensolvers
and SCF loops read the same way under both sets choose nothing: FF_MaxIter, Chebyshev_Degree_Decrease_After,
Convergence_Criterion_Approach, Chebyshev_Filtering, Maximum_Matvec, Fix_Number_Eigenvalues and PARSEC 1.5’s
eigensolver labels, the MPI and library tuning labels (MPI_Groups/Npcol, Exp_Comm, Max_Lap_Buffers,
Use_ScaLAPACK, …), the FDET labels (Potential_Field: .false., which PARSEC 1.5’s bak_complete_parsec.in
writes in every run, Write_Potential_Field, AFM_Scan, …: FDET itself is refused for a periodic input) and
Recenter_Atoms_In_Aperiodic_Directions (.false. keeps the coordinates of the input, as Andrew Grieder’s routines
do for a bulk cell). Any other label chooses nothing either when it is written at a value that does nothing:
Input/routines.py holds the table NO_EFFECT (label -> the predicate “has no effect” and its reason), for example
Add_Point_Charges: .false., Point_Typ_Num 0, Alpha_Filter 0, Create_DOS: .false., DOS_Pnum without
Create_DOS, LDAplusU_U 0, the mixer defaults (Mixing_Restart_Factor 0.3, …), NSCF_States_Num without a
non-self-consistent run, Output_Data: .true., which are the lines PARSEC 1.5’s bak_complete_parsec.in writes at
their defaults. A value that acts still chooses the Fortran-derived routines, and the warning names it
(input option(s) mixing_restart_factor = 0.1 (read by the Fortran-derived routines only)). Before 4 November 2026 writing Convergence_Criterion_Approach, Chebyshev_Filtering,
Maximum_Matvec, Fix_Number_Eigenvalues, MPI_Groups, Exp_Comm or Max_Lap_Buffers moved a periodic input to the
Fortran-derived routines (Si8 at h 0.45: 1.3 mRy at the Gamma point, 3.8 mRy on a 2x2x2 grid, from the routines). A
Restart_Run, NSCF or DOS input runs on the Fortran-derived routines, so the SCF that writes its parsec.dat
should run on them too (a file of another grid is refused).
The grids of the Fortran-derived routines are PARSEC’s (1.5): along every lattice vector the largest even number
of points whose step is not below Grid_Spacing, commensurate with the fractional translations of the space
group (none with Ignore_Symmetry, molecular dynamics or manual movements), and the points half a step off the
origin, or on it with Ignore_Symmetry and along a lattice vector that is not orthogonal to another one. An
orthorhombic cell whose steps agree takes the orthorhombic grid and its fast paths, every other cell Fortran’s
general grid. Up to the parity round of PARSEC 1.5 their orthorhombic grid had round(L/h) points from the origin;
its results, and the parsec.dat files written on it, changed with the rule (a restart from such a file is
refused by its shift). Periodic atoms are translated to fractional coordinates in [-1/2, 1/2) at start, as
PARSEC 1.5 does (printed coordinates and trajectories; no number of the run changes beyond round-off).
PARSEC 1.5’s Grid_Shift block (one line of three numbers in grid steps, their absolute values; zero along an
oblique periodic direction) sets the shift of every grid, clusters included, whatever Ignore_Symmetry says.
Foldblock_Side_Length 2 fills a cluster domain up to whole blocks of 2 x 2 x 2 points and switches the symmetry
off, as 1.5 does (TierI/0d_H2: 25600 points instead of 22575); for a bulk cell it </s_z></s_y></s_x></s_z></s_y></s_x>
README 内容过长,已截取前 64 KB。完整内容请前往 GitHub 仓库查看。
评论