Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
docking
ocladock
Commits
1354f05c
Commit
1354f05c
authored
Apr 17, 2018
by
Leonardo Solis
Browse files
corrected grid forces for ligand with rotbond
parent
1948124e
Changes
48
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
1354f05c
...
...
@@ -4,6 +4,7 @@ initpop.txt
*.xml
input/albumin_dock/
ocladock.wiki/
bin/
final_population_run*
device/stringify_tmp
KernelProgramBuildInfo.txt
...
...
Makefile
View file @
1354f05c
...
...
@@ -197,7 +197,11 @@ odock: check-env-all stringify $(SRC)
# Example
PDB
:=
1ac8
# 1ac8: for testing gradients of translation and rotation genes
# 7cpa: for testing gradients of torsion genes (15 torsions)
# 3tmn: for testing gradients of torsion genes (1 torsion)
PDB
:=
3tmn
NRUN
:=
1
POPSIZE
:=
10
TESTNAME
:=
test
...
...
device/calcenergy.cl
View file @
1354f05c
...
...
@@ -22,6 +22,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#
define
DEBUG_ENERGY
#
include
"calcenergy_basic.h"
//
All
related
pragmas
are
in
defines.h
(
accesible
by
host
and
device
code
)
...
...
@@ -53,6 +56,11 @@ void gpu_calc_energy(
__local
float*
calc_coords_z,
__local
float*
partial_energies,
#
if
defined
(
DEBUG_ENERGY
)
__local
float*
partial_interE,
__local
float*
partial_intraE,
#
endif
__constant
float*
atom_charges_const,
__constant
char*
atom_types_const,
__constant
char*
intraE_contributors_const,
...
...
@@ -76,6 +84,12 @@ void gpu_calc_energy(
{
partial_energies[get_local_id
(
0
)
]
=
0.0f
;
#
if
defined
(
DEBUG_ENERGY
)
partial_interE[get_local_id
(
0
)
]
=
0.0f
;
partial_intraE[get_local_id
(
0
)
]
=
0.0f
;
#
endif
#
if
defined
(
IMPROVE_GRID
)
//
INTERMOLECULAR
for-loop
(
intermediate
results
)
//
It
stores
a
product
of
two
chars
...
...
@@ -276,6 +290,10 @@ void gpu_calc_energy(
|| (y >= dockpars_gridsize_y-1)
|
|
(
z
>=
dockpars_gridsize_z-1
))
{
partial_energies[get_local_id
(
0
)
]
+=
16777216.0f
; //100000.0f;
#
if
defined
(
DEBUG_ENERGY
)
partial_interE[get_local_id
(
0
)
]
+=
16777216.0f
;
#
endif
}
else
{
...
...
@@ -380,6 +398,10 @@ void gpu_calc_energy(
//
Calculating
affinity
energy
partial_energies[get_local_id
(
0
)
]
+=
TRILININTERPOL
(
cube,
weights
)
;
#
if
defined
(
DEBUG_ENERGY
)
partial_interE[get_local_id
(
0
)
]
+=
TRILININTERPOL
(
cube,
weights
)
;
#
endif
//
Capturing
electrostatic
values
atom_typeid
=
dockpars_num_of_atypes
;
...
...
@@ -444,6 +466,10 @@ void gpu_calc_energy(
//
Calculating
electrosatic
energy
partial_energies[get_local_id
(
0
)
]
+=
q
*
TRILININTERPOL
(
cube,
weights
)
;
#
if
defined
(
DEBUG_ENERGY
)
partial_interE[get_local_id
(
0
)
]
+=
q
*
TRILININTERPOL
(
cube,
weights
)
;
#
endif
//
Capturing
desolvation
values
atom_typeid
=
dockpars_num_of_atypes+1
;
...
...
@@ -507,10 +533,36 @@ void gpu_calc_energy(
//
Calculating
desolvation
energy
partial_energies[get_local_id
(
0
)
]
+=
fabs
(
q
)
*
TRILININTERPOL
(
cube,
weights
)
;
#
if
defined
(
DEBUG_ENERGY
)
partial_interE[get_local_id
(
0
)
]
+=
fabs
(
q
)
*
TRILININTERPOL
(
cube,
weights
)
;
#
endif
}
}
//
End
atom_id
for-loop
(
INTERMOLECULAR
ENERGY
)
#
if
defined
(
DEBUG_ENERGY
)
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
get_local_id
(
0
)
==
0
)
{
float
energy_interE
=
partial_interE[0]
;
for
(
uint
contributor_counter=1
;
contributor_counter<NUM_OF_THREADS_PER_BLOCK
;
contributor_counter++
)
{
energy_interE
+=
partial_interE[contributor_counter]
;
}
partial_interE[0]
=
energy_interE
;
//printf
(
"%-20s %-10.8f\n"
,
"energy_interE: "
,
energy_interE
)
;
}
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
#
endif
//
In
paper:
intermolecular
and
internal
energy
calculation
//
are
independent
from
each
other,
->
NO
BARRIER
NEEDED
//
but
require
different
operations,
...
...
@@ -559,33 +611,49 @@ void gpu_calc_energy(
//
Calculating
van
der
Waals
/
hydrogen
bond
term
#
if
defined
(
NATIVE_PRECISION
)
partial_energies[get_local_id
(
0
)
]
+=
native_divide
(
VWpars_AC_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],native_powr
(
atomic_distance,12
))
;
#
if
defined
(
DEBUG_ENERGY
)
partial_intraE[get_local_id
(
0
)
]
+=
native_divide
(
VWpars_AC_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],native_powr
(
atomic_distance,12
))
;
#
endif
#
elif
defined
(
HALF_PRECISION
)
p
for
(
uint
rotation_counter
=
get_local_id
(
0
)
;
for
(
uint
rotation_counter
=
get_local_id
(
0
)
;
rotation_counter
<
dockpars_rotbondlist_length
;
rotation_counter+=NUM_OF_THREADS_PER_BLOCK
)
{artial_energies[get_local_id
(
0
)
]
+=
half_divide
(
VWpars_AC_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],half_powr
(
atomic_distance,12
))
;
{
p
artial_energies[get_local_id
(
0
)
]
+=
half_divide
(
VWpars_AC_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],half_powr
(
atomic_distance,12
))
;
#
else
//
Full
precision
partial_energies[get_local_id
(
0
)
]
+=
VWpars_AC_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid]/powr
(
atomic_distance,12
)
;
#
endif
if
(
intraE_contributors_const[3*contributor_counter+2]
==
1
)
//H-bond
if
(
intraE_contributors_const[3*contributor_counter+2]
==
1
)
{
//H-bond
#
if
defined
(
NATIVE_PRECISION
)
partial_energies[get_local_id
(
0
)
]
-=
native_divide
(
VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],native_powr
(
atomic_distance,10
))
;
#
if
defined
(
DEBUG_ENERGY
)
partial_intraE[get_local_id
(
0
)
]
-=
native_divide
(
VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],native_powr
(
atomic_distance,10
))
;
#
endif
#
elif
defined
(
HALF_PRECISION
)
partial_energies[get_local_id
(
0
)
]
-=
half_divide
(
VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],half_powr
(
atomic_distance,10
))
;
#
else
//
Full
precision
partial_energies[get_local_id
(
0
)
]
-=
VWpars_BD_const[atom1_typeid*dockpars_num_of_atypes+atom2_typeid]/powr
(
atomic_distance,10
)
;
#
endif
else
//van
der
Waals
}
else
{
//van
der
Waals
#
if
defined
(
NATIVE_PRECISION
)
partial_energies[get_local_id
(
0
)
]
-=
native_divide
(
VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],native_powr
(
atomic_distance,6
))
;
#
if
defined
(
DEBUG_ENERGY
)
partial_intraE[get_local_id
(
0
)
]
-=
native_divide
(
VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],native_powr
(
atomic_distance,6
))
;
#
endif
#
elif
defined
(
HALF_PRECISION
)
partial_energies[get_local_id
(
0
)
]
-=
half_divide
(
VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],half_powr
(
atomic_distance,6
))
;
#
else
//
Full
precision
partial_energies[get_local_id
(
0
)
]
-=
VWpars_BD_const[atom1_typeid*dockpars_num_of_atypes+atom2_typeid]/powr
(
atomic_distance,6
)
;
#
endif
}
//
Calculating
electrostatic
term
/*
...
...
@@ -600,7 +668,24 @@ void gpu_calc_energy(
atomic_distance
*
(
-8.5525f
+
half_divide
(
86.9525f,
(
1.0f
+
7.7839f*half_exp
(
-0.3154f*atomic_distance
))))
)
;
#
else
//
Full
precision
partial_energies[get_local_id
(
0
)
]
+=
dockpars_coeff_elec*atom_charges_const[atom1_id]*atom_charges_const[atom2_id]/
partial_energies[get_local_
#
if
defined
(
DEBUG_ENERGY
)
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
get_local_id
(
0
)
==
0
)
{
float
energy_interE
=
partial_interE[0]
;
for
(
uint
contributor_counter=1
;
contributor_counter<NUM_OF_THREADS_PER_BLOCK
;
contributor_counter++
)
{
energy_interE
+=
partial_interE[contributor_counter]
;
}
}
printf
(
"%-20s %-10.8f\n"
,
"energy_interE: "
,
energy_interE
)
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
#
endifid
(
0
)
]
+=
dockpars_coeff_elec*atom_charges_const[atom1_id]*atom_charges_const[atom2_id]/
(
atomic_distance*
(
-8.5525f
+
86.9525f/
(
1.0f
+
7.7839f*exp
(
-0.3154f*atomic_distance
))))
;
#
endif
*/
...
...
@@ -611,6 +696,15 @@ void gpu_calc_energy(
dockpars_coeff_elec
*
atom_charges_const[atom1_id]
*
atom_charges_const[atom2_id],
atomic_distance
*
(
DIEL_A
+
native_divide
(
DIEL_B,
(
1.0f
+
DIEL_K*native_exp
(
-DIEL_B_TIMES_H*atomic_distance
))))
)
;
#
if
defined
(
DEBUG_ENERGY
)
partial_intraE[get_local_id
(
0
)
]
+=
native_divide
(
dockpars_coeff_elec
*
atom_charges_const[atom1_id]
*
atom_charges_const[atom2_id],
atomic_distance
*
(
DIEL_A
+
native_divide
(
DIEL_B,
(
1.0f
+
DIEL_K*native_exp
(
-DIEL_B_TIMES_H*atomic_distance
))))
)
;
#
endif
#
elif
defined
(
HALF_PRECISION
)
partial_energies[get_local_id
(
0
)
]
+=
half_divide
(
dockpars_coeff_elec
*
atom_charges_const[atom1_id]
*
atom_charges_const[atom2_id],
...
...
@@ -635,6 +729,15 @@ void gpu_calc_energy(
(
dspars_S_const[atom2_typeid]
+
dockpars_qasp*fabs
(
atom_charges_const[atom2_id]
))
*dspars_V_const[atom1_typeid]
)
*
dockpars_coeff_desolv*native_exp
(
-atomic_distance*native_divide
(
atomic_distance,25.92f
))
;
#
if
defined
(
DEBUG_ENERGY
)
partial_intraE[get_local_id
(
0
)
]
+=
((
dspars_S_const[atom1_typeid]
+
dockpars_qasp*fabs
(
atom_charges_const[atom1_id]
))
*dspars_V_const[atom2_typeid]
+
(
dspars_S_const[atom2_typeid]
+
dockpars_qasp*fabs
(
atom_charges_const[atom2_id]
))
*dspars_V_const[atom1_typeid]
)
*
dockpars_coeff_desolv*native_exp
(
-atomic_distance*native_divide
(
atomic_distance,25.92f
))
;
#
endif
#
elif
defined
(
HALF_PRECISION
)
partial_energies[get_local_id
(
0
)
]
+=
((
dspars_S_const[atom1_typeid]
+
dockpars_qasp*fabs
(
atom_charges_const[atom1_id]
))
*dspars_V_const[atom2_typeid]
+
...
...
@@ -666,6 +769,26 @@ void gpu_calc_energy(
}
}
#
if
defined
(
DEBUG_ENERGY
)
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
get_local_id
(
0
)
==
0
)
{
float
energy_intraE
=
partial_intraE[0]
;
for
(
uint
contributor_counter=1
;
contributor_counter<NUM_OF_THREADS_PER_BLOCK
;
contributor_counter++
)
{
energy_intraE
+=
partial_intraE[contributor_counter]
;
}
partial_intraE[0]
=
energy_intraE
;
//printf
(
"%-20s %-10.8f\n"
,
"energy_intraE: "
,
energy_intraE
)
;
}
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
#
endif
}
#
include
"kernel1.cl"
...
...
device/calcgradient.cl
View file @
1354f05c
...
...
@@ -34,6 +34,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
whose
population
includes
the
current
entity
(
which
can
be
determined
with
get_group_id
(
0
))
,
//
since
this
determines
which
reference
orientation
should
be
used.
//#define
DEBUG_GRAD_TRANSLATION_GENES
//#define
DEBUG_GRAD_ROTATION_GENES
#
define
DEBUG_GRAD_TORSION_GENES
//#define
DEBUG_GRAD
void
gpu_calc_gradient
(
int
dockpars_rotbondlist_length,
char
dockpars_num_of_atoms,
...
...
@@ -71,12 +77,14 @@ void gpu_calc_gradient(
__constant
float*
ref_coords_z_const,
__constant
float*
rotbonds_moving_vectors_const,
__constant
float*
rotbonds_unit_vectors_const,
__constant
float*
ref_orientation_quats_const
__constant
float*
ref_orientation_quats_const,
__constant
int*
rotbonds_const,
__constant
int*
rotbonds_atoms_const,
__constant
int*
num_rotating_atoms_per_rotbond_const
//
Gradient-related
arguments
//
Calculate
gradients
(
forces
)
for
intermolecular
energy
//
Derived
from
autodockdev/maps.py
//
"is_enabled_gradient_calc"
:
enables
gradient
calculation.
//
In
Genetic-Generation:
no
need
for
gradients
//
In
Gradient-Minimizer:
must
calculate
gradients
...
...
@@ -321,6 +329,8 @@ void gpu_calc_gradient(
float dy = y - y_low;
float dz = z - z_low;
//printf("%-15s %-5u %-10.8f %-10.8f %-10.8f\n", "dx,dy,dz", atom_id, dx, dy, dz);
// Capturing affinity values
uint ylow_times_g1 = y_low*g1;
uint yhigh_times_g1 = y_high*g1;
...
...
@@ -447,6 +457,8 @@ void gpu_calc_gradient(
vz_y1
=
(
1
-
dx
)
*
z62
+
dx
*
z75
; // y = 1
gradient_inter_z[atom_id]
+=
(
1
-
dy
)
*
vz_y0
+
dy
*
vz_y1
;
//printf
(
"%-15s %-3u %-10.8f %-10.8f %-10.8f %-10.8f %-10.8f %-10.8f\n"
,
"atom aff"
,
atom_id,
vx_z0,
vx_z1,
vy_z0,
vy_z1,
vz_y0,
vz_y1
)
;
//
-------------------------------------------------------------------
//
Calculating
gradients
(
forces
)
corresponding
to
//
"elec"
intermolecular
energy
...
...
@@ -473,7 +485,7 @@ void gpu_calc_gradient(
x76
=
cube
[1][1][1]
-
cube
[0][1][1]
; // z = 1
vx_z0
=
(
1
-
dy
)
*
x10
+
dy
*
x52
; // z = 0
vx_z1
=
(
1
-
dy
)
*
x43
+
dy
*
x76
; // z = 1
gradient_inter_x[atom_id]
+=
(
1
-
dz
)
*
vx_z0
+
dz
*
vx_z1
;
gradient_inter_x[atom_id]
+=
q
*
(
(
1
-
dz
)
*
vx_z0
+
dz
*
vx_z1
)
;
//
Vector
in
y-direction
y20
=
cube[0][1][0]
-
cube
[0][0][0]
; // z = 0
...
...
@@ -482,7 +494,7 @@ void gpu_calc_gradient(
y74
=
cube[1][1][1]
-
cube
[1][0][1]
; // z = 1
vy_z0
=
(
1
-
dx
)
*
y20
+
dx
*
y51
; // z = 0
vy_z1
=
(
1
-
dx
)
*
y63
+
dx
*
y74
; // z = 1
gradient_inter_y[atom_id]
+=
(
1
-
dz
)
*
vy_z0
+
dz
*
vy_z1
;
gradient_inter_y[atom_id]
+=
q
*
(
(
1
-
dz
)
*
vy_z0
+
dz
*
vy_z1
)
;
//
Vectors
in
z-direction
z30
=
cube
[0][0][1]
-
cube
[0][0][0]
; // y = 0
...
...
@@ -491,7 +503,9 @@ void gpu_calc_gradient(
z75
=
cube
[1][1][1]
-
cube
[1][1][0]
; // y = 1
vz_y0
=
(
1
-
dx
)
*
z30
+
dx
*
z41
; // y = 0
vz_y1
=
(
1
-
dx
)
*
z62
+
dx
*
z75
; // y = 1
gradient_inter_z[atom_id]
+=
(
1
-
dy
)
*
vz_y0
+
dy
*
vz_y1
;
gradient_inter_z[atom_id]
+=
q
*
((
1
-
dy
)
*
vz_y0
+
dy
*
vz_y1
)
;
//printf
(
"%-15s %-3u %-10.8f %-10.8f %-10.8f %-10.8f %-10.8f %-10.8f\n"
,
"elec"
,
atom_id,
vx_z0,
vx_z1,
vy_z0,
vy_z1,
vz_y0,
vz_y1
)
;
//
-------------------------------------------------------------------
//
Calculating
gradients
(
forces
)
corresponding
to
...
...
@@ -519,7 +533,7 @@ void gpu_calc_gradient(
x76
=
cube
[1][1][1]
-
cube
[0][1][1]
; // z = 1
vx_z0
=
(
1
-
dy
)
*
x10
+
dy
*
x52
; // z = 0
vx_z1
=
(
1
-
dy
)
*
x43
+
dy
*
x76
; // z = 1
gradient_inter_x[atom_id]
+=
(
1
-
dz
)
*
vx_z0
+
dz
*
vx_z1
;
gradient_inter_x[atom_id]
+=
fabs
(
q
)
*
(
(
1
-
dz
)
*
vx_z0
+
dz
*
vx_z1
)
;
//
Vector
in
y-direction
y20
=
cube[0][1][0]
-
cube
[0][0][0]
; // z = 0
...
...
@@ -528,7 +542,7 @@ void gpu_calc_gradient(
y74
=
cube[1][1][1]
-
cube
[1][0][1]
; // z = 1
vy_z0
=
(
1
-
dx
)
*
y20
+
dx
*
y51
; // z = 0
vy_z1
=
(
1
-
dx
)
*
y63
+
dx
*
y74
; // z = 1
gradient_inter_y[atom_id]
+=
(
1
-
dz
)
*
vy_z0
+
dz
*
vy_z1
;
gradient_inter_y[atom_id]
+=
fabs
(
q
)
*
(
(
1
-
dz
)
*
vy_z0
+
dz
*
vy_z1
)
;
//
Vectors
in
z-direction
z30
=
cube
[0][0][1]
-
cube
[0][0][0]
; // y = 0
...
...
@@ -537,7 +551,10 @@ void gpu_calc_gradient(
z75
=
cube
[1][1][1]
-
cube
[1][1][0]
; // y = 1
vz_y0
=
(
1
-
dx
)
*
z30
+
dx
*
z41
; // y = 0
vz_y1
=
(
1
-
dx
)
*
z62
+
dx
*
z75
; // y = 1
gradient_inter_z[atom_id]
+=
(
1
-
dy
)
*
vz_y0
+
dy
*
vz_y1
;
gradient_inter_z[atom_id]
+=
fabs
(
q
)
*
((
1
-
dy
)
*
vz_y0
+
dy
*
vz_y1
)
;
//printf
(
"%-15s %-3u %-10.8f %-10.8f %-10.8f %-10.8f %-10.8f %-10.8f\n"
,
"desol"
,
atom_id,
vx_z0,
vx_z1,
vy_z0,
vy_z1,
vz_y0,
vz_y1
)
;
//
-------------------------------------------------------------------
}
...
...
@@ -559,6 +576,9 @@ void gpu_calc_gradient(
//
Getting
atom
IDs
uint
atom1_id
=
intraE_contributors_const[3*contributor_counter]
;
uint
atom2_id
=
intraE_contributors_const[3*contributor_counter+1]
;
/*
printf
(
"%-5u %-5u %-5u\n"
,
contributor_counter,
atom1_id,
atom2_id
)
;
*/
//
Calculating
vector
components
of
vector
going
//
from
first
atom
's
to
second
atom
's
coordinates
...
...
@@ -587,7 +607,8 @@ void gpu_calc_gradient(
if
(
intraE_contributors_const[3*contributor_counter+2]
==
1
)
{
//H-bond
gradient_per_intracontributor[contributor_counter]
+=
native_divide
(
10*VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],
native_powr
(
atomic_distance,
11
)
)
;
)
;
}
else
{
//van
der
Waals
gradient_per_intracontributor[contributor_counter]
+=
native_divide
(
6*VWpars_BD_const[atom1_typeid
*
dockpars_num_of_atypes+atom2_typeid],
...
...
@@ -615,7 +636,7 @@ void gpu_calc_gradient(
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
//
Accumulating
gradients
of
each
atom
from
"gradient_per_intracontributor"
//
Accumulating
gradients
from
"gradient_per_intracontributor"
for
each
each
if
(
get_local_id
(
0
)
==
0
)
{
for
(
uint
contributor_counter
=
0
;
contributor_counter
<
dockpars_num_of_intraE_contributors
;
...
...
@@ -625,22 +646,23 @@ void gpu_calc_gradient(
uint
atom1_id
=
intraE_contributors_const[3*contributor_counter]
;
uint
atom2_id
=
intraE_contributors_const[3*contributor_counter+1]
;
//
Calculating
xyz
distances
in
Angstroms
//
between
"atom1_id"
-to-
"atom2_id"
float
subx
=
(
calc_coords_x[atom1_id]
-
calc_coords_x[atom2_id]
)
*
dockpars_grid_spacing
;
float
suby
=
(
calc_coords_y[atom1_id]
-
calc_coords_y[atom2_id]
)
*
dockpars_grid_spacing
;
float
subz
=
(
calc_coords_z[atom1_id]
-
calc_coords_z[atom2_id]
)
*
dockpars_grid_spacing
;
//
Calculating
xyz
distances
in
Angstroms
of
vector
//
that
goes
from
"atom1_id"
-to-
"atom2_id"
float
subx
=
(
calc_coords_x[atom2_id]
-
calc_coords_x[atom1_id]
)
;
float
suby
=
(
calc_coords_y[atom2_id]
-
calc_coords_y[atom1_id]
)
;
float
subz
=
(
calc_coords_z[atom2_id]
-
calc_coords_z[atom1_id]
)
;
float
dist
=
native_sqrt
(
subx*subx
+
suby*suby
+
subz*subz
)
;
//
Calculating
gradients
in
xyz
components.
//
Gradients
for
both
atoms
in
a
single
contributor
pair
//
have
the
same
magnitude,
but
opposite
directions
gradient_intra_x[atom1_id]
+
=
gradient_per_intracontributor[contributor_counter]
*
subx
;
gradient_intra_y[atom1_id]
+
=
gradient_per_intracontributor[contributor_counter]
*
suby
;
gradient_intra_z[atom1_id]
+
=
gradient_per_intracontributor[contributor_counter]
*
subz
;
gradient_intra_x[atom1_id]
-
=
gradient_per_intracontributor[contributor_counter]
*
subx
/
dist
;
gradient_intra_y[atom1_id]
-
=
gradient_per_intracontributor[contributor_counter]
*
suby
/
dist
;
gradient_intra_z[atom1_id]
-
=
gradient_per_intracontributor[contributor_counter]
*
subz
/
dist
;
gradient_intra_x[atom2_id]
-
=
gradient_per_intracontributor[contributor_counter]
*
subx
;
gradient_intra_y[atom2_id]
-
=
gradient_per_intracontributor[contributor_counter]
*
suby
;
gradient_intra_z[atom2_id]
-
=
gradient_per_intracontributor[contributor_counter]
*
subz
;
gradient_intra_x[atom2_id]
+
=
gradient_per_intracontributor[contributor_counter]
*
subx
/
dist
;
gradient_intra_y[atom2_id]
+
=
gradient_per_intracontributor[contributor_counter]
*
suby
/
dist
;
gradient_intra_z[atom2_id]
+
=
gradient_per_intracontributor[contributor_counter]
*
subz
/
dist
;
}
}
...
...
@@ -651,9 +673,26 @@ void gpu_calc_gradient(
for
(
uint
atom_cnt
=
get_local_id
(
0
)
;
atom_cnt
<
dockpars_num_of_atoms
;
atom_cnt+=
NUM_OF_THREADS_PER_BLOCK
)
{
gradient_x[atom_cnt]
=
gradient_inter_x[atom_cnt]
+
gradient_intra_x[atom_cnt]
;
gradient_y[atom_cnt]
=
gradient_inter_y[atom_cnt]
+
gradient_intra_y[atom_cnt]
;
gradient_z[atom_cnt]
=
gradient_inter_z[atom_cnt]
+
gradient_intra_z[atom_cnt]
;
//
Grid
gradients
were
calculated
in
the
grid
space,
//
so
they
have
to
be
put
back
in
Angstrom.
//
Intramolecular
gradients
were
already
in
Angstrom,
//
so
no
scaling
for
them
is
required.
gradient_inter_x[atom_cnt]
=
gradient_inter_x[atom_cnt]
/
dockpars_grid_spacing
;
gradient_inter_y[atom_cnt]
=
gradient_inter_y[atom_cnt]
/
dockpars_grid_spacing
;
gradient_inter_z[atom_cnt]
=
gradient_inter_z[atom_cnt]
/
dockpars_grid_spacing
;
gradient_x[atom_cnt]
=
gradient_inter_x[atom_cnt]
;//+ gradient_intra_x[atom_cnt];
gradient_y[atom_cnt]
=
gradient_inter_y[atom_cnt]
;//+ gradient_intra_y[atom_cnt];
gradient_z[atom_cnt]
=
gradient_inter_z[atom_cnt]
;//+ gradient_intra_z[atom_cnt];
printf
(
"%-15s %-5u %-10.8f %-10.8f %-10.8f\n"
,
"grad_grid"
,
atom_cnt,
gradient_inter_x[atom_cnt],
gradient_inter_y[atom_cnt],
gradient_inter_z[atom_cnt]
)
;
//printf
(
"%-15s %-5u %-10.8f %-10.8f %-10.8f\n"
,
"grad_intra"
,
atom_cnt,
gradient_intra_x[atom_cnt],
gradient_intra_y[atom_cnt],
gradient_intra_z[atom_cnt]
)
;
//printf
(
"%-15s %-5u %-10.8f %-10.8f %-10.8f\n"
,
"calc_coords"
,
atom_cnt,
calc_coords_x[atom_cnt],
calc_coords_y[atom_cnt],
calc_coords_z[atom_cnt]
)
;
}
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
...
...
@@ -670,11 +709,20 @@ void gpu_calc_gradient(
gradient_genotype[2]
+=
gradient_z[lig_atom_id]
; // gradient for gene 2: gene z
}
/*
//
Scaling
gradient
for
translational
genes
as
//
their
corresponding
gradients
were
calculated
in
the
space
//
where
these
genes
are
in
Angstrom,
//
but
OCLaDock
translational
genes
are
within
in
grids
gradient_genotype[0]
*=
dockpars_grid_spacing
;
gradient_genotype[1]
*=
dockpars_grid_spacing
;
gradient_genotype[2]
*=
dockpars_grid_spacing
;
#
if
defined
(
DEBUG_GRAD_TRANSLATION_GENES
)
printf
(
"gradient_x:%f\n"
,
gradient_genotype
[0]
)
;
printf
(
"gradient_y:%f\n"
,
gradient_genotype
[1]
)
;
printf
(
"gradient_z:%f\n"
,
gradient_genotype
[2]
)
;
*/
#
endif
}
//
------------------------------------------
...
...
@@ -691,20 +739,23 @@ void gpu_calc_gradient(
//
------------------------------------------
if
(
get_local_id
(
0
)
==
1
)
{
float3
torque_rot
=
(
float3
)(
0.0f,
0.0f,
0.0f
)
;
float3
torque_rot
;
torque_rot.x
=
0.0f
;
torque_rot.y
=
0.0f
;
torque_rot.z
=
0.0f
;
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-20s %-10.5f %-10.5f %-10.5f\n"
,
"initial torque: "
,
torque_rot.x,
torque_rot.y,
torque_rot.z
)
;
#
endif
//
Center
of
rotation
//
In
getparameters.cpp,
it
indicates
//
translation
genes
are
in
grid
spacing
(
instead
of
Angstroms
)
float3
about
;
//#if
0
about.x
=
/*30*/genotype[0]
;
about.y
=
/*30*/genotype[1]
;
about.z
=
/*30*/genotype[2]
;
//#endif
//
Temporal
variable
to
calculate
translation
differences.
//
They
are
converted
back
to
Angstroms
here
float3
r
;
...
...
@@ -716,21 +767,33 @@ void gpu_calc_gradient(
r.y
=
(
calc_coords_y[lig_atom_id]
-
about.y
)
*
dockpars_grid_spacing
;
r.z
=
(
calc_coords_z[lig_atom_id]
-
about.z
)
*
dockpars_grid_spacing
;
float3
force
=
(
float3
)(
gradient_x[lig_atom_id],
gradient_y[lig_atom_id],
gradient_z[lig_atom_id]
)
/
dockpars_grid_spacing
;
float3
force
;
force.x
=
gradient_x[lig_atom_id]
;
force.y
=
gradient_y[lig_atom_id]
;
force.z
=
gradient_z[lig_atom_id]
;
torque_rot
+=
cross
(
r,
force
)
;
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-20s %-10u\n"
,
"contrib. of atom-id: "
,
lig_atom_id
)
;
printf
(
"%-20s %-10.5f %-10.5f %-10.5f\n"
,
"r : "
,
r.x,
r.y,
r.z
)
;
printf
(
"%-20s %-10.5f %-10.5f %-10.5f\n"
,
"force : "
,
force.x,
force.y,
force.z
)
;
printf
(
"%-20s %-10.5f %-10.5f %-10.5f\n"
,
"partial torque: "
,
torque_rot.x,
torque_rot.y,
torque_rot.z
)
;
printf
(
"\n"
)
;
#
endif
}
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-20s %-10.5f %-10.5f %-10.5f\n"
,
"final torque: "
,
torque_rot.x,
torque_rot.y,
torque_rot.z
)
;
#
endif
//
Derived
from
rotation.py/axisangle_to_q
()
//
genes[3:7]
=
rotation.axisangle_to_q
(
torque,
rad
)
float
torque_length
=
fast_length
(
torque_rot
)
;
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-20s %-10.5f\n"
,
"torque length: "
,
torque_length
)
;
#
endif
//
Infinitesimal
rotation
in
radians
const
float
infinitesimal_radian
=
1E-5
;
...
...
@@ -742,7 +805,10 @@ void gpu_calc_gradient(
quat_torque.x
=
fast_normalize
(
torque_rot
)
.
x
*
native_sin
(
infinitesimal_radian*0.5f
)
;
quat_torque.y
=
fast_normalize
(
torque_rot
)
.
y
*
native_sin
(
infinitesimal_radian*0.5f
)
;
quat_torque.z
=
fast_normalize
(
torque_rot
)
.
z
*
native_sin
(
infinitesimal_radian*0.5f
)
;
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-20s %-10.5f %-10.5f %-10.5f %-10.5f\n"
,
"quat_torque (w,x,y,z): "
,
quat_torque.w,
quat_torque.x,
quat_torque.y,
quat_torque.z
)
;
#
endif
//
Converting
quaternion
gradients
into
Shoemake
gradients
//
Derived
from
autodockdev/motion.py/_get_cube3_gradient
...
...
@@ -752,7 +818,10 @@ void gpu_calc_gradient(
current_u1
=
genotype[3]
; // check very initial input Shoemake genes
current_u2
=
genotype[4]
;
current_u3
=
genotype[5]
;
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-30s %-10.5f %-10.5f %-10.5f\n"
,
"current_u (1,2,3): "
,
genotype[3],
genotype[4],
genotype[5]
)
;
#
endif
//
This
is
where
we
are
in
quaternion
space
//
current_q
=
cube3_to_quaternion
(
current_u
)
...
...
@@ -761,7 +830,10 @@ void gpu_calc_gradient(
current_q.x
=
native_sqrt
(
1-current_u1
)
*
native_cos
(
PI_TIMES_2*current_u2
)
;
current_q.y
=
native_sqrt
(
current_u1
)
*
native_sin
(
PI_TIMES_2*current_u3
)
;
current_q.z
=
native_sqrt
(
current_u1
)
*
native_cos
(
PI_TIMES_2*current_u3
)
;
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-30s %-10.8f %-10.8f %-10.8f %-10.8f\n"
,
"current_q (w,x,y,z): "
,
current_q.w,
current_q.x,
current_q.y,
current_q.z
)
;
#
endif
//
This
is
where
we
want
to
be
in
quaternion
space
float4
target_q
;
...
...
@@ -773,7 +845,9 @@ void gpu_calc_gradient(
target_q.x
=
quat_torque.w*current_q.x
+
quat_torque.x*current_q.w
+
quat_torque.y*current_q.z
-
quat_torque.z*current_q.y
;// x
target_q.y
=
quat_torque.w*current_q.y
+
quat_torque.y*current_q.w
+
quat_torque.z*current_q.x
-
quat_torque.x*current_q.z
;// y
target_q.z
=
quat_torque.w*current_q.z
+
quat_torque.z*current_q.w
+
quat_torque.x*current_q.y
-
quat_torque.y*current_q.x
;// z
#
if
defined
(
DEBUG_GRAD_ROTATION_GENES
)
printf
(
"%-30s %-10.8f %-10.8f %-10.8f %-10.8f\n"
,
"target_q (w,x,y,z): "
,
target_q.w,
target_q.x,
target_q.y,
target_q.z
)
;
#
endif
//
This
is
where
we
want
to
be
in
Shoemake
space
float
target_u1,
target_u2,
target_u3
;
...
...
@@ -785,30 +859,20 @@ void gpu_calc_gradient(
target_u2
=
atan2
(
target_q.w,
target_q.x
)
;
target_u3
=
atan2
(
target_q.y,
target_q.z
)
;
if
(
target_u2
<
0.0f
)
{
target_u2
+=
PI_TIMES_2
;
}
if
(
target_u2
>
PI_TIMES_2
)
{
target_u2
-=
PI_TIMES_2
;
}
if
(
target_u3
<
0.0f
)
{
target_u3
+=
PI_TIMES_2
;
}
if
(
target_u3
>
PI_TIMES_2
)
{
target_u3
-=
PI_TIMES_2
;
}
/*
if
(
target_u2
<
0.0f
)
{
target_u2
+=
PI_TIMES_2
; }
if
(
target_u2
>
PI_TIMES_2
)
{
target_u2
-=
PI_TIMES_2
; }
if
(
target_u3
<
0.0f
)
{
target_u3
+=
PI_TIMES_2
; }
if
(
target_u3
>
PI_TIMES_2
)
{
target_u3
-=
PI_TIMES_2
; }
/*
printf
(
"%-30s %-10.8f %-10.8f %-10.8f\n"
,
"target_u (1,2,3) - before mapping: "
,
target_u1,
target_u2,
target_u3
)
;
target_u2
=
target_u2
/
PI_TIMES_2
;
target_u3
=
target_u3
/
PI_TIMES_2
;
*/
*/