Ignore:
Timestamp:
Jul 10, 2009, 12:48:05 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
22f587
Parents:
a8c8ba
Message:

molecule::CenterInBox puts atoms now periodically into the given box, new function molecule::TranslatePeriodically, BUGFIX: molecule::ReturnFullMatrixforSymmetrical()

  • molecule::CenterInBox() has no more a vector as a parameter, but instead enforces the periodicity of the simulation box, i.e. all atoms out of bounds are put back in with wrap-around at boundaries. Call of function was changed in everywhere.
  • in ParseCommandLineParameters() a SetBoxDimension was missing in certain Center...() commands.
  • new function molecule::TranslatePeriodically translates all atoms of a molecule while adhering to the periodicity of the domain
  • new function vector::InverseMatrix() returns the hard-encoded inverse of 3x3 real matrix
  • BUGFIX: molecule::ReturnFullMatrixforSymmetrical()'s assignment from 6-doubles to 9-doubles was all wrong (symmetric to full 3x3 matrix)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/vector.cpp

    ra8c8ba r6fb785  
    413413        for (int i=NDIM;i--;)
    414414                x[i] = C.x[i];
     415};
     416
     417/** Calculate the inverse of a 3x3 matrix.
     418 * \param *matrix NDIM_NDIM array
     419 */
     420double * Vector::InverseMatrix(double *A)
     421{
     422  double *B = (double *) Malloc(sizeof(double)*NDIM*NDIM, "Vector::InverseMatrix: *B");
     423  double detA = RDET3(A);
     424  double detAReci;
     425
     426  for (int i=0;i<NDIM*NDIM;++i)
     427    B[i] = 0.;
     428  // calculate the inverse B
     429  if (fabs(detA) > MYEPSILON) {;  // RDET3(A) yields precisely zero if A irregular
     430    detAReci = 1./detA;
     431    B[0] =  detAReci*RDET2(A[4],A[5],A[7],A[8]);    // A_11
     432    B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]);    // A_12
     433    B[2] =  detAReci*RDET2(A[1],A[2],A[4],A[5]);    // A_13
     434    B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]);    // A_21
     435    B[4] =  detAReci*RDET2(A[0],A[2],A[6],A[8]);    // A_22
     436    B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]);    // A_23
     437    B[6] =  detAReci*RDET2(A[3],A[4],A[6],A[7]);    // A_31
     438    B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]);    // A_32
     439    B[8] =  detAReci*RDET2(A[0],A[1],A[3],A[4]);    // A_33
     440  }
     441  return B;
    415442};
    416443
Note: See TracChangeset for help on using the changeset viewer.