dpgen2 icon indicating copy to clipboard operation
dpgen2 copied to clipboard

Add CP2K support for dpgen2

Open Cloudac7 opened this issue 1 year ago • 4 comments

As described in #180 , dpgen2 did not support CP2K. This PR add RunCp2k and is tested to be OK to generate fp tasks.

Thus solved #180.

Summary by CodeRabbit

  • New Features

    • Introduced CP2K support with new classes for preparing and running CP2K tasks.
    • Added functionality for generating CP2K input files from user configurations.
    • Included new test cases for CP2K input generation and task execution.
  • Bug Fixes

    • None
  • Documentation

    • None
  • Refactor

    • None
  • Style

    • None
  • Tests

    • Added test cases for Cp2kInputs and RunCp2k classes.
  • Chores

    • None
  • Revert

    • None

Cloudac7 avatar Feb 18 '24 02:02 Cloudac7

Codecov Report

Attention: Patch coverage is 91.36691% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 87.69%. Comparing base (76c9657) to head (3ccfe50).

:exclamation: Current head 3ccfe50 differs from pull request most recent head 61fbc00

Please upload reports for the commit 61fbc00 to get more accurate results.

Files Patch % Lines
dpgen2/fp/cp2k_input.py 92.85% 7 Missing :warning:
dpgen2/fp/cp2k.py 87.50% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #190      +/-   ##
==========================================
+ Coverage   84.63%   87.69%   +3.06%     
==========================================
  Files          94       85       -9     
  Lines        5140     4322     -818     
==========================================
- Hits         4350     3790     -560     
+ Misses        790      532     -258     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 18 '24 07:02 codecov[bot]

It seems that only the three elements C, N, and H and the corresponding pseudopotentials are considered in the code, and once there are other elements in the system, the code may be incorrect.

Andy6M avatar May 18 '24 07:05 Andy6M

It seems that only the three elements C, N, and H and the corresponding pseudopotentials are considered in the code, and once there are other elements in the system, the code may be incorrect.

No, it is just a default dict as placeholder. This PR would be soon refactored.

Cloudac7 avatar May 22 '24 03:05 Cloudac7

Walkthrough

Walkthrough

The changes introduce functionalities for integrating CP2K, a computational chemistry software package, into the dpgen2 framework. This integration includes adding new classes for preparing and running CP2K tasks, generating CP2K input files, and handling structural data. Additionally, new test cases are created to ensure the correctness of these functionalities. The updates enhance the capability of dpgen2 to support CP2K simulations, making it more versatile for computational chemistry applications.

Changes

Files/Paths Change Summary
dpgen2/fp/__init__.py Added imports for CP2K-related classes and a dictionary entry for "cp2k".
dpgen2/fp/cp2k.py Introduced PrepCp2k and RunCp2k classes with methods for CP2K task preparation and execution.
dpgen2/fp/cp2k_input.py Added functionality for generating CP2K input files, including dictionary updates and structural data handling.
tests/fp/data.cp2k/coord_n_cell.inc Introduced coordinate and cell information for Na atoms in a crystal structure.
tests/fp/data.cp2k/input.inp Added configuration settings for a CP2K simulation, including global settings, DFT parameters, and atomic details.
tests/fp/data.cp2k/input.json Defined parameters for a CP2K simulation in JSON format.
tests/fp/data.cp2k/sys-2/type.raw Included type information for a system.
tests/fp/data.cp2k/sys-2/type_map.raw Introduced type mapping for Na.
tests/fp/test_cp2k.py Added test cases for Cp2kInputs and RunCp2k classes to validate CP2K input generation and task execution.

Recent Review Details

Configuration used: CodeRabbit UI Review profile: CHILL

Commits Files that changed from the base of the PR and between 76c96571a879132aea4fd4e1fbdb6ad2803b3e6c and 61fbc00317d9d7107a1fd9843e026ae7d1d19c63.
Files selected for processing (9)
  • dpgen2/fp/init.py (2 hunks)
  • dpgen2/fp/cp2k.py (1 hunks)
  • dpgen2/fp/cp2k_input.py (1 hunks)
  • tests/fp/data.cp2k/coord_n_cell.inc (1 hunks)
  • tests/fp/data.cp2k/input.inp (1 hunks)
  • tests/fp/data.cp2k/input.json (1 hunks)
  • tests/fp/data.cp2k/sys-2/type.raw (1 hunks)
  • tests/fp/data.cp2k/sys-2/type_map.raw (1 hunks)
  • tests/fp/test_cp2k.py (1 hunks)
Files skipped from review due to trivial changes (4)
  • tests/fp/data.cp2k/coord_n_cell.inc
  • tests/fp/data.cp2k/input.json
  • tests/fp/data.cp2k/sys-2/type.raw
  • tests/fp/data.cp2k/sys-2/type_map.raw
Additional Context Used
Ruff (31)
dpgen2/fp/cp2k.py (14)

6-6: typing.Dict imported but unused


8-8: typing.Optional imported but unused


9-9: typing.Set imported but unused


11-11: typing.Union imported but unused


15-15: numpy imported but unused


18-18: dargs.ArgumentEncoder imported but unused


19-19: dargs.Variant imported but unused


20-20: dargs.dargs imported but unused


23-23: dflow.python.OP imported but unused


24-24: dflow.python.OPIO imported but unused


25-25: dflow.python.Artifact imported but unused


26-26: dflow.python.BigParameter imported but unused


27-27: dflow.python.FatalError imported but unused


28-28: dflow.python.OPIOSign imported but unused

dpgen2/fp/cp2k_input.py (8)

2-2: pathlib.Path imported but unused


6-6: typing.List imported but unused


8-8: typing.Set imported but unused


9-9: typing.Tuple imported but unused


10-10: typing.Union imported but unused


17-17: dargs.ArgumentEncoder imported but unused


18-18: dargs.Variant imported but unused


19-19: dargs.dargs imported but unused

tests/fp/test_cp2k.py (9)

1-1: glob imported but unused


2-2: json imported but unused


3-3: os imported but unused


4-4: shutil imported but unused


5-5: sys imported but unused


6-6: textwrap imported but unused


17-17: numpy imported but unused


21-21: .context.dpgen2 imported but unused


33-33: Redefinition of unused json from line 2

Additional comments not posted (5)
tests/fp/data.cp2k/input.inp (1)

1-52: The CP2K configuration file is well-structured and aligns with the standard practices for setting up simulations. Good job on maintaining clarity and organization in the file.

dpgen2/fp/__init__.py (1)

6-10: The addition of CP2K classes to the imports and the fp_styles dictionary is correctly implemented. This setup enables the framework to handle CP2K tasks effectively.

Also applies to: 48-52

tests/fp/test_cp2k.py (1)

31-93: The test cases for CP2K input generation and task execution are comprehensive and well-implemented. These tests should effectively validate the CP2K integration.

dpgen2/fp/cp2k.py (1)

55-164: The implementations of PrepCp2k and RunCp2k classes are robust and well-documented. These classes are crucial for integrating CP2K support into the framework.

dpgen2/fp/cp2k_input.py (1)

51-211: The functions update_dict and iterdict, along with the class Cp2kInputs, are well-implemented and crucial for generating CP2K input files. These implementations are essential for the CP2K support in the framework.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar May 22 '24 03:05 coderabbitai[bot]

Hi @Cloudac7 :

Could you please provide the following example files:

An example of the CP2K inp file. A corresponding input.json file for dpgen2.

These example files would be incredibly helpful for us to quickly get started and verify the new functionality.

Thank you very much!

Andy6M avatar Jun 08 '24 11:06 Andy6M

https://github.com/deepmodeling/dpgen2/pull/238

zjgemi avatar Jul 01 '24 05:07 zjgemi

https://github.com/deepmodeling/dpgen2/pull/238 CP2K support is implemented with FPOP. Please feed back if there is any question. I will close this PR.

zjgemi avatar Jul 05 '24 06:07 zjgemi