Commit 6f1f40aa authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@935 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent 4933685c
Loading
Loading
Loading
Loading
+36 −31
Original line number Diff line number Diff line
@@ -26,10 +26,9 @@
#include "stdlib.h"
#include "pair_eam.h"
#include "atom.h"
#include "update.h"
#include "force.h"
#include "neighbor.h"
#include "comm.h"
#include "force.h"
#include "neigh_list.h"
#include "memory.h"

#define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -71,7 +70,7 @@ void PairEAMOpt::eval()
    double _pad[3];
  } fast_gamma_t;
  
  double** __restrict__ f;
  int i,j,ii,jj,inum,jnum,itype,jtype;
  double* __restrict__ coeff;
  
  // grow energy array if necessary
@@ -85,12 +84,10 @@ void PairEAMOpt::eval()
  }
  
  eng_vdwl = 0.0;
  if (VFLAG) for (int i = 0; i < 6; i++) virial[i] = 0.0;
  
  if (VFLAG == 2) f = update->f_pair;
  else f = atom->f;
  if (VFLAG) for (i = 0; i < 6; i++) virial[i] = 0.0;
  
  double** __restrict__ x = atom->x;
  double** __restrict__ f = atom->f;
  int* __restrict__ type = atom->type;
  int nlocal = atom->nlocal;
  
@@ -102,15 +99,17 @@ void PairEAMOpt::eval()
  int nr2 = nr-2;
  int nr1 = nr-1;
  
  int** __restrict__ firstneigh = neighbor->firstneigh;
  int* __restrict__ num = neighbor->numneigh;
  inum = list->inum;
  int* __restrict__ ilist = list->ilist;
  int** __restrict__ firstneigh = list->firstneigh;
  int* __restrict__ numneigh = list->numneigh;
  
  int ntypes = atom->ntypes;
  int ntypes2 = ntypes*ntypes;
  
  fast_alpha_t* __restrict__ fast_alpha = 
    (fast_alpha_t*) malloc(ntypes2*(nr+1)*sizeof(fast_alpha_t));
  for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
  for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
    fast_alpha_t* __restrict__ tab = &fast_alpha[i*ntypes*nr+j*nr];
    for(int m = 1; m <= nr; m++) {
      tab[m].rhor0i =  rhor_spline[type2rhor[i+1][j+1]][m][6];
@@ -127,7 +126,7 @@ void PairEAMOpt::eval()
  
  fast_gamma_t* __restrict__ fast_gamma = 
    (fast_gamma_t*) malloc(ntypes2*(nr+1)*sizeof(fast_gamma_t));
  for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
  for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
    fast_gamma_t* __restrict__ tab = &fast_gamma[i*ntypes*nr+j*nr];
    for(int m = 1; m <= nr; m++) {
      tab[m].rhor4i =  rhor_spline[type2rhor[i+1][j+1]][m][2];
@@ -151,25 +150,28 @@ void PairEAMOpt::eval()
  
  if (NEWTON_PAIR) {
    int m = nlocal + atom->nghost;
    for (int i = 0; i < m; i++) rho[i] = 0.0;
  } else for (int i = 0; i < nlocal; i++) rho[i] = 0.0;
    for (i = 0; i < m; i++) rho[i] = 0.0;
  } else for (i = 0; i < nlocal; i++) rho[i] = 0.0;
  
  // rho = density at each atom
  // loop over neighbors of my atoms
  
  for (int i = 0; i < nlocal; i++) {
  // loop over neighbors of my atoms
  
  for (ii = 0; ii < inum; ii++) {
    i = ilist[ii];
    double xtmp = xx[i].x;
    double ytmp = xx[i].y;
    double ztmp = xx[i].z;
    int itype = type[i] - 1;
    int* __restrict__ neighs = firstneigh[i];
    int numneigh = num[i];
    itype = type[i] - 1;
    int* __restrict__ jlist = firstneigh[i];
    jnum = numneigh[i];
    
    double tmprho = rho[i];
    
    fast_alpha_t* __restrict__ tabeighti = &tabeight[itype*ntypes*nr];
    for (int k = 0; k < numneigh; k++) {
      int j = neighs[k];

    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];

      double delx = xtmp - xx[j].x;
      double dely = ytmp - xx[j].y;
@@ -178,7 +180,7 @@ void PairEAMOpt::eval()
      
      if (rsq < tmp_cutforcesq) {
	
	int jtype = type[j] - 1;
	jtype = type[j] - 1;
	
	double p = sqrt(rsq)*tmp_rdr;
	if ( (int)p <= nr2 ) {
@@ -210,7 +212,8 @@ void PairEAMOpt::eval()
  // fp = derivative of embedding energy at each atom
  // phi = embedding energy at each atom
  
  for (int i = 0; i < nlocal; i++) {
  for (ii = 0; ii < inum; ii++) {
    i = ilist[ii];
    double p = rho[i]*rdrho;
    int m = MIN((int)p,nrho-2);
    p -= (double)m;
@@ -227,21 +230,23 @@ void PairEAMOpt::eval()
  // compute forces on each atom
  // loop over neighbors of my atoms

  for (int i = 0; i < nlocal; i++) {
  for (ii = 0; ii < inum; ii++) {
    i = ilist[ii];
    double xtmp = xx[i].x;
    double ytmp = xx[i].y;
    double ztmp = xx[i].z;
    int itype1 = type[i] - 1;
    int* __restrict__ neighs = firstneigh[i];
    int numneigh = num[i];
    int* __restrict__ jlist = firstneigh[i];
    jnum = numneigh[i];
    
    double tmpfx = 0.0;
    double tmpfy = 0.0;
    double tmpfz = 0.0;
    
    fast_gamma_t* __restrict__ tabssi = &tabss[itype1*ntypes*nr];
    for (int k = 0; k < numneigh; k++) {
      int j = neighs[k];

    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];
      
      double delx = xtmp - xx[j].x;
      double dely = ytmp - xx[j].y;
@@ -249,7 +254,7 @@ void PairEAMOpt::eval()
      double rsq = delx*delx + dely*dely + delz*delz;
      
      if (rsq < tmp_cutforcesq) {
	int jtype = type[j] - 1;
	jtype = type[j] - 1;
	double r = sqrt(rsq);
	double rhoip,rhojp,z2,z2p;
	double p = r*tmp_rdr;
+17 −25
Original line number Diff line number Diff line
@@ -21,21 +21,12 @@
#ifndef PAIR_LJ_CHARMM_COUL_LONG_OPT_H
#define PAIR_LJ_CHARMM_COUL_LONG_OPT_H

#include "pair_lj_charmm_coul_long.h"
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "pair_lj_charmm_coul_long.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "kspace.h"
#include "update.h"
#include "integrate.h"
#include "respa.h"
#include "memory.h"
#include "neighbor.h"
#include "error.h"
#include "neigh_list.h"

#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -69,24 +60,20 @@ void PairLJCharmmCoulLongOpt::eval()
    double _pad[2];
  } fast_alpha_t;
  
  int i,j,k,itype,jtype,itable;
  int i,j,ii,jj,inum,jnum,itype,jtype,itable;
  double fraction,table;
  double r,r2inv,r6inv,forcecoul,forcelj,fforce,factor_coul,factor_lj;
  double grij,expm2,prefactor,t,erfc;
  double factor,phicoul,philj,switch1,switch2;
  
  double** __restrict__ f;
  
  float rsq;
  int *int_rsq = (int *) &rsq;
  
  eng_vdwl = eng_coul = 0.0;
  if (VFLAG) for (i = 0; i < 6; i++) virial[i] = 0.0;
  
  if (VFLAG == 2) f = update->f_pair;
  else f = atom->f;
  
  double** __restrict__ x = atom->x;
  double** __restrict__ f = atom->f;
  double* __restrict__ q = atom->q;
  int* __restrict__ type = atom->type;
  int nlocal = atom->nlocal;
@@ -94,8 +81,11 @@ void PairLJCharmmCoulLongOpt::eval()
  double* __restrict__ special_coul = force->special_coul;
  double* __restrict__ special_lj = force->special_lj;
  double qqrd2e = force->qqrd2e;
  int** __restrict__ firstneigh = neighbor->firstneigh;
  int* __restrict__ num = neighbor->numneigh;

  inum = list->inum;
  int* __restrict__ ilist = list->ilist;
  int** __restrict__ firstneigh = list->firstneigh;
  int* __restrict__ numneigh = list->numneigh;
  
  vec3_t* __restrict__ xx = (vec3_t*)x[0];
  vec3_t* __restrict__ ff = (vec3_t*)f[0];
@@ -108,7 +98,7 @@ void PairLJCharmmCoulLongOpt::eval()
  
  fast_alpha_t* __restrict__ fast_alpha = 
    (fast_alpha_t*)malloc(ntypes2*sizeof(fast_alpha_t));
  for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
  for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
    fast_alpha_t& a = fast_alpha[i*ntypes+j];
    a.cutsq = cutsq[i+1][j+1];
    a.lj1 = lj1[i+1][j+1];
@@ -120,22 +110,24 @@ void PairLJCharmmCoulLongOpt::eval()
  
  // loop over neighbors of my atoms
  
  for (i = 0; i < nlocal; i++) {
  for (ii = 0; ii < inum; ii++) {
    i = ilist[ii];
    double qtmp = q[i];
    double xtmp = xx[i].x;
    double ytmp = xx[i].y;
    double ztmp = xx[i].z;
    itype = type[i] - 1;
    int* __restrict__ neighs = firstneigh[i];
    int numneigh = num[i];
    int* __restrict__ jlist = firstneigh[i];
    jnum = numneigh[i];
    
    double tmpfx = 0.0;
    double tmpfy = 0.0;
    double tmpfz = 0.0;
    
    fast_alpha_t* __restrict__ tabsixi = (fast_alpha_t*) &tabsix[itype*ntypes];
    for (k = 0; k < numneigh; k++) {
      j = neighs[k];

    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];
      
      if (j < nall) {
	double delx = xtmp - xx[j].x;
+20 −19
Original line number Diff line number Diff line
@@ -24,9 +24,8 @@
#include "stdlib.h"
#include "pair_lj_cut.h"
#include "atom.h"
#include "update.h"
#include "force.h"
#include "neighbor.h"
#include "neigh_list.h"

namespace LAMMPS_NS {

@@ -49,21 +48,22 @@ void PairLJCutOpt::eval()
    double _pad[2];
  } fast_alpha_t;
  
  double** __restrict__ f;
  int i,j,ii,jj,inum,jnum,itype,jtype;
  
  eng_vdwl = 0.0;
  if (VFLAG) for (int i = 0; i < 6; i++) virial[i] = 0.0;
  
  if (VFLAG == 2) f = update->f_pair;
  else f = atom->f;
  if (VFLAG) for (i = 0; i < 6; i++) virial[i] = 0.0;
  
  double** __restrict__ x = atom->x;
  double** __restrict__ f = atom->f;
  int* __restrict__ type = atom->type;
  int nlocal = atom->nlocal;
  int nall = atom->nlocal + atom->nghost;
  double* __restrict__ special_lj = force->special_lj;
  int** __restrict__ firstneigh = neighbor->firstneigh;
  int* __restrict__ num = neighbor->numneigh;

  inum = list->inum;
  int* __restrict__ ilist = list->ilist;
  int** __restrict__ firstneigh = list->firstneigh;
  int* __restrict__ numneigh = list->numneigh;
  
  vec3_t* __restrict__ xx = (vec3_t*)x[0];
  vec3_t* __restrict__ ff = (vec3_t*)f[0];
@@ -73,7 +73,7 @@ void PairLJCutOpt::eval()
  
  fast_alpha_t* __restrict__ fast_alpha = 
    (fast_alpha_t*) malloc(ntypes2*sizeof(fast_alpha_t));
  for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
  for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
    fast_alpha_t& a = fast_alpha[i*ntypes+j];
    a.cutsq = cutsq[i+1][j+1];
    a.lj1 = lj1[i+1][j+1];
@@ -86,13 +86,14 @@ void PairLJCutOpt::eval()
  
  // loop over neighbors of my atoms
  
  for (int i = 0; i < nlocal; i++) {
  for (ii = 0; ii < inum; ii++) {
    i = ilist[ii];
    double xtmp = xx[i].x;
    double ytmp = xx[i].y;
    double ztmp = xx[i].z;
    int itype = type[i] - 1;
    int* __restrict__ neighs = firstneigh[i];
    int numneigh = num[i];
    itype = type[i] - 1;
    int* __restrict__ jlist = firstneigh[i];
    jnum = numneigh[i];
    
    double tmpfx = 0.0;
    double tmpfy = 0.0;
@@ -100,8 +101,8 @@ void PairLJCutOpt::eval()
    
    fast_alpha_t* __restrict__ tabsixi = (fast_alpha_t*)&tabsix[itype*ntypes];
    
    for (int k = 0; k < numneigh; k++) {
      int j = neighs[k];
    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];
      double factor_lj;

      if (j < nall) {
@@ -110,7 +111,7 @@ void PairLJCutOpt::eval()
	double delz = ztmp - xx[j].z;
	double rsq = delx*delx + dely*dely + delz*delz;
	
	int jtype = type[j] - 1;
	jtype = type[j] - 1;
	
	fast_alpha_t& a = tabsixi[jtype];
	
@@ -155,7 +156,7 @@ void PairLJCutOpt::eval()
	double rsq = delx*delx + dely*dely + delz*delz;
	
	int jtype1 = type[j];
	int jtype = jtype1 - 1;
	jtype = jtype1 - 1;
	
	fast_alpha_t& a = tabsixi[jtype];
	if (rsq < a.cutsq) {
+20 −24
Original line number Diff line number Diff line
@@ -22,16 +22,11 @@
#define PAIR_MORSE_OPT_H

#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "pair_morse.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "update.h"
#include "memory.h"
#include "neighbor.h"
#include "error.h"
#include "neigh_list.h"

namespace LAMMPS_NS {

@@ -54,22 +49,22 @@ void PairMorseOpt::eval()
    double _pad[2];
  } fast_alpha_t;
  
  double** __restrict__ f;
  int i,j,ii,jj,inum,jnum,itype,jtype;
  
  eng_vdwl = 0.0;
  if (VFLAG) for (int i = 0; i < 6; i++) virial[i] = 0.0;
  
  if (VFLAG == 2) f = update->f_pair;
  else f = atom->f;
  if (VFLAG) for (i = 0; i < 6; i++) virial[i] = 0.0;
  
  double** __restrict__ x = atom->x;
  double** __restrict__ f = atom->f;
  int* __restrict__ type = atom->type;
  int nlocal = atom->nlocal;
  int nall = atom->nlocal + atom->nghost;
  double* __restrict__ special_lj = force->special_lj;
  
  int** __restrict__ firstneigh = neighbor->firstneigh;
  int* __restrict__ num = neighbor->numneigh;
  inum = list->inum;
  int* __restrict__ ilist = list->ilist;
  int** __restrict__ firstneigh = list->firstneigh;
  int* __restrict__ numneigh = list->numneigh;
  
  vec3_t* __restrict__ xx = (vec3_t*)x[0];
  vec3_t* __restrict__ ff = (vec3_t*)f[0];
@@ -79,7 +74,7 @@ void PairMorseOpt::eval()
  
  fast_alpha_t* __restrict__ fast_alpha = 
    (fast_alpha_t*) malloc(ntypes2*sizeof(fast_alpha_t));
  for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
  for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
    fast_alpha_t& a = fast_alpha[i*ntypes+j];
    a.cutsq = cutsq[i+1][j+1];
    a.r0 = r0[i+1][j+1];
@@ -92,13 +87,14 @@ void PairMorseOpt::eval()
  
  // loop over neighbors of my atoms
  
  for (int i = 0; i < nlocal; i++) {
  for (ii = 0; ii < inum; ii++) {
    i = ilist[ii];
    double xtmp = xx[i].x;
    double ytmp = xx[i].y;
    double ztmp = xx[i].z;
    int itype = type[i] - 1;
    int* __restrict__ neighs = firstneigh[i];
    int numneigh = num[i];
    itype = type[i] - 1;
    int* __restrict__ jlist = firstneigh[i];
    jnum = numneigh[i];
    
    double tmpfx = 0.0;
    double tmpfy = 0.0;
@@ -106,17 +102,17 @@ void PairMorseOpt::eval()
    
    fast_alpha_t* __restrict__ tabsixi = (fast_alpha_t*)&tabsix[itype*ntypes];
   
    for (int k = 0; k < numneigh; k++) {
      int j = neighs[k];
      
    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];
      double factor_lj;

      if (j < nall) {
	double delx = xtmp - xx[j].x;
	double dely = ytmp - xx[j].y;
	double delz = ztmp - xx[j].z;
	double rsq = delx*delx + dely*dely + delz*delz;
	
	int jtype = type[j] - 1;
	jtype = type[j] - 1;
	
	fast_alpha_t& a = tabsixi[jtype];
	if (rsq < a.cutsq) {
@@ -161,7 +157,7 @@ void PairMorseOpt::eval()
	double delz = ztmp - xx[j].z;
	double rsq = delx*delx + dely*dely + delz*delz;
	
	int jtype = type[j] - 1;
	jtype = type[j] - 1;
	
	fast_alpha_t& a = tabsixi[jtype];
	if (rsq < a.cutsq) {