calcgradient.cl 46.6 KB
Newer Older
1001
		float temp_u1 = genotype[3];
1002
			
1003
		if ((0.0f < temp_u1) && (temp_u1 < 1.0f)){
1004
			grad_u1 *= (native_divide(1.0f, temp_u1) + native_divide(1.0f, (1.0f-temp_u1)));
1005
		}
1006
1007
		grad_u2 *= 4.0f * (1.0f-temp_u1);
		grad_u3 *= 4.0f * temp_u1;
1008
1009

		#if defined (DEBUG_GRAD_ROTATION_GENES)
1010
		printf("%-30s %-10.8f %-10.8f %-10.8f\n", "grad_u (1,2,3) - after emp. scaling: ", grad_u1, grad_u2, grad_u3);
1011
		#endif
1012
		
1013
1014
1015
1016
		// Setting gradient rotation-related genotypes in cube3.
		// Scaling gradient for u2 and u3 genes as 
		// their corresponding gradients were calculated in the space where u2/3 are within [0, 2PI]
		// but OCLaDock u2/3 genes are within [0, 1]
1017
		gradient_genotype[3] = grad_u1;
1018
1019
		gradient_genotype[4] = grad_u2 * PI_TIMES_2; 
		gradient_genotype[5] = grad_u3 * PI_TIMES_2;
1020
1021
	}

Leonardo Solis's avatar
Leonardo Solis committed
1022
1023
1024
	// ------------------------------------------
	// Obtaining torsion-related gradients
	// ------------------------------------------
lvs's avatar
lvs committed
1025
1026
1027
1028
1029

	//----------------------------------
	// fastergrad
	//----------------------------------
/*
1030
1031
1032
1033
1034
	if (get_local_id(0) == 2) {

		for (uint rotbond_id = 0;
			  rotbond_id < dockpars_num_of_genes-6;
			  rotbond_id ++) {
lvs's avatar
lvs committed
1035
1036
1037
1038
1039
1040
*/

		for (uint rotbond_id = get_local_id(0);
			  rotbond_id < dockpars_num_of_genes-6;
			  rotbond_id +=NUM_OF_THREADS_PER_BLOCK) {
	//----------------------------------
1041

1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
			// Querying ids of atoms belonging to the rotatable bond in question
			int atom1_id = rotbonds_const[2*rotbond_id];
			int atom2_id = rotbonds_const[2*rotbond_id+1];

			float3 atomRef_coords;
			atomRef_coords.x = calc_coords_x[atom1_id];
			atomRef_coords.y = calc_coords_y[atom1_id];
			atomRef_coords.z = calc_coords_z[atom1_id];

			#if defined (DEBUG_GRAD_TORSION_GENES)
			printf("%-15s %-10u\n", "rotbond_id: ", rotbond_id);
			printf("%-15s %-10i\n", "atom1_id: ", atom1_id);
			printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom1_coords: ", calc_coords_x[atom1_id], calc_coords_y[atom1_id], calc_coords_z[atom1_id]);
			printf("%-15s %-10i\n", "atom2_id: ", atom2_id);
			printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom2_coords: ", calc_coords_x[atom2_id], calc_coords_y[atom2_id], calc_coords_z[atom2_id]);
			printf("\n");
			#endif		

1060
			float3 rotation_unitvec;
1061
			/*
1062
1063
1064
			rotation_unitvec.x = rotbonds_unit_vectors_const[3*rotbond_id];
			rotation_unitvec.y = rotbonds_unit_vectors_const[3*rotbond_id+1];
			rotation_unitvec.z = rotbonds_unit_vectors_const[3*rotbond_id+2];
1065
1066
1067
1068
1069
1070
			*/
			rotation_unitvec.x = calc_coords_x[atom2_id] - calc_coords_x[atom1_id];
			rotation_unitvec.y = calc_coords_y[atom2_id] - calc_coords_y[atom1_id];
			rotation_unitvec.z = calc_coords_z[atom2_id] - calc_coords_z[atom1_id];
			rotation_unitvec = fast_normalize(rotation_unitvec);

1071
			// Torque of torsions
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
			float3 torque_tor;
			torque_tor.x = 0.0f;
			torque_tor.y = 0.0f;
			torque_tor.z = 0.0f;

			// Iterating over each ligand atom that rotates 
			// if the bond in question rotates
			for (uint rotable_atom_cnt = 0;
				  rotable_atom_cnt<num_rotating_atoms_per_rotbond_const[rotbond_id];
				  rotable_atom_cnt++) {
1082

1083
				uint lig_atom_id = rotbonds_atoms_const[MAX_NUM_OF_ATOMS*rotbond_id + rotable_atom_cnt];
1084

Leonardo Solis's avatar
Leonardo Solis committed
1085
				// Calculating torque on point "A" 
1086
				// (could be any other point "B" along the rotation axis)
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
				float3 atom_coords;
				atom_coords.x = calc_coords_x[lig_atom_id];
				atom_coords.y = calc_coords_y[lig_atom_id];
				atom_coords.z = calc_coords_z[lig_atom_id];

				// Temporal variable to calculate translation differences.
				// They are converted back to Angstroms here
				float3 r;
				r.x = (atom_coords.x - atomRef_coords.x) * dockpars_grid_spacing;
				r.y = (atom_coords.y - atomRef_coords.y) * dockpars_grid_spacing;
				r.z = (atom_coords.z - atomRef_coords.z) * dockpars_grid_spacing;

				float3 atom_force;
				atom_force.x = gradient_x[lig_atom_id]; 
				atom_force.y = gradient_y[lig_atom_id];
				atom_force.z = gradient_z[lig_atom_id];

				torque_tor += cross(r, atom_force);

				#if defined (DEBUG_GRAD_TORSION_GENES)
				printf("\n");
Leonardo Solis's avatar
Leonardo Solis committed
1108
				printf("%-15s %-10u\n", "rotable_atom_cnt: ", rotable_atom_cnt);
1109
				printf("%-15s %-10u\n", "atom_id: ", lig_atom_id);
Leonardo Solis's avatar
Leonardo Solis committed
1110
1111
1112
				printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom_coords: ", atom_coords.x, atom_coords.y, atom_coords.z);
				printf("%-15s %-10.8f %-10.8f %-10.8f\n", "r: ", r.x, r.y, r.z);
				printf("%-15s %-10.8f %-10.8f %-10.8f\n", "unitvec: ", rotation_unitvec.x, rotation_unitvec.y, rotation_unitvec.z);
1113
				printf("%-15s %-10.8f %-10.8f %-10.8f\n", "atom_force: ", atom_force.x, atom_force.y, atom_force.z);
Leonardo Solis's avatar
Leonardo Solis committed
1114
				printf("%-15s %-10.8f %-10.8f %-10.8f\n", "torque_tor: ", torque_tor.x, torque_tor.y, torque_tor.z);
1115
				#endif
1116
1117

			}
1118
1119
1120
			#if defined (DEBUG_GRAD_TORSION_GENES)
			printf("\n");
			#endif
1121

1122
			// Projecting torque on rotation axis
1123
1124
1125
			float torque_on_axis = dot(rotation_unitvec, torque_tor);

			// Assignment of gene-based gradient
1126
			gradient_genotype[rotbond_id+6] = torque_on_axis * DEG_TO_RAD /*(M_PI / 180.0f)*/;
1127

1128
1129
1130
			#if defined (DEBUG_GRAD_TORSION_GENES)
			printf("gradient_torsion [%u] :%f\n", rotbond_id+6, gradient_genotype [rotbond_id+6]);
			#endif
1131
			
1132
		} // End of iterations over rotatable bonds
1133

lvs's avatar
lvs committed
1134
1135
1136
1137
1138
1139
1140
	//----------------------------------
	// fastergrad
	//----------------------------------
/*
	}
*/
	//----------------------------------
1141
}
For faster browsing, not all history is shown. View entire blame