Skip to content

Implement Makov–Payne isolated-cell correction and input option#1

Merged
kluonju merged 1 commit into
developfrom
codex/add-makov-payne-correction-for-cubic-systems
May 13, 2026
Merged

Implement Makov–Payne isolated-cell correction and input option#1
kluonju merged 1 commit into
developfrom
codex/add-makov-payne-correction-for-cubic-systems

Conversation

@kluonju

@kluonju kluonju commented May 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide an isolated-cell electrostatic correction for charged systems in 3D supercells (Makov–Payne) and estimate a corrected vacuum level for eigenvalue alignment.
  • Allow users to enable the correction via an input option and include the correction consistently in total energy accounting and output.

Description

  • Add makov_payne.h / makov_payne.cpp implementing makov_payne_correction that computes first- and second-order Makov–Payne corrections and attempts to estimate a corrected vacuum level; this implementation supports cubic lattices (latname = sc, fcc, bcc) and uses MPI reductions where available.
  • Integrate the correction into the electronic energy workflow by adding makov_payne.cpp to the build, including makov_payne.h in elecstate_energy.cpp, computing correction_el when input.assume_isolated == "makov-payne", and supplying the electrostatic potential via H_Hartree_pw::v_hartree combined with Potential::get_fixed_v() and Potential::get_ucell().
  • Extend the fenergy data structure and routines to hold, accumulate, and print the new correction_el field, and include it in both calculate_etot() and calculate_harris().
  • Add a new input parameter assume_isolated with parsing, allowed aliases (m-p, mp) and validation that limits usage to cubic lattices in read_input_item_system.cpp.
  • Expose Potential::get_ucell() and add makov_payne.o / makov_payne.cpp to the build lists (Makefile.Objects and CMakeLists.txt).

Testing

  • Project configured and built with cmake and make -j which completed successfully.
  • The extended energy bookkeeping was exercised by running the electronic energy calculation paths and the fenergy print routines, and the added correction_el value is reported in outputs.
  • Existing automated regression/unit tests were executed and passed with no failures.

Codex Task

@kluonju kluonju merged commit 976b3f2 into develop May 13, 2026
kluonju pushed a commit that referenced this pull request Jun 20, 2026
* Refactor: Restructure tools/ directory for clarity and fix include analysis script

This commit consolidates three previous commits (#1, #2, deepmodeling#3) into a single
comprehensive refactor of the tools/ directory, addressing both
organizational structure and a path-related bug in the code analysis script.

1. tools/ directory reorganization
   - Group all numerical atomic orbital (NAO) generation tools under
     01_NAO_generation/, including:
       * SIAB/ (Simulated Annealing method in C++)
       * pytorch/ and pytorch_dpsi/ (PyTorch gradient methods)
       * pytorch_gradient_source/ (original PyTorch implementation)
       * lcao_bash/ and abfs_bash/ (bash-based orbital generators)
       * qo/ (quasiatomic orbital generation)
       * Generate_Orbital_AllInOne.sh (main entry script)
       * examples/ (example input files)
   - Move all post-processing and visualization tools under
     02_postprocessing/:
       * rt-tddft-tools/, stm/, average_pot/, selective_dynamics/, plot-tools/
   - Place source code analysis tools under 03_code_analysis/
   - Rename windows/ to 04_windows_installation/ for consistency
   - Use numerical prefixes (01_, 02_, 03_, 04_) to define a clear order
   - Use git mv to preserve file history throughout the refactor

2. New tools/README.md
   - Add a comprehensive README with directory tree, quick start guide
     and tool descriptions

3. Fix generate_include_analysis.py path bug
   - The script computed repo_root using os.path.dirname(script_dir),
     assuming the script lived in tools/. After moving to
     tools/03_code_analysis/, this resolved to tools/ instead of the
     repository root, causing os.walk to find no source files.
   - Update to os.path.dirname(os.path.dirname(script_dir)) to correctly
     resolve the repository root from the new script location.

Combined previous commits:
  6e3b7954c add code analysis python file
  546d7cd76 update tools
  92094b81d update

* Fix: Update path references in docs and source code after tools/ directory restructuring

After the tools/ directory reorganization, several path references in documentation
and source code were still pointing to the old directory structure. This commit
updates all hardcoded paths to match the new organization:

1. docs/advanced/windows_installer.md
   - tools/windows/ → tools/04_windows_installation/ (3 occurrences)

2. docs/advanced/input_files/input-main.md
   - tools/average_pot/aveElecStatPot.py → tools/02_postprocessing/average_pot/aveElecStatPot.py

3. docs/parameters.yaml
   - tools/average_pot/aveElecStatPot.py → tools/02_postprocessing/average_pot/aveElecStatPot.py

4. source/source_io/module_qo/to_qo_kernel.cpp
   - /tools/qo/postprocess.py → /tools/01_NAO_generation/qo/postprocess.py

5. source/source_basis/module_nao/atomic_radials.cpp
   - Update SIAB/PyTorchGradient paths to 01_NAO_generation/pytorch and 01_NAO_generation/SIAB

6. source/source_io/module_parameter/read_input_item_output.cpp
   - tools/average_pot/aveElecStatPot.py → tools/02_postprocessing/average_pot/aveElecStatPot.py

* add a threshold in 17_DS_DFTU/01_LCAO_SPIN_S2_Z

---------

Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
Co-authored-by: Xiaoyang Zhang <tsfxwbbzxy@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant