⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 torsion.cc

📁 c++编写的并行拉马克遗传算法的程序。实现分析对接程序
💻 CC
字号:
/* torsion.cc */#include <math.h>#ifdef sgi    #include "constants.h"    #include "structs.h"    #include "torsion.h"#else    extern "C"    {        #include "constants.h"        #include "structs.h"        #include "torsion.h"    }#endifvoid torsion( State now,              float crd[MAX_ATOMS][SPACE],              float v[MAX_TORS][SPACE],              int   tlist[MAX_TORS][MAX_ATOMS],              int   ntor )/******************************************************************************//*      Name: torsion                                                         *//*  Function: Apply the Torsion rotation(s) to the Small Molecule.            *//* Copyright: (C) TSRI                                                        *//*----------------------------------------------------------------------------*//*    Author: Garrett Morris, The Scripps Research Institute                  *//*      Date: 03/14/94                                                        *//*----------------------------------------------------------------------------*//*    Inputs: now, v, tlist, ntor                                             *//*   Returns: crd                                                             *//*   Globals: MAX_TORS, SPACE, MAX_ATOMS.                                     *//*----------------------------------------------------------------------------*//* Modification Record                                                        *//* Date     Inits   Comments                                                  *//* 05/14/92 GMM     Translated into C                                         *//* 03/14/94 GMM     optimized equations, redundant operations removed...      *//******************************************************************************/{    register double crdtemp[SPACE];    register double  d[SPACE];    register double sv[SPACE];    register double ov[SPACE];    register double  k[SPACE][SPACE];    register double s, c, o, vni, this_tor;                /* "o" is: 1. - c, "One minus c". */    register int n, a, mvatm, atmnum, numatmmoved;    for (n = 0;  n < ntor;  n++) {                /* "n"-th Torsion */          s = sin(this_tor = ModRad(now.tor[n]));          o = 1. - (c = cos(this_tor));          /*          atmnum = Serial number of Atom 0 in Torsion n, (0)--(1)           This atom is at the origin of the current torsion          vector, about which we are rotating...          */          atmnum = tlist[n][0];          crdtemp[X] = crd[atmnum][X];          crdtemp[Y] = crd[atmnum][Y];          crdtemp[Z] = crd[atmnum][Z];          sv[X] = s * (vni = v[n][X]);          k[X][X] = (ov[X] = o * vni) * vni + c;          sv[Y] = s * (vni = v[n][Y]);          k[Y][Y] = (ov[Y] = o * vni) * vni + c;          sv[Z] = s * (vni = v[n][Z]);          k[Z][Z] = (ov[Z] = o * vni) * vni + c;          k[Y][Z]  =  v[n][Y] * ov[Z]  -  sv[X];          k[Z][X]  =  v[n][Z] * ov[X]  -  sv[Y];          k[X][Y]  =  v[n][X] * ov[Y]  -  sv[Z];          k[Z][Y]  =  v[n][Z] * ov[Y]  +  sv[X];          k[X][Z]  =  v[n][X] * ov[Z]  +  sv[Y];          k[Y][X]  =  v[n][Y] * ov[X]  +  sv[Z];          numatmmoved = tlist[n][NUM_ATM_MOVED] + 3;           for (a = 3;  a < numatmmoved;  a++ )  {                      mvatm = tlist[n][a]; /* mvatm = Serial Num of Atom to be moved by this Torsion */              d[X] = crd[mvatm][X] - crdtemp[X];              d[Y] = crd[mvatm][Y] - crdtemp[Y];              d[Z] = crd[mvatm][Z] - crdtemp[Z];              crd[mvatm][X] = crdtemp[X] + d[X] * k[X][X] + d[Y] * k[X][Y] + d[Z] * k[X][Z];               crd[mvatm][Y] = crdtemp[Y] + d[X] * k[Y][X] + d[Y] * k[Y][Y] + d[Z] * k[Y][Z];               crd[mvatm][Z] = crdtemp[Z] + d[X] * k[Z][X] + d[Y] * k[Z][Y] + d[Z] * k[Z][Z];           }/*a*/    } /*n*/}/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -