Commit d3f31547 authored by Sebastian Hütter's avatar Sebastian Hütter
Browse files

Reformat code with clang-format (Mozilla style guide)

parent 7c7468ff
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
extern "C" {
#include "meam.h"

void meam_cleanup_(void) {
void
meam_cleanup_(void)
{

  deallocate(meam_data.phirar6);
  deallocate(meam_data.phirar5);
@@ -11,6 +13,5 @@ void meam_cleanup_(void) {
  deallocate(meam_data.phirar1);
  deallocate(meam_data.phirar);
  deallocate(meam_data.phir);

}
}
 No newline at end of file
+239 −212
Original line number Diff line number Diff line
@@ -2,8 +2,10 @@ extern "C"{
#include "meam.h"
#include <math.h>

      void G_gam(double Gamma, int ibar, double gsmooth_factor, double *G, int *errorflag);
      void dG_gam(double Gamma, int ibar, double gsmooth_factor,double *G, double *dG);
void G_gam(double Gamma, int ibar, double gsmooth_factor, double* G,
           int* errorflag);
void dG_gam(double Gamma, int ibar, double gsmooth_factor, double* G,
            double* dG);

// in meam_setup_done
void get_shpfcn(double* s /* s(3) */, lattice_t latt);
@@ -25,20 +27,23 @@ extern "C"{
//	     dgamma2,dgamma3,rho,rho0,rho1,rho2,rho3,frhop,&errorflag);
//

      void meam_dens_final_(int *nlocal, int *nmax,
           int *eflag_either, int *eflag_global, int *eflag_atom, double *eng_vdwl, double *eatom,
           int *ntype, int *type, int *fmap,
           double *Arho1, double *Arho2, double *Arho2b, double *Arho3, double *Arho3b, double *t_ave, double *tsq_ave,
           double *Gamma, double *dGamma1, double *dGamma2, double *dGamma3,
           double *rho, double *rho0, double *rho1, double *rho2, double *rho3, double *fp, int *errorflag)
void
meam_dens_final_(int* nlocal, int* nmax, int* eflag_either, int* eflag_global,
                 int* eflag_atom, double* eng_vdwl, double* eatom, int* ntype,
                 int* type, int* fmap, double* Arho1, double* Arho2,
                 double* Arho2b, double* Arho3, double* Arho3b, double* t_ave,
                 double* tsq_ave, double* Gamma, double* dGamma1,
                 double* dGamma2, double* dGamma3, double* rho, double* rho0,
                 double* rho1, double* rho2, double* rho3, double* fp,
                 int* errorflag)
{

      arrdim2v(Arho1,3,*nmax)
      arrdim2v(Arho2,6,*nmax)
      arrdim2v(Arho3,10,*nmax)
      arrdim2v(Arho3b,3,*nmax)
      arrdim2v(t_ave,3,*nmax)
      arrdim2v(tsq_ave,3,*nmax)
  arrdim2v(Arho1, 3, *nmax);
  arrdim2v(Arho2, 6, *nmax);
  arrdim2v(Arho3, 10, *nmax);
  arrdim2v(Arho3b, 3, *nmax);
  arrdim2v(t_ave, 3, *nmax);
  arrdim2v(tsq_ave, 3, *nmax);

  int i, elti;
  int m;
@@ -54,14 +59,20 @@ extern "C"{
      arr1v(rho2, i) = -1.0 / 3.0 * arr1v(Arho2b, i) * arr1v(Arho2b, i);
      arr1v(rho3, i) = 0.0;
      for (m = 1; m <= 3; m++) {
            arr1v(rho1,i) = arr1v(rho1,i) + arr2v(Arho1,m,i)*arr2v(Arho1,m,i);
            arr1v(rho3,i) = arr1v(rho3,i) - 3.0/5.0*arr2v(Arho3b,m,i)*arr2v(Arho3b,m,i);
        arr1v(rho1, i) =
          arr1v(rho1, i) + arr2v(Arho1, m, i) * arr2v(Arho1, m, i);
        arr1v(rho3, i) = arr1v(rho3, i) -
                         3.0 / 5.0 * arr2v(Arho3b, m, i) * arr2v(Arho3b, m, i);
      }
      for (m = 1; m <= 6; m++) {
            arr1v(rho2,i) = arr1v(rho2,i) + meam_data.v2D[m]*arr2v(Arho2,m,i)*arr2v(Arho2,m,i);
        arr1v(rho2, i) =
          arr1v(rho2, i) +
          meam_data.v2D[m] * arr2v(Arho2, m, i) * arr2v(Arho2, m, i);
      }
      for (m = 1; m <= 10; m++) {
            arr1v(rho3,i) = arr1v(rho3,i) + meam_data.v3D[m]*arr2v(Arho3,m,i)*arr2v(Arho3,m,i);
        arr1v(rho3, i) =
          arr1v(rho3, i) +
          meam_data.v3D[m] * arr2v(Arho3, m, i) * arr2v(Arho3, m, i);
      }

      if (arr1v(rho0, i) > 0.0) {
@@ -80,7 +91,9 @@ extern "C"{
        }
      }

          arr1v(Gamma,i) = arr2v(t_ave,1,i)*arr1v(rho1,i) + arr2v(t_ave,2,i)*arr1v(rho2,i) + arr2v(t_ave,3,i)*arr1v(rho3,i);
      arr1v(Gamma, i) = arr2v(t_ave, 1, i) * arr1v(rho1, i) +
                        arr2v(t_ave, 2, i) * arr1v(rho2, i) +
                        arr2v(t_ave, 3, i) * arr1v(rho3, i);

      if (arr1v(rho0, i) > 0.0) {
        arr1v(Gamma, i) = arr1v(Gamma, i) / (arr1v(rho0, i) * arr1v(rho0, i));
@@ -88,19 +101,27 @@ extern "C"{

      Z = meam_data.Z_meam[elti];

          G_gam(arr1v(Gamma,i),meam_data.ibar_meam[elti], meam_data.gsmooth_factor,&G,errorflag);
          if (*errorflag!=0) return;
      G_gam(arr1v(Gamma, i), meam_data.ibar_meam[elti],
            meam_data.gsmooth_factor, &G, errorflag);
      if (*errorflag != 0)
        return;
      get_shpfcn(shp, meam_data.lattce_meam[elti][elti]);
      if (meam_data.ibar_meam[elti] <= 0) {
        Gbar = 1.0;
        dGbar = 0.0;
      } else {
        if (meam_data.mix_ref_t == 1) {
              gam = (arr2v(t_ave,1,i)*shp[1]+arr2v(t_ave,2,i)*shp[2] +arr2v(t_ave,3,i)*shp[3])/(Z*Z);
          gam = (arr2v(t_ave, 1, i) * shp[1] + arr2v(t_ave, 2, i) * shp[2] +
                 arr2v(t_ave, 3, i) * shp[3]) /
                (Z * Z);
        } else {
              gam = (meam_data.t1_meam[elti]*shp[1]+meam_data.t2_meam[elti]*shp[2] +meam_data.t3_meam[elti]*shp[3])/(Z*Z);
          gam = (meam_data.t1_meam[elti] * shp[1] +
                 meam_data.t2_meam[elti] * shp[2] +
                 meam_data.t3_meam[elti] * shp[3]) /
                (Z * Z);
        }
            G_gam(gam,meam_data.ibar_meam[elti],meam_data.gsmooth_factor,&Gbar,errorflag);
        G_gam(gam, meam_data.ibar_meam[elti], meam_data.gsmooth_factor, &Gbar,
              errorflag);
      }
      arr1v(rho, i) = arr1v(rho0, i) * G;

@@ -109,8 +130,11 @@ extern "C"{
          Gbar = 1.0;
          dGbar = 0.0;
        } else {
              gam = (arr2v(t_ave,1,i)*shp[1]+arr2v(t_ave,2,i)*shp[2] +arr2v(t_ave,3,i)*shp[3])/(Z*Z);
              dG_gam(gam,meam_data.ibar_meam[elti],meam_data.gsmooth_factor, &Gbar,&dGbar);
          gam = (arr2v(t_ave, 1, i) * shp[1] + arr2v(t_ave, 2, i) * shp[2] +
                 arr2v(t_ave, 3, i) * shp[3]) /
                (Z * Z);
          dG_gam(gam, meam_data.ibar_meam[elti], meam_data.gsmooth_factor,
                 &Gbar, &dGbar);
        }
        rho_bkgd = meam_data.rho0_meam[elti] * Z * Gbar;
      } else {
@@ -123,7 +147,8 @@ extern "C"{
      rhob = arr1v(rho, i) / rho_bkgd;
      denom = 1.0 / rho_bkgd;

          dG_gam(arr1v(Gamma,i),meam_data.ibar_meam[elti],meam_data.gsmooth_factor,&G,&dG);
      dG_gam(arr1v(Gamma, i), meam_data.ibar_meam[elti],
             meam_data.gsmooth_factor, &G, &dG);

      arr1v(dGamma1, i) = (G - 2 * dG * arr1v(Gamma, i)) * denom;

@@ -175,12 +200,12 @@ extern "C"{
      }
    }
  }

}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void G_gam(double Gamma, int ibar, double gsmooth_factor, double *G, int *errorflag)
void
G_gam(double Gamma, int ibar, double gsmooth_factor, double* G, int* errorflag)
{
  //     Compute G(Gamma) based on selection flag ibar:
  //   0 => G = sqrt(1+Gamma)
@@ -197,7 +222,8 @@ extern "C"{
      //         e.g. gsmooth_factor is 99, {:
      //         gsmooth_switchpoint = -0.99
      //         G = 0.01*(-0.99/Gamma)**99
          *G = 1/(gsmooth_factor+1) * pow((gsmooth_switchpoint/Gamma),gsmooth_factor);
      *G = 1 / (gsmooth_factor + 1) *
           pow((gsmooth_switchpoint / Gamma), gsmooth_factor);
      *G = sqrt(*G);
    } else {
      *G = sqrt(1.0 + Gamma);
@@ -219,7 +245,8 @@ extern "C"{

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void dG_gam(double Gamma, int ibar, double gsmooth_factor,double *G, double *dG)
void
dG_gam(double Gamma, int ibar, double gsmooth_factor, double* G, double* dG)
{
  // Compute G(Gamma) and dG(gamma) based on selection flag ibar:
  //   0 => G = sqrt(1+Gamma)
@@ -236,7 +263,8 @@ extern "C"{
      //         e.g. gsmooth_factor is 99, {:
      //         gsmooth_switchpoint = -0.99
      //         G = 0.01*(-0.99/Gamma)**99
          *G = 1/(gsmooth_factor+1) * pow((gsmooth_switchpoint/Gamma), gsmooth_factor);
      *G = 1 / (gsmooth_factor + 1) *
           pow((gsmooth_switchpoint / Gamma), gsmooth_factor);
      *G = sqrt(*G);
      *dG = -gsmooth_factor * *G / (2.0 * Gamma);
    } else {
@@ -261,5 +289,4 @@ extern "C"{
}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

}
 No newline at end of file
+503 −463
Original line number Diff line number Diff line
@@ -2,25 +2,30 @@ extern "C" {
#include "meam.h"
#include <math.h>

      void getscreen(int i, int nmax, double *scrfcn, double *dscrfcn, double *fcpair, double *x,
          int numneigh, int *firstneigh,
          int numneigh_full, int *firstneigh_full,
          int ntype, int *type, int *fmap);
void getscreen(int i, int nmax, double* scrfcn, double* dscrfcn, double* fcpair,
               double* x, int numneigh, int* firstneigh, int numneigh_full,
               int* firstneigh_full, int ntype, int* type, int* fmap);
void calc_rho1(int i, int nmax, int ntype, int* type, int* fmap, double* x,
          int numneigh, int *firstneigh,
          double *scrfcn, double *fcpair, double *rho0, double *arho1, double *arho2, double *arho2b,
               int numneigh, int* firstneigh, double* scrfcn, double* fcpair,
               double* rho0, double* arho1, double* arho2, double* arho2b,
               double* arho3, double* arho3b, double* t_ave, double* tsq_ave);

      void screen(int i, int j, int nmax, double *x, double rijsq, double *sij, int numneigh_full, int *firstneigh_full, int ntype, int *type, int *fmap);
      void dsij(int i,int j,int k,int jn,int nmax,int numneigh,double rij2,double *dsij1,double *dsij2, int ntype, int *type, int *fmap,double *x,double *scrfcn, double*fcpair);
void screen(int i, int j, int nmax, double* x, double rijsq, double* sij,
            int numneigh_full, int* firstneigh_full, int ntype, int* type,
            int* fmap);
void dsij(int i, int j, int k, int jn, int nmax, int numneigh, double rij2,
          double* dsij1, double* dsij2, int ntype, int* type, int* fmap,
          double* x, double* scrfcn, double* fcpair);
void fcut(double xi, double* fc);
void dfcut(double xi, double* fc, double* dfc);
void dCfunc(double rij2, double rik2, double rjk2, double* dCikj);
      void dCfunc2(double rij2,double rik2,double rjk2,double *dCikj1,double *dCikj2);
void dCfunc2(double rij2, double rik2, double rjk2, double* dCikj1,
             double* dCikj2);

//     Extern "C" declaration has the form:
//
//  void meam_dens_init_(int *, int *, int *, double *, int *, int *, int *, double *,
//  void meam_dens_init_(int *, int *, int *, double *, int *, int *, int *,
//  double *,
//		 int *, int *, int *, int *,
//		 double *, double *, double *, double *, double *, double *,
//		 double *, double *, double *, double *, double *, int *);
@@ -35,38 +40,34 @@ extern "C" {
//	       &arho3[0][0],&arho3b[0][0],&t_ave[0][0],&tsq_ave[0][0],&errorflag);
//

      void meam_dens_init_(int *i, int *nmax,
          int *ntype, int *type, int *fmap, double *x,
          int *numneigh, int *firstneigh,
          int *numneigh_full, int *firstneigh_full,
          double *scrfcn, double *dscrfcn, double *fcpair, double *rho0, double *arho1, double *arho2, double *arho2b,
          double *arho3, double *arho3b, double *t_ave, double *tsq_ave, int *errorflag)
void
meam_dens_init_(int* i, int* nmax, int* ntype, int* type, int* fmap, double* x,
                int* numneigh, int* firstneigh, int* numneigh_full,
                int* firstneigh_full, double* scrfcn, double* dscrfcn,
                double* fcpair, double* rho0, double* arho1, double* arho2,
                double* arho2b, double* arho3, double* arho3b, double* t_ave,
                double* tsq_ave, int* errorflag)
{
  *errorflag = 0;

  //     Compute screening function and derivatives
      getscreen(*i, *nmax, scrfcn, dscrfcn, fcpair, x,
          *numneigh, firstneigh,
          *numneigh_full, firstneigh_full,
          *ntype, type, fmap);
  getscreen(*i, *nmax, scrfcn, dscrfcn, fcpair, x, *numneigh, firstneigh,
            *numneigh_full, firstneigh_full, *ntype, type, fmap);

  //     Calculate intermediate density terms to be communicated
      calc_rho1(*i, *nmax, *ntype, type, fmap, x,
          *numneigh, firstneigh,
          scrfcn, fcpair, rho0, arho1, arho2, arho2b,
          arho3, arho3b, t_ave, tsq_ave);

  calc_rho1(*i, *nmax, *ntype, type, fmap, x, *numneigh, firstneigh, scrfcn,
            fcpair, rho0, arho1, arho2, arho2b, arho3, arho3b, t_ave, tsq_ave);
}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void getscreen(int i, int nmax, double *scrfcn, double *dscrfcn, double *fcpair, double *x,
          int numneigh, int *firstneigh,
          int numneigh_full, int *firstneigh_full,
          int ntype, int *type, int *fmap)
void
getscreen(int i, int nmax, double* scrfcn, double* dscrfcn, double* fcpair,
          double* x, int numneigh, int* firstneigh, int numneigh_full,
          int* firstneigh_full, int ntype, int* type, int* fmap)
{

        arrdim2v(x,3,nmax)
  arrdim2v(x, 3, nmax);

  int jn, j, kn, k;
  int elti, eltj, eltk;
@@ -110,7 +111,8 @@ extern "C" {
          sij = 0.0;
        } else {
          rnorm = (meam_data.rc_meam - rij) * drinv;
              screen(i, j, nmax, x, rij2, &sij, numneigh_full, firstneigh_full, ntype, type, fmap);
          screen(i, j, nmax, x, rij2, &sij, numneigh_full, firstneigh_full,
                 ntype, type, fmap);
          dfcut(rnorm, &fc, &dfc);
          fcij = fc;
          dfcij = dfc * drinv;
@@ -119,13 +121,16 @@ extern "C" {
        //     Now compute derivatives
        arr1v(dscrfcn, jn) = 0.0;
        sfcij = sij * fcij;
            if (iszero(sfcij) || iszero(sfcij-1.0)) goto LABEL_100;
        if (iszero(sfcij) || iszero(sfcij - 1.0))
          goto LABEL_100;
        rbound = meam_data.ebound_meam[elti][eltj] * rij2;
        for (kn = 1; kn <= numneigh_full; kn++) {
          k = arr1v(firstneigh_full, kn);
              if (k==j) continue;
          if (k == j)
            continue;
          eltk = arr1v(fmap, arr1v(type, k));
              if (eltk==0) continue;
          if (eltk == 0)
            continue;
          xktmp = arr2v(x, 1, k);
          yktmp = arr2v(x, 2, k);
          zktmp = arr2v(x, 3, k);
@@ -133,27 +138,33 @@ extern "C" {
          delyjk = yktmp - yjtmp;
          delzjk = zktmp - zjtmp;
          rjk2 = delxjk * delxjk + delyjk * delyjk + delzjk * delzjk;
              if (rjk2 > rbound) continue;
          if (rjk2 > rbound)
            continue;
          delxik = xktmp - xitmp;
          delyik = yktmp - yitmp;
          delzik = zktmp - zitmp;
          rik2 = delxik * delxik + delyik * delyik + delzik * delzik;
              if (rik2 > rbound) continue;
          if (rik2 > rbound)
            continue;
          xik = rik2 / rij2;
          xjk = rjk2 / rij2;
          a = 1 - (xik - xjk) * (xik - xjk);
          //     if a < 0, then ellipse equation doesn't describe this case and
          //     atom k can't possibly screen i-j
              if (a<=0.0) continue;
          if (a <= 0.0)
            continue;
          cikj = (2.0 * (xik + xjk) + a - 2.0) / a;
          Cmax = meam_data.Cmax_meam[elti][eltj][eltk];
          Cmin = meam_data.Cmin_meam[elti][eltj][eltk];
          if (cikj >= Cmax) {
            continue;
            //     Note that cikj may be slightly negative (within numerical
//     tolerance) if atoms are colinear, so don't reject that case here
//     (other negative cikj cases were handled by the test on "a" above)
//     Note that we never have 0<cikj<Cmin here, else sij=0 (rejected above)
            //     tolerance) if atoms are colinear, so don't reject that case
            //     here
            //     (other negative cikj cases were handled by the test on "a"
            //     above)
            //     Note that we never have 0<cikj<Cmin here, else sij=0
            //     (rejected above)
          } else {
            delc = Cmax - Cmin;
            cikj = (cikj - Cmin) / delc;
@@ -170,29 +181,26 @@ extern "C" {
      LABEL_100:
        arr1v(scrfcn, jn) = sij;
        arr1v(fcpair, jn) = fcij;

      }

    }

  }
}


// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void calc_rho1(int i, int nmax, int ntype, int *type, int *fmap, double *x,
          int numneigh, int *firstneigh,
          double *scrfcn, double *fcpair, double *rho0, double *arho1, double *arho2, double *arho2b,
void
calc_rho1(int i, int nmax, int ntype, int* type, int* fmap, double* x,
          int numneigh, int* firstneigh, double* scrfcn, double* fcpair,
          double* rho0, double* arho1, double* arho2, double* arho2b,
          double* arho3, double* arho3b, double* t_ave, double* tsq_ave)
{
        arrdim2v(x,3,nmax)
        arrdim2v(arho1,3,nmax)
        arrdim2v(arho2,6,nmax)
        arrdim2v(arho3,10,nmax)
        arrdim2v(arho3b,3,nmax)
        arrdim2v(t_ave,3,nmax)
        arrdim2v(tsq_ave,3,nmax)
  arrdim2v(x, 3, nmax);
  arrdim2v(arho1, 3, nmax);
  arrdim2v(arho2, 6, nmax);
  arrdim2v(arho3, 10, nmax);
  arrdim2v(arho3b, 3, nmax);
  arrdim2v(t_ave, 3, nmax);
  arrdim2v(tsq_ave, 3, nmax);

  int jn, j, m, n, p, elti, eltj;
  int nv2, nv3;
@@ -241,20 +249,38 @@ extern "C" {
        arr1v(rho0, j) = arr1v(rho0, j) + rhoa0i;
        // For ialloy = 2, use single-element value (not average)
        if (meam_data.ialloy != 2) {
              arr2v(t_ave,1,i) = arr2v(t_ave,1,i) + meam_data.t1_meam[eltj]*rhoa0j;
              arr2v(t_ave,2,i) = arr2v(t_ave,2,i) + meam_data.t2_meam[eltj]*rhoa0j;
              arr2v(t_ave,3,i) = arr2v(t_ave,3,i) + meam_data.t3_meam[eltj]*rhoa0j;
              arr2v(t_ave,1,j) = arr2v(t_ave,1,j) + meam_data.t1_meam[elti]*rhoa0i;
              arr2v(t_ave,2,j) = arr2v(t_ave,2,j) + meam_data.t2_meam[elti]*rhoa0i;
              arr2v(t_ave,3,j) = arr2v(t_ave,3,j) + meam_data.t3_meam[elti]*rhoa0i;
          arr2v(t_ave, 1, i) =
            arr2v(t_ave, 1, i) + meam_data.t1_meam[eltj] * rhoa0j;
          arr2v(t_ave, 2, i) =
            arr2v(t_ave, 2, i) + meam_data.t2_meam[eltj] * rhoa0j;
          arr2v(t_ave, 3, i) =
            arr2v(t_ave, 3, i) + meam_data.t3_meam[eltj] * rhoa0j;
          arr2v(t_ave, 1, j) =
            arr2v(t_ave, 1, j) + meam_data.t1_meam[elti] * rhoa0i;
          arr2v(t_ave, 2, j) =
            arr2v(t_ave, 2, j) + meam_data.t2_meam[elti] * rhoa0i;
          arr2v(t_ave, 3, j) =
            arr2v(t_ave, 3, j) + meam_data.t3_meam[elti] * rhoa0i;
        }
        if (meam_data.ialloy == 1) {
              arr2v(tsq_ave,1,i) = arr2v(tsq_ave,1,i) + meam_data.t1_meam[eltj]*meam_data.t1_meam[eltj]*rhoa0j;
              arr2v(tsq_ave,2,i) = arr2v(tsq_ave,2,i) + meam_data.t2_meam[eltj]*meam_data.t2_meam[eltj]*rhoa0j;
              arr2v(tsq_ave,3,i) = arr2v(tsq_ave,3,i) + meam_data.t3_meam[eltj]*meam_data.t3_meam[eltj]*rhoa0j;
              arr2v(tsq_ave,1,j) = arr2v(tsq_ave,1,j) + meam_data.t1_meam[elti]*meam_data.t1_meam[elti]*rhoa0i;
              arr2v(tsq_ave,2,j) = arr2v(tsq_ave,2,j) + meam_data.t2_meam[elti]*meam_data.t2_meam[elti]*rhoa0i;
              arr2v(tsq_ave,3,j) = arr2v(tsq_ave,3,j) + meam_data.t3_meam[elti]*meam_data.t3_meam[elti]*rhoa0i;
          arr2v(tsq_ave, 1, i) =
            arr2v(tsq_ave, 1, i) +
            meam_data.t1_meam[eltj] * meam_data.t1_meam[eltj] * rhoa0j;
          arr2v(tsq_ave, 2, i) =
            arr2v(tsq_ave, 2, i) +
            meam_data.t2_meam[eltj] * meam_data.t2_meam[eltj] * rhoa0j;
          arr2v(tsq_ave, 3, i) =
            arr2v(tsq_ave, 3, i) +
            meam_data.t3_meam[eltj] * meam_data.t3_meam[eltj] * rhoa0j;
          arr2v(tsq_ave, 1, j) =
            arr2v(tsq_ave, 1, j) +
            meam_data.t1_meam[elti] * meam_data.t1_meam[elti] * rhoa0i;
          arr2v(tsq_ave, 2, j) =
            arr2v(tsq_ave, 2, j) +
            meam_data.t2_meam[elti] * meam_data.t2_meam[elti] * rhoa0i;
          arr2v(tsq_ave, 3, j) =
            arr2v(tsq_ave, 3, j) +
            meam_data.t3_meam[elti] * meam_data.t3_meam[elti] * rhoa0i;
        }
        arr1v(arho2b, i) = arr1v(arho2b, i) + rhoa2j;
        arr1v(arho2b, j) = arr1v(arho2b, j) + rhoa2i;
@@ -273,12 +299,16 @@ extern "C" {
          arr2v(arho3b, m, i) = arr2v(arho3b, m, i) + rhoa3j * delij[m] / rij;
          arr2v(arho3b, m, j) = arr2v(arho3b, m, j) - rhoa3i * delij[m] / rij;
          for (n = m; n <= 3; n++) {
                arr2v(arho2,nv2,i) = arr2v(arho2,nv2,i) + A2j*delij[m]*delij[n];
                arr2v(arho2,nv2,j) = arr2v(arho2,nv2,j) + A2i*delij[m]*delij[n];
            arr2v(arho2, nv2, i) =
              arr2v(arho2, nv2, i) + A2j * delij[m] * delij[n];
            arr2v(arho2, nv2, j) =
              arr2v(arho2, nv2, j) + A2i * delij[m] * delij[n];
            nv2 = nv2 + 1;
            for (p = n; p <= 3; p++) {
                  arr2v(arho3,nv3,i) = arr2v(arho3,nv3,i) + A3j*delij[m]*delij[n]*delij[p];
                  arr2v(arho3,nv3,j) = arr2v(arho3,nv3,j) - A3i*delij[m]*delij[n]*delij[p];
              arr2v(arho3, nv3, i) =
                arr2v(arho3, nv3, i) + A3j * delij[m] * delij[n] * delij[p];
              arr2v(arho3, nv3, j) =
                arr2v(arho3, nv3, j) - A3i * delij[m] * delij[n] * delij[p];
              nv3 = nv3 + 1;
            }
          }
@@ -286,12 +316,13 @@ extern "C" {
      }
    }
  }

}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void screen(int i, int j, int nmax, double *x, double rijsq, double *sij, int numneigh_full, int *firstneigh_full, int ntype, int *type, int *fmap)
void
screen(int i, int j, int nmax, double* x, double rijsq, double* sij,
       int numneigh_full, int* firstneigh_full, int ntype, int* type, int* fmap)
//     Screening function
//     Inputs:  i = atom 1 id (integer)
//     j = atom 2 id (integer)
@@ -301,7 +332,8 @@ extern "C" {

  arrdim2v(x, 3, nmax)

      int k,nk/*,m*/;
    int k,
    nk /*,m*/;
  int elti, eltj, eltk;
  double delxik, delyik, delzik;
  double delxjk, delyjk, delzjk;
@@ -318,23 +350,27 @@ extern "C" {
  for (nk = 1; nk <= numneigh_full; nk++) {
    k = arr1v(firstneigh_full, nk);
    eltk = arr1v(fmap, arr1v(type, k));
        if (k==j) continue;
    if (k == j)
      continue;
    delxjk = arr2v(x, 1, k) - arr2v(x, 1, j);
    delyjk = arr2v(x, 2, k) - arr2v(x, 2, j);
    delzjk = arr2v(x, 3, k) - arr2v(x, 3, j);
    rjksq = delxjk * delxjk + delyjk * delyjk + delzjk * delzjk;
        if (rjksq > rbound) continue;
    if (rjksq > rbound)
      continue;
    delxik = arr2v(x, 1, k) - arr2v(x, 1, i);
    delyik = arr2v(x, 2, k) - arr2v(x, 2, i);
    delzik = arr2v(x, 3, k) - arr2v(x, 3, i);
    riksq = delxik * delxik + delyik * delyik + delzik * delzik;
        if (riksq > rbound) continue;
    if (riksq > rbound)
      continue;
    xik = riksq / rijsq;
    xjk = rjksq / rijsq;
    a = 1 - (xik - xjk) * (xik - xjk);
    //     if a < 0, then ellipse equation doesn't describe this case and
    //     atom k can't possibly screen i-j
        if (a<=0.0) continue;
    if (a <= 0.0)
      continue;
    cikj = (2.0 * (xik + xjk) + a - 2.0) / a;
    Cmax = meam_data.Cmax_meam[elti][eltj][eltk];
    Cmin = meam_data.Cmin_meam[elti][eltj][eltk];
@@ -353,12 +389,14 @@ extern "C" {
    }
    *sij = *sij * sikj;
  }

}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void dsij(int i,int j,int k,int jn,int nmax,int numneigh,double rij2,double *dsij1,double *dsij2, int ntype, int *type, int *fmap,double *x,double *scrfcn, double*fcpair)
void
dsij(int i, int j, int k, int jn, int nmax, int numneigh, double rij2,
     double* dsij1, double* dsij2, int ntype, int* type, int* fmap, double* x,
     double* scrfcn, double* fcpair)
{
  //     Inputs: i,j,k = id's of 3 atom triplet
  //     jn = id of i-j pair
@@ -366,8 +404,7 @@ extern "C" {
  //     Outputs: dsij1 = deriv. of sij w.r.t. rik
  //     dsij2 = deriv. of sij w.r.t. rjk

        arrdim2v(x,3,nmax)
      int elti,eltj,eltk;
  arrdim2v(x, 3, nmax) int elti, eltj, eltk;
  double rik2, rjk2;

  double dxik, dyik, dzik;
@@ -416,10 +453,10 @@ extern "C" {
  }
}


// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void fcut(double xi, double * fc)
void
fcut(double xi, double* fc)
{
  //     cutoff function
  double a;
@@ -439,7 +476,8 @@ extern "C" {

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void dfcut(double xi, double *fc, double *dfc)
void
dfcut(double xi, double* fc, double* dfc)
{
  //     cutoff function and its derivative
  double a, a3, a4;
@@ -462,7 +500,8 @@ extern "C" {

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void dCfunc(double rij2,double rik2,double rjk2,double *dCikj)
void
dCfunc(double rij2, double rik2, double rjk2, double* dCikj)
{
  //     Inputs: rij,rij2,rik2,rjk2
  //     Outputs: dCikj = derivative of Cikj w.r.t. rij
@@ -478,7 +517,8 @@ extern "C" {

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      void dCfunc2(double rij2,double rik2,double rjk2,double *dCikj1,double *dCikj2)
void
dCfunc2(double rij2, double rik2, double rjk2, double* dCikj1, double* dCikj2)
{
  //     Inputs: rij,rij2,rik2,rjk2
  //     Outputs: dCikj1 = derivative of Cikj w.r.t. rik
@@ -492,13 +532,13 @@ extern "C" {
  b = rik2 + rjk2;
  denom = rij4 - a * a;
  denom = denom * denom;
      *dCikj1 = 4*rij2*(rij4 + rik4 + 2*rik2*rjk2 - 3*rjk4 - 2*rij2*a)/ denom;
      *dCikj2 = 4*rij2*(rij4 - 3*rik4 + 2*rik2*rjk2 + rjk4 + 2*rij2*a)/ denom;
  *dCikj1 = 4 * rij2 *
            (rij4 + rik4 + 2 * rik2 * rjk2 - 3 * rjk4 - 2 * rij2 * a) / denom;
  *dCikj2 = 4 * rij2 *
            (rij4 - 3 * rik4 + 2 * rik2 * rjk2 + rjk4 + 2 * rij2 * a) / denom;

  (void)(b);
}

// ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc


}
 No newline at end of file
+555 −504

File changed.

Preview size limit exceeded, changes collapsed.

+985 −849

File changed.

Preview size limit exceeded, changes collapsed.

Loading