Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7c2dedd
add nonlocal_info_base.h
Jul 15, 2026
520a708
move setup_nonloal to source_lcao
Jul 15, 2026
e1375e2
refactor: dependency inversion for non-local pseudopotential
Jul 15, 2026
1f5a676
fix bug
Jul 16, 2026
8ab9bc3
fix compile bugs
Jul 16, 2026
3bf62c4
due to the change of unitcell, we need to change related tests
Jul 16, 2026
592b2f1
remove some PARAM
Jul 16, 2026
4e17484
fix GPU compiling bug
Jul 17, 2026
9266305
Merge branch 'develop' into 20260715
mohanchen Jul 17, 2026
795b00f
Merge branch 'develop' into 20260715
mohanchen Jul 18, 2026
e10a01b
remove PARAM in source_cell
Jul 18, 2026
a50e4f0
remove PARAM
Jul 18, 2026
a115e6c
remove PARAM
Jul 18, 2026
fa23597
remove PARAM
Jul 18, 2026
2a6c0a0
update read pseudopotentials
Jul 18, 2026
688fcdb
update removing PARAM
Jul 18, 2026
36f5b0b
update
Jul 18, 2026
1db0d9b
remove PARAM
Jul 18, 2026
1dc7835
remove PARAM in klist
Jul 18, 2026
275ec8b
update, removing PARAM
Jul 18, 2026
0e2a62a
update
Jul 18, 2026
92f8827
update
Jul 18, 2026
374d2d5
Merge branch 'develop' into 20260715
mohanchen Jul 18, 2026
196c18a
update
Jul 18, 2026
78424bd
Merge branch '20260715' of github.com:mohanchen/abacus-mc into 20260715
Jul 18, 2026
7641498
update
Jul 18, 2026
0bfc20b
update
Jul 18, 2026
5ece9f0
remove parameter.h
Jul 18, 2026
5f7647b
update cmake
Jul 18, 2026
b39a376
remove PARAM in symm
Jul 18, 2026
c27e5a5
fix test
Jul 18, 2026
7826ad8
fix
Jul 18, 2026
5ac06b9
fix bug
Jul 18, 2026
d98b754
update fix bugs
Jul 18, 2026
d939d71
Merge branch 'develop' into 20260715
mohanchen Jul 18, 2026
16529a8
fix problems
Jul 18, 2026
11be45a
update
Jul 18, 2026
80280dc
fix
Jul 18, 2026
b3625f2
fix
Jul 18, 2026
667aedf
Merge branch '20260715' of github.com:mohanchen/abacus-mc into 20260715
Jul 18, 2026
2509aea
move cal_nelec_nband from estate to cell
Jul 18, 2026
1433369
fix bug
Jul 19, 2026
a3c0486
Merge branch 'develop' into 20260715
mohanchen Jul 19, 2026
b7a1d1d
remove PARAM in deepks test
Jul 19, 2026
39f8db2
fix bug
Jul 19, 2026
99ae204
fix important bug!
Jul 20, 2026
900e643
fix another important bug!
Jul 20, 2026
8afb26a
fix tests and input parameter documentation: not needed
Jul 20, 2026
c7993d2
update, fix bugs
Jul 20, 2026
a2dee2a
update agent governance
Jul 20, 2026
6f1c04d
Merge branch 'develop' into 20260715
mohanchen Jul 20, 2026
0457e6e
update agent governance
Jul 20, 2026
8e72d4a
use a method to eliminate the define private public method
Jul 21, 2026
3252c23
fix nupdown bug
Jul 21, 2026
95fcfff
remove some notes
Jul 21, 2026
fbce872
update headers
Jul 21, 2026
93fc2e4
replace NonlocalInfoBase* infoNL = nullptr with std::unique_ptr<Nonlo…
Jul 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/developers_guide/agent_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ decisions.
| Heterogeneous test evidence | CUDA/ROCM/kernel change has test evidence or reason | phase-one mechanical warning + AI review | CI + AI review | high | warn | changed paths and PR body | Sufficiency is human-reviewed |
| Test existence | Source change has test evidence or reason | phase-one mechanical warning + AI review | CI + AI review | high | warn | PR body and changed paths | Sufficiency is human-reviewed |
| Test sufficiency | Tests cover important behavior | AI review + human confirmation | AI + human review | medium | human confirmation | semantic review | Not mechanically blocked |
| INPUT behavior linkage | Parameter metadata/default/type/parser behavior updates YAML and docs | phase-one mechanical + AI review | CI + AI review | high | block | behavior-field diff plus docs/PR body | Comment-only parameter-file changes are not blocked |
| INPUT behavior linkage | Parameter metadata/default/type/parser behavior updates YAML and docs | phase-one mechanical + AI review | CI + AI review | high | warn | behavior-field diff plus docs/PR body | Comment-only parameter-file changes are not blocked |
| Documentation sync | Behavior/interface docs updated | phase-one mechanical warning + AI review | CI + AI review | medium | warn | changed paths and PR body | Major behavior changes escalate to reviewers |
| PR metadata completeness | Issue, tests, behavior, INPUT, core impact, exceptions | phase-one mechanical | CI or GitHub bot | medium | warn | PR template fields | Not run by local hook |
| AI workflow | Interface lookup, uncertainty, verification report | AI review | AI review | high | warn | review transcript/output | Applies to AI agents |
Expand Down Expand Up @@ -215,13 +215,15 @@ setup workflows and should be added only through a later governance change.
## INPUT Parameter Changes

Changes to parameter metadata, default values, type, availability, description,
or parsing behavior must include both:
or parsing behavior should include both:

- `docs/parameters.yaml`
- `docs/advanced/input_files/input-main.md`

If the diff touches parameter internals but does not change user-visible INPUT
behavior, the PR must state why no documentation update is required.
behavior, the PR should state why no documentation update is required. Missing
documentation updates trigger a governance warning (not a block), but maintainers
may still request documentation updates before merging.

## PR Self-Consistency

Expand Down
5 changes: 4 additions & 1 deletion python/pyabacus/src/ModuleDriver/py_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ CalculationResult PyDriver::run(
);

// Read structure
impl_->ucell_->setup_cell(PARAM.globalv.global_in_stru, GlobalV::ofs_running);
impl_->ucell_->setup_cell(PARAM.globalv.global_in_stru, GlobalV::ofs_running, PARAM.inp.symmetry_prec, PARAM.inp.dfthalf_type, PARAM.inp.pseudo_dir, PARAM.inp.nspin,
PARAM.inp.basis_type, PARAM.inp.orbital_dir, PARAM.inp.init_wfc,
PARAM.inp.onsite_radius, PARAM.globalv.deepks_setorb, PARAM.inp.rpa,
PARAM.inp.fixed_atoms, PARAM.inp.noncolin, PARAM.inp.calculation, PARAM.inp.esolver_type);

// Check atomic structure
unitcell::check_atomic_stru(*impl_->ucell_, PARAM.inp.min_dist_coef);
Expand Down
2 changes: 1 addition & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ OBJS_CELL=atom_pseudo.o\
read_atom_species.o\
sep.o\
sep_cell.o\
cal_nelec_nband.o\

OBJS_DEEPKS=LCAO_deepks.o\
deepks_basic.o\
Expand Down Expand Up @@ -247,7 +248,6 @@ OBJS_ELECSTAT=elecstate.o\
pot_xc.o\
cal_ux.o\
read_orb.o\
cal_nelec_nband.o\
read_pseudo.o\
cal_wfc.o\
setup_estate_pw.o\
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_library(
read_atoms.cpp
read_atoms_helper.cpp
read_orb.cpp
setup_nonlocal.cpp
klist.cpp
parallel_kpoints.cpp
cell_index.cpp
Expand All @@ -34,6 +33,7 @@ add_library(
sep_cell.cpp
qlist.cpp
qlist.h
cal_nelec_nband.cpp
)

if(ENABLE_COVERAGE)
Expand Down
12 changes: 7 additions & 5 deletions source/source_cell/atom_pseudo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "atom_pseudo.h"
#include "source_io/module_parameter/parameter.h"

#include "source_io/module_parameter/parameter.h"
Atom_pseudo::Atom_pseudo()
{
}
Expand All @@ -14,8 +12,12 @@ Atom_pseudo::~Atom_pseudo()
void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,
const int& nproj_in,
const int& nproj_in_so,
const bool has_so)
const bool has_so,
const bool lspinorb,
const int nspin)
{
const bool lspinorb_ = lspinorb;
const int nspin_ = nspin;
if (this->lmax < -1 || this->lmax > 20)
{
ModuleBase::WARNING_QUIT("Numerical_Nonlocal", "bad input of lmax : should be between -1 and 20");
Expand Down Expand Up @@ -69,7 +71,7 @@ void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,

if (this->lmax > -1)
{
if (PARAM.inp.lspinorb)
if (lspinorb_)
{
int is = 0;
for (int is1 = 0; is1 < 2; is1++)
Expand Down Expand Up @@ -107,7 +109,7 @@ void Atom_pseudo::set_d_so(ModuleBase::ComplexMatrix& d_so_in,
{
for (int is2 = 0; is2 < 2; is2++)
{
if (is >= PARAM.inp.nspin) {
if (is >= nspin_) {
break;
}
for (int L1 = 0; L1 < nproj_soc; L1++)
Expand Down
4 changes: 3 additions & 1 deletion source/source_cell/atom_pseudo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class Atom_pseudo : public pseudo
ModuleBase::ComplexMatrix &d_so_in,
const int &nproj_in,
const int &nproj_in_so,
const bool has_so);
const bool has_so,
const bool lspinorb,
const int nspin);


inline void get_d(const int& is, const int& p1, const int& p2, const std::complex<double>*& tmp_d)
Expand Down
16 changes: 8 additions & 8 deletions source/source_cell/bcast_cell.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "unitcell.h"
#include "source_base/parallel_common.h"
#include "source_io/module_parameter/parameter.h"

#include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info

#include <string>
Expand Down Expand Up @@ -99,32 +99,32 @@ namespace unitcell
#endif
}

void bcast_magnetism(Magnetism& magnet, const int ntype)
void bcast_magnetism(Magnetism& magnet, const int ntype, const int nspin)
{
#ifdef __MPI
#ifdef __MPI
MPI_Barrier(MPI_COMM_WORLD);
if (GlobalV::MY_RANK != 0)
{
magnet.start_mag.resize(ntype, 0.0);
}
Parallel_Common::bcast_double(magnet.start_mag.data(), ntype);
if (PARAM.inp.nspin == 4)
if (nspin == 4)
{
Parallel_Common::bcast_double(magnet.ux_[0]);
Parallel_Common::bcast_double(magnet.ux_[1]);
Parallel_Common::bcast_double(magnet.ux_[2]);
}
#endif
#endif
}

void bcast_unitcell(UnitCell& ucell)
void bcast_unitcell(UnitCell& ucell, const int nspin)
{
#ifdef __MPI
#ifdef __MPI
const int ntype = ucell.ntype;
Parallel_Common::bcast_int(ucell.nat);

bcast_Lattice(ucell.lat);
bcast_magnetism(ucell.magnet,ntype);
bcast_magnetism(ucell.magnet,ntype, nspin);
bcast_atoms_tau(ucell.atoms,ntype);

for (int i = 0; i < ntype; i++)
Expand Down
9 changes: 6 additions & 3 deletions source/source_cell/bcast_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ namespace unitcell
* @param nytpe: the number of types of the atoms [in]
*/
void bcast_magnetism(Magnetism& magnet,
const int ntype);

const int ntype,
const int nspin);

/**
* @brief broadcast the unitcell
*
* @param ucell: the unitcell to be broadcasted [in/out]
* @param nspin: the number of spin components
*/
void bcast_unitcell(UnitCell& ucell);
void bcast_unitcell(UnitCell& ucell,
const int nspin);


}
Expand Down
114 changes: 86 additions & 28 deletions source/source_cell/cal_atoms_info.h
Original file line number Diff line number Diff line change
@@ -1,90 +1,148 @@
#ifndef CAL_ATOMS_INFO_H
#define CAL_ATOMS_INFO_H
#include "source_io/module_parameter/parameter.h"
#include "source_estate/cal_nelec_nband.h"
#include "source_cell/cal_nelec_nband.h"
#include "source_base/global_function.h"

struct AtomsInfoResult
{
int nlocal = 0;
double nelec = 0.0;
int nbands = 0;
double nupdown = 0.0;
bool use_uspp = false;
int nbands_l = 0;
bool ks_run = false;
};

class CalAtomsInfo
{
public:
CalAtomsInfo(){};
~CalAtomsInfo(){};

/**
* @brief Calculate the atom information from pseudopotential to set Parameter
* @brief Calculate the atom information from pseudopotential
*
* IMPORTANT: The nbands and nelec parameters must be the user-specified values from INPUT file.
* This function passes nbands to cal_nbands() and nelec to cal_nelec().
* If nbands is 0, cal_nbands() will auto-calculate a default.
* If nelec is 0, cal_nelec() will auto-calculate based on atomic valence.
*
* @param atoms [in] Atom pointer
* @param ntype [in] number of atom types
* @param para [out] Parameter object
* @param nspin [in] number of spin components
* @param two_fermi [in] two fermi level flag
* @param nelec_delta [in] electron number delta
* @param esolver_type [in] solver type
* @param lspinorb [in] spin-orbit coupling flag
* @param basis_type [in] basis type
* @param smearing_method [in] smearing method
* @param ks_solver [in] KS solver type
* @param bndpar [in] band parallel parameter
* @param nbands [in] user-specified number of bands from INPUT file
* @param nelec [in] user-specified number of electrons from INPUT file
* @param nupdown [in] user-specified spin polarization from INPUT file
* @return AtomsInfoResult containing calculated atom information
*/
void cal_atoms_info(const Atom* atoms, const int& ntype, Parameter& para)
AtomsInfoResult cal_atoms_info(Atom* atoms, const int& ntype,
const int nspin, const bool two_fermi,
const double nelec_delta,
const std::string& esolver_type,
const bool lspinorb,
const std::string& basis_type,
const std::string& smearing_method,
const std::string& ks_solver,
const int bndpar,
const int nbands,
const double nelec,
const double nupdown)
{
AtomsInfoResult result;

// calculate initial total magnetization when NSPIN=2
if (para.inp.nspin == 2 && !para.globalv.two_fermi)
if (nspin == 2 && !two_fermi)
{
for (int it = 0; it < ntype; ++it)
{
for (int ia = 0; ia < atoms[it].na; ++ia)
{
para.input.nupdown += atoms[it].mag[ia];
result.nupdown += atoms[it].mag[ia];
}
}
GlobalV::ofs_running << std::endl;
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "The readin total magnetization", para.inp.nupdown);
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "The readin total magnetization", result.nupdown);
}
else if (nspin == 2 && two_fermi)
{
result.nupdown = nupdown;
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "The user-specified total magnetization", result.nupdown);
}


// decide whether to be USPP
for (int it = 0; it < ntype; ++it)
{
if (atoms[it].ncpp.tvanp)
{
para.sys.use_uspp = true;
result.use_uspp = true;
}
}

// set index for atoms before calculating nlocal
// this ensures consistency with cal_nwfc() which also calls set_index() first
for (int it = 0; it < ntype; ++it)
{
atoms[it].set_index();
}

// calculate the total number of local basis
para.sys.nlocal = 0;
// nlocal = sum over all atom types of (atoms[it].nw * atoms[it].na)
// For nspin == 4 (non-collinear), each basis function has 2 polarizations,
// so nlocal is doubled. This value is used by cal_nwfc() to initialize
// index arrays (iwt2iat, iwt2iw, itia2iat).
result.nlocal = 0;
for (int it = 0; it < ntype; ++it)
{
const int nlocal_it = atoms[it].nw * atoms[it].na;
if (para.inp.nspin != 4)
if (nspin != 4)
{
para.sys.nlocal += nlocal_it;
result.nlocal += nlocal_it;
}
else
{
para.sys.nlocal += nlocal_it * 2; // zhengdy-soc
result.nlocal += nlocal_it * 2; // zhengdy-soc
}
}

// calculate the total number of electrons
elecstate::cal_nelec(atoms, ntype, para.input.nelec);
result.nelec = nelec;
unitcell::cal_nelec(atoms, ntype, result.nelec, nelec_delta);

// autoset and check GlobalV::NBANDS
std::vector<double> nelec_spin(2, 0.0);
if (para.inp.nspin == 2)
if (nspin == 2)
{
nelec_spin[0] = (para.inp.nelec + para.inp.nupdown ) / 2.0;
nelec_spin[1] = (para.inp.nelec - para.inp.nupdown ) / 2.0;
nelec_spin[0] = (result.nelec + result.nupdown) / 2.0;
nelec_spin[1] = (result.nelec - result.nupdown) / 2.0;
}
elecstate::cal_nbands(para.inp.nelec, para.sys.nlocal, nelec_spin, para.input.nbands);
result.nbands = nbands;
unitcell::cal_nbands(static_cast<int>(result.nelec), result.nlocal, nelec_spin, result.nbands,
esolver_type, lspinorb, nspin, basis_type, smearing_method);

// calculate the number of nbands_local
para.sys.nbands_l = para.inp.nbands;
if (para.inp.ks_solver == "bpcg") // only bpcg support band parallel
result.nbands_l = result.nbands;
if (ks_solver == "bpcg")
{
para.sys.nbands_l = para.inp.nbands / para.inp.bndpar;
if (GlobalV::MY_BNDGROUP < para.inp.nbands % para.inp.bndpar)
result.nbands_l = result.nbands / bndpar;
if (GlobalV::MY_BNDGROUP < result.nbands % bndpar)
{
para.sys.nbands_l++;
result.nbands_l++;
}
}
// temporary code
if (GlobalV::MY_BNDGROUP == 0 || para.inp.ks_solver == "bpcg")
if (GlobalV::MY_BNDGROUP == 0 || ks_solver == "bpcg")
{
para.sys.ks_run = true;
result.ks_run = true;
}
return;
return result;
}
};
#endif
Loading
Loading