LigandDroplet.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "molmodel/internal/common.h"
00039 #include "molmodel/internal/Compound.h"
00040 #include <iostream>
00041 #include <fstream>
00042
00043
00044
00045 namespace SimTK
00046 {
00047
00048 class LigandDroplet : public Compound { public:
00049 LigandDroplet(CompoundSystem &system
00050 , TinkerDuMMForceFieldSubsystem &dumm
00051 , GeneralForceSubsystem& forces
00052 , Vec3 dropletCenter = Vec3(0,0,0 )
00053 , float dropletRadius = 2.50
00054 , float arista = 1.6
00055 )
00056 {
00057 Vec3 atomLocation;
00058 AtomPathName myAtomName;
00059 float shellRadius =10.0;
00060 int cellsAcross = dropletRadius*2/arista+1;
00061 std::cout<<"cellsAcross = "<<cellsAcross<<std::endl;
00062 int totalAtoms =0;
00063 int myWaterVecOccupation[cellsAcross][cellsAcross][cellsAcross];
00064 int numWater =0;
00065
00066 VanderWallSphere myVanderWallSphere( forces, dumm,dropletCenter,shellRadius, .1 , 1.0 );
00067
00068 float myRadius=0.;
00069 for (int xi = 0; xi < cellsAcross; xi++)
00070 for (int yi = 0; yi < cellsAcross; yi++)
00071 for (int zi = 0; zi < cellsAcross; zi++)
00072 {
00073 cout<<"for indices "<<xi<<","<<yi<<","<<zi<<endl;
00074
00075 cout<<" checking condition: "<<dropletCenter[0]<<","<<xi<<" , = "<<pow((dropletCenter[0]-(xi*arista-dropletRadius)),2)<<endl;
00076 myRadius = pow((pow((xi*arista-dropletRadius),float(2))+ pow((yi*arista-dropletRadius),float(2))+ pow((zi*arista-dropletRadius),float(2))),float(.5) );
00077 cout<<"radius = "<<myRadius<<endl;
00078 if (myRadius <= dropletRadius)
00079 {
00080
00081 numWater++;myWaterVecOccupation[xi][yi][zi] = 1;
00082 }
00083 else
00084 {cout<<"outside of water droplet radius; no water to be placed here."<<endl; myWaterVecOccupation[xi][yi][zi] = 0;}
00085 }
00086
00087
00088 for (int i =0 ; i< system.getNumCompounds(); i++)
00089 {
00090 cout<<"counting atoms in compound # "<<i<<endl;
00091 totalAtoms += system.updCompound(Compound::Index(i)).getNAtoms();
00092 }
00093 cout<<"counted "<<totalAtoms<<" total atoms."<<endl;
00094
00095 Vec3 atomLocationArray[totalAtoms];
00096 int myAtomIndex = 0;
00097
00098 for (int i =0 ; i< system.getNumCompounds(); i++)
00099 {
00100 for (int j = 0; j< system.updCompound(Compound::Index(i)).getNAtoms(); j++)
00101 {
00102 Compound & myCompound = system.updCompound(Compound::Index(i));
00103 myAtomName = myCompound.getAtomName(Compound::AtomIndex(j));
00104 atomLocationArray[myAtomIndex] = myCompound.calcDefaultAtomLocationInGroundFrame(myAtomName);
00105
00106
00107
00108 cout << "myAtomName= "<<myAtomName<<" atomLocation= "<<atomLocationArray[myAtomIndex]<<endl;
00109 int myxi = (atomLocationArray[myAtomIndex][0]-dropletCenter[0]+dropletRadius)/arista+.5;
00110 int myyi = (atomLocationArray[myAtomIndex][1]-dropletCenter[1]+dropletRadius)/arista+.5;
00111 int myzi = (atomLocationArray[myAtomIndex][2]-dropletCenter[2]+dropletRadius)/arista+.5;
00112 cout<<" indices = "<<myxi<<","<<myyi<<","<<myzi<<endl;
00113 if (((myxi < cellsAcross) && (myxi >=0))
00114 && ((myyi < cellsAcross) && (myyi >=0))
00115 && ((myzi < cellsAcross) && (myzi >=0))
00116 && (myWaterVecOccupation[myxi][myyi][myzi] == 1))
00117 {
00118 numWater--;
00119 cout<<"setting an occupation to 0"<<endl;
00120 myWaterVecOccupation[myxi][myyi][myzi] = 0;
00121 }
00122 myAtomIndex++;
00123 }
00124 }
00125
00126 cout<<"about to create array of "<<numWater<<" water molecules."<<endl;
00127 P12 * myWaterVec[numWater];
00128 for (int k =0;k<numWater;k++) {
00129 myWaterVec[k]=new P12(dumm);
00130 (*myWaterVec[k]).setPdbResidueName("P12");
00131 (*myWaterVec[k]).setPdbResidueNumber(k+1 );
00132 (*myWaterVec[k]).setPdbChainId('D');
00133 }
00134
00135 int myWaterIndex =-1;
00136 for (int xi = 0; xi < cellsAcross; xi++)
00137 for (int yi = 0; yi < cellsAcross; yi++)
00138 for (int zi = 0; zi < cellsAcross; zi++)
00139 {
00140 cout<<"checking occupation for "<<xi<<","<<yi<<","<<zi<<endl;
00141 if (myWaterVecOccupation[xi][yi][zi])
00142 {
00143 myWaterIndex++;
00144 if (myWaterIndex > numWater) {cout << "Attempted to adopt more water than exists in array"<<endl; exit(1);}
00145 cout<<"adopting water at "<< xi*arista-dropletRadius+dropletCenter[0]<<","<<yi*arista-dropletRadius+dropletCenter[1]<<"=,"<<zi*arista-dropletRadius+dropletCenter[2]<<endl;
00146 Rotation myRotation(45.*Deg2Rad, YAxis);
00147 myRotation = myRotation * Rotation(45.*Deg2Rad, XAxis);
00148 Transform myTransform(myRotation,Vec3(xi*arista-dropletRadius+dropletCenter[0],yi*arista-dropletRadius+dropletCenter[1],zi*arista-dropletRadius+dropletCenter[2]));
00149 system.adoptCompound(*myWaterVec[myWaterIndex],myTransform);
00150 }
00151 }
00152
00153
00154
00155
00156 }
00157 };
00158 }