Skip to content

Conversation

@EBB2675
Copy link
Collaborator

@EBB2675 EBB2675 commented Aug 18, 2025

No description provided.

@EBB2675 EBB2675 changed the title add ModelMethodMolecular and its add-ons Sprint: Density Functional Theory Aug 18, 2025
@coveralls
Copy link

coveralls commented Aug 18, 2025

Pull Request Test Coverage Report for Build 19224631192

Details

  • 302 of 331 (91.24%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.9%) to 83.59%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/nomad_simulations/schema_packages/utils/libxc/build.py 15 20 75.0%
src/nomad_simulations/schema_packages/numerical_settings.py 8 14 57.14%
src/nomad_simulations/schema_packages/model_method.py 100 107 93.46%
src/nomad_simulations/schema_packages/utils/libxc/expand.py 63 74 85.14%
Totals Coverage Status
Change from base Build 19170712288: 0.9%
Covered Lines: 6882
Relevant Lines: 8233

💛 - Coveralls

@EBB2675 EBB2675 changed the title Sprint: Density Functional Theory Quantum chemistry add-ons to Density Functional Theory Aug 18, 2025
@EBB2675 EBB2675 added improvement/fix Improvement or fix of a previous feature sprint Issue associated with a sprint ModelMethod labels Aug 18, 2025
@EBB2675 EBB2675 marked this pull request as ready for review August 18, 2025 09:56
@JFRudzinski
Copy link
Collaborator

What do you mean exactly with Point 2?

Bernadette-Mohr

This comment was marked as resolved.

@EBB2675 EBB2675 requested a review from ladinesa August 19, 2025 06:47
@EBB2675 EBB2675 force-pushed the sprint-dft-qchem branch 2 times, most recently from 258b00e to fea8c63 Compare September 2, 2025 09:08
@EBB2675
Copy link
Collaborator Author

EBB2675 commented Sep 3, 2025

@ladinesa @ndaelman-hu @JFRudzinski please take a look at LibXC canonicalization and the new DFT architecture

I added XCComponent for a single LibXC identified kernel, and then XCFunctional as the whole XC approximation in accordance with the community jargon and theory.

As you can understand, there are multiple ways this canonicalization can take place. this is one complete implementation. I do not have any personal preferences. I am ready to adopt to whatever you suggest 👍

@JFRudzinski
Copy link
Collaborator

@ladinesa @ndaelman-hu @JFRudzinski please take a look at LibXC canonicalization and the new DFT architecture

I added XCComponent for a single LibXC identified kernel, and then XCFunctional as the whole XC approximation in accordance with the community jargon and theory.

As you can understand, there are multiple ways this canonicalization can take place. this is one complete implementation. I do not have any personal preferences. I am ready to adopt to whatever you suggest 👍

For me this looks very nice, but I have no insight into the domain details here. I expect @ndaelman-hu will give you more specific feedback/confirmation

Copy link
Collaborator

@ndaelman-hu ndaelman-hu left a comment

Choose a reason for hiding this comment

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

Like the DFT mapping additions. A few quantities that need to be added.
Also comments on the structure, suggesting some reorganization. I think that if these are addressed, you can go ahead and merge. No need for another review.

Disclaimer: didn't check the actual code implementations too much (would first need to understand the exact workflow). You could ask the copilot reviewer.

Comment on lines 42 to 48
_COMMON_XC_CASES = [
# ---------------- LDA ----------------
('LDA', 'LDA', ['XC_LDA_X', 'XC_LDA_C_PW', 'XC_LDA_C_PZ']),
('PW92', 'LDA', ['XC_LDA_C_PW']),
('PZ81', 'LDA', ['XC_LDA_C_PZ']),
('VWN', 'LDA', ['XC_LDA_C_VWN']),
('SVWN', 'LDA', ['XC_LDA_X', 'XC_LDA_C_VWN']),
('LSDA', 'LDA', ['XC_LDA_X', 'XC_LDA_C_VWN']),
('LDA+PW', 'LDA', ['XC_LDA_X', 'XC_LDA_C_PW']),
# ---------------- GGA ----------------
('PBE', 'GGA', ['XC_GGA_X_PBE', 'XC_GGA_C_PBE']),
('PBEsol', 'GGA', ['XC_GGA_X_PBE_SOL', 'XC_GGA_C_PBE_SOL']),
('revPBE', 'GGA', ['XC_GGA_X_RPBE', 'XC_GGA_C_PBE']),
('RPBE', 'GGA', ['XC_GGA_X_RPBE', 'XC_GGA_C_PBE']),
('PW91', 'GGA', ['XC_GGA_X_PW91', 'XC_GGA_C_PW91']),
('BLYP', 'GGA', ['XC_GGA_X_B88', 'XC_GGA_C_LYP']),
('BP86', 'GGA', ['XC_GGA_X_B88', 'XC_GGA_C_P86']),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please import this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these are also present in expand.py, correct? Unfortunately, there isn't much of a way for testing these kinds of mappings [1]. You basically generated them twice and check for typos.

Personally, I feel that you can safely remove this test.

[1]: I guess that with a very granular format specification, you could run that to impose compliance. But I think that's overkill in this case.

@ndaelman-hu
Copy link
Collaborator

@EBB2675 , at this stage, I'd also request feedback from the co-pilot reviewer.

@EBB2675 EBB2675 requested a review from Copilot October 7, 2025 16:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds quantum chemistry extensions to Density Functional Theory (DFT) capabilities by introducing LibXC-based XC functional normalization and additional quantum chemistry model methods. The changes include a comprehensive XC functional expansion system, new model method classes for implicit solvation, dispersion corrections, and relativistic treatments, along with extensive test coverage.

Key Changes

  • Implements LibXC-based XC functional canonicalization with registry lookup and expansion capabilities
  • Adds new model method classes: ImplicitSolvationModel, ExplicitDispersionModel, RelativityModel, and CoreElectronTreatment
  • Refactors DFT class to use new XCFunctional/XCComponent schema with automatic Jacob's ladder derivation

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/utils/test_libxc.py Comprehensive test suite for LibXC functional expansion and DFT normalization
tests/test_model_method.py Extended tests for DFT class with XC component handling and parameter derivation
src/nomad_simulations/schema_packages/utils/libxc/registry.py LibXC registry lookup functionality with label and ID-based queries
src/nomad_simulations/schema_packages/utils/libxc/expand.py XC functional expansion logic with alias tables and fallback mechanisms
src/nomad_simulations/schema_packages/utils/libxc/build.py XCComponent factory functions for creating components from LibXC data
src/nomad_simulations/schema_packages/utils/libxc/init.py Module interface exposing build functions
src/nomad_simulations/schema_packages/utils/libxc/README.md Documentation for LibXC canonicalization pipeline and supported formats
src/nomad_simulations/schema_packages/numerical_settings.py Added FrozenCore, IntegralDecomposition, and OrbitalLocalization settings classes
src/nomad_simulations/schema_packages/model_method.py Major refactor with new quantum chemistry model classes and updated DFT implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@EBB2675 EBB2675 requested a review from Copilot October 8, 2025 08:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@ndaelman-hu ndaelman-hu left a comment

Choose a reason for hiding this comment

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

Some structural remarks in the schema. These should be addressed.

Normally, I'd give this "Comment", but since no further iteration is needed and you typically follow up well with the comments, I'll add it as "Approve". Note that some older comments are also still open.

except KeyError:
return 'unavailable'
return self._jacobs_ladder_map.get(highest_rung_abbrev, 'unavailable')
# ? Do we need to define `type` for DFT+U?
Copy link
Collaborator

Choose a reason for hiding this comment

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

@EBB2675 EBB2675 requested a review from kubanmar October 9, 2025 09:28
@JosePizarro3
Copy link
Collaborator

Hey, @EBB2675, I will check this later next week. It looks good, but there are a couple of sections I will move out of ModelMethodElectronic, as these are only relevant for quantum chemistry simulations.

Furthermore, I am not sure about the role here of dielectrics and so. In cond mat, these are typically something else (I am guessing, I dont know. I would like to check this, or if you know, please let me know :-) ).

@EBB2675 EBB2675 requested a review from Copilot October 14, 2025 09:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@EBB2675 EBB2675 requested a review from Copilot October 14, 2025 09:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@kubanmar kubanmar left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Collaborator

@JosePizarro3 JosePizarro3 left a comment

Choose a reason for hiding this comment

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

All good, just some minor thing about a couple of sub-sections in ModelMethodElectronic that I would move out.

@EBB2675
Copy link
Collaborator Author

EBB2675 commented Nov 4, 2025

Hi @ladinesa @JosePizarro3 @JFRudzinski, @Bernadette-Mohr , @ndaelman-hu , @kubanmar ,

This PR is ready for rigorous DFT parser testing.

  • Please skim utils/libxc/README.md for the canonicalization pipeline overview.
  • Added extensive tests in tests/utils/test_libxc.py.
  • Removed a few out-of-scope items (e.g., CoreElectronTreatment) to keep scope manageable; will handle separately.
  • In ModelMethodElectronic, I dropped QC-specific SubSections as suggested by @JosePizarro3, they will instead be attached to the parent method through ModelMethod.contributions when and if needed. I added tests for these as well.
  • Finally, i replaced the legacy ModelMethodElectronic.is_spin_polarized with a clearer determinant:
    determinant = Quantity(
        type=MEnum('unrestricted', 'restricted', 'restricted-open-shell'),
        description="""
        The spin-coupling form of the determinant used for the
        self-consistent field (SCF) or Kohn-Sham calculation.

        - **restricted**  (RHF/RKS): α and β electrons share the same spatial orbitals  
        - **unrestricted** (UHF/UKS): α and β orbitals are optimized independently  
        - **restricted-open-shell** (ROHF/ROKS): closed-shell core with spin-unpaired electrons
        sharing spatial orbitals in the open-shell manifold
        """,
    )

If you prefer a different name for determinant, please let me know 🏃‍♀️

@EBB2675 EBB2675 self-assigned this Nov 4, 2025
Copy link
Collaborator

@ndaelman-hu ndaelman-hu left a comment

Choose a reason for hiding this comment

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

Hey, great work on this PR! Structurally it looks good overall.
Given how mature it is already, I just went over all my old comments. I noticed that I missed some of your replies under all the e-mail notifications.

I followed up on a few comments. I just have a few suggestions for minor tweaks.
I also opened a bunch of issues where you suggested. Feel free to add to them.

Edit: I added a bunch of our comments via VS Code's GitLens, but they appear as new messages now without their thread... My apologies for the mess.

""",
)

approximation = Quantity(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment has not yet been applied. It's not a big deal, but would mean 1 field less when parsing.

@EBB2675 EBB2675 merged commit ef1b580 into develop Nov 13, 2025
6 checks passed
@EBB2675 EBB2675 deleted the sprint-dft-qchem branch November 13, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement/fix Improvement or fix of a previous feature ModelMethod

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refine DFT to cover molecular cases Add solvation methods (for Solid State)

9 participants