Beispiel #1
0
void  boost(double * n, double *p)
{

   double M=p[0]; /* particle mass */
   double shY=n[0]; /* h-sine of rapidity */
   double chY=sqrt(1+ shY*shY);
   double f= ENERGY(M,p+1)*shY + (p[1]*n[1]+p[2]*n[2]+p[3]*n[3])*(chY-1);

   int i;
   for(i=1;i<=3;i++) p[i]+=n[i]*f;
} 
Beispiel #2
0
std::vector<double>
OBSpectrophore::GetSpectrophore(OpenBabel::OBMol* mol)
{
   // Clear the return variable
   _spectro.clear();

   // Atoms
   _nAtoms = mol->NumAtoms();
   if (_nAtoms < 3)
   {
      std::cerr << "OBSpectrophore::GetSpectrophore() error: not enough atoms in molecule" << std::endl;;
      return _spectro;
   }

   // Coordinate and property arrays
   _oricoor = new double*[_nAtoms];
   _coor = new double*[_nAtoms];
   double** REF1 = new double*[_nAtoms];
   double** REF2 = new double*[_nAtoms];
   _property = new double*[_nAtoms];
   for (unsigned int i = 0; i < _nAtoms; ++i)
   {
      _oricoor[i] = new double[3];
      _coor[i] = new double[3];
      REF1[i] = new double[3];
      REF2[i] = new double[3];
      _property[i] = new double[N_PROPERTIES];
   }

    // Atom radii and coordinates
   _radii = new double[_nAtoms];
   _getMoleculeData(mol);

   // Atom properties
   _calculateProperties(mol);

   // Shift molecule to its center of gravity and orient it in a standard way
   _orient();

   // Calculate the first spectrum to initiate values
   unsigned int sphoreSize(N_PROPERTIES * _numberOfProbes);
   std::vector<double> ENERGY(sphoreSize);
   std::vector<double> SPHORE(sphoreSize);

   // Properties
   _getBox(_oricoor);
   _getEnergies(_oricoor, &(ENERGY[0]));
   _initiateSpectrophore(&(ENERGY[0]), &(SPHORE[0]));

   // Rotate
   double psi;
   double cos_psi;
   double sin_psi;
   double theta;
   double cos_theta;
   double sin_theta;
   double phi;
   double cos_phi;
   double sin_phi;

   for (unsigned int i = 0; i < _rotationStepList.size(); ++i)
   {
      int rotationStep(_rotationStepList[i]);

      for (int iTheta = 0; iTheta < 180; iTheta += rotationStep)
      {
         theta = 0.017453292519943 * iTheta;
         cos_theta = cos(theta);
         sin_theta = sin(theta);
         _rotateY(_oricoor, REF1, cos_theta, sin_theta);

         for (int iPsi = 0; iPsi < 360; iPsi += rotationStep)
         {
            psi = 0.017453292519943 * iPsi;
            cos_psi = cos(psi);
            sin_psi = sin(psi);
            _rotateZ(REF1, REF2, cos_psi, sin_psi);

            for (int iPhi = 0; iPhi < 360; iPhi += rotationStep)
            {
               phi = 0.017453292519943 * iPhi;
               cos_phi = cos(phi);
               sin_phi = sin(phi);
               _rotateX(REF2, _coor, cos_phi, sin_phi);

               // Calculate energies
               _getBox(_coor);
               _getEnergies(_coor, &(ENERGY[0]));
               _updateSpectrophore(&(ENERGY[0]), &(SPHORE[0]));
            }
         }
      }
   }


   // Cleanup
   for (unsigned int i = 0; i < _nAtoms; ++i)
   {
      delete[] _property[i];
      delete[] _oricoor[i];
      delete[] REF1[i];
      delete[] REF2[i];
      delete[] _coor[i];
      _property[i] = NULL;
      _oricoor[i] = NULL;
      REF1[i] = NULL;
      REF2[i] = NULL;
      _coor[i] = NULL;
   }
   delete[] _radii;
   _radii = NULL;


   // Modify the actual sphore data
   _spectro.resize(sphoreSize);
   for (unsigned int i = 0; i < sphoreSize; ++i)
   {
      _spectro[i] = -100 * SPHORE[i];
   }

   // Normalisation
   double mean[N_PROPERTIES];
   double std[N_PROPERTIES];
   unsigned int m;
   for (unsigned int i(0); i < N_PROPERTIES; ++i)
   {
      mean[i] = 0.0;
      for (unsigned int n(0); n < 12; ++n)
      {
         m = (i * 12) + n;
         mean[i] += _spectro[m];
      }
      mean[i] /= 12.0;
      std[i] = 0.0;
      for (unsigned int n(0); n < 12; ++n)
      {
         m = (i * 12) + n;
         std[i] += (_spectro[m] - mean[i]) * (_spectro[m] - mean[i]);
      }
      std[i] /= 11.0;
      std[i] = sqrt(std[i]);
   }
   if ((_normalization == OBSpectrophore::NormalizationTowardsZeroMean) ||
       (_normalization == OBSpectrophore::NormalizationTowardsZeroMeanAndUnitStd))
   {
      for (unsigned int i(0); i < N_PROPERTIES; ++i)
      {
         for (unsigned int n(0); n < 12; ++n)
         {
            m = (i * 12) + n;
            _spectro[m] -= mean[i];
         }
      }
   }
   if ((_normalization == OBSpectrophore::NormalizationTowardsUnitStd) ||
       (_normalization == OBSpectrophore::NormalizationTowardsZeroMeanAndUnitStd))
   {
      for (unsigned int i(0); i < N_PROPERTIES; ++i)
      {
         for (unsigned int n(0); n < 12; ++n)
         {
            m = (i * 12) + n;
            _spectro[m] /= std[i];
         }
      }
   }

   // Return
   return _spectro;
}