Skip to content

Formatting files in /source/source_hamilt/module_xc#7399

Open
mohanchen wants to merge 6 commits into
deepmodeling:developfrom
mohanchen:20260530
Open

Formatting files in /source/source_hamilt/module_xc#7399
mohanchen wants to merge 6 commits into
deepmodeling:developfrom
mohanchen:20260530

Conversation

@mohanchen
Copy link
Copy Markdown
Collaborator

Formatting files in /source/source_hamilt/module_xc

abacus_fixer added 2 commits May 30, 2026 06:32
- Add tau_xc overload with hybrid_alpha parameter
- Add ElecState::set_exx overload with cal_exx and hybrid_alpha parameters
- Format code: one parameter per line, align code, initialize variables, one variable per line, add braces to single-line for/if
@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels May 29, 2026
abacus_fixer added 4 commits May 30, 2026 07:15
- Format function parameters to one per line
- Initialize all variables when declared
- Separate variable declarations onto individual lines
- Add braces for single-line if/for statements
- Improve code alignment and readability
@mohanchen mohanchen requested a review from zzlinpku May 30, 2026 01:52
Copy link
Copy Markdown
Collaborator

@zzlinpku zzlinpku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

This is a well-executed code style refactoring PR. The new file naming scheme (xc_*.cpp for native implementations, libxc_*.cpp for Libxc wrappers) is clear and consistent. A few items to address:

🔴 Must fix: Header guard in libxc.h still uses the old name.
🟡 Consider: Update comment references to old file names, and note the reference member risk in exx_info.h.

#endif // USE_LIBXC

#endif // XC_FUNCTIONAL_LIBXC_H No newline at end of file
#ifndef XC_FUNCTIONAL_LIBXC_H
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Issue: The header guard still uses the old filename XC_FUNCTIONAL_LIBXC_H. Since the file has been renamed from xc_functional_libxc.h to libxc.h, the guard should be updated accordingly.

Suggested change
#ifndef XC_FUNCTIONAL_LIBXC_H
#ifndef LIBXC_H
#define LIBXC_H

(The closing #endif on line 239 should also be updated to #endif // LIBXC_H)

namespace XC_Functional_Libxc
{
//-------------------
// xc_functional_libxc.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: The section comment still references the old file name xc_functional_libxc.cpp. Consider updating to // libxc_setup.cpp to match the renamed file.



//-------------------
// xc_functional_libxc_vxc.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: Same here — the old file name xc_functional_libxc_vxc.cpp should be updated to libxc_pot.cpp.



//-------------------
// xc_functional_libxc_tools.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: Old file name xc_functional_libxc_tools.cpp → should be libxc_tools.cpp.



//-------------------
// xc_functional_libxc_wrapper_xc.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: Old file name xc_functional_libxc_wrapper_xc.cpp → should be libxc_lda_wrap.cpp.



//-------------------
// xc_functional_libxc_wrapper_tauxc.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: Old file name xc_functional_libxc_wrapper_tauxc.cpp → should be libxc_mgga_wrap.cpp.

@@ -147,65 +155,91 @@ class XC_Functional
// LIBXC, and the reason for not having gcxc_libxc is explained
// in the NOTE in the comment for xc_functional_wrapper_wc.cpp part
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: The comment references xc_functional_wrapper_wc.cpp which appears to be a typo or old filename. Consider updating to xc_gga_wrap.cpp for clarity.

double &v2c);

//-------------------
// xc_funct_hcth.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Nit: Comment still references old filename xc_funct_hcth.cpp. Consider updating to xc_hcth.cpp.

//XC_POLARIZED, XC_UNPOLARIZED: internal flags used in LIBXC,
//denote the polarized(nspin=1) or unpolarized(nspin=2) calculations,
//definition can be found in xc.h from LIBXC
void XC_Functional_Libxc::tau_xc(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice design: The new 8-parameter tau_xc overload that accepts hybrid_alpha as a parameter is a clean improvement. The original 7-parameter version now delegates to it, which removes the direct dependency on GlobalC::exx_info from the core function. This makes the function more testable and reusable.

Consider applying the same pattern to tau_xc_spin if a hybrid mGGA functional needs it in the future.

struct Exx_Info_RI
{
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param;
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string, std::string>>> &coulomb_param;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Note: Exx_Info_RI::coulomb_param is a const reference member bound to info_global.coulomb_param (line 82). This is a pre-existing design, but worth noting — if an Exx_Info_RI object outlives its source Exx_Info_Global, this becomes a dangling reference. Consider documenting this lifetime dependency or using a shared pointer if the ownership model changes in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants