18 USE iso_c_binding,
ONLY: c_char,&
25 #include "./base/base_uses.f90"
31 TYPE deepmd_model_type
33 TYPE(C_PTR) :: c_ptr = c_null_ptr
34 END TYPE deepmd_model_type
44 CHARACTER(len=*),
INTENT(INOUT) :: filename
45 TYPE(deepmd_model_type) :: model
47 CHARACTER(LEN=*),
PARAMETER :: routinen =
'deepmd_model_load'
51 FUNCTION newdeeppot(filename)
BIND(C, name="DP_NewDeepPot")
52 IMPORT :: c_ptr, c_char
53 CHARACTER(kind=C_CHAR),
DIMENSION(*) :: filename
54 TYPE(c_ptr) :: newdeeppot
58 CALL timeset(routinen, handle)
61 model%c_ptr = newdeeppot(filename=trim(filename)//c_null_char)
63 cpabort(
"CP2K was compiled without libdeepmd_c library.")
85 atomic_energy, atomic_virial)
86 TYPE(deepmd_model_type) :: model
88 REAL(kind=
dp),
DIMENSION(natom, 3),
INTENT(IN) :: coord
89 INTEGER,
DIMENSION(natom),
INTENT(IN) :: atype
90 REAL(kind=
dp),
DIMENSION(9),
INTENT(IN) :: cell
91 REAL(kind=
dp),
INTENT(OUT) :: energy
92 REAL(kind=
dp),
DIMENSION(natom, 3),
INTENT(OUT) :: force
93 REAL(kind=
dp),
DIMENSION(9),
INTENT(OUT) :: virial
94 REAL(kind=
dp),
DIMENSION(natom),
INTENT(OUT) :: atomic_energy
95 REAL(kind=
dp),
DIMENSION(natom, 9),
INTENT(OUT) :: atomic_virial
97 CHARACTER(LEN=*),
PARAMETER :: routinen =
'deepmd_model_compute'
101 SUBROUTINE deeppotcompute(model, natom, coord, atype, cell, energy, force, virial, &
102 atomic_energy, atomic_virial)
BIND(C, name="DP_DeepPotCompute")
103 IMPORT :: c_ptr, c_int, c_double
104 TYPE(c_ptr),
VALUE :: model
105 INTEGER(C_INT),
VALUE :: natom
106 REAL(c_double),
DIMENSION(natom, 3) :: coord
107 INTEGER(C_INT),
DIMENSION(natom) :: atype
108 REAL(c_double),
DIMENSION(9) :: cell
109 REAL(c_double) :: energy
110 REAL(c_double),
DIMENSION(natom, 3) :: force
111 REAL(c_double),
DIMENSION(9) :: virial
112 REAL(c_double),
DIMENSION(natom) :: atomic_energy
113 REAL(c_double),
DIMENSION(natom, 9) :: atomic_virial
117 CALL timeset(routinen, handle)
119 #if defined(__DEEPMD)
120 CALL deeppotcompute(model=model%c_ptr, &
128 atomic_energy=atomic_energy, &
129 atomic_virial=atomic_virial)
131 cpabort(
"CP2K was compiled without libdeepmd_c library.")
140 mark_used(atomic_energy)
141 mark_used(atomic_virial)
144 CALL timestop(handle)
152 TYPE(deepmd_model_type) :: model
154 model%c_ptr = c_null_ptr
Interface to the DeePMD-kit or a c++ wrapper.
type(deepmd_model_type) function, public deepmd_model_load(filename)
Load DP from a model file.
subroutine, public deepmd_model_release(model)
Releases a deepmd model and all its ressources.
subroutine, public deepmd_model_compute(model, natom, coord, atype, cell, energy, force, virial, atomic_energy, atomic_virial)
Compute energy, force and virial from DP.
Defines the basic variable types.
integer, parameter, public dp