Tinker9 70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
urey.h
1#pragma once
2#include "math/libfunc.h"
3#include "seq/add.h"
4#include "seq/seq.h"
5
6namespace tinker {
7#pragma acc routine seq
8template <class Ver>
11 real& restrict vzx, real& restrict vyy, real& restrict vzy,
12 real& restrict vzz,
13
16
17 real ureyunit, int i, const int (*restrict iury)[3], const real* restrict uk,
18 const real* restrict ul, real cury, real qury,
19
20 const real* restrict x, const real* restrict y, const real* restrict z)
21{
22 constexpr bool do_e = Ver::e;
23 constexpr bool do_g = Ver::g;
24 constexpr bool do_v = Ver::v;
25
26 const int ia = iury[i][0];
27 const int ic = iury[i][2];
28 const real ideal = ul[i];
29 const real force = uk[i];
30
31 real xac = x[ia] - x[ic];
32 real yac = y[ia] - y[ic];
33 real zac = z[ia] - z[ic];
34
35 real rac = REAL_SQRT(xac * xac + yac * yac + zac * zac);
36 real dt = rac - ideal;
37 real dt2 = dt * dt;
38
39 if CONSTEXPR (do_e) {
40 e = ureyunit * force * dt2 * (1 + cury * dt + qury * dt2);
41 }
42
43 if CONSTEXPR (do_g) {
44 real deddt = 2 * ureyunit * force * dt
45 * (1 + 1.5f * cury * dt + 2 * qury * dt2);
46 real de = deddt * REAL_RECIP(rac);
47 real dedx = de * xac;
48 real dedy = de * yac;
49 real dedz = de * zac;
50
51 atomic_add(dedx, deubx, ia);
52 atomic_add(dedy, deuby, ia);
53 atomic_add(dedz, deubz, ia);
54 atomic_add(-dedx, deubx, ic);
55 atomic_add(-dedy, deuby, ic);
56 atomic_add(-dedz, deubz, ic);
57
58 if CONSTEXPR (do_v) {
59 vxx = xac * dedx;
60 vyx = yac * dedx;
61 vzx = zac * dedx;
62 vyy = yac * dedy;
63 vzy = zac * dedy;
64 vzz = zac * dedz;
65 }
66 }
67}
68}
void atomic_add(T value, T *buffer, size_t offset=0)
Definition: acc/adddef.h:14
#define SEQ_CUDA
Definition: acc/seqdef.h:12
#define restrict
Definition: macro.h:51
#define CONSTEXPR
Definition: macro.h:61
real * z
Current coordinates used in energy evaluation and neighbor lists.
real * x
Number of the trajectory frames.
real * y
Current coordinates used in energy evaluation and neighbor lists.
float real
Definition: precision.h:80
fixed grad_prec
Definition: precision.h:103
real ureyunit
real qury
grad_prec * deubz
real * uk
real cury
int(* iury)[3]
real * ul
grad_prec * deubx
grad_prec * deuby
Definition: testrt.h:9
__device__ void dk_urey(real &__restrict__ e, real &__restrict__ vxx, real &__restrict__ vyx, real &__restrict__ vzx, real &__restrict__ vyy, real &__restrict__ vzy, real &__restrict__ vzz, grad_prec *__restrict__ deubx, grad_prec *__restrict__ deuby, grad_prec *__restrict__ deubz, real ureyunit, int i, const int(*__restrict__ iury)[3], const real *__restrict__ uk, const real *__restrict__ ul, real cury, real qury, const real *__restrict__ x, const real *__restrict__ y, const real *__restrict__ z)
Definition: urey.h:10