Skip to content

Refactor LCAO workflows to use SimulationContext#7668

Open
goodchong wants to merge 1 commit into
deepmodeling:developfrom
goodchong:inandoutv2
Open

Refactor LCAO workflows to use SimulationContext#7668
goodchong wants to merge 1 commit into
deepmodeling:developfrom
goodchong:inandoutv2

Conversation

@goodchong

@goodchong goodchong commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

I plan to refactor the global variable implementation of this project using a new approach.

  1. Continue the current approach of categorizing and breaking down global variables into smaller structs.
  2. The new global variable mechanism will be implemented first in the module hs for experimentation; the code of other parts and modules will remain unchanged.
  3. Global calls will still be used in L1 and above, while parameter-based calls will be used in L2 and below.

The new and old global variable mechanisms will currently operate in parallel. The new global variables should contain all the contents of the old global variables, not just those used by the module hs. Variables will be passed to the module hs code as parameters, rather than being copied separately.

Summary

  • introduce a driver-owned SimulationContext builder and scoped runtime binding
  • pass explicit context data through LCAO, module_hs, LR, RT-TDDFT, and restart output paths
  • add mapping manifests, focused context tests, module_hs compatibility tests, and governance checks

Motivation

This change reduces lower-level reads from GlobalV, GlobalC, and PARAM while keeping legacy globals authoritative at the orchestration boundary. Runtime-derived fields are captured after pseudopotential and basis initialization, and the KS-to-LR transition remains inside the context lifetime.

The staged governance check reports a net reduction of 120 GlobalV, GlobalC, and PARAM references at PR scope.

flowchart TB
    ROOT["ABACUS 项目"]

    subgraph S0["L0 装配与配置入口层"]
        direction LR
        MAIN["source_main<br/>Main、Driver"]
        CONTEXT["source_context<br/>Builder、Adapter、Context"]
        INPUT["module_parameter<br/>INPUT 解析"]
    end

    subgraph S1["L1 工作流编排层"]
        direction LR
        ESOLVER["source_esolver"]
        CTRL["module_ctrl"]
        MDCTRL["MD 编排<br/>run_md、md_base、md_func"]
        RELAXCTRL["Relax 编排<br/>relax_driver"]
        LREX["LR ESolver<br/>临时目录例外"]
    end

    subgraph S2["L2 计算方法与领域层"]
        direction LR
        LCAO["source_lcao<br/>LCAO、Gint、RI、DeepKS、DFT+U、RT、LR"]
        PW["source_pw<br/>PWDFT、OFDFT、SDFT、DFPT"]
        MDALG["MD 算法<br/>FIRE、Verlet、Langevin、MSST、NHChain"]
        RELAXALG["Relax 算法<br/>CG、BFGS、LBFGS、SD"]
    end

    subgraph S3["L3 通用科学计算组件层"]
        direction LR
        HAMILT["source_hamilt<br/>Hamiltonian、Ewald、XC、vdW"]
        HSOLVER["source_hsolver<br/>CG、Davidson、BPCG、ELPA、PEXSI"]
        ESTATE["source_estate<br/>ElecState、Charge、Potential、DM"]
    end

    subgraph S4["L4 数据模型与外部边界层"]
        direction LR
        CELL["source_cell<br/>UnitCell、Symmetry、Neighbor"]
        BASIS["source_basis<br/>AO、NAO、PW"]
        PSI["source_psi<br/>波函数数据"]
        IO["source_io 叶子模块<br/>HS、WF、DOS、Restart、Output"]
    end

    subgraph S5["L5 基础设施与 Kernel 层"]
        direction LR
        BASE["source_base<br/>Container、FFT、Grid、Mixing、Libm"]
        DEVICE["module_device<br/>CPU、CUDA、ROCm、DSP"]
        KERNEL["各模块 Kernels<br/>POD、Buffer、数值计算"]
    end

    ROOT ==> MAIN
    MAIN ==> ESOLVER
    ESOLVER ==> LCAO
    LCAO ==> HAMILT
    HAMILT ==> CELL
    CELL ==> BASE

    classDef l0 fill:#f6c85f,stroke:#7a5b00,color:#111
    classDef l1 fill:#6fbbd3,stroke:#24566b,color:#111
    classDef l2 fill:#91cf60,stroke:#3d6d24,color:#111
    classDef l3 fill:#b39ddb,stroke:#5e4d83,color:#111
    classDef l4 fill:#ffab91,stroke:#8b4c39,color:#111
    classDef l5 fill:#b0bec5,stroke:#455a64,color:#111

    class MAIN,CONTEXT,INPUT l0
    class ESOLVER,CTRL,MDCTRL,RELAXCTRL,LREX l1
    class LCAO,PW,MDALG,RELAXALG l2
    class HAMILT,HSOLVER,ESTATE l3
    class CELL,BASIS,PSI,IO l4
    class BASE,DEVICE,KERNEL l5
Loading

@mohanchen mohanchen added the Feature Discussed The features will be discussed first but will not be implemented soon label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Discussed The features will be discussed first but will not be implemented soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants