[Q&A] Hybrid DeepMD–Classical Force Field NVT Simulation in CP2K #5505
Replies: 6 comments 6 replies
-
|
Hi @drpriyadey, Yes, this is completely possible in CP2K, but it requires configuring the simulation engine under a Mixed Force-Field (QM/MM style) framework. Instead of treating DeePMD as a global potential, you partition the system so that CP2K evaluates the organic component using its internal classical MM mechanics, while routing the inorganic/metallic atomic coordinates to DeePMD-kit via an external calculator hook. Here is how to map this out in your CP2K input script (.inp):
Fortran
Fortran
Fortran
Fortran Ensure that your CP2K executable was compiled with the flags matching your libdeepmd_c.so library linking, or you will throw an unrecognized keyword error when initializing the DEEPMD block type. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much @Tobi-Adesoye san. I will try the procedure. |
Beta Was this translation helpful? Give feedback.
-
|
You are very welcome, @drpriyadey!
Don't hesitate to reach back out or reopen the thread if you encounter any
convergence anomalies or formatting quirks in your INPUT blocks once the
CP2K run kicks off. Best of luck with your hybrid NVT simulation!
…On Wed, Jun 10, 2026 at 2:39 AM Priya Dey ***@***.***> wrote:
Thank you so much @Tobi-Adesoye <https://github.com/Tobi-Adesoye> san. I
will try the procedure.
—
Reply to this email directly, view it on GitHub
<#5505?email_source=notifications&email_token=AQSPCWHW6OUJKUTTCOFJ4KD47C333A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZSGQ2DIMJTUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#discussioncomment-17244413>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQSPCWB2PUQH6KSS7ITFU7L47C333AVCNFSM6AAAAACZ6SGCECVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTOMRUGQ2DCMY>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AQSPCWEXY7FDSROYTAUKRXD47C333A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZSGQ2DIMJTUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/AQSPCWAWQ7T4P727YROPNRT47C333A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZSGQ2DIMJTUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
|
Hi @drpriyadey,
Thanks for testing this and for sharing the error output.
Looking at the messages you posted, I suspect the problem is not with your
structure files but with the input syntax itself. The unknown keyword
errors, followed by the CPASSERT failed in force_env_types.F, indicate that
CP2K is encountering sections or keywords that it does not recognize for
your build or version.
In hindsight, the example I shared was intended to illustrate the
high-level partitioning strategy rather than serve as a drop-in CP2K input
file. Some of the block names and keywords may therefore not correspond
exactly to valid CP2K syntax.
A few things would help narrow this down:
1.
Could you post the complete tobi.inp file (or at least the relevant
FORCE_EVAL sections)?
2.
Was your CP2K executable compiled with DeePMD support? Your banner
indicates deepmd is present, which is encouraging, but the exact
interface still matters.
3.
What is your intended coupling strategy? For example:
-
DeePMD for one subset of atoms and a classical force field for
another subset, or
-
DeePMD as the sole potential for the entire system.
If the goal is a true hybrid DeePMD + classical force-field simulation in
CP2K, I would also recommend checking whether the required coupling
mechanism is explicitly supported by your CP2K version and build
configuration, as the available interfaces can differ between releases.
If you share the input file, I'd be happy to take a closer look and help
identify the specific source of the assertion failure.
…On Mon, Jun 22, 2026 at 10:08 AM Priya Dey ***@***.***> wrote:
Dear @Tobi-Adesoye <https://github.com/Tobi-Adesoye>
After i am trying to correct the input file, I have the following error:
DBCSR| CPU Multiplication driver XSMM (U)
DBCSR| Multrec recursion limit 512 (U)
DBCSR| Multiplication stack size 1000 (D)
DBCSR| Maximum elements for images UNLIMITED (U)
DBCSR| Multiplicative factor virtual images 1 (U)
DBCSR| Use multiplication densification T (D)
DBCSR| Multiplication size stacks 3 (U)
DBCSR| Use memory pool for CPU allocation F (U)
DBCSR| Number of 3D layers SINGLE (U)
DBCSR| Use MPI memory allocation F (U)
DBCSR| Use RMA algorithm F (U)
DBCSR| Use Communication thread T (U)
DBCSR| Communication thread load 87 (D)
DBCSR| MPI: My process id 0
DBCSR| MPI: Number of processes 1
DBCSR| OMP: Current number of threads 1
DBCSR| OMP: Max number of threads 1
DBCSR| Split modifier for TAS multiplication algorithm 1.0E+00 (U)
**** **** ****** ** PROGRAM STARTED AT 2026-06-22 18:05:18.760
***** ** *** *** ** PROGRAM STARTED ON priya-dey
** **** ****** PROGRAM STARTED BY priya-dey
***** ** ** ** ** PROGRAM PROCESS ID 88936
**** ** ******* ** PROGRAM STARTED IN /home/priya-dey/Project-ML/bt3
CP2K| version string: CP2K version 2024.3
CP2K| source code revision number: git:6712648
CP2K| cp2kflags: omp libint fftw3 libxc libgrpp pexsi elpa parallel
scalapack m
CP2K| pi_f08 cosma quip deepmd xsmm plumed2 spglib sirius libvori li
CP2K| ibbqb libtorch libvdwxc hdf5
CP2K| is freely available from https://www.cp2k.org/
CP2K| Program compiled at Tue Apr 7 01:57:03 AM JST 2026
CP2K| Program compiled on priya-dey
CP2K| Program compiled for local
CP2K| Data directory path /home/priya-dey/cp2k/data
CP2K| Input file name tobi.inp
------------------------------
- ___ *
- / \ *
- [ABORT] *
- ___/ CPASSERT failed *
- | *
- O/| *
- /| | *
- / \ force_env_types.F:730 *
------------------------------
===== Routine Calling Stack =====
1 CP2K
—
Reply to this email directly, view it on GitHub
<#5505?email_source=notifications&email_token=AQSPCWEVU6HAW6SN2PMY3WL5BDZRNA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZTHEYDCMBWUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#discussioncomment-17390106>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQSPCWHS4FFPW43NB23PLEL5BDZRNAVCNFSNUABIKJSXA33TNF2G64TZHMYTCNBQGA3DCOJTHNCGS43DOVZXG2LPNY5TCMBSGE3TAMZRUF3AE>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AQSPCWHEPDACOZ7R4HW6D7L5BDZRNA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZTHEYDCMBWUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/AQSPCWBAQNK7J6RA24WW73D5BDZRNA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZTHEYDCMBWUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
|
Hi Priya,
Great question — this is an important point and often the source of
confusion with hybrid setups in CP2K.
When I said *“the required coupling mechanism must be explicitly supported
by your CP2K version and build configuration”*, I was referring to the fact
that CP2K does not automatically allow arbitrary combinations of force
engines unless the specific interface is compiled and enabled at build time.
What this means in practice
Even if your input file is syntactically correct, CP2K will only accept
certain hybrid or external-force combinations if:
1. The interface exists in your CP2K build
For DeePMD specifically, CP2K must be compiled with:
-
-DDEEPMD support enabled
-
Linked against the DeePMD-kit C++ library (libdeepmd_c.so or equivalent)
-
Matching API version between CP2K ↔ DeePMD-kit
If this is not present, CP2K will still parse the input but fail later with:
-
CPASSERT failed in force_env_types.F
-
or “unknown keyword / force type” errors
…------------------------------
2. The coupling mode is actually implemented in CP2K core
This is the more subtle part.
CP2K supports:
-
QM/MM coupling (well established)
-
Single global MM force fields
-
External potentials (limited cases)
-
Machine learning potentials (DeePMD, GAP, etc. depending on version)
But *it does NOT generally support arbitrary additive partitioning like:*
-
DeePMD on subsystem A
-
Classical FF on subsystem B
-
then linear mixing of forces via a custom MIXED block
That kind of “manual force partition + linear combination” is not a
standard CP2K feature in most releases.
So even if the syntax resembles QM/MM, CP2K may reject:
-
custom METHOD Mixed
-
non-standard MIXING_TYPE
-
or duplicated FORCE_EVAL blocks intended to be merged
------------------------------
Why your current error is happening
In your input, CP2K is likely failing because:
-
METHOD Mixed is not a valid FORCE_EVAL method in standard CP2K
-
Multiple FORCE_EVAL blocks are being interpreted as independent
simulations, not coupled subsystems
-
The DeePMD interface is being used correctly, but *not within a
supported coupling framework*
So CP2K reaches internal validation (force_env_types.F) and aborts because
the force environment topology is inconsistent with its expected
architecture.
------------------------------
What *is actually supported*
Depending on version, you typically have only these safe options:
Option A — Pure DeePMD simulation
Use DeePMD as the only force engine for all atoms.
Option B — Classical MM only
AMBER / CHARMM / etc.
Option C — QM/MM (only supported hybrid framework)
If you truly need partitioning, CP2K expects QM/MM style coupling, not
MM+ML mixing.
------------------------------
What I would recommend
If your goal is:
“DeePMD + classical force field in one system”
Then currently in CP2K, the most stable approach is:
-
either unify everything into DeePMD (train combined system)
-
or use QM/MM where QM is DFT and MM is classical
-
or use an external driver (ASE / LAMMPS coupling / custom wrapper) for
true hybrid ML+MM control
------------------------------
If you want, I can help next
If you share:
-
CP2K version
-
DeePMD version
-
compile flags (or cp2k.psmp -c output header)
I can tell you exactly:
-
what hybrid modes your build actually supports
-
and whether partial coupling is possible or fundamentally blocked
------------------------------
Let me know 👍
On Wed, Jun 24, 2026 at 2:34 AM Priya Dey ***@***.***> wrote:
Dear @Tobi-Adesoye <https://github.com/Tobi-Adesoye>
The input is following:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!instruct CP2K to initialize a MIXED force environment
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
&FORCE_EVAL
METHOD Mixed
&MIXED
MIXING_TYPE LINEAR_COMBINATION
&LINEAR
!# Combines forces additively across the defined subsystems
LAMBDA 0.5
&END LINEAR
&END MIXED
&END FORCE_EVAL
!!Bind the Inorganic Metallic Subsystem to DeePMD-kit
&FORCE_EVAL
METHOD FIST
&MM
&FORCEFIELD
&NONBONDED
&DEEPMD
ATOMS C CU N S
ATOMS_DEEPMD_TYPE 0 1 2 3
POT_FILE_NAME graph.pb
&END DEEPMD
&END NONBONDED
&END FORCEFIELD
&END MM
&SUBSYS
&CELL
A 18.8886360910 0 0
B 0 19.7198589339 0
C 0 0 55.0091418766
PERIODIC XY
&END CELL
&TOPOLOGY
COORD_FILE_NAME structure_new.xyz
COORD_FILE_FORMAT XYZ
&END TOPOLOGY
&KIND C
ELEMENT C
&END KIND
&KIND Cu
ELEMENT Cu
&END KIND
&KIND N
ELEMENT N
&END KIND
&KIND S
ELEMENT S
&END KIND
&END SUBSYS
&END FORCE_EVAL
#Bind the Organic Subsystem to your Classical Force Field
&FORCE_EVAL
METHOD FIST
#SUBsys_NAME Force_Organic
&MM
&FORCEFIELD
PARM_FILE_NAME y6.prmtop
PARMTYPE AMBER
&END FORCEFIELD
&POISSON
&EWALD
EWALD_TYPE SPME
&END EWALD
&END POISSON
&END MM
&SUBSYS
&CELL
ABC 25.0 25.0 25.0
&END CELL
&TOPOLOGY
COORD_FILE_NAME y6_core.xyz
COORD_FILE_FORMAT XYZ
&END TOPOLOGY
&END SUBSYS
&END FORCE_EVAL
#Configure the NVT Ensemble Integration Loop
&MOTION
&MD
ENSEMBLE NVT
STEPS 50000
TIMESTEP [fs] 0.5
TEMPERATURE [K] 300.0
&THERMOSTAT
TYPE CSVR
&CSVR
TIMECON 1000.0
&END CSVR
&END THERMOSTAT
&END MD
&END MOTION
—
Reply to this email directly, view it on GitHub
<#5505?email_source=notifications&email_token=AQSPCWHIQZV476WMZR42CX35BMV2NA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZUGE2DENRTUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#discussioncomment-17414263>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQSPCWFXTMQVMHUD2I3AA2L5BMV2NAVCNFSNUABIKJSXA33TNF2G64TZHMYTCNBQGA3DCOJTHNCGS43DOVZXG2LPNY5TCMBSGE3TAMZRUF3AE>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AQSPCWDTGJMSHSIVY33MKE35BMV2NA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZUGE2DENRTUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/AQSPCWEHGORJSWIX74ZOLID5BMV2NA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZUGE2DENRTUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
|
Hi Priya
this helps clarify the situation.
From what you’ve provided (CP2K 2024.3 + DeePMD-kit v3.1.3 with deepmd +
libtorch enabled), your build is correctly configured for *standard DeePMD
force evaluation inside CP2K*, so the interface layer itself is not the
issue.
The key point is that your current failure is still not related to
compilation or CUDA/TensorFlow/Torch runtime warnings — those
TensorFlow/cuDNN/cuBLAS messages are *non-fatal initialization logs from
DeePMD’s backend* and can be safely ignored unless the run aborts earlier.
------------------------------
The actual limitation you are hitting
CP2K 2024.3 supports DeePMD only as a *standalone FORCE_EVAL driver*, not
as a participant in a *custom mixed-force coupling scheme*.
So while your build supports:
- METHOD FIST + DeePMD
- Pure DeePMD MD runs
- Standard QM/MM frameworks
It does *not support*:
- Arbitrary multi-force additive schemes (e.g. DeePMD + classical FF
simultaneously on the same atomic system via a custom MIXED or hybrid
block)
- Non-QM/MM force partitioning inside a single global force environment
This is consistent with the architecture of CP2K’s force evaluation tree —
multiple FORCE_EVAL sections are treated as independent subsystems unless
explicitly coupled through supported QM/MM or periodic embedding schemes.
------------------------------
Why your input still fails
Even if DeePMD is correctly loaded, CP2K will fail when:
- A non-supported METHOD Mixed or equivalent coupling directive is used
- Multiple FORCE_EVAL blocks are defined with the expectation of force
aggregation
- The force topology is inconsistent with CP2K’s internal
force_env_types.F validation layer
So the failure is not in DeePMD — it is in the *assumed coupling model*,
which CP2K does not expose generically.
------------------------------
What your current build *does support*
With CP2K 2024.3 + DeePMD enabled, you can reliably use:
Option 1 — Pure DeePMD MD
Single unified ML potential for all atoms.
Option 2 — Classical FF only
AMBER / CHARMM / etc.
Option 3 — QM/MM (true supported hybrid)
DFT region + classical MM region (only officially supported hybrid coupling
scheme).
------------------------------
Important clarification for your goal
If your intention is:
“DeePMD + classical force field in the same simulation domain with additive
coupling”
Then in CP2K 2024.3 this is *not natively supported*, even if both engines
compile successfully.
To achieve that workflow, you typically need one of:
- External coupling (ASE / Python driver / LAMMPS + DeePMD plugin)
- Re-training a unified DeePMD potential that absorbs classical effects
- QM/MM reformulation (if physically justified)
…------------------------------
I'd recommend
Given your stack is already correctly built, the most stable path forward
is:
- Use DeePMD as the *sole force field* for the system, *or*
- Move to an external orchestrator if hybrid ML+classical decomposition
is essential
Trying to force a MIXED-force architecture inside CP2K will remain
structurally incompatible with the current force evaluation design.
On Wed, Jun 24, 2026 at 6:59 AM Priya Dey ***@***.***> wrote:
Dear @Tobi-Adesoye <https://github.com/Tobi-Adesoye>
Thank you for replying. I am using the following version of software:
1. CP2K version 2024.3
2. DeePMD-kit v3.1.3
the compiler flag:
2026-06-24 14:58:04.983380: I tensorflow/core/util/port.cc:111] oneDNN
custom operations are on. You may see slightly different numerical results
due to floating-point round-off errors from different computation orders.
To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2026-06-24 14:58:05.001677: E
tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to
register cuDNN factory: Attempting to register factory for plugin cuDNN
when one has already been registered
2026-06-24 14:58:05.001701: E
tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to
register cuFFT factory: Attempting to register factory for plugin cuFFT
when one has already been registered
2026-06-24 14:58:05.001729: E
tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to
register cuBLAS factory: Attempting to register factory for plugin cuBLAS
when one has already been registered
DeePMD-kit: Successfully load libcudart.so.11.0
CP2K version 2024.3
Source code revision git:6712648
cp2kflags: omp libint fftw3 libxc libgrpp pexsi elpa parallel scalapack
mpi_f08 cosma quip deepmd xsmm plumed2 spglib sirius libvori libbqb
libtorch libvdwxc hdf5
compiler: GCC version 13.3.0
—
Reply to this email directly, view it on GitHub
<#5505?email_source=notifications&email_token=AQSPCWHO6GYTGEHD3RO7QW35BNU4ZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZUGE3DINRVUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#discussioncomment-17416465>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQSPCWEQQMVDDBVIINQJF4D5BNU4ZAVCNFSNUABIKJSXA33TNF2G64TZHMYTCNBQGA3DCOJTHNCGS43DOVZXG2LPNY5TCMBSGE3TAMZRUF3AE>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AQSPCWHZT5CFLWAHK54BKYL5BNU4ZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZUGE3DINRVUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/AQSPCWGLIDZJPDD356SPYCD5BNU4ZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZUGE3DINRVUZZGKYLTN5XKO3LFNZ2GS33OUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Is it possible to perform an NVT simulation in CP2K for a hybrid metallic–organic system, where a DeepMD potential is used for the inorganic component and a classical force field is applied to the organic component?
DeePMD-kit Version
DeePMD-kit v3.1.3
Backend and its version
TensorFlow 2.19.1
Python Version, CUDA Version, GCC Version, LAMMPS Version, etc
Python 3.12.13
CUDA toolkit (nvcc) 12.0.140
CUDA 12.8
CP2K 2024.3
Details
No response
Reproducible Example, Input Files, and Commands
No response
Further Information, Files, and Links
No response
Beta Was this translation helpful? Give feedback.
All reactions