Add CP2K support for dpgen2
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
Cp2kInputsandRunCp2kclasses.
- Added test cases for
-
Chores
- None
-
Revert
- None
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.
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.
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.
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.Dictimported but unused
8-8:
typing.Optionalimported but unused
9-9:
typing.Setimported but unused
11-11:
typing.Unionimported but unused
15-15:
numpyimported but unused
18-18:
dargs.ArgumentEncoderimported but unused
19-19:
dargs.Variantimported but unused
20-20:
dargs.dargsimported but unused
23-23:
dflow.python.OPimported but unused
24-24:
dflow.python.OPIOimported but unused
25-25:
dflow.python.Artifactimported but unused
26-26:
dflow.python.BigParameterimported but unused
27-27:
dflow.python.FatalErrorimported but unused
28-28:
dflow.python.OPIOSignimported but unuseddpgen2/fp/cp2k_input.py (8)
2-2:
pathlib.Pathimported but unused
6-6:
typing.Listimported but unused
8-8:
typing.Setimported but unused
9-9:
typing.Tupleimported but unused
10-10:
typing.Unionimported but unused
17-17:
dargs.ArgumentEncoderimported but unused
18-18:
dargs.Variantimported but unused
19-19:
dargs.dargsimported but unusedtests/fp/test_cp2k.py (9)
1-1:
globimported but unused
2-2:
jsonimported but unused
3-3:
osimported but unused
4-4:
shutilimported but unused
5-5:
sysimported but unused
6-6:
textwrapimported but unused
17-17:
numpyimported but unused
21-21:
.context.dpgen2imported but unused
33-33: Redefinition of unused
jsonfrom 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 thefp_stylesdictionary 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 ofPrepCp2kandRunCp2kclasses 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 functionsupdate_dictanditerdict, along with the classCp2kInputs, 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?
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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai helpto 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.yamlfile 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.
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!
https://github.com/deepmodeling/dpgen2/pull/238
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.