From a6bfcf838ab6ce0e1bb06f6f88ee78ae7e0daf6a Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 8 Jul 2022 15:43:06 -0600 Subject: [PATCH 01/43] First attempt --- src/MEAM/meam.h | 16 +++ src/MEAM/meam_force.cpp | 312 +++++++++++++++++++++++++++++++--------- 2 files changed, 257 insertions(+), 71 deletions(-) diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index 8a2f43e354..0f14b7db5a 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -74,6 +74,12 @@ class MEAM { // vind[23]D = Voight notation index maps for 2 and 3D // v2D,v3D = array of factors to apply for Voight notation + // MS-MEAM parameters + + // msmeamflag = flag to activate MS-MEAM + // betam[1-3]_meam = MS-MEAM electron density constants + // tm[1-3]_meam = MS-MEAM coefficients on densities in Gamma computation + // nr,dr = pair function discretization parameters // nrar,rdrar = spline coeff array parameters @@ -115,12 +121,22 @@ class MEAM { int nr, nrar; double dr, rdrar; + // MS-MEAM parameters + + double t1m_meam[maxelt], t2m_meam[maxelt], t3m_meam[maxelt]; + double beta1m_meam[maxelt], beta2m_meam[maxelt], beta3m_meam[maxelt]; + int msmeamflag; + public: int nmax; double *rho, *rho0, *rho1, *rho2, *rho3, *frhop; double *gamma, *dgamma1, *dgamma2, *dgamma3, *arho2b; double **arho1, **arho2, **arho3, **arho3b, **t_ave, **tsq_ave; + // MS-MEAM arrays + + double **arho1m, **arho2m, *arho2mb, **arho3m, **arho3mb; + int maxneigh; double *scrfcn, *dscrfcn, *fcpair; diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 88b6140f80..26ccf110c8 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -61,6 +61,17 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double t1i, t2i, t3i, t1j, t2j, t3j; double scaleij; + double rhoa1mj,drhoa1mj,rhoa1mi,drhoa1mi; + double rhoa2mj,drhoa2mj,rhoa2mi,drhoa2mi; + double a3m, a3ma, b3m, rhoa3mj, drhoa3mj, rhoa3mi, drhoa3mi; + double arg1i1m, arg1j1m, arg1i2m, arg1j2m, arg1i3m, arg1j3m, arg3i3m, arg3j3m; + double drho1mdr1, drho1mdr2, drho1mds1, drho1mds2; + double drho1mdrm1[3], drho1mdrm2[3]; + double drho2mdr1, drho2mdr2, drho2mds1, drho2mds2; + double drho2mdrm1[3], drho2mdrm2[3]; + double drho3mdr1, drho3mdr2, drho3mds1, drho3mds2; + double drho3mdrm1[3], drho3mdrm2[3]; + third = 1.0 / 3.0; sixth = 1.0 / 6.0; @@ -138,6 +149,15 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhoa2j = -this->beta2_meam[eltj] * invrej * rhoa2j; rhoa3j = ro0j * MathSpecial::fm_exp(-this->beta3_meam[eltj] * aj); drhoa3j = -this->beta3_meam[eltj] * invrej * rhoa3j; + + if (this->msmeamflag) { + rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecial::fm_exp(-this->beta1m_meam[eltj] * aj); + drhoa1mj = -this->beta1m_meam[eltj] * invrej * rhoa1mj; + rhoa2mj = ro0j * t2m_meam[eltj] * MathSpecial::fm_exp(-this->beta2m_meam[eltj] * aj); + drhoa2mj = -this->beta2m_meam[eltj] * invrej * rhoa2mj; + rhoa3mj = ro0j * t3m_meam[eltj] * MathSpecial::fm_exp(-this->beta3m_meam[eltj] * aj); + drhoa3mj = -this->beta3m_meam[eltj] * invrej * rhoa3mj; + } } else { rhoa0j = rhoa0i; drhoa0j = drhoa0i; @@ -147,7 +167,16 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhoa2j = drhoa2i; rhoa3j = rhoa3i; drhoa3j = drhoa3i; - } + + if (this->msmeamflag) { + rhoa1mj = rhoa1mi; + drhoa1mj = drhoa1mi; + rhoa2mj = rhoa2mi; + drhoa2mj = drhoa2mi; + rhoa3mj = rhoa3mi; + drhoa3mj = drhoa3mi; + } + } const double t1mi = this->t1_meam[elti]; const double t2mi = this->t2_meam[elti]; @@ -200,6 +229,36 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int arg3j3 = arg3j3 - arho3b[j][n] * delij[n]; } + // arhom args + arg1i1m = 0.0; + arg1j1m = 0.0; + arg1i2m = 0.0; + arg1j2m = 0.0; + arg1i3m = 0.0; + arg1j3m = 0.0; + arg3i3m = 0.0; + arg3j3m = 0.0; + if (this->msmeamflag) { + for (n = 0; n < 3; n++) { + for (p = n; p < 3; p++) { + for (q = p; q < 3; q++) { + arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; + arg1i3m = arg1i3m + arho3m[i][nv3] * arg; + arg1j3m = arg1j3m - arho3m[j][nv3] * arg; + nv3 = nv3 + 1; + } + arg = delij[n] * delij[p] * this->v2D[nv2]; + arg1i2m = arg1i2m + arho2m[i][nv2] * arg; + arg1j2m = arg1j2m + arho2m[j][nv2] * arg; + nv2 = nv2 + 1; + } + arg1i1m = arg1i1m + arho1m[i][n] * delij[n]; + arg1j1m = arg1j1m - arho1m[j][n] * delij[n]; + arg3i3m = arg3i3m + arho3mb[i][n] * delij[n]; + arg3j3m = arg3j3m - arho3mb[j][n] * delij[n]; + } + } + // rho0 terms drho0dr1 = drhoa0j * sij; drho0dr2 = drhoa0i * sij; @@ -214,21 +273,21 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho1drm2[m] = -a1 * rhoa1i * arho1[j][m]; } - // rho2 terms - a2 = 2 * sij / rij2; - drho2dr1 = a2 * (drhoa2j - 2 * rhoa2j / rij) * arg1i2 - 2.0 / 3.0 * arho2b[i] * drhoa2j * sij; - drho2dr2 = a2 * (drhoa2i - 2 * rhoa2i / rij) * arg1j2 - 2.0 / 3.0 * arho2b[j] * drhoa2i * sij; - a2 = 4 * sij / rij2; - for (m = 0; m < 3; m++) { - drho2drm1[m] = 0.0; - drho2drm2[m] = 0.0; - for (n = 0; n < 3; n++) { - drho2drm1[m] = drho2drm1[m] + arho2[i][this->vind2D[m][n]] * delij[n]; - drho2drm2[m] = drho2drm2[m] - arho2[j][this->vind2D[m][n]] * delij[n]; - } - drho2drm1[m] = a2 * rhoa2j * drho2drm1[m]; - drho2drm2[m] = -a2 * rhoa2i * drho2drm2[m]; - } + // rho2 terms + a2 = 2 * sij / rij2; + drho2dr1 = a2 * (drhoa2j - 2 * rhoa2j / rij) * arg1i2 - 2.0 / 3.0 * arho2b[i] * drhoa2j * sij; + drho2dr2 = a2 * (drhoa2i - 2 * rhoa2i / rij) * arg1j2 - 2.0 / 3.0 * arho2b[j] * drhoa2i * sij; + a2 = 4 * sij / rij2; + for (m = 0; m < 3; m++) { + drho2drm1[m] = 0.0; + drho2drm2[m] = 0.0; + for (n = 0; n < 3; n++) { + drho2drm1[m] = drho2drm1[m] + arho2[i][this->vind2D[m][n]] * delij[n]; + drho2drm2[m] = drho2drm2[m] - arho2[j][this->vind2D[m][n]] * delij[n]; + } + drho2drm1[m] = a2 * rhoa2j * drho2drm1[m]; + drho2drm2[m] = -a2 * rhoa2i * drho2drm2[m]; + } // rho3 terms rij3 = rij * rij2; @@ -254,73 +313,163 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3drm2[m] = (-a3 * drho3drm2[m] + a3a * arho3b[j][m]) * rhoa3i; } - // Compute derivatives of weighting functions t wrt rij - t1i = t_ave[i][0]; - t2i = t_ave[i][1]; - t3i = t_ave[i][2]; - t1j = t_ave[j][0]; - t2j = t_ave[j][1]; - t3j = t_ave[j][2]; + if (this->msmeamflag) { + // rho1m terms + a1 = 2 * sij / rij; + drho1mdr1 = a1 * (drhoa1mj - rhoa1mj / rij) * arg1i1m; + drho1mdr2 = a1 * (drhoa1mi - rhoa1mi / rij) * arg1j1m; + drho1mdr1 *= -1.0; + drho1mdr2 *= -1.0; + a1 = 2.0 * sij / rij; + for (m = 0; m < 3; m++) { + drho1mdrm1[m] = a1 * rhoa1mj * arho1m[i][m]; + drho1mdrm2[m] = -a1 * rhoa1mi * arho1m[j][m]; + } - if (this->ialloy == 1) { + // rho2m terms + a2 = 2 * sij / rij2; + drho2mdr1 = a2 * (drhoa2mj - 2 * rhoa2mj / rij) * arg1i2m - 2.0 / 3.0 * arho2mb[i] * drhoa2mj * sij; + drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - 2.0 / 3.0 * arho2mb[j] * drhoa2mi * sij; + a2 = 4 * sij / rij2; + for (m = 0; m < 3; m++) { + drho2mdrm1[m] = 0.0; + drho2mdrm2[m] = 0.0; + for (n = 0; n < 3; n++) { + drho2mdrm1[m] = drho2mdrm1[m] + arho2m[i][this->vind2D[m][n]] * delij[n]; + drho2mdrm2[m] = drho2mdrm2[m] - arho2m[j][this->vind2D[m][n]] * delij[n]; + } + drho2mdrm1[m] = a2 * rhoa2mj * drho2mdrm1[m]; + drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; + } - a1i = fdiv_zero(drhoa0j * sij, tsq_ave[i][0]); - a1j = fdiv_zero(drhoa0i * sij, tsq_ave[j][0]); - a2i = fdiv_zero(drhoa0j * sij, tsq_ave[i][1]); - a2j = fdiv_zero(drhoa0i * sij, tsq_ave[j][1]); - a3i = fdiv_zero(drhoa0j * sij, tsq_ave[i][2]); - a3j = fdiv_zero(drhoa0i * sij, tsq_ave[j][2]); + // rho3m terms + rij3 = rij * rij2; + a3 = 2 * sij / rij3; + a3a = 6.0 / 5.0 * sij / rij; + drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; + drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; + drho3mdr1 *= -1.0; + drho3mdr2 *= -1.0; + a3 = 6 * sij / rij3; + a3a = 6 * sij / (5 * rij); + for (m = 0; m < 3; m++) { + drho3mdrm1[m] = 0.0; + drho3mdrm2[m] = 0.0; + nv2 = 0; + for (n = 0; n < 3; n++) { + for (p = n; p < 3; p++) { + arg = delij[n] * delij[p] * this->v2D[nv2]; + drho3mdrm1[m] = drho3mdrm1[m] + arho3m[i][this->vind3D[m][n][p]] * arg; + drho3mdrm2[m] = drho3mdrm2[m] + arho3m[j][this->vind3D[m][n][p]] * arg; + nv2 = nv2 + 1; + } + } + drho3mdrm1[m] = (a3 * drho3mdrm1[m] - a3a * arho3mb[i][m]) * rhoa3mj; + drho3mdrm2[m] = (-a3 * drho3mdrm2[m] + a3a * arho3mb[j][m]) * rhoa3mi; + } + } else { + drho1mdrm1[m] = 0.0; + drho1mdrm2[m] = 0.0; + drho2mdrm1[m] = 0.0; + drho2mdrm2[m] = 0.0; + drho3mdrm1[m] = 0.0; + drho3mdrm2[m] = 0.0; + } + + // compute derivatives of weighting functions t wrt rij + // weighting functions t set to unity for MS-MEAM + + if (this->msmeamflag) { - dt1dr1 = a1i * (t1mj - t1i * MathSpecial::square(t1mj)); - dt1dr2 = a1j * (t1mi - t1j * MathSpecial::square(t1mi)); - dt2dr1 = a2i * (t2mj - t2i * MathSpecial::square(t2mj)); - dt2dr2 = a2j * (t2mi - t2j * MathSpecial::square(t2mi)); - dt3dr1 = a3i * (t3mj - t3i * MathSpecial::square(t3mj)); - dt3dr2 = a3j * (t3mi - t3j * MathSpecial::square(t3mi)); + t1i = 1.0; + t2i = 1.0; + t3i = 1.0; + t1j = 1.0; + t2j = 1.0; + t3j = 1.0; + dt1dr1 = 0.0; + dt1dr2 = 0.0; + dt2dr1 = 0.0; + dt2dr2 = 0.0; + dt3dr1 = 0.0; + dt3dr2 = 0.0; - } else if (this->ialloy == 2) { + } else { - dt1dr1 = 0.0; - dt1dr2 = 0.0; - dt2dr1 = 0.0; - dt2dr2 = 0.0; - dt3dr1 = 0.0; - dt3dr2 = 0.0; + t1i = t_ave[i][0]; + t2i = t_ave[i][1]; + t3i = t_ave[i][2]; + t1j = t_ave[j][0]; + t2j = t_ave[j][1]; + t3j = t_ave[j][2]; - } else { + if (this->ialloy == 1) { - ai = 0.0; - if (!iszero(rho0[i])) - ai = drhoa0j * sij / rho0[i]; - aj = 0.0; - if (!iszero(rho0[j])) - aj = drhoa0i * sij / rho0[j]; + a1i = fdiv_zero(drhoa0j * sij, tsq_ave[i][0]); + a1j = fdiv_zero(drhoa0i * sij, tsq_ave[j][0]); + a2i = fdiv_zero(drhoa0j * sij, tsq_ave[i][1]); + a2j = fdiv_zero(drhoa0i * sij, tsq_ave[j][1]); + a3i = fdiv_zero(drhoa0j * sij, tsq_ave[i][2]); + a3j = fdiv_zero(drhoa0i * sij, tsq_ave[j][2]); - dt1dr1 = ai * (t1mj - t1i); - dt1dr2 = aj * (t1mi - t1j); - dt2dr1 = ai * (t2mj - t2i); - dt2dr2 = aj * (t2mi - t2j); - dt3dr1 = ai * (t3mj - t3i); - dt3dr2 = aj * (t3mi - t3j); - } + dt1dr1 = a1i * (t1mj - t1i * MathSpecial::square(t1mj)); + dt1dr2 = a1j * (t1mi - t1j * MathSpecial::square(t1mi)); + dt2dr1 = a2i * (t2mj - t2i * MathSpecial::square(t2mj)); + dt2dr2 = a2j * (t2mi - t2j * MathSpecial::square(t2mi)); + dt3dr1 = a3i * (t3mj - t3i * MathSpecial::square(t3mj)); + dt3dr2 = a3j * (t3mi - t3j * MathSpecial::square(t3mi)); + + } else if (this->ialloy == 2) { + + dt1dr1 = 0.0; + dt1dr2 = 0.0; + dt2dr1 = 0.0; + dt2dr2 = 0.0; + dt3dr1 = 0.0; + dt3dr2 = 0.0; + + } else { + + ai = 0.0; + if (!iszero(rho0[i])) + ai = drhoa0j * sij / rho0[i]; + aj = 0.0; + if (!iszero(rho0[j])) + aj = drhoa0i * sij / rho0[j]; + + dt1dr1 = ai * (t1mj - t1i); + dt1dr2 = aj * (t1mi - t1j); + dt2dr1 = ai * (t2mj - t2i); + dt2dr2 = aj * (t2mi - t2j); + dt3dr1 = ai * (t3mj - t3i); + dt3dr2 = aj * (t3mi - t3j); + } + + } // Compute derivatives of total density wrt rij, sij and rij(3) get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpi); get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); drhodr1 = dgamma1[i] * drho0dr1 + - dgamma2[i] * (dt1dr1 * rho1[i] + t1i * drho1dr1 + dt2dr1 * rho2[i] + t2i * drho2dr1 + - dt3dr1 * rho3[i] + t3i * drho3dr1) - + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + + dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); drhodr2 = dgamma1[j] * drho0dr2 + - dgamma2[j] * (dt1dr2 * rho1[j] + t1j * drho1dr2 + dt2dr2 * rho2[j] + t2j * drho2dr2 + - dt3dr2 * rho3[j] + t3j * drho3dr2) - + dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + + dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); for (m = 0; m < 3; m++) { drhodrm1[m] = 0.0; drhodrm2[m] = 0.0; - drhodrm1[m] = dgamma2[i] * (t1i * drho1drm1[m] + t2i * drho2drm1[m] + t3i * drho3drm1[m]); - drhodrm2[m] = dgamma2[j] * (t1j * drho1drm2[m] + t2j * drho2drm2[m] + t3j * drho3drm2[m]); + drhodrm1[m] = dgamma2[i] * (t1i * (drho1drm1[m] - drho1mdrm1[m]) + + t2i * (drho2drm1[m] - drho2mdrm1[m]) + + t3i * (drho3drm1[m] - drho3mdrm1[m]) ); + drhodrm2[m] = dgamma2[j] * (t1j * (drho1drm2[m] - drho1mdrm2[m]) + + t2j * (drho2drm2[m] - drho2mdrm2[m]) + + t3j * (drho3drm2[m] - drho3mdrm2[m]) ); } // Compute derivatives wrt sij, but only if necessary @@ -328,16 +477,35 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho0ds1 = rhoa0j; drho0ds2 = rhoa0i; a1 = 2.0 / rij; - drho1ds1 = a1 * rhoa1j * arg1i1; - drho1ds2 = a1 * rhoa1i * arg1j1; a2 = 2.0 / rij2; - drho2ds1 = a2 * rhoa2j * arg1i2 - 2.0 / 3.0 * arho2b[i] * rhoa2j; - drho2ds2 = a2 * rhoa2i * arg1j2 - 2.0 / 3.0 * arho2b[j] * rhoa2i; a3 = 2.0 / rij3; a3a = 6.0 / (5.0 * rij); + + drho1ds1 = a1 * rhoa1j * arg1i1; + drho1ds2 = a1 * rhoa1i * arg1j1; + drho2ds1 = a2 * rhoa2j * arg1i2 - 2.0 / 3.0 * arho2b[i] * rhoa2j; + drho2ds2 = a2 * rhoa2i * arg1j2 - 2.0 / 3.0 * arho2b[j] * rhoa2i; drho3ds1 = a3 * rhoa3j * arg1i3 - a3a * rhoa3j * arg3i3; drho3ds2 = a3 * rhoa3i * arg1j3 - a3a * rhoa3i * arg3j3; + if (this->msmeamflag) { + drho1mds1 = a1 * rhoa1mj * arg1i1m; + drho1mds2 = a1 * rhoa1mi * arg1j1m; + drho2mds1 = a2 * rhoa2mj * arg1i2m - 2.0 / 3.0 * arho2mb[i] * rhoa2mj; + drho2mds2 = a2 * rhoa2mi * arg1j2m - 2.0 / 3.0 * arho2mb[j] * rhoa2mi; + drho3mds1 = a3 * rhoa3mj * arg1i3m - a3a * rhoa3mj * arg3i3m; + drho3mds2 = a3 * rhoa3mi * arg1j3m - a3a * rhoa3mi * arg3j3m; + drho3mds1 *= -1; + drho3mds2 *= -1; + } else { + drho1mds1 = 0.0; + drho1mds2 = 0.0; + drho2mds1 = 0.0; + drho2mds2 = 0.0; + drho3mds1 = 0.0; + drho3mds2 = 0.0; + } + if (this->ialloy == 1) { a1i = fdiv_zero(rhoa0j, tsq_ave[i][0]); a1j = fdiv_zero(rhoa0i, tsq_ave[j][0]); @@ -380,12 +548,14 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } drhods1 = dgamma1[i] * drho0ds1 + - dgamma2[i] * (dt1ds1 * rho1[i] + t1i * drho1ds1 + dt2ds1 * rho2[i] + t2i * drho2ds1 + - dt3ds1 * rho3[i] + t3i * drho3ds1) - + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * (drho1ds1 - drho1mds1) + + dt2ds1 * rho2[i] + t2i * (drho2ds1 - drho2mds1) + + dt3ds1 * rho3[i] + t3i * (drho3ds1 - drho3mds1)) - dgamma3[i] * (shpi[0] * dt1ds1 + shpi[1] * dt2ds1 + shpi[2] * dt3ds1); drhods2 = dgamma1[j] * drho0ds2 + - dgamma2[j] * (dt1ds2 * rho1[j] + t1j * drho1ds2 + dt2ds2 * rho2[j] + t2j * drho2ds2 + - dt3ds2 * rho3[j] + t3j * drho3ds2) - + dgamma2[j] * (dt1ds2 * rho1[j] + t1j * (drho1ds2 - drho1mds2) + + dt2ds2 * rho2[j] + t2j * (drho2ds2 - drho2mds2) + + dt3ds2 * rho3[j] + t3j * (drho3ds2 - drho3mds2)) - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); } From 8b40ecff4c3d13112825610861a5c3f56a071374 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Fri, 15 Jul 2022 16:39:02 -0600 Subject: [PATCH 02/43] Debugging prints --- src/tokenizer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 89c5b99dfb..d45fdea692 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -255,6 +255,7 @@ std::string ValueTokenizer::next_string() int ValueTokenizer::next_int() { std::string current = tokens.next(); + printf("Tokenizer::next_int() current = %s\n", current.c_str()); if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } return atoi(current.c_str()); } @@ -285,6 +286,7 @@ tagint ValueTokenizer::next_tagint() double ValueTokenizer::next_double() { std::string current = tokens.next(); + printf("Tokenizer::next_double() current = %s\n", current.c_str()); if (!utils::is_double(current)) { throw InvalidFloatException(current); } return atof(current.c_str()); } From 0fc9bb2cdfe411b79fc88fc8672574481c665cc2 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 6 Dec 2022 18:56:58 -0700 Subject: [PATCH 03/43] Add optional msmeam flag --- src/MEAM/meam.h | 3 ++- src/MEAM/pair_meam.cpp | 17 +++++++++++++++-- src/MEAM/pair_meam.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index 0f14b7db5a..c00f40900c 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -30,6 +30,7 @@ class MEAM { virtual ~MEAM(); int copymode; + int msmeamflag; protected: Memory *memory; @@ -125,7 +126,7 @@ class MEAM { double t1m_meam[maxelt], t2m_meam[maxelt], t3m_meam[maxelt]; double beta1m_meam[maxelt], beta2m_meam[maxelt], beta3m_meam[maxelt]; - int msmeamflag; + //int msmeamflag; // made public for pair style settings public: int nmax; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 6cbe5c69b9..3eba4b294b 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -53,6 +53,7 @@ PairMEAM::PairMEAM(LAMMPS *lmp) : Pair(lmp) one_coeff = 1; manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; + msmeamflag = 0; allocated = 0; @@ -190,9 +191,20 @@ void PairMEAM::allocate() global settings ------------------------------------------------------------------------- */ -void PairMEAM::settings(int narg, char ** /*arg*/) +void PairMEAM::settings(int narg, char **arg) { - if (narg != 0) error->all(FLERR,"Illegal pair_style command"); + if (narg > 1) error->all(FLERR,"Illegal pair_style command"); + + meam_inst->msmeamflag = 0; + + if (narg == 1){ + if (strcmp("ms", arg[0]) == 0){ + msmeamflag = 1; + meam_inst->msmeamflag = 1; + } else + error->all(FLERR, "Unknown pair style zero option {}", arg[0]); + } + } /* ---------------------------------------------------------------------- @@ -433,6 +445,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) t2[index] = values.next_double(); t3[index] = values.next_double(); rozero[index] = values.next_double(); + printf("ibar:\n"); ibar[index] = values.next_int(); if (!isone(t0[index])) diff --git a/src/MEAM/pair_meam.h b/src/MEAM/pair_meam.h index 304e7eb41f..3b85a6598a 100644 --- a/src/MEAM/pair_meam.h +++ b/src/MEAM/pair_meam.h @@ -47,6 +47,7 @@ class PairMEAM : public Pair { class MEAM *meam_inst; double cutmax; // max cutoff for all elements int nlibelements; // # of library elements + int msmeamflag; // 0 (default) for normal MEAM, 1 for MS-MEAM std::vector libelements; // names of library elements std::vector mass; // mass of library element From 80ea94ae24a9a5986b20740fda9f95dfe5ebc184 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Fri, 6 Jan 2023 11:10:52 -0700 Subject: [PATCH 04/43] Envelope msmeam calculations in conditional --- src/MEAM/meam_force.cpp | 501 ++++++++++++++++++++++------------------ 1 file changed, 276 insertions(+), 225 deletions(-) diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 26ccf110c8..ffcb6169cc 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -83,8 +83,10 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int xitmp = x[i][0]; yitmp = x[i][1]; zitmp = x[i][2]; + //printf("%f %f %f\n", xitmp, yitmp, zitmp); // Treat each pair + for (jn = 0; jn < numneigh; jn++) { j = firstneigh[jn]; eltj = fmap[type[j]]; @@ -97,6 +99,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int delij[1] = x[j][1] - yitmp; delij[2] = x[j][2] - zitmp; rij2 = delij[0] * delij[0] + delij[1] * delij[1] + delij[2] * delij[2]; + //printf("rij2: %f\n", rij2); if (rij2 < this->cutforcesq) { rij = sqrt(rij2); recip = 1.0 / rij; @@ -137,6 +140,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3i = ro0i * MathSpecial::fm_exp(-this->beta3_meam[elti] * ai); drhoa3i = -this->beta3_meam[elti] * invrei * rhoa3i; + //printf("%f %f %f %f %f\n", ro0i, drhoa0i, drhoa1i, drhoa2i, drhoa3i); + if (elti != eltj) { invrej = 1.0 / this->re_meam[eltj][eltj]; aj = rij * invrej - 1.0; @@ -150,33 +155,38 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3j = ro0j * MathSpecial::fm_exp(-this->beta3_meam[eltj] * aj); drhoa3j = -this->beta3_meam[eltj] * invrej * rhoa3j; - if (this->msmeamflag) { - rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecial::fm_exp(-this->beta1m_meam[eltj] * aj); - drhoa1mj = -this->beta1m_meam[eltj] * invrej * rhoa1mj; - rhoa2mj = ro0j * t2m_meam[eltj] * MathSpecial::fm_exp(-this->beta2m_meam[eltj] * aj); - drhoa2mj = -this->beta2m_meam[eltj] * invrej * rhoa2mj; - rhoa3mj = ro0j * t3m_meam[eltj] * MathSpecial::fm_exp(-this->beta3m_meam[eltj] * aj); - drhoa3mj = -this->beta3m_meam[eltj] * invrej * rhoa3mj; - } - } else { - rhoa0j = rhoa0i; - drhoa0j = drhoa0i; - rhoa1j = rhoa1i; - drhoa1j = drhoa1i; - rhoa2j = rhoa2i; - drhoa2j = drhoa2i; - rhoa3j = rhoa3i; - drhoa3j = drhoa3i; - if (this->msmeamflag) { - rhoa1mj = rhoa1mi; - drhoa1mj = drhoa1mi; - rhoa2mj = rhoa2mi; - drhoa2mj = drhoa2mi; - rhoa3mj = rhoa3mi; - drhoa3mj = drhoa3mi; - } - } + if (this->msmeamflag) { + rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecial::fm_exp(-this->beta1m_meam[eltj] * aj); + drhoa1mj = -this->beta1m_meam[eltj] * invrej * rhoa1mj; + rhoa2mj = ro0j * t2m_meam[eltj] * MathSpecial::fm_exp(-this->beta2m_meam[eltj] * aj); + drhoa2mj = -this->beta2m_meam[eltj] * invrej * rhoa2mj; + rhoa3mj = ro0j * t3m_meam[eltj] * MathSpecial::fm_exp(-this->beta3m_meam[eltj] * aj); + drhoa3mj = -this->beta3m_meam[eltj] * invrej * rhoa3mj; + } + + } else { + rhoa0j = rhoa0i; + drhoa0j = drhoa0i; + rhoa1j = rhoa1i; + drhoa1j = drhoa1i; + rhoa2j = rhoa2i; + drhoa2j = drhoa2i; + rhoa3j = rhoa3i; + drhoa3j = drhoa3i; + + if (this->msmeamflag) { + rhoa1mj = rhoa1mi; + drhoa1mj = drhoa1mi; + rhoa2mj = rhoa2mi; + drhoa2mj = drhoa2mi; + rhoa3mj = rhoa3mi; + drhoa3mj = drhoa3mi; + } + } + + //printf("%f %f %f %f %f\n", ro0i, drhoa0j, drhoa1j, drhoa2j, drhoa3j); + //printf("%f %f %f\n", drhoa1mj, drhoa2mj, drhoa3mj); const double t1mi = this->t1_meam[elti]; const double t2mi = this->t2_meam[elti]; @@ -185,6 +195,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int const double t2mj = this->t2_meam[eltj]; const double t3mj = this->t3_meam[eltj]; + //printf("%f %f %f %f %f %f\n", t1mi, t2mi, t3mi, t1mj, t2mj, t3mj); + if (this->ialloy == 1) { rhoa1j *= t1mj; rhoa2j *= t2mj; @@ -229,40 +241,43 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int arg3j3 = arg3j3 - arho3b[j][n] * delij[n]; } - // arhom args - arg1i1m = 0.0; - arg1j1m = 0.0; - arg1i2m = 0.0; - arg1j2m = 0.0; - arg1i3m = 0.0; - arg1j3m = 0.0; - arg3i3m = 0.0; - arg3j3m = 0.0; - if (this->msmeamflag) { - for (n = 0; n < 3; n++) { - for (p = n; p < 3; p++) { - for (q = p; q < 3; q++) { - arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; - arg1i3m = arg1i3m + arho3m[i][nv3] * arg; - arg1j3m = arg1j3m - arho3m[j][nv3] * arg; - nv3 = nv3 + 1; - } - arg = delij[n] * delij[p] * this->v2D[nv2]; - arg1i2m = arg1i2m + arho2m[i][nv2] * arg; - arg1j2m = arg1j2m + arho2m[j][nv2] * arg; - nv2 = nv2 + 1; - } - arg1i1m = arg1i1m + arho1m[i][n] * delij[n]; - arg1j1m = arg1j1m - arho1m[j][n] * delij[n]; - arg3i3m = arg3i3m + arho3mb[i][n] * delij[n]; - arg3j3m = arg3j3m - arho3mb[j][n] * delij[n]; - } - } + // arhom args (msmeam) + + arg1i1m = 0.0; + arg1j1m = 0.0; + arg1i2m = 0.0; + arg1j2m = 0.0; + arg1i3m = 0.0; + arg1j3m = 0.0; + arg3i3m = 0.0; + arg3j3m = 0.0; + if (this->msmeamflag) { + for (n = 0; n < 3; n++) { + for (p = n; p < 3; p++) { + for (q = p; q < 3; q++) { + arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; + arg1i3m = arg1i3m + arho3m[i][nv3] * arg; + arg1j3m = arg1j3m - arho3m[j][nv3] * arg; + nv3 = nv3 + 1; + } + arg = delij[n] * delij[p] * this->v2D[nv2]; + arg1i2m = arg1i2m + arho2m[i][nv2] * arg; + arg1j2m = arg1j2m + arho2m[j][nv2] * arg; + nv2 = nv2 + 1; + } + arg1i1m = arg1i1m + arho1m[i][n] * delij[n]; + arg1j1m = arg1j1m - arho1m[j][n] * delij[n]; + arg3i3m = arg3i3m + arho3mb[i][n] * delij[n]; + arg3j3m = arg3j3m - arho3mb[j][n] * delij[n]; + } + } // rho0 terms drho0dr1 = drhoa0j * sij; drho0dr2 = drhoa0i * sij; + //printf("%f %f\n", drho0dr1, drho0dr2); + // rho1 terms a1 = 2 * sij / rij; drho1dr1 = a1 * (drhoa1j - rhoa1j / rij) * arg1i1; @@ -271,23 +286,24 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int for (m = 0; m < 3; m++) { drho1drm1[m] = a1 * rhoa1j * arho1[i][m]; drho1drm2[m] = -a1 * rhoa1i * arho1[j][m]; + //printf("%f %f\n", drho1drm1[m], drho1drm2[m]); } - // rho2 terms - a2 = 2 * sij / rij2; - drho2dr1 = a2 * (drhoa2j - 2 * rhoa2j / rij) * arg1i2 - 2.0 / 3.0 * arho2b[i] * drhoa2j * sij; - drho2dr2 = a2 * (drhoa2i - 2 * rhoa2i / rij) * arg1j2 - 2.0 / 3.0 * arho2b[j] * drhoa2i * sij; - a2 = 4 * sij / rij2; - for (m = 0; m < 3; m++) { - drho2drm1[m] = 0.0; - drho2drm2[m] = 0.0; - for (n = 0; n < 3; n++) { - drho2drm1[m] = drho2drm1[m] + arho2[i][this->vind2D[m][n]] * delij[n]; - drho2drm2[m] = drho2drm2[m] - arho2[j][this->vind2D[m][n]] * delij[n]; - } - drho2drm1[m] = a2 * rhoa2j * drho2drm1[m]; - drho2drm2[m] = -a2 * rhoa2i * drho2drm2[m]; - } + // rho2 terms + a2 = 2 * sij / rij2; + drho2dr1 = a2 * (drhoa2j - 2 * rhoa2j / rij) * arg1i2 - 2.0 / 3.0 * arho2b[i] * drhoa2j * sij; + drho2dr2 = a2 * (drhoa2i - 2 * rhoa2i / rij) * arg1j2 - 2.0 / 3.0 * arho2b[j] * drhoa2i * sij; + a2 = 4 * sij / rij2; + for (m = 0; m < 3; m++) { + drho2drm1[m] = 0.0; + drho2drm2[m] = 0.0; + for (n = 0; n < 3; n++) { + drho2drm1[m] = drho2drm1[m] + arho2[i][this->vind2D[m][n]] * delij[n]; + drho2drm2[m] = drho2drm2[m] - arho2[j][this->vind2D[m][n]] * delij[n]; + } + drho2drm1[m] = a2 * rhoa2j * drho2drm1[m]; + drho2drm2[m] = -a2 * rhoa2i * drho2drm2[m]; + } // rho3 terms rij3 = rij * rij2; @@ -313,164 +329,185 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3drm2[m] = (-a3 * drho3drm2[m] + a3a * arho3b[j][m]) * rhoa3i; } - if (this->msmeamflag) { - // rho1m terms - a1 = 2 * sij / rij; - drho1mdr1 = a1 * (drhoa1mj - rhoa1mj / rij) * arg1i1m; - drho1mdr2 = a1 * (drhoa1mi - rhoa1mi / rij) * arg1j1m; - drho1mdr1 *= -1.0; - drho1mdr2 *= -1.0; - a1 = 2.0 * sij / rij; - for (m = 0; m < 3; m++) { - drho1mdrm1[m] = a1 * rhoa1mj * arho1m[i][m]; - drho1mdrm2[m] = -a1 * rhoa1mi * arho1m[j][m]; - } + if (this->msmeamflag) { + // rho1m terms + a1 = 2 * sij / rij; + drho1mdr1 = a1 * (drhoa1mj - rhoa1mj / rij) * arg1i1m; + drho1mdr2 = a1 * (drhoa1mi - rhoa1mi / rij) * arg1j1m; + drho1mdr1 *= -1.0; + drho1mdr2 *= -1.0; + a1 = 2.0 * sij / rij; + for (m = 0; m < 3; m++) { + drho1mdrm1[m] = a1 * rhoa1mj * arho1m[i][m]; + drho1mdrm2[m] = -a1 * rhoa1mi * arho1m[j][m]; + } - // rho2m terms - a2 = 2 * sij / rij2; - drho2mdr1 = a2 * (drhoa2mj - 2 * rhoa2mj / rij) * arg1i2m - 2.0 / 3.0 * arho2mb[i] * drhoa2mj * sij; - drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - 2.0 / 3.0 * arho2mb[j] * drhoa2mi * sij; - a2 = 4 * sij / rij2; - for (m = 0; m < 3; m++) { - drho2mdrm1[m] = 0.0; - drho2mdrm2[m] = 0.0; - for (n = 0; n < 3; n++) { - drho2mdrm1[m] = drho2mdrm1[m] + arho2m[i][this->vind2D[m][n]] * delij[n]; - drho2mdrm2[m] = drho2mdrm2[m] - arho2m[j][this->vind2D[m][n]] * delij[n]; - } - drho2mdrm1[m] = a2 * rhoa2mj * drho2mdrm1[m]; - drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; - } + // rho2m terms + a2 = 2 * sij / rij2; + drho2mdr1 = a2 * (drhoa2mj - 2 * rhoa2mj / rij) * arg1i2m - 2.0 / 3.0 * arho2mb[i] * drhoa2mj * sij; + drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - 2.0 / 3.0 * arho2mb[j] * drhoa2mi * sij; + a2 = 4 * sij / rij2; + for (m = 0; m < 3; m++) { + drho2mdrm1[m] = 0.0; + drho2mdrm2[m] = 0.0; + for (n = 0; n < 3; n++) { + drho2mdrm1[m] = drho2mdrm1[m] + arho2m[i][this->vind2D[m][n]] * delij[n]; + drho2mdrm2[m] = drho2mdrm2[m] - arho2m[j][this->vind2D[m][n]] * delij[n]; + } + drho2mdrm1[m] = a2 * rhoa2mj * drho2mdrm1[m]; + drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; + } - // rho3m terms - rij3 = rij * rij2; - a3 = 2 * sij / rij3; - a3a = 6.0 / 5.0 * sij / rij; - drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; - drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; - drho3mdr1 *= -1.0; - drho3mdr2 *= -1.0; - a3 = 6 * sij / rij3; - a3a = 6 * sij / (5 * rij); - for (m = 0; m < 3; m++) { - drho3mdrm1[m] = 0.0; - drho3mdrm2[m] = 0.0; - nv2 = 0; - for (n = 0; n < 3; n++) { - for (p = n; p < 3; p++) { - arg = delij[n] * delij[p] * this->v2D[nv2]; - drho3mdrm1[m] = drho3mdrm1[m] + arho3m[i][this->vind3D[m][n][p]] * arg; - drho3mdrm2[m] = drho3mdrm2[m] + arho3m[j][this->vind3D[m][n][p]] * arg; - nv2 = nv2 + 1; - } - } - drho3mdrm1[m] = (a3 * drho3mdrm1[m] - a3a * arho3mb[i][m]) * rhoa3mj; - drho3mdrm2[m] = (-a3 * drho3mdrm2[m] + a3a * arho3mb[j][m]) * rhoa3mi; - } - } else { - drho1mdrm1[m] = 0.0; - drho1mdrm2[m] = 0.0; - drho2mdrm1[m] = 0.0; - drho2mdrm2[m] = 0.0; - drho3mdrm1[m] = 0.0; - drho3mdrm2[m] = 0.0; - } + // rho3m terms + rij3 = rij * rij2; + a3 = 2 * sij / rij3; + a3a = 6.0 / 5.0 * sij / rij; + drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; + drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; + drho3mdr1 *= -1.0; + drho3mdr2 *= -1.0; + a3 = 6 * sij / rij3; + a3a = 6 * sij / (5 * rij); + for (m = 0; m < 3; m++) { + drho3mdrm1[m] = 0.0; + drho3mdrm2[m] = 0.0; + nv2 = 0; + for (n = 0; n < 3; n++) { + for (p = n; p < 3; p++) { + arg = delij[n] * delij[p] * this->v2D[nv2]; + drho3mdrm1[m] = drho3mdrm1[m] + arho3m[i][this->vind3D[m][n][p]] * arg; + drho3mdrm2[m] = drho3mdrm2[m] + arho3m[j][this->vind3D[m][n][p]] * arg; + nv2 = nv2 + 1; + } + } + drho3mdrm1[m] = (a3 * drho3mdrm1[m] - a3a * arho3mb[i][m]) * rhoa3mj; + drho3mdrm2[m] = (-a3 * drho3mdrm2[m] + a3a * arho3mb[j][m]) * rhoa3mi; + } + } else { + drho1mdrm1[m] = 0.0; + drho1mdrm2[m] = 0.0; + drho2mdrm1[m] = 0.0; + drho2mdrm2[m] = 0.0; + drho3mdrm1[m] = 0.0; + drho3mdrm2[m] = 0.0; + } // compute derivatives of weighting functions t wrt rij - // weighting functions t set to unity for MS-MEAM - - if (this->msmeamflag) { + // weighting functions t set to unity for MS-MEAM + + if (this->msmeamflag) { - t1i = 1.0; - t2i = 1.0; - t3i = 1.0; - t1j = 1.0; - t2j = 1.0; - t3j = 1.0; - dt1dr1 = 0.0; - dt1dr2 = 0.0; - dt2dr1 = 0.0; - dt2dr2 = 0.0; - dt3dr1 = 0.0; - dt3dr2 = 0.0; + t1i = 1.0; + t2i = 1.0; + t3i = 1.0; + t1j = 1.0; + t2j = 1.0; + t3j = 1.0; + dt1dr1 = 0.0; + dt1dr2 = 0.0; + dt2dr1 = 0.0; + dt2dr2 = 0.0; + dt3dr1 = 0.0; + dt3dr2 = 0.0; - } else { + } else { - t1i = t_ave[i][0]; - t2i = t_ave[i][1]; - t3i = t_ave[i][2]; - t1j = t_ave[j][0]; - t2j = t_ave[j][1]; - t3j = t_ave[j][2]; + t1i = t_ave[i][0]; + t2i = t_ave[i][1]; + t3i = t_ave[i][2]; + t1j = t_ave[j][0]; + t2j = t_ave[j][1]; + t3j = t_ave[j][2]; - if (this->ialloy == 1) { + if (this->ialloy == 1) { - a1i = fdiv_zero(drhoa0j * sij, tsq_ave[i][0]); - a1j = fdiv_zero(drhoa0i * sij, tsq_ave[j][0]); - a2i = fdiv_zero(drhoa0j * sij, tsq_ave[i][1]); - a2j = fdiv_zero(drhoa0i * sij, tsq_ave[j][1]); - a3i = fdiv_zero(drhoa0j * sij, tsq_ave[i][2]); - a3j = fdiv_zero(drhoa0i * sij, tsq_ave[j][2]); + a1i = fdiv_zero(drhoa0j * sij, tsq_ave[i][0]); + a1j = fdiv_zero(drhoa0i * sij, tsq_ave[j][0]); + a2i = fdiv_zero(drhoa0j * sij, tsq_ave[i][1]); + a2j = fdiv_zero(drhoa0i * sij, tsq_ave[j][1]); + a3i = fdiv_zero(drhoa0j * sij, tsq_ave[i][2]); + a3j = fdiv_zero(drhoa0i * sij, tsq_ave[j][2]); - dt1dr1 = a1i * (t1mj - t1i * MathSpecial::square(t1mj)); - dt1dr2 = a1j * (t1mi - t1j * MathSpecial::square(t1mi)); - dt2dr1 = a2i * (t2mj - t2i * MathSpecial::square(t2mj)); - dt2dr2 = a2j * (t2mi - t2j * MathSpecial::square(t2mi)); - dt3dr1 = a3i * (t3mj - t3i * MathSpecial::square(t3mj)); - dt3dr2 = a3j * (t3mi - t3j * MathSpecial::square(t3mi)); + dt1dr1 = a1i * (t1mj - t1i * MathSpecial::square(t1mj)); + dt1dr2 = a1j * (t1mi - t1j * MathSpecial::square(t1mi)); + dt2dr1 = a2i * (t2mj - t2i * MathSpecial::square(t2mj)); + dt2dr2 = a2j * (t2mi - t2j * MathSpecial::square(t2mi)); + dt3dr1 = a3i * (t3mj - t3i * MathSpecial::square(t3mj)); + dt3dr2 = a3j * (t3mi - t3j * MathSpecial::square(t3mi)); - } else if (this->ialloy == 2) { + } else if (this->ialloy == 2) { - dt1dr1 = 0.0; - dt1dr2 = 0.0; - dt2dr1 = 0.0; - dt2dr2 = 0.0; - dt3dr1 = 0.0; - dt3dr2 = 0.0; + dt1dr1 = 0.0; + dt1dr2 = 0.0; + dt2dr1 = 0.0; + dt2dr2 = 0.0; + dt3dr1 = 0.0; + dt3dr2 = 0.0; - } else { + } else { - ai = 0.0; - if (!iszero(rho0[i])) - ai = drhoa0j * sij / rho0[i]; - aj = 0.0; - if (!iszero(rho0[j])) - aj = drhoa0i * sij / rho0[j]; + ai = 0.0; + if (!iszero(rho0[i])) + ai = drhoa0j * sij / rho0[i]; + aj = 0.0; + if (!iszero(rho0[j])) + aj = drhoa0i * sij / rho0[j]; - dt1dr1 = ai * (t1mj - t1i); - dt1dr2 = aj * (t1mi - t1j); - dt2dr1 = ai * (t2mj - t2i); - dt2dr2 = aj * (t2mi - t2j); - dt3dr1 = ai * (t3mj - t3i); - dt3dr2 = aj * (t3mi - t3j); - } - - } + dt1dr1 = ai * (t1mj - t1i); + dt1dr2 = aj * (t1mi - t1j); + dt2dr1 = ai * (t2mj - t2i); + dt2dr2 = aj * (t2mi - t2j); + dt3dr1 = ai * (t3mj - t3i); + dt3dr2 = aj * (t3mi - t3j); + } + + } + + //printf("%f %f %f %f %f %f\n", dt1dr1, dt1dr2, dt2dr1, dt2dr2, dt3dr1, dt3dr2); // Compute derivatives of total density wrt rij, sij and rij(3) get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpi); get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); - drhodr1 = dgamma1[i] * drho0dr1 + - dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + - dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + - dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - - dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); - drhodr2 = dgamma1[j] * drho0dr2 + - dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + - dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + - dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); - for (m = 0; m < 3; m++) { - drhodrm1[m] = 0.0; - drhodrm2[m] = 0.0; - drhodrm1[m] = dgamma2[i] * (t1i * (drho1drm1[m] - drho1mdrm1[m]) + - t2i * (drho2drm1[m] - drho2mdrm1[m]) + - t3i * (drho3drm1[m] - drho3mdrm1[m]) ); - drhodrm2[m] = dgamma2[j] * (t1j * (drho1drm2[m] - drho1mdrm2[m]) + - t2j * (drho2drm2[m] - drho2mdrm2[m]) + - t3j * (drho3drm2[m] - drho3mdrm2[m]) ); + if (this->msmeamflag){ + drhodr1 = dgamma1[i] * drho0dr1 + + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + + dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - + dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); + drhodr2 = dgamma1[j] * drho0dr2 + + dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + + dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - + dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + for (m = 0; m < 3; m++) { + drhodrm1[m] = 0.0; + drhodrm2[m] = 0.0; + drhodrm1[m] = dgamma2[i] * (t1i * (drho1drm1[m] - drho1mdrm1[m]) + + t2i * (drho2drm1[m] - drho2mdrm1[m]) + + t3i * (drho3drm1[m] - drho3mdrm1[m]) ); + drhodrm2[m] = dgamma2[j] * (t1j * (drho1drm2[m] - drho1mdrm2[m]) + + t2j * (drho2drm2[m] - drho2mdrm2[m]) + + t3j * (drho3drm2[m] - drho3mdrm2[m]) ); + } + } else{ + + drhodr1 = dgamma1[i] * drho0dr1 + + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * drho1dr1 + dt2dr1 * rho2[i] + t2i * drho2dr1 + + dt3dr1 * rho3[i] + t3i * drho3dr1) - + dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); + drhodr2 = dgamma1[j] * drho0dr2 + + dgamma2[j] * (dt1dr2 * rho1[j] + t1j * drho1dr2 + dt2dr2 * rho2[j] + t2j * drho2dr2 + + dt3dr2 * rho3[j] + t3j * drho3dr2) - + dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + for (m = 0; m < 3; m++) { + drhodrm1[m] = 0.0; + drhodrm2[m] = 0.0; + drhodrm1[m] = dgamma2[i] * (t1i * drho1drm1[m] + t2i * drho2drm1[m] + t3i * drho3drm1[m]); + drhodrm2[m] = dgamma2[j] * (t1j * drho1drm2[m] + t2j * drho2drm2[m] + t3j * drho3drm2[m]); + } } + //printf("%f %f %f %f %f %f %f %f\n", drhodr1, drhodr2, drhodrm1[0], drhodrm1[1], drhodrm1[2], drhodrm2[0], drhodrm2[1], drhodrm2[2]); // Compute derivatives wrt sij, but only if necessary if (!iszero(dscrfcn[fnoffset + jn])) { @@ -488,23 +525,23 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3ds1 = a3 * rhoa3j * arg1i3 - a3a * rhoa3j * arg3i3; drho3ds2 = a3 * rhoa3i * arg1j3 - a3a * rhoa3i * arg3j3; - if (this->msmeamflag) { - drho1mds1 = a1 * rhoa1mj * arg1i1m; - drho1mds2 = a1 * rhoa1mi * arg1j1m; - drho2mds1 = a2 * rhoa2mj * arg1i2m - 2.0 / 3.0 * arho2mb[i] * rhoa2mj; - drho2mds2 = a2 * rhoa2mi * arg1j2m - 2.0 / 3.0 * arho2mb[j] * rhoa2mi; - drho3mds1 = a3 * rhoa3mj * arg1i3m - a3a * rhoa3mj * arg3i3m; - drho3mds2 = a3 * rhoa3mi * arg1j3m - a3a * rhoa3mi * arg3j3m; - drho3mds1 *= -1; - drho3mds2 *= -1; - } else { - drho1mds1 = 0.0; - drho1mds2 = 0.0; - drho2mds1 = 0.0; - drho2mds2 = 0.0; - drho3mds1 = 0.0; - drho3mds2 = 0.0; - } + if (this->msmeamflag) { + drho1mds1 = a1 * rhoa1mj * arg1i1m; + drho1mds2 = a1 * rhoa1mi * arg1j1m; + drho2mds1 = a2 * rhoa2mj * arg1i2m - 2.0 / 3.0 * arho2mb[i] * rhoa2mj; + drho2mds2 = a2 * rhoa2mi * arg1j2m - 2.0 / 3.0 * arho2mb[j] * rhoa2mi; + drho3mds1 = a3 * rhoa3mj * arg1i3m - a3a * rhoa3mj * arg3i3m; + drho3mds2 = a3 * rhoa3mi * arg1j3m - a3a * rhoa3mi * arg3j3m; + drho3mds1 *= -1; + drho3mds2 *= -1; + } else { + drho1mds1 = 0.0; + drho1mds2 = 0.0; + drho2mds1 = 0.0; + drho2mds2 = 0.0; + drho3mds1 = 0.0; + drho3mds2 = 0.0; + } if (this->ialloy == 1) { a1i = fdiv_zero(rhoa0j, tsq_ave[i][0]); @@ -547,6 +584,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt3ds2 = aj * (t3mi - t3j); } + if (this->msmeamflag){ drhods1 = dgamma1[i] * drho0ds1 + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * (drho1ds1 - drho1mds1) + dt2ds1 * rho2[i] + t2i * (drho2ds1 - drho2mds1) + @@ -557,7 +595,20 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt2ds2 * rho2[j] + t2j * (drho2ds2 - drho2mds2) + dt3ds2 * rho3[j] + t3j * (drho3ds2 - drho3mds2)) - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); - } + } + else{ + drhods1 = dgamma1[i] * drho0ds1 + + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * drho1ds1 + dt2ds1 * rho2[i] + t2i * drho2ds1 + + dt3ds1 * rho3[i] + t3i * drho3ds1) - + dgamma3[i] * (shpi[0] * dt1ds1 + shpi[1] * dt2ds1 + shpi[2] * dt3ds1); + drhods2 = dgamma1[j] * drho0ds2 + + dgamma2[j] * (dt1ds2 * rho1[j] + t1j * drho1ds2 + dt2ds2 * rho2[j] + t2j * drho2ds2 + + dt3ds2 * rho3[j] + t3j * drho3ds2) - + dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); + } + + //printf("%f %f\n", drhods1, drhods2); + } // Compute derivatives of energy wrt rij, sij and rij[3] dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; From f28b0e491c70fc690aec29300046a697376595ee Mon Sep 17 00:00:00 2001 From: rohskopf Date: Fri, 6 Jan 2023 12:37:38 -0700 Subject: [PATCH 05/43] Optionally read msmeam parameters --- src/MEAM/pair_meam.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 3eba4b294b..e45918e7d1 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -201,6 +201,7 @@ void PairMEAM::settings(int narg, char **arg) if (strcmp("ms", arg[0]) == 0){ msmeamflag = 1; meam_inst->msmeamflag = 1; + printf("^^^^^ msmeam flag on!\n"); } else error->all(FLERR, "Unknown pair style zero option {}", arg[0]); } @@ -369,6 +370,7 @@ void PairMEAM::read_files(const std::string &globalfile, void PairMEAM::read_global_meam_file(const std::string &globalfile) { // allocate parameter arrays + std::vector lat(nlibelements); std::vector ielement(nlibelements); std::vector ibar(nlibelements); @@ -389,6 +391,15 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) std::vector rozero(nlibelements); std::vector found(nlibelements, false); + // allocate 6 extra arrays for msmeam + + std::vector b1m(nlibelements); + std::vector b2m(nlibelements); + std::vector b3m(nlibelements); + std::vector t1m(nlibelements); + std::vector t2m(nlibelements); + std::vector t3m(nlibelements); + // open global meamf file on proc 0 if (comm->me == 0) { @@ -423,6 +434,8 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) // map lat string to an integer std::string lattice_type = values.next_string(); + //error->one(FLERR,"lattice_type {}", lattice_type); + if (!MEAM::str_to_lat(lattice_type, true, lat[index])) error->one(FLERR,"Unrecognized lattice type in MEAM " "library file: {}", lattice_type); @@ -437,6 +450,11 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) b1[index] = values.next_double(); b2[index] = values.next_double(); b3[index] = values.next_double(); + if (this->msmeamflag){ + b1m[index] = values.next_double(); + b2m[index] = values.next_double(); + b3m[index] = values.next_double(); + } alat[index] = values.next_double(); esub[index] = values.next_double(); asub[index] = values.next_double(); @@ -444,10 +462,16 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) t1[index] = values.next_double(); t2[index] = values.next_double(); t3[index] = values.next_double(); + if (this->msmeamflag){ + t1m[index] = values.next_double(); + t2m[index] = values.next_double(); + t3m[index] = values.next_double(); + } rozero[index] = values.next_double(); - printf("ibar:\n"); ibar[index] = values.next_int(); + //error->one(FLERR,"^^^^ DEBUG"); + if (!isone(t0[index])) error->one(FLERR,"Unsupported parameter in MEAM library file: t0!=1"); From e815bea89486134c0cfc4fd15b4e72884b8274de Mon Sep 17 00:00:00 2001 From: rohskopf Date: Fri, 6 Jan 2023 13:16:21 -0700 Subject: [PATCH 06/43] Setup global function with msmeam parameters --- src/MEAM/meam.h | 4 +++- src/MEAM/meam_dens_final.cpp | 1 + src/MEAM/meam_setup_global.cpp | 20 +++++++++++++++++++- src/MEAM/pair_meam.cpp | 20 +++++++++++++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index c00f40900c..454dd35873 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -298,10 +298,12 @@ class MEAM { } // clang-format on static int get_Zij(const lattice_t latt); + // last 6 args are msmeam parameters void meam_setup_global(int nelt, lattice_t *lat, int *ielement, double *atwt, double *alpha, double *b0, double *b1, double *b2, double *b3, double *alat, double *esub, double *asub, double *t0, double *t1, double *t2, double *t3, - double *rozero, int *ibar); + double *rozero, int *ibar, double *b1m, double *b2m, double *b3m, + double *t1m, double *t2m, double *t3m); void meam_setup_param(int which, double value, int nindex, int *index /*index(3)*/, int *errorflag); virtual void meam_setup_done(double *cutmax); diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index e4df007230..ea53ea38ff 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -136,6 +136,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } if (eflag_atom != 0) { eatom[i] = eatom[i] + Fl; + } } } diff --git a/src/MEAM/meam_setup_global.cpp b/src/MEAM/meam_setup_global.cpp index a474e579c2..0ff64b06bc 100644 --- a/src/MEAM/meam_setup_global.cpp +++ b/src/MEAM/meam_setup_global.cpp @@ -36,9 +36,15 @@ void MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt*/, double* alpha, double* b0, double* b1, double* b2, double* b3, double* alat, double* esub, double* asub, double* t0, double* t1, double* t2, double* t3, double* rozero, - int* ibar) + int* ibar, double* b1m, double *b2m, double *b3m, double *t1m, double *t2m, + double *t3m) { + printf("^^^^^ meam setup global msmeamflag: %d\n", this->msmeamflag); + if (this->msmeamflag){ + printf("b1m[0]: %f\n", b1m[0]); + } + int i; double tmplat[maxelt]; @@ -53,6 +59,12 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* this->beta1_meam[i] = b1[i]; this->beta2_meam[i] = b2[i]; this->beta3_meam[i] = b3[i]; + if (this->msmeamflag){ + printf("^^^^^ Filling betam\n"); + this->beta1m_meam[i] = b1m[i]; + this->beta2m_meam[i] = b2m[i]; + this->beta3m_meam[i] = b3m[i]; + } tmplat[i] = alat[i]; this->Ec_meam[i][i] = esub[i]; this->A_meam[i] = asub[i]; @@ -60,6 +72,12 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* this->t1_meam[i] = t1[i]; this->t2_meam[i] = t2[i]; this->t3_meam[i] = t3[i]; + if (this->msmeamflag){ + printf("^^^^^ Filling tm\n"); + this->t1m_meam[i] = t1m[i]; + this->t2m_meam[i] = t2m[i]; + this->t3m_meam[i] = t3m[i]; + } this->rho0_meam[i] = rozero[i]; this->ibar_meam[i] = ibar[i]; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index e45918e7d1..cccca3fdda 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -517,13 +517,31 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) MPI_Bcast(t2.data(), nlibelements, MPI_DOUBLE, 0, world); MPI_Bcast(t3.data(), nlibelements, MPI_DOUBLE, 0, world); MPI_Bcast(rozero.data(), nlibelements, MPI_DOUBLE, 0, world); + // distribute msmeam parameter sets + MPI_Bcast(b1m.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(b2m.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(b3m.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t1m.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t2m.data(), nlibelements, MPI_DOUBLE, 0, world); + MPI_Bcast(t3m.data(), nlibelements, MPI_DOUBLE, 0, world); // pass element parameters to MEAM package + if (this->msmeamflag){ meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), - t2.data(), t3.data(), rozero.data(), ibar.data()); + t2.data(), t3.data(), rozero.data(), ibar.data(), b1m.data(), + b2m.data(), b3m.data(), t1m.data(), t2m.data(), t3m.data()); + } else{ + meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), + alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), + alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), + t2.data(), t3.data(), rozero.data(), ibar.data(), nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr); + } + + error->one(FLERR,"^^^^ DEBUG"); // set element masses From b419a98f0fc47cdc43c533e061f096a728c86f4b Mon Sep 17 00:00:00 2001 From: rohskopf Date: Fri, 6 Jan 2023 15:49:09 -0700 Subject: [PATCH 07/43] Identify segfault with arho params --- examples/meam/msmeam/HGaMS.meam | 30 ++++++++ examples/meam/msmeam/README.md | 4 + examples/meam/msmeam/library.MSmeam | 14 ++++ examples/meam/msmeam/potential-2.mod | 25 +++++++ examples/meam/msmeam/potential.mod | 25 +++++++ examples/meam/msmeam/potential3.mod | 25 +++++++ examples/meam/msmeam/test-2.in | 31 ++++++++ examples/meam/msmeam/test.data | 25 +++++++ examples/meam/msmeam/test.data.bu | 25 +++++++ examples/meam/msmeam/test.dump | 0 examples/meam/msmeam/test.dump.bu | 24 ++++++ examples/meam/msmeam/test.in | 31 ++++++++ examples/meam/msmeam/test.log | 0 examples/meam/msmeam/test.log.bu | 107 +++++++++++++++++++++++++++ examples/meam/msmeam/test3.in | 31 ++++++++ src/MEAM/meam_force.cpp | 15 ++-- src/MEAM/meam_impl.cpp | 6 +- src/MEAM/pair_meam.cpp | 7 +- 18 files changed, 414 insertions(+), 11 deletions(-) create mode 100644 examples/meam/msmeam/HGaMS.meam create mode 100644 examples/meam/msmeam/README.md create mode 100644 examples/meam/msmeam/library.MSmeam create mode 100644 examples/meam/msmeam/potential-2.mod create mode 100644 examples/meam/msmeam/potential.mod create mode 100644 examples/meam/msmeam/potential3.mod create mode 100644 examples/meam/msmeam/test-2.in create mode 100644 examples/meam/msmeam/test.data create mode 100644 examples/meam/msmeam/test.data.bu create mode 100644 examples/meam/msmeam/test.dump create mode 100644 examples/meam/msmeam/test.dump.bu create mode 100644 examples/meam/msmeam/test.in create mode 100644 examples/meam/msmeam/test.log create mode 100644 examples/meam/msmeam/test.log.bu create mode 100644 examples/meam/msmeam/test3.in diff --git a/examples/meam/msmeam/HGaMS.meam b/examples/meam/msmeam/HGaMS.meam new file mode 100644 index 0000000000..9f01501c16 --- /dev/null +++ b/examples/meam/msmeam/HGaMS.meam @@ -0,0 +1,30 @@ +bkgd_dyn = 1 +emb_lin_neg = 1 +augt1=0 +ialloy=1 +rc = 5.9 +#H +attrac(1,1)=0.460 +repuls(1,1)=0.460 +Cmin(1,1,1)=1.3 # PuMS +Cmax(1,1,1)= 2.80 +nn2(1,1)=1 +#Ga +rho0(2) = 0.6 +attrac(2,2)=0.097 +repuls(2,2)=0.097 +nn2(2,2)=1 +#HGa +attrac(1,2)=0.300 +repuls(1,2)=0.300 +lattce(1,2)=l12 +re(1,2)=3.19 +delta(1,2)=-0.48 +alpha(1,2)=6.6 +Cmin(1,1,2)=2.0 +Cmin(2,1,2)= 2.0 +Cmin(1,2,1)=2.0 +Cmin(2,2,1) = 1.4 +Cmin(1,2,2) = 1.4 +Cmin(1,1,2) = 1.4 +nn2(1,2)=1 diff --git a/examples/meam/msmeam/README.md b/examples/meam/msmeam/README.md new file mode 100644 index 0000000000..be4e81e472 --- /dev/null +++ b/examples/meam/msmeam/README.md @@ -0,0 +1,4 @@ +To run Baske's test, do + + lmp -in test3.in + diff --git a/examples/meam/msmeam/library.MSmeam b/examples/meam/msmeam/library.MSmeam new file mode 100644 index 0000000000..438284e90f --- /dev/null +++ b/examples/meam/msmeam/library.MSmeam @@ -0,0 +1,14 @@ +# DATE: 2018-09-22 MB DATE: 2016-09-21 CONTRIBUTOR: Steve Valone, smv@lanl.gov CITATION: Baskes, PRB 1992; smv, sr, mib, JNM 2010 +# ms-meam data format May 2010 +# elt lat z ielement atwt +# alpha b0 b1 b2 b3 b1m b2m b3m alat esub asub +# - t0 t1 t2 t3 t1m t2m t3m rozero ibar +# NOTE: leading character cannot be a space + +'H' 'dim' 1.0 1 1.0079 +2.960 2.960 3.0 1.0 1.0 1.0 3.0 1.0 0.741 2.235 2.50 +1.0 0.44721 0.0 0.00 0.0 0.31623 0 6.70 0 + +'Ga4' 'fcc' 12.0 31 69.723 +4.42 4.80 3.10 6.00 0.00 0.0 0.0 0.5 4.247 2.897 0.97 +1.0 1.649 1.435 0.00 0.0 0.0 2.0 0.70 0 diff --git a/examples/meam/msmeam/potential-2.mod b/examples/meam/msmeam/potential-2.mod new file mode 100644 index 0000000000..725bcaafa1 --- /dev/null +++ b/examples/meam/msmeam/potential-2.mod @@ -0,0 +1,25 @@ +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +# Choose potential +pair_style meam #MSmeam +print "we just executed" + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes diff --git a/examples/meam/msmeam/potential.mod b/examples/meam/msmeam/potential.mod new file mode 100644 index 0000000000..0532ee9d07 --- /dev/null +++ b/examples/meam/msmeam/potential.mod @@ -0,0 +1,25 @@ +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +# Choose potential +pair_style MSmeam +print "we just executed" + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes diff --git a/examples/meam/msmeam/potential3.mod b/examples/meam/msmeam/potential3.mod new file mode 100644 index 0000000000..21650e13f6 --- /dev/null +++ b/examples/meam/msmeam/potential3.mod @@ -0,0 +1,25 @@ +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +# Choose potential +pair_style meam ms #MSmeam +print "we just executed" + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes diff --git a/examples/meam/msmeam/test-2.in b/examples/meam/msmeam/test-2.in new file mode 100644 index 0000000000..775e33bab9 --- /dev/null +++ b/examples/meam/msmeam/test-2.in @@ -0,0 +1,31 @@ +echo both +log test.log +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box + +# + +include potential-2.mod +create_atoms 1 single 0 0 0 units box +create_atoms 2 single 2.2 0 0 units box +create_atoms 2 single 0.3 2.3 0 units box +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +write_data test.data + +print "All done!" diff --git a/examples/meam/msmeam/test.data b/examples/meam/msmeam/test.data new file mode 100644 index 0000000000..576a3c50de --- /dev/null +++ b/examples/meam/msmeam/test.data @@ -0,0 +1,25 @@ +LAMMPS data file via write_data, version 16 Feb 2016, timestep = 1 + +3 atoms +2 atom types + +-4.0000000000000000e+00 4.0000000000000000e+00 xlo xhi +-4.0000000000000000e+00 4.0000000000000000e+00 ylo yhi +-4.0000000000000000e+00 4.0000000000000000e+00 zlo zhi + +Masses + +1 1.0079 +2 69.723 + +Atoms # atomic + +1 1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 +2 2 2.2000000000000002e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 +3 2 2.9999999999999999e-01 2.2999999999999998e+00 0.0000000000000000e+00 0 0 0 + +Velocities + +1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +2 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +3 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 diff --git a/examples/meam/msmeam/test.data.bu b/examples/meam/msmeam/test.data.bu new file mode 100644 index 0000000000..576a3c50de --- /dev/null +++ b/examples/meam/msmeam/test.data.bu @@ -0,0 +1,25 @@ +LAMMPS data file via write_data, version 16 Feb 2016, timestep = 1 + +3 atoms +2 atom types + +-4.0000000000000000e+00 4.0000000000000000e+00 xlo xhi +-4.0000000000000000e+00 4.0000000000000000e+00 ylo yhi +-4.0000000000000000e+00 4.0000000000000000e+00 zlo zhi + +Masses + +1 1.0079 +2 69.723 + +Atoms # atomic + +1 1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 +2 2 2.2000000000000002e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 +3 2 2.9999999999999999e-01 2.2999999999999998e+00 0.0000000000000000e+00 0 0 0 + +Velocities + +1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +2 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +3 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 diff --git a/examples/meam/msmeam/test.dump b/examples/meam/msmeam/test.dump new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/meam/msmeam/test.dump.bu b/examples/meam/msmeam/test.dump.bu new file mode 100644 index 0000000000..039f630073 --- /dev/null +++ b/examples/meam/msmeam/test.dump.bu @@ -0,0 +1,24 @@ +ITEM: TIMESTEP +0 +ITEM: NUMBER OF ATOMS +3 +ITEM: BOX BOUNDS pp pp pp +-4 4 +-4 4 +-4 4 +ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 +2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 +ITEM: TIMESTEP +1 +ITEM: NUMBER OF ATOMS +3 +ITEM: BOX BOUNDS pp pp pp +-4 4 +-4 4 +-4 4 +ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 +2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 diff --git a/examples/meam/msmeam/test.in b/examples/meam/msmeam/test.in new file mode 100644 index 0000000000..d3ce0173e6 --- /dev/null +++ b/examples/meam/msmeam/test.in @@ -0,0 +1,31 @@ +echo both +log test.log +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box + +# + +include potential.mod +create_atoms 1 single 0 0 0 units box +create_atoms 2 single 2.2 0 0 units box +create_atoms 2 single 0.3 2.3 0 units box +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +write_data test.data + +print "All done!" diff --git a/examples/meam/msmeam/test.log b/examples/meam/msmeam/test.log new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/meam/msmeam/test.log.bu b/examples/meam/msmeam/test.log.bu new file mode 100644 index 0000000000..e7e414dbd4 --- /dev/null +++ b/examples/meam/msmeam/test.log.bu @@ -0,0 +1,107 @@ +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box +Created orthogonal box = (-4 -4 -4) to (4 4 4) + 1 by 1 by 1 MPI processor grid + +# + +include potential.mod +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +potential chosen H +# Choose potential +pair_style MSmeam +print "we just executed" +we just executed + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 +Reading potential file library.MSmeam with DATE: 2018-09-22 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +min_modify dmax 0.01 line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes +create_atoms 1 single 0 0 0 units box +Created 1 atoms +create_atoms 2 single 2.2 0 0 units box +Created 1 atoms +create_atoms 2 single 0.3 2.3 0 units box +Created 1 atoms +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +WARNING: No fixes defined, atoms won't move (../verlet.cpp:55) +Neighbor list info ... + 2 neighbor list requests + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.9 + ghost atom cutoff = 6.9 +Memory usage per processor = 12.9295 Mbytes +Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume eatoms + 0 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 + 1 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 +Loop time of 0.000172138 on 1 procs for 1 steps with 3 atoms + +Performance: 501.922 ns/day, 0.048 hours/ns, 5809.285 timesteps/s +81.3% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 6.6996e-05 | 6.6996e-05 | 6.6996e-05 | 0.0 | 38.92 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 1.9073e-06 | 1.9073e-06 | 1.9073e-06 | 0.0 | 1.11 +Output | 9.7036e-05 | 9.7036e-05 | 9.7036e-05 | 0.0 | 56.37 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 6.199e-06 | | | 3.60 + +Nlocal: 3 ave 3 max 3 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 78 ave 78 max 78 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7 ave 7 max 7 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 14 ave 14 max 14 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 14 +Ave neighs/atom = 4.66667 +Neighbor list builds = 0 +Dangerous builds = 0 +write_data test.data + +print "All done!" +All done! +Total wall time: 0:00:00 + diff --git a/examples/meam/msmeam/test3.in b/examples/meam/msmeam/test3.in new file mode 100644 index 0000000000..9ace5cb162 --- /dev/null +++ b/examples/meam/msmeam/test3.in @@ -0,0 +1,31 @@ +echo both +log test.log +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box + +# + +include potential3.mod +create_atoms 1 single 0 0 0 units box +create_atoms 2 single 2.2 0 0 units box +create_atoms 2 single 0.3 2.3 0 units box +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +write_data test.data + +print "All done!" diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index ffcb6169cc..14ca5f0dc7 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -155,7 +155,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3j = ro0j * MathSpecial::fm_exp(-this->beta3_meam[eltj] * aj); drhoa3j = -this->beta3_meam[eltj] * invrej * rhoa3j; - + printf("^^^^^ check\n"); if (this->msmeamflag) { rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecial::fm_exp(-this->beta1m_meam[eltj] * aj); drhoa1mj = -this->beta1m_meam[eltj] * invrej * rhoa1mj; @@ -255,10 +255,11 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int for (n = 0; n < 3; n++) { for (p = n; p < 3; p++) { for (q = p; q < 3; q++) { - arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; - arg1i3m = arg1i3m + arho3m[i][nv3] * arg; - arg1j3m = arg1j3m - arho3m[j][nv3] * arg; - nv3 = nv3 + 1; + arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; + printf("segfault here n p q: %d %d %d\n", n, p, q); + arg1i3m = arg1i3m + arho3m[i][nv3] * arg; + arg1j3m = arg1j3m - arho3m[j][nv3] * arg; + nv3 = nv3 + 1; } arg = delij[n] * delij[p] * this->v2D[nv2]; arg1i2m = arg1i2m + arho2m[i][nv2] * arg; @@ -271,7 +272,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int arg3j3m = arg3j3m - arho3mb[j][n] * delij[n]; } } - + // rho0 terms drho0dr1 = drhoa0j * sij; drho0dr2 = drhoa0i * sij; @@ -304,7 +305,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho2drm1[m] = a2 * rhoa2j * drho2drm1[m]; drho2drm2[m] = -a2 * rhoa2i * drho2drm2[m]; } - + printf("^^^^^ check 4\n"); // rho3 terms rij3 = rij * rij2; a3 = 2 * sij / rij3; diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index d0d81cee88..f04f2acd1a 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -33,6 +33,8 @@ MEAM::MEAM(Memory* mem) rho = rho0 = rho1 = rho2 = rho3 = frhop = nullptr; gamma = dgamma1 = dgamma2 = dgamma3 = arho2b = nullptr; arho1 = arho2 = arho3 = arho3b = t_ave = tsq_ave = nullptr; + // msmeam arrays + //arho1m = arho2m = arho2mb = arho3m = arho3mb = nullptr; maxneigh = 0; scrfcn = dscrfcn = fcpair = nullptr; @@ -43,7 +45,9 @@ MEAM::MEAM(Memory* mem) A_meam[i] = rho0_meam[i] = beta0_meam[i] = beta1_meam[i]= beta2_meam[i] = beta3_meam[i] = t0_meam[i] = t1_meam[i] = t2_meam[i] = t3_meam[i] = - rho_ref_meam[i] = ibar_meam[i] = ielt_meam[i] = 0.0; + rho_ref_meam[i] = ibar_meam[i] = ielt_meam[i] = + t1m_meam[i] = t2m_meam[i] = t3m_meam[i] = + beta1m_meam[i] = beta2m_meam[i] = beta3m_meam[i] = 0.0; for (int j = 0; j < maxelt; j++) { lattce_meam[i][j] = FCC; Ec_meam[i][j] = re_meam[i][j] = alpha_meam[i][j] = delta_meam[i][j] = ebound_meam[i][j] = attrac_meam[i][j] = repuls_meam[i][j] = 0.0; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index cccca3fdda..6a3c91115e 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -159,9 +159,10 @@ void PairMEAM::compute(int eflag, int vflag) double **vptr = nullptr; if (vflag_atom) vptr = vatom; - + printf("^^^^^ before force loop\n"); for (ii = 0; ii < inum_half; ii++) { i = ilist_half[ii]; + printf("^^^^^ i: %d\n", i); meam_inst->meam_force(i,eflag_global,eflag_atom,vflag_global, vflag_atom,&eng_vdwl,eatom,ntype,type,map,scale,x, numneigh_half[i],firstneigh_half[i], @@ -169,7 +170,7 @@ void PairMEAM::compute(int eflag, int vflag) offset,f,vptr,virial); offset += numneigh_half[i]; } - + printf("^^^^^ after force loop\n"); if (vflag_fdotr) virial_fdotr_compute(); } @@ -541,7 +542,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) nullptr, nullptr, nullptr, nullptr, nullptr); } - error->one(FLERR,"^^^^ DEBUG"); + //error->one(FLERR,"^^^^ DEBUG"); // set element masses From d5e29864ab9010ed19e2ff226ebaae964dc6206b Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 10 Jan 2023 15:14:14 -0700 Subject: [PATCH 08/43] Allocate meam arrays and fully implement force calculation --- examples/meam/msmeam/README.md | 7 +- examples/meam/msmeam/potential-2.mod | 25 ------ examples/meam/msmeam/potential.mod | 2 +- examples/meam/msmeam/potential3.mod | 25 ------ examples/meam/msmeam/run_loop.sh | 9 ++ examples/meam/msmeam/test-2.in | 31 ------- examples/meam/msmeam/test.data | 20 ++--- examples/meam/msmeam/test.dump | 24 ++++++ examples/meam/msmeam/test.log | 123 +++++++++++++++++++++++++++ examples/meam/msmeam/test3.in | 31 ------- src/MEAM/meam_dens_init.cpp | 12 +++ src/MEAM/meam_force.cpp | 72 ++++++++-------- src/MEAM/meam_impl.cpp | 3 +- src/MEAM/pair_meam.cpp | 66 ++++++++++++-- 14 files changed, 279 insertions(+), 171 deletions(-) delete mode 100644 examples/meam/msmeam/potential-2.mod delete mode 100644 examples/meam/msmeam/potential3.mod create mode 100755 examples/meam/msmeam/run_loop.sh delete mode 100644 examples/meam/msmeam/test-2.in delete mode 100644 examples/meam/msmeam/test3.in diff --git a/examples/meam/msmeam/README.md b/examples/meam/msmeam/README.md index be4e81e472..1b542ed867 100644 --- a/examples/meam/msmeam/README.md +++ b/examples/meam/msmeam/README.md @@ -1,4 +1,9 @@ To run Baske's test, do - lmp -in test3.in + lmp -in test.in + +Then + + diff test.dump test.dump.bu + diff --git a/examples/meam/msmeam/potential-2.mod b/examples/meam/msmeam/potential-2.mod deleted file mode 100644 index 725bcaafa1..0000000000 --- a/examples/meam/msmeam/potential-2.mod +++ /dev/null @@ -1,25 +0,0 @@ -# NOTE: This script can be modified for different pair styles -# See in.elastic for more info. - -variable Pu string H -print "potential chosen ${Pu}" -# Choose potential -pair_style meam #MSmeam -print "we just executed" - -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 -# Setup neighbor style -neighbor 1.0 nsq -neigh_modify once no every 1 delay 0 check yes - -# Setup minimization style -variable dmax equal 1.0e-2 -min_style cg -min_modify dmax ${dmax} line quadratic -compute eng all pe/atom -compute eatoms all reduce sum c_eng - -# Setup output -thermo 100 -thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms -thermo_modify norm yes diff --git a/examples/meam/msmeam/potential.mod b/examples/meam/msmeam/potential.mod index 0532ee9d07..10cc43afd8 100644 --- a/examples/meam/msmeam/potential.mod +++ b/examples/meam/msmeam/potential.mod @@ -4,7 +4,7 @@ variable Pu string H print "potential chosen ${Pu}" # Choose potential -pair_style MSmeam +pair_style meam ms # the `ms` flag turns on MS-MEAM print "we just executed" pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 diff --git a/examples/meam/msmeam/potential3.mod b/examples/meam/msmeam/potential3.mod deleted file mode 100644 index 21650e13f6..0000000000 --- a/examples/meam/msmeam/potential3.mod +++ /dev/null @@ -1,25 +0,0 @@ -# NOTE: This script can be modified for different pair styles -# See in.elastic for more info. - -variable Pu string H -print "potential chosen ${Pu}" -# Choose potential -pair_style meam ms #MSmeam -print "we just executed" - -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 -# Setup neighbor style -neighbor 1.0 nsq -neigh_modify once no every 1 delay 0 check yes - -# Setup minimization style -variable dmax equal 1.0e-2 -min_style cg -min_modify dmax ${dmax} line quadratic -compute eng all pe/atom -compute eatoms all reduce sum c_eng - -# Setup output -thermo 100 -thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms -thermo_modify norm yes diff --git a/examples/meam/msmeam/run_loop.sh b/examples/meam/msmeam/run_loop.sh new file mode 100755 index 0000000000..3a63672cce --- /dev/null +++ b/examples/meam/msmeam/run_loop.sh @@ -0,0 +1,9 @@ +# run in a loop to test for rare segfaults +for (( ; ; )) +do + ~/lammps/build-msmeam/lmp -in test3.in + # terminate loop if seg fault + if [[ $? -eq 139 ]]; then + exit 1 + fi +done \ No newline at end of file diff --git a/examples/meam/msmeam/test-2.in b/examples/meam/msmeam/test-2.in deleted file mode 100644 index 775e33bab9..0000000000 --- a/examples/meam/msmeam/test-2.in +++ /dev/null @@ -1,31 +0,0 @@ -echo both -log test.log -# Test of MEAM potential for HGa - -# ------------------------ INITIALIZATION ---------------------------- -units metal -dimension 3 -boundary p p p -atom_style atomic -variable latparam equal 4.646 -variable ncell equal 3 - -# ----------------------- ATOM DEFINITION ---------------------------- -region box block -4 4 -4 4 -4 4 -create_box 2 box - -# - -include potential-2.mod -create_atoms 1 single 0 0 0 units box -create_atoms 2 single 2.2 0 0 units box -create_atoms 2 single 0.3 2.3 0 units box -# ---------- Define Settings --------------------- -variable teng equal "c_eatoms" -compute pot_energy all pe/atom -compute stress all stress/atom NULL -dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -write_data test.data - -print "All done!" diff --git a/examples/meam/msmeam/test.data b/examples/meam/msmeam/test.data index 576a3c50de..f379aeccb5 100644 --- a/examples/meam/msmeam/test.data +++ b/examples/meam/msmeam/test.data @@ -1,11 +1,11 @@ -LAMMPS data file via write_data, version 16 Feb 2016, timestep = 1 +LAMMPS data file via write_data, version 23 Jun 2022, timestep = 1 3 atoms 2 atom types --4.0000000000000000e+00 4.0000000000000000e+00 xlo xhi --4.0000000000000000e+00 4.0000000000000000e+00 ylo yhi --4.0000000000000000e+00 4.0000000000000000e+00 zlo zhi +-4 4 xlo xhi +-4 4 ylo yhi +-4 4 zlo zhi Masses @@ -14,12 +14,12 @@ Masses Atoms # atomic -1 1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 -2 2 2.2000000000000002e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 -3 2 2.9999999999999999e-01 2.2999999999999998e+00 0.0000000000000000e+00 0 0 0 +1 1 0 0 0 0 0 0 +2 2 2.2 0 0 0 0 0 +3 2 0.3 2.3 0 0 0 0 Velocities -1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 -2 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 -3 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +1 0 0 0 +2 0 0 0 +3 0 0 0 diff --git a/examples/meam/msmeam/test.dump b/examples/meam/msmeam/test.dump index e69de29bb2..476ebfeb75 100644 --- a/examples/meam/msmeam/test.dump +++ b/examples/meam/msmeam/test.dump @@ -0,0 +1,24 @@ +ITEM: TIMESTEP +0 +ITEM: NUMBER OF ATOMS +3 +ITEM: BOX BOUNDS pp pp pp +-4.0000000000000000e+00 4.0000000000000000e+00 +-4.0000000000000000e+00 4.0000000000000000e+00 +-4.0000000000000000e+00 4.0000000000000000e+00 +ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +1 0 0 0 -132.308 -88.6953 0 22.6425 -2.1528e+08 -1.63302e+08 -0 -2.06499e+07 -0 -0 +2 2.2 0 0 121.138 -0.446613 0 14.8521 -2.12596e+08 -0 -0 386632 -0 -0 +3 0.3 2.3 0 11.1693 89.1419 0 8.67443 -2.68428e+06 -1.63302e+08 -0 -2.10365e+07 -0 -0 +ITEM: TIMESTEP +1 +ITEM: NUMBER OF ATOMS +3 +ITEM: BOX BOUNDS pp pp pp +-4.0000000000000000e+00 4.0000000000000000e+00 +-4.0000000000000000e+00 4.0000000000000000e+00 +-4.0000000000000000e+00 4.0000000000000000e+00 +ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +1 0 0 0 -132.308 -88.6953 0 22.6425 -2.1528e+08 -1.63302e+08 -0 -2.06499e+07 -0 -0 +2 2.2 0 0 121.138 -0.446613 0 14.8521 -2.12596e+08 -0 -0 386632 -0 -0 +3 0.3 2.3 0 11.1693 89.1419 0 8.67443 -2.68428e+06 -1.63302e+08 -0 -2.10365e+07 -0 -0 diff --git a/examples/meam/msmeam/test.log b/examples/meam/msmeam/test.log index e69de29bb2..83e0d92f70 100644 --- a/examples/meam/msmeam/test.log +++ b/examples/meam/msmeam/test.log @@ -0,0 +1,123 @@ +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box +Created orthogonal box = (-4 -4 -4) to (4 4 4) + 1 by 1 by 1 MPI processor grid + +# + +include potential.mod +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +potential chosen H +# Choose potential +pair_style meam ms # the `ms` flag turns on MS-MEAM +print "we just executed" +we just executed + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 +Reading MEAM library file library.MSmeam with DATE: 2018-09-22 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +min_modify dmax 0.01 line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes +create_atoms 1 single 0 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 2.2 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 0.3 2.3 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.9 + ghost atom cutoff = 6.9 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair meam, perpetual + attributes: full, newton on + pair build: full/nsq + stencil: none + bin: none + (2) pair meam, perpetual, half/full from (1) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes + Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms + 0 0 15.389692 492946.21 840939 637899.63 0 80663.676 0 0 8 8 8 512 15.389692 + 1 0 15.389692 492946.21 840939 637899.63 0 80663.676 0 0 8 8 8 512 15.389692 +Loop time of 7.9076e-05 on 1 procs for 1 steps with 3 atoms + +Performance: 1092.620 ns/day, 0.022 hours/ns, 12646.062 timesteps/s +67.0% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.4076e-05 | 2.4076e-05 | 2.4076e-05 | 0.0 | 30.45 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 3.204e-06 | 3.204e-06 | 3.204e-06 | 0.0 | 4.05 +Output | 4.726e-05 | 4.726e-05 | 4.726e-05 | 0.0 | 59.77 +Modify | 5.97e-07 | 5.97e-07 | 5.97e-07 | 0.0 | 0.75 +Other | | 3.939e-06 | | | 4.98 + +Nlocal: 3 ave 3 max 3 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 78 ave 78 max 78 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7 ave 7 max 7 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 14 ave 14 max 14 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 14 +Ave neighs/atom = 4.6666667 +Neighbor list builds = 0 +Dangerous builds = 0 +write_data test.data +System init for write_data ... + +print "All done!" +All done! +Total wall time: 0:00:00 diff --git a/examples/meam/msmeam/test3.in b/examples/meam/msmeam/test3.in deleted file mode 100644 index 9ace5cb162..0000000000 --- a/examples/meam/msmeam/test3.in +++ /dev/null @@ -1,31 +0,0 @@ -echo both -log test.log -# Test of MEAM potential for HGa - -# ------------------------ INITIALIZATION ---------------------------- -units metal -dimension 3 -boundary p p p -atom_style atomic -variable latparam equal 4.646 -variable ncell equal 3 - -# ----------------------- ATOM DEFINITION ---------------------------- -region box block -4 4 -4 4 -4 4 -create_box 2 box - -# - -include potential3.mod -create_atoms 1 single 0 0 0 units box -create_atoms 2 single 2.2 0 0 units box -create_atoms 2 single 0.3 2.3 0 units box -# ---------- Define Settings --------------------- -variable teng equal "c_eatoms" -compute pot_energy all pe/atom -compute stress all stress/atom NULL -dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -write_data test.data - -print "All done!" diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index f6de79de53..f5980233d6 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -45,6 +45,12 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memory->destroy(arho3b); memory->destroy(t_ave); memory->destroy(tsq_ave); + // msmeam params + memory->destroy(arho1m); + memory->destroy(arho2m); + memory->destroy(arho3m); + memory->destroy(arho2mb); + memory->destroy(arho3mb); nmax = atom_nmax; @@ -65,6 +71,12 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memory->create(arho3b, nmax, 3, "pair:arho3b"); memory->create(t_ave, nmax, 3, "pair:t_ave"); memory->create(tsq_ave, nmax, 3, "pair:tsq_ave"); + // msmeam params + memory->create(arho1m, nmax, 3, "pair:arho1m"); + memory->create(arho2m, nmax, 6, "pair:arho2m"); + memory->create(arho3m, nmax, 10, "pair:arho3m"); + memory->create(arho2mb, nmax, "pair:arho2mb"); + memory->create(arho3mb, nmax, 3, "pair:arho3mb"); } if (n_neigh > maxneigh) { diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 14ca5f0dc7..0d48c1fbc8 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -47,10 +47,13 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double drho0dr1, drho0dr2, drho0ds1, drho0ds2; double drho1dr1, drho1dr2, drho1ds1, drho1ds2; double drho1drm1[3], drho1drm2[3]; + //double drho1mdrm1[3], drho1mdrm2[3]; // msmeam params double drho2dr1, drho2dr2, drho2ds1, drho2ds2; double drho2drm1[3], drho2drm2[3]; + //double drho2mdrm1[3], drho2mdrm2[3]; // msmeam params double drho3dr1, drho3dr2, drho3ds1, drho3ds2; double drho3drm1[3], drho3drm2[3]; + //double drho3mdrm1[3], drho3mdrm2[3]; // msmeam params double dt1dr1, dt1dr2, dt1ds1, dt1ds2; double dt2dr1, dt2dr2, dt2ds1, dt2ds2; double dt3dr1, dt3dr2, dt3ds1, dt3ds2; @@ -128,6 +131,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int // write(1,*) "force_meamf: phip: ",phip // Compute pair densities and derivatives + invrei = 1.0 / this->re_meam[elti][elti]; ai = rij * invrei - 1.0; ro0i = this->rho0_meam[elti]; @@ -140,7 +144,14 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3i = ro0i * MathSpecial::fm_exp(-this->beta3_meam[elti] * ai); drhoa3i = -this->beta3_meam[elti] * invrei * rhoa3i; - //printf("%f %f %f %f %f\n", ro0i, drhoa0i, drhoa1i, drhoa2i, drhoa3i); + if (this->msmeamflag){ + rhoa1mi = ro0i * MathSpecial::fm_exp(-this->beta1m_meam[elti] * ai) * t1m_meam[elti]; + drhoa1mi = -this->beta1m_meam[elti] * invrei * rhoa1mi; + rhoa2mi = ro0i * MathSpecial::fm_exp(-this->beta2m_meam[elti] * ai) * t2m_meam[elti]; + drhoa2mi = -this->beta2m_meam[elti] * invrei * rhoa2mi; + rhoa3mi = ro0i * MathSpecial::fm_exp(-this->beta3m_meam[elti] * ai) * t3m_meam[elti]; + drhoa3mi = -this->beta3m_meam[elti] * invrei * rhoa3mi; + } if (elti != eltj) { invrej = 1.0 / this->re_meam[eltj][eltj]; @@ -155,7 +166,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3j = ro0j * MathSpecial::fm_exp(-this->beta3_meam[eltj] * aj); drhoa3j = -this->beta3_meam[eltj] * invrej * rhoa3j; - printf("^^^^^ check\n"); if (this->msmeamflag) { rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecial::fm_exp(-this->beta1m_meam[eltj] * aj); drhoa1mj = -this->beta1m_meam[eltj] * invrej * rhoa1mj; @@ -185,9 +195,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } } - //printf("%f %f %f %f %f\n", ro0i, drhoa0j, drhoa1j, drhoa2j, drhoa3j); - //printf("%f %f %f\n", drhoa1mj, drhoa2mj, drhoa3mj); - const double t1mi = this->t1_meam[elti]; const double t2mi = this->t2_meam[elti]; const double t3mi = this->t3_meam[elti]; @@ -195,8 +202,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int const double t2mj = this->t2_meam[eltj]; const double t3mj = this->t3_meam[eltj]; - //printf("%f %f %f %f %f %f\n", t1mi, t2mi, t3mi, t1mj, t2mj, t3mj); - if (this->ialloy == 1) { rhoa1j *= t1mj; rhoa2j *= t2mj; @@ -241,7 +246,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int arg3j3 = arg3j3 - arho3b[j][n] * delij[n]; } - // arhom args (msmeam) + // msmeam arhom args arg1i1m = 0.0; arg1j1m = 0.0; @@ -256,7 +261,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int for (p = n; p < 3; p++) { for (q = p; q < 3; q++) { arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; - printf("segfault here n p q: %d %d %d\n", n, p, q); arg1i3m = arg1i3m + arho3m[i][nv3] * arg; arg1j3m = arg1j3m - arho3m[j][nv3] * arg; nv3 = nv3 + 1; @@ -277,8 +281,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho0dr1 = drhoa0j * sij; drho0dr2 = drhoa0i * sij; - //printf("%f %f\n", drho0dr1, drho0dr2); - // rho1 terms a1 = 2 * sij / rij; drho1dr1 = a1 * (drhoa1j - rhoa1j / rij) * arg1i1; @@ -287,7 +289,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int for (m = 0; m < 3; m++) { drho1drm1[m] = a1 * rhoa1j * arho1[i][m]; drho1drm2[m] = -a1 * rhoa1i * arho1[j][m]; - //printf("%f %f\n", drho1drm1[m], drho1drm2[m]); } // rho2 terms @@ -305,7 +306,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho2drm1[m] = a2 * rhoa2j * drho2drm1[m]; drho2drm2[m] = -a2 * rhoa2i * drho2drm2[m]; } - printf("^^^^^ check 4\n"); + // rho3 terms rij3 = rij * rij2; a3 = 2 * sij / rij3; @@ -464,8 +465,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } - //printf("%f %f %f %f %f %f\n", dt1dr1, dt1dr2, dt2dr1, dt2dr2, dt3dr1, dt3dr2); - // Compute derivatives of total density wrt rij, sij and rij(3) get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpi); get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); @@ -473,23 +472,23 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int if (this->msmeamflag){ drhodr1 = dgamma1[i] * drho0dr1 + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + - dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + - dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + + dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); drhodr2 = dgamma1[j] * drho0dr2 + dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + - dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + - dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - + dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); for (m = 0; m < 3; m++) { drhodrm1[m] = 0.0; drhodrm2[m] = 0.0; drhodrm1[m] = dgamma2[i] * (t1i * (drho1drm1[m] - drho1mdrm1[m]) + - t2i * (drho2drm1[m] - drho2mdrm1[m]) + - t3i * (drho3drm1[m] - drho3mdrm1[m]) ); + t2i * (drho2drm1[m] - drho2mdrm1[m]) + + t3i * (drho3drm1[m] - drho3mdrm1[m]) ); drhodrm2[m] = dgamma2[j] * (t1j * (drho1drm2[m] - drho1mdrm2[m]) + - t2j * (drho2drm2[m] - drho2mdrm2[m]) + - t3j * (drho3drm2[m] - drho3mdrm2[m]) ); + t2j * (drho2drm2[m] - drho2mdrm2[m]) + + t3j * (drho3drm2[m] - drho3mdrm2[m]) ); } } else{ @@ -508,7 +507,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhodrm2[m] = dgamma2[j] * (t1j * drho1drm2[m] + t2j * drho2drm2[m] + t3j * drho3drm2[m]); } } - //printf("%f %f %f %f %f %f %f %f\n", drhodr1, drhodr2, drhodrm1[0], drhodrm1[1], drhodrm1[2], drhodrm2[0], drhodrm2[1], drhodrm2[2]); // Compute derivatives wrt sij, but only if necessary if (!iszero(dscrfcn[fnoffset + jn])) { @@ -586,16 +584,16 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } if (this->msmeamflag){ - drhods1 = dgamma1[i] * drho0ds1 + - dgamma2[i] * (dt1ds1 * rho1[i] + t1i * (drho1ds1 - drho1mds1) + - dt2ds1 * rho2[i] + t2i * (drho2ds1 - drho2mds1) + - dt3ds1 * rho3[i] + t3i * (drho3ds1 - drho3mds1)) - - dgamma3[i] * (shpi[0] * dt1ds1 + shpi[1] * dt2ds1 + shpi[2] * dt3ds1); - drhods2 = dgamma1[j] * drho0ds2 + - dgamma2[j] * (dt1ds2 * rho1[j] + t1j * (drho1ds2 - drho1mds2) + - dt2ds2 * rho2[j] + t2j * (drho2ds2 - drho2mds2) + - dt3ds2 * rho3[j] + t3j * (drho3ds2 - drho3mds2)) - - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); + drhods1 = dgamma1[i] * drho0ds1 + + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * (drho1ds1 - drho1mds1) + + dt2ds1 * rho2[i] + t2i * (drho2ds1 - drho2mds1) + + dt3ds1 * rho3[i] + t3i * (drho3ds1 - drho3mds1)) - + dgamma3[i] * (shpi[0] * dt1ds1 + shpi[1] * dt2ds1 + shpi[2] * dt3ds1); + drhods2 = dgamma1[j] * drho0ds2 + + dgamma2[j] * (dt1ds2 * rho1[j] + t1j * (drho1ds2 - drho1mds2) + + dt2ds2 * rho2[j] + t2j * (drho2ds2 - drho2mds2) + + dt3ds2 * rho3[j] + t3j * (drho3ds2 - drho3mds2)) - + dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); } else{ drhods1 = dgamma1[i] * drho0ds1 + @@ -607,11 +605,11 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt3ds2 * rho3[j] + t3j * drho3ds2) - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); } - - //printf("%f %f\n", drhods1, drhods2); } - // Compute derivatives of energy wrt rij, sij and rij[3] + // Compute derivatives of energy wrt rij, sij and rij[3] + // From this point on, MS-MEAM should not affect the code + dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; dUdsij = 0.0; if (!iszero(dscrfcn[fnoffset + jn])) { diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index f04f2acd1a..fb83a699ac 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -34,7 +34,8 @@ MEAM::MEAM(Memory* mem) gamma = dgamma1 = dgamma2 = dgamma3 = arho2b = nullptr; arho1 = arho2 = arho3 = arho3b = t_ave = tsq_ave = nullptr; // msmeam arrays - //arho1m = arho2m = arho2mb = arho3m = arho3mb = nullptr; + arho2mb = nullptr; + arho1m = arho2m = arho3m = arho3mb = nullptr; maxneigh = 0; scrfcn = dscrfcn = fcpair = nullptr; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 6a3c91115e..889840129a 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -144,7 +144,6 @@ void PairMEAM::compute(int eflag, int vflag) } comm->reverse_comm(this); - meam_inst->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, &eng_vdwl,eatom,ntype,type,map,scale,errorflag); if (errorflag) @@ -159,10 +158,8 @@ void PairMEAM::compute(int eflag, int vflag) double **vptr = nullptr; if (vflag_atom) vptr = vatom; - printf("^^^^^ before force loop\n"); for (ii = 0; ii < inum_half; ii++) { i = ilist_half[ii]; - printf("^^^^^ i: %d\n", i); meam_inst->meam_force(i,eflag_global,eflag_atom,vflag_global, vflag_atom,&eng_vdwl,eatom,ntype,type,map,scale,x, numneigh_half[i],firstneigh_half[i], @@ -170,7 +167,6 @@ void PairMEAM::compute(int eflag, int vflag) offset,f,vptr,virial); offset += numneigh_half[i]; } - printf("^^^^^ after force loop\n"); if (vflag_fdotr) virial_fdotr_compute(); } @@ -202,7 +198,6 @@ void PairMEAM::settings(int narg, char **arg) if (strcmp("ms", arg[0]) == 0){ msmeamflag = 1; meam_inst->msmeamflag = 1; - printf("^^^^^ msmeam flag on!\n"); } else error->all(FLERR, "Unknown pair style zero option {}", arg[0]); } @@ -471,8 +466,6 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) rozero[index] = values.next_double(); ibar[index] = values.next_int(); - //error->one(FLERR,"^^^^ DEBUG"); - if (!isone(t0[index])) error->one(FLERR,"Unsupported parameter in MEAM library file: t0!=1"); @@ -542,8 +535,6 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) nullptr, nullptr, nullptr, nullptr, nullptr); } - //error->one(FLERR,"^^^^ DEBUG"); - // set element masses for (int i = 0; i < nlibelements; i++) mass[i] = atwt[i]; @@ -665,6 +656,25 @@ int PairMEAM::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst->tsq_ave[j][0]; buf[m++] = meam_inst->tsq_ave[j][1]; buf[m++] = meam_inst->tsq_ave[j][2]; + + // msmeam params + if (this->msmeamflag){ + buf[m++] = meam_inst->arho2mb[j]; + buf[m++] = meam_inst->arho1m[j][0]; + buf[m++] = meam_inst->arho1m[j][1]; + buf[m++] = meam_inst->arho1m[j][2]; + buf[m++] = meam_inst->arho2m[j][0]; + buf[m++] = meam_inst->arho2m[j][1]; + buf[m++] = meam_inst->arho2m[j][2]; + buf[m++] = meam_inst->arho2m[j][3]; + buf[m++] = meam_inst->arho2m[j][4]; + buf[m++] = meam_inst->arho2m[j][5]; + for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3m[j][k]; + buf[m++] = meam_inst->arho3mb[j][0]; + buf[m++] = meam_inst->arho3mb[j][1]; + buf[m++] = meam_inst->arho3mb[j][2]; + } + } return m; @@ -708,6 +718,25 @@ void PairMEAM::unpack_forward_comm(int n, int first, double *buf) meam_inst->tsq_ave[i][0] = buf[m++]; meam_inst->tsq_ave[i][1] = buf[m++]; meam_inst->tsq_ave[i][2] = buf[m++]; + + // msmeam params + + if (this->msmeamflag){ + meam_inst->arho2mb[i] = buf[m++]; + meam_inst->arho1m[i][0] = buf[m++]; + meam_inst->arho1m[i][1] = buf[m++]; + meam_inst->arho1m[i][2] = buf[m++]; + meam_inst->arho2m[i][0] = buf[m++]; + meam_inst->arho2m[i][1] = buf[m++]; + meam_inst->arho2m[i][2] = buf[m++]; + meam_inst->arho2m[i][3] = buf[m++]; + meam_inst->arho2m[i][4] = buf[m++]; + meam_inst->arho2m[i][5] = buf[m++]; + for (k = 0; k < 10; k++) meam_inst->arho3m[i][k] = buf[m++]; + meam_inst->arho3mb[i][0] = buf[m++]; + meam_inst->arho3mb[i][1] = buf[m++]; + meam_inst->arho3mb[i][2] = buf[m++]; + } } } @@ -741,6 +770,25 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) buf[m++] = meam_inst->tsq_ave[i][0]; buf[m++] = meam_inst->tsq_ave[i][1]; buf[m++] = meam_inst->tsq_ave[i][2]; + + // msmeam params + + if (this->msmeamflag){ + buf[m++] = meam_inst->arho2mb[i]; + buf[m++] = meam_inst->arho1m[i][0]; + buf[m++] = meam_inst->arho1m[i][1]; + buf[m++] = meam_inst->arho1m[i][2]; + buf[m++] = meam_inst->arho2m[i][0]; + buf[m++] = meam_inst->arho2m[i][1]; + buf[m++] = meam_inst->arho2m[i][2]; + buf[m++] = meam_inst->arho2m[i][3]; + buf[m++] = meam_inst->arho2m[i][4]; + buf[m++] = meam_inst->arho2m[i][5]; + for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3m[i][k]; + buf[m++] = meam_inst->arho3mb[i][0]; + buf[m++] = meam_inst->arho3mb[i][1]; + buf[m++] = meam_inst->arho3mb[i][2]; + } } return m; From 5a8d191a4a7f05439edb5fae53783253200df9ac Mon Sep 17 00:00:00 2001 From: rohskopf Date: Thu, 12 Jan 2023 09:26:19 -0700 Subject: [PATCH 09/43] Correct force rho and arho parameters; need to fix get_densref function --- src/MEAM/meam.h | 2 +- src/MEAM/meam_dens_final.cpp | 316 +++++++++++++++++++++++++---------- src/MEAM/meam_dens_init.cpp | 57 +++++++ src/MEAM/meam_force.cpp | 99 ++++++++--- src/MEAM/meam_setup_done.cpp | 32 +++- src/MEAM/pair_meam.cpp | 24 ++- 6 files changed, 418 insertions(+), 112 deletions(-) diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index 454dd35873..5fdf84d460 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -259,7 +259,7 @@ class MEAM { double, double, double, double, double, int, int, lattice_t); void get_sijk(double, int, int, int, double *); void get_densref(double, int, int, double *, double *, double *, double *, double *, double *, - double *, double *); + double *, double *, double *, double *, double *, double *, double *, double *); // last 6 args for msmeam void interpolate_meam(int); public: diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index ea53ea38ff..234694473a 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -25,118 +25,258 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ double denom, rho_bkgd, Fl; double scaleii; + printf("meam_dens_final arho3m\n"); + printf("%f\n", arho3m[0][0]); + // Complete the calculation of density - for (i = 0; i < nlocal; i++) { - elti = fmap[type[i]]; - if (elti >= 0) { - scaleii = scale[type[i]][type[i]]; - rho1[i] = 0.0; - rho2[i] = -1.0 / 3.0 * arho2b[i] * arho2b[i]; - rho3[i] = 0.0; - for (m = 0; m < 3; m++) { - rho1[i] = rho1[i] + arho1[i][m] * arho1[i][m]; - rho3[i] = rho3[i] - 3.0 / 5.0 * arho3b[i][m] * arho3b[i][m]; - } - for (m = 0; m < 6; m++) { - rho2[i] = rho2[i] + this->v2D[m] * arho2[i][m] * arho2[i][m]; - } - for (m = 0; m < 10; m++) { - rho3[i] = rho3[i] + this->v3D[m] * arho3[i][m] * arho3[i][m]; - } - - if (rho0[i] > 0.0) { - if (this->ialloy == 1) { - t_ave[i][0] = fdiv_zero(t_ave[i][0], tsq_ave[i][0]); - t_ave[i][1] = fdiv_zero(t_ave[i][1], tsq_ave[i][1]); - t_ave[i][2] = fdiv_zero(t_ave[i][2], tsq_ave[i][2]); - } else if (this->ialloy == 2) { - t_ave[i][0] = this->t1_meam[elti]; - t_ave[i][1] = this->t2_meam[elti]; - t_ave[i][2] = this->t3_meam[elti]; - } else { - t_ave[i][0] = t_ave[i][0] / rho0[i]; - t_ave[i][1] = t_ave[i][1] / rho0[i]; - t_ave[i][2] = t_ave[i][2] / rho0[i]; + if (this->msmeamflag){ + for (i = 0; i < nlocal; i++) { + elti = fmap[type[i]]; + if (elti >= 0) { + scaleii = scale[type[i]][type[i]]; + rho1[i] = 0.0; + rho2[i] = -1.0 / 3.0 * (arho2b[i] * arho2b[i] + - arho2mb[i] * arho2mb[i]); + rho3[i] = 0.0; + for (m = 0; m < 3; m++) { + rho1[i] = rho1[i] + arho1[i][m] * arho1[i][m] + - arho1m[i][m] * arho1m[i][m]; + rho3[i] = rho3[i] - 3.0 / 5.0 * (arho3b[i][m] * arho3b[i][m] + - arho3mb[i][m] * arho3mb[i][m]); + } + for (m = 0; m < 6; m++) { + rho2[i] = rho2[i] + this->v2D[m] * (arho2[i][m] * arho2[i][m] + - arho2m[i][m] * arho2m[i][m]); + } + for (m = 0; m < 10; m++) { + rho3[i] = rho3[i] + this->v3D[m] * (arho3[i][m] * arho3[i][m] + - arho3m[i][m] * arho3m[i][m]); + printf("arho loop %f %f\n", arho3[i][m], arho3m[i][m]); } - } - gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; + // Compared to Greg's original, all of the t weightings are already accounted for. + // Code block for t_ave removed. + printf("gam rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); + gamma[i] = rho1[i] + rho2[i] + rho3[i]; + printf("gam check 0 %f\n", gamma[i]); - if (rho0[i] > 0.0) { - gamma[i] = gamma[i] / (rho0[i] * rho0[i]); - } + /* + if (rho0[i] > 0.0) { + if (this->ialloy == 1) { + t_ave[i][0] = fdiv_zero(t_ave[i][0], tsq_ave[i][0]); + t_ave[i][1] = fdiv_zero(t_ave[i][1], tsq_ave[i][1]); + t_ave[i][2] = fdiv_zero(t_ave[i][2], tsq_ave[i][2]); + } else if (this->ialloy == 2) { + t_ave[i][0] = this->t1_meam[elti]; + t_ave[i][1] = this->t2_meam[elti]; + t_ave[i][2] = this->t3_meam[elti]; + } else { + t_ave[i][0] = t_ave[i][0] / rho0[i]; + t_ave[i][1] = t_ave[i][1] / rho0[i]; + t_ave[i][2] = t_ave[i][2] / rho0[i]; + } + } - Z = get_Zij(this->lattce_meam[elti][elti]); + gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; + */ + printf("rho0 %f\n", rho0[i]); + if (rho0[i] > 0.0) { + gamma[i] = gamma[i] / (rho0[i] * rho0[i]); + } + printf("gam check1 %f\n", gamma[i]); - G = G_gam(gamma[i], this->ibar_meam[elti], errorflag); - if (errorflag != 0) - return; + Z = get_Zij(this->lattce_meam[elti][elti]); - get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shp); + G = G_gam(gamma[i], this->ibar_meam[elti], errorflag); + if (errorflag != 0) + return; - if (this->ibar_meam[elti] <= 0) { - Gbar = 1.0; - dGbar = 0.0; - } else { + get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shp); + + if (this->ibar_meam[elti] <= 0) { + Gbar = 1.0; + dGbar = 0.0; + printf("ibar meam <= 0\n"); + } else { + if (this->mix_ref_t == 1) { + gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); + } else { + gam = (this->t1_meam[elti] * shp[0] + this->t2_meam[elti] * shp[1] + this->t3_meam[elti] * shp[2]) / + (Z * Z); + } + Gbar = G_gam(gam, this->ibar_meam[elti], errorflag); + printf("ibar meam > 0\n"); + } + rho[i] = rho0[i] * G; + + // nothing to modify and DON'T USE mix_ref_t = 1 if (this->mix_ref_t == 1) { - gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); + if (this->ibar_meam[elti] <= 0) { + Gbar = 1.0; + dGbar = 0.0; + } else { + gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); + Gbar = dG_gam(gam, this->ibar_meam[elti], dGbar); + } + rho_bkgd = this->rho0_meam[elti] * Z * Gbar; } else { - gam = (this->t1_meam[elti] * shp[0] + this->t2_meam[elti] * shp[1] + this->t3_meam[elti] * shp[2]) / - (Z * Z); + if (this->bkgd_dyn == 1) { + rho_bkgd = this->rho0_meam[elti] * Z; + } else { + rho_bkgd = this->rho_ref_meam[elti]; + } } - Gbar = G_gam(gam, this->ibar_meam[elti], errorflag); - } - rho[i] = rho0[i] * G; + rhob = rho[i] / rho_bkgd; + denom = 1.0 / rho_bkgd; + + printf("dgam rhob denom %f %f\n", rhob, denom); + + G = dG_gam(gamma[i], this->ibar_meam[elti], dG); + + dgamma1[i] = (G - 2 * dG * gamma[i]) * denom; + + if (!iszero(rho0[i])) { + dgamma2[i] = (dG / rho0[i]) * denom; + } else { + dgamma2[i] = 0.0; + } + + // dgamma3 is nonzero only if we are using the "mixed" rule for + // computing t in the reference system (which is not correct, but + // included for backward compatibility + if (this->mix_ref_t == 1) { + dgamma3[i] = rho0[i] * G * dGbar / (Gbar * Z * Z) * denom; + } else { + dgamma3[i] = 0.0; + } + + Fl = embedding(this->A_meam[elti], this->Ec_meam[elti][elti], rhob, frhop[i]); + + if (eflag_either != 0) { + Fl *= scaleii; + if (eflag_global != 0) { + *eng_vdwl = *eng_vdwl + Fl; + } + if (eflag_atom != 0) { + eatom[i] = eatom[i] + Fl; + + } + } + } + } + } else{ + for (i = 0; i < nlocal; i++) { + elti = fmap[type[i]]; + if (elti >= 0) { + scaleii = scale[type[i]][type[i]]; + rho1[i] = 0.0; + rho2[i] = -1.0 / 3.0 * arho2b[i] * arho2b[i]; + rho3[i] = 0.0; + for (m = 0; m < 3; m++) { + rho1[i] = rho1[i] + arho1[i][m] * arho1[i][m]; + rho3[i] = rho3[i] - 3.0 / 5.0 * arho3b[i][m] * arho3b[i][m]; + } + for (m = 0; m < 6; m++) { + rho2[i] = rho2[i] + this->v2D[m] * arho2[i][m] * arho2[i][m]; + } + for (m = 0; m < 10; m++) { + rho3[i] = rho3[i] + this->v3D[m] * arho3[i][m] * arho3[i][m]; + } + + if (rho0[i] > 0.0) { + if (this->ialloy == 1) { + t_ave[i][0] = fdiv_zero(t_ave[i][0], tsq_ave[i][0]); + t_ave[i][1] = fdiv_zero(t_ave[i][1], tsq_ave[i][1]); + t_ave[i][2] = fdiv_zero(t_ave[i][2], tsq_ave[i][2]); + } else if (this->ialloy == 2) { + t_ave[i][0] = this->t1_meam[elti]; + t_ave[i][1] = this->t2_meam[elti]; + t_ave[i][2] = this->t3_meam[elti]; + } else { + t_ave[i][0] = t_ave[i][0] / rho0[i]; + t_ave[i][1] = t_ave[i][1] / rho0[i]; + t_ave[i][2] = t_ave[i][2] / rho0[i]; + } + } + + gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; + + if (rho0[i] > 0.0) { + gamma[i] = gamma[i] / (rho0[i] * rho0[i]); + } + + Z = get_Zij(this->lattce_meam[elti][elti]); + + G = G_gam(gamma[i], this->ibar_meam[elti], errorflag); + if (errorflag != 0) + return; + + get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shp); - if (this->mix_ref_t == 1) { if (this->ibar_meam[elti] <= 0) { Gbar = 1.0; dGbar = 0.0; } else { - gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); - Gbar = dG_gam(gam, this->ibar_meam[elti], dGbar); + if (this->mix_ref_t == 1) { + gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); + } else { + gam = (this->t1_meam[elti] * shp[0] + this->t2_meam[elti] * shp[1] + this->t3_meam[elti] * shp[2]) / + (Z * Z); + } + Gbar = G_gam(gam, this->ibar_meam[elti], errorflag); } - rho_bkgd = this->rho0_meam[elti] * Z * Gbar; - } else { - if (this->bkgd_dyn == 1) { - rho_bkgd = this->rho0_meam[elti] * Z; + rho[i] = rho0[i] * G; + + if (this->mix_ref_t == 1) { + if (this->ibar_meam[elti] <= 0) { + Gbar = 1.0; + dGbar = 0.0; + } else { + gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); + Gbar = dG_gam(gam, this->ibar_meam[elti], dGbar); + } + rho_bkgd = this->rho0_meam[elti] * Z * Gbar; } else { - rho_bkgd = this->rho_ref_meam[elti]; + if (this->bkgd_dyn == 1) { + rho_bkgd = this->rho0_meam[elti] * Z; + } else { + rho_bkgd = this->rho_ref_meam[elti]; + } } - } - rhob = rho[i] / rho_bkgd; - denom = 1.0 / rho_bkgd; + rhob = rho[i] / rho_bkgd; + denom = 1.0 / rho_bkgd; - G = dG_gam(gamma[i], this->ibar_meam[elti], dG); + G = dG_gam(gamma[i], this->ibar_meam[elti], dG); - dgamma1[i] = (G - 2 * dG * gamma[i]) * denom; + dgamma1[i] = (G - 2 * dG * gamma[i]) * denom; - if (!iszero(rho0[i])) { - dgamma2[i] = (dG / rho0[i]) * denom; - } else { - dgamma2[i] = 0.0; - } - - // dgamma3 is nonzero only if we are using the "mixed" rule for - // computing t in the reference system (which is not correct, but - // included for backward compatibility - if (this->mix_ref_t == 1) { - dgamma3[i] = rho0[i] * G * dGbar / (Gbar * Z * Z) * denom; - } else { - dgamma3[i] = 0.0; - } - - Fl = embedding(this->A_meam[elti], this->Ec_meam[elti][elti], rhob, frhop[i]); - - if (eflag_either != 0) { - Fl *= scaleii; - if (eflag_global != 0) { - *eng_vdwl = *eng_vdwl + Fl; + if (!iszero(rho0[i])) { + dgamma2[i] = (dG / rho0[i]) * denom; + } else { + dgamma2[i] = 0.0; } - if (eflag_atom != 0) { - eatom[i] = eatom[i] + Fl; - + + // dgamma3 is nonzero only if we are using the "mixed" rule for + // computing t in the reference system (which is not correct, but + // included for backward compatibility + if (this->mix_ref_t == 1) { + dgamma3[i] = rho0[i] * G * dGbar / (Gbar * Z * Z) * denom; + } else { + dgamma3[i] = 0.0; + } + + Fl = embedding(this->A_meam[elti], this->Ec_meam[elti][elti], rhob, frhop[i]); + + if (eflag_either != 0) { + Fl *= scaleii; + if (eflag_global != 0) { + *eng_vdwl = *eng_vdwl + Fl; + } + if (eflag_atom != 0) { + eatom[i] = eatom[i] + Fl; + + } } } } diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index f5980233d6..38f9387bc2 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -95,11 +95,19 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) rho0[i] = 0.0; arho2b[i] = 0.0; arho1[i][0] = arho1[i][1] = arho1[i][2] = 0.0; + if (this->msmeamflag) + arho1m[i][0] = arho1m[i][1] = arho1m[i][2] = 0.0; for (j = 0; j < 6; j++) arho2[i][j] = 0.0; + if (this->msmeamflag) + arho2m[i][j] = 0.0; for (j = 0; j < 10; j++) arho3[i][j] = 0.0; + if (this->msmeamflag) + arho3m[i][j] = 0.0; arho3b[i][0] = arho3b[i][1] = arho3b[i][2] = 0.0; + if (this->msmeamflag) + arho3mb[i][0] = arho3mb[i][1] = arho3mb[i][2] = 0.0; t_ave[i][0] = t_ave[i][1] = t_ave[i][2] = 0.0; tsq_ave[i][0] = tsq_ave[i][1] = tsq_ave[i][2] = 0.0; } @@ -294,6 +302,9 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn // double G,Gbar,gam,shp[3+1]; double ro0i, ro0j; double rhoa0i, rhoa1i, rhoa2i, rhoa3i, A1i, A2i, A3i; + // msmeam params + double rhoa1mj, rhoa2mj, rhoa3mj, A1mj, A2mj, A3mj; + double rhoa1mi, rhoa2mi, rhoa3mi, A1mi, A2mi, A3mi; elti = fmap[type[i]]; xtmp = x[i][0]; @@ -318,11 +329,22 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn rhoa1j = ro0j * MathSpecial::fm_exp(-this->beta1_meam[eltj] * aj) * sij; rhoa2j = ro0j * MathSpecial::fm_exp(-this->beta2_meam[eltj] * aj) * sij; rhoa3j = ro0j * MathSpecial::fm_exp(-this->beta3_meam[eltj] * aj) * sij; + if (this->msmeamflag){ + rhoa1mj = ro0j * this->t1m_meam[eltj] * MathSpecial::fm_exp(-this->beta1m_meam[eltj] * aj) * sij; + rhoa2mj = ro0j * this->t2m_meam[eltj] * MathSpecial::fm_exp(-this->beta2m_meam[eltj] * aj) * sij; + rhoa3mj = ro0j * this->t3m_meam[eltj] * MathSpecial::fm_exp(-this->beta3m_meam[eltj] * aj) * sij; + } rhoa0i = ro0i * MathSpecial::fm_exp(-this->beta0_meam[elti] * ai) * sij; rhoa1i = ro0i * MathSpecial::fm_exp(-this->beta1_meam[elti] * ai) * sij; rhoa2i = ro0i * MathSpecial::fm_exp(-this->beta2_meam[elti] * ai) * sij; rhoa3i = ro0i * MathSpecial::fm_exp(-this->beta3_meam[elti] * ai) * sij; + if (this->msmeamflag){ + rhoa1mi = ro0i * this->t1m_meam[elti] * MathSpecial::fm_exp(-this->beta1m_meam[elti] * ai) * sij; + rhoa2mi = ro0i * this->t2m_meam[elti] * MathSpecial::fm_exp(-this->beta2m_meam[elti] * ai) * sij; + rhoa3mi = ro0i * this->t3m_meam[elti] * MathSpecial::fm_exp(-this->beta3m_meam[elti] * ai) * sij; + } if (this->ialloy == 1) { + // this is used in Baske's test since they put t's in rhoa definitions rhoa1j = rhoa1j * this->t1_meam[eltj]; rhoa2j = rhoa2j * this->t2_meam[eltj]; rhoa3j = rhoa3j * this->t3_meam[eltj]; @@ -330,9 +352,13 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn rhoa2i = rhoa2i * this->t2_meam[elti]; rhoa3i = rhoa3i * this->t3_meam[elti]; } + printf("rhos1 %d %d %f %f %f %f\n", i, j, rhoa1i, rhoa1j, rhoa1mi, rhoa1mj); + printf("rhos2 %d %d %f %f %f %f\n", i, j, rhoa2i, rhoa2j, rhoa2mi, rhoa2mj); + printf("rhos3 %d %d %f %f %f %f\n", i, j, rhoa3i, rhoa3j, rhoa3mi, rhoa3mj); rho0[i] = rho0[i] + rhoa0j; rho0[j] = rho0[j] + rhoa0i; // For ialloy = 2, use single-element value (not average) + // Not used in MS-MEAM: For ialloy = 2, use single-element value (not average) if (this->ialloy != 2) { t_ave[i][0] = t_ave[i][0] + this->t1_meam[eltj] * rhoa0j; t_ave[i][1] = t_ave[i][1] + this->t2_meam[eltj] * rhoa0j; @@ -360,18 +386,49 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn A3i = rhoa3i / (rij2 * rij); nv2 = 0; nv3 = 0; + if (this->msmeamflag){ + arho2mb[i] = arho2mb[i] + rhoa2mj; + arho2mb[j] = arho2mb[j] + rhoa2mi; + A1mj = rhoa1mj/rij; + A2mj = rhoa2mj/rij2; + A3mj = rhoa3mj/(rij2*rij); + A1mi = rhoa1mi/rij; + A2mi = rhoa2mi/rij2; + A3mi = rhoa3mi/(rij2*rij); + } + printf("arho2mb i j %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); for (m = 0; m < 3; m++) { arho1[i][m] = arho1[i][m] + A1j * delij[m]; arho1[j][m] = arho1[j][m] - A1i * delij[m]; arho3b[i][m] = arho3b[i][m] + rhoa3j * delij[m] / rij; arho3b[j][m] = arho3b[j][m] - rhoa3i * delij[m] / rij; + if (this->msmeamflag){ + arho1m[i][m] = arho1m[i][m] + A1mj*delij[m]; + arho1m[j][m] = arho1m[j][m] - A1mi*delij[m]; + arho3mb[i][m] = arho3mb[i][m] + rhoa3mj*delij[m] / rij; + arho3mb[j][m] = arho3mb[j][m] - rhoa3mi*delij[m] / rij; + } + printf("arho1m %f %f\n", arho1m[i][m], arho1m[j][m]); + printf("arho3mb %f %f\n", arho3mb[i][m], arho3mb[j][m]); for (n = m; n < 3; n++) { arho2[i][nv2] = arho2[i][nv2] + A2j * delij[m] * delij[n]; arho2[j][nv2] = arho2[j][nv2] + A2i * delij[m] * delij[n]; + if (this->msmeamflag){ + arho2m[i][nv2] = arho2m[i][nv2] + A2mj*delij[m] * delij[n]; + arho2m[j][nv2] = arho2m[j][nv2] + A2mi*delij[m] * delij[n]; + } + //printf("delij %f %f\n", delij[m], delij[n]); + printf("arho2m %d %d %f %f\n", nv2, m, arho2m[i][nv2], arho2m[j][nv2]); nv2 = nv2 + 1; for (p = n; p < 3; p++) { arho3[i][nv3] = arho3[i][nv3] + A3j * delij[m] * delij[n] * delij[p]; arho3[j][nv3] = arho3[j][nv3] - A3i * delij[m] * delij[n] * delij[p]; + if (this->msmeamflag){ + arho3m[i][nv3] = arho3m[i][nv3] + A3mj*delij[m]*delij[n]*delij[p]; + arho3m[j][nv3] = arho3m[j][nv3] - A3mi*delij[m]*delij[n]*delij[p]; + } + //arho3m[0][0]=500.0; + printf("arho3m %d %f %f\n", p, arho3m[i][nv3], arho3m[j][nv3]); nv3 = nv3 + 1; } } diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 0d48c1fbc8..20a6112244 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -75,6 +75,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double drho3mdr1, drho3mdr2, drho3mds1, drho3mds2; double drho3mdrm1[3], drho3mdrm2[3]; + printf("forces f %d %f\n", i, f[0][0]); + third = 1.0 / 3.0; sixth = 1.0 / 6.0; @@ -86,7 +88,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int xitmp = x[i][0]; yitmp = x[i][1]; zitmp = x[i][2]; - //printf("%f %f %f\n", xitmp, yitmp, zitmp); + printf("xtmp ytmp ztmp: %f %f %f\n", xitmp, yitmp, zitmp); // Treat each pair @@ -95,6 +97,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int eltj = fmap[type[j]]; scaleij = scale[type[i]][type[j]]; + printf("in j loop %d %d %d %d %f\n", i, j, eltj, type[j], scrfcn[fnoffset + jn]); if (!iszero(scrfcn[fnoffset + jn]) && eltj >= 0) { sij = scrfcn[fnoffset + jn] * fcpair[fnoffset + jn]; @@ -106,7 +109,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int if (rij2 < this->cutforcesq) { rij = sqrt(rij2); recip = 1.0 / rij; - + printf("forces, sij, rij = %f %f for i = %d and j = %d\n", sij, rij, i, j); // Compute phi and phip ind = this->eltind[elti][eltj]; pp = rij * this->rdrar; @@ -116,6 +119,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int pp = std::min(pp, 1.0); phi = ((this->phirar3[ind][kk] * pp + this->phirar2[ind][kk]) * pp + this->phirar1[ind][kk]) * pp + this->phirar[ind][kk]; phip = (this->phirar6[ind][kk] * pp + this->phirar5[ind][kk]) * pp + this->phirar4[ind][kk]; + printf("--- phi and phip i = %d ---\n", i); + printf("phi %f %f\n", this->phirar3[ind][kk], this->phirar2[ind][kk]); + printf("phi2 %f %f\n", this->phirar1[ind][kk], this->phirar[ind][kk]); + printf("phip %f %f\n", this->phirar6[ind][kk], this->phirar5[ind][kk]); + printf("phip2 %f\n", this->phirar4[ind][kk]); + printf("-----"); if (eflag_either != 0) { double phi_sc = phi * scaleij; @@ -202,6 +211,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int const double t2mj = this->t2_meam[eltj]; const double t3mj = this->t3_meam[eltj]; + // ialloy mod not needed in msmeam according to fortran code + // if we remove this, need to multiply rhoali and rhoalj above by t vars if (this->ialloy == 1) { rhoa1j *= t1mj; rhoa2j *= t2mj; @@ -217,6 +228,11 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhoa3i *= t3mi; } + printf("forces, rhoali %f %f %f %f\n", rhoa0i, rhoa1i, rhoa2i, rhoa3i); + printf("forces, rhoalmi %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi); + printf("forces, rhoalj %f %f %f %f\n", rhoa0j, rhoa1j, rhoa2j, rhoa3j); + printf("forces, rhoalmj %f %f %f\n", rhoa1mj, rhoa2mj, rhoa3mj); + nv2 = 0; nv3 = 0; arg1i1 = 0.0; @@ -248,6 +264,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int // msmeam arhom args + nv2 = 0; + nv3 = 0; arg1i1m = 0.0; arg1j1m = 0.0; arg1i2m = 0.0; @@ -261,22 +279,29 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int for (p = n; p < 3; p++) { for (q = p; q < 3; q++) { arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; - arg1i3m = arg1i3m + arho3m[i][nv3] * arg; - arg1j3m = arg1j3m - arho3m[j][nv3] * arg; + arg1i3m = arg1i3m - arho3m[i][nv3] * arg; + arg1j3m = arg1j3m + arho3m[j][nv3] * arg; + //printf("^^^ arho3m[i&j][nv3] arg %f %f\n", arho3m[j][nv3], arg); nv3 = nv3 + 1; } arg = delij[n] * delij[p] * this->v2D[nv2]; arg1i2m = arg1i2m + arho2m[i][nv2] * arg; arg1j2m = arg1j2m + arho2m[j][nv2] * arg; + printf(" arho2m[j][nv2] %d %d %f\n", j, nv2, arho2m[j][nv2]); nv2 = nv2 + 1; } - arg1i1m = arg1i1m + arho1m[i][n] * delij[n]; - arg1j1m = arg1j1m - arho1m[j][n] * delij[n]; - arg3i3m = arg3i3m + arho3mb[i][n] * delij[n]; - arg3j3m = arg3j3m - arho3mb[j][n] * delij[n]; + arg1i1m = arg1i1m - arho1m[i][n] * delij[n]; + arg1j1m = arg1j1m + arho1m[j][n] * delij[n]; + arg3i3m = arg3i3m - arho3mb[i][n] * delij[n]; + arg3j3m = arg3j3m + arho3mb[j][n] * delij[n]; } } + printf("rho1 terms arg1i %d %d %f %f\n", i, j, arg1i1, arg1i1m); + printf("rho1 terms arg1j %d %d %f %f\n", i, j, arg1j1, arg1j1m); + printf("rho1 terms rhoa1j %d %d %f %f\n", i, j, rhoa1j, rhoa1mj); + printf("rho1 terms drhoa1j %d %d %f %f\n", i,j, drhoa1j, drhoa1mj); + // rho0 terms drho0dr1 = drhoa0j * sij; drho0dr2 = drhoa0i * sij; @@ -348,6 +373,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int a2 = 2 * sij / rij2; drho2mdr1 = a2 * (drhoa2mj - 2 * rhoa2mj / rij) * arg1i2m - 2.0 / 3.0 * arho2mb[i] * drhoa2mj * sij; drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - 2.0 / 3.0 * arho2mb[j] * drhoa2mi * sij; + printf(" drho2mdr arho %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); + printf(" drhoa rhoa arg1 %f %f %f\n", drhoa2mi, rhoa2mi, arg1j2m); a2 = 4 * sij / rij2; for (m = 0; m < 3; m++) { drho2mdrm1[m] = 0.0; @@ -360,16 +387,21 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; } + printf("forces drho2 %f %f %f %f\n", drho2drm1[0], drho2mdrm1[0], drho2drm2[0], drho2mdrm2[0]); + // rho3m terms rij3 = rij * rij2; a3 = 2 * sij / rij3; a3a = 6.0 / 5.0 * sij / rij; + printf("args %f %f %f %f\n", arg1i3m, arg3i3m, arg1j3m, arg3j3m); drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; drho3mdr1 *= -1.0; drho3mdr2 *= -1.0; + a3 = 6 * sij / rij3; a3a = 6 * sij / (5 * rij); + printf("forces drho3mdr %f %f\n", drho3mdr1, drho3mdr2); for (m = 0; m < 3; m++) { drho3mdrm1[m] = 0.0; drho3mdrm2[m] = 0.0; @@ -394,6 +426,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3mdrm2[m] = 0.0; } + printf("rho2 terms drho2dr1 %f %f\n", drho2dr1, drho2mdr1); + printf("rho2 terms drho2dr2 %f %f\n", drho2dr2, drho2mdr2); + printf("rho2 terms %f %f\n", drho2drm1[0], drho2mdrm1[0]); + printf("rho2 terms %f %f\n", drho2drm2[0], drho2mdrm2[0]); + + // compute derivatives of weighting functions t wrt rij // weighting functions t set to unity for MS-MEAM @@ -470,25 +508,37 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); if (this->msmeamflag){ + printf("test rhodg %f %f %f\n", dgamma1[i], dgamma2[i], dgamma3[i]); + printf("test rhod dtdr %f %f %f\n", dt1dr1, dt2dr1, dt3dr1); + printf("test rhod rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); + printf("test rhod t %f %f %f\n", t1i, t2i, t3i); + printf(" drhodr1 terms %f %f %f\n", drho1dr1, drho2dr1, drho3dr1); + printf(" %f %f %f\n", drho1mdr1, drho2mdr1, drho3mdr1); + printf(" %f %f %f\n", shpi[0], shpi[1], shpi[2]); + printf(" %f\n", drho0dr1); + printf(" %f %f %f\n", dgamma1[i], dgamma2[i], dgamma3[i]); + printf(" %f %f %f\n", drho1dr2, drho2dr2, drho3dr2); + printf(" %f %f %f\n", drho1mdr2, drho2mdr2, drho3mdr2); drhodr1 = dgamma1[i] * drho0dr1 + - dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + - dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + - dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - - dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + + dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - + dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); drhodr2 = dgamma1[j] * drho0dr2 + - dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + - dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + - dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + + dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - + dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + printf(" drhodr1&2 %f %f\n", drhodr1, drhodr2); for (m = 0; m < 3; m++) { drhodrm1[m] = 0.0; drhodrm2[m] = 0.0; drhodrm1[m] = dgamma2[i] * (t1i * (drho1drm1[m] - drho1mdrm1[m]) + - t2i * (drho2drm1[m] - drho2mdrm1[m]) + - t3i * (drho3drm1[m] - drho3mdrm1[m]) ); + t2i * (drho2drm1[m] - drho2mdrm1[m]) + + t3i * (drho3drm1[m] - drho3mdrm1[m]) ); drhodrm2[m] = dgamma2[j] * (t1j * (drho1drm2[m] - drho1mdrm2[m]) + - t2j * (drho2drm2[m] - drho2mdrm2[m]) + - t3j * (drho3drm2[m] - drho3mdrm2[m]) ); + t2j * (drho2drm2[m] - drho2mdrm2[m]) + + t3j * (drho3drm2[m] - drho3mdrm2[m]) ); } } else{ @@ -508,8 +558,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } } + printf("rhod terms drhodr1 %f %f\n", drhodr1, drhodr2); + printf("rhod terms drhodr1 %f %f\n", drhodrm1[0], drhodrm2[0]); + // Compute derivatives wrt sij, but only if necessary if (!iszero(dscrfcn[fnoffset + jn])) { + printf("computing derivatives wrt sij\n"); drho0ds1 = rhoa0j; drho0ds2 = rhoa0i; a1 = 2.0 / rij; @@ -612,6 +666,11 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; dUdsij = 0.0; + printf("--- compute derivatives of energy wrt ...\n"); + printf("phip sij %f %f\n", phip,sij); + printf("drhodr %f %f\n", drhodr1, drhodr2); + printf("fp %f %f\n", frhop[i], frhop[j]); + printf("dUdrij %f\n", dUdrij); if (!iszero(dscrfcn[fnoffset + jn])) { dUdsij = phi + frhop[i] * drhods1 + frhop[j] * drhods2; } diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 1d7598d2c0..578f23caf2 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -213,15 +213,20 @@ void MEAM::compute_pair_meam() memory->create(this->phirar5, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar5"); memory->create(this->phirar6, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar6"); + printf("--- compute_pair_meam ---\n"); // loop over pairs of element types nv2 = 0; for (a = 0; a < this->neltypes; a++) { for (b = a; b < this->neltypes; b++) { + + printf("%u\n", this->lattce_meam[a][b]); + printf("%f %f %f\n", this->Cmin_meam[a][a][b], this->Cmax_meam[a][a][b], this->stheta_meam[a][b]); // loop over r values and compute for (j = 0; j < this->nr; j++) { r = j * this->dr; this->phir[nv2][j] = phi_meam(r, a, b); + printf("%f\n", this->phir[nv2][j]); // if using second-nearest neighbor, solve recursive problem // (see Lee and Baskes, PRB 62(13):8564 eqn.(21)) @@ -333,6 +338,12 @@ double MEAM::phi_meam(double r, int a, int b) lattice_t latta /*unused:,lattb*/; double rho_bkgd1, rho_bkgd2; double b11s, b22s; + // msmeam params + double t1m1av, t2m1av, t3m1av, t1m2av, t2m2av, t3m2av; + double rhoa1m1, rhoa2m1, rhoa3m1; + double rhoa1m2, rhoa2m2, rhoa3m2; + double rho1m1, rho2m1, rho3m1; + double rho1m2, rho2m2, rho3m2; double phi_m = 0.0; @@ -345,7 +356,16 @@ double MEAM::phi_meam(double r, int a, int b) Z2 = get_Zij(this->lattce_meam[b][b]); Z12 = get_Zij(this->lattce_meam[a][b]); - get_densref(r, a, b, &rho01, &rho11, &rho21, &rho31, &rho02, &rho12, &rho22, &rho32); + // this function has extra args for msmeam + if (this->msmeamflag){ + get_densref(r, a, b, &rho01, &rho11, &rho21, &rho31, &rho02, &rho12, &rho22, &rho32, + &rho1m1, &rho2m1, &rho3m1, + &rho1m2, &rho2m2, &rho3m2); + } else{ + get_densref(r, a, b, &rho01, &rho11, &rho21, &rho31, &rho02, &rho12, &rho22, &rho32, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr); + } // if densities are too small, numerical problems may result; just return zero if (rho01 <= 1e-14 && rho02 <= 1e-14) @@ -653,7 +673,9 @@ void MEAM::get_sijk(double C, int i, int j, int k, double* sijk) //------------------------------------------------------------------------------c // Calculate density functions, assuming reference configuration void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, double* rho21, double* rho31, - double* rho02, double* rho12, double* rho22, double* rho32) + double* rho02, double* rho12, double* rho22, double* rho32, + double* rho1m1, double* rho2m1, double* rho3m1, + double* rho1m2, double* rho2m2, double* rho3m2) { double a1, a2; double s[3]; @@ -861,7 +883,12 @@ void MEAM::interpolate_meam(int ind) this->rdrar = 1.0 / drar; // phir interp + printf("--- phir interp ---\n"); + + printf("nrar %d\n", this->nrar); + //printf("phir:\n"); for (j = 0; j < this->nrar; j++) { + //printf("%f\n", phir[ind][j]); this->phirar[ind][j] = this->phir[ind][j]; } this->phirar1[ind][0] = this->phirar[ind][1] - this->phirar[ind][0]; @@ -889,4 +916,5 @@ void MEAM::interpolate_meam(int ind) this->phirar5[ind][j] = 2.0 * this->phirar2[ind][j] / drar; this->phirar6[ind][j] = 3.0 * this->phirar3[ind][j] / drar; } + printf("-----\n"); } diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 889840129a..9355e8b364 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -142,8 +142,9 @@ void PairMEAM::compute(int eflag, int vflag) offset); offset += numneigh_half[i]; } - + printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->reverse_comm(this); + printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); meam_inst->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, &eng_vdwl,eatom,ntype,type,map,scale,errorflag); if (errorflag) @@ -748,6 +749,7 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) m = 0; last = first + n; + //printf("pack revcomm last %d\n", last); for (i = first; i < last; i++) { buf[m++] = meam_inst->rho0[i]; buf[m++] = meam_inst->arho2b[i]; @@ -801,6 +803,7 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) int i,j,k,m; m = 0; + //printf("unpack revcomm n %d\n", n); for (i = 0; i < n; i++) { j = list[i]; meam_inst->rho0[j] += buf[m++]; @@ -824,7 +827,26 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) meam_inst->tsq_ave[j][0] += buf[m++]; meam_inst->tsq_ave[j][1] += buf[m++]; meam_inst->tsq_ave[j][2] += buf[m++]; + + if (this->msmeamflag){ + meam_inst->arho2mb[j] += buf[m++]; + meam_inst->arho1m[j][0] += buf[m++]; + meam_inst->arho1m[j][1] += buf[m++]; + meam_inst->arho1m[j][2] += buf[m++]; + meam_inst->arho2m[j][0] += buf[m++]; + meam_inst->arho2m[j][1] += buf[m++]; + meam_inst->arho2m[j][2] += buf[m++]; + meam_inst->arho2m[j][3] += buf[m++]; + meam_inst->arho2m[j][4] += buf[m++]; + meam_inst->arho2m[j][5] += buf[m++]; + for (k = 0; k < 10; k++) meam_inst->arho3m[j][k] += buf[m++]; + meam_inst->arho3mb[j][0] += buf[m++]; + meam_inst->arho3mb[j][1] += buf[m++]; + meam_inst->arho3mb[j][2] += buf[m++]; + } } + + } /* ---------------------------------------------------------------------- From 03838f06f87d1e21c694676b707213f249455228 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Thu, 12 Jan 2023 19:28:10 -0700 Subject: [PATCH 10/43] Zero arrays in dens setup to prevent forces from growing each timestep --- src/MEAM/arho2 | 175 +++++++++++++++++++++++++++++++++++ src/MEAM/meam_dens_init.cpp | 23 +++-- src/MEAM/meam_force.cpp | 3 +- src/MEAM/meam_setup_done.cpp | 123 ++++++++++++++++++++---- src/MEAM/pair_meam.cpp | 17 +++- 5 files changed, 310 insertions(+), 31 deletions(-) create mode 100644 src/MEAM/arho2 diff --git a/src/MEAM/arho2 b/src/MEAM/arho2 new file mode 100644 index 0000000000..57c3b47f17 --- /dev/null +++ b/src/MEAM/arho2 @@ -0,0 +1,175 @@ +./pair_meam.cpp: meam_inst->meam_dens_setup(atom->nmax, nall, n); +./pair_meam.cpp: printf("before meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); +./pair_meam.cpp: meam_inst->meam_dens_init(i,ntype,type,map,x, +./pair_meam.cpp: printf("after meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); +./pair_meam.cpp: printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); +./pair_meam.cpp: printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); +./pair_meam.cpp: meam_inst->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, +./pair_meam.cpp: printf("before forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); +./pair_meam.cpp: printf("after forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); +./pair_meam.cpp: meam_inst->meam_force(i,eflag_global,eflag_atom,vflag_global, +./pair_meam.cpp: meam_inst->msmeamflag = 0; +./pair_meam.cpp: meam_inst->msmeamflag = 1; +./pair_meam.cpp: meam_inst->meam_setup_done(&cutmax); +./pair_meam.cpp: meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), +./pair_meam.cpp: meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), +./pair_meam.cpp: meam_inst->meam_setup_param(which,value,nindex,index,&errorflag); +./pair_meam.cpp: buf[m++] = meam_inst->rho0[j]; +./pair_meam.cpp: buf[m++] = meam_inst->rho1[j]; +./pair_meam.cpp: buf[m++] = meam_inst->rho2[j]; +./pair_meam.cpp: buf[m++] = meam_inst->rho3[j]; +./pair_meam.cpp: buf[m++] = meam_inst->frhop[j]; +./pair_meam.cpp: buf[m++] = meam_inst->gamma[j]; +./pair_meam.cpp: buf[m++] = meam_inst->dgamma1[j]; +./pair_meam.cpp: buf[m++] = meam_inst->dgamma2[j]; +./pair_meam.cpp: buf[m++] = meam_inst->dgamma3[j]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2b[j]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][3]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][4]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][5]; +./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3[j][k]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3b[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3b[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3b[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->t_ave[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->t_ave[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->t_ave[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2mb[j]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1m[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1m[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1m[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][3]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][4]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][5]; +./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3m[j][k]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[j][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[j][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[j][2]; +./pair_meam.cpp: meam_inst->rho0[i] = buf[m++]; +./pair_meam.cpp: meam_inst->rho1[i] = buf[m++]; +./pair_meam.cpp: meam_inst->rho2[i] = buf[m++]; +./pair_meam.cpp: meam_inst->rho3[i] = buf[m++]; +./pair_meam.cpp: meam_inst->frhop[i] = buf[m++]; +./pair_meam.cpp: meam_inst->gamma[i] = buf[m++]; +./pair_meam.cpp: meam_inst->dgamma1[i] = buf[m++]; +./pair_meam.cpp: meam_inst->dgamma2[i] = buf[m++]; +./pair_meam.cpp: meam_inst->dgamma3[i] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2b[i] = buf[m++]; +./pair_meam.cpp: meam_inst->arho1[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->arho1[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->arho1[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2[i][3] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2[i][4] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2[i][5] = buf[m++]; +./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3[i][k] = buf[m++]; +./pair_meam.cpp: meam_inst->arho3b[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->arho3b[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->arho3b[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->t_ave[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->t_ave[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->t_ave[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->tsq_ave[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->tsq_ave[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->tsq_ave[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2mb[i] = buf[m++]; +./pair_meam.cpp: meam_inst->arho1m[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->arho1m[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->arho1m[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[i][2] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[i][3] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[i][4] = buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[i][5] = buf[m++]; +./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3m[i][k] = buf[m++]; +./pair_meam.cpp: meam_inst->arho3mb[i][0] = buf[m++]; +./pair_meam.cpp: meam_inst->arho3mb[i][1] = buf[m++]; +./pair_meam.cpp: meam_inst->arho3mb[i][2] = buf[m++]; +./pair_meam.cpp: buf[m++] = meam_inst->rho0[i]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2b[i]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][3]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][4]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][5]; +./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3[i][k]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3b[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3b[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3b[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->t_ave[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->t_ave[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->t_ave[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2mb[i]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1m[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1m[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho1m[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][2]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][3]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][4]; +./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][5]; +./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3m[i][k]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[i][0]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[i][1]; +./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[i][2]; +./pair_meam.cpp: meam_inst->rho0[j] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2b[j] += buf[m++]; +./pair_meam.cpp: meam_inst->arho1[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->arho1[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->arho1[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2[j][3] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2[j][4] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2[j][5] += buf[m++]; +./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3[j][k] += buf[m++]; +./pair_meam.cpp: meam_inst->arho3b[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->arho3b[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->arho3b[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->t_ave[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->t_ave[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->t_ave[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->tsq_ave[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->tsq_ave[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->tsq_ave[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2mb[j] += buf[m++]; +./pair_meam.cpp: meam_inst->arho1m[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->arho1m[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->arho1m[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[j][2] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[j][3] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[j][4] += buf[m++]; +./pair_meam.cpp: meam_inst->arho2m[j][5] += buf[m++]; +./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3m[j][k] += buf[m++]; +./pair_meam.cpp: meam_inst->arho3mb[j][0] += buf[m++]; +./pair_meam.cpp: meam_inst->arho3mb[j][1] += buf[m++]; +./pair_meam.cpp: meam_inst->arho3mb[j][2] += buf[m++]; +./pair_meam.cpp: double bytes = 11 * meam_inst->nmax * sizeof(double); +./pair_meam.cpp: bytes += (double)(3 + 6 + 10 + 3 + 3 + 3) * meam_inst->nmax * sizeof(double); +./pair_meam.cpp: bytes += (double)3 * meam_inst->maxneigh * sizeof(double); diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index 38f9387bc2..802f811071 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -90,27 +90,36 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) } // zero out local arrays - + printf("^^^ zero out local arrays in mean_dens_init\n"); for (i = 0; i < nall; i++) { rho0[i] = 0.0; arho2b[i] = 0.0; arho1[i][0] = arho1[i][1] = arho1[i][2] = 0.0; - if (this->msmeamflag) + if (this->msmeamflag){ + arho2mb[i] = 0.0; arho1m[i][0] = arho1m[i][1] = arho1m[i][2] = 0.0; - for (j = 0; j < 6; j++) + } + for (j = 0; j < 6; j++){ arho2[i][j] = 0.0; - if (this->msmeamflag) + if (this->msmeamflag){ arho2m[i][j] = 0.0; - for (j = 0; j < 10; j++) + } + } + for (j = 0; j < 10; j++){ arho3[i][j] = 0.0; - if (this->msmeamflag) + if (this->msmeamflag){ arho3m[i][j] = 0.0; + } + } arho3b[i][0] = arho3b[i][1] = arho3b[i][2] = 0.0; - if (this->msmeamflag) + if (this->msmeamflag){ arho3mb[i][0] = arho3mb[i][1] = arho3mb[i][2] = 0.0; + } t_ave[i][0] = t_ave[i][1] = t_ave[i][2] = 0.0; tsq_ave[i][0] = tsq_ave[i][1] = tsq_ave[i][2] = 0.0; } + + printf("^^^ arho3m %f\n", arho3m[0][0]); } void diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 20a6112244..bca423f563 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -75,6 +75,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double drho3mdr1, drho3mdr2, drho3mds1, drho3mds2; double drho3mdrm1[3], drho3mdrm2[3]; + printf("----- begin meam_force -----\n"); printf("forces f %d %f\n", i, f[0][0]); third = 1.0 / 3.0; @@ -662,7 +663,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } // Compute derivatives of energy wrt rij, sij and rij[3] - // From this point on, MS-MEAM should not affect the code + // MS-MEAM affects phip dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; dUdsij = 0.0; diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 578f23caf2..c3dfc8c7fc 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -213,20 +213,20 @@ void MEAM::compute_pair_meam() memory->create(this->phirar5, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar5"); memory->create(this->phirar6, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar6"); - printf("--- compute_pair_meam ---\n"); + //printf("--- compute_pair_meam ---\n"); // loop over pairs of element types nv2 = 0; for (a = 0; a < this->neltypes; a++) { for (b = a; b < this->neltypes; b++) { - printf("%u\n", this->lattce_meam[a][b]); - printf("%f %f %f\n", this->Cmin_meam[a][a][b], this->Cmax_meam[a][a][b], this->stheta_meam[a][b]); + //printf("%u\n", this->lattce_meam[a][b]); + //printf("%f %f %f\n", this->Cmin_meam[a][a][b], this->Cmax_meam[a][a][b], this->stheta_meam[a][b]); // loop over r values and compute for (j = 0; j < this->nr; j++) { r = j * this->dr; this->phir[nv2][j] = phi_meam(r, a, b); - printf("%f\n", this->phir[nv2][j]); + //printf("%f\n", this->phir[nv2][j]); // if using second-nearest neighbor, solve recursive problem // (see Lee and Baskes, PRB 62(13):8564 eqn.(21)) @@ -367,12 +367,17 @@ double MEAM::phi_meam(double r, int a, int b) nullptr, nullptr, nullptr); } + //printf("--- phi_meam after densref ---\n"); + //printf("rhoim1 %f %f %f\n", rho1m1, rho2m1, rho3m1); + //printf("rhoim2 %f %f %f\n", rho1m2, rho2m2, rho3m2); + // if densities are too small, numerical problems may result; just return zero if (rho01 <= 1e-14 && rho02 <= 1e-14) return 0.0; // calculate average weighting factors for the reference structure if (this->lattce_meam[a][b] == C11) { + // note ialloy and t_ave not used in MS-MEAM if (this->ialloy == 2) { t11av = this->t1_meam[a]; t12av = this->t1_meam[b]; @@ -394,6 +399,12 @@ double MEAM::phi_meam(double r, int a, int b) get_tavref(&t11av, &t21av, &t31av, &t12av, &t22av, &t32av, this->t1_meam[a], this->t2_meam[a], this->t3_meam[a], this->t1_meam[b], this->t2_meam[b], this->t3_meam[b], r, a, b, this->lattce_meam[a][b]); + // msmeam - call twice with different sets of variables + if (this->msmeamflag){ + get_tavref(&t1m1av, &t2m1av, &t3m1av, &t1m2av, &t2m2av, &t3m2av, this->t1m_meam[a], this->t2m_meam[a], + this->t3m_meam[a], this->t1m_meam[b], this->t2m_meam[b], this->t3m_meam[b], r, a, b, + this->lattce_meam[a][b]); + } } // for c11b structure, calculate background electron densities @@ -440,17 +451,34 @@ double MEAM::phi_meam(double r, int a, int b) rho0_1 = this->rho0_meam[a] * Z1 * G1; rho0_2 = this->rho0_meam[b] * Z2 * G2; } - Gam1 = (t11av * rho11 + t21av * rho21 + t31av * rho31); - if (rho01 < 1.0e-14) - Gam1 = 0.0; - else - Gam1 = Gam1 / (rho01 * rho01); + // msmeam modified: no additional use of t's here. All included in definitions of rho's (in fortran) - Gam2 = (t12av * rho12 + t22av * rho22 + t32av * rho32); - if (rho02 < 1.0e-14) - Gam2 = 0.0; - else - Gam2 = Gam2 / (rho02 * rho02); + if (this->msmeamflag){ + Gam1 = rho11 + rho21 + rho31 - (rho1m1 + rho2m1 + rho3m1); + Gam1 = Gam1/(rho01 * rho01); + Gam2 = rho12 + rho22 + rho32 - (rho1m2 + rho2m2 + rho3m2); + Gam2 = Gam2/(rho02 * rho02); + /* + printf("Gam %f %f\n", Gam1, Gam2); + printf("rhoim1 %f %f %f\n", rho1m1, rho2m1, rho3m1); + printf("rhoim2 %f %f %f\n", rho1m2, rho2m2, rho3m2); + printf("rho1 %f %f %f\n", rho11, rho21, rho31); + printf("rho2 %f %f %f\n", rho12, rho22, rho32); + printf("rho0 %f %f\n", rho01, rho02); + */ + } else{ + Gam1 = (t11av * rho11 + t21av * rho21 + t31av * rho31); + if (rho01 < 1.0e-14) + Gam1 = 0.0; + else + Gam1 = Gam1 / (rho01 * rho01); + + Gam2 = (t12av * rho12 + t22av * rho22 + t32av * rho32); + if (rho02 < 1.0e-14) + Gam2 = 0.0; + else + Gam2 = Gam2 / (rho02 * rho02); + } G1 = G_gam(Gam1, this->ibar_meam[a], errorflag); G2 = G_gam(Gam2, this->ibar_meam[b], errorflag); @@ -686,11 +714,15 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou double rhoa02, rhoa12, rhoa22, rhoa32; double arat, scrn, denom; double C, s111, s112, s221, S11, S22; + // msmeam params + double rhoa1m1, rhoa2m1, rhoa3m1, rhoa1m2, rhoa2m2, rhoa3m2; a1 = r / this->re_meam[a][a] - 1.0; a2 = r / this->re_meam[b][b] - 1.0; rhoa01 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta0_meam[a] * a1); + /* + // Modified: ialloy=1 not used in MSMEAM rhoa11 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); rhoa21 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); rhoa31 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); @@ -698,6 +730,25 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa12 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); rhoa22 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); rhoa32 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); + */ + rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); + rhoa21 = this->rho0_meam[a] * this->t2_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); + rhoa31 = this->rho0_meam[a] * this->t3_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); + rhoa02 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta0_meam[b] * a2); + rhoa12 = this->rho0_meam[b] * this->t1_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); + rhoa22 = this->rho0_meam[b] * this->t2_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); + rhoa32 = this->rho0_meam[b] * this->t3_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); + if (this->msmeamflag){ + rhoa1m1 = this->rho0_meam[a] * this->t1m_meam[a] * MathSpecial::fm_exp(-this->beta1m_meam[a] * a1); + rhoa2m1 = this->rho0_meam[a] * this->t2m_meam[a] * MathSpecial::fm_exp(-this->beta2m_meam[a] * a1); + rhoa3m1 = this->rho0_meam[a] * this->t3m_meam[a] * MathSpecial::fm_exp(-this->beta3m_meam[a] * a1); + rhoa1m2 = this->rho0_meam[b] * this->t1m_meam[b] * MathSpecial::fm_exp(-this->beta1m_meam[b] * a2); + rhoa2m2 = this->rho0_meam[b] * this->t2m_meam[b] * MathSpecial::fm_exp(-this->beta2m_meam[b] * a2); + rhoa3m2 = this->rho0_meam[b] * this->t3m_meam[b] * MathSpecial::fm_exp(-this->beta3m_meam[b] * a2); + } + //printf("rhoa0 %f %f\n", rhoa01, rhoa02); + //printf("rhoai1 %f %f %f\n", rhoa11, rhoa21, rhoa31); + //printf("rhoai2 %f %f %f\n", rhoa12, rhoa22, rhoa32); lat = this->lattce_meam[a][b]; @@ -709,7 +760,14 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho12 = 0.0; *rho22 = 0.0; *rho32 = 0.0; + *rho1m1 = 0.0; + *rho2m1 = 0.0; + *rho3m1 = 0.0; + *rho1m2 = 0.0; + *rho2m2 = 0.0; + *rho3m2 = 0.0; + // keep track of density components separately; combine in the calling subroutine switch (lat) { case FCC: *rho01 = 12.0 * rhoa02; @@ -729,12 +787,20 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho02 = 4.0 * rhoa01; *rho31 = 32.0 / 9.0 * rhoa32 * rhoa32; *rho32 = 32.0 / 9.0 * rhoa31 * rhoa31; + if (this->msmeamflag){ + *rho3m1 = 32.0 / 9.0 * rhoa3m2 * rhoa3m2; + *rho3m2 = 32.0 / 9.0 * rhoa3m1 * rhoa3m1; + } break; case HCP: *rho01 = 12 * rhoa02; *rho02 = 12 * rhoa01; *rho31 = 1.0 / 3.0 * rhoa32 * rhoa32; *rho32 = 1.0 / 3.0 * rhoa31 * rhoa31; + if (this->msmeamflag){ + *rho3m1 = 1.0 / 3.0 * rhoa3m2 * rhoa3m2; + *rho3m2 = 1.0 / 3.0 * rhoa3m1 * rhoa3m1; + } break; case DIM: get_shpfcn(DIM, 0, 0, s); @@ -746,6 +812,14 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho22 = s[1] * rhoa21 * rhoa21; *rho31 = s[2] * rhoa32 * rhoa32; *rho32 = s[2] * rhoa31 * rhoa31; + if (this->msmeamflag){ + *rho1m1 = s[0] * rhoa1m2 * rhoa1m2; + *rho1m2 = s[0] * rhoa1m1 * rhoa1m1; + *rho2m1 = s[1] * rhoa2m2 * rhoa2m2; + *rho2m2 = s[1] * rhoa2m1 * rhoa2m1; + *rho3m1 = s[2] * rhoa3m2 * rhoa3m2; + *rho3m2 = s[2] * rhoa3m1 * rhoa3m1; + } break; case C11: *rho01 = rhoa01; @@ -756,17 +830,30 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho22 = rhoa22; *rho31 = rhoa31; *rho32 = rhoa32; + if (this->msmeamflag){ + *rho1m1 = rhoa1m1; + *rho1m2 = rhoa1m2; + *rho2m1 = rhoa2m1; + *rho2m2 = rhoa2m2; + *rho3m1 = rhoa3m1; + *rho3m2 = rhoa3m2; + } break; case L12: *rho01 = 8 * rhoa01 + 4 * rhoa02; *rho02 = 12 * rhoa01; - if (this->ialloy == 1) { + // not modified by choice with msmeam; use of t's inconsistent with above + if (this->ialloy == 1 && !this->msmeamflag) { + printf("^^^ ialloy=1 in getdensref\n"); *rho21 = 8. / 3. * MathSpecial::square(rhoa21 * this->t2_meam[a] - rhoa22 * this->t2_meam[b]); denom = 8 * rhoa01 * MathSpecial::square(this->t2_meam[a]) + 4 * rhoa02 * MathSpecial::square(this->t2_meam[b]); if (denom > 0.) *rho21 = *rho21 / denom * *rho01; } else *rho21 = 8. / 3. * (rhoa21 - rhoa22) * (rhoa21 - rhoa22); + if (this->msmeamflag){ + *rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2); + } break; case B2: *rho01 = 8.0 * rhoa02; @@ -883,9 +970,9 @@ void MEAM::interpolate_meam(int ind) this->rdrar = 1.0 / drar; // phir interp - printf("--- phir interp ---\n"); + //printf("--- phir interp ---\n"); - printf("nrar %d\n", this->nrar); + //printf("nrar %d\n", this->nrar); //printf("phir:\n"); for (j = 0; j < this->nrar; j++) { //printf("%f\n", phir[ind][j]); @@ -916,5 +1003,5 @@ void MEAM::interpolate_meam(int ind) this->phirar5[ind][j] = 2.0 * this->phirar2[ind][j] / drar; this->phirar6[ind][j] = 3.0 * this->phirar3[ind][j] / drar; } - printf("-----\n"); + //printf("-----\n"); } diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 9355e8b364..a53b0e3cf8 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -63,8 +63,8 @@ PairMEAM::PairMEAM(LAMMPS *lmp) : Pair(lmp) // set comm size needed by this Pair - comm_forward = 38; - comm_reverse = 30; + comm_forward = 38+23; // plus 23 for msmeam + comm_reverse = 30+23; // plus 23 for msmeam } /* ---------------------------------------------------------------------- @@ -134,6 +134,8 @@ void PairMEAM::compute(int eflag, int vflag) int offset = 0; errorflag = 0; + printf("before meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + for (ii = 0; ii < inum_half; ii++) { i = ilist_half[ii]; meam_inst->meam_dens_init(i,ntype,type,map,x, @@ -142,6 +144,7 @@ void PairMEAM::compute(int eflag, int vflag) offset); offset += numneigh_half[i]; } + printf("after meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->reverse_comm(this); printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); @@ -150,7 +153,9 @@ void PairMEAM::compute(int eflag, int vflag) if (errorflag) error->one(FLERR,"MEAM library error {}",errorflag); + printf("before forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->forward_comm(this); + printf("after forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); offset = 0; @@ -658,7 +663,7 @@ int PairMEAM::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst->tsq_ave[j][1]; buf[m++] = meam_inst->tsq_ave[j][2]; - // msmeam params + // msmeam params - increases buffer by 23 if (this->msmeamflag){ buf[m++] = meam_inst->arho2mb[j]; buf[m++] = meam_inst->arho1m[j][0]; @@ -720,7 +725,7 @@ void PairMEAM::unpack_forward_comm(int n, int first, double *buf) meam_inst->tsq_ave[i][1] = buf[m++]; meam_inst->tsq_ave[i][2] = buf[m++]; - // msmeam params + // msmeam params - increases buffer size by 23 if (this->msmeamflag){ meam_inst->arho2mb[i] = buf[m++]; @@ -773,7 +778,7 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) buf[m++] = meam_inst->tsq_ave[i][1]; buf[m++] = meam_inst->tsq_ave[i][2]; - // msmeam params + // msmeam params - increases buffer size by 23 if (this->msmeamflag){ buf[m++] = meam_inst->arho2mb[i]; @@ -828,6 +833,8 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) meam_inst->tsq_ave[j][1] += buf[m++]; meam_inst->tsq_ave[j][2] += buf[m++]; + // msmeam params - increases buffer size by 23 + if (this->msmeamflag){ meam_inst->arho2mb[j] += buf[m++]; meam_inst->arho1m[j][0] += buf[m++]; From 665b87706330bc60d0e4b59c3d9f2fb89cfe1f8f Mon Sep 17 00:00:00 2001 From: rohskopf Date: Mon, 16 Jan 2023 07:37:32 -0700 Subject: [PATCH 11/43] Update msmeam example and clean up code --- examples/meam/dump.xyz | 130 +++++++++++++++ examples/meam/in.meam | 5 +- examples/meam/msmeam/test.dump | 12 +- examples/meam/msmeam/test.log | 22 +-- examples/meam/msmeam/test.out | 294 +++++++++++++++++++++++++++++++++ src/MEAM/meam_dens_final.cpp | 20 +-- src/MEAM/meam_dens_init.cpp | 16 +- src/MEAM/meam_force.cpp | 52 +++--- src/MEAM/meam_setup_done.cpp | 30 +++- src/MEAM/meam_setup_global.cpp | 7 +- src/MEAM/pair_meam.cpp | 12 +- 11 files changed, 529 insertions(+), 71 deletions(-) create mode 100644 examples/meam/dump.xyz create mode 100644 examples/meam/msmeam/test.out diff --git a/examples/meam/dump.xyz b/examples/meam/dump.xyz new file mode 100644 index 0000000000..60e60ac7e7 --- /dev/null +++ b/examples/meam/dump.xyz @@ -0,0 +1,130 @@ +128 + Atoms. Timestep: 0 +2 -2.93785 -4.45926 -4.81092 +2 5.62221 -2.7335 -1.71576 +2 -2.66146 -5.54311 1.63537 +2 -5.43268 -4.61746 5.94523 +2 5.86792 -0.112054 -3.58394 +2 -3.71746 -0.662331 -0.371479 +2 -5.07247 -2.56716 4.41035 +2 -3.39514 0.934113 4.93107 +2 -5.43476 1.95238 -5.61809 +2 -4.58847 2.29045 -1.05977 +2 -5.90587 0.621241 2.01276 +2 -4.76807 0.196574 4.32678 +2 -5.42289 5.25697 -4.51629 +2 -5.2684 -5.91937 -2.86487 +2 -2.86109 1.04847 2.02991 +2 -4.07111 5.3133 3.80095 +2 -0.194715 -4.16777 -5.69509 +2 -2.98927 -3.16474 -1.61739 +2 -0.912931 -4.38191 -0.160186 +2 -2.45137 -5.24665 4.88829 +2 -2.888 -0.163345 -3.34011 +1 -4.67388 -1.38073 -2.29468 +2 -0.697395 -1.48853 0.600516 +1 -2.73922 -2.47748 0.238719 +2 -2.65513 -2.723 2.63503 +1 -3.46443 -4.60281 3.38178 +2 0.722761 -2.07094 2.92147 +1 -2.10006 -3.21313 5.72734 +2 -3.10576 2.32048 -2.27256 +1 -2.22988 0.716839 -1.31072 +2 -1.86983 1.40068 0.726511 +1 -4.11034 -0.709334 1.93418 +2 -0.350558 3.27072 -0.288066 +1 -3.40454 -1.4384 4.39035 +2 -3.09405 1.41325 -5.36355 +1 -4.45607 1.20729 -3.73102 +2 -2.6061 4.63735 -4.69039 +1 -3.34774 4.67681 -2.62847 +2 0.81217 4.86024 -4.67109 +1 -2.57569 3.37407 -0.213635 +2 -0.386798 5.87456 -2.11199 +1 -1.67662 1.33743 3.87415 +2 -0.877061 3.37359 4.3847 +1 -1.86093 3.31582 -5.97866 +1 -5.27323 -4.60733 -0.958175 +1 -2.78887 -5.69102 -0.792202 +1 -2.47172 4.58019 2.50832 +1 -3.88199 5.84566 -5.75634 +2 2.23148 -2.77292 -5.23569 +2 0.298198 -3.13853 -3.16082 +2 2.88108 -3.46587 -0.58232 +2 0.250962 -5.75952 2.73898 +2 -0.293412 -0.802943 -3.36985 +1 -1.00757 -2.04819 -1.94193 +2 2.07291 1.49224 -2.38981 +1 1.11109 -3.20042 0.949108 +2 1.67743 -0.790186 2.51588 +1 -0.83423 -4.33425 2.09715 +2 3.27474 -1.31079 4.78847 +1 1.71262 -3.36915 4.5581 +2 0.47706 1.7769 -5.33399 +1 0.294439 0.589278 -2.20301 +2 2.20393 3.15576 -2.02768 +1 -0.0404494 0.476782 1.03964 +2 1.13959 2.37634 2.3481 +1 -0.973837 -1.63252 3.75386 +2 -0.3292 0.299699 5.27708 +1 -1.61856 -0.396427 -5.17712 +2 2.59999 -5.19777 5.82307 +1 -1.62707 2.32109 -3.62999 +2 3.65327 4.92826 -5.43193 +1 0.0788934 4.0241 -2.50115 +2 2.85565 2.61687 2.11255 +1 0.973899 2.62554 4.34121 +2 3.74529 3.45214 4.59464 +1 2.08052 4.7039 5.32803 +1 -1.03242 -5.8155 -4.32658 +1 0.762244 -4.36316 -1.31566 +1 0.326368 3.99374 1.61723 +1 -0.435011 -5.79971 4.59591 +2 3.91611 -4.60528 -3.31917 +2 1.92407 5.73451 -1.97543 +2 -5.97945 -4.23694 1.86465 +2 4.334 -4.48452 5.37374 +2 2.27555 -0.632774 -5.79318 +1 1.87282 -1.55049 -3.456 +2 3.45581 -1.10541 -1.83331 +1 4.37882 -1.94665 -0.328464 +2 2.59992 -3.7549 2.57406 +1 3.99839 -4.48566 1.19687 +2 -5.72956 -2.14757 -5.99636 +1 4.26641 -2.6989 -5.80055 +2 4.52547 2.29068 -3.47658 +1 2.36031 1.34164 -4.41738 +2 4.77671 1.40612 -0.752462 +1 1.80727 -0.783597 -0.458199 +2 4.4745 0.373622 2.10683 +1 3.60812 -1.73157 2.40191 +2 4.62814 -0.286541 4.47565 +1 1.79752 0.289353 4.23308 +2 5.83415 4.49865 -5.96645 +1 3.24013 4.16552 -3.507 +2 4.87203 4.871 -2.33644 +1 3.55265 1.22628 0.692683 +2 -5.81733 4.54205 1.55789 +1 3.96832 1.54411 3.82844 +2 -5.53493 1.9067 3.75041 +1 4.47286 2.64156 -5.59528 +1 1.70009 -4.81154 -4.19539 +1 1.72215 4.18784 -0.371268 +1 3.92182 4.59356 1.32634 +1 3.13102 -5.89225 3.60012 +1 4.75587 -2.28778 -3.47421 +1 -5.50503 -2.70274 0.874887 +1 5.84186 -4.60644 3.87141 +1 -4.75169 -3.1692 -4.40998 +1 3.9405 0.71887 -2.28988 +1 -5.68697 0.204238 -0.191674 +1 5.89496 -1.24226 3.12013 +1 5.96758 -0.0712572 5.8964 +1 -5.62085 3.36 -2.94935 +1 5.20653 3.45179 -0.380089 +1 -4.69945 2.54896 1.82974 +1 -4.07584 3.07262 5.0648 +1 4.15876 -5.08968 -1.14435 +1 -4.69638 -5.74298 1.13578 +1 5.59942 4.6887 3.59483 +1 5.09884 -5.37744 -4.90513 diff --git a/examples/meam/in.meam b/examples/meam/in.meam index b4463be365..550d2fb4dc 100644 --- a/examples/meam/in.meam +++ b/examples/meam/in.meam @@ -14,9 +14,10 @@ neighbor 0.3 bin neigh_modify delay 10 fix 1 all nve -thermo 10 +thermo 1 timestep 0.001 +dump 1 all xyz 100 dump.xyz #dump 1 all atom 50 dump.meam #dump 2 all image 10 image.*.jpg element element & @@ -27,4 +28,4 @@ timestep 0.001 # axes yes 0.8 0.02 view 60 -30 #dump_modify 3 pad 3 element Si C -run 100 +run 10 diff --git a/examples/meam/msmeam/test.dump b/examples/meam/msmeam/test.dump index 476ebfeb75..45d17a5228 100644 --- a/examples/meam/msmeam/test.dump +++ b/examples/meam/msmeam/test.dump @@ -7,9 +7,9 @@ ITEM: BOX BOUNDS pp pp pp -4.0000000000000000e+00 4.0000000000000000e+00 -4.0000000000000000e+00 4.0000000000000000e+00 ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -132.308 -88.6953 0 22.6425 -2.1528e+08 -1.63302e+08 -0 -2.06499e+07 -0 -0 -2 2.2 0 0 121.138 -0.446613 0 14.8521 -2.12596e+08 -0 -0 386632 -0 -0 -3 0.3 2.3 0 11.1693 89.1419 0 8.67443 -2.68428e+06 -1.63302e+08 -0 -2.10365e+07 -0 -0 +1 0 0 0 -131.977 -88.3322 0 22.9236 -2.14786e+08 -1.62719e+08 -0 -2.05378e+07 -0 -0 +2 2.2 0 0 120.857 -0.482171 0 14.7745 -2.12113e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1201 88.8144 0 8.61773 -2.67245e+06 -1.62719e+08 -0 -2.09411e+07 -0 -0 ITEM: TIMESTEP 1 ITEM: NUMBER OF ATOMS @@ -19,6 +19,6 @@ ITEM: BOX BOUNDS pp pp pp -4.0000000000000000e+00 4.0000000000000000e+00 -4.0000000000000000e+00 4.0000000000000000e+00 ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -132.308 -88.6953 0 22.6425 -2.1528e+08 -1.63302e+08 -0 -2.06499e+07 -0 -0 -2 2.2 0 0 121.138 -0.446613 0 14.8521 -2.12596e+08 -0 -0 386632 -0 -0 -3 0.3 2.3 0 11.1693 89.1419 0 8.67443 -2.68428e+06 -1.63302e+08 -0 -2.10365e+07 -0 -0 +1 0 0 0 -131.977 -88.3322 0 22.9236 -2.14786e+08 -1.62719e+08 -0 -2.05378e+07 -0 -0 +2 2.2 0 0 120.857 -0.482171 0 14.7745 -2.12113e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1201 88.8144 0 8.61773 -2.67245e+06 -1.62719e+08 -0 -2.09411e+07 -0 -0 diff --git a/examples/meam/msmeam/test.log b/examples/meam/msmeam/test.log index 83e0d92f70..813acd55da 100644 --- a/examples/meam/msmeam/test.log +++ b/examples/meam/msmeam/test.log @@ -83,24 +83,24 @@ Neighbor list info ... pair build: halffull/newton stencil: none bin: none -Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes +Per MPI rank memory allocation (min/avg/max) = 10.71 | 10.71 | 10.71 Mbytes Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms - 0 0 15.389692 492946.21 840939 637899.63 0 80663.676 0 0 8 8 8 512 15.389692 - 1 0 15.389692 492946.21 840939 637899.63 0 80663.676 0 0 8 8 8 512 15.389692 -Loop time of 7.9076e-05 on 1 procs for 1 steps with 3 atoms + 0 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 + 1 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 +Loop time of 6.7095e-05 on 1 procs for 1 steps with 3 atoms -Performance: 1092.620 ns/day, 0.022 hours/ns, 12646.062 timesteps/s -67.0% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1287.726 ns/day, 0.019 hours/ns, 14904.240 timesteps/s +77.5% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 2.4076e-05 | 2.4076e-05 | 2.4076e-05 | 0.0 | 30.45 +Pair | 2.7954e-05 | 2.7954e-05 | 2.7954e-05 | 0.0 | 41.66 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 3.204e-06 | 3.204e-06 | 3.204e-06 | 0.0 | 4.05 -Output | 4.726e-05 | 4.726e-05 | 4.726e-05 | 0.0 | 59.77 -Modify | 5.97e-07 | 5.97e-07 | 5.97e-07 | 0.0 | 0.75 -Other | | 3.939e-06 | | | 4.98 +Comm | 3.164e-06 | 3.164e-06 | 3.164e-06 | 0.0 | 4.72 +Output | 3.1658e-05 | 3.1658e-05 | 3.1658e-05 | 0.0 | 47.18 +Modify | 1.712e-06 | 1.712e-06 | 1.712e-06 | 0.0 | 2.55 +Other | | 2.607e-06 | | | 3.89 Nlocal: 3 ave 3 max 3 min Histogram: 1 0 0 0 0 0 0 0 0 0 diff --git a/examples/meam/msmeam/test.out b/examples/meam/msmeam/test.out new file mode 100644 index 0000000000..72592b4673 --- /dev/null +++ b/examples/meam/msmeam/test.out @@ -0,0 +1,294 @@ +LAMMPS (23 Jun 2022) +log test.log +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box +Created orthogonal box = (-4 -4 -4) to (4 4 4) + 1 by 1 by 1 MPI processor grid + +# + +include potential.mod +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +potential chosen H +# Choose potential +pair_style meam ms # the `ms` flag turns on MS-MEAM +print "we just executed" +we just executed + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 +Reading MEAM library file library.MSmeam with DATE: 2018-09-22 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 1.0079 +Tokenizer::next_double() current = 2.960 +Tokenizer::next_double() current = 2.960 +Tokenizer::next_double() current = 3.0 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_double() current = 3.0 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_double() current = 0.741 +Tokenizer::next_double() current = 2.235 +Tokenizer::next_double() current = 2.50 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_double() current = 0.44721 +Tokenizer::next_double() current = 0.0 +Tokenizer::next_double() current = 0.00 +Tokenizer::next_double() current = 0.0 +Tokenizer::next_double() current = 0.31623 +Tokenizer::next_double() current = 0 +Tokenizer::next_double() current = 6.70 +Tokenizer::next_int() current = 0 +Tokenizer::next_double() current = 12.0 +Tokenizer::next_int() current = 31 +Tokenizer::next_double() current = 69.723 +Tokenizer::next_double() current = 4.42 +Tokenizer::next_double() current = 4.80 +Tokenizer::next_double() current = 3.10 +Tokenizer::next_double() current = 6.00 +Tokenizer::next_double() current = 0.00 +Tokenizer::next_double() current = 0.0 +Tokenizer::next_double() current = 0.0 +Tokenizer::next_double() current = 0.5 +Tokenizer::next_double() current = 4.247 +Tokenizer::next_double() current = 2.897 +Tokenizer::next_double() current = 0.97 +Tokenizer::next_double() current = 1.0 +Tokenizer::next_double() current = 1.649 +Tokenizer::next_double() current = 1.435 +Tokenizer::next_double() current = 0.00 +Tokenizer::next_double() current = 0.0 +Tokenizer::next_double() current = 0.0 +Tokenizer::next_double() current = 2.0 +Tokenizer::next_double() current = 0.70 +Tokenizer::next_int() current = 0 +^^^^^ Filling tm +^^^^^ Filling tm +Tokenizer::next_double() current = 1 +Tokenizer::next_double() current = 1 +Tokenizer::next_double() current = 0 +Tokenizer::next_double() current = 1 +Tokenizer::next_double() current = 5.9 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 0.460 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 0.460 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 1.3 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 2.80 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 0.6 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 0.097 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 0.097 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 0.300 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 0.300 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 3.19 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = -0.48 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 6.6 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 2.0 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 2.0 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 2.0 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 1 +Tokenizer::next_double() current = 1.4 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 1.4 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 1.4 +Tokenizer::next_int() current = 1 +Tokenizer::next_int() current = 2 +Tokenizer::next_double() current = 1 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +min_modify dmax 0.01 line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes +create_atoms 1 single 0 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 2.2 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 0.3 2.3 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.9 + ghost atom cutoff = 6.9 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair meam, perpetual + attributes: full, newton on + pair build: full/nsq + stencil: none + bin: none + (2) pair meam, perpetual, half/full from (1) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none +Setting up Verlet run ... + Unit style : metal + Current step : 0 + Time step : 0.001 +--- compute derivatives of energy wrt ... +phip sij -116.571511 1.000000 +drhodr -1.327736 -0.011564 +fp 4.976162 -13.618158 +dUdrij -123.021058 +--- compute derivatives of energy wrt ... +phip sij -86.757953 1.000000 +drhodr -0.821855 -0.007170 +fp 4.976162 -14.961215 +dUdrij -90.740359 +--- compute derivatives of energy wrt ... +phip sij 0.129370 1.000000 +drhodr -0.000000 -0.002189 +fp -13.618158 4.976162 +dUdrij 0.118475 +--- compute derivatives of energy wrt ... +phip sij 0.140206 1.000000 +drhodr -0.000000 -0.002956 +fp -14.961215 4.976162 +dUdrij 0.125499 +Per MPI rank memory allocation (min/avg/max) = 10.71 | 10.71 | 10.71 Mbytes + Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms + 0 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 +--- compute derivatives of energy wrt ... +phip sij -116.571511 1.000000 +drhodr -1.327736 -0.011564 +fp 4.976162 -13.618158 +dUdrij -123.021058 +--- compute derivatives of energy wrt ... +phip sij -86.757953 1.000000 +drhodr -0.821855 -0.007170 +fp 4.976162 -14.961215 +dUdrij -90.740359 +--- compute derivatives of energy wrt ... +phip sij 0.129370 1.000000 +drhodr -0.000000 -0.002189 +fp -13.618158 4.976162 +dUdrij 0.118475 +--- compute derivatives of energy wrt ... +phip sij 0.140206 1.000000 +drhodr -0.000000 -0.002956 +fp -14.961215 4.976162 +dUdrij 0.125499 + 1 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 +Loop time of 6.7095e-05 on 1 procs for 1 steps with 3 atoms + +Performance: 1287.726 ns/day, 0.019 hours/ns, 14904.240 timesteps/s +77.5% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.7954e-05 | 2.7954e-05 | 2.7954e-05 | 0.0 | 41.66 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 3.164e-06 | 3.164e-06 | 3.164e-06 | 0.0 | 4.72 +Output | 3.1658e-05 | 3.1658e-05 | 3.1658e-05 | 0.0 | 47.18 +Modify | 1.712e-06 | 1.712e-06 | 1.712e-06 | 0.0 | 2.55 +Other | | 2.607e-06 | | | 3.89 + +Nlocal: 3 ave 3 max 3 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 78 ave 78 max 78 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7 ave 7 max 7 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 14 ave 14 max 14 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 14 +Ave neighs/atom = 4.6666667 +Neighbor list builds = 0 +Dangerous builds = 0 +write_data test.data +System init for write_data ... + +print "All done!" +All done! +Total wall time: 0:00:00 diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index 234694473a..201b27cbeb 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -25,8 +25,8 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ double denom, rho_bkgd, Fl; double scaleii; - printf("meam_dens_final arho3m\n"); - printf("%f\n", arho3m[0][0]); + //printf("meam_dens_final arho3m\n"); + //printf("%f\n", arho3m[0][0]); // Complete the calculation of density @@ -52,14 +52,14 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ for (m = 0; m < 10; m++) { rho3[i] = rho3[i] + this->v3D[m] * (arho3[i][m] * arho3[i][m] - arho3m[i][m] * arho3m[i][m]); - printf("arho loop %f %f\n", arho3[i][m], arho3m[i][m]); + //printf("arho loop %f %f\n", arho3[i][m], arho3m[i][m]); } // Compared to Greg's original, all of the t weightings are already accounted for. // Code block for t_ave removed. - printf("gam rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); + //printf("gam rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); gamma[i] = rho1[i] + rho2[i] + rho3[i]; - printf("gam check 0 %f\n", gamma[i]); + //printf("gam check 0 %f\n", gamma[i]); /* if (rho0[i] > 0.0) { @@ -80,11 +80,11 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; */ - printf("rho0 %f\n", rho0[i]); + //printf("rho0 %f\n", rho0[i]); if (rho0[i] > 0.0) { gamma[i] = gamma[i] / (rho0[i] * rho0[i]); } - printf("gam check1 %f\n", gamma[i]); + //printf("gam check1 %f\n", gamma[i]); Z = get_Zij(this->lattce_meam[elti][elti]); @@ -97,7 +97,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ if (this->ibar_meam[elti] <= 0) { Gbar = 1.0; dGbar = 0.0; - printf("ibar meam <= 0\n"); + //printf("ibar meam <= 0\n"); } else { if (this->mix_ref_t == 1) { gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); @@ -106,7 +106,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ (Z * Z); } Gbar = G_gam(gam, this->ibar_meam[elti], errorflag); - printf("ibar meam > 0\n"); + //printf("ibar meam > 0\n"); } rho[i] = rho0[i] * G; @@ -130,7 +130,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ rhob = rho[i] / rho_bkgd; denom = 1.0 / rho_bkgd; - printf("dgam rhob denom %f %f\n", rhob, denom); + //printf("dgam rhob denom %f %f\n", rhob, denom); G = dG_gam(gamma[i], this->ibar_meam[elti], dG); diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index 802f811071..61fc6e8bf0 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -90,7 +90,7 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) } // zero out local arrays - printf("^^^ zero out local arrays in mean_dens_init\n"); + //printf("^^^ zero out local arrays in mean_dens_init\n"); for (i = 0; i < nall; i++) { rho0[i] = 0.0; arho2b[i] = 0.0; @@ -119,7 +119,7 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) tsq_ave[i][0] = tsq_ave[i][1] = tsq_ave[i][2] = 0.0; } - printf("^^^ arho3m %f\n", arho3m[0][0]); + //printf("^^^ arho3m %f\n", arho3m[0][0]); } void @@ -361,9 +361,11 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn rhoa2i = rhoa2i * this->t2_meam[elti]; rhoa3i = rhoa3i * this->t3_meam[elti]; } + /* printf("rhos1 %d %d %f %f %f %f\n", i, j, rhoa1i, rhoa1j, rhoa1mi, rhoa1mj); printf("rhos2 %d %d %f %f %f %f\n", i, j, rhoa2i, rhoa2j, rhoa2mi, rhoa2mj); printf("rhos3 %d %d %f %f %f %f\n", i, j, rhoa3i, rhoa3j, rhoa3mi, rhoa3mj); + */ rho0[i] = rho0[i] + rhoa0j; rho0[j] = rho0[j] + rhoa0i; // For ialloy = 2, use single-element value (not average) @@ -405,7 +407,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn A2mi = rhoa2mi/rij2; A3mi = rhoa3mi/(rij2*rij); } - printf("arho2mb i j %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); + //printf("arho2mb i j %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); for (m = 0; m < 3; m++) { arho1[i][m] = arho1[i][m] + A1j * delij[m]; arho1[j][m] = arho1[j][m] - A1i * delij[m]; @@ -417,8 +419,8 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho3mb[i][m] = arho3mb[i][m] + rhoa3mj*delij[m] / rij; arho3mb[j][m] = arho3mb[j][m] - rhoa3mi*delij[m] / rij; } - printf("arho1m %f %f\n", arho1m[i][m], arho1m[j][m]); - printf("arho3mb %f %f\n", arho3mb[i][m], arho3mb[j][m]); + //printf("arho1m %f %f\n", arho1m[i][m], arho1m[j][m]); + //printf("arho3mb %f %f\n", arho3mb[i][m], arho3mb[j][m]); for (n = m; n < 3; n++) { arho2[i][nv2] = arho2[i][nv2] + A2j * delij[m] * delij[n]; arho2[j][nv2] = arho2[j][nv2] + A2i * delij[m] * delij[n]; @@ -427,7 +429,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho2m[j][nv2] = arho2m[j][nv2] + A2mi*delij[m] * delij[n]; } //printf("delij %f %f\n", delij[m], delij[n]); - printf("arho2m %d %d %f %f\n", nv2, m, arho2m[i][nv2], arho2m[j][nv2]); + //printf("arho2m %d %d %f %f\n", nv2, m, arho2m[i][nv2], arho2m[j][nv2]); nv2 = nv2 + 1; for (p = n; p < 3; p++) { arho3[i][nv3] = arho3[i][nv3] + A3j * delij[m] * delij[n] * delij[p]; @@ -437,7 +439,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho3m[j][nv3] = arho3m[j][nv3] - A3mi*delij[m]*delij[n]*delij[p]; } //arho3m[0][0]=500.0; - printf("arho3m %d %f %f\n", p, arho3m[i][nv3], arho3m[j][nv3]); + //printf("arho3m %d %f %f\n", p, arho3m[i][nv3], arho3m[j][nv3]); nv3 = nv3 + 1; } } diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index bca423f563..172f61a2dc 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -75,8 +75,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double drho3mdr1, drho3mdr2, drho3mds1, drho3mds2; double drho3mdrm1[3], drho3mdrm2[3]; - printf("----- begin meam_force -----\n"); - printf("forces f %d %f\n", i, f[0][0]); + //printf("----- begin meam_force -----\n"); + //printf("forces f %d %f\n", i, f[0][0]); third = 1.0 / 3.0; sixth = 1.0 / 6.0; @@ -89,7 +89,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int xitmp = x[i][0]; yitmp = x[i][1]; zitmp = x[i][2]; - printf("xtmp ytmp ztmp: %f %f %f\n", xitmp, yitmp, zitmp); + //printf("xtmp ytmp ztmp: %f %f %f\n", xitmp, yitmp, zitmp); // Treat each pair @@ -98,7 +98,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int eltj = fmap[type[j]]; scaleij = scale[type[i]][type[j]]; - printf("in j loop %d %d %d %d %f\n", i, j, eltj, type[j], scrfcn[fnoffset + jn]); + //printf("in j loop %d %d %d %d %f\n", i, j, eltj, type[j], scrfcn[fnoffset + jn]); if (!iszero(scrfcn[fnoffset + jn]) && eltj >= 0) { sij = scrfcn[fnoffset + jn] * fcpair[fnoffset + jn]; @@ -110,7 +110,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int if (rij2 < this->cutforcesq) { rij = sqrt(rij2); recip = 1.0 / rij; - printf("forces, sij, rij = %f %f for i = %d and j = %d\n", sij, rij, i, j); + //printf("forces, sij, rij = %f %f for i = %d and j = %d\n", sij, rij, i, j); // Compute phi and phip ind = this->eltind[elti][eltj]; pp = rij * this->rdrar; @@ -120,12 +120,14 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int pp = std::min(pp, 1.0); phi = ((this->phirar3[ind][kk] * pp + this->phirar2[ind][kk]) * pp + this->phirar1[ind][kk]) * pp + this->phirar[ind][kk]; phip = (this->phirar6[ind][kk] * pp + this->phirar5[ind][kk]) * pp + this->phirar4[ind][kk]; + /* printf("--- phi and phip i = %d ---\n", i); printf("phi %f %f\n", this->phirar3[ind][kk], this->phirar2[ind][kk]); printf("phi2 %f %f\n", this->phirar1[ind][kk], this->phirar[ind][kk]); printf("phip %f %f\n", this->phirar6[ind][kk], this->phirar5[ind][kk]); printf("phip2 %f\n", this->phirar4[ind][kk]); printf("-----"); + */ if (eflag_either != 0) { double phi_sc = phi * scaleij; @@ -212,9 +214,11 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int const double t2mj = this->t2_meam[eltj]; const double t3mj = this->t3_meam[eltj]; - // ialloy mod not needed in msmeam according to fortran code - // if we remove this, need to multiply rhoali and rhoalj above by t vars - if (this->ialloy == 1) { + // ialloy mod not needed in msmeam, but similarity here is that we need to multiply rhos by t + // msmeam fortran code accomplishes this by multiplying rho's with t's above, like we did + // with rhoa1mj, rhoa2mj, etc + + if (this->ialloy == 1 || this->msmeamflag) { rhoa1j *= t1mj; rhoa2j *= t2mj; rhoa3j *= t3mj; @@ -229,10 +233,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhoa3i *= t3mi; } + /* printf("forces, rhoali %f %f %f %f\n", rhoa0i, rhoa1i, rhoa2i, rhoa3i); printf("forces, rhoalmi %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi); printf("forces, rhoalj %f %f %f %f\n", rhoa0j, rhoa1j, rhoa2j, rhoa3j); printf("forces, rhoalmj %f %f %f\n", rhoa1mj, rhoa2mj, rhoa3mj); + */ nv2 = 0; nv3 = 0; @@ -288,7 +294,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int arg = delij[n] * delij[p] * this->v2D[nv2]; arg1i2m = arg1i2m + arho2m[i][nv2] * arg; arg1j2m = arg1j2m + arho2m[j][nv2] * arg; - printf(" arho2m[j][nv2] %d %d %f\n", j, nv2, arho2m[j][nv2]); + //printf(" arho2m[j][nv2] %d %d %f\n", j, nv2, arho2m[j][nv2]); nv2 = nv2 + 1; } arg1i1m = arg1i1m - arho1m[i][n] * delij[n]; @@ -298,10 +304,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } } + /* printf("rho1 terms arg1i %d %d %f %f\n", i, j, arg1i1, arg1i1m); printf("rho1 terms arg1j %d %d %f %f\n", i, j, arg1j1, arg1j1m); printf("rho1 terms rhoa1j %d %d %f %f\n", i, j, rhoa1j, rhoa1mj); printf("rho1 terms drhoa1j %d %d %f %f\n", i,j, drhoa1j, drhoa1mj); + */ // rho0 terms drho0dr1 = drhoa0j * sij; @@ -374,8 +382,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int a2 = 2 * sij / rij2; drho2mdr1 = a2 * (drhoa2mj - 2 * rhoa2mj / rij) * arg1i2m - 2.0 / 3.0 * arho2mb[i] * drhoa2mj * sij; drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - 2.0 / 3.0 * arho2mb[j] * drhoa2mi * sij; - printf(" drho2mdr arho %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); - printf(" drhoa rhoa arg1 %f %f %f\n", drhoa2mi, rhoa2mi, arg1j2m); + //printf(" drho2mdr arho %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); + //printf(" drhoa rhoa arg1 %f %f %f\n", drhoa2mi, rhoa2mi, arg1j2m); a2 = 4 * sij / rij2; for (m = 0; m < 3; m++) { drho2mdrm1[m] = 0.0; @@ -388,13 +396,13 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; } - printf("forces drho2 %f %f %f %f\n", drho2drm1[0], drho2mdrm1[0], drho2drm2[0], drho2mdrm2[0]); + //printf("forces drho2 %f %f %f %f\n", drho2drm1[0], drho2mdrm1[0], drho2drm2[0], drho2mdrm2[0]); // rho3m terms rij3 = rij * rij2; a3 = 2 * sij / rij3; a3a = 6.0 / 5.0 * sij / rij; - printf("args %f %f %f %f\n", arg1i3m, arg3i3m, arg1j3m, arg3j3m); + //printf("args %f %f %f %f\n", arg1i3m, arg3i3m, arg1j3m, arg3j3m); drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; drho3mdr1 *= -1.0; @@ -402,7 +410,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int a3 = 6 * sij / rij3; a3a = 6 * sij / (5 * rij); - printf("forces drho3mdr %f %f\n", drho3mdr1, drho3mdr2); + //printf("forces drho3mdr %f %f\n", drho3mdr1, drho3mdr2); for (m = 0; m < 3; m++) { drho3mdrm1[m] = 0.0; drho3mdrm2[m] = 0.0; @@ -426,11 +434,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3mdrm1[m] = 0.0; drho3mdrm2[m] = 0.0; } - + /* printf("rho2 terms drho2dr1 %f %f\n", drho2dr1, drho2mdr1); printf("rho2 terms drho2dr2 %f %f\n", drho2dr2, drho2mdr2); printf("rho2 terms %f %f\n", drho2drm1[0], drho2mdrm1[0]); printf("rho2 terms %f %f\n", drho2drm2[0], drho2mdrm2[0]); + */ // compute derivatives of weighting functions t wrt rij @@ -509,6 +518,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); if (this->msmeamflag){ + /* printf("test rhodg %f %f %f\n", dgamma1[i], dgamma2[i], dgamma3[i]); printf("test rhod dtdr %f %f %f\n", dt1dr1, dt2dr1, dt3dr1); printf("test rhod rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); @@ -520,6 +530,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int printf(" %f %f %f\n", dgamma1[i], dgamma2[i], dgamma3[i]); printf(" %f %f %f\n", drho1dr2, drho2dr2, drho3dr2); printf(" %f %f %f\n", drho1mdr2, drho2mdr2, drho3mdr2); + */ drhodr1 = dgamma1[i] * drho0dr1 + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + @@ -530,7 +541,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); - printf(" drhodr1&2 %f %f\n", drhodr1, drhodr2); + //printf(" drhodr1&2 %f %f\n", drhodr1, drhodr2); for (m = 0; m < 3; m++) { drhodrm1[m] = 0.0; drhodrm2[m] = 0.0; @@ -559,12 +570,12 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } } - printf("rhod terms drhodr1 %f %f\n", drhodr1, drhodr2); - printf("rhod terms drhodr1 %f %f\n", drhodrm1[0], drhodrm2[0]); + //printf("rhod terms drhodr1 %f %f\n", drhodr1, drhodr2); + //printf("rhod terms drhodr1 %f %f\n", drhodrm1[0], drhodrm2[0]); // Compute derivatives wrt sij, but only if necessary if (!iszero(dscrfcn[fnoffset + jn])) { - printf("computing derivatives wrt sij\n"); + //printf("computing derivatives wrt sij\n"); drho0ds1 = rhoa0j; drho0ds2 = rhoa0i; a1 = 2.0 / rij; @@ -598,6 +609,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } if (this->ialloy == 1) { + a1i = fdiv_zero(rhoa0j, tsq_ave[i][0]); a1j = fdiv_zero(rhoa0i, tsq_ave[j][0]); a2i = fdiv_zero(rhoa0j, tsq_ave[i][1]); @@ -667,11 +679,13 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; dUdsij = 0.0; + printf("--- compute derivatives of energy wrt ...\n"); printf("phip sij %f %f\n", phip,sij); printf("drhodr %f %f\n", drhodr1, drhodr2); printf("fp %f %f\n", frhop[i], frhop[j]); printf("dUdrij %f\n", dUdrij); + if (!iszero(dscrfcn[fnoffset + jn])) { dUdsij = phi + frhop[i] * drhods1 + frhop[j] * drhods2; } diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index c3dfc8c7fc..0335b7ae3d 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -377,7 +377,7 @@ double MEAM::phi_meam(double r, int a, int b) // calculate average weighting factors for the reference structure if (this->lattce_meam[a][b] == C11) { - // note ialloy and t_ave not used in MS-MEAM + // note ialloy and t_ave not used in msmeam if (this->ialloy == 2) { t11av = this->t1_meam[a]; t12av = this->t1_meam[b]; @@ -399,7 +399,7 @@ double MEAM::phi_meam(double r, int a, int b) get_tavref(&t11av, &t21av, &t31av, &t12av, &t22av, &t32av, this->t1_meam[a], this->t2_meam[a], this->t3_meam[a], this->t1_meam[b], this->t2_meam[b], this->t3_meam[b], r, a, b, this->lattce_meam[a][b]); - // msmeam - call twice with different sets of variables + // with msmeam call twice with different sets of variables if (this->msmeamflag){ get_tavref(&t1m1av, &t2m1av, &t3m1av, &t1m2av, &t2m2av, &t3m2av, this->t1m_meam[a], this->t2m_meam[a], this->t3m_meam[a], this->t1m_meam[b], this->t2m_meam[b], this->t3m_meam[b], r, a, b, @@ -731,6 +731,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa22 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); rhoa32 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); */ + /* rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); rhoa21 = this->rho0_meam[a] * this->t2_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); rhoa31 = this->rho0_meam[a] * this->t3_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); @@ -738,7 +739,17 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa12 = this->rho0_meam[b] * this->t1_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); rhoa22 = this->rho0_meam[b] * this->t2_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); rhoa32 = this->rho0_meam[b] * this->t3_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); + */ if (this->msmeamflag){ + // in msmeam, the rho variables are multiplied by t here since we don't use ialloy + rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); + rhoa21 = this->rho0_meam[a] * this->t2_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); + rhoa31 = this->rho0_meam[a] * this->t3_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); + rhoa02 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta0_meam[b] * a2); + rhoa12 = this->rho0_meam[b] * this->t1_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); + rhoa22 = this->rho0_meam[b] * this->t2_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); + rhoa32 = this->rho0_meam[b] * this->t3_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); + // msmeam specific rho vars rhoa1m1 = this->rho0_meam[a] * this->t1m_meam[a] * MathSpecial::fm_exp(-this->beta1m_meam[a] * a1); rhoa2m1 = this->rho0_meam[a] * this->t2m_meam[a] * MathSpecial::fm_exp(-this->beta2m_meam[a] * a1); rhoa3m1 = this->rho0_meam[a] * this->t3m_meam[a] * MathSpecial::fm_exp(-this->beta3m_meam[a] * a1); @@ -746,6 +757,15 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa2m2 = this->rho0_meam[b] * this->t2m_meam[b] * MathSpecial::fm_exp(-this->beta2m_meam[b] * a2); rhoa3m2 = this->rho0_meam[b] * this->t3m_meam[b] * MathSpecial::fm_exp(-this->beta3m_meam[b] * a2); } + else{ + rhoa11 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); + rhoa21 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); + rhoa31 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); + rhoa02 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta0_meam[b] * a2); + rhoa12 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); + rhoa22 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); + rhoa32 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); + } //printf("rhoa0 %f %f\n", rhoa01, rhoa02); //printf("rhoai1 %f %f %f\n", rhoa11, rhoa21, rhoa31); //printf("rhoai2 %f %f %f\n", rhoa12, rhoa22, rhoa32); @@ -842,9 +862,11 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou case L12: *rho01 = 8 * rhoa01 + 4 * rhoa02; *rho02 = 12 * rhoa01; - // not modified by choice with msmeam; use of t's inconsistent with above + // don't use with msmeam; use of t's inconsistent with above + // also we should not use ialloy with msmeam + // possibly make ialloy not an option when using msmeam if (this->ialloy == 1 && !this->msmeamflag) { - printf("^^^ ialloy=1 in getdensref\n"); + //printf("^^^ ialloy=1 in getdensref\n"); *rho21 = 8. / 3. * MathSpecial::square(rhoa21 * this->t2_meam[a] - rhoa22 * this->t2_meam[b]); denom = 8 * rhoa01 * MathSpecial::square(this->t2_meam[a]) + 4 * rhoa02 * MathSpecial::square(this->t2_meam[b]); if (denom > 0.) diff --git a/src/MEAM/meam_setup_global.cpp b/src/MEAM/meam_setup_global.cpp index 0ff64b06bc..859de87d5a 100644 --- a/src/MEAM/meam_setup_global.cpp +++ b/src/MEAM/meam_setup_global.cpp @@ -40,11 +40,6 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* double *t3m) { - printf("^^^^^ meam setup global msmeamflag: %d\n", this->msmeamflag); - if (this->msmeamflag){ - printf("b1m[0]: %f\n", b1m[0]); - } - int i; double tmplat[maxelt]; @@ -60,7 +55,7 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* this->beta2_meam[i] = b2[i]; this->beta3_meam[i] = b3[i]; if (this->msmeamflag){ - printf("^^^^^ Filling betam\n"); + //printf("^^^^^ Filling betam\n"); this->beta1m_meam[i] = b1m[i]; this->beta2m_meam[i] = b2m[i]; this->beta3m_meam[i] = b3m[i]; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index a53b0e3cf8..0aec140eed 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -134,7 +134,7 @@ void PairMEAM::compute(int eflag, int vflag) int offset = 0; errorflag = 0; - printf("before meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + //printf("before meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); for (ii = 0; ii < inum_half; ii++) { i = ilist_half[ii]; @@ -144,18 +144,18 @@ void PairMEAM::compute(int eflag, int vflag) offset); offset += numneigh_half[i]; } - printf("after meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); - printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + //printf("after meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + //printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->reverse_comm(this); - printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + //printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); meam_inst->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, &eng_vdwl,eatom,ntype,type,map,scale,errorflag); if (errorflag) error->one(FLERR,"MEAM library error {}",errorflag); - printf("before forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + //printf("before forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->forward_comm(this); - printf("after forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); + //printf("after forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); offset = 0; From d14f070bef2091691ee8e2021b0e4040a2c143b5 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 17 Jan 2023 20:46:54 -0700 Subject: [PATCH 12/43] Fix segfault with normal meam --- src/MEAM/meam_dens_final.cpp | 54 ++++++++----------- src/MEAM/meam_dens_init.cpp | 15 +----- src/MEAM/meam_force.cpp | 70 +------------------------ src/MEAM/meam_setup_done.cpp | 96 +++++++++++++--------------------- src/MEAM/meam_setup_global.cpp | 2 +- src/MEAM/pair_meam.cpp | 24 ++++----- 6 files changed, 71 insertions(+), 190 deletions(-) diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index 201b27cbeb..b3c65121e5 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -25,9 +25,6 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ double denom, rho_bkgd, Fl; double scaleii; - //printf("meam_dens_final arho3m\n"); - //printf("%f\n", arho3m[0][0]); - // Complete the calculation of density if (this->msmeamflag){ @@ -52,39 +49,34 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ for (m = 0; m < 10; m++) { rho3[i] = rho3[i] + this->v3D[m] * (arho3[i][m] * arho3[i][m] - arho3m[i][m] * arho3m[i][m]); - //printf("arho loop %f %f\n", arho3[i][m], arho3m[i][m]); } - // Compared to Greg's original, all of the t weightings are already accounted for. - // Code block for t_ave removed. - //printf("gam rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); - gamma[i] = rho1[i] + rho2[i] + rho3[i]; - //printf("gam check 0 %f\n", gamma[i]); - - /* - if (rho0[i] > 0.0) { - if (this->ialloy == 1) { - t_ave[i][0] = fdiv_zero(t_ave[i][0], tsq_ave[i][0]); - t_ave[i][1] = fdiv_zero(t_ave[i][1], tsq_ave[i][1]); - t_ave[i][2] = fdiv_zero(t_ave[i][2], tsq_ave[i][2]); - } else if (this->ialloy == 2) { - t_ave[i][0] = this->t1_meam[elti]; - t_ave[i][1] = this->t2_meam[elti]; - t_ave[i][2] = this->t3_meam[elti]; - } else { - t_ave[i][0] = t_ave[i][0] / rho0[i]; - t_ave[i][1] = t_ave[i][1] / rho0[i]; - t_ave[i][2] = t_ave[i][2] / rho0[i]; + if (this->msmeamflag){ + // with msmeam, all the t weights are already accounted for + gamma[i] = rho1[i] + rho2[i] + rho3[i]; + } else { + if (rho0[i] > 0.0) { + if (this->ialloy == 1) { + t_ave[i][0] = fdiv_zero(t_ave[i][0], tsq_ave[i][0]); + t_ave[i][1] = fdiv_zero(t_ave[i][1], tsq_ave[i][1]); + t_ave[i][2] = fdiv_zero(t_ave[i][2], tsq_ave[i][2]); + } else if (this->ialloy == 2) { + t_ave[i][0] = this->t1_meam[elti]; + t_ave[i][1] = this->t2_meam[elti]; + t_ave[i][2] = this->t3_meam[elti]; + } else { + t_ave[i][0] = t_ave[i][0] / rho0[i]; + t_ave[i][1] = t_ave[i][1] / rho0[i]; + t_ave[i][2] = t_ave[i][2] / rho0[i]; + } } + + gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; } - gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; - */ - //printf("rho0 %f\n", rho0[i]); if (rho0[i] > 0.0) { gamma[i] = gamma[i] / (rho0[i] * rho0[i]); } - //printf("gam check1 %f\n", gamma[i]); Z = get_Zij(this->lattce_meam[elti][elti]); @@ -97,7 +89,6 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ if (this->ibar_meam[elti] <= 0) { Gbar = 1.0; dGbar = 0.0; - //printf("ibar meam <= 0\n"); } else { if (this->mix_ref_t == 1) { gam = (t_ave[i][0] * shp[0] + t_ave[i][1] * shp[1] + t_ave[i][2] * shp[2]) / (Z * Z); @@ -106,11 +97,10 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ (Z * Z); } Gbar = G_gam(gam, this->ibar_meam[elti], errorflag); - //printf("ibar meam > 0\n"); } rho[i] = rho0[i] * G; - // nothing to modify and DON'T USE mix_ref_t = 1 + // mix_ref_t == 1 should not be used with msmeam if (this->mix_ref_t == 1) { if (this->ibar_meam[elti] <= 0) { Gbar = 1.0; @@ -130,8 +120,6 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ rhob = rho[i] / rho_bkgd; denom = 1.0 / rho_bkgd; - //printf("dgam rhob denom %f %f\n", rhob, denom); - G = dG_gam(gamma[i], this->ibar_meam[elti], dG); dgamma1[i] = (G - 2 * dG * gamma[i]) * denom; diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index 61fc6e8bf0..0a89e0f3f2 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -90,7 +90,7 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) } // zero out local arrays - //printf("^^^ zero out local arrays in mean_dens_init\n"); + for (i = 0; i < nall; i++) { rho0[i] = 0.0; arho2b[i] = 0.0; @@ -119,7 +119,6 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) tsq_ave[i][0] = tsq_ave[i][1] = tsq_ave[i][2] = 0.0; } - //printf("^^^ arho3m %f\n", arho3m[0][0]); } void @@ -361,11 +360,6 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn rhoa2i = rhoa2i * this->t2_meam[elti]; rhoa3i = rhoa3i * this->t3_meam[elti]; } - /* - printf("rhos1 %d %d %f %f %f %f\n", i, j, rhoa1i, rhoa1j, rhoa1mi, rhoa1mj); - printf("rhos2 %d %d %f %f %f %f\n", i, j, rhoa2i, rhoa2j, rhoa2mi, rhoa2mj); - printf("rhos3 %d %d %f %f %f %f\n", i, j, rhoa3i, rhoa3j, rhoa3mi, rhoa3mj); - */ rho0[i] = rho0[i] + rhoa0j; rho0[j] = rho0[j] + rhoa0i; // For ialloy = 2, use single-element value (not average) @@ -407,7 +401,6 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn A2mi = rhoa2mi/rij2; A3mi = rhoa3mi/(rij2*rij); } - //printf("arho2mb i j %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); for (m = 0; m < 3; m++) { arho1[i][m] = arho1[i][m] + A1j * delij[m]; arho1[j][m] = arho1[j][m] - A1i * delij[m]; @@ -419,8 +412,6 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho3mb[i][m] = arho3mb[i][m] + rhoa3mj*delij[m] / rij; arho3mb[j][m] = arho3mb[j][m] - rhoa3mi*delij[m] / rij; } - //printf("arho1m %f %f\n", arho1m[i][m], arho1m[j][m]); - //printf("arho3mb %f %f\n", arho3mb[i][m], arho3mb[j][m]); for (n = m; n < 3; n++) { arho2[i][nv2] = arho2[i][nv2] + A2j * delij[m] * delij[n]; arho2[j][nv2] = arho2[j][nv2] + A2i * delij[m] * delij[n]; @@ -428,8 +419,6 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho2m[i][nv2] = arho2m[i][nv2] + A2mj*delij[m] * delij[n]; arho2m[j][nv2] = arho2m[j][nv2] + A2mi*delij[m] * delij[n]; } - //printf("delij %f %f\n", delij[m], delij[n]); - //printf("arho2m %d %d %f %f\n", nv2, m, arho2m[i][nv2], arho2m[j][nv2]); nv2 = nv2 + 1; for (p = n; p < 3; p++) { arho3[i][nv3] = arho3[i][nv3] + A3j * delij[m] * delij[n] * delij[p]; @@ -438,8 +427,6 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho3m[i][nv3] = arho3m[i][nv3] + A3mj*delij[m]*delij[n]*delij[p]; arho3m[j][nv3] = arho3m[j][nv3] - A3mi*delij[m]*delij[n]*delij[p]; } - //arho3m[0][0]=500.0; - //printf("arho3m %d %f %f\n", p, arho3m[i][nv3], arho3m[j][nv3]); nv3 = nv3 + 1; } } diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 172f61a2dc..6662aa7512 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -75,9 +75,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double drho3mdr1, drho3mdr2, drho3mds1, drho3mds2; double drho3mdrm1[3], drho3mdrm2[3]; - //printf("----- begin meam_force -----\n"); - //printf("forces f %d %f\n", i, f[0][0]); - third = 1.0 / 3.0; sixth = 1.0 / 6.0; @@ -89,7 +86,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int xitmp = x[i][0]; yitmp = x[i][1]; zitmp = x[i][2]; - //printf("xtmp ytmp ztmp: %f %f %f\n", xitmp, yitmp, zitmp); // Treat each pair @@ -98,7 +94,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int eltj = fmap[type[j]]; scaleij = scale[type[i]][type[j]]; - //printf("in j loop %d %d %d %d %f\n", i, j, eltj, type[j], scrfcn[fnoffset + jn]); if (!iszero(scrfcn[fnoffset + jn]) && eltj >= 0) { sij = scrfcn[fnoffset + jn] * fcpair[fnoffset + jn]; @@ -106,11 +101,9 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int delij[1] = x[j][1] - yitmp; delij[2] = x[j][2] - zitmp; rij2 = delij[0] * delij[0] + delij[1] * delij[1] + delij[2] * delij[2]; - //printf("rij2: %f\n", rij2); if (rij2 < this->cutforcesq) { rij = sqrt(rij2); recip = 1.0 / rij; - //printf("forces, sij, rij = %f %f for i = %d and j = %d\n", sij, rij, i, j); // Compute phi and phip ind = this->eltind[elti][eltj]; pp = rij * this->rdrar; @@ -120,15 +113,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int pp = std::min(pp, 1.0); phi = ((this->phirar3[ind][kk] * pp + this->phirar2[ind][kk]) * pp + this->phirar1[ind][kk]) * pp + this->phirar[ind][kk]; phip = (this->phirar6[ind][kk] * pp + this->phirar5[ind][kk]) * pp + this->phirar4[ind][kk]; - /* - printf("--- phi and phip i = %d ---\n", i); - printf("phi %f %f\n", this->phirar3[ind][kk], this->phirar2[ind][kk]); - printf("phi2 %f %f\n", this->phirar1[ind][kk], this->phirar[ind][kk]); - printf("phip %f %f\n", this->phirar6[ind][kk], this->phirar5[ind][kk]); - printf("phip2 %f\n", this->phirar4[ind][kk]); - printf("-----"); - */ - + if (eflag_either != 0) { double phi_sc = phi * scaleij; if (eflag_global != 0) @@ -233,13 +218,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhoa3i *= t3mi; } - /* - printf("forces, rhoali %f %f %f %f\n", rhoa0i, rhoa1i, rhoa2i, rhoa3i); - printf("forces, rhoalmi %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi); - printf("forces, rhoalj %f %f %f %f\n", rhoa0j, rhoa1j, rhoa2j, rhoa3j); - printf("forces, rhoalmj %f %f %f\n", rhoa1mj, rhoa2mj, rhoa3mj); - */ - nv2 = 0; nv3 = 0; arg1i1 = 0.0; @@ -288,13 +266,11 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int arg = delij[n] * delij[p] * delij[q] * this->v3D[nv3]; arg1i3m = arg1i3m - arho3m[i][nv3] * arg; arg1j3m = arg1j3m + arho3m[j][nv3] * arg; - //printf("^^^ arho3m[i&j][nv3] arg %f %f\n", arho3m[j][nv3], arg); nv3 = nv3 + 1; } arg = delij[n] * delij[p] * this->v2D[nv2]; arg1i2m = arg1i2m + arho2m[i][nv2] * arg; arg1j2m = arg1j2m + arho2m[j][nv2] * arg; - //printf(" arho2m[j][nv2] %d %d %f\n", j, nv2, arho2m[j][nv2]); nv2 = nv2 + 1; } arg1i1m = arg1i1m - arho1m[i][n] * delij[n]; @@ -304,13 +280,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } } - /* - printf("rho1 terms arg1i %d %d %f %f\n", i, j, arg1i1, arg1i1m); - printf("rho1 terms arg1j %d %d %f %f\n", i, j, arg1j1, arg1j1m); - printf("rho1 terms rhoa1j %d %d %f %f\n", i, j, rhoa1j, rhoa1mj); - printf("rho1 terms drhoa1j %d %d %f %f\n", i,j, drhoa1j, drhoa1mj); - */ - // rho0 terms drho0dr1 = drhoa0j * sij; drho0dr2 = drhoa0i * sij; @@ -382,8 +351,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int a2 = 2 * sij / rij2; drho2mdr1 = a2 * (drhoa2mj - 2 * rhoa2mj / rij) * arg1i2m - 2.0 / 3.0 * arho2mb[i] * drhoa2mj * sij; drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - 2.0 / 3.0 * arho2mb[j] * drhoa2mi * sij; - //printf(" drho2mdr arho %d %d %f %f\n", i, j, arho2mb[i], arho2mb[j]); - //printf(" drhoa rhoa arg1 %f %f %f\n", drhoa2mi, rhoa2mi, arg1j2m); a2 = 4 * sij / rij2; for (m = 0; m < 3; m++) { drho2mdrm1[m] = 0.0; @@ -396,13 +363,10 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; } - //printf("forces drho2 %f %f %f %f\n", drho2drm1[0], drho2mdrm1[0], drho2drm2[0], drho2mdrm2[0]); - // rho3m terms rij3 = rij * rij2; a3 = 2 * sij / rij3; a3a = 6.0 / 5.0 * sij / rij; - //printf("args %f %f %f %f\n", arg1i3m, arg3i3m, arg1j3m, arg3j3m); drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; drho3mdr1 *= -1.0; @@ -410,7 +374,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int a3 = 6 * sij / rij3; a3a = 6 * sij / (5 * rij); - //printf("forces drho3mdr %f %f\n", drho3mdr1, drho3mdr2); for (m = 0; m < 3; m++) { drho3mdrm1[m] = 0.0; drho3mdrm2[m] = 0.0; @@ -434,13 +397,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3mdrm1[m] = 0.0; drho3mdrm2[m] = 0.0; } - /* - printf("rho2 terms drho2dr1 %f %f\n", drho2dr1, drho2mdr1); - printf("rho2 terms drho2dr2 %f %f\n", drho2dr2, drho2mdr2); - printf("rho2 terms %f %f\n", drho2drm1[0], drho2mdrm1[0]); - printf("rho2 terms %f %f\n", drho2drm2[0], drho2mdrm2[0]); - */ - // compute derivatives of weighting functions t wrt rij // weighting functions t set to unity for MS-MEAM @@ -518,19 +474,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); if (this->msmeamflag){ - /* - printf("test rhodg %f %f %f\n", dgamma1[i], dgamma2[i], dgamma3[i]); - printf("test rhod dtdr %f %f %f\n", dt1dr1, dt2dr1, dt3dr1); - printf("test rhod rho %f %f %f\n", rho1[i], rho2[i], rho3[i]); - printf("test rhod t %f %f %f\n", t1i, t2i, t3i); - printf(" drhodr1 terms %f %f %f\n", drho1dr1, drho2dr1, drho3dr1); - printf(" %f %f %f\n", drho1mdr1, drho2mdr1, drho3mdr1); - printf(" %f %f %f\n", shpi[0], shpi[1], shpi[2]); - printf(" %f\n", drho0dr1); - printf(" %f %f %f\n", dgamma1[i], dgamma2[i], dgamma3[i]); - printf(" %f %f %f\n", drho1dr2, drho2dr2, drho3dr2); - printf(" %f %f %f\n", drho1mdr2, drho2mdr2, drho3mdr2); - */ drhodr1 = dgamma1[i] * drho0dr1 + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + @@ -541,7 +484,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); - //printf(" drhodr1&2 %f %f\n", drhodr1, drhodr2); for (m = 0; m < 3; m++) { drhodrm1[m] = 0.0; drhodrm2[m] = 0.0; @@ -570,12 +512,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int } } - //printf("rhod terms drhodr1 %f %f\n", drhodr1, drhodr2); - //printf("rhod terms drhodr1 %f %f\n", drhodrm1[0], drhodrm2[0]); - // Compute derivatives wrt sij, but only if necessary if (!iszero(dscrfcn[fnoffset + jn])) { - //printf("computing derivatives wrt sij\n"); drho0ds1 = rhoa0j; drho0ds2 = rhoa0i; a1 = 2.0 / rij; @@ -680,12 +618,6 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; dUdsij = 0.0; - printf("--- compute derivatives of energy wrt ...\n"); - printf("phip sij %f %f\n", phip,sij); - printf("drhodr %f %f\n", drhodr1, drhodr2); - printf("fp %f %f\n", frhop[i], frhop[j]); - printf("dUdrij %f\n", dUdrij); - if (!iszero(dscrfcn[fnoffset + jn])) { dUdsij = phi + frhop[i] * drhods1 + frhop[j] * drhods2; } diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 0335b7ae3d..a0961f68e2 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -87,12 +87,15 @@ void MEAM::meam_setup_done(double* cutmax) } // Compute background densities for reference structure + printf("--- msd 1\n"); compute_reference_density(); // Compute pair potentials and setup arrays for interpolation this->nr = 1000; this->dr = 1.1 * this->rc_meam / this->nr; + printf("--- msd 2\n"); compute_pair_meam(); + printf("--- computed pair meam\n"); } // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc @@ -213,20 +216,17 @@ void MEAM::compute_pair_meam() memory->create(this->phirar5, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar5"); memory->create(this->phirar6, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar6"); - //printf("--- compute_pair_meam ---\n"); + printf("--- looping over pairs\n"); // loop over pairs of element types nv2 = 0; for (a = 0; a < this->neltypes; a++) { for (b = a; b < this->neltypes; b++) { - - //printf("%u\n", this->lattce_meam[a][b]); - //printf("%f %f %f\n", this->Cmin_meam[a][a][b], this->Cmax_meam[a][a][b], this->stheta_meam[a][b]); + printf("--- a b %d %d\n", a, b); // loop over r values and compute for (j = 0; j < this->nr; j++) { r = j * this->dr; - + printf("j %d\n", j); this->phir[nv2][j] = phi_meam(r, a, b); - //printf("%f\n", this->phir[nv2][j]); // if using second-nearest neighbor, solve recursive problem // (see Lee and Baskes, PRB 62(13):8564 eqn.(21)) @@ -241,6 +241,7 @@ void MEAM::compute_pair_meam() // well. if (this->lattce_meam[a][b] == B1 || this->lattce_meam[a][b] == B2 || this->lattce_meam[a][b] == L12 || this->lattce_meam[a][b] == DIA) { + rarat = r * arat; // phi_aa @@ -300,8 +301,9 @@ void MEAM::compute_pair_meam() // endif if (this->zbl_meam[a][b] == 1) { astar = this->alpha_meam[a][b] * (r / this->re_meam[a][b] - 1.0); - if (astar <= -3.0) + if (astar <= -3.0){ this->phir[nv2][j] = zbl(r, this->ielt_meam[a], this->ielt_meam[b]); + } else if (astar > -3.0 && astar < -1.0) { frac = fcut(1 - (astar + 1.0) / (-3.0 + 1.0)); phizbl = zbl(r, this->ielt_meam[a], this->ielt_meam[b]); @@ -346,7 +348,7 @@ double MEAM::phi_meam(double r, int a, int b) double rho1m2, rho2m2, rho3m2; double phi_m = 0.0; - + printf("--- inside phi_meam\n"); // Equation numbers below refer to: // I. Huang et.al., Modelling simul. Mater. Sci. Eng. 3:615 @@ -366,11 +368,7 @@ double MEAM::phi_meam(double r, int a, int b) nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); } - - //printf("--- phi_meam after densref ---\n"); - //printf("rhoim1 %f %f %f\n", rho1m1, rho2m1, rho3m1); - //printf("rhoim2 %f %f %f\n", rho1m2, rho2m2, rho3m2); - + printf("--- got densref\n"); // if densities are too small, numerical problems may result; just return zero if (rho01 <= 1e-14 && rho02 <= 1e-14) return 0.0; @@ -455,17 +453,18 @@ double MEAM::phi_meam(double r, int a, int b) if (this->msmeamflag){ Gam1 = rho11 + rho21 + rho31 - (rho1m1 + rho2m1 + rho3m1); - Gam1 = Gam1/(rho01 * rho01); + //Gam1 = Gam1/(rho01 * rho01); + if (rho01 < 1.0e-14) + Gam1 = 0.0; + else + Gam1 = Gam1 / (rho01 * rho01); Gam2 = rho12 + rho22 + rho32 - (rho1m2 + rho2m2 + rho3m2); - Gam2 = Gam2/(rho02 * rho02); - /* - printf("Gam %f %f\n", Gam1, Gam2); - printf("rhoim1 %f %f %f\n", rho1m1, rho2m1, rho3m1); - printf("rhoim2 %f %f %f\n", rho1m2, rho2m2, rho3m2); - printf("rho1 %f %f %f\n", rho11, rho21, rho31); - printf("rho2 %f %f %f\n", rho12, rho22, rho32); - printf("rho0 %f %f\n", rho01, rho02); - */ + //Gam2 = Gam2/(rho02 * rho02); + if (rho02 < 1.0e-14) + Gam2 = 0.0; + else + Gam2 = Gam2 / (rho02 * rho02); + } else{ Gam1 = (t11av * rho11 + t21av * rho21 + t31av * rho31); if (rho01 < 1.0e-14) @@ -721,25 +720,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou a2 = r / this->re_meam[b][b] - 1.0; rhoa01 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta0_meam[a] * a1); - /* - // Modified: ialloy=1 not used in MSMEAM - rhoa11 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); - rhoa21 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); - rhoa31 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); - rhoa02 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta0_meam[b] * a2); - rhoa12 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); - rhoa22 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); - rhoa32 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); - */ - /* - rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); - rhoa21 = this->rho0_meam[a] * this->t2_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); - rhoa31 = this->rho0_meam[a] * this->t3_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); - rhoa02 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta0_meam[b] * a2); - rhoa12 = this->rho0_meam[b] * this->t1_meam[b] * MathSpecial::fm_exp(-this->beta1_meam[b] * a2); - rhoa22 = this->rho0_meam[b] * this->t2_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); - rhoa32 = this->rho0_meam[b] * this->t3_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); - */ + if (this->msmeamflag){ // in msmeam, the rho variables are multiplied by t here since we don't use ialloy rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); @@ -766,9 +747,6 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa22 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta2_meam[b] * a2); rhoa32 = this->rho0_meam[b] * MathSpecial::fm_exp(-this->beta3_meam[b] * a2); } - //printf("rhoa0 %f %f\n", rhoa01, rhoa02); - //printf("rhoai1 %f %f %f\n", rhoa11, rhoa21, rhoa31); - //printf("rhoai2 %f %f %f\n", rhoa12, rhoa22, rhoa32); lat = this->lattce_meam[a][b]; @@ -780,13 +758,17 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho12 = 0.0; *rho22 = 0.0; *rho32 = 0.0; - *rho1m1 = 0.0; - *rho2m1 = 0.0; - *rho3m1 = 0.0; - *rho1m2 = 0.0; - *rho2m2 = 0.0; - *rho3m2 = 0.0; + printf("--- about to segfault!\n"); + if (this->msmeamflag){ + *rho1m1 = 0.0; + *rho2m1 = 0.0; + *rho3m1 = 0.0; + *rho1m2 = 0.0; + *rho2m2 = 0.0; + *rho3m2 = 0.0; + } + printf("--- keeping tracking density components\n"); // keep track of density components separately; combine in the calling subroutine switch (lat) { case FCC: @@ -862,11 +844,8 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou case L12: *rho01 = 8 * rhoa01 + 4 * rhoa02; *rho02 = 12 * rhoa01; - // don't use with msmeam; use of t's inconsistent with above - // also we should not use ialloy with msmeam - // possibly make ialloy not an option when using msmeam - if (this->ialloy == 1 && !this->msmeamflag) { - //printf("^^^ ialloy=1 in getdensref\n"); + // possibly inconsistent use of t's when using msmeam + if (this->ialloy ==1){ *rho21 = 8. / 3. * MathSpecial::square(rhoa21 * this->t2_meam[a] - rhoa22 * this->t2_meam[b]); denom = 8 * rhoa01 * MathSpecial::square(this->t2_meam[a]) + 4 * rhoa02 * MathSpecial::square(this->t2_meam[b]); if (denom > 0.) @@ -992,12 +971,8 @@ void MEAM::interpolate_meam(int ind) this->rdrar = 1.0 / drar; // phir interp - //printf("--- phir interp ---\n"); - //printf("nrar %d\n", this->nrar); - //printf("phir:\n"); for (j = 0; j < this->nrar; j++) { - //printf("%f\n", phir[ind][j]); this->phirar[ind][j] = this->phir[ind][j]; } this->phirar1[ind][0] = this->phirar[ind][1] - this->phirar[ind][0]; @@ -1025,5 +1000,4 @@ void MEAM::interpolate_meam(int ind) this->phirar5[ind][j] = 2.0 * this->phirar2[ind][j] / drar; this->phirar6[ind][j] = 3.0 * this->phirar3[ind][j] / drar; } - //printf("-----\n"); } diff --git a/src/MEAM/meam_setup_global.cpp b/src/MEAM/meam_setup_global.cpp index 859de87d5a..4b876ae94d 100644 --- a/src/MEAM/meam_setup_global.cpp +++ b/src/MEAM/meam_setup_global.cpp @@ -68,7 +68,7 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* this->t2_meam[i] = t2[i]; this->t3_meam[i] = t3[i]; if (this->msmeamflag){ - printf("^^^^^ Filling tm\n"); + //printf("^^^^^ Filling tm\n"); this->t1m_meam[i] = t1m[i]; this->t2m_meam[i] = t2m[i]; this->t3m_meam[i] = t3m[i]; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 0aec140eed..24a81868d0 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -63,8 +63,13 @@ PairMEAM::PairMEAM(LAMMPS *lmp) : Pair(lmp) // set comm size needed by this Pair - comm_forward = 38+23; // plus 23 for msmeam - comm_reverse = 30+23; // plus 23 for msmeam + if (this->msmeamflag){ + comm_forward = 38+23; // plus 23 for msmeam + comm_reverse = 30+23; // plus 23 for msmeam + } else{ + comm_forward = 38; + comm_reverse = 30; + } } /* ---------------------------------------------------------------------- @@ -134,8 +139,6 @@ void PairMEAM::compute(int eflag, int vflag) int offset = 0; errorflag = 0; - //printf("before meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); - for (ii = 0; ii < inum_half; ii++) { i = ilist_half[ii]; meam_inst->meam_dens_init(i,ntype,type,map,x, @@ -144,18 +147,13 @@ void PairMEAM::compute(int eflag, int vflag) offset); offset += numneigh_half[i]; } - //printf("after meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); - //printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->reverse_comm(this); - //printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); meam_inst->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, &eng_vdwl,eatom,ntype,type,map,scale,errorflag); if (errorflag) error->one(FLERR,"MEAM library error {}",errorflag); - //printf("before forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); comm->forward_comm(this); - //printf("after forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); offset = 0; @@ -279,10 +277,13 @@ void PairMEAM::coeff(int narg, char **arg) // read MEAM library and parameter files // pass all parameters to MEAM package // tell MEAM package that setup is done - + printf("--- Here 1\n"); read_files(lib_file,par_file); + printf("--- Here 1.5\n"); meam_inst->meam_setup_done(&cutmax); + printf("--- Here 2\n"); + // read args that map atom types to MEAM elements // map[i] = which element the Ith atom type is, -1 if not mapped @@ -364,6 +365,7 @@ void PairMEAM::read_files(const std::string &globalfile, const std::string &userfile) { read_global_meam_file(globalfile); + printf("--- global meam is read\n"); read_user_meam_file(userfile); } @@ -754,7 +756,6 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) m = 0; last = first + n; - //printf("pack revcomm last %d\n", last); for (i = first; i < last; i++) { buf[m++] = meam_inst->rho0[i]; buf[m++] = meam_inst->arho2b[i]; @@ -808,7 +809,6 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) int i,j,k,m; m = 0; - //printf("unpack revcomm n %d\n", n); for (i = 0; i < n; i++) { j = list[i]; meam_inst->rho0[j] += buf[m++]; From ff9ccc96bfeed29f65d2c5ad4ba4faf1b0d3f468 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 17 Jan 2023 21:11:07 -0700 Subject: [PATCH 13/43] Clean up --- examples/meam/msmeam/test.dump | 12 +-- examples/meam/msmeam/test.log | 22 ++--- examples/meam/msmeam/test.out | 64 +++--------- src/MEAM/arho2 | 175 --------------------------------- src/MEAM/meam_setup_done.cpp | 10 -- src/MEAM/meam_setup_global.cpp | 2 - src/MEAM/pair_meam.cpp | 9 +- src/tokenizer.cpp | 2 - 8 files changed, 30 insertions(+), 266 deletions(-) delete mode 100644 src/MEAM/arho2 diff --git a/examples/meam/msmeam/test.dump b/examples/meam/msmeam/test.dump index 45d17a5228..6faee7ce12 100644 --- a/examples/meam/msmeam/test.dump +++ b/examples/meam/msmeam/test.dump @@ -7,9 +7,9 @@ ITEM: BOX BOUNDS pp pp pp -4.0000000000000000e+00 4.0000000000000000e+00 -4.0000000000000000e+00 4.0000000000000000e+00 ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -131.977 -88.3322 0 22.9236 -2.14786e+08 -1.62719e+08 -0 -2.05378e+07 -0 -0 -2 2.2 0 0 120.857 -0.482171 0 14.7745 -2.12113e+08 -0 -0 403352 -0 -0 -3 0.3 2.3 0 11.1201 88.8144 0 8.61773 -2.67245e+06 -1.62719e+08 -0 -2.09411e+07 -0 -0 +1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 +2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 ITEM: TIMESTEP 1 ITEM: NUMBER OF ATOMS @@ -19,6 +19,6 @@ ITEM: BOX BOUNDS pp pp pp -4.0000000000000000e+00 4.0000000000000000e+00 -4.0000000000000000e+00 4.0000000000000000e+00 ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -131.977 -88.3322 0 22.9236 -2.14786e+08 -1.62719e+08 -0 -2.05378e+07 -0 -0 -2 2.2 0 0 120.857 -0.482171 0 14.7745 -2.12113e+08 -0 -0 403352 -0 -0 -3 0.3 2.3 0 11.1201 88.8144 0 8.61773 -2.67245e+06 -1.62719e+08 -0 -2.09411e+07 -0 -0 +1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 +2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 diff --git a/examples/meam/msmeam/test.log b/examples/meam/msmeam/test.log index 813acd55da..f80c80aa30 100644 --- a/examples/meam/msmeam/test.log +++ b/examples/meam/msmeam/test.log @@ -83,24 +83,24 @@ Neighbor list info ... pair build: halffull/newton stencil: none bin: none -Per MPI rank memory allocation (min/avg/max) = 10.71 | 10.71 | 10.71 Mbytes +Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms - 0 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 - 1 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 -Loop time of 6.7095e-05 on 1 procs for 1 steps with 3 atoms + 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 + 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 +Loop time of 8.6099e-05 on 1 procs for 1 steps with 3 atoms -Performance: 1287.726 ns/day, 0.019 hours/ns, 14904.240 timesteps/s -77.5% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1003.496 ns/day, 0.024 hours/ns, 11614.537 timesteps/s +65.0% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 2.7954e-05 | 2.7954e-05 | 2.7954e-05 | 0.0 | 41.66 +Pair | 2.6205e-05 | 2.6205e-05 | 2.6205e-05 | 0.0 | 30.44 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 3.164e-06 | 3.164e-06 | 3.164e-06 | 0.0 | 4.72 -Output | 3.1658e-05 | 3.1658e-05 | 3.1658e-05 | 0.0 | 47.18 -Modify | 1.712e-06 | 1.712e-06 | 1.712e-06 | 0.0 | 2.55 -Other | | 2.607e-06 | | | 3.89 +Comm | 4.272e-06 | 4.272e-06 | 4.272e-06 | 0.0 | 4.96 +Output | 5.2102e-05 | 5.2102e-05 | 5.2102e-05 | 0.0 | 60.51 +Modify | 3.79e-07 | 3.79e-07 | 3.79e-07 | 0.0 | 0.44 +Other | | 3.141e-06 | | | 3.65 Nlocal: 3 ave 3 max 3 min Histogram: 1 0 0 0 0 0 0 0 0 0 diff --git a/examples/meam/msmeam/test.out b/examples/meam/msmeam/test.out index 72592b4673..30a6616f40 100644 --- a/examples/meam/msmeam/test.out +++ b/examples/meam/msmeam/test.out @@ -80,8 +80,6 @@ Tokenizer::next_double() current = 0.0 Tokenizer::next_double() current = 2.0 Tokenizer::next_double() current = 0.70 Tokenizer::next_int() current = 0 -^^^^^ Filling tm -^^^^^ Filling tm Tokenizer::next_double() current = 1 Tokenizer::next_double() current = 1 Tokenizer::next_double() current = 0 @@ -214,64 +212,24 @@ Setting up Verlet run ... Unit style : metal Current step : 0 Time step : 0.001 ---- compute derivatives of energy wrt ... -phip sij -116.571511 1.000000 -drhodr -1.327736 -0.011564 -fp 4.976162 -13.618158 -dUdrij -123.021058 ---- compute derivatives of energy wrt ... -phip sij -86.757953 1.000000 -drhodr -0.821855 -0.007170 -fp 4.976162 -14.961215 -dUdrij -90.740359 ---- compute derivatives of energy wrt ... -phip sij 0.129370 1.000000 -drhodr -0.000000 -0.002189 -fp -13.618158 4.976162 -dUdrij 0.118475 ---- compute derivatives of energy wrt ... -phip sij 0.140206 1.000000 -drhodr -0.000000 -0.002956 -fp -14.961215 4.976162 -dUdrij 0.125499 -Per MPI rank memory allocation (min/avg/max) = 10.71 | 10.71 | 10.71 Mbytes +Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms - 0 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 ---- compute derivatives of energy wrt ... -phip sij -116.571511 1.000000 -drhodr -1.327736 -0.011564 -fp 4.976162 -13.618158 -dUdrij -123.021058 ---- compute derivatives of energy wrt ... -phip sij -86.757953 1.000000 -drhodr -0.821855 -0.007170 -fp 4.976162 -14.961215 -dUdrij -90.740359 ---- compute derivatives of energy wrt ... -phip sij 0.129370 1.000000 -drhodr -0.000000 -0.002189 -fp -13.618158 4.976162 -dUdrij 0.118475 ---- compute derivatives of energy wrt ... -phip sij 0.140206 1.000000 -drhodr -0.000000 -0.002956 -fp -14.961215 4.976162 -dUdrij 0.125499 - 1 0 15.438614 491542.52 839006.02 635621.55 0 80225.587 0 0 8 8 8 512 15.438614 -Loop time of 6.7095e-05 on 1 procs for 1 steps with 3 atoms + 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 + 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 +Loop time of 8.3795e-05 on 1 procs for 1 steps with 3 atoms -Performance: 1287.726 ns/day, 0.019 hours/ns, 14904.240 timesteps/s -77.5% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1031.088 ns/day, 0.023 hours/ns, 11933.886 timesteps/s +57.3% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 2.7954e-05 | 2.7954e-05 | 2.7954e-05 | 0.0 | 41.66 +Pair | 2.1835e-05 | 2.1835e-05 | 2.1835e-05 | 0.0 | 26.06 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 3.164e-06 | 3.164e-06 | 3.164e-06 | 0.0 | 4.72 -Output | 3.1658e-05 | 3.1658e-05 | 3.1658e-05 | 0.0 | 47.18 -Modify | 1.712e-06 | 1.712e-06 | 1.712e-06 | 0.0 | 2.55 -Other | | 2.607e-06 | | | 3.89 +Comm | 3.128e-06 | 3.128e-06 | 3.128e-06 | 0.0 | 3.73 +Output | 5.4931e-05 | 5.4931e-05 | 5.4931e-05 | 0.0 | 65.55 +Modify | 1.601e-06 | 1.601e-06 | 1.601e-06 | 0.0 | 1.91 +Other | | 2.3e-06 | | | 2.74 Nlocal: 3 ave 3 max 3 min Histogram: 1 0 0 0 0 0 0 0 0 0 diff --git a/src/MEAM/arho2 b/src/MEAM/arho2 deleted file mode 100644 index 57c3b47f17..0000000000 --- a/src/MEAM/arho2 +++ /dev/null @@ -1,175 +0,0 @@ -./pair_meam.cpp: meam_inst->meam_dens_setup(atom->nmax, nall, n); -./pair_meam.cpp: printf("before meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); -./pair_meam.cpp: meam_inst->meam_dens_init(i,ntype,type,map,x, -./pair_meam.cpp: printf("after meam_dens_init %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); -./pair_meam.cpp: printf("before revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); -./pair_meam.cpp: printf("after revcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); -./pair_meam.cpp: meam_inst->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, -./pair_meam.cpp: printf("before forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); -./pair_meam.cpp: printf("after forcomm %f %f\n", meam_inst->arho2m[0][0], meam_inst->arho3m[0][0]); -./pair_meam.cpp: meam_inst->meam_force(i,eflag_global,eflag_atom,vflag_global, -./pair_meam.cpp: meam_inst->msmeamflag = 0; -./pair_meam.cpp: meam_inst->msmeamflag = 1; -./pair_meam.cpp: meam_inst->meam_setup_done(&cutmax); -./pair_meam.cpp: meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), -./pair_meam.cpp: meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), -./pair_meam.cpp: meam_inst->meam_setup_param(which,value,nindex,index,&errorflag); -./pair_meam.cpp: buf[m++] = meam_inst->rho0[j]; -./pair_meam.cpp: buf[m++] = meam_inst->rho1[j]; -./pair_meam.cpp: buf[m++] = meam_inst->rho2[j]; -./pair_meam.cpp: buf[m++] = meam_inst->rho3[j]; -./pair_meam.cpp: buf[m++] = meam_inst->frhop[j]; -./pair_meam.cpp: buf[m++] = meam_inst->gamma[j]; -./pair_meam.cpp: buf[m++] = meam_inst->dgamma1[j]; -./pair_meam.cpp: buf[m++] = meam_inst->dgamma2[j]; -./pair_meam.cpp: buf[m++] = meam_inst->dgamma3[j]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2b[j]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][3]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][4]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[j][5]; -./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3[j][k]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3b[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3b[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3b[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->t_ave[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->t_ave[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->t_ave[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2mb[j]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1m[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1m[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1m[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][3]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][4]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[j][5]; -./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3m[j][k]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[j][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[j][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[j][2]; -./pair_meam.cpp: meam_inst->rho0[i] = buf[m++]; -./pair_meam.cpp: meam_inst->rho1[i] = buf[m++]; -./pair_meam.cpp: meam_inst->rho2[i] = buf[m++]; -./pair_meam.cpp: meam_inst->rho3[i] = buf[m++]; -./pair_meam.cpp: meam_inst->frhop[i] = buf[m++]; -./pair_meam.cpp: meam_inst->gamma[i] = buf[m++]; -./pair_meam.cpp: meam_inst->dgamma1[i] = buf[m++]; -./pair_meam.cpp: meam_inst->dgamma2[i] = buf[m++]; -./pair_meam.cpp: meam_inst->dgamma3[i] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2b[i] = buf[m++]; -./pair_meam.cpp: meam_inst->arho1[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->arho1[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->arho1[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2[i][3] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2[i][4] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2[i][5] = buf[m++]; -./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3[i][k] = buf[m++]; -./pair_meam.cpp: meam_inst->arho3b[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->arho3b[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->arho3b[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->t_ave[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->t_ave[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->t_ave[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->tsq_ave[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->tsq_ave[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->tsq_ave[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2mb[i] = buf[m++]; -./pair_meam.cpp: meam_inst->arho1m[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->arho1m[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->arho1m[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[i][2] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[i][3] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[i][4] = buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[i][5] = buf[m++]; -./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3m[i][k] = buf[m++]; -./pair_meam.cpp: meam_inst->arho3mb[i][0] = buf[m++]; -./pair_meam.cpp: meam_inst->arho3mb[i][1] = buf[m++]; -./pair_meam.cpp: meam_inst->arho3mb[i][2] = buf[m++]; -./pair_meam.cpp: buf[m++] = meam_inst->rho0[i]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2b[i]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][3]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][4]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2[i][5]; -./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3[i][k]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3b[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3b[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3b[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->t_ave[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->t_ave[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->t_ave[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->tsq_ave[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2mb[i]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1m[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1m[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho1m[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][2]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][3]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][4]; -./pair_meam.cpp: buf[m++] = meam_inst->arho2m[i][5]; -./pair_meam.cpp: for (k = 0; k < 10; k++) buf[m++] = meam_inst->arho3m[i][k]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[i][0]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[i][1]; -./pair_meam.cpp: buf[m++] = meam_inst->arho3mb[i][2]; -./pair_meam.cpp: meam_inst->rho0[j] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2b[j] += buf[m++]; -./pair_meam.cpp: meam_inst->arho1[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->arho1[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->arho1[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2[j][3] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2[j][4] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2[j][5] += buf[m++]; -./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3[j][k] += buf[m++]; -./pair_meam.cpp: meam_inst->arho3b[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->arho3b[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->arho3b[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->t_ave[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->t_ave[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->t_ave[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->tsq_ave[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->tsq_ave[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->tsq_ave[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2mb[j] += buf[m++]; -./pair_meam.cpp: meam_inst->arho1m[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->arho1m[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->arho1m[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[j][2] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[j][3] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[j][4] += buf[m++]; -./pair_meam.cpp: meam_inst->arho2m[j][5] += buf[m++]; -./pair_meam.cpp: for (k = 0; k < 10; k++) meam_inst->arho3m[j][k] += buf[m++]; -./pair_meam.cpp: meam_inst->arho3mb[j][0] += buf[m++]; -./pair_meam.cpp: meam_inst->arho3mb[j][1] += buf[m++]; -./pair_meam.cpp: meam_inst->arho3mb[j][2] += buf[m++]; -./pair_meam.cpp: double bytes = 11 * meam_inst->nmax * sizeof(double); -./pair_meam.cpp: bytes += (double)(3 + 6 + 10 + 3 + 3 + 3) * meam_inst->nmax * sizeof(double); -./pair_meam.cpp: bytes += (double)3 * meam_inst->maxneigh * sizeof(double); diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index a0961f68e2..493cb4d859 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -87,15 +87,12 @@ void MEAM::meam_setup_done(double* cutmax) } // Compute background densities for reference structure - printf("--- msd 1\n"); compute_reference_density(); // Compute pair potentials and setup arrays for interpolation this->nr = 1000; this->dr = 1.1 * this->rc_meam / this->nr; - printf("--- msd 2\n"); compute_pair_meam(); - printf("--- computed pair meam\n"); } // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc @@ -216,16 +213,13 @@ void MEAM::compute_pair_meam() memory->create(this->phirar5, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar5"); memory->create(this->phirar6, (this->neltypes * (this->neltypes + 1)) / 2, this->nr, "pair:phirar6"); - printf("--- looping over pairs\n"); // loop over pairs of element types nv2 = 0; for (a = 0; a < this->neltypes; a++) { for (b = a; b < this->neltypes; b++) { - printf("--- a b %d %d\n", a, b); // loop over r values and compute for (j = 0; j < this->nr; j++) { r = j * this->dr; - printf("j %d\n", j); this->phir[nv2][j] = phi_meam(r, a, b); // if using second-nearest neighbor, solve recursive problem @@ -348,7 +342,6 @@ double MEAM::phi_meam(double r, int a, int b) double rho1m2, rho2m2, rho3m2; double phi_m = 0.0; - printf("--- inside phi_meam\n"); // Equation numbers below refer to: // I. Huang et.al., Modelling simul. Mater. Sci. Eng. 3:615 @@ -368,7 +361,6 @@ double MEAM::phi_meam(double r, int a, int b) nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); } - printf("--- got densref\n"); // if densities are too small, numerical problems may result; just return zero if (rho01 <= 1e-14 && rho02 <= 1e-14) return 0.0; @@ -758,7 +750,6 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho12 = 0.0; *rho22 = 0.0; *rho32 = 0.0; - printf("--- about to segfault!\n"); if (this->msmeamflag){ *rho1m1 = 0.0; *rho2m1 = 0.0; @@ -768,7 +759,6 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho3m2 = 0.0; } - printf("--- keeping tracking density components\n"); // keep track of density components separately; combine in the calling subroutine switch (lat) { case FCC: diff --git a/src/MEAM/meam_setup_global.cpp b/src/MEAM/meam_setup_global.cpp index 4b876ae94d..1d7ba9ac68 100644 --- a/src/MEAM/meam_setup_global.cpp +++ b/src/MEAM/meam_setup_global.cpp @@ -55,7 +55,6 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* this->beta2_meam[i] = b2[i]; this->beta3_meam[i] = b3[i]; if (this->msmeamflag){ - //printf("^^^^^ Filling betam\n"); this->beta1m_meam[i] = b1m[i]; this->beta2m_meam[i] = b2m[i]; this->beta3m_meam[i] = b3m[i]; @@ -68,7 +67,6 @@ MEAM::meam_setup_global(int nelt, lattice_t* lat, int* ielement, double* /*atwt* this->t2_meam[i] = t2[i]; this->t3_meam[i] = t3[i]; if (this->msmeamflag){ - //printf("^^^^^ Filling tm\n"); this->t1m_meam[i] = t1m[i]; this->t2m_meam[i] = t2m[i]; this->t3m_meam[i] = t3m[i]; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 24a81868d0..f7ea36311f 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -98,7 +98,6 @@ void PairMEAM::compute(int eflag, int vflag) int i,ii,n,inum_half,errorflag; int *ilist_half,*numneigh_half,**firstneigh_half; int *numneigh_full,**firstneigh_full; - ev_init(eflag,vflag); // neighbor list info @@ -277,12 +276,9 @@ void PairMEAM::coeff(int narg, char **arg) // read MEAM library and parameter files // pass all parameters to MEAM package // tell MEAM package that setup is done - printf("--- Here 1\n"); - read_files(lib_file,par_file); - printf("--- Here 1.5\n"); - meam_inst->meam_setup_done(&cutmax); - printf("--- Here 2\n"); + read_files(lib_file,par_file); + meam_inst->meam_setup_done(&cutmax); // read args that map atom types to MEAM elements // map[i] = which element the Ith atom type is, -1 if not mapped @@ -365,7 +361,6 @@ void PairMEAM::read_files(const std::string &globalfile, const std::string &userfile) { read_global_meam_file(globalfile); - printf("--- global meam is read\n"); read_user_meam_file(userfile); } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index d45fdea692..89c5b99dfb 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -255,7 +255,6 @@ std::string ValueTokenizer::next_string() int ValueTokenizer::next_int() { std::string current = tokens.next(); - printf("Tokenizer::next_int() current = %s\n", current.c_str()); if (!utils::is_integer(current)) { throw InvalidIntegerException(current); } return atoi(current.c_str()); } @@ -286,7 +285,6 @@ tagint ValueTokenizer::next_tagint() double ValueTokenizer::next_double() { std::string current = tokens.next(); - printf("Tokenizer::next_double() current = %s\n", current.c_str()); if (!utils::is_double(current)) { throw InvalidFloatException(current); } return atof(current.c_str()); } From 7cf9b309432cb3d379f53482b45691b8748e1500 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 17 Jan 2023 21:27:21 -0700 Subject: [PATCH 14/43] Confirm agreement with old meam example --- examples/meam/dump.xyz | 130 ------------------------------- examples/meam/in.meam | 5 +- examples/meam/msmeam/run_loop.sh | 9 --- examples/meam/msmeam/test.data | 2 +- examples/meam/msmeam/test.log | 18 ++--- 5 files changed, 12 insertions(+), 152 deletions(-) delete mode 100644 examples/meam/dump.xyz delete mode 100755 examples/meam/msmeam/run_loop.sh diff --git a/examples/meam/dump.xyz b/examples/meam/dump.xyz deleted file mode 100644 index 60e60ac7e7..0000000000 --- a/examples/meam/dump.xyz +++ /dev/null @@ -1,130 +0,0 @@ -128 - Atoms. Timestep: 0 -2 -2.93785 -4.45926 -4.81092 -2 5.62221 -2.7335 -1.71576 -2 -2.66146 -5.54311 1.63537 -2 -5.43268 -4.61746 5.94523 -2 5.86792 -0.112054 -3.58394 -2 -3.71746 -0.662331 -0.371479 -2 -5.07247 -2.56716 4.41035 -2 -3.39514 0.934113 4.93107 -2 -5.43476 1.95238 -5.61809 -2 -4.58847 2.29045 -1.05977 -2 -5.90587 0.621241 2.01276 -2 -4.76807 0.196574 4.32678 -2 -5.42289 5.25697 -4.51629 -2 -5.2684 -5.91937 -2.86487 -2 -2.86109 1.04847 2.02991 -2 -4.07111 5.3133 3.80095 -2 -0.194715 -4.16777 -5.69509 -2 -2.98927 -3.16474 -1.61739 -2 -0.912931 -4.38191 -0.160186 -2 -2.45137 -5.24665 4.88829 -2 -2.888 -0.163345 -3.34011 -1 -4.67388 -1.38073 -2.29468 -2 -0.697395 -1.48853 0.600516 -1 -2.73922 -2.47748 0.238719 -2 -2.65513 -2.723 2.63503 -1 -3.46443 -4.60281 3.38178 -2 0.722761 -2.07094 2.92147 -1 -2.10006 -3.21313 5.72734 -2 -3.10576 2.32048 -2.27256 -1 -2.22988 0.716839 -1.31072 -2 -1.86983 1.40068 0.726511 -1 -4.11034 -0.709334 1.93418 -2 -0.350558 3.27072 -0.288066 -1 -3.40454 -1.4384 4.39035 -2 -3.09405 1.41325 -5.36355 -1 -4.45607 1.20729 -3.73102 -2 -2.6061 4.63735 -4.69039 -1 -3.34774 4.67681 -2.62847 -2 0.81217 4.86024 -4.67109 -1 -2.57569 3.37407 -0.213635 -2 -0.386798 5.87456 -2.11199 -1 -1.67662 1.33743 3.87415 -2 -0.877061 3.37359 4.3847 -1 -1.86093 3.31582 -5.97866 -1 -5.27323 -4.60733 -0.958175 -1 -2.78887 -5.69102 -0.792202 -1 -2.47172 4.58019 2.50832 -1 -3.88199 5.84566 -5.75634 -2 2.23148 -2.77292 -5.23569 -2 0.298198 -3.13853 -3.16082 -2 2.88108 -3.46587 -0.58232 -2 0.250962 -5.75952 2.73898 -2 -0.293412 -0.802943 -3.36985 -1 -1.00757 -2.04819 -1.94193 -2 2.07291 1.49224 -2.38981 -1 1.11109 -3.20042 0.949108 -2 1.67743 -0.790186 2.51588 -1 -0.83423 -4.33425 2.09715 -2 3.27474 -1.31079 4.78847 -1 1.71262 -3.36915 4.5581 -2 0.47706 1.7769 -5.33399 -1 0.294439 0.589278 -2.20301 -2 2.20393 3.15576 -2.02768 -1 -0.0404494 0.476782 1.03964 -2 1.13959 2.37634 2.3481 -1 -0.973837 -1.63252 3.75386 -2 -0.3292 0.299699 5.27708 -1 -1.61856 -0.396427 -5.17712 -2 2.59999 -5.19777 5.82307 -1 -1.62707 2.32109 -3.62999 -2 3.65327 4.92826 -5.43193 -1 0.0788934 4.0241 -2.50115 -2 2.85565 2.61687 2.11255 -1 0.973899 2.62554 4.34121 -2 3.74529 3.45214 4.59464 -1 2.08052 4.7039 5.32803 -1 -1.03242 -5.8155 -4.32658 -1 0.762244 -4.36316 -1.31566 -1 0.326368 3.99374 1.61723 -1 -0.435011 -5.79971 4.59591 -2 3.91611 -4.60528 -3.31917 -2 1.92407 5.73451 -1.97543 -2 -5.97945 -4.23694 1.86465 -2 4.334 -4.48452 5.37374 -2 2.27555 -0.632774 -5.79318 -1 1.87282 -1.55049 -3.456 -2 3.45581 -1.10541 -1.83331 -1 4.37882 -1.94665 -0.328464 -2 2.59992 -3.7549 2.57406 -1 3.99839 -4.48566 1.19687 -2 -5.72956 -2.14757 -5.99636 -1 4.26641 -2.6989 -5.80055 -2 4.52547 2.29068 -3.47658 -1 2.36031 1.34164 -4.41738 -2 4.77671 1.40612 -0.752462 -1 1.80727 -0.783597 -0.458199 -2 4.4745 0.373622 2.10683 -1 3.60812 -1.73157 2.40191 -2 4.62814 -0.286541 4.47565 -1 1.79752 0.289353 4.23308 -2 5.83415 4.49865 -5.96645 -1 3.24013 4.16552 -3.507 -2 4.87203 4.871 -2.33644 -1 3.55265 1.22628 0.692683 -2 -5.81733 4.54205 1.55789 -1 3.96832 1.54411 3.82844 -2 -5.53493 1.9067 3.75041 -1 4.47286 2.64156 -5.59528 -1 1.70009 -4.81154 -4.19539 -1 1.72215 4.18784 -0.371268 -1 3.92182 4.59356 1.32634 -1 3.13102 -5.89225 3.60012 -1 4.75587 -2.28778 -3.47421 -1 -5.50503 -2.70274 0.874887 -1 5.84186 -4.60644 3.87141 -1 -4.75169 -3.1692 -4.40998 -1 3.9405 0.71887 -2.28988 -1 -5.68697 0.204238 -0.191674 -1 5.89496 -1.24226 3.12013 -1 5.96758 -0.0712572 5.8964 -1 -5.62085 3.36 -2.94935 -1 5.20653 3.45179 -0.380089 -1 -4.69945 2.54896 1.82974 -1 -4.07584 3.07262 5.0648 -1 4.15876 -5.08968 -1.14435 -1 -4.69638 -5.74298 1.13578 -1 5.59942 4.6887 3.59483 -1 5.09884 -5.37744 -4.90513 diff --git a/examples/meam/in.meam b/examples/meam/in.meam index 550d2fb4dc..6c065becff 100644 --- a/examples/meam/in.meam +++ b/examples/meam/in.meam @@ -14,10 +14,9 @@ neighbor 0.3 bin neigh_modify delay 10 fix 1 all nve -thermo 1 +thermo 10 timestep 0.001 -dump 1 all xyz 100 dump.xyz #dump 1 all atom 50 dump.meam #dump 2 all image 10 image.*.jpg element element & @@ -28,4 +27,4 @@ dump 1 all xyz 100 dump.xyz # axes yes 0.8 0.02 view 60 -30 #dump_modify 3 pad 3 element Si C -run 10 +run 100 \ No newline at end of file diff --git a/examples/meam/msmeam/run_loop.sh b/examples/meam/msmeam/run_loop.sh deleted file mode 100755 index 3a63672cce..0000000000 --- a/examples/meam/msmeam/run_loop.sh +++ /dev/null @@ -1,9 +0,0 @@ -# run in a loop to test for rare segfaults -for (( ; ; )) -do - ~/lammps/build-msmeam/lmp -in test3.in - # terminate loop if seg fault - if [[ $? -eq 139 ]]; then - exit 1 - fi -done \ No newline at end of file diff --git a/examples/meam/msmeam/test.data b/examples/meam/msmeam/test.data index f379aeccb5..1347192780 100644 --- a/examples/meam/msmeam/test.data +++ b/examples/meam/msmeam/test.data @@ -1,4 +1,4 @@ -LAMMPS data file via write_data, version 23 Jun 2022, timestep = 1 +LAMMPS data file via write_data, version 22 Dec 2022, timestep = 1 3 atoms 2 atom types diff --git a/examples/meam/msmeam/test.log b/examples/meam/msmeam/test.log index f80c80aa30..e1de5b3934 100644 --- a/examples/meam/msmeam/test.log +++ b/examples/meam/msmeam/test.log @@ -68,7 +68,7 @@ dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stres run 1 WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) Neighbor list info ... - update every 1 steps, delay 0 steps, check yes + update: every = 1 steps, delay = 0 steps, check = yes max neighbors/atom: 2000, page size: 100000 master list distance cutoff = 6.9 ghost atom cutoff = 6.9 @@ -87,20 +87,20 @@ Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 -Loop time of 8.6099e-05 on 1 procs for 1 steps with 3 atoms +Loop time of 0.000110387 on 1 procs for 1 steps with 3 atoms -Performance: 1003.496 ns/day, 0.024 hours/ns, 11614.537 timesteps/s -65.0% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 782.701 ns/day, 0.031 hours/ns, 9059.038 timesteps/s, 27.177 katom-step/s +56.2% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 2.6205e-05 | 2.6205e-05 | 2.6205e-05 | 0.0 | 30.44 +Pair | 2.6411e-05 | 2.6411e-05 | 2.6411e-05 | 0.0 | 23.93 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 4.272e-06 | 4.272e-06 | 4.272e-06 | 0.0 | 4.96 -Output | 5.2102e-05 | 5.2102e-05 | 5.2102e-05 | 0.0 | 60.51 -Modify | 3.79e-07 | 3.79e-07 | 3.79e-07 | 0.0 | 0.44 -Other | | 3.141e-06 | | | 3.65 +Comm | 4.455e-06 | 4.455e-06 | 4.455e-06 | 0.0 | 4.04 +Output | 7.4411e-05 | 7.4411e-05 | 7.4411e-05 | 0.0 | 67.41 +Modify | 7.54e-07 | 7.54e-07 | 7.54e-07 | 0.0 | 0.68 +Other | | 4.356e-06 | | | 3.95 Nlocal: 3 ave 3 max 3 min Histogram: 1 0 0 0 0 0 0 0 0 0 From 3eb22313ed4acda9737d9354e7d4582d02812c53 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Thu, 19 Jan 2023 19:26:42 -0700 Subject: [PATCH 15/43] Default nvcc wrapper --- lib/kokkos/bin/nvcc_wrapper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kokkos/bin/nvcc_wrapper b/lib/kokkos/bin/nvcc_wrapper index 8c168412e7..656ab84a5b 100755 --- a/lib/kokkos/bin/nvcc_wrapper +++ b/lib/kokkos/bin/nvcc_wrapper @@ -12,8 +12,8 @@ # or g++ as their back-end compiler. The defaults can be overwritten # by using the usual arguments (e.g., -arch=sm_30 -ccbin icpc). -default_arch="sm_35" -#default_arch="sm_50" +#default_arch="sm_35" +default_arch="sm_50" # # The default C++ compiler. From bb2553b079c9fb1cc5d9763a379d2835c8810c53 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Fri, 20 Jan 2023 13:02:50 -0700 Subject: [PATCH 16/43] Set comm size outside constructor --- src/MEAM/pair_meam.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index c1af98a8a7..32fc286625 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -61,16 +61,6 @@ PairMEAM::PairMEAM(LAMMPS *lmp) : Pair(lmp) nlibelements = 0; meam_inst = new MEAM(memory); scale = nullptr; - - // set comm size needed by this Pair - - if (this->msmeamflag){ - comm_forward = 38+23; // plus 23 for msmeam - comm_reverse = 30+23; // plus 23 for msmeam - } else{ - comm_forward = 38; - comm_reverse = 30; - } } /* ---------------------------------------------------------------------- @@ -138,7 +128,6 @@ void PairMEAM::compute(int eflag, int vflag) int offset = 0; errorflag = 0; - for (ii = 0; ii < inum_half; ii++) { i = ilist_half[ii]; meam_inst->meam_dens_init(i,ntype,type,map,x, @@ -206,6 +195,15 @@ void PairMEAM::settings(int narg, char **arg) error->all(FLERR, "Unknown pair style zero option {}", arg[0]); } + // set comm size needed by this Pair + + if (this->msmeamflag){ + comm_forward = 38+23; // plus 23 for msmeam + comm_reverse = 30+23; // plus 23 for msmeam + } else{ + comm_forward = 38; + comm_reverse = 30; + } } /* ---------------------------------------------------------------------- From 1812cf6264ac37134080c63e4f2b60bc18bbe9f8 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Mon, 23 Jan 2023 15:10:59 -0700 Subject: [PATCH 17/43] Begin kokkos implementation up to calc_rho1 function --- src/KOKKOS/meam_dens_final_kokkos.h | 12 +- src/KOKKOS/meam_dens_init_kokkos.h | 145 ++++++++++++++++- src/KOKKOS/meam_impl_kokkos.h | 8 + src/KOKKOS/meam_kokkos.h | 32 ++++ src/KOKKOS/pair_meam_kokkos.cpp | 236 +++++++++++++++++++++++++++- src/KOKKOS/pair_meam_kokkos.h | 3 + 6 files changed, 420 insertions(+), 16 deletions(-) diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index bcc7b558dc..0a709be2b3 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -36,6 +36,7 @@ MEAMKokkos::meam_dens_final(int nlocal, int eflag_either, int eflag_ Kokkos::deep_copy(d_errorflag,0); + printf("- inside meam_dens_final\n"); // Complete the calculation of density copymode = 1; @@ -57,11 +58,20 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT F_FLOAT denom, rho_bkgd, Fl; double scaleii; + printf("- inside TagMEAMDensFinal msmeamflag=%d i=%d\n", msmeamflag, i); + int elti = d_map[type[i]]; if (elti >= 0) { scaleii = d_scale(type[i],type[i]); d_rho1[i] = 0.0; - d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; + //printf("%f\n", arho1m[i][0]); + //printf("%f\n", arho2mb[i]); + //if (msmeamflag){ + // d_rho2[i] = -1.0 / 3.0 * (arho2b[i] * arho2b[i] + // - arho2mb[i] * arho2mb[i]); + //} else{ + d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; + //} d_rho3[i] = 0.0; for (int m = 0; m < 3; m++) { d_rho1[i] += d_arho1(i,m) * d_arho1(i,m); diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index 31ac046dcf..83005206da 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -24,6 +24,7 @@ template template KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMDensInit, const int &i) const { + printf("- inside TagMEAMDensInit i=%d\n", i); int ii, offsetval; ii = d_ilist_half[i]; offsetval = d_offset[i]; @@ -43,11 +44,26 @@ void MEAMKokkos::operator()(TagMEAMZero, const int &i) const { d_rho0[i] = 0.0; d_arho2b[i] = 0.0; d_arho1(i,0) = d_arho1(i,1) = d_arho1(i,2) = 0.0; - for (int j = 0; j < 6; j++) + if (this->msmeamflag){ + d_arho2mb[i] = 0.0; + d_arho1m(i,0) = d_arho1m(i,1) = d_arho1m(i,2) = 0.0; + } + for (int j = 0; j < 6; j++){ d_arho2(i,j) = 0.0; - for (int j = 0; j < 10; j++) + if (msmeamflag){ + d_arho2m(i,j) = 0.0; + } + } + for (int j = 0; j < 10; j++){ d_arho3(i,j) = 0.0; + if (msmeamflag){ + d_arho3m(i,j) = 0.0; + } + } d_arho3b(i,0) = d_arho3b(i,1) = d_arho3b(i,2) = 0.0; + if (msmeamflag){ + d_arho3mb(i,0) = d_arho3mb(i,1) = d_arho3mb(i,2) = 0.0; + } d_t_ave(i,0) = d_t_ave(i,1) = d_t_ave(i,2) = 0.0; d_tsq_ave(i,0) = d_tsq_ave(i,1) = d_tsq_ave(i,2) = 0.0; } @@ -58,6 +74,8 @@ template void MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) { + + printf("- inside meam_dens_setup\n"); MemoryKokkos *memoryKK = (MemoryKokkos *)memory; // grow local arrays if necessary @@ -80,13 +98,20 @@ MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memoryKK->destroy_kokkos(k_arho3b,arho3b); memoryKK->destroy_kokkos(k_t_ave,t_ave); memoryKK->destroy_kokkos(k_tsq_ave,tsq_ave); + // msmeam params + memoryKK->destroy_kokkos(k_arho1m, arho1m); + memoryKK->destroy_kokkos(k_arho2m, arho2m); + memoryKK->destroy_kokkos(k_arho3m, arho3m); + memoryKK->destroy_kokkos(k_arho2mb, arho2mb); + memoryKK->destroy_kokkos(k_arho3mb, arho3mb); nmax = atom_nmax; -// memory->create(rho, nmax, "pair:rho"); + + //memory->create(rho, nmax, "pair:rho"); k_rho = DAT::tdual_ffloat_1d("pair:rho",nmax); d_rho = k_rho.template view(); h_rho = k_rho.h_view; - // memory->create(rho0, nmax, "pair:rho0"); + //memory->create(rho0, nmax, "pair:rho0"); k_rho0 = DAT::tdual_ffloat_1d("pair:rho0",nmax); d_rho0 = k_rho0.template view(); h_rho0 = k_rho0.h_view; @@ -150,6 +175,34 @@ MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) k_tsq_ave = DAT::tdual_ffloat_2d("pair:tsq_ave",nmax, 3); d_tsq_ave = k_tsq_ave.template view(); h_tsq_ave = k_tsq_ave.h_view; + + // msmeam params + + printf("- making msmeam params in meam_dens_setup\n"); + //memory->create(arho2mb, nmax, "pair:arho2mb"); + k_arho2mb = DAT::tdual_ffloat_1d("pair:arho2mb",nmax); + d_arho2mb = k_arho2mb.template view(); + h_arho2mb = k_arho2mb.h_view; + //memory->create(arho1m, nmax, 3, "pair:arho1m"); + k_arho1m = DAT::tdual_ffloat_2d("pair:arho1m", nmax, 3); + d_arho1m = k_arho1m.template view(); + h_arho1m = k_arho1m.h_view; + //memory->create(arho2m, nmax, 6, "pair:arho2m"); + k_arho2m = DAT::tdual_ffloat_2d("pair:arho2m", nmax, 6); + d_arho2m = k_arho2m.template view(); + h_arho2m = k_arho2m.h_view; + //memory->create(arho3m, nmax, 10, "pair:arho3m"); + k_arho3m = DAT::tdual_ffloat_2d("pair:arho3m", nmax, 10); + d_arho3m = k_arho3m.template view(); + h_arho3m = k_arho3m.h_view; + //memory->create(arho2mb, nmax, "pair:arho2mb"); + //k_arho2mb = DAT::tdual_ffloat_1d("pair:arho2mb", nmax); + //d_arho2mb = k_arho2mb.template view(); + //h_arho2mb = k_arho2mb.h_view; + //memory->create(arho3mb, nmax, 3, "pair:arho3mb"); + k_arho3mb = DAT::tdual_ffloat_2d("pair:arho3mb", nmax, 3); + d_arho3mb = k_arho3mb.template view(); + h_arho3mb = k_arho3mb.h_view; } if (n_neigh > maxneigh) { @@ -197,7 +250,10 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ this->d_offset = d_offset; this->nlocal = nlocal; + printf("- inside meam_dens_init()\n"); + if (need_dup) { + printf("- need dup\n"); dup_rho0 = Kokkos::Experimental::create_scatter_view(d_rho0); dup_arho2b = Kokkos::Experimental::create_scatter_view(d_arho2b); dup_arho1 = Kokkos::Experimental::create_scatter_view(d_arho1); @@ -206,7 +262,14 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ dup_arho3b = Kokkos::Experimental::create_scatter_view(d_arho3b); dup_t_ave = Kokkos::Experimental::create_scatter_view(d_t_ave); dup_tsq_ave = Kokkos::Experimental::create_scatter_view(d_tsq_ave); + // msmeam params + dup_arho2mb = Kokkos::Experimental::create_scatter_view(d_arho2mb); + dup_arho1m = Kokkos::Experimental::create_scatter_view(d_arho1m); + dup_arho2m = Kokkos::Experimental::create_scatter_view(d_arho2m); + dup_arho3m = Kokkos::Experimental::create_scatter_view(d_arho3m); + dup_arho3mb = Kokkos::Experimental::create_scatter_view(d_arho3mb); } else { + printf("- no dup\n"); ndup_rho0 = Kokkos::Experimental::create_scatter_view(d_rho0); ndup_arho2b = Kokkos::Experimental::create_scatter_view(d_arho2b); ndup_arho1 = Kokkos::Experimental::create_scatter_view(d_arho1); @@ -215,6 +278,12 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ ndup_arho3b = Kokkos::Experimental::create_scatter_view(d_arho3b); ndup_t_ave = Kokkos::Experimental::create_scatter_view(d_t_ave); ndup_tsq_ave = Kokkos::Experimental::create_scatter_view(d_tsq_ave); + // msmeam params + ndup_arho2mb = Kokkos::Experimental::create_scatter_view(d_arho2mb); + ndup_arho1m = Kokkos::Experimental::create_scatter_view(d_arho1m); + ndup_arho2m = Kokkos::Experimental::create_scatter_view(d_arho2m); + ndup_arho3m = Kokkos::Experimental::create_scatter_view(d_arho3m); + ndup_arho3mb = Kokkos::Experimental::create_scatter_view(d_arho3mb); } copymode = 1; @@ -233,6 +302,12 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ Kokkos::Experimental::contribute(d_arho3b, dup_arho3b); Kokkos::Experimental::contribute(d_t_ave, dup_t_ave); Kokkos::Experimental::contribute(d_tsq_ave, dup_tsq_ave); + // msmeam params + Kokkos::Experimental::contribute(d_arho2mb, dup_arho2mb); + Kokkos::Experimental::contribute(d_arho1m, dup_arho1m); + Kokkos::Experimental::contribute(d_arho2m, dup_arho2m); + Kokkos::Experimental::contribute(d_arho3m, dup_arho3m); + Kokkos::Experimental::contribute(d_arho3mb, dup_arho3mb); // free duplicated memory dup_rho0 = decltype(dup_rho0)(); @@ -243,6 +318,12 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ dup_arho3b = decltype(dup_arho3b)(); dup_t_ave = decltype(dup_t_ave)(); dup_tsq_ave = decltype(dup_tsq_ave)(); + // msmeam params + dup_arho2mb = decltype(dup_arho2mb)(); + dup_arho1m = decltype(dup_arho1m)(); + dup_arho2m = decltype(dup_arho2m)(); + dup_arho3m = decltype(dup_arho3m)(); + dup_arho3mb = decltype(dup_arho3mb)(); } } @@ -417,7 +498,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty int offset) const { // The rho0, etc. arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial - + printf("- inside calc_rho1 i=%d\n", i); auto v_rho0 = ScatterViewHelper,decltype(dup_rho0),decltype(ndup_rho0)>::get(dup_rho0,ndup_rho0); auto a_rho0 = v_rho0.template access>(); auto v_arho2b = ScatterViewHelper,decltype(dup_arho2b),decltype(ndup_arho2b)>::get(dup_arho2b,ndup_arho2b); @@ -434,11 +515,24 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty auto a_t_ave = v_t_ave.template access>(); auto v_tsq_ave = ScatterViewHelper,decltype(dup_tsq_ave),decltype(ndup_tsq_ave)>::get(dup_tsq_ave,ndup_tsq_ave); auto a_tsq_ave = v_tsq_ave.template access>(); + //if (msmeamflag){ + auto v_arho2mb = ScatterViewHelper,decltype(dup_arho2mb),decltype(ndup_arho2mb)>::get(dup_arho2mb,ndup_arho2mb); + auto a_arho2mb = v_arho2mb.template access>(); + auto v_arho1m = ScatterViewHelper,decltype(dup_arho1m),decltype(ndup_arho1m)>::get(dup_arho1m,ndup_arho1m); + auto a_arho1m = v_arho1m.template access>(); + auto v_arho2m = ScatterViewHelper,decltype(dup_arho2m),decltype(ndup_arho2m)>::get(dup_arho2m,ndup_arho2m); + auto a_arho2m = v_arho2m.template access>(); + auto v_arho3m = ScatterViewHelper,decltype(dup_arho3m),decltype(ndup_arho3m)>::get(dup_arho3m,ndup_arho3m); + auto a_arho3m = v_arho3m.template access>(); + auto v_arho3mb = ScatterViewHelper,decltype(dup_arho3mb),decltype(ndup_arho3mb)>::get(dup_arho3mb,ndup_arho3mb); + auto a_arho3mb = v_arho3mb.template access>(); + //} const int elti = d_map[type[i]]; const double xtmp = x(i,0); const double ytmp = x(i,1); const double ztmp = x(i,2); + printf("- begin loop over neigh i=%d\n", i); for (int jn = 0; jn < d_numneigh[i]; jn++) { if (!iszero_kk(d_scrfcn[offset+jn])) { const int j = d_neighbors_half(i,jn); @@ -463,6 +557,16 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty double rhoa1i = ro0i * MathSpecialKokkos::fm_exp(-beta1_meam[elti] * ai) * sij; double rhoa2i = ro0i * MathSpecialKokkos::fm_exp(-beta2_meam[elti] * ai) * sij; double rhoa3i = ro0i * MathSpecialKokkos::fm_exp(-beta3_meam[elti] * ai) * sij; + // msmeam params + double rhoa1mj, rhoa2mj, rhoa3mj, rhoa1mi, rhoa2mi, rhoa3mi; + if (msmeamflag){ + rhoa1mj = ro0j * t1_meam[eltj] * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * sij; + rhoa2mj = ro0j * t2_meam[eltj] * MathSpecialKokkos::fm_exp(-beta2m_meam[eltj] * aj) * sij; + rhoa3mj = ro0j * t3_meam[eltj] * MathSpecialKokkos::fm_exp(-beta3m_meam[eltj] * aj) * sij; + rhoa1mi = ro0i * t1_meam[elti] * MathSpecialKokkos::fm_exp(-beta1m_meam[elti] * ai) * sij; + rhoa2mi = ro0i * t2_meam[elti] * MathSpecialKokkos::fm_exp(-beta2m_meam[elti] * ai) * sij; + rhoa3mi = ro0i * t3_meam[elti] * MathSpecialKokkos::fm_exp(-beta3m_meam[elti] * ai) * sij; + } if (ialloy == 1) { rhoa1j *= t1_meam[eltj]; rhoa2j *= t2_meam[eltj]; @@ -499,20 +603,45 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty const double A1i = rhoa1i / rij; const double A2i = rhoa2i / rij2; const double A3i = rhoa3i / (rij2 * rij); + if (msmeamflag){ + a_arho2mb[i] += rhoa2mj; + a_arho2mb[j] += rhoa2mi; + } + const double A1mj = rhoa1mj / rij; + const double A2mj = rhoa2mj / rij2; + const double A3mj = rhoa3mj / (rij2 * rij); + const double A1mi = rhoa1mi / rij; + const double A2mi = rhoa2mi / rij2; + const double A3mi = rhoa3mi / (rij2 * rij); int nv2 = 0; int nv3 = 0; + printf("- about to loop over m\n"); for (int m = 0; m < 3; m++) { - a_arho1(i,m) += A1j * delij[m]; + a_arho1(i,m) += A1j * delij[m]; a_arho1(j,m) += -A1i * delij[m]; - a_arho3b(i,m) += rhoa3j * delij[m] / rij; + a_arho3b(i,m) += rhoa3j * delij[m] / rij; a_arho3b(j,m) += -rhoa3i * delij[m] / rij; + if (msmeamflag){ + a_arho1m(i,m) += A1mj * delij[m]; + a_arho1m(j,m) += -A1mi * delij[m]; + a_arho3mb(i,m) += rhoa3mj * delij[m] / rij; + a_arho3mb(j,m) += -rhoa3mi * delij[m] / rij; + } for (int n = m; n < 3; n++) { a_arho2(i,nv2) += A2j * delij[m] * delij[n]; a_arho2(j,nv2) += A2i * delij[m] * delij[n]; + if (msmeamflag){ + a_arho2m(i,nv2) += A2mj * delij[m] * delij[n]; + a_arho2m(j,nv2) += A2mi * delij[m] * delij[n]; + } nv2++; for (int p = n; p < 3; p++) { - a_arho3(i,nv3) += A3j * delij[m] * delij[n] * delij[p]; + a_arho3(i,nv3) += A3j * delij[m] * delij[n] * delij[p]; a_arho3(j,nv3) += -A3i * delij[m] * delij[n] * delij[p]; + if (msmeamflag){ + a_arho3m(i,nv3) += A3mj * delij[m] * delij[n] * delij[p]; + a_arho3m(j,nv3) += -A3mi * delij[m] * delij[n] * delij[p]; + } nv3++; } } diff --git a/src/KOKKOS/meam_impl_kokkos.h b/src/KOKKOS/meam_impl_kokkos.h index bdd8728356..03fcfca03d 100644 --- a/src/KOKKOS/meam_impl_kokkos.h +++ b/src/KOKKOS/meam_impl_kokkos.h @@ -58,6 +58,14 @@ MEAMKokkos::~MEAMKokkos() memoryKK->destroy_kokkos(k_scrfcn,scrfcn); memoryKK->destroy_kokkos(k_dscrfcn,dscrfcn); memoryKK->destroy_kokkos(k_fcpair,fcpair); + + // msmeam params + + memoryKK->destroy_kokkos(k_arho2mb, arho2mb); + memoryKK->destroy_kokkos(k_arho1m, arho1m); + memoryKK->destroy_kokkos(k_arho2m, arho2m); + memoryKK->destroy_kokkos(k_arho3m, arho3m); + memoryKK->destroy_kokkos(k_arho3mb, arho3mb); } #include "meam_setup_done_kokkos.h" diff --git a/src/KOKKOS/meam_kokkos.h b/src/KOKKOS/meam_kokkos.h index cc75023810..f7bde30b85 100644 --- a/src/KOKKOS/meam_kokkos.h +++ b/src/KOKKOS/meam_kokkos.h @@ -136,6 +136,13 @@ template class MEAMKokkos : public MEAM { DAT::tdual_ffloat_1d k_scrfcn, k_dscrfcn, k_fcpair; typename ArrayTypes::t_ffloat_1d d_scrfcn, d_dscrfcn, d_fcpair; HAT::t_ffloat_1d h_scrfcn, h_dscrfcn, h_fcpair; + // msmeam params + DAT::tdual_ffloat_2d k_arho1m, k_arho2m, k_arho3m, k_arho3mb; + typename ArrayTypes::t_ffloat_2d d_arho1m, d_arho2m, d_arho3m, d_arho3mb; + HAT::t_ffloat_2d h_arho1m, h_arho2m, h_arho3m, h_arho3mb; + DAT::tdual_ffloat_1d k_arho2mb; + typename ArrayTypes::t_ffloat_1d d_arho2mb; + HAT::t_ffloat_1d h_arho2mb; protected: int need_dup; @@ -195,6 +202,31 @@ template class MEAMKokkos : public MEAM { dup_vatom; NonDupScatterView ndup_vatom; + + // msmeam params + + DupScatterView + dup_arho1m; + NonDupScatterView + ndup_arho1m; + DupScatterView + dup_arho2m; + NonDupScatterView + ndup_arho2m; + DupScatterView + dup_arho3m; + NonDupScatterView + ndup_arho3m; + DupScatterView + dup_arho2mb; + NonDupScatterView + ndup_arho2mb; + DupScatterView + dup_arho3mb; + NonDupScatterView + ndup_arho3mb; }; KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index 90e714cefe..084e39e31c 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -122,7 +122,10 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) int n = 0; Kokkos::parallel_reduce(Kokkos::RangePolicy(0,inum_half),*this,n); + printf("--- about to meam_dens_setup %d\n", comm->me); + meam_inst_kk->meam_dens_setup(atom->nmax, nall, n); + printf("--- about to update meam views\n"); update_meam_views(); x = atomKK->k_x.view(); @@ -156,8 +159,11 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) int need_dup = lmp->kokkos->need_dup(); + printf("--- about to start meam_dens_init\n"); meam_inst_kk->meam_dens_init(inum_half,ntype,type,d_map,x,d_numneigh_half,d_numneigh_full,d_ilist_half,d_neighbors_half, d_neighbors_full, d_offset, neighflag, need_dup); + printf("--- modifying arrays\n"); + printf("--- msmeamflag: %d\n", msmeamflag); meam_inst_kk->k_rho0.template modify(); meam_inst_kk->k_arho2b.template modify(); meam_inst_kk->k_arho1.template modify(); @@ -166,7 +172,16 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template modify(); meam_inst_kk->k_t_ave.template modify(); meam_inst_kk->k_tsq_ave.template modify(); + if (msmeamflag){ + printf("--- modifying msmeam arrays\n"); + meam_inst_kk->k_arho2mb.template modify(); + meam_inst_kk->k_arho1m.template modify(); + meam_inst_kk->k_arho2m.template modify(); + meam_inst_kk->k_arho3m.template modify(); + meam_inst_kk->k_arho3mb.template modify(); + } + printf("--- start reverse comm\n"); comm->reverse_comm(this); meam_inst_kk->k_rho0.template sync(); @@ -177,7 +192,15 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template sync(); meam_inst_kk->k_t_ave.template sync(); meam_inst_kk->k_tsq_ave.template sync(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.template sync(); + meam_inst_kk->k_arho1m.template sync(); + meam_inst_kk->k_arho2m.template sync(); + meam_inst_kk->k_arho3m.template sync(); + meam_inst_kk->k_arho3mb.template sync(); + } + printf("--- about to start meam_dens_final\n"); meam_inst_kk->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, d_eatom,ntype,type,d_map,d_scale,errorflag,ev); @@ -200,7 +223,15 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template modify(); meam_inst_kk->k_t_ave.template modify(); meam_inst_kk->k_tsq_ave.template modify(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.template modify(); + meam_inst_kk->k_arho1m.template modify(); + meam_inst_kk->k_arho2m.template modify(); + meam_inst_kk->k_arho3m.template modify(); + meam_inst_kk->k_arho3mb.template modify(); + } + printf("--- start forward comm\n"); comm->forward_comm(this); meam_inst_kk->k_rho0.template sync(); @@ -219,6 +250,13 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template sync(); meam_inst_kk->k_t_ave.template sync(); meam_inst_kk->k_tsq_ave.template sync(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.template sync(); + meam_inst_kk->k_arho1m.template sync(); + meam_inst_kk->k_arho2m.template sync(); + meam_inst_kk->k_arho3m.template sync(); + meam_inst_kk->k_arho3mb.template sync(); + } meam_inst_kk->meam_force(inum_half,eflag_global,eflag_atom,vflag_global, vflag_atom,d_eatom,ntype,type,d_map,x, @@ -303,6 +341,8 @@ void PairMEAMKokkos::init_style() if (neighflag == FULL) error->all(FLERR,"Must use half neighbor list style with pair meam/kk"); + + printf("--- comm sizes: %d %d\n", comm_forward, comm_reverse); } /* ---------------------------------------------------------------------- */ @@ -315,7 +355,8 @@ int PairMEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2 iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); - return n*38; + //return n*38; + return n*comm_forward; } /* ---------------------------------------------------------------------- */ @@ -324,7 +365,8 @@ template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const int &i) const { int j = d_sendlist(iswap, i); - int m = i*38; + //int m = i*38; + int m = i*comm_forward; v_buf[m++] = d_rho0[j]; v_buf[m++] = d_rho1[j]; v_buf[m++] = d_rho2[j]; @@ -354,6 +396,22 @@ void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const in v_buf[m++] = d_tsq_ave(j,0); v_buf[m++] = d_tsq_ave(j,1); v_buf[m++] = d_tsq_ave(j,2); + if (msmeamflag){ + v_buf[m++] = d_arho2mb[j]; + v_buf[m++] = d_arho1m(j,0); + v_buf[m++] = d_arho1m(j,1); + v_buf[m++] = d_arho1m(j,2); + v_buf[m++] = d_arho2m(j,0); + v_buf[m++] = d_arho2m(j,1); + v_buf[m++] = d_arho2m(j,2); + v_buf[m++] = d_arho2m(j,3); + v_buf[m++] = d_arho2m(j,4); + v_buf[m++] = d_arho2m(j,5); + for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3m(j,k); + v_buf[m++] = d_arho3mb(j,0); + v_buf[m++] = d_arho3mb(j,1); + v_buf[m++] = d_arho3mb(j,2); + } } /* ---------------------------------------------------------------------- */ @@ -371,7 +429,8 @@ void PairMEAMKokkos::unpack_forward_comm_kokkos(int n, int first_in, template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMUnpackForwardComm, const int &i) const{ - int m = i*38; + //int m = i*38; + int m = i*comm_forward; d_rho0[i+first] = v_buf[m++]; d_rho1[i+first] = v_buf[m++]; @@ -402,6 +461,22 @@ void PairMEAMKokkos::operator()(TagPairMEAMUnpackForwardComm, const d_tsq_ave(i+first,0) = v_buf[m++]; d_tsq_ave(i+first,1) = v_buf[m++]; d_tsq_ave(i+first,2) = v_buf[m++]; + if (msmeamflag){ + d_arho2mb[i+first] = v_buf[m++]; + d_arho1m(i+first,0) = v_buf[m++]; + d_arho1m(i+first,1) = v_buf[m++]; + d_arho1m(i+first,2) = v_buf[m++]; + d_arho2m(i+first,0) = v_buf[m++]; + d_arho2m(i+first,1) = v_buf[m++]; + d_arho2m(i+first,2) = v_buf[m++]; + d_arho2m(i+first,3) = v_buf[m++]; + d_arho2m(i+first,4) = v_buf[m++]; + d_arho2m(i+first,5) = v_buf[m++]; + for (int k = 0; k < 10; k++) d_arho3m(i+first,k) = v_buf[m++]; + d_arho3mb(i+first,0) = v_buf[m++]; + d_arho3mb(i+first,1) = v_buf[m++]; + d_arho3mb(i+first,2) = v_buf[m++]; + } } /* ---------------------------------------------------------------------- */ @@ -426,6 +501,13 @@ int PairMEAMKokkos::pack_forward_comm(int n, int *list, double *buf, meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.sync_host(); + meam_inst_kk->k_arho1m.sync_host(); + meam_inst_kk->k_arho2m.sync_host(); + meam_inst_kk->k_arho3m.sync_host(); + meam_inst_kk->k_arho3mb.sync_host(); + } int m = 0; for (int i = 0; i < n; i++) { @@ -459,6 +541,22 @@ int PairMEAMKokkos::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst_kk->h_tsq_ave(j,0); buf[m++] = meam_inst_kk->h_tsq_ave(j,1); buf[m++] = meam_inst_kk->h_tsq_ave(j,2); + if (msmeamflag){ + buf[m++] = meam_inst_kk->h_arho2mb[j]; + buf[m++] = meam_inst_kk->h_arho1m(j,0); + buf[m++] = meam_inst_kk->h_arho1m(j,1); + buf[m++] = meam_inst_kk->h_arho1m(j,2); + buf[m++] = meam_inst_kk->h_arho2m(j,0); + buf[m++] = meam_inst_kk->h_arho2m(j,1); + buf[m++] = meam_inst_kk->h_arho2m(j,2); + buf[m++] = meam_inst_kk->h_arho2m(j,3); + buf[m++] = meam_inst_kk->h_arho2m(j,4); + buf[m++] = meam_inst_kk->h_arho2m(j,5); + for (int k = 0; k < 10; k++) buf[m++] = meam_inst_kk->h_arho3m(j,k); + buf[m++] = meam_inst_kk->h_arho3mb(j,0); + buf[m++] = meam_inst_kk->h_arho3mb(j,1); + buf[m++] = meam_inst_kk->h_arho3mb(j,2); + } } return m; @@ -485,6 +583,13 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.sync_host(); + meam_inst_kk->k_arho1m.sync_host(); + meam_inst_kk->k_arho2m.sync_host(); + meam_inst_kk->k_arho3m.sync_host(); + meam_inst_kk->k_arho3mb.sync_host(); + } int m = 0; const int last = first + n; @@ -518,6 +623,22 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b meam_inst_kk->h_tsq_ave(i,0) = buf[m++]; meam_inst_kk->h_tsq_ave(i,1) = buf[m++]; meam_inst_kk->h_tsq_ave(i,2) = buf[m++]; + if (msmeamflag){ + meam_inst_kk->h_arho2mb[i] = buf[m++]; + meam_inst_kk->h_arho1m(i,0) = buf[m++]; + meam_inst_kk->h_arho1m(i,1) = buf[m++]; + meam_inst_kk->h_arho1m(i,2) = buf[m++]; + meam_inst_kk->h_arho2m(i,0) = buf[m++]; + meam_inst_kk->h_arho2m(i,1) = buf[m++]; + meam_inst_kk->h_arho2m(i,2) = buf[m++]; + meam_inst_kk->h_arho2m(i,3) = buf[m++]; + meam_inst_kk->h_arho2m(i,4) = buf[m++]; + meam_inst_kk->h_arho2m(i,5) = buf[m++]; + for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3m(i,k) = buf[m++]; + meam_inst_kk->h_arho3mb(i,0) = buf[m++]; + meam_inst_kk->h_arho3mb(i,1) = buf[m++]; + meam_inst_kk->h_arho3mb(i,2) = buf[m++]; + } } meam_inst_kk->k_rho0.modify_host(); @@ -536,6 +657,13 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b meam_inst_kk->k_arho3b.modify_host(); meam_inst_kk->k_t_ave.modify_host(); meam_inst_kk->k_tsq_ave.modify_host(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.modify_host(); + meam_inst_kk->k_arho1m.modify_host(); + meam_inst_kk->k_arho2m.modify_host(); + meam_inst_kk->k_arho3m.modify_host(); + meam_inst_kk->k_arho3mb.modify_host(); + } } /* ---------------------------------------------------------------------- */ @@ -546,7 +674,8 @@ int PairMEAMKokkos::pack_reverse_comm_kokkos(int n, int first_in, DA first = first_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); - return n*30; + //return n*30; + return n*comm_reverse; } /* ---------------------------------------------------------------------- */ @@ -554,7 +683,8 @@ int PairMEAMKokkos::pack_reverse_comm_kokkos(int n, int first_in, DA template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMPackReverseComm, const int &i) const { - int m = i*30; + //int m = i*30; + int m = i*comm_reverse; v_buf[m++] = d_rho0[i+first]; v_buf[m++] = d_arho2b[i+first]; @@ -577,6 +707,22 @@ void PairMEAMKokkos::operator()(TagPairMEAMPackReverseComm, const in v_buf[m++] = d_tsq_ave(i+first,0); v_buf[m++] = d_tsq_ave(i+first,1); v_buf[m++] = d_tsq_ave(i+first,2); + if (msmeamflag){ + v_buf[m++] = d_arho2mb[i+first]; + v_buf[m++] = d_arho1m(i+first,0); + v_buf[m++] = d_arho1m(i+first,1); + v_buf[m++] = d_arho1m(i+first,2); + v_buf[m++] = d_arho2m(i+first,0); + v_buf[m++] = d_arho2m(i+first,1); + v_buf[m++] = d_arho2m(i+first,2); + v_buf[m++] = d_arho2m(i+first,3); + v_buf[m++] = d_arho2m(i+first,4); + v_buf[m++] = d_arho2m(i+first,5); + for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3m(i+first,k); + v_buf[m++] = d_arho3mb(i+first,0); + v_buf[m++] = d_arho3mb(i+first,1); + v_buf[m++] = d_arho3mb(i+first,2); + } } /* ---------------------------------------------------------------------- */ @@ -592,6 +738,13 @@ int PairMEAMKokkos::pack_reverse_comm(int n, int first, double *buf) meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.sync_host(); + meam_inst_kk->k_arho1m.sync_host(); + meam_inst_kk->k_arho2m.sync_host(); + meam_inst_kk->k_arho3m.sync_host(); + meam_inst_kk->k_arho3mb.sync_host(); + } int m = 0; const int last = first + n; @@ -617,6 +770,22 @@ int PairMEAMKokkos::pack_reverse_comm(int n, int first, double *buf) buf[m++] = meam_inst_kk->h_tsq_ave(i,0); buf[m++] = meam_inst_kk->h_tsq_ave(i,1); buf[m++] = meam_inst_kk->h_tsq_ave(i,2); + if (msmeamflag){ + buf[m++] = meam_inst_kk->h_arho2mb[i]; + buf[m++] = meam_inst_kk->h_arho1m(i,0); + buf[m++] = meam_inst_kk->h_arho1m(i,1); + buf[m++] = meam_inst_kk->h_arho1m(i,2); + buf[m++] = meam_inst_kk->h_arho2m(i,0); + buf[m++] = meam_inst_kk->h_arho2m(i,1); + buf[m++] = meam_inst_kk->h_arho2m(i,2); + buf[m++] = meam_inst_kk->h_arho2m(i,3); + buf[m++] = meam_inst_kk->h_arho2m(i,4); + buf[m++] = meam_inst_kk->h_arho2m(i,5); + for (int k = 0; k < 10; k++) buf[m++] = meam_inst_kk->h_arho3m(i,k); + buf[m++] = meam_inst_kk->h_arho3mb(i,0); + buf[m++] = meam_inst_kk->h_arho3mb(i,1); + buf[m++] = meam_inst_kk->h_arho3mb(i,2); + } } return m; @@ -639,7 +808,8 @@ template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMUnpackReverseComm, const int &i) const { int j = d_sendlist(iswap, i); - int m = i*30; + //int m = i*30; + int m = i*comm_reverse; d_rho0[j] += v_buf[m++]; d_arho2b[j] += v_buf[m++]; @@ -662,6 +832,22 @@ void PairMEAMKokkos::operator()(TagPairMEAMUnpackReverseComm, const d_tsq_ave(j,0) += v_buf[m++]; d_tsq_ave(j,1) += v_buf[m++]; d_tsq_ave(j,2) += v_buf[m++]; + if (msmeamflag){ + d_arho2mb[j] += v_buf[m++]; + d_arho1m(j,0) += v_buf[m++]; + d_arho1m(j,1) += v_buf[m++]; + d_arho1m(j,2) += v_buf[m++]; + d_arho2m(j,0) += v_buf[m++]; + d_arho2m(j,1) += v_buf[m++]; + d_arho2m(j,2) += v_buf[m++]; + d_arho2m(j,3) += v_buf[m++]; + d_arho2m(j,4) += v_buf[m++]; + d_arho2m(j,5) += v_buf[m++]; + for (int k = 0; k < 10; k++) d_arho3m(j,k) += v_buf[m++]; + d_arho3mb(j,0) += v_buf[m++]; + d_arho3mb(j,1) += v_buf[m++]; + d_arho3mb(j,2) += v_buf[m++]; + } } /* ---------------------------------------------------------------------- */ @@ -677,6 +863,13 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.sync_host(); + meam_inst_kk->k_arho1m.sync_host(); + meam_inst_kk->k_arho2m.sync_host(); + meam_inst_kk->k_arho3m.sync_host(); + meam_inst_kk->k_arho3mb.sync_host(); + } int m = 0; for (int i = 0; i < n; i++) { @@ -701,7 +894,23 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->h_t_ave(j,2) += buf[m++]; meam_inst_kk->h_tsq_ave(j,0) += buf[m++]; meam_inst_kk->h_tsq_ave(j,1) += buf[m++]; - meam_inst_kk->h_tsq_ave(j,2) += buf[m++]; + meam_inst_kk->h_tsq_ave(j,2) += buf[m++]; + if (msmeamflag){ + meam_inst_kk->h_arho2mb[j] += buf[m++]; + meam_inst_kk->h_arho1m(j,0) += buf[m++]; + meam_inst_kk->h_arho1m(j,1) += buf[m++]; + meam_inst_kk->h_arho1m(j,2) += buf[m++]; + meam_inst_kk->h_arho2m(j,0) += buf[m++]; + meam_inst_kk->h_arho2m(j,1) += buf[m++]; + meam_inst_kk->h_arho2m(j,2) += buf[m++]; + meam_inst_kk->h_arho2m(j,3) += buf[m++]; + meam_inst_kk->h_arho2m(j,4) += buf[m++]; + meam_inst_kk->h_arho2m(j,5) += buf[m++]; + for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3m(j,k) += buf[m++]; + meam_inst_kk->h_arho3mb(j,0) += buf[m++]; + meam_inst_kk->h_arho3mb(j,1) += buf[m++]; + meam_inst_kk->h_arho3mb(j,2) += buf[m++]; + } } meam_inst_kk->k_rho0.modify_host(); @@ -712,6 +921,13 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->k_arho3b.modify_host(); meam_inst_kk->k_t_ave.modify_host(); meam_inst_kk->k_tsq_ave.modify_host(); + if (msmeamflag){ + meam_inst_kk->k_arho2mb.modify_host(); + meam_inst_kk->k_arho1m.modify_host(); + meam_inst_kk->k_arho2m.modify_host(); + meam_inst_kk->k_arho3m.modify_host(); + meam_inst_kk->k_arho3mb.modify_host(); + } } /* ---------------------------------------------------------------------- @@ -764,6 +980,12 @@ void PairMEAMKokkos::update_meam_views() d_arho3b = meam_inst_kk->d_arho3b; d_t_ave = meam_inst_kk->d_t_ave; d_tsq_ave = meam_inst_kk->d_tsq_ave; + // msmeam params + d_arho1m = meam_inst_kk->d_arho1m; + d_arho2m = meam_inst_kk->d_arho2m; + d_arho3m = meam_inst_kk->d_arho3m; + d_arho2mb = meam_inst_kk->d_arho2mb; + d_arho3mb = meam_inst_kk->d_arho3mb; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_meam_kokkos.h b/src/KOKKOS/pair_meam_kokkos.h index c5fe82fa79..f052826b59 100644 --- a/src/KOKKOS/pair_meam_kokkos.h +++ b/src/KOKKOS/pair_meam_kokkos.h @@ -117,6 +117,9 @@ class PairMEAMKokkos : public PairMEAM, public KokkosBase { typename ArrayTypes::t_ffloat_1d d_rho, d_rho0, d_rho1, d_rho2, d_rho3, d_frhop; typename ArrayTypes::t_ffloat_1d d_gamma, d_dgamma1, d_dgamma2, d_dgamma3, d_arho2b; typename ArrayTypes::t_ffloat_2d d_arho1, d_arho2, d_arho3, d_arho3b, d_t_ave, d_tsq_ave; + // msmeam params + typename ArrayTypes::t_ffloat_1d d_arho2mb; + typename ArrayTypes::t_ffloat_2d d_arho1m, d_arho2m, d_arho3m, d_arho3mb; void update_meam_views(); From a82b028b7261b2bdb87610b0bbffd7f9383e0008 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Mon, 23 Jan 2023 19:43:31 -0700 Subject: [PATCH 18/43] Finish porting MS-MEAM to Kokkos; obtain agreement in forces and energies --- src/KOKKOS/meam_dens_final_kokkos.h | 90 +++++--- src/KOKKOS/meam_dens_init_kokkos.h | 22 +- src/KOKKOS/meam_force_kokkos.h | 332 +++++++++++++++++++++++----- src/KOKKOS/pair_meam_kokkos.cpp | 1 + 4 files changed, 347 insertions(+), 98 deletions(-) diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index 0a709be2b3..bde8878da2 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -64,45 +64,71 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT if (elti >= 0) { scaleii = d_scale(type[i],type[i]); d_rho1[i] = 0.0; - //printf("%f\n", arho1m[i][0]); - //printf("%f\n", arho2mb[i]); - //if (msmeamflag){ - // d_rho2[i] = -1.0 / 3.0 * (arho2b[i] * arho2b[i] - // - arho2mb[i] * arho2mb[i]); - //} else{ + if (msmeamflag){ + d_rho2[i] = -1.0 / 3.0 * (d_arho2b[i] * d_arho2b[i] + - d_arho2mb[i] * d_arho2mb[i]); + } else{ d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; - //} - d_rho3[i] = 0.0; - for (int m = 0; m < 3; m++) { - d_rho1[i] += d_arho1(i,m) * d_arho1(i,m); - d_rho3[i] -= 3.0 / 5.0 * d_arho3b(i,m) * d_arho3b(i,m); } - for (int m = 0; m < 6; m++) - d_rho2[i] += v2D[m] * d_arho2(i,m) * d_arho2(i,m); - for (int m = 0; m < 10; m++) - d_rho3[i] += v3D[m] * d_arho3(i,m) * d_arho3(i,m); + //printf("rho2 %d %f\n", i, d_rho2[i]); + d_rho3[i] = 0.0; - if (d_rho0[i] > 0.0) { - if (ialloy == 1) { - d_t_ave(i,0) = fdiv_zero_kk(d_t_ave(i,0), d_tsq_ave(i,0)); - d_t_ave(i,1) = fdiv_zero_kk(d_t_ave(i,1), d_tsq_ave(i,1)); - d_t_ave(i,2) = fdiv_zero_kk(d_t_ave(i,2), d_tsq_ave(i,2)); - } else if (ialloy == 2) { - d_t_ave(i,0) = t1_meam[elti]; - d_t_ave(i,1) = t2_meam[elti]; - d_t_ave(i,2) = t3_meam[elti]; - } else { - d_t_ave(i,0) /= d_rho0[i]; - d_t_ave(i,1) /= d_rho0[i]; - d_t_ave(i,2) /= d_rho0[i]; + for (int m = 0; m < 3; m++) { + if (msmeamflag){ + d_rho1[i] = d_rho1[i] + d_arho1(i, m) * d_arho1(i, m) + - d_arho1m(i, m) * d_arho1m(i, m); + d_rho3[i] = d_rho3[i] - 3.0 / 5.0 * (d_arho3b(i, m) * d_arho3b(i, m) + - d_arho3mb(i, m) * d_arho3mb(i, m)); + } else{ + d_rho1[i] += d_arho1(i,m) * d_arho1(i,m); + d_rho3[i] -= 3.0 / 5.0 * d_arho3b(i,m) * d_arho3b(i,m); } } + //printf("rho1 rho3 %d %f %f\n", i, d_rho1[i], d_rho3[i]); + for (int m = 0; m < 6; m++){ + if (msmeamflag){ + d_rho2[i] = d_rho2[i] + v2D[m] * (d_arho2(i, m) * d_arho2(i, m) + - d_arho2m(i, m) * d_arho2m(i, m)); + } else{ + d_rho2[i] += v2D[m] * d_arho2(i,m) * d_arho2(i,m); + } + } + for (int m = 0; m < 10; m++) + if (msmeamflag){ + d_rho3[i] = d_rho3[i] + v3D[m] * (d_arho3(i, m) * d_arho3(i, m) + - d_arho3m(i, m) * d_arho3m(i, m)); + } else{ + d_rho3[i] += v3D[m] * d_arho3(i,m) * d_arho3(i,m); + } - d_gamma[i] = d_t_ave(i,0) * d_rho1[i] + d_t_ave(i,1) * d_rho2[i] + d_t_ave(i,2) * d_rho3[i]; + if (msmeamflag){ + // with msmeam all t weights are already accounted for + d_gamma[i] = d_rho1[i] + d_rho2[i] + d_rho3[i]; + + } else{ + if (d_rho0[i] > 0.0) { + if (ialloy == 1) { + d_t_ave(i,0) = fdiv_zero_kk(d_t_ave(i,0), d_tsq_ave(i,0)); + d_t_ave(i,1) = fdiv_zero_kk(d_t_ave(i,1), d_tsq_ave(i,1)); + d_t_ave(i,2) = fdiv_zero_kk(d_t_ave(i,2), d_tsq_ave(i,2)); + } else if (ialloy == 2) { + d_t_ave(i,0) = t1_meam[elti]; + d_t_ave(i,1) = t2_meam[elti]; + d_t_ave(i,2) = t3_meam[elti]; + } else { + d_t_ave(i,0) /= d_rho0[i]; + d_t_ave(i,1) /= d_rho0[i]; + d_t_ave(i,2) /= d_rho0[i]; + } + } + d_gamma[i] = d_t_ave(i,0) * d_rho1[i] + d_t_ave(i,1) * d_rho2[i] + d_t_ave(i,2) * d_rho3[i]; + } if (d_rho0[i] > 0.0) d_gamma[i] /= (d_rho0[i] * d_rho0[i]); + //printf("gamma %d %f\n", i, d_gamma[i]); + Z = get_Zij(lattce_meam[elti][elti]); G = G_gam(d_gamma[i], ibar_meam[elti], d_errorflag()); @@ -114,7 +140,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT Gbar = 1.0; dGbar = 0.0; } else { - if (mix_ref_t == 1) + if (mix_ref_t == 1) // should not be used with msmeam gam = (d_t_ave(i,0) * shp[0] + d_t_ave(i,1) * shp[1] + d_t_ave(i,2) * shp[2]) / (Z * Z); else gam = (t1_meam[elti] * shp[0] + t2_meam[elti] * shp[1] + t3_meam[elti] * shp[2]) / @@ -159,7 +185,8 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT d_dgamma3[i] = 0.0; Fl = embedding(A_meam[elti], Ec_meam[elti][elti], rhob, d_frhop[i]); - + //printf("dgamma %d %f %f %f\n", i, d_dgamma1[i], d_dgamma2[i], d_dgamma3[i]); + //printf("Fl %d %f\n", i, Fl); if (eflag_either) { Fl *= scaleii; if (eflag_global) { @@ -167,6 +194,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } if (eflag_atom) { d_eatom[i] += Fl; + printf("eatom %d %f\n", i, d_eatom[i]); } } } diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index 83005206da..8f37549ad3 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -560,12 +560,19 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty // msmeam params double rhoa1mj, rhoa2mj, rhoa3mj, rhoa1mi, rhoa2mi, rhoa3mi; if (msmeamflag){ - rhoa1mj = ro0j * t1_meam[eltj] * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * sij; - rhoa2mj = ro0j * t2_meam[eltj] * MathSpecialKokkos::fm_exp(-beta2m_meam[eltj] * aj) * sij; - rhoa3mj = ro0j * t3_meam[eltj] * MathSpecialKokkos::fm_exp(-beta3m_meam[eltj] * aj) * sij; - rhoa1mi = ro0i * t1_meam[elti] * MathSpecialKokkos::fm_exp(-beta1m_meam[elti] * ai) * sij; - rhoa2mi = ro0i * t2_meam[elti] * MathSpecialKokkos::fm_exp(-beta2m_meam[elti] * ai) * sij; - rhoa3mi = ro0i * t3_meam[elti] * MathSpecialKokkos::fm_exp(-beta3m_meam[elti] * ai) * sij; + rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * sij; + rhoa2mj = ro0j * t2m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta2m_meam[eltj] * aj) * sij; + rhoa3mj = ro0j * t3m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta3m_meam[eltj] * aj) * sij; + rhoa1mi = ro0i * t1m_meam[elti] * MathSpecialKokkos::fm_exp(-beta1m_meam[elti] * ai) * sij; + rhoa2mi = ro0i * t2m_meam[elti] * MathSpecialKokkos::fm_exp(-beta2m_meam[elti] * ai) * sij; + rhoa3mi = ro0i * t3m_meam[elti] * MathSpecialKokkos::fm_exp(-beta3m_meam[elti] * ai) * sij; + //printf("- rhoam params:\n"); + //printf(" %f %f %f\n", rhoa1mj, rhoa2mj, rhoa3mj); + //printf(" %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi); + //printf(" %f %f %f\n", this->t1m_meam[elti], this->t2m_meam[elti], this->t3m_meam[elti]); + //printf(" %f %f %f\n", this->beta1m_meam[elti], this->beta2m_meam[elti], this->beta3m_meam[elti]); + //printf(" - rhoam params %f %f %f\n", ro0i, ai, sij); + //printf(" - rhoam %f %f %f %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi, rhoa1mj, rhoa2mj, rhoa3mj); } if (ialloy == 1) { rhoa1j *= t1_meam[eltj]; @@ -596,6 +603,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty } a_arho2b[i] += rhoa2j; a_arho2b[j] += rhoa2i; + //printf("- %f %f\n", a_arho2b[i], a_arho2b[j]); const double A1j = rhoa1j / rij; const double A2j = rhoa2j / rij2; @@ -606,6 +614,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty if (msmeamflag){ a_arho2mb[i] += rhoa2mj; a_arho2mb[j] += rhoa2mi; + //printf("- %f %f\n", a_arho2mb[i], a_arho2mb[j]); } const double A1mj = rhoa1mj / rij; const double A2mj = rhoa2mj / rij2; @@ -613,6 +622,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty const double A1mi = rhoa1mi / rij; const double A2mi = rhoa2mi / rij2; const double A3mi = rhoa3mi / (rij2 * rij); + //printf("A %d %d %f %f %f %f %f %f\n", i, j, A1mj, A2mj, A3mj, A1mi, A2mi, A3mi); int nv2 = 0; int nv3 = 0; printf("- about to loop over m\n"); diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index e7e6c64231..3bcedfc4ae 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -119,6 +119,17 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForcev2D[nv2]; + drho3mdrm1[m] = drho3mdrm1[m] + d_arho3m(i, vind3D[m][n][p]) * arg; + drho3mdrm2[m] = drho3mdrm2[m] + d_arho3m(j, vind3D[m][n][p]) * arg; + nv2 = nv2 + 1; + } + } + drho3mdrm1[m] = (a3 * drho3mdrm1[m] - a3a * d_arho3mb(i, m)) * rhoa3mj; + drho3mdrm2[m] = (-a3 * drho3mdrm2[m] + a3a * d_arho3mb(j, m)) * rhoa3mi; + } + } else{ + drho1mdrm1[m] = 0.0; + drho1mdrm2[m] = 0.0; + drho2mdrm1[m] = 0.0; + drho2mdrm2[m] = 0.0; + drho3mdrm1[m] = 0.0; + drho3mdrm2[m] = 0.0; + } + // Compute derivatives of weighting functions t wrt rij - t1i = d_t_ave(i, 0); - t2i = d_t_ave(i, 1); - t3i = d_t_ave(i, 2); - t1j = d_t_ave(j, 0); - t2j = d_t_ave(j, 1); - t3j = d_t_ave(j, 2); - - if (ialloy == 1) { - - a1i = fdiv_zero_kk(drhoa0j * sij, d_tsq_ave(i, 0)); - a1j = fdiv_zero_kk(drhoa0i * sij, d_tsq_ave(j, 0)); - a2i = fdiv_zero_kk(drhoa0j * sij, d_tsq_ave(i, 1)); - a2j = fdiv_zero_kk(drhoa0i * sij, d_tsq_ave(j, 1)); - a3i = fdiv_zero_kk(drhoa0j * sij, d_tsq_ave(i, 2)); - a3j = fdiv_zero_kk(drhoa0i * sij, d_tsq_ave(j, 2)); - - dt1dr1 = a1i * (t1mj - t1i * MathSpecialKokkos::square(t1mj)); - dt1dr2 = a1j * (t1mi - t1j * MathSpecialKokkos::square(t1mi)); - dt2dr1 = a2i * (t2mj - t2i * MathSpecialKokkos::square(t2mj)); - dt2dr2 = a2j * (t2mi - t2j * MathSpecialKokkos::square(t2mi)); - dt3dr1 = a3i * (t3mj - t3i * MathSpecialKokkos::square(t3mj)); - dt3dr2 = a3j * (t3mi - t3j * MathSpecialKokkos::square(t3mi)); - - } else if (ialloy == 2) { + // Weighting functions t set to unity for msmeam + if (msmeamflag){ + t1i = 1.0; + t2i = 1.0; + t3i = 1.0; + t1j = 1.0; + t2j = 1.0; + t3j = 1.0; dt1dr1 = 0.0; dt1dr2 = 0.0; dt2dr1 = 0.0; dt2dr2 = 0.0; dt3dr1 = 0.0; dt3dr2 = 0.0; + } else{ - } else { + t1i = d_t_ave(i, 0); + t2i = d_t_ave(i, 1); + t3i = d_t_ave(i, 2); + t1j = d_t_ave(j, 0); + t2j = d_t_ave(j, 1); + t3j = d_t_ave(j, 2); - ai = 0.0; - if (!iszero_kk(d_rho0[i])) ai = drhoa0j * sij / d_rho0[i]; - aj = 0.0; - if (!iszero_kk(d_rho0[j])) aj = drhoa0i * sij / d_rho0[j]; + if (ialloy == 1) { - dt1dr1 = ai * (t1mj - t1i); - dt1dr2 = aj * (t1mi - t1j); - dt2dr1 = ai * (t2mj - t2i); - dt2dr2 = aj * (t2mi - t2j); - dt3dr1 = ai * (t3mj - t3i); - dt3dr2 = aj * (t3mi - t3j); + a1i = fdiv_zero_kk(drhoa0j * sij, d_tsq_ave(i, 0)); + a1j = fdiv_zero_kk(drhoa0i * sij, d_tsq_ave(j, 0)); + a2i = fdiv_zero_kk(drhoa0j * sij, d_tsq_ave(i, 1)); + a2j = fdiv_zero_kk(drhoa0i * sij, d_tsq_ave(j, 1)); + a3i = fdiv_zero_kk(drhoa0j * sij, d_tsq_ave(i, 2)); + a3j = fdiv_zero_kk(drhoa0i * sij, d_tsq_ave(j, 2)); + + dt1dr1 = a1i * (t1mj - t1i * MathSpecialKokkos::square(t1mj)); + dt1dr2 = a1j * (t1mi - t1j * MathSpecialKokkos::square(t1mi)); + dt2dr1 = a2i * (t2mj - t2i * MathSpecialKokkos::square(t2mj)); + dt2dr2 = a2j * (t2mi - t2j * MathSpecialKokkos::square(t2mi)); + dt3dr1 = a3i * (t3mj - t3i * MathSpecialKokkos::square(t3mj)); + dt3dr2 = a3j * (t3mi - t3j * MathSpecialKokkos::square(t3mi)); + + } else if (ialloy == 2) { + + dt1dr1 = 0.0; + dt1dr2 = 0.0; + dt2dr1 = 0.0; + dt2dr2 = 0.0; + dt3dr1 = 0.0; + dt3dr2 = 0.0; + + } else { + + ai = 0.0; + if (!iszero_kk(d_rho0[i])) ai = drhoa0j * sij / d_rho0[i]; + aj = 0.0; + if (!iszero_kk(d_rho0[j])) aj = drhoa0i * sij / d_rho0[j]; + + dt1dr1 = ai * (t1mj - t1i); + dt1dr2 = aj * (t1mi - t1j); + dt2dr1 = ai * (t2mj - t2i); + dt2dr2 = aj * (t2mi - t2j); + dt3dr1 = ai * (t3mj - t3i); + dt3dr2 = aj * (t3mi - t3j); + } } // Compute derivatives of total density wrt rij, sij and rij(3) get_shpfcn(lattce_meam[elti][elti], stheta_meam[elti][elti], ctheta_meam[elti][elti], shpi); get_shpfcn(lattce_meam[eltj][eltj], stheta_meam[elti][elti], ctheta_meam[elti][elti], shpj); - drhodr1 = d_dgamma1[i] * drho0dr1 + - d_dgamma2[i] * - (dt1dr1 * d_rho1[i] + t1i * drho1dr1 + dt2dr1 * d_rho2[i] + t2i * drho2dr1 + - dt3dr1 * d_rho3[i] + t3i * drho3dr1) - - d_dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); - drhodr2 = d_dgamma1[j] * drho0dr2 + - d_dgamma2[j] * - (dt1dr2 * d_rho1[j] + t1j * drho1dr2 + dt2dr2 * d_rho2[j] + t2j * drho2dr2 + - dt3dr2 * d_rho3[j] + t3j * drho3dr2) - - d_dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); - for (m = 0; m < 3; m++) { - drhodrm1[m] = 0.0; - drhodrm2[m] = 0.0; - drhodrm1[m] = - d_dgamma2[i] * (t1i * drho1drm1[m] + t2i * drho2drm1[m] + t3i * drho3drm1[m]); - drhodrm2[m] = - d_dgamma2[j] * (t1j * drho1drm2[m] + t2j * drho2drm2[m] + t3j * drho3drm2[m]); + if (!msmeamflag){ + drhodr1 = d_dgamma1[i] * drho0dr1 + + d_dgamma2[i] * + (dt1dr1 * d_rho1[i] + t1i * drho1dr1 + dt2dr1 * d_rho2[i] + t2i * drho2dr1 + + dt3dr1 * d_rho3[i] + t3i * drho3dr1) - + d_dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); + drhodr2 = d_dgamma1[j] * drho0dr2 + + d_dgamma2[j] * + (dt1dr2 * d_rho1[j] + t1j * drho1dr2 + dt2dr2 * d_rho2[j] + t2j * drho2dr2 + + dt3dr2 * d_rho3[j] + t3j * drho3dr2) - + d_dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + for (m = 0; m < 3; m++) { + drhodrm1[m] = 0.0; + drhodrm2[m] = 0.0; + drhodrm1[m] = + d_dgamma2[i] * (t1i * drho1drm1[m] + t2i * drho2drm1[m] + t3i * drho3drm1[m]); + drhodrm2[m] = + d_dgamma2[j] * (t1j * drho1drm2[m] + t2j * drho2drm2[m] + t3j * drho3drm2[m]); + } + } else{ + drhodr1 = d_dgamma1[i] * drho0dr1 + + d_dgamma2[i] * (dt1dr1 * d_rho1[i] + t1i * (drho1dr1 - drho1mdr1) + + dt2dr1 * d_rho2[i] + t2i * (drho2dr1 - drho2mdr1) + + dt3dr1 * d_rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - + d_dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); + drhodr2 = d_dgamma1[j] * drho0dr2 + + d_dgamma2[j] * (dt1dr2 * d_rho1[j] + t1j * (drho1dr2 - drho1mdr2) + + dt2dr2 * d_rho2[j] + t2j * (drho2dr2 - drho2mdr2) + + dt3dr2 * d_rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - + d_dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + for (m = 0; m < 3; m++) { + drhodrm1[m] = 0.0; + drhodrm2[m] = 0.0; + drhodrm1[m] = d_dgamma2[i] * (t1i * (drho1drm1[m] - drho1mdrm1[m]) + + t2i * (drho2drm1[m] - drho2mdrm1[m]) + + t3i * (drho3drm1[m] - drho3mdrm1[m]) ); + drhodrm2[m] = d_dgamma2[j] * (t1j * (drho1drm2[m] - drho1mdrm2[m]) + + t2j * (drho2drm2[m] - drho2mdrm2[m]) + + t3j * (drho3drm2[m] - drho3mdrm2[m]) ); + } } // Compute derivatives wrt sij, but only if necessary @@ -416,6 +593,24 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce::operator()(TagMEAMForce::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3mb.template sync(); } + printf("--- starting meam_force\n"); meam_inst_kk->meam_force(inum_half,eflag_global,eflag_atom,vflag_global, vflag_atom,d_eatom,ntype,type,d_map,x, d_numneigh_half, d_numneigh_full,f,d_vatom, From 533af97d8e4a0bbbec0945afd093599414a5f04a Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 11:02:14 -0700 Subject: [PATCH 19/43] Format and clean Kokkos MEAM --- src/KOKKOS/meam_dens_final_kokkos.h | 21 +++---- src/KOKKOS/meam_dens_init_kokkos.h | 89 ++++++++++------------------- src/KOKKOS/meam_force_kokkos.h | 85 ++++++++++++++------------- src/KOKKOS/meam_impl_kokkos.h | 2 +- src/KOKKOS/meam_kokkos.h | 4 +- src/KOKKOS/pair_meam_kokkos.cpp | 24 ++------ src/MEAM/meam.h | 8 +-- src/MEAM/meam_dens_final.cpp | 8 +-- src/MEAM/meam_dens_init.cpp | 3 +- src/MEAM/meam_force.cpp | 21 +++---- src/MEAM/meam_impl.cpp | 4 +- src/MEAM/meam_setup_done.cpp | 11 ++-- src/MEAM/pair_meam.cpp | 5 +- 13 files changed, 117 insertions(+), 168 deletions(-) diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index bde8878da2..1f88c7c54b 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -36,7 +36,6 @@ MEAMKokkos::meam_dens_final(int nlocal, int eflag_either, int eflag_ Kokkos::deep_copy(d_errorflag,0); - printf("- inside meam_dens_final\n"); // Complete the calculation of density copymode = 1; @@ -58,8 +57,6 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT F_FLOAT denom, rho_bkgd, Fl; double scaleii; - printf("- inside TagMEAMDensFinal msmeamflag=%d i=%d\n", msmeamflag, i); - int elti = d_map[type[i]]; if (elti >= 0) { scaleii = d_scale(type[i],type[i]); @@ -70,9 +67,11 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } else{ d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; } - //printf("rho2 %d %f\n", i, d_rho2[i]); + if (!msmeamflag) + d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; + else + d_rho2[i] = -1.0 / 3.0 * (d_arho2b[i] * d_arho2b[i] - d_arho2mb[i] * d_arho2mb[i]); d_rho3[i] = 0.0; - for (int m = 0; m < 3; m++) { if (msmeamflag){ d_rho1[i] = d_rho1[i] + d_arho1(i, m) * d_arho1(i, m) @@ -84,7 +83,6 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT d_rho3[i] -= 3.0 / 5.0 * d_arho3b(i,m) * d_arho3b(i,m); } } - //printf("rho1 rho3 %d %f %f\n", i, d_rho1[i], d_rho3[i]); for (int m = 0; m < 6; m++){ if (msmeamflag){ d_rho2[i] = d_rho2[i] + v2D[m] * (d_arho2(i, m) * d_arho2(i, m) @@ -102,9 +100,8 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } if (msmeamflag){ - // with msmeam all t weights are already accounted for + // with msmeam all t weights are already accounted for in rho d_gamma[i] = d_rho1[i] + d_rho2[i] + d_rho3[i]; - } else{ if (d_rho0[i] > 0.0) { if (ialloy == 1) { @@ -127,8 +124,6 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT if (d_rho0[i] > 0.0) d_gamma[i] /= (d_rho0[i] * d_rho0[i]); - //printf("gamma %d %f\n", i, d_gamma[i]); - Z = get_Zij(lattce_meam[elti][elti]); G = G_gam(d_gamma[i], ibar_meam[elti], d_errorflag()); @@ -140,7 +135,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT Gbar = 1.0; dGbar = 0.0; } else { - if (mix_ref_t == 1) // should not be used with msmeam + if (mix_ref_t == 1) // mix_ref_t not used with msmeam gam = (d_t_ave(i,0) * shp[0] + d_t_ave(i,1) * shp[1] + d_t_ave(i,2) * shp[2]) / (Z * Z); else gam = (t1_meam[elti] * shp[0] + t2_meam[elti] * shp[1] + t3_meam[elti] * shp[2]) / @@ -185,8 +180,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT d_dgamma3[i] = 0.0; Fl = embedding(A_meam[elti], Ec_meam[elti][elti], rhob, d_frhop[i]); - //printf("dgamma %d %f %f %f\n", i, d_dgamma1[i], d_dgamma2[i], d_dgamma3[i]); - //printf("Fl %d %f\n", i, Fl); + if (eflag_either) { Fl *= scaleii; if (eflag_global) { @@ -194,7 +188,6 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } if (eflag_atom) { d_eatom[i] += Fl; - printf("eatom %d %f\n", i, d_eatom[i]); } } } diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index 8f37549ad3..82ab68396a 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -24,7 +24,6 @@ template template KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMDensInit, const int &i) const { - printf("- inside TagMEAMDensInit i=%d\n", i); int ii, offsetval; ii = d_ilist_half[i]; offsetval = d_offset[i]; @@ -50,20 +49,17 @@ void MEAMKokkos::operator()(TagMEAMZero, const int &i) const { } for (int j = 0; j < 6; j++){ d_arho2(i,j) = 0.0; - if (msmeamflag){ + if (msmeamflag) d_arho2m(i,j) = 0.0; - } } for (int j = 0; j < 10; j++){ d_arho3(i,j) = 0.0; - if (msmeamflag){ + if (msmeamflag) d_arho3m(i,j) = 0.0; - } } d_arho3b(i,0) = d_arho3b(i,1) = d_arho3b(i,2) = 0.0; - if (msmeamflag){ + if (msmeamflag) d_arho3mb(i,0) = d_arho3mb(i,1) = d_arho3mb(i,2) = 0.0; - } d_t_ave(i,0) = d_t_ave(i,1) = d_t_ave(i,2) = 0.0; d_tsq_ave(i,0) = d_tsq_ave(i,1) = d_tsq_ave(i,2) = 0.0; } @@ -74,8 +70,6 @@ template void MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) { - - printf("- inside meam_dens_setup\n"); MemoryKokkos *memoryKK = (MemoryKokkos *)memory; // grow local arrays if necessary @@ -98,11 +92,11 @@ MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memoryKK->destroy_kokkos(k_arho3b,arho3b); memoryKK->destroy_kokkos(k_t_ave,t_ave); memoryKK->destroy_kokkos(k_tsq_ave,tsq_ave); - // msmeam params + // msmeam + memoryKK->destroy_kokkos(k_arho2mb, arho2mb); memoryKK->destroy_kokkos(k_arho1m, arho1m); memoryKK->destroy_kokkos(k_arho2m, arho2m); memoryKK->destroy_kokkos(k_arho3m, arho3m); - memoryKK->destroy_kokkos(k_arho2mb, arho2mb); memoryKK->destroy_kokkos(k_arho3mb, arho3mb); nmax = atom_nmax; @@ -176,10 +170,8 @@ MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) d_tsq_ave = k_tsq_ave.template view(); h_tsq_ave = k_tsq_ave.h_view; - // msmeam params - - printf("- making msmeam params in meam_dens_setup\n"); - //memory->create(arho2mb, nmax, "pair:arho2mb"); + // msmeam + //memory->create(arho2mb, nmax, "pair:arho2mb"); k_arho2mb = DAT::tdual_ffloat_1d("pair:arho2mb",nmax); d_arho2mb = k_arho2mb.template view(); h_arho2mb = k_arho2mb.h_view; @@ -195,10 +187,6 @@ MEAMKokkos::meam_dens_setup(int atom_nmax, int nall, int n_neigh) k_arho3m = DAT::tdual_ffloat_2d("pair:arho3m", nmax, 10); d_arho3m = k_arho3m.template view(); h_arho3m = k_arho3m.h_view; - //memory->create(arho2mb, nmax, "pair:arho2mb"); - //k_arho2mb = DAT::tdual_ffloat_1d("pair:arho2mb", nmax); - //d_arho2mb = k_arho2mb.template view(); - //h_arho2mb = k_arho2mb.h_view; //memory->create(arho3mb, nmax, 3, "pair:arho3mb"); k_arho3mb = DAT::tdual_ffloat_2d("pair:arho3mb", nmax, 3); d_arho3mb = k_arho3mb.template view(); @@ -250,10 +238,7 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ this->d_offset = d_offset; this->nlocal = nlocal; - printf("- inside meam_dens_init()\n"); - if (need_dup) { - printf("- need dup\n"); dup_rho0 = Kokkos::Experimental::create_scatter_view(d_rho0); dup_arho2b = Kokkos::Experimental::create_scatter_view(d_arho2b); dup_arho1 = Kokkos::Experimental::create_scatter_view(d_arho1); @@ -262,14 +247,13 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ dup_arho3b = Kokkos::Experimental::create_scatter_view(d_arho3b); dup_t_ave = Kokkos::Experimental::create_scatter_view(d_t_ave); dup_tsq_ave = Kokkos::Experimental::create_scatter_view(d_tsq_ave); - // msmeam params + // msmeam dup_arho2mb = Kokkos::Experimental::create_scatter_view(d_arho2mb); dup_arho1m = Kokkos::Experimental::create_scatter_view(d_arho1m); dup_arho2m = Kokkos::Experimental::create_scatter_view(d_arho2m); dup_arho3m = Kokkos::Experimental::create_scatter_view(d_arho3m); dup_arho3mb = Kokkos::Experimental::create_scatter_view(d_arho3mb); } else { - printf("- no dup\n"); ndup_rho0 = Kokkos::Experimental::create_scatter_view(d_rho0); ndup_arho2b = Kokkos::Experimental::create_scatter_view(d_arho2b); ndup_arho1 = Kokkos::Experimental::create_scatter_view(d_arho1); @@ -278,7 +262,7 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ ndup_arho3b = Kokkos::Experimental::create_scatter_view(d_arho3b); ndup_t_ave = Kokkos::Experimental::create_scatter_view(d_t_ave); ndup_tsq_ave = Kokkos::Experimental::create_scatter_view(d_tsq_ave); - // msmeam params + // msmeam ndup_arho2mb = Kokkos::Experimental::create_scatter_view(d_arho2mb); ndup_arho1m = Kokkos::Experimental::create_scatter_view(d_arho1m); ndup_arho2m = Kokkos::Experimental::create_scatter_view(d_arho2m); @@ -302,7 +286,7 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ Kokkos::Experimental::contribute(d_arho3b, dup_arho3b); Kokkos::Experimental::contribute(d_t_ave, dup_t_ave); Kokkos::Experimental::contribute(d_tsq_ave, dup_tsq_ave); - // msmeam params + // msmeam Kokkos::Experimental::contribute(d_arho2mb, dup_arho2mb); Kokkos::Experimental::contribute(d_arho1m, dup_arho1m); Kokkos::Experimental::contribute(d_arho2m, dup_arho2m); @@ -318,7 +302,7 @@ MEAMKokkos::meam_dens_init(int inum_half, int ntype, typename AT::t_ dup_arho3b = decltype(dup_arho3b)(); dup_t_ave = decltype(dup_t_ave)(); dup_tsq_ave = decltype(dup_tsq_ave)(); - // msmeam params + // msmeam dup_arho2mb = decltype(dup_arho2mb)(); dup_arho1m = decltype(dup_arho1m)(); dup_arho2m = decltype(dup_arho2m)(); @@ -498,7 +482,6 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty int offset) const { // The rho0, etc. arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial - printf("- inside calc_rho1 i=%d\n", i); auto v_rho0 = ScatterViewHelper,decltype(dup_rho0),decltype(ndup_rho0)>::get(dup_rho0,ndup_rho0); auto a_rho0 = v_rho0.template access>(); auto v_arho2b = ScatterViewHelper,decltype(dup_arho2b),decltype(ndup_arho2b)>::get(dup_arho2b,ndup_arho2b); @@ -515,24 +498,22 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty auto a_t_ave = v_t_ave.template access>(); auto v_tsq_ave = ScatterViewHelper,decltype(dup_tsq_ave),decltype(ndup_tsq_ave)>::get(dup_tsq_ave,ndup_tsq_ave); auto a_tsq_ave = v_tsq_ave.template access>(); - //if (msmeamflag){ - auto v_arho2mb = ScatterViewHelper,decltype(dup_arho2mb),decltype(ndup_arho2mb)>::get(dup_arho2mb,ndup_arho2mb); - auto a_arho2mb = v_arho2mb.template access>(); - auto v_arho1m = ScatterViewHelper,decltype(dup_arho1m),decltype(ndup_arho1m)>::get(dup_arho1m,ndup_arho1m); - auto a_arho1m = v_arho1m.template access>(); - auto v_arho2m = ScatterViewHelper,decltype(dup_arho2m),decltype(ndup_arho2m)>::get(dup_arho2m,ndup_arho2m); - auto a_arho2m = v_arho2m.template access>(); - auto v_arho3m = ScatterViewHelper,decltype(dup_arho3m),decltype(ndup_arho3m)>::get(dup_arho3m,ndup_arho3m); - auto a_arho3m = v_arho3m.template access>(); - auto v_arho3mb = ScatterViewHelper,decltype(dup_arho3mb),decltype(ndup_arho3mb)>::get(dup_arho3mb,ndup_arho3mb); - auto a_arho3mb = v_arho3mb.template access>(); - //} + // msmeam + auto v_arho2mb = ScatterViewHelper,decltype(dup_arho2mb),decltype(ndup_arho2mb)>::get(dup_arho2mb,ndup_arho2mb); + auto a_arho2mb = v_arho2mb.template access>(); + auto v_arho1m = ScatterViewHelper,decltype(dup_arho1m),decltype(ndup_arho1m)>::get(dup_arho1m,ndup_arho1m); + auto a_arho1m = v_arho1m.template access>(); + auto v_arho2m = ScatterViewHelper,decltype(dup_arho2m),decltype(ndup_arho2m)>::get(dup_arho2m,ndup_arho2m); + auto a_arho2m = v_arho2m.template access>(); + auto v_arho3m = ScatterViewHelper,decltype(dup_arho3m),decltype(ndup_arho3m)>::get(dup_arho3m,ndup_arho3m); + auto a_arho3m = v_arho3m.template access>(); + auto v_arho3mb = ScatterViewHelper,decltype(dup_arho3mb),decltype(ndup_arho3mb)>::get(dup_arho3mb,ndup_arho3mb); + auto a_arho3mb = v_arho3mb.template access>(); const int elti = d_map[type[i]]; const double xtmp = x(i,0); const double ytmp = x(i,1); const double ztmp = x(i,2); - printf("- begin loop over neigh i=%d\n", i); for (int jn = 0; jn < d_numneigh[i]; jn++) { if (!iszero_kk(d_scrfcn[offset+jn])) { const int j = d_neighbors_half(i,jn); @@ -557,7 +538,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty double rhoa1i = ro0i * MathSpecialKokkos::fm_exp(-beta1_meam[elti] * ai) * sij; double rhoa2i = ro0i * MathSpecialKokkos::fm_exp(-beta2_meam[elti] * ai) * sij; double rhoa3i = ro0i * MathSpecialKokkos::fm_exp(-beta3_meam[elti] * ai) * sij; - // msmeam params + // msmeam double rhoa1mj, rhoa2mj, rhoa3mj, rhoa1mi, rhoa2mi, rhoa3mi; if (msmeamflag){ rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * sij; @@ -566,13 +547,6 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty rhoa1mi = ro0i * t1m_meam[elti] * MathSpecialKokkos::fm_exp(-beta1m_meam[elti] * ai) * sij; rhoa2mi = ro0i * t2m_meam[elti] * MathSpecialKokkos::fm_exp(-beta2m_meam[elti] * ai) * sij; rhoa3mi = ro0i * t3m_meam[elti] * MathSpecialKokkos::fm_exp(-beta3m_meam[elti] * ai) * sij; - //printf("- rhoam params:\n"); - //printf(" %f %f %f\n", rhoa1mj, rhoa2mj, rhoa3mj); - //printf(" %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi); - //printf(" %f %f %f\n", this->t1m_meam[elti], this->t2m_meam[elti], this->t3m_meam[elti]); - //printf(" %f %f %f\n", this->beta1m_meam[elti], this->beta2m_meam[elti], this->beta3m_meam[elti]); - //printf(" - rhoam params %f %f %f\n", ro0i, ai, sij); - //printf(" - rhoam %f %f %f %f %f %f\n", rhoa1mi, rhoa2mi, rhoa3mi, rhoa1mj, rhoa2mj, rhoa3mj); } if (ialloy == 1) { rhoa1j *= t1_meam[eltj]; @@ -603,7 +577,6 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty } a_arho2b[i] += rhoa2j; a_arho2b[j] += rhoa2i; - //printf("- %f %f\n", a_arho2b[i], a_arho2b[j]); const double A1j = rhoa1j / rij; const double A2j = rhoa2j / rij2; @@ -611,21 +584,19 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty const double A1i = rhoa1i / rij; const double A2i = rhoa2i / rij2; const double A3i = rhoa3i / (rij2 * rij); + double A1mj, A2mj, A3mj, A1mi, A2mi, A3mi; if (msmeamflag){ a_arho2mb[i] += rhoa2mj; a_arho2mb[j] += rhoa2mi; - //printf("- %f %f\n", a_arho2mb[i], a_arho2mb[j]); + A1mj = rhoa1mj / rij; + A2mj = rhoa2mj / rij2; + A3mj = rhoa3mj / (rij2 * rij); + A1mi = rhoa1mi / rij; + A2mi = rhoa2mi / rij2; + A3mi = rhoa3mi / (rij2 * rij); } - const double A1mj = rhoa1mj / rij; - const double A2mj = rhoa2mj / rij2; - const double A3mj = rhoa3mj / (rij2 * rij); - const double A1mi = rhoa1mi / rij; - const double A2mi = rhoa2mi / rij2; - const double A3mi = rhoa3mi / (rij2 * rij); - //printf("A %d %d %f %f %f %f %f %f\n", i, j, A1mj, A2mj, A3mj, A1mi, A2mi, A3mi); int nv2 = 0; int nv3 = 0; - printf("- about to loop over m\n"); for (int m = 0; m < 3; m++) { a_arho1(i,m) += A1j * delij[m]; a_arho1(j,m) += -A1i * delij[m]; diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index 3bcedfc4ae..a67585c4e7 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -119,7 +119,7 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::~MEAMKokkos() memoryKK->destroy_kokkos(k_dscrfcn,dscrfcn); memoryKK->destroy_kokkos(k_fcpair,fcpair); - // msmeam params + // msmeam memoryKK->destroy_kokkos(k_arho2mb, arho2mb); memoryKK->destroy_kokkos(k_arho1m, arho1m); diff --git a/src/KOKKOS/meam_kokkos.h b/src/KOKKOS/meam_kokkos.h index f7bde30b85..2203355641 100644 --- a/src/KOKKOS/meam_kokkos.h +++ b/src/KOKKOS/meam_kokkos.h @@ -136,7 +136,7 @@ template class MEAMKokkos : public MEAM { DAT::tdual_ffloat_1d k_scrfcn, k_dscrfcn, k_fcpair; typename ArrayTypes::t_ffloat_1d d_scrfcn, d_dscrfcn, d_fcpair; HAT::t_ffloat_1d h_scrfcn, h_dscrfcn, h_fcpair; - // msmeam params + // msmeam DAT::tdual_ffloat_2d k_arho1m, k_arho2m, k_arho3m, k_arho3mb; typename ArrayTypes::t_ffloat_2d d_arho1m, d_arho2m, d_arho3m, d_arho3mb; HAT::t_ffloat_2d h_arho1m, h_arho2m, h_arho3m, h_arho3mb; @@ -203,7 +203,7 @@ template class MEAMKokkos : public MEAM { NonDupScatterView ndup_vatom; - // msmeam params + // msmeam DupScatterView dup_arho1m; diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index e3b4006080..3998d89bdb 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -122,10 +122,7 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) int n = 0; Kokkos::parallel_reduce(Kokkos::RangePolicy(0,inum_half),*this,n); - printf("--- about to meam_dens_setup %d\n", comm->me); - meam_inst_kk->meam_dens_setup(atom->nmax, nall, n); - printf("--- about to update meam views\n"); update_meam_views(); x = atomKK->k_x.view(); @@ -159,11 +156,9 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) int need_dup = lmp->kokkos->need_dup(); - printf("--- about to start meam_dens_init\n"); - meam_inst_kk->meam_dens_init(inum_half,ntype,type,d_map,x,d_numneigh_half,d_numneigh_full,d_ilist_half,d_neighbors_half, d_neighbors_full, d_offset, neighflag, need_dup); + meam_inst_kk->meam_dens_init(inum_half,ntype,type,d_map,x,d_numneigh_half,d_numneigh_full, + d_ilist_half,d_neighbors_half, d_neighbors_full, d_offset, neighflag, need_dup); - printf("--- modifying arrays\n"); - printf("--- msmeamflag: %d\n", msmeamflag); meam_inst_kk->k_rho0.template modify(); meam_inst_kk->k_arho2b.template modify(); meam_inst_kk->k_arho1.template modify(); @@ -173,7 +168,6 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_t_ave.template modify(); meam_inst_kk->k_tsq_ave.template modify(); if (msmeamflag){ - printf("--- modifying msmeam arrays\n"); meam_inst_kk->k_arho2mb.template modify(); meam_inst_kk->k_arho1m.template modify(); meam_inst_kk->k_arho2m.template modify(); @@ -181,7 +175,6 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3mb.template modify(); } - printf("--- start reverse comm\n"); comm->reverse_comm(this); meam_inst_kk->k_rho0.template sync(); @@ -200,7 +193,6 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3mb.template sync(); } - printf("--- about to start meam_dens_final\n"); meam_inst_kk->meam_dens_final(nlocal,eflag_either,eflag_global,eflag_atom, d_eatom,ntype,type,d_map,d_scale,errorflag,ev); @@ -231,7 +223,6 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3mb.template modify(); } - printf("--- start forward comm\n"); comm->forward_comm(this); meam_inst_kk->k_rho0.template sync(); @@ -258,7 +249,6 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3mb.template sync(); } - printf("--- starting meam_force\n"); meam_inst_kk->meam_force(inum_half,eflag_global,eflag_atom,vflag_global, vflag_atom,d_eatom,ntype,type,d_map,x, d_numneigh_half, d_numneigh_full,f,d_vatom, @@ -342,8 +332,6 @@ void PairMEAMKokkos::init_style() if (neighflag == FULL) error->all(FLERR,"Must use half neighbor list style with pair meam/kk"); - - printf("--- comm sizes: %d %d\n", comm_forward, comm_reverse); } /* ---------------------------------------------------------------------- */ @@ -356,7 +344,6 @@ int PairMEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2 iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); - //return n*38; return n*comm_forward; } @@ -366,7 +353,6 @@ template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const int &i) const { int j = d_sendlist(iswap, i); - //int m = i*38; int m = i*comm_forward; v_buf[m++] = d_rho0[j]; v_buf[m++] = d_rho1[j]; @@ -411,7 +397,7 @@ void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const in for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3m(j,k); v_buf[m++] = d_arho3mb(j,0); v_buf[m++] = d_arho3mb(j,1); - v_buf[m++] = d_arho3mb(j,2); + v_buf[m++] = d_arho3mb(j,2); } } @@ -895,7 +881,7 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->h_t_ave(j,2) += buf[m++]; meam_inst_kk->h_tsq_ave(j,0) += buf[m++]; meam_inst_kk->h_tsq_ave(j,1) += buf[m++]; - meam_inst_kk->h_tsq_ave(j,2) += buf[m++]; + meam_inst_kk->h_tsq_ave(j,2) += buf[m++]; if (msmeamflag){ meam_inst_kk->h_arho2mb[j] += buf[m++]; meam_inst_kk->h_arho1m(j,0) += buf[m++]; @@ -981,7 +967,7 @@ void PairMEAMKokkos::update_meam_views() d_arho3b = meam_inst_kk->d_arho3b; d_t_ave = meam_inst_kk->d_t_ave; d_tsq_ave = meam_inst_kk->d_tsq_ave; - // msmeam params + // msmeam d_arho1m = meam_inst_kk->d_arho1m; d_arho2m = meam_inst_kk->d_arho2m; d_arho3m = meam_inst_kk->d_arho3m; diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index db0989bb79..0b29f1715b 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -80,7 +80,7 @@ class MEAM { // msmeamflag = flag to activate MS-MEAM // betam[1-3]_meam = MS-MEAM electron density constants // tm[1-3]_meam = MS-MEAM coefficients on densities in Gamma computation - + // nr,dr = pair function discretization parameters // nrar,rdrar = spline coeff array parameters @@ -123,11 +123,11 @@ class MEAM { double dr, rdrar; // MS-MEAM parameters - + double t1m_meam[maxelt], t2m_meam[maxelt], t3m_meam[maxelt]; double beta1m_meam[maxelt], beta2m_meam[maxelt], beta3m_meam[maxelt]; //int msmeamflag; // made public for pair style settings - + public: int nmax; double *rho, *rho0, *rho1, *rho2, *rho3, *frhop; @@ -137,7 +137,7 @@ class MEAM { // MS-MEAM arrays double **arho1m, **arho2m, *arho2mb, **arho3m, **arho3mb; - + int maxneigh; double *scrfcn, *dscrfcn, *fcpair; diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index e4ac2f8fd8..b3a238c95f 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -33,11 +33,11 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ if (elti >= 0) { scaleii = scale[type[i]][type[i]]; rho1[i] = 0.0; - rho2[i] = -1.0 / 3.0 * (arho2b[i] * arho2b[i] + rho2[i] = -1.0 / 3.0 * (arho2b[i] * arho2b[i] - arho2mb[i] * arho2mb[i]); rho3[i] = 0.0; for (m = 0; m < 3; m++) { - rho1[i] = rho1[i] + arho1[i][m] * arho1[i][m] + rho1[i] = rho1[i] + arho1[i][m] * arho1[i][m] - arho1m[i][m] * arho1m[i][m]; rho3[i] = rho3[i] - 3.0 / 5.0 * (arho3b[i][m] * arho3b[i][m] - arho3mb[i][m] * arho3mb[i][m]); @@ -148,7 +148,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } if (eflag_atom != 0) { eatom[i] = eatom[i] + Fl; - + } } } @@ -263,7 +263,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } if (eflag_atom != 0) { eatom[i] = eatom[i] + Fl; - + } } } diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index 9be52efd23..6efa7fdf6a 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -23,6 +23,7 @@ using namespace LAMMPS_NS; void MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) { + int i, j; // grow local arrays if necessary @@ -101,7 +102,7 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) } for (j = 0; j < 6; j++){ arho2[i][j] = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag){ arho2m[i][j] = 0.0; } } diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 7b57f706a4..daf282e3b8 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -47,13 +47,10 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double drho0dr1, drho0dr2, drho0ds1, drho0ds2; double drho1dr1, drho1dr2, drho1ds1, drho1ds2; double drho1drm1[3], drho1drm2[3]; - //double drho1mdrm1[3], drho1mdrm2[3]; // msmeam params double drho2dr1, drho2dr2, drho2ds1, drho2ds2; double drho2drm1[3], drho2drm2[3]; - //double drho2mdrm1[3], drho2mdrm2[3]; // msmeam params double drho3dr1, drho3dr2, drho3ds1, drho3ds2; double drho3drm1[3], drho3drm2[3]; - //double drho3mdrm1[3], drho3mdrm2[3]; // msmeam params double dt1dr1, dt1dr2, dt1ds1, dt1ds2; double dt2dr1, dt2dr2, dt2ds1, dt2ds2; double dt3dr1, dt3dr2, dt3ds1, dt3ds2; @@ -66,7 +63,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int double rhoa1mj,drhoa1mj,rhoa1mi,drhoa1mi; double rhoa2mj,drhoa2mj,rhoa2mi,drhoa2mi; - double a3m, a3ma, b3m, rhoa3mj, drhoa3mj, rhoa3mi, drhoa3mi; + double rhoa3mj, drhoa3mj, rhoa3mi, drhoa3mi; double arg1i1m, arg1j1m, arg1i2m, arg1j2m, arg1i3m, arg1j3m, arg3i3m, arg3j3m; double drho1mdr1, drho1mdr2, drho1mds1, drho1mds2; double drho1mdrm1[3], drho1mdrm2[3]; @@ -113,7 +110,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int pp = std::min(pp, 1.0); phi = ((this->phirar3[ind][kk] * pp + this->phirar2[ind][kk]) * pp + this->phirar1[ind][kk]) * pp + this->phirar[ind][kk]; phip = (this->phirar6[ind][kk] * pp + this->phirar5[ind][kk]) * pp + this->phirar4[ind][kk]; - + if (eflag_either != 0) { double phi_sc = phi * scaleij; if (eflag_global != 0) @@ -190,7 +187,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3mj = rhoa3mi; drhoa3mj = drhoa3mi; } - } + } const double t1mi = this->t1_meam[elti]; const double t2mi = this->t2_meam[elti]; @@ -200,7 +197,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int const double t3mj = this->t3_meam[eltj]; // ialloy mod not needed in msmeam, but similarity here is that we need to multiply rhos by t - // msmeam fortran code accomplishes this by multiplying rho's with t's above, like we did + // msmeam fortran code accomplishes this by multiplying rho's with t's above, like we did // with rhoa1mj, rhoa2mj, etc if (this->ialloy == 1 || this->msmeamflag) { @@ -400,7 +397,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int // compute derivatives of weighting functions t wrt rij // weighting functions t set to unity for MS-MEAM - + if (this->msmeamflag) { t1i = 1.0; @@ -466,7 +463,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt3dr1 = ai * (t3mj - t3i); dt3dr2 = aj * (t3mi - t3j); } - + } // Compute derivatives of total density wrt rij, sij and rij(3) @@ -545,7 +542,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3mds1 = 0.0; drho3mds2 = 0.0; } - + if (this->ialloy == 1) { a1i = fdiv_zero(rhoa0j, tsq_ave[i][0]); @@ -610,14 +607,14 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt3ds2 * rho3[j] + t3j * drho3ds2) - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); } - } + } // Compute derivatives of energy wrt rij, sij and rij[3] // MS-MEAM affects phip dUdrij = phip * sij + frhop[i] * drhodr1 + frhop[j] * drhodr2; dUdsij = 0.0; - + if (!iszero(dscrfcn[fnoffset + jn])) { dUdsij = phi + frhop[i] * drhods1 + frhop[j] * drhods2; } diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index aff478b3d3..0dca742f39 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -46,8 +46,8 @@ MEAM::MEAM(Memory* mem) A_meam[i] = rho0_meam[i] = beta0_meam[i] = beta1_meam[i]= beta2_meam[i] = beta3_meam[i] = t0_meam[i] = t1_meam[i] = t2_meam[i] = t3_meam[i] = - rho_ref_meam[i] = ibar_meam[i] = ielt_meam[i] = - t1m_meam[i] = t2m_meam[i] = t3m_meam[i] = + rho_ref_meam[i] = ibar_meam[i] = ielt_meam[i] = + t1m_meam[i] = t2m_meam[i] = t3m_meam[i] = beta1m_meam[i] = beta2m_meam[i] = beta3m_meam[i] = 0.0; for (int j = 0; j < maxelt; j++) { lattce_meam[i][j] = FCC; diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 9bf31e049f..512ba8a639 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -174,6 +174,7 @@ void MEAM::alloyparams() void MEAM::compute_pair_meam() { + printf("- inside compute_pair_meam\n"); double r; int j, a, b, nv2; double astar, frac, phizbl; @@ -336,8 +337,6 @@ double MEAM::phi_meam(double r, int a, int b) double b11s, b22s; // msmeam params double t1m1av, t2m1av, t3m1av, t1m2av, t2m2av, t3m2av; - double rhoa1m1, rhoa2m1, rhoa3m1; - double rhoa1m2, rhoa2m2, rhoa3m2; double rho1m1, rho2m1, rho3m1; double rho1m2, rho2m2, rho3m2; @@ -389,7 +388,7 @@ double MEAM::phi_meam(double r, int a, int b) get_tavref(&t11av, &t21av, &t31av, &t12av, &t22av, &t32av, this->t1_meam[a], this->t2_meam[a], this->t3_meam[a], this->t1_meam[b], this->t2_meam[b], this->t3_meam[b], r, a, b, this->lattce_meam[a][b]); - // with msmeam call twice with different sets of variables + // with msmeam call twice with different sets of variables if (this->msmeamflag){ get_tavref(&t1m1av, &t2m1av, &t3m1av, &t1m2av, &t2m2av, &t3m2av, this->t1m_meam[a], this->t2m_meam[a], this->t3m_meam[a], this->t1m_meam[b], this->t2m_meam[b], this->t3m_meam[b], r, a, b, @@ -456,7 +455,7 @@ double MEAM::phi_meam(double r, int a, int b) Gam2 = 0.0; else Gam2 = Gam2 / (rho02 * rho02); - + } else{ Gam1 = (t11av * rho11 + t21av * rho21 + t31av * rho31); if (rho01 < 1.0e-14) @@ -694,8 +693,8 @@ void MEAM::get_sijk(double C, int i, int j, int k, double* sijk) //------------------------------------------------------------------------------c // Calculate density functions, assuming reference configuration void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, double* rho21, double* rho31, - double* rho02, double* rho12, double* rho22, double* rho32, - double* rho1m1, double* rho2m1, double* rho3m1, + double* rho02, double* rho12, double* rho22, double* rho32, + double* rho1m1, double* rho2m1, double* rho3m1, double* rho1m2, double* rho2m2, double* rho3m2) { double a1, a2; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 32fc286625..164112f9c2 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -370,6 +370,9 @@ void PairMEAM::read_files(const std::string &globalfile, void PairMEAM::read_global_meam_file(const std::string &globalfile) { + + printf("--- Reading global meam file\n"); + // allocate parameter arrays std::vector lat(nlibelements); @@ -850,7 +853,7 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) } } - + } /* ---------------------------------------------------------------------- From f3f8613437082dfab14f60122c62bc1298b7881a Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 11:21:04 -0700 Subject: [PATCH 20/43] Debug final stage of dens setup --- src/MEAM/meam_dens_final.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index e4ac2f8fd8..e35bc1f6e8 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -46,6 +46,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ rho2[i] = rho2[i] + this->v2D[m] * (arho2[i][m] * arho2[i][m] - arho2m[i][m] * arho2m[i][m]); } + for (m = 0; m < 10; m++) { rho3[i] = rho3[i] + this->v3D[m] * (arho3[i][m] * arho3[i][m] - arho3m[i][m] * arho3m[i][m]); @@ -140,7 +141,6 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } Fl = embedding(this->A_meam[elti], this->Ec_meam[elti][elti], rhob, frhop[i]); - if (eflag_either != 0) { Fl *= scaleii; if (eflag_global != 0) { @@ -148,7 +148,6 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } if (eflag_atom != 0) { eatom[i] = eatom[i] + Fl; - } } } From f1ae427ee00c025e3152aba81c4f85420b81a2d2 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 12:04:47 -0700 Subject: [PATCH 21/43] Format and organize pair MEAM --- src/MEAM/meam.h | 2 +- src/MEAM/meam_setup_done.cpp | 1 - src/MEAM/pair_meam.cpp | 18 ++++++++---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index 0b29f1715b..c5d6afbea5 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -299,7 +299,7 @@ class MEAM { } // clang-format on static int get_Zij(const lattice_t latt); - // last 6 args are msmeam parameters + // last 6 args are optional msmeam parameters void meam_setup_global(int nelt, lattice_t *lat, int *ielement, double *atwt, double *alpha, double *b0, double *b1, double *b2, double *b3, double *alat, double *esub, double *asub, double *t0, double *t1, double *t2, double *t3, diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 512ba8a639..d7550070c7 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -174,7 +174,6 @@ void MEAM::alloyparams() void MEAM::compute_pair_meam() { - printf("- inside compute_pair_meam\n"); double r; int j, a, b, nv2; double astar, frac, phizbl; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 164112f9c2..960f08020c 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -197,7 +197,7 @@ void PairMEAM::settings(int narg, char **arg) // set comm size needed by this Pair - if (this->msmeamflag){ + if (msmeamflag){ comm_forward = 38+23; // plus 23 for msmeam comm_reverse = 30+23; // plus 23 for msmeam } else{ @@ -371,8 +371,6 @@ void PairMEAM::read_files(const std::string &globalfile, void PairMEAM::read_global_meam_file(const std::string &globalfile) { - printf("--- Reading global meam file\n"); - // allocate parameter arrays std::vector lat(nlibelements); @@ -454,7 +452,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) b1[index] = values.next_double(); b2[index] = values.next_double(); b3[index] = values.next_double(); - if (this->msmeamflag){ + if (msmeamflag){ b1m[index] = values.next_double(); b2m[index] = values.next_double(); b3m[index] = values.next_double(); @@ -466,7 +464,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) t1[index] = values.next_double(); t2[index] = values.next_double(); t3[index] = values.next_double(); - if (this->msmeamflag){ + if (msmeamflag){ t1m[index] = values.next_double(); t2m[index] = values.next_double(); t3m[index] = values.next_double(); @@ -529,7 +527,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) // pass element parameters to MEAM package - if (this->msmeamflag){ + if (msmeamflag){ meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), @@ -666,7 +664,7 @@ int PairMEAM::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst->tsq_ave[j][2]; // msmeam params - increases buffer by 23 - if (this->msmeamflag){ + if (msmeamflag){ buf[m++] = meam_inst->arho2mb[j]; buf[m++] = meam_inst->arho1m[j][0]; buf[m++] = meam_inst->arho1m[j][1]; @@ -729,7 +727,7 @@ void PairMEAM::unpack_forward_comm(int n, int first, double *buf) // msmeam params - increases buffer size by 23 - if (this->msmeamflag){ + if (msmeamflag){ meam_inst->arho2mb[i] = buf[m++]; meam_inst->arho1m[i][0] = buf[m++]; meam_inst->arho1m[i][1] = buf[m++]; @@ -781,7 +779,7 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) // msmeam params - increases buffer size by 23 - if (this->msmeamflag){ + if (msmeamflag){ buf[m++] = meam_inst->arho2mb[i]; buf[m++] = meam_inst->arho1m[i][0]; buf[m++] = meam_inst->arho1m[i][1]; @@ -835,7 +833,7 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) // msmeam params - increases buffer size by 23 - if (this->msmeamflag){ + if (msmeamflag){ meam_inst->arho2mb[j] += buf[m++]; meam_inst->arho1m[j][0] += buf[m++]; meam_inst->arho1m[j][1] += buf[m++]; From 8f554a3b1c0bfa5f96c816053aa1c91b82c39d3c Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 12:30:18 -0700 Subject: [PATCH 22/43] Clean up --- examples/meam/in.meam | 3 +- examples/meam/msmeam/test.out | 252 --------------------------------- lib/kokkos/bin/nvcc_wrapper | 4 +- src/KOKKOS/meam_force_kokkos.h | 5 +- src/MEAM/meam_dens_init.cpp | 4 +- src/MEAM/meam_force.cpp | 5 +- src/MEAM/meam_setup_done.cpp | 16 +-- src/MEAM/pair_meam.cpp | 33 ++--- 8 files changed, 24 insertions(+), 298 deletions(-) delete mode 100644 examples/meam/msmeam/test.out diff --git a/examples/meam/in.meam b/examples/meam/in.meam index 6c065becff..cfaf1db7c3 100644 --- a/examples/meam/in.meam +++ b/examples/meam/in.meam @@ -27,4 +27,5 @@ timestep 0.001 # axes yes 0.8 0.02 view 60 -30 #dump_modify 3 pad 3 element Si C -run 100 \ No newline at end of file +run 100 + diff --git a/examples/meam/msmeam/test.out b/examples/meam/msmeam/test.out deleted file mode 100644 index 30a6616f40..0000000000 --- a/examples/meam/msmeam/test.out +++ /dev/null @@ -1,252 +0,0 @@ -LAMMPS (23 Jun 2022) -log test.log -# Test of MEAM potential for HGa - -# ------------------------ INITIALIZATION ---------------------------- -units metal -dimension 3 -boundary p p p -atom_style atomic -variable latparam equal 4.646 -variable ncell equal 3 - -# ----------------------- ATOM DEFINITION ---------------------------- -region box block -4 4 -4 4 -4 4 -create_box 2 box -Created orthogonal box = (-4 -4 -4) to (4 4 4) - 1 by 1 by 1 MPI processor grid - -# - -include potential.mod -# NOTE: This script can be modified for different pair styles -# See in.elastic for more info. - -variable Pu string H -print "potential chosen ${Pu}" -potential chosen H -# Choose potential -pair_style meam ms # the `ms` flag turns on MS-MEAM -print "we just executed" -we just executed - -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 -Reading MEAM library file library.MSmeam with DATE: 2018-09-22 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 1.0079 -Tokenizer::next_double() current = 2.960 -Tokenizer::next_double() current = 2.960 -Tokenizer::next_double() current = 3.0 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_double() current = 3.0 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_double() current = 0.741 -Tokenizer::next_double() current = 2.235 -Tokenizer::next_double() current = 2.50 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_double() current = 0.44721 -Tokenizer::next_double() current = 0.0 -Tokenizer::next_double() current = 0.00 -Tokenizer::next_double() current = 0.0 -Tokenizer::next_double() current = 0.31623 -Tokenizer::next_double() current = 0 -Tokenizer::next_double() current = 6.70 -Tokenizer::next_int() current = 0 -Tokenizer::next_double() current = 12.0 -Tokenizer::next_int() current = 31 -Tokenizer::next_double() current = 69.723 -Tokenizer::next_double() current = 4.42 -Tokenizer::next_double() current = 4.80 -Tokenizer::next_double() current = 3.10 -Tokenizer::next_double() current = 6.00 -Tokenizer::next_double() current = 0.00 -Tokenizer::next_double() current = 0.0 -Tokenizer::next_double() current = 0.0 -Tokenizer::next_double() current = 0.5 -Tokenizer::next_double() current = 4.247 -Tokenizer::next_double() current = 2.897 -Tokenizer::next_double() current = 0.97 -Tokenizer::next_double() current = 1.0 -Tokenizer::next_double() current = 1.649 -Tokenizer::next_double() current = 1.435 -Tokenizer::next_double() current = 0.00 -Tokenizer::next_double() current = 0.0 -Tokenizer::next_double() current = 0.0 -Tokenizer::next_double() current = 2.0 -Tokenizer::next_double() current = 0.70 -Tokenizer::next_int() current = 0 -Tokenizer::next_double() current = 1 -Tokenizer::next_double() current = 1 -Tokenizer::next_double() current = 0 -Tokenizer::next_double() current = 1 -Tokenizer::next_double() current = 5.9 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 0.460 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 0.460 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 1.3 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 2.80 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 0.6 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 0.097 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 0.097 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 0.300 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 0.300 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 3.19 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = -0.48 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 6.6 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 2.0 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 2.0 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 2.0 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 1 -Tokenizer::next_double() current = 1.4 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 1.4 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 1.4 -Tokenizer::next_int() current = 1 -Tokenizer::next_int() current = 2 -Tokenizer::next_double() current = 1 -# Setup neighbor style -neighbor 1.0 nsq -neigh_modify once no every 1 delay 0 check yes - -# Setup minimization style -variable dmax equal 1.0e-2 -min_style cg -min_modify dmax ${dmax} line quadratic -min_modify dmax 0.01 line quadratic -compute eng all pe/atom -compute eatoms all reduce sum c_eng - -# Setup output -thermo 100 -thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms -thermo_modify norm yes -create_atoms 1 single 0 0 0 units box -Created 1 atoms - using box units in orthogonal box = (-4 -4 -4) to (4 4 4) - create_atoms CPU = 0.000 seconds -create_atoms 2 single 2.2 0 0 units box -Created 1 atoms - using box units in orthogonal box = (-4 -4 -4) to (4 4 4) - create_atoms CPU = 0.000 seconds -create_atoms 2 single 0.3 2.3 0 units box -Created 1 atoms - using box units in orthogonal box = (-4 -4 -4) to (4 4 4) - create_atoms CPU = 0.000 seconds -# ---------- Define Settings --------------------- -variable teng equal "c_eatoms" -compute pot_energy all pe/atom -compute stress all stress/atom NULL -dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.9 - ghost atom cutoff = 6.9 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair meam, perpetual - attributes: full, newton on - pair build: full/nsq - stencil: none - bin: none - (2) pair meam, perpetual, half/full from (1) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none -Setting up Verlet run ... - Unit style : metal - Current step : 0 - Time step : 0.001 -Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes - Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms - 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 - 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 -Loop time of 8.3795e-05 on 1 procs for 1 steps with 3 atoms - -Performance: 1031.088 ns/day, 0.023 hours/ns, 11933.886 timesteps/s -57.3% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.1835e-05 | 2.1835e-05 | 2.1835e-05 | 0.0 | 26.06 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 3.128e-06 | 3.128e-06 | 3.128e-06 | 0.0 | 3.73 -Output | 5.4931e-05 | 5.4931e-05 | 5.4931e-05 | 0.0 | 65.55 -Modify | 1.601e-06 | 1.601e-06 | 1.601e-06 | 0.0 | 1.91 -Other | | 2.3e-06 | | | 2.74 - -Nlocal: 3 ave 3 max 3 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 78 ave 78 max 78 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 7 ave 7 max 7 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 14 ave 14 max 14 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 14 -Ave neighs/atom = 4.6666667 -Neighbor list builds = 0 -Dangerous builds = 0 -write_data test.data -System init for write_data ... - -print "All done!" -All done! -Total wall time: 0:00:00 diff --git a/lib/kokkos/bin/nvcc_wrapper b/lib/kokkos/bin/nvcc_wrapper index f8bf1c3763..e1a2088138 100755 --- a/lib/kokkos/bin/nvcc_wrapper +++ b/lib/kokkos/bin/nvcc_wrapper @@ -12,8 +12,8 @@ # or g++ as their back-end compiler. The defaults can be overwritten # by using the usual arguments (e.g., -arch=sm_30 -ccbin icpc). -#default_arch="sm_35" -default_arch="sm_50" +default_arch="sm_35" +#default_arch="sm_50" # # The default C++ compiler. diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index a67585c4e7..b1578512a1 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -263,9 +263,8 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForcet3m_meam[elti] * MathSpecial::fm_exp(-this->beta3m_meam[elti] * ai) * sij; } if (this->ialloy == 1) { - // this is used in Baske's test since they put t's in rhoa definitions rhoa1j = rhoa1j * this->t1_meam[eltj]; rhoa2j = rhoa2j * this->t2_meam[eltj]; rhoa3j = rhoa3j * this->t3_meam[eltj]; @@ -364,7 +362,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn rho0[i] = rho0[i] + rhoa0j; rho0[j] = rho0[j] + rhoa0i; // For ialloy = 2, use single-element value (not average) - // Not used in MS-MEAM: For ialloy = 2, use single-element value (not average) + // For ialloy = 2, use single-element value (not average) if (this->ialloy != 2) { t_ave[i][0] = t_ave[i][0] + this->t1_meam[eltj] * rhoa0j; t_ave[i][1] = t_ave[i][1] + this->t2_meam[eltj] * rhoa0j; diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index daf282e3b8..f11b5cd700 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -196,9 +196,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int const double t2mj = this->t2_meam[eltj]; const double t3mj = this->t3_meam[eltj]; - // ialloy mod not needed in msmeam, but similarity here is that we need to multiply rhos by t - // msmeam fortran code accomplishes this by multiplying rho's with t's above, like we did - // with rhoa1mj, rhoa2mj, etc + // ialloy mod not needed in MS-MEAM, but similarity here is that we multply rhos by t. + // We did this above with rhoa1mj, rhoa2mj, etc. if (this->ialloy == 1 || this->msmeamflag) { rhoa1j *= t1mj; diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index d7550070c7..d304fd74d4 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -235,7 +235,6 @@ void MEAM::compute_pair_meam() // well. if (this->lattce_meam[a][b] == B1 || this->lattce_meam[a][b] == B2 || this->lattce_meam[a][b] == L12 || this->lattce_meam[a][b] == DIA) { - rarat = r * arat; // phi_aa @@ -295,9 +294,8 @@ void MEAM::compute_pair_meam() // endif if (this->zbl_meam[a][b] == 1) { astar = this->alpha_meam[a][b] * (r / this->re_meam[a][b] - 1.0); - if (astar <= -3.0){ + if (astar <= -3.0) this->phir[nv2][j] = zbl(r, this->ielt_meam[a], this->ielt_meam[b]); - } else if (astar > -3.0 && astar < -1.0) { frac = fcut(1 - (astar + 1.0) / (-3.0 + 1.0)); phizbl = zbl(r, this->ielt_meam[a], this->ielt_meam[b]); @@ -334,7 +332,7 @@ double MEAM::phi_meam(double r, int a, int b) lattice_t latta /*unused:,lattb*/; double rho_bkgd1, rho_bkgd2; double b11s, b22s; - // msmeam params + // msmeam double t1m1av, t2m1av, t3m1av, t1m2av, t2m2av, t3m2av; double rho1m1, rho2m1, rho3m1; double rho1m2, rho2m2, rho3m2; @@ -365,7 +363,6 @@ double MEAM::phi_meam(double r, int a, int b) // calculate average weighting factors for the reference structure if (this->lattce_meam[a][b] == C11) { - // note ialloy and t_ave not used in msmeam if (this->ialloy == 2) { t11av = this->t1_meam[a]; t12av = this->t1_meam[b]; @@ -439,17 +436,15 @@ double MEAM::phi_meam(double r, int a, int b) rho0_1 = this->rho0_meam[a] * Z1 * G1; rho0_2 = this->rho0_meam[b] * Z2 * G2; } - // msmeam modified: no additional use of t's here. All included in definitions of rho's (in fortran) if (this->msmeamflag){ + // no additional use of t's here; all included in definitions of rho's for msmeam Gam1 = rho11 + rho21 + rho31 - (rho1m1 + rho2m1 + rho3m1); - //Gam1 = Gam1/(rho01 * rho01); if (rho01 < 1.0e-14) Gam1 = 0.0; else Gam1 = Gam1 / (rho01 * rho01); Gam2 = rho12 + rho22 + rho32 - (rho1m2 + rho2m2 + rho3m2); - //Gam2 = Gam2/(rho02 * rho02); if (rho02 < 1.0e-14) Gam2 = 0.0; else @@ -705,7 +700,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou double rhoa02, rhoa12, rhoa22, rhoa32; double arat, scrn, denom; double C, s111, s112, s221, S11, S22; - // msmeam params + // msmeam double rhoa1m1, rhoa2m1, rhoa3m1, rhoa1m2, rhoa2m2, rhoa3m2; a1 = r / this->re_meam[a][a] - 1.0; @@ -714,7 +709,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa01 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta0_meam[a] * a1); if (this->msmeamflag){ - // in msmeam, the rho variables are multiplied by t here since we don't use ialloy + // the rho variables are multiplied by t here since ialloy not needed in msmeam rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); rhoa21 = this->rho0_meam[a] * this->t2_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); rhoa31 = this->rho0_meam[a] * this->t3_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); @@ -835,7 +830,6 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou case L12: *rho01 = 8 * rhoa01 + 4 * rhoa02; *rho02 = 12 * rhoa01; - // possibly inconsistent use of t's when using msmeam if (this->ialloy ==1){ *rho21 = 8. / 3. * MathSpecial::square(rhoa21 * this->t2_meam[a] - rhoa22 * this->t2_meam[b]); denom = 8 * rhoa01 * MathSpecial::square(this->t2_meam[a]) + 4 * rhoa02 * MathSpecial::square(this->t2_meam[b]); diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 960f08020c..a5ea5c0ded 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -436,8 +436,6 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) // map lat string to an integer std::string lattice_type = values.next_string(); - //error->one(FLERR,"lattice_type {}", lattice_type); - if (!MEAM::str_to_lat(lattice_type, true, lat[index])) error->one(FLERR,"Unrecognized lattice type in MEAM " "library file: {}", lattice_type); @@ -528,17 +526,17 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) // pass element parameters to MEAM package if (msmeamflag){ - meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), - alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), - alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), - t2.data(), t3.data(), rozero.data(), ibar.data(), b1m.data(), - b2m.data(), b3m.data(), t1m.data(), t2m.data(), t3m.data()); + meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), + alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), + alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), + t2.data(), t3.data(), rozero.data(), ibar.data(), b1m.data(), + b2m.data(), b3m.data(), t1m.data(), t2m.data(), t3m.data()); } else{ - meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), - alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), - alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), - t2.data(), t3.data(), rozero.data(), ibar.data(), nullptr, - nullptr, nullptr, nullptr, nullptr, nullptr); + meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), + alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), + alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), + t2.data(), t3.data(), rozero.data(), ibar.data(), nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr); } // set element masses @@ -662,8 +660,6 @@ int PairMEAM::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst->tsq_ave[j][0]; buf[m++] = meam_inst->tsq_ave[j][1]; buf[m++] = meam_inst->tsq_ave[j][2]; - - // msmeam params - increases buffer by 23 if (msmeamflag){ buf[m++] = meam_inst->arho2mb[j]; buf[m++] = meam_inst->arho1m[j][0]; @@ -724,9 +720,6 @@ void PairMEAM::unpack_forward_comm(int n, int first, double *buf) meam_inst->tsq_ave[i][0] = buf[m++]; meam_inst->tsq_ave[i][1] = buf[m++]; meam_inst->tsq_ave[i][2] = buf[m++]; - - // msmeam params - increases buffer size by 23 - if (msmeamflag){ meam_inst->arho2mb[i] = buf[m++]; meam_inst->arho1m[i][0] = buf[m++]; @@ -776,9 +769,6 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) buf[m++] = meam_inst->tsq_ave[i][0]; buf[m++] = meam_inst->tsq_ave[i][1]; buf[m++] = meam_inst->tsq_ave[i][2]; - - // msmeam params - increases buffer size by 23 - if (msmeamflag){ buf[m++] = meam_inst->arho2mb[i]; buf[m++] = meam_inst->arho1m[i][0]; @@ -830,9 +820,6 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) meam_inst->tsq_ave[j][0] += buf[m++]; meam_inst->tsq_ave[j][1] += buf[m++]; meam_inst->tsq_ave[j][2] += buf[m++]; - - // msmeam params - increases buffer size by 23 - if (msmeamflag){ meam_inst->arho2mb[j] += buf[m++]; meam_inst->arho1m[j][0] += buf[m++]; From ab83b31ce2ff6e971eb34f15a179a21bd00cb127 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 13:05:47 -0700 Subject: [PATCH 23/43] Document changes --- doc/src/pair_meam.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/src/pair_meam.rst b/doc/src/pair_meam.rst index ae8b96a47d..194afeb1ff 100644 --- a/doc/src/pair_meam.rst +++ b/doc/src/pair_meam.rst @@ -11,7 +11,9 @@ Syntax .. code-block:: LAMMPS - pair_style meam + pair_style meam [ms] + +* ms = use multi-state MEAM (optional) Examples """""""" @@ -351,6 +353,14 @@ Most published MEAM parameter sets use the default values *attrac* = *repulse* = Setting *repuls* = *attrac* = *delta* corresponds to the form used in several recent published MEAM parameter sets, such as :ref:`(Valone) ` +The optional *ms* flag activates multi-state MEAM (MS-MEAM) according to :ref:`(Baskes2) `. +This requires 6 extra parameters in the MEAM library file, resulting in 25 parameters ordered like: + +elt, lat, z, ielement, atwt, alpha, b0, b1, b2, b3, b1m, b2m, b3m, alat, esub, asub, +t0, t1, t2, t3, t1m, t2m, t3m, rozero, ibar + +The 6 extra MS-MEAM parameters are *b1m, b2m, b3m, t1m, t2m, t3m*. + ---------- .. include:: accel_styles.rst @@ -421,6 +431,10 @@ none **(Baskes)** Baskes, Phys Rev B, 46, 2727-2742 (1992). +.. _Baskes2: + +**(Baskes2)** Baskes, Phys Rev B, 75, 094113 (2007). + .. _Gullet: **(Gullet)** Gullet, Wagner, Slepoy, SANDIA Report 2003-8782 (2003). DOI:10.2172/918395 From d0a614b1fe2302ed989579f7dac80a15e85f1c14 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 14:53:00 -0700 Subject: [PATCH 24/43] Remove unnecessary conditional --- src/KOKKOS/meam_dens_final_kokkos.h | 6 +++--- src/MEAM/meam_dens_final.cpp | 25 ++----------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index 1f88c7c54b..67f016d0a2 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -67,10 +67,10 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } else{ d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; } - if (!msmeamflag) - d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; - else + if (msmeamflag) d_rho2[i] = -1.0 / 3.0 * (d_arho2b[i] * d_arho2b[i] - d_arho2mb[i] * d_arho2mb[i]); + else + d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; d_rho3[i] = 0.0; for (int m = 0; m < 3; m++) { if (msmeamflag){ diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index 59ea74ebcc..de23009332 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -52,28 +52,8 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ - arho3m[i][m] * arho3m[i][m]); } - if (this->msmeamflag){ - // with msmeam, all the t weights are already accounted for - gamma[i] = rho1[i] + rho2[i] + rho3[i]; - } else { - if (rho0[i] > 0.0) { - if (this->ialloy == 1) { - t_ave[i][0] = fdiv_zero(t_ave[i][0], tsq_ave[i][0]); - t_ave[i][1] = fdiv_zero(t_ave[i][1], tsq_ave[i][1]); - t_ave[i][2] = fdiv_zero(t_ave[i][2], tsq_ave[i][2]); - } else if (this->ialloy == 2) { - t_ave[i][0] = this->t1_meam[elti]; - t_ave[i][1] = this->t2_meam[elti]; - t_ave[i][2] = this->t3_meam[elti]; - } else { - t_ave[i][0] = t_ave[i][0] / rho0[i]; - t_ave[i][1] = t_ave[i][1] / rho0[i]; - t_ave[i][2] = t_ave[i][2] / rho0[i]; - } - } - - gamma[i] = t_ave[i][0] * rho1[i] + t_ave[i][1] * rho2[i] + t_ave[i][2] * rho3[i]; - } + // all the t weights are already accounted for with msmeam + gamma[i] = rho1[i] + rho2[i] + rho3[i]; if (rho0[i] > 0.0) { gamma[i] = gamma[i] / (rho0[i] * rho0[i]); @@ -101,7 +81,6 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } rho[i] = rho0[i] * G; - // mix_ref_t == 1 should not be used with msmeam if (this->mix_ref_t == 1) { if (this->ibar_meam[elti] <= 0) { Gbar = 1.0; From 647172bfe1eeaf4293c1ec61152005c8756a24d0 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 14:56:27 -0700 Subject: [PATCH 25/43] Clean up --- src/KOKKOS/meam_dens_final_kokkos.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index 67f016d0a2..dbbf887bc2 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -67,10 +67,6 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } else{ d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; } - if (msmeamflag) - d_rho2[i] = -1.0 / 3.0 * (d_arho2b[i] * d_arho2b[i] - d_arho2mb[i] * d_arho2mb[i]); - else - d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; d_rho3[i] = 0.0; for (int m = 0; m < 3; m++) { if (msmeamflag){ @@ -135,7 +131,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT Gbar = 1.0; dGbar = 0.0; } else { - if (mix_ref_t == 1) // mix_ref_t not used with msmeam + if (mix_ref_t == 1) gam = (d_t_ave(i,0) * shp[0] + d_t_ave(i,1) * shp[1] + d_t_ave(i,2) * shp[2]) / (Z * Z); else gam = (t1_meam[elti] * shp[0] + t2_meam[elti] * shp[1] + t3_meam[elti] * shp[2]) / From 862c7180bbc22092e3e6eadb995c16947f8c177f Mon Sep 17 00:00:00 2001 From: rohskopf Date: Tue, 24 Jan 2023 21:11:33 -0700 Subject: [PATCH 26/43] Enclose create/destroy in msmeam conditional --- src/MEAM/meam_dens_init.cpp | 24 ++++++++++++++---------- src/MEAM/meam_impl.cpp | 9 +++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index 4286853e01..2e67d7277f 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -46,11 +46,13 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memory->destroy(t_ave); memory->destroy(tsq_ave); // msmeam params - memory->destroy(arho1m); - memory->destroy(arho2m); - memory->destroy(arho3m); - memory->destroy(arho2mb); - memory->destroy(arho3mb); + if (this->msmeamflag){ + memory->destroy(arho1m); + memory->destroy(arho2m); + memory->destroy(arho3m); + memory->destroy(arho2mb); + memory->destroy(arho3mb); + } nmax = atom_nmax; @@ -72,11 +74,13 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memory->create(t_ave, nmax, 3, "pair:t_ave"); memory->create(tsq_ave, nmax, 3, "pair:tsq_ave"); // msmeam params - memory->create(arho1m, nmax, 3, "pair:arho1m"); - memory->create(arho2m, nmax, 6, "pair:arho2m"); - memory->create(arho3m, nmax, 10, "pair:arho3m"); - memory->create(arho2mb, nmax, "pair:arho2mb"); - memory->create(arho3mb, nmax, 3, "pair:arho3mb"); + if (this->msmeamflag){ + memory->create(arho1m, nmax, 3, "pair:arho1m"); + memory->create(arho2m, nmax, 6, "pair:arho2m"); + memory->create(arho3m, nmax, 10, "pair:arho3m"); + memory->create(arho2mb, nmax, "pair:arho2mb"); + memory->create(arho3mb, nmax, 3, "pair:arho3mb"); + } } if (n_neigh > maxneigh) { diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index 0dca742f39..d2db0d9c7b 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -92,4 +92,13 @@ MEAM::~MEAM() memory->destroy(this->scrfcn); memory->destroy(this->dscrfcn); memory->destroy(this->fcpair); + + // msmeam + if (this->msmeamflag){ + memory->destroy(this->arho1m); + memory->destroy(this->arho2m); + memory->destroy(this->arho3m); + memory->destroy(this->arho2mb); + memory->destroy(this->arho3mb); + } } From c87b4c58876ee36e32b39cf8db530e0c46fcc9cb Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 25 Jan 2023 06:16:36 -0500 Subject: [PATCH 27/43] must initialize msmeamflag --- src/MEAM/meam_impl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index d2db0d9c7b..f85d9d710c 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -33,7 +33,9 @@ MEAM::MEAM(Memory* mem) rho = rho0 = rho1 = rho2 = rho3 = frhop = nullptr; gamma = dgamma1 = dgamma2 = dgamma3 = arho2b = nullptr; arho1 = arho2 = arho3 = arho3b = t_ave = tsq_ave = nullptr; + // msmeam arrays + msmeamflag = 0; arho2mb = nullptr; arho1m = arho2m = arho3m = arho3mb = nullptr; From fcea881d3e05a932fefd7c0a2653c3d2316674f3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 25 Jan 2023 06:16:48 -0500 Subject: [PATCH 28/43] programming style --- src/MEAM/pair_meam.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index a5ea5c0ded..db31fd264c 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -183,16 +183,15 @@ void PairMEAM::allocate() void PairMEAM::settings(int narg, char **arg) { - if (narg > 1) error->all(FLERR,"Illegal pair_style command"); + if (narg > 1) error->all(FLERR,"Illegal pair_style meam command"); meam_inst->msmeamflag = 0; - if (narg == 1){ - if (strcmp("ms", arg[0]) == 0){ - msmeamflag = 1; - meam_inst->msmeamflag = 1; + if (narg == 1) { + if (strcmp("ms", arg[0]) == 0) { + msmeamflag = meam_inst->msmeamflag = 1; } else - error->all(FLERR, "Unknown pair style zero option {}", arg[0]); + error->all(FLERR, "Unknown pair style meam option {}", arg[0]); } // set comm size needed by this Pair From 16354d02622390c6c758ff152d4f7a51843607c0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 25 Jan 2023 15:28:22 -0500 Subject: [PATCH 29/43] fix out-of-bounds access --- src/MEAM/meam_force.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index f11b5cd700..8d0ef861f7 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -386,12 +386,14 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho3mdrm2[m] = (-a3 * drho3mdrm2[m] + a3a * arho3mb[j][m]) * rhoa3mi; } } else { - drho1mdrm1[m] = 0.0; - drho1mdrm2[m] = 0.0; - drho2mdrm1[m] = 0.0; - drho2mdrm2[m] = 0.0; - drho3mdrm1[m] = 0.0; - drho3mdrm2[m] = 0.0; + for (m = 0; m < 3; m++) { + drho1mdrm1[m] = 0.0; + drho1mdrm2[m] = 0.0; + drho2mdrm1[m] = 0.0; + drho2mdrm2[m] = 0.0; + drho3mdrm1[m] = 0.0; + drho3mdrm2[m] = 0.0; + } } // compute derivatives of weighting functions t wrt rij From 91ef7c22fa45f8553dc5d4d0c7f7bbbca3c48ab8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 25 Jan 2023 15:29:13 -0500 Subject: [PATCH 30/43] reindent --- src/MEAM/meam_force.cpp | 64 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 8d0ef861f7..e483676118 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -169,25 +169,25 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drhoa3mj = -this->beta3m_meam[eltj] * invrej * rhoa3mj; } - } else { - rhoa0j = rhoa0i; - drhoa0j = drhoa0i; - rhoa1j = rhoa1i; - drhoa1j = drhoa1i; - rhoa2j = rhoa2i; - drhoa2j = drhoa2i; - rhoa3j = rhoa3i; - drhoa3j = drhoa3i; + } else { + rhoa0j = rhoa0i; + drhoa0j = drhoa0i; + rhoa1j = rhoa1i; + drhoa1j = drhoa1i; + rhoa2j = rhoa2i; + drhoa2j = drhoa2i; + rhoa3j = rhoa3i; + drhoa3j = drhoa3i; - if (this->msmeamflag) { - rhoa1mj = rhoa1mi; - drhoa1mj = drhoa1mi; - rhoa2mj = rhoa2mi; - drhoa2mj = drhoa2mi; - rhoa3mj = rhoa3mi; - drhoa3mj = drhoa3mi; - } - } + if (this->msmeamflag) { + rhoa1mj = rhoa1mi; + drhoa1mj = drhoa1mi; + rhoa2mj = rhoa2mi; + drhoa2mj = drhoa2mi; + rhoa3mj = rhoa3mi; + drhoa3mj = drhoa3mi; + } + } const double t1mi = this->t1_meam[elti]; const double t2mi = this->t2_meam[elti]; @@ -352,8 +352,8 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int drho2mdrm1[m] = 0.0; drho2mdrm2[m] = 0.0; for (n = 0; n < 3; n++) { - drho2mdrm1[m] = drho2mdrm1[m] + arho2m[i][this->vind2D[m][n]] * delij[n]; - drho2mdrm2[m] = drho2mdrm2[m] - arho2m[j][this->vind2D[m][n]] * delij[n]; + drho2mdrm1[m] += arho2m[i][this->vind2D[m][n]] * delij[n]; + drho2mdrm2[m] -= arho2m[j][this->vind2D[m][n]] * delij[n]; } drho2mdrm1[m] = a2 * rhoa2mj * drho2mdrm1[m]; drho2mdrm2[m] = -a2 * rhoa2mi * drho2mdrm2[m]; @@ -376,10 +376,10 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int nv2 = 0; for (n = 0; n < 3; n++) { for (p = n; p < 3; p++) { - arg = delij[n] * delij[p] * this->v2D[nv2]; - drho3mdrm1[m] = drho3mdrm1[m] + arho3m[i][this->vind3D[m][n][p]] * arg; - drho3mdrm2[m] = drho3mdrm2[m] + arho3m[j][this->vind3D[m][n][p]] * arg; - nv2 = nv2 + 1; + arg = delij[n] * delij[p] * this->v2D[nv2]; + drho3mdrm1[m] += arho3m[i][this->vind3D[m][n][p]] * arg; + drho3mdrm2[m] += arho3m[j][this->vind3D[m][n][p]] * arg; + nv2 = nv2 + 1; } } drho3mdrm1[m] = (a3 * drho3mdrm1[m] - a3a * arho3mb[i][m]) * rhoa3mj; @@ -473,15 +473,15 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int if (this->msmeamflag){ drhodr1 = dgamma1[i] * drho0dr1 + - dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + - dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + - dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - - dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + + dt3dr1 * rho3[i] + t3i * (drho3dr1 - drho3mdr1)) - + dgamma3[i] * (shpi[0] * dt1dr1 + shpi[1] * dt2dr1 + shpi[2] * dt3dr1); drhodr2 = dgamma1[j] * drho0dr2 + - dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + - dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + - dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - - dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); + dgamma2[j] * (dt1dr2 * rho1[j] + t1j * (drho1dr2 - drho1mdr2) + + dt2dr2 * rho2[j] + t2j * (drho2dr2 - drho2mdr2) + + dt3dr2 * rho3[j] + t3j * (drho3dr2 - drho3mdr2)) - + dgamma3[j] * (shpj[0] * dt1dr2 + shpj[1] * dt2dr2 + shpj[2] * dt3dr2); for (m = 0; m < 3; m++) { drhodrm1[m] = 0.0; drhodrm2[m] = 0.0; From 34a5123e29bf04b65b04f3f08e7ccdbeb0b01217 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Wed, 25 Jan 2023 13:56:52 -0700 Subject: [PATCH 31/43] Kokkos fix out-of-bounds access --- src/KOKKOS/meam_force_kokkos.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index b1578512a1..00992eadec 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -456,12 +456,15 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce Date: Wed, 25 Jan 2023 14:05:55 -0700 Subject: [PATCH 32/43] Use bin neighbor list with Kokkos --- examples/meam/msmeam/potential.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/meam/msmeam/potential.mod b/examples/meam/msmeam/potential.mod index 10cc43afd8..ceec721c45 100644 --- a/examples/meam/msmeam/potential.mod +++ b/examples/meam/msmeam/potential.mod @@ -9,7 +9,7 @@ print "we just executed" pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 # Setup neighbor style -neighbor 1.0 nsq +neighbor 1.0 bin neigh_modify once no every 1 delay 0 check yes # Setup minimization style From d88a4a768d89b9ee00fbdfcf6e22b9a12ad238d2 Mon Sep 17 00:00:00 2001 From: rohskopf Date: Wed, 25 Jan 2023 14:52:02 -0700 Subject: [PATCH 33/43] Style changes --- examples/meam/msmeam/{HGaMS.meam => HGa.meam} | 0 .../msmeam/{library.MSmeam => library.msmeam} | 2 +- examples/meam/msmeam/potential.mod | 2 +- examples/meam/msmeam/test.data | 2 +- examples/meam/msmeam/test.dump | 24 ---- examples/meam/msmeam/test.log | 123 ------------------ potentials/HGa.msmeam | 30 +++++ potentials/library.msmeam | 14 ++ src/KOKKOS/meam_dens_final_kokkos.h | 10 +- src/KOKKOS/meam_dens_init_kokkos.h | 16 +-- src/KOKKOS/meam_force_kokkos.h | 29 ++--- src/KOKKOS/pair_meam_kokkos.cpp | 36 ++--- src/MEAM/meam_dens_final.cpp | 4 +- src/MEAM/meam_dens_init.cpp | 24 ++-- src/MEAM/meam_force.cpp | 10 +- src/MEAM/meam_impl.cpp | 2 +- src/MEAM/meam_setup_done.cpp | 27 ++-- src/MEAM/pair_meam.cpp | 20 +-- 18 files changed, 135 insertions(+), 240 deletions(-) rename examples/meam/msmeam/{HGaMS.meam => HGa.meam} (100%) rename examples/meam/msmeam/{library.MSmeam => library.msmeam} (82%) delete mode 100644 examples/meam/msmeam/test.dump delete mode 100644 examples/meam/msmeam/test.log create mode 100644 potentials/HGa.msmeam create mode 100644 potentials/library.msmeam diff --git a/examples/meam/msmeam/HGaMS.meam b/examples/meam/msmeam/HGa.meam similarity index 100% rename from examples/meam/msmeam/HGaMS.meam rename to examples/meam/msmeam/HGa.meam diff --git a/examples/meam/msmeam/library.MSmeam b/examples/meam/msmeam/library.msmeam similarity index 82% rename from examples/meam/msmeam/library.MSmeam rename to examples/meam/msmeam/library.msmeam index 438284e90f..9937eaee08 100644 --- a/examples/meam/msmeam/library.MSmeam +++ b/examples/meam/msmeam/library.msmeam @@ -1,4 +1,4 @@ -# DATE: 2018-09-22 MB DATE: 2016-09-21 CONTRIBUTOR: Steve Valone, smv@lanl.gov CITATION: Baskes, PRB 1992; smv, sr, mib, JNM 2010 +# DATE: 2018-09-22 UNITS: metal CONTRIBUTOR: Steve Valone, smv@lanl.gov CITATION: Baskes, PRB 1992; smv, sr, mib, JNM 2010 # ms-meam data format May 2010 # elt lat z ielement atwt # alpha b0 b1 b2 b3 b1m b2m b3m alat esub asub diff --git a/examples/meam/msmeam/potential.mod b/examples/meam/msmeam/potential.mod index ceec721c45..37596ce725 100644 --- a/examples/meam/msmeam/potential.mod +++ b/examples/meam/msmeam/potential.mod @@ -7,7 +7,7 @@ print "potential chosen ${Pu}" pair_style meam ms # the `ms` flag turns on MS-MEAM print "we just executed" -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.msmeam ${Pu} Ga4 HGa.meam ${Pu} Ga4 # Setup neighbor style neighbor 1.0 bin neigh_modify once no every 1 delay 0 check yes diff --git a/examples/meam/msmeam/test.data b/examples/meam/msmeam/test.data index 1347192780..69be174e2d 100644 --- a/examples/meam/msmeam/test.data +++ b/examples/meam/msmeam/test.data @@ -12,7 +12,7 @@ Masses 1 1.0079 2 69.723 -Atoms # atomic +Atoms # atomic/kk 1 1 0 0 0 0 0 0 2 2 2.2 0 0 0 0 0 diff --git a/examples/meam/msmeam/test.dump b/examples/meam/msmeam/test.dump deleted file mode 100644 index 6faee7ce12..0000000000 --- a/examples/meam/msmeam/test.dump +++ /dev/null @@ -1,24 +0,0 @@ -ITEM: TIMESTEP -0 -ITEM: NUMBER OF ATOMS -3 -ITEM: BOX BOUNDS pp pp pp --4.0000000000000000e+00 4.0000000000000000e+00 --4.0000000000000000e+00 4.0000000000000000e+00 --4.0000000000000000e+00 4.0000000000000000e+00 -ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 -2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 -3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 -ITEM: TIMESTEP -1 -ITEM: NUMBER OF ATOMS -3 -ITEM: BOX BOUNDS pp pp pp --4.0000000000000000e+00 4.0000000000000000e+00 --4.0000000000000000e+00 4.0000000000000000e+00 --4.0000000000000000e+00 4.0000000000000000e+00 -ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 -2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 -3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 diff --git a/examples/meam/msmeam/test.log b/examples/meam/msmeam/test.log deleted file mode 100644 index e1de5b3934..0000000000 --- a/examples/meam/msmeam/test.log +++ /dev/null @@ -1,123 +0,0 @@ -# Test of MEAM potential for HGa - -# ------------------------ INITIALIZATION ---------------------------- -units metal -dimension 3 -boundary p p p -atom_style atomic -variable latparam equal 4.646 -variable ncell equal 3 - -# ----------------------- ATOM DEFINITION ---------------------------- -region box block -4 4 -4 4 -4 4 -create_box 2 box -Created orthogonal box = (-4 -4 -4) to (4 4 4) - 1 by 1 by 1 MPI processor grid - -# - -include potential.mod -# NOTE: This script can be modified for different pair styles -# See in.elastic for more info. - -variable Pu string H -print "potential chosen ${Pu}" -potential chosen H -# Choose potential -pair_style meam ms # the `ms` flag turns on MS-MEAM -print "we just executed" -we just executed - -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 -Reading MEAM library file library.MSmeam with DATE: 2018-09-22 -# Setup neighbor style -neighbor 1.0 nsq -neigh_modify once no every 1 delay 0 check yes - -# Setup minimization style -variable dmax equal 1.0e-2 -min_style cg -min_modify dmax ${dmax} line quadratic -min_modify dmax 0.01 line quadratic -compute eng all pe/atom -compute eatoms all reduce sum c_eng - -# Setup output -thermo 100 -thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms -thermo_modify norm yes -create_atoms 1 single 0 0 0 units box -Created 1 atoms - using box units in orthogonal box = (-4 -4 -4) to (4 4 4) - create_atoms CPU = 0.000 seconds -create_atoms 2 single 2.2 0 0 units box -Created 1 atoms - using box units in orthogonal box = (-4 -4 -4) to (4 4 4) - create_atoms CPU = 0.000 seconds -create_atoms 2 single 0.3 2.3 0 units box -Created 1 atoms - using box units in orthogonal box = (-4 -4 -4) to (4 4 4) - create_atoms CPU = 0.000 seconds -# ---------- Define Settings --------------------- -variable teng equal "c_eatoms" -compute pot_energy all pe/atom -compute stress all stress/atom NULL -dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) -Neighbor list info ... - update: every = 1 steps, delay = 0 steps, check = yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.9 - ghost atom cutoff = 6.9 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair meam, perpetual - attributes: full, newton on - pair build: full/nsq - stencil: none - bin: none - (2) pair meam, perpetual, half/full from (1) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none -Per MPI rank memory allocation (min/avg/max) = 10.69 | 10.69 | 10.69 Mbytes - Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms - 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 - 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 -Loop time of 0.000110387 on 1 procs for 1 steps with 3 atoms - -Performance: 782.701 ns/day, 0.031 hours/ns, 9059.038 timesteps/s, 27.177 katom-step/s -56.2% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.6411e-05 | 2.6411e-05 | 2.6411e-05 | 0.0 | 23.93 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 4.455e-06 | 4.455e-06 | 4.455e-06 | 0.0 | 4.04 -Output | 7.4411e-05 | 7.4411e-05 | 7.4411e-05 | 0.0 | 67.41 -Modify | 7.54e-07 | 7.54e-07 | 7.54e-07 | 0.0 | 0.68 -Other | | 4.356e-06 | | | 3.95 - -Nlocal: 3 ave 3 max 3 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 78 ave 78 max 78 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 7 ave 7 max 7 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 14 ave 14 max 14 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 14 -Ave neighs/atom = 4.6666667 -Neighbor list builds = 0 -Dangerous builds = 0 -write_data test.data -System init for write_data ... - -print "All done!" -All done! -Total wall time: 0:00:00 diff --git a/potentials/HGa.msmeam b/potentials/HGa.msmeam new file mode 100644 index 0000000000..9f01501c16 --- /dev/null +++ b/potentials/HGa.msmeam @@ -0,0 +1,30 @@ +bkgd_dyn = 1 +emb_lin_neg = 1 +augt1=0 +ialloy=1 +rc = 5.9 +#H +attrac(1,1)=0.460 +repuls(1,1)=0.460 +Cmin(1,1,1)=1.3 # PuMS +Cmax(1,1,1)= 2.80 +nn2(1,1)=1 +#Ga +rho0(2) = 0.6 +attrac(2,2)=0.097 +repuls(2,2)=0.097 +nn2(2,2)=1 +#HGa +attrac(1,2)=0.300 +repuls(1,2)=0.300 +lattce(1,2)=l12 +re(1,2)=3.19 +delta(1,2)=-0.48 +alpha(1,2)=6.6 +Cmin(1,1,2)=2.0 +Cmin(2,1,2)= 2.0 +Cmin(1,2,1)=2.0 +Cmin(2,2,1) = 1.4 +Cmin(1,2,2) = 1.4 +Cmin(1,1,2) = 1.4 +nn2(1,2)=1 diff --git a/potentials/library.msmeam b/potentials/library.msmeam new file mode 100644 index 0000000000..9937eaee08 --- /dev/null +++ b/potentials/library.msmeam @@ -0,0 +1,14 @@ +# DATE: 2018-09-22 UNITS: metal CONTRIBUTOR: Steve Valone, smv@lanl.gov CITATION: Baskes, PRB 1992; smv, sr, mib, JNM 2010 +# ms-meam data format May 2010 +# elt lat z ielement atwt +# alpha b0 b1 b2 b3 b1m b2m b3m alat esub asub +# - t0 t1 t2 t3 t1m t2m t3m rozero ibar +# NOTE: leading character cannot be a space + +'H' 'dim' 1.0 1 1.0079 +2.960 2.960 3.0 1.0 1.0 1.0 3.0 1.0 0.741 2.235 2.50 +1.0 0.44721 0.0 0.00 0.0 0.31623 0 6.70 0 + +'Ga4' 'fcc' 12.0 31 69.723 +4.42 4.80 3.10 6.00 0.00 0.0 0.0 0.5 4.247 2.897 0.97 +1.0 1.649 1.435 0.00 0.0 0.0 2.0 0.70 0 diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index dbbf887bc2..5e7ffdec20 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -61,7 +61,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT if (elti >= 0) { scaleii = d_scale(type[i],type[i]); d_rho1[i] = 0.0; - if (msmeamflag){ + if (msmeamflag) { d_rho2[i] = -1.0 / 3.0 * (d_arho2b[i] * d_arho2b[i] - d_arho2mb[i] * d_arho2mb[i]); } else{ @@ -69,7 +69,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } d_rho3[i] = 0.0; for (int m = 0; m < 3; m++) { - if (msmeamflag){ + if (msmeamflag) { d_rho1[i] = d_rho1[i] + d_arho1(i, m) * d_arho1(i, m) - d_arho1m(i, m) * d_arho1m(i, m); d_rho3[i] = d_rho3[i] - 3.0 / 5.0 * (d_arho3b(i, m) * d_arho3b(i, m) @@ -80,7 +80,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } } for (int m = 0; m < 6; m++){ - if (msmeamflag){ + if (msmeamflag) { d_rho2[i] = d_rho2[i] + v2D[m] * (d_arho2(i, m) * d_arho2(i, m) - d_arho2m(i, m) * d_arho2m(i, m)); } else{ @@ -88,14 +88,14 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT } } for (int m = 0; m < 10; m++) - if (msmeamflag){ + if (msmeamflag) { d_rho3[i] = d_rho3[i] + v3D[m] * (d_arho3(i, m) * d_arho3(i, m) - d_arho3m(i, m) * d_arho3m(i, m)); } else{ d_rho3[i] += v3D[m] * d_arho3(i,m) * d_arho3(i,m); } - if (msmeamflag){ + if (msmeamflag) { // with msmeam all t weights are already accounted for in rho d_gamma[i] = d_rho1[i] + d_rho2[i] + d_rho3[i]; } else{ diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index 82ab68396a..a1a184f0a2 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -43,16 +43,16 @@ void MEAMKokkos::operator()(TagMEAMZero, const int &i) const { d_rho0[i] = 0.0; d_arho2b[i] = 0.0; d_arho1(i,0) = d_arho1(i,1) = d_arho1(i,2) = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag) { d_arho2mb[i] = 0.0; d_arho1m(i,0) = d_arho1m(i,1) = d_arho1m(i,2) = 0.0; } - for (int j = 0; j < 6; j++){ + for (int j = 0; j < 6; j++) { d_arho2(i,j) = 0.0; if (msmeamflag) d_arho2m(i,j) = 0.0; } - for (int j = 0; j < 10; j++){ + for (int j = 0; j < 10; j++) { d_arho3(i,j) = 0.0; if (msmeamflag) d_arho3m(i,j) = 0.0; @@ -540,7 +540,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty double rhoa3i = ro0i * MathSpecialKokkos::fm_exp(-beta3_meam[elti] * ai) * sij; // msmeam double rhoa1mj, rhoa2mj, rhoa3mj, rhoa1mi, rhoa2mi, rhoa3mi; - if (msmeamflag){ + if (msmeamflag) { rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * sij; rhoa2mj = ro0j * t2m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta2m_meam[eltj] * aj) * sij; rhoa3mj = ro0j * t3m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta3m_meam[eltj] * aj) * sij; @@ -585,7 +585,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty const double A2i = rhoa2i / rij2; const double A3i = rhoa3i / (rij2 * rij); double A1mj, A2mj, A3mj, A1mi, A2mi, A3mi; - if (msmeamflag){ + if (msmeamflag) { a_arho2mb[i] += rhoa2mj; a_arho2mb[j] += rhoa2mi; A1mj = rhoa1mj / rij; @@ -602,7 +602,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty a_arho1(j,m) += -A1i * delij[m]; a_arho3b(i,m) += rhoa3j * delij[m] / rij; a_arho3b(j,m) += -rhoa3i * delij[m] / rij; - if (msmeamflag){ + if (msmeamflag) { a_arho1m(i,m) += A1mj * delij[m]; a_arho1m(j,m) += -A1mi * delij[m]; a_arho3mb(i,m) += rhoa3mj * delij[m] / rij; @@ -611,7 +611,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty for (int n = m; n < 3; n++) { a_arho2(i,nv2) += A2j * delij[m] * delij[n]; a_arho2(j,nv2) += A2i * delij[m] * delij[n]; - if (msmeamflag){ + if (msmeamflag) { a_arho2m(i,nv2) += A2mj * delij[m] * delij[n]; a_arho2m(j,nv2) += A2mi * delij[m] * delij[n]; } @@ -619,7 +619,7 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty for (int p = n; p < 3; p++) { a_arho3(i,nv3) += A3j * delij[m] * delij[n] * delij[p]; a_arho3(j,nv3) += -A3i * delij[m] * delij[n] * delij[p]; - if (msmeamflag){ + if (msmeamflag) { a_arho3m(i,nv3) += A3mj * delij[m] * delij[n] * delij[p]; a_arho3m(j,nv3) += -A3mi * delij[m] * delij[n] * delij[p]; } diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index 00992eadec..5c4244e99b 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -208,7 +208,7 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::operator()(TagMEAMForce::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template modify(); meam_inst_kk->k_t_ave.template modify(); meam_inst_kk->k_tsq_ave.template modify(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.template modify(); meam_inst_kk->k_arho1m.template modify(); meam_inst_kk->k_arho2m.template modify(); @@ -185,7 +185,7 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template sync(); meam_inst_kk->k_t_ave.template sync(); meam_inst_kk->k_tsq_ave.template sync(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.template sync(); meam_inst_kk->k_arho1m.template sync(); meam_inst_kk->k_arho2m.template sync(); @@ -215,7 +215,7 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template modify(); meam_inst_kk->k_t_ave.template modify(); meam_inst_kk->k_tsq_ave.template modify(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.template modify(); meam_inst_kk->k_arho1m.template modify(); meam_inst_kk->k_arho2m.template modify(); @@ -241,7 +241,7 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) meam_inst_kk->k_arho3b.template sync(); meam_inst_kk->k_t_ave.template sync(); meam_inst_kk->k_tsq_ave.template sync(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.template sync(); meam_inst_kk->k_arho1m.template sync(); meam_inst_kk->k_arho2m.template sync(); @@ -383,7 +383,7 @@ void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const in v_buf[m++] = d_tsq_ave(j,0); v_buf[m++] = d_tsq_ave(j,1); v_buf[m++] = d_tsq_ave(j,2); - if (msmeamflag){ + if (msmeamflag) { v_buf[m++] = d_arho2mb[j]; v_buf[m++] = d_arho1m(j,0); v_buf[m++] = d_arho1m(j,1); @@ -448,7 +448,7 @@ void PairMEAMKokkos::operator()(TagPairMEAMUnpackForwardComm, const d_tsq_ave(i+first,0) = v_buf[m++]; d_tsq_ave(i+first,1) = v_buf[m++]; d_tsq_ave(i+first,2) = v_buf[m++]; - if (msmeamflag){ + if (msmeamflag) { d_arho2mb[i+first] = v_buf[m++]; d_arho1m(i+first,0) = v_buf[m++]; d_arho1m(i+first,1) = v_buf[m++]; @@ -488,7 +488,7 @@ int PairMEAMKokkos::pack_forward_comm(int n, int *list, double *buf, meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.sync_host(); meam_inst_kk->k_arho1m.sync_host(); meam_inst_kk->k_arho2m.sync_host(); @@ -528,7 +528,7 @@ int PairMEAMKokkos::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst_kk->h_tsq_ave(j,0); buf[m++] = meam_inst_kk->h_tsq_ave(j,1); buf[m++] = meam_inst_kk->h_tsq_ave(j,2); - if (msmeamflag){ + if (msmeamflag) { buf[m++] = meam_inst_kk->h_arho2mb[j]; buf[m++] = meam_inst_kk->h_arho1m(j,0); buf[m++] = meam_inst_kk->h_arho1m(j,1); @@ -570,7 +570,7 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.sync_host(); meam_inst_kk->k_arho1m.sync_host(); meam_inst_kk->k_arho2m.sync_host(); @@ -610,7 +610,7 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b meam_inst_kk->h_tsq_ave(i,0) = buf[m++]; meam_inst_kk->h_tsq_ave(i,1) = buf[m++]; meam_inst_kk->h_tsq_ave(i,2) = buf[m++]; - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->h_arho2mb[i] = buf[m++]; meam_inst_kk->h_arho1m(i,0) = buf[m++]; meam_inst_kk->h_arho1m(i,1) = buf[m++]; @@ -644,7 +644,7 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b meam_inst_kk->k_arho3b.modify_host(); meam_inst_kk->k_t_ave.modify_host(); meam_inst_kk->k_tsq_ave.modify_host(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.modify_host(); meam_inst_kk->k_arho1m.modify_host(); meam_inst_kk->k_arho2m.modify_host(); @@ -694,7 +694,7 @@ void PairMEAMKokkos::operator()(TagPairMEAMPackReverseComm, const in v_buf[m++] = d_tsq_ave(i+first,0); v_buf[m++] = d_tsq_ave(i+first,1); v_buf[m++] = d_tsq_ave(i+first,2); - if (msmeamflag){ + if (msmeamflag) { v_buf[m++] = d_arho2mb[i+first]; v_buf[m++] = d_arho1m(i+first,0); v_buf[m++] = d_arho1m(i+first,1); @@ -725,7 +725,7 @@ int PairMEAMKokkos::pack_reverse_comm(int n, int first, double *buf) meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.sync_host(); meam_inst_kk->k_arho1m.sync_host(); meam_inst_kk->k_arho2m.sync_host(); @@ -757,7 +757,7 @@ int PairMEAMKokkos::pack_reverse_comm(int n, int first, double *buf) buf[m++] = meam_inst_kk->h_tsq_ave(i,0); buf[m++] = meam_inst_kk->h_tsq_ave(i,1); buf[m++] = meam_inst_kk->h_tsq_ave(i,2); - if (msmeamflag){ + if (msmeamflag) { buf[m++] = meam_inst_kk->h_arho2mb[i]; buf[m++] = meam_inst_kk->h_arho1m(i,0); buf[m++] = meam_inst_kk->h_arho1m(i,1); @@ -819,7 +819,7 @@ void PairMEAMKokkos::operator()(TagPairMEAMUnpackReverseComm, const d_tsq_ave(j,0) += v_buf[m++]; d_tsq_ave(j,1) += v_buf[m++]; d_tsq_ave(j,2) += v_buf[m++]; - if (msmeamflag){ + if (msmeamflag) { d_arho2mb[j] += v_buf[m++]; d_arho1m(j,0) += v_buf[m++]; d_arho1m(j,1) += v_buf[m++]; @@ -850,7 +850,7 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->k_arho3b.sync_host(); meam_inst_kk->k_t_ave.sync_host(); meam_inst_kk->k_tsq_ave.sync_host(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.sync_host(); meam_inst_kk->k_arho1m.sync_host(); meam_inst_kk->k_arho2m.sync_host(); @@ -882,7 +882,7 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->h_tsq_ave(j,0) += buf[m++]; meam_inst_kk->h_tsq_ave(j,1) += buf[m++]; meam_inst_kk->h_tsq_ave(j,2) += buf[m++]; - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->h_arho2mb[j] += buf[m++]; meam_inst_kk->h_arho1m(j,0) += buf[m++]; meam_inst_kk->h_arho1m(j,1) += buf[m++]; @@ -908,7 +908,7 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b meam_inst_kk->k_arho3b.modify_host(); meam_inst_kk->k_t_ave.modify_host(); meam_inst_kk->k_tsq_ave.modify_host(); - if (msmeamflag){ + if (msmeamflag) { meam_inst_kk->k_arho2mb.modify_host(); meam_inst_kk->k_arho1m.modify_host(); meam_inst_kk->k_arho2m.modify_host(); diff --git a/src/MEAM/meam_dens_final.cpp b/src/MEAM/meam_dens_final.cpp index de23009332..ab0ac8c53f 100644 --- a/src/MEAM/meam_dens_final.cpp +++ b/src/MEAM/meam_dens_final.cpp @@ -27,7 +27,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ // Complete the calculation of density - if (this->msmeamflag){ + if (this->msmeamflag) { for (i = 0; i < nlocal; i++) { elti = fmap[type[i]]; if (elti >= 0) { @@ -131,7 +131,7 @@ MEAM::meam_dens_final(int nlocal, int eflag_either, int eflag_global, int eflag_ } } } - } else{ + } else { for (i = 0; i < nlocal; i++) { elti = fmap[type[i]]; if (elti >= 0) { diff --git a/src/MEAM/meam_dens_init.cpp b/src/MEAM/meam_dens_init.cpp index 2e67d7277f..00ad276ad7 100644 --- a/src/MEAM/meam_dens_init.cpp +++ b/src/MEAM/meam_dens_init.cpp @@ -46,7 +46,7 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memory->destroy(t_ave); memory->destroy(tsq_ave); // msmeam params - if (this->msmeamflag){ + if (this->msmeamflag) { memory->destroy(arho1m); memory->destroy(arho2m); memory->destroy(arho3m); @@ -74,7 +74,7 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) memory->create(t_ave, nmax, 3, "pair:t_ave"); memory->create(tsq_ave, nmax, 3, "pair:tsq_ave"); // msmeam params - if (this->msmeamflag){ + if (this->msmeamflag) { memory->create(arho1m, nmax, 3, "pair:arho1m"); memory->create(arho2m, nmax, 6, "pair:arho2m"); memory->create(arho3m, nmax, 10, "pair:arho3m"); @@ -99,24 +99,24 @@ MEAM::meam_dens_setup(int atom_nmax, int nall, int n_neigh) rho0[i] = 0.0; arho2b[i] = 0.0; arho1[i][0] = arho1[i][1] = arho1[i][2] = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag) { arho2mb[i] = 0.0; arho1m[i][0] = arho1m[i][1] = arho1m[i][2] = 0.0; } - for (j = 0; j < 6; j++){ + for (j = 0; j < 6; j++) { arho2[i][j] = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag) { arho2m[i][j] = 0.0; } } - for (j = 0; j < 10; j++){ + for (j = 0; j < 10; j++) { arho3[i][j] = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag) { arho3m[i][j] = 0.0; } } arho3b[i][0] = arho3b[i][1] = arho3b[i][2] = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag) { arho3mb[i][0] = arho3mb[i][1] = arho3mb[i][2] = 0.0; } t_ave[i][0] = t_ave[i][1] = t_ave[i][2] = 0.0; @@ -394,7 +394,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn A3i = rhoa3i / (rij2 * rij); nv2 = 0; nv3 = 0; - if (this->msmeamflag){ + if (this->msmeamflag) { arho2mb[i] = arho2mb[i] + rhoa2mj; arho2mb[j] = arho2mb[j] + rhoa2mi; A1mj = rhoa1mj/rij; @@ -409,7 +409,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn arho1[j][m] = arho1[j][m] - A1i * delij[m]; arho3b[i][m] = arho3b[i][m] + rhoa3j * delij[m] / rij; arho3b[j][m] = arho3b[j][m] - rhoa3i * delij[m] / rij; - if (this->msmeamflag){ + if (this->msmeamflag) { arho1m[i][m] = arho1m[i][m] + A1mj*delij[m]; arho1m[j][m] = arho1m[j][m] - A1mi*delij[m]; arho3mb[i][m] = arho3mb[i][m] + rhoa3mj*delij[m] / rij; @@ -418,7 +418,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn for (n = m; n < 3; n++) { arho2[i][nv2] = arho2[i][nv2] + A2j * delij[m] * delij[n]; arho2[j][nv2] = arho2[j][nv2] + A2i * delij[m] * delij[n]; - if (this->msmeamflag){ + if (this->msmeamflag) { arho2m[i][nv2] = arho2m[i][nv2] + A2mj*delij[m] * delij[n]; arho2m[j][nv2] = arho2m[j][nv2] + A2mi*delij[m] * delij[n]; } @@ -426,7 +426,7 @@ MEAM::calc_rho1(int i, int /*ntype*/, int* type, int* fmap, double** x, int numn for (p = n; p < 3; p++) { arho3[i][nv3] = arho3[i][nv3] + A3j * delij[m] * delij[n] * delij[p]; arho3[j][nv3] = arho3[j][nv3] - A3i * delij[m] * delij[n] * delij[p]; - if (this->msmeamflag){ + if (this->msmeamflag) { arho3m[i][nv3] = arho3m[i][nv3] + A3mj*delij[m]*delij[n]*delij[p]; arho3m[j][nv3] = arho3m[j][nv3] - A3mi*delij[m]*delij[n]*delij[p]; } diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index e483676118..4bc7380898 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -138,7 +138,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int rhoa3i = ro0i * MathSpecial::fm_exp(-this->beta3_meam[elti] * ai); drhoa3i = -this->beta3_meam[elti] * invrei * rhoa3i; - if (this->msmeamflag){ + if (this->msmeamflag) { rhoa1mi = ro0i * MathSpecial::fm_exp(-this->beta1m_meam[elti] * ai) * t1m_meam[elti]; drhoa1mi = -this->beta1m_meam[elti] * invrei * rhoa1mi; rhoa2mi = ro0i * MathSpecial::fm_exp(-this->beta2m_meam[elti] * ai) * t2m_meam[elti]; @@ -471,7 +471,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int get_shpfcn(this->lattce_meam[elti][elti], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpi); get_shpfcn(this->lattce_meam[eltj][eltj], this->stheta_meam[elti][elti], this->ctheta_meam[elti][elti], shpj); - if (this->msmeamflag){ + if (this->msmeamflag) { drhodr1 = dgamma1[i] * drho0dr1 + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * (drho1dr1 - drho1mdr1) + dt2dr1 * rho2[i] + t2i * (drho2dr1 - drho2mdr1) + @@ -492,7 +492,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int t2j * (drho2drm2[m] - drho2mdrm2[m]) + t3j * (drho3drm2[m] - drho3mdrm2[m]) ); } - } else{ + } else { drhodr1 = dgamma1[i] * drho0dr1 + dgamma2[i] * (dt1dr1 * rho1[i] + t1i * drho1dr1 + dt2dr1 * rho2[i] + t2i * drho2dr1 + @@ -586,7 +586,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt3ds2 = aj * (t3mi - t3j); } - if (this->msmeamflag){ + if (this->msmeamflag) { drhods1 = dgamma1[i] * drho0ds1 + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * (drho1ds1 - drho1mds1) + dt2ds1 * rho2[i] + t2i * (drho2ds1 - drho2mds1) + @@ -598,7 +598,7 @@ MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, int dt3ds2 * rho3[j] + t3j * (drho3ds2 - drho3mds2)) - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); } - else{ + else { drhods1 = dgamma1[i] * drho0ds1 + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * drho1ds1 + dt2ds1 * rho2[i] + t2i * drho2ds1 + dt3ds1 * rho3[i] + t3i * drho3ds1) - diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index f85d9d710c..5290647b18 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -96,7 +96,7 @@ MEAM::~MEAM() memory->destroy(this->fcpair); // msmeam - if (this->msmeamflag){ + if (this->msmeamflag){ memory->destroy(this->arho1m); memory->destroy(this->arho2m); memory->destroy(this->arho3m); diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index d304fd74d4..911b8930df 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -348,11 +348,11 @@ double MEAM::phi_meam(double r, int a, int b) Z12 = get_Zij(this->lattce_meam[a][b]); // this function has extra args for msmeam - if (this->msmeamflag){ + if (this->msmeamflag) { get_densref(r, a, b, &rho01, &rho11, &rho21, &rho31, &rho02, &rho12, &rho22, &rho32, &rho1m1, &rho2m1, &rho3m1, &rho1m2, &rho2m2, &rho3m2); - } else{ + } else { get_densref(r, a, b, &rho01, &rho11, &rho21, &rho31, &rho02, &rho12, &rho22, &rho32, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); @@ -385,7 +385,7 @@ double MEAM::phi_meam(double r, int a, int b) this->t3_meam[a], this->t1_meam[b], this->t2_meam[b], this->t3_meam[b], r, a, b, this->lattce_meam[a][b]); // with msmeam call twice with different sets of variables - if (this->msmeamflag){ + if (this->msmeamflag) { get_tavref(&t1m1av, &t2m1av, &t3m1av, &t1m2av, &t2m2av, &t3m2av, this->t1m_meam[a], this->t2m_meam[a], this->t3m_meam[a], this->t1m_meam[b], this->t2m_meam[b], this->t3m_meam[b], r, a, b, this->lattce_meam[a][b]); @@ -437,7 +437,7 @@ double MEAM::phi_meam(double r, int a, int b) rho0_2 = this->rho0_meam[b] * Z2 * G2; } - if (this->msmeamflag){ + if (this->msmeamflag) { // no additional use of t's here; all included in definitions of rho's for msmeam Gam1 = rho11 + rho21 + rho31 - (rho1m1 + rho2m1 + rho3m1); if (rho01 < 1.0e-14) @@ -450,7 +450,7 @@ double MEAM::phi_meam(double r, int a, int b) else Gam2 = Gam2 / (rho02 * rho02); - } else{ + } else { Gam1 = (t11av * rho11 + t21av * rho21 + t31av * rho31); if (rho01 < 1.0e-14) Gam1 = 0.0; @@ -708,7 +708,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa01 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta0_meam[a] * a1); - if (this->msmeamflag){ + if (this->msmeamflag) { // the rho variables are multiplied by t here since ialloy not needed in msmeam rhoa11 = this->rho0_meam[a] * this->t1_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); rhoa21 = this->rho0_meam[a] * this->t2_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); @@ -724,8 +724,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou rhoa1m2 = this->rho0_meam[b] * this->t1m_meam[b] * MathSpecial::fm_exp(-this->beta1m_meam[b] * a2); rhoa2m2 = this->rho0_meam[b] * this->t2m_meam[b] * MathSpecial::fm_exp(-this->beta2m_meam[b] * a2); rhoa3m2 = this->rho0_meam[b] * this->t3m_meam[b] * MathSpecial::fm_exp(-this->beta3m_meam[b] * a2); - } - else{ + } else { rhoa11 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta1_meam[a] * a1); rhoa21 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta2_meam[a] * a1); rhoa31 = this->rho0_meam[a] * MathSpecial::fm_exp(-this->beta3_meam[a] * a1); @@ -745,7 +744,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho12 = 0.0; *rho22 = 0.0; *rho32 = 0.0; - if (this->msmeamflag){ + if (this->msmeamflag) { *rho1m1 = 0.0; *rho2m1 = 0.0; *rho3m1 = 0.0; @@ -775,7 +774,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho02 = 4.0 * rhoa01; *rho31 = 32.0 / 9.0 * rhoa32 * rhoa32; *rho32 = 32.0 / 9.0 * rhoa31 * rhoa31; - if (this->msmeamflag){ + if (this->msmeamflag) { *rho3m1 = 32.0 / 9.0 * rhoa3m2 * rhoa3m2; *rho3m2 = 32.0 / 9.0 * rhoa3m1 * rhoa3m1; } @@ -785,7 +784,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho02 = 12 * rhoa01; *rho31 = 1.0 / 3.0 * rhoa32 * rhoa32; *rho32 = 1.0 / 3.0 * rhoa31 * rhoa31; - if (this->msmeamflag){ + if (this->msmeamflag) { *rho3m1 = 1.0 / 3.0 * rhoa3m2 * rhoa3m2; *rho3m2 = 1.0 / 3.0 * rhoa3m1 * rhoa3m1; } @@ -800,7 +799,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho22 = s[1] * rhoa21 * rhoa21; *rho31 = s[2] * rhoa32 * rhoa32; *rho32 = s[2] * rhoa31 * rhoa31; - if (this->msmeamflag){ + if (this->msmeamflag) { *rho1m1 = s[0] * rhoa1m2 * rhoa1m2; *rho1m2 = s[0] * rhoa1m1 * rhoa1m1; *rho2m1 = s[1] * rhoa2m2 * rhoa2m2; @@ -818,7 +817,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho22 = rhoa22; *rho31 = rhoa31; *rho32 = rhoa32; - if (this->msmeamflag){ + if (this->msmeamflag) { *rho1m1 = rhoa1m1; *rho1m2 = rhoa1m2; *rho2m1 = rhoa2m1; @@ -837,7 +836,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho21 = *rho21 / denom * *rho01; } else *rho21 = 8. / 3. * (rhoa21 - rhoa22) * (rhoa21 - rhoa22); - if (this->msmeamflag){ + if (this->msmeamflag) { *rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2); } break; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index db31fd264c..62c0278da3 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -196,10 +196,10 @@ void PairMEAM::settings(int narg, char **arg) // set comm size needed by this Pair - if (msmeamflag){ + if (msmeamflag) { comm_forward = 38+23; // plus 23 for msmeam comm_reverse = 30+23; // plus 23 for msmeam - } else{ + } else { comm_forward = 38; comm_reverse = 30; } @@ -449,7 +449,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) b1[index] = values.next_double(); b2[index] = values.next_double(); b3[index] = values.next_double(); - if (msmeamflag){ + if (msmeamflag) { b1m[index] = values.next_double(); b2m[index] = values.next_double(); b3m[index] = values.next_double(); @@ -461,7 +461,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) t1[index] = values.next_double(); t2[index] = values.next_double(); t3[index] = values.next_double(); - if (msmeamflag){ + if (msmeamflag) { t1m[index] = values.next_double(); t2m[index] = values.next_double(); t3m[index] = values.next_double(); @@ -524,13 +524,13 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) // pass element parameters to MEAM package - if (msmeamflag){ + if (msmeamflag) { meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), t2.data(), t3.data(), rozero.data(), ibar.data(), b1m.data(), b2m.data(), b3m.data(), t1m.data(), t2m.data(), t3m.data()); - } else{ + } else { meam_inst->meam_setup_global(nlibelements, lat.data(), ielement.data(), atwt.data(), alpha.data(), b0.data(), b1.data(), b2.data(), b3.data(), alat.data(), esub.data(), asub.data(), t0.data(), t1.data(), @@ -659,7 +659,7 @@ int PairMEAM::pack_forward_comm(int n, int *list, double *buf, buf[m++] = meam_inst->tsq_ave[j][0]; buf[m++] = meam_inst->tsq_ave[j][1]; buf[m++] = meam_inst->tsq_ave[j][2]; - if (msmeamflag){ + if (msmeamflag) { buf[m++] = meam_inst->arho2mb[j]; buf[m++] = meam_inst->arho1m[j][0]; buf[m++] = meam_inst->arho1m[j][1]; @@ -719,7 +719,7 @@ void PairMEAM::unpack_forward_comm(int n, int first, double *buf) meam_inst->tsq_ave[i][0] = buf[m++]; meam_inst->tsq_ave[i][1] = buf[m++]; meam_inst->tsq_ave[i][2] = buf[m++]; - if (msmeamflag){ + if (msmeamflag) { meam_inst->arho2mb[i] = buf[m++]; meam_inst->arho1m[i][0] = buf[m++]; meam_inst->arho1m[i][1] = buf[m++]; @@ -768,7 +768,7 @@ int PairMEAM::pack_reverse_comm(int n, int first, double *buf) buf[m++] = meam_inst->tsq_ave[i][0]; buf[m++] = meam_inst->tsq_ave[i][1]; buf[m++] = meam_inst->tsq_ave[i][2]; - if (msmeamflag){ + if (msmeamflag) { buf[m++] = meam_inst->arho2mb[i]; buf[m++] = meam_inst->arho1m[i][0]; buf[m++] = meam_inst->arho1m[i][1]; @@ -819,7 +819,7 @@ void PairMEAM::unpack_reverse_comm(int n, int *list, double *buf) meam_inst->tsq_ave[j][0] += buf[m++]; meam_inst->tsq_ave[j][1] += buf[m++]; meam_inst->tsq_ave[j][2] += buf[m++]; - if (msmeamflag){ + if (msmeamflag) { meam_inst->arho2mb[j] += buf[m++]; meam_inst->arho1m[j][0] += buf[m++]; meam_inst->arho1m[j][1] += buf[m++]; From b7f2c3feda4b9ea04ea9e422438e26274a569b09 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 26 Jan 2023 15:09:14 -0500 Subject: [PATCH 34/43] convert "ms" pair style flag for MEAM into meam/ms pair style --- doc/src/Commands_pair.rst | 1 + doc/src/pair_meam.rst | 62 +++++++++++++++++++----------- doc/src/pair_style.rst | 3 +- src/KOKKOS/pair_meam_kokkos.cpp | 1 + src/KOKKOS/pair_meam_kokkos.h | 12 +++--- src/KOKKOS/pair_meam_ms_kokkos.cpp | 32 +++++++++++++++ src/KOKKOS/pair_meam_ms_kokkos.h | 36 +++++++++++++++++ src/MEAM/meam.h | 2 +- src/MEAM/meam_setup_done.cpp | 6 +-- src/MEAM/pair_meam.cpp | 40 +++++++------------ src/MEAM/pair_meam.h | 1 + src/MEAM/pair_meam_ms.cpp | 25 ++++++++++++ src/MEAM/pair_meam_ms.h | 33 ++++++++++++++++ 13 files changed, 195 insertions(+), 59 deletions(-) create mode 100644 src/KOKKOS/pair_meam_ms_kokkos.cpp create mode 100644 src/KOKKOS/pair_meam_ms_kokkos.h create mode 100644 src/MEAM/pair_meam_ms.cpp create mode 100644 src/MEAM/pair_meam_ms.h diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index 59501b4a56..91d6b6290f 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -200,6 +200,7 @@ OPT. * :doc:`mdpd ` * :doc:`mdpd/rhosum ` * :doc:`meam (k) ` + * :doc:`meam/ms (k) ` * :doc:`meam/spline (o) ` * :doc:`meam/sw/spline ` * :doc:`mesocnt ` diff --git a/doc/src/pair_meam.rst b/doc/src/pair_meam.rst index 194afeb1ff..1963332e8a 100644 --- a/doc/src/pair_meam.rst +++ b/doc/src/pair_meam.rst @@ -1,19 +1,26 @@ .. index:: pair_style meam .. index:: pair_style meam/kk +.. index:: pair_style meam/ms +.. index:: pair_style meam/ms/kk pair_style meam command ========================= Accelerator Variants: *meam/kk* +pair_style meam/ms command +========================== + +Accelerator Variants: *meam/ms/kk* + Syntax """""" .. code-block:: LAMMPS - pair_style meam [ms] + pair_style style -* ms = use multi-state MEAM (optional) +* style = *meam* or *meam/ms* Examples """""""" @@ -24,6 +31,9 @@ Examples pair_coeff * * ../potentials/library.meam Si ../potentials/si.meam Si pair_coeff * * ../potentials/library.meam Ni Al NULL Ni Al Ni Ni + pair_style meam/ms + pair_coeff * * ../potentials/library.msmeam H Ga ../potentials/HGa.meam H Ga + Description """"""""""" @@ -33,16 +43,23 @@ Description as of November 2010; see description below of the mixture_ref_t parameter -Pair style *meam* computes non-bonded interactions for a variety of materials -using the modified embedded-atom method (MEAM) -:ref:`(Baskes) `. Conceptually, it is an extension to the original -:doc:`EAM method ` which adds angular forces. It is -thus suitable for modeling metals and alloys with fcc, bcc, hcp and -diamond cubic structures, as well as materials with covalent interactions -like silicon and carbon. This *meam* pair style is a translation of the -original Fortran version to C++. It is functionally equivalent but more -efficient and has additional features. The Fortran version of the *meam* -pair style has been removed from LAMMPS after the 12 December 2018 release. +Pair style *meam* computes non-bonded interactions for a variety of +materials using the modified embedded-atom method (MEAM) :ref:`(Baskes) +`. Conceptually, it is an extension to the original :doc:`EAM +method ` which adds angular forces. It is thus suitable for +modeling metals and alloys with fcc, bcc, hcp and diamond cubic +structures, as well as materials with covalent interactions like silicon +and carbon. + +The *meam* pair style is a translation of the original Fortran version +to C++. It is functionally equivalent but more efficient and has +additional features. The Fortran version of the *meam* pair style has +been removed from LAMMPS after the 12 December 2018 release. + +Pair style *meam/ms* uses the multi-state MEAM (MS-MEAM) method +according to :ref:`(Baskes2) `, which is an extension to MEAM. +This pair style is mostly equivalent to *meam* and is use differs only +where noted in the documentation below. In the MEAM formulation, the total energy E of a system of atoms is given by: @@ -353,13 +370,15 @@ Most published MEAM parameter sets use the default values *attrac* = *repulse* = Setting *repuls* = *attrac* = *delta* corresponds to the form used in several recent published MEAM parameter sets, such as :ref:`(Valone) ` -The optional *ms* flag activates multi-state MEAM (MS-MEAM) according to :ref:`(Baskes2) `. -This requires 6 extra parameters in the MEAM library file, resulting in 25 parameters ordered like: +Then using *meam/ms* pair style the multi-state MEAM (MS-MEAM) method is +activated. This requires 6 extra parameters in the MEAM library file, +resulting in 25 parameters ordered that are ordered like this: elt, lat, z, ielement, atwt, alpha, b0, b1, b2, b3, b1m, b2m, b3m, alat, esub, asub, t0, t1, t2, t3, t1m, t2m, t3m, rozero, ibar The 6 extra MS-MEAM parameters are *b1m, b2m, b3m, t1m, t2m, t3m*. +In the LAMMPS ``potentials`` folder, compatible files have an ".msmeam" extension. ---------- @@ -403,16 +422,15 @@ This pair style can only be used via the *pair* keyword of the Restrictions """""""""""" -The *meam* style is provided in the MEAM package. It is -only enabled if LAMMPS was built with that package. +The *meam* and *meam/ms* pair styles are provided in the MEAM +package. They are only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. -The maximum number of elements, that can be read from the MEAM -library file, is determined at compile time. The default is 5. -If you need support for more elements, you have to change the -define for the constant 'maxelt' at the beginning of the file -src/MEAM/meam.h and update/recompile LAMMPS. There is no -limit on the number of atoms types. +The maximum number of elements, that can be read from the MEAM library +file, is determined at compile time. The default is 5. If you need +support for more elements, you have to change the the constant 'maxelt' +at the beginning of the file ``src/MEAM/meam.h`` and update/recompile +LAMMPS. There is no limit on the number of atoms types. Related commands """""""""""""""" diff --git a/doc/src/pair_style.rst b/doc/src/pair_style.rst index 3f91bfc0b4..cc471ecf6d 100644 --- a/doc/src/pair_style.rst +++ b/doc/src/pair_style.rst @@ -277,7 +277,8 @@ accelerated styles exist. * :doc:`lubricateU/poly ` - hydrodynamic lubrication forces for Fast Lubrication with polydispersity * :doc:`mdpd ` - mDPD particle interactions * :doc:`mdpd/rhosum ` - mDPD particle interactions for mass density -* :doc:`meam ` - modified embedded atom method (MEAM) in C +* :doc:`meam ` - modified embedded atom method (MEAM) +* :doc:`meam/ms ` - multi-state modified embedded atom method (MS-MEAM) * :doc:`meam/spline ` - splined version of MEAM * :doc:`meam/sw/spline ` - splined version of MEAM with a Stillinger-Weber term * :doc:`mesocnt ` - mesoscopic vdW potential for (carbon) nanotubes diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index 7f88645f1d..c2b03c2054 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -51,6 +51,7 @@ PairMEAMKokkos::PairMEAMKokkos(LAMMPS *lmp) : PairMEAM(lmp) delete meam_inst; meam_inst_kk = new MEAMKokkos(memory); meam_inst = meam_inst_kk; + myname = "meam/kk"; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_meam_kokkos.h b/src/KOKKOS/pair_meam_kokkos.h index f052826b59..0d0d7667f3 100644 --- a/src/KOKKOS/pair_meam_kokkos.h +++ b/src/KOKKOS/pair_meam_kokkos.h @@ -13,12 +13,12 @@ #ifdef PAIR_CLASS // clang-format off -PairStyle(meam/c/kk,PairMEAMKokkos) -PairStyle(meam/c/kk/device,PairMEAMKokkos) -PairStyle(meam/c/kk/host,PairMEAMKokkos) -PairStyle(meam/kk,PairMEAMKokkos) -PairStyle(meam/kk/device,PairMEAMKokkos) -PairStyle(meam/kk/host,PairMEAMKokkos) +PairStyle(meam/c/kk,PairMEAMKokkos); +PairStyle(meam/c/kk/device,PairMEAMKokkos); +PairStyle(meam/c/kk/host,PairMEAMKokkos); +PairStyle(meam/kk,PairMEAMKokkos); +PairStyle(meam/kk/device,PairMEAMKokkos); +PairStyle(meam/kk/host,PairMEAMKokkos); // clang-format on #else diff --git a/src/KOKKOS/pair_meam_ms_kokkos.cpp b/src/KOKKOS/pair_meam_ms_kokkos.cpp new file mode 100644 index 0000000000..491fc0273c --- /dev/null +++ b/src/KOKKOS/pair_meam_ms_kokkos.cpp @@ -0,0 +1,32 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "pair_meam_ms_kokkos.h" +#include "meam.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ +template +PairMEAMMSKokkos::PairMEAMMSKokkos(LAMMPS *lmp) : PairMEAMKokkos(lmp) +{ + this->meam_inst->msmeamflag = this->msmeamflag = 1; + this->myname = "meam/ms/kk"; +} + +namespace LAMMPS_NS { +template class PairMEAMMSKokkos; +#ifdef KOKKOS_ENABLE_CUDA +template class PairMEAMMSKokkos; +#endif +} diff --git a/src/KOKKOS/pair_meam_ms_kokkos.h b/src/KOKKOS/pair_meam_ms_kokkos.h new file mode 100644 index 0000000000..a2cefc2c16 --- /dev/null +++ b/src/KOKKOS/pair_meam_ms_kokkos.h @@ -0,0 +1,36 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(meam/ms/kk,PairMEAMMSKokkos); +PairStyle(meam/ms/kk/device,PairMEAMMSKokkos); +PairStyle(meam/ms/kk/host,PairMEAMMSKokkos); +// clang-format on +#else + +#ifndef LMP_PAIR_MEAM_MS_KOKKOS_H +#define LMP_PAIR_MEAM_MS_KOKKOS_H + +#include "pair_meam_kokkos.h" + +namespace LAMMPS_NS { + +template +class PairMEAMMSKokkos : public PairMEAMKokkos { + public: + PairMEAMMSKokkos(class LAMMPS *); +}; +} // namespace LAMMPS_NS +#endif +#endif diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index c5d6afbea5..5a131bdc34 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -17,7 +17,7 @@ #include #include -#define maxelt 5 +constexpr int maxelt = 5; namespace LAMMPS_NS { class Memory; diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 911b8930df..de1188349c 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -836,9 +836,9 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho21 = *rho21 / denom * *rho01; } else *rho21 = 8. / 3. * (rhoa21 - rhoa22) * (rhoa21 - rhoa22); - if (this->msmeamflag) { - *rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2); - } + if (this->msmeamflag) { + *rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2); + } break; case B2: *rho01 = 8.0 * rhoa02; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 62c0278da3..c4a4cfa1d7 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -54,12 +54,15 @@ PairMEAM::PairMEAM(LAMMPS *lmp) : Pair(lmp) one_coeff = 1; manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - msmeamflag = 0; allocated = 0; nlibelements = 0; + meam_inst = new MEAM(memory); + meam_inst->msmeamflag = msmeamflag = 0; + myname = "meam"; + scale = nullptr; } @@ -181,18 +184,9 @@ void PairMEAM::allocate() global settings ------------------------------------------------------------------------- */ -void PairMEAM::settings(int narg, char **arg) +void PairMEAM::settings(int narg, char ** /*arg*/) { - if (narg > 1) error->all(FLERR,"Illegal pair_style meam command"); - - meam_inst->msmeamflag = 0; - - if (narg == 1) { - if (strcmp("ms", arg[0]) == 0) { - msmeamflag = meam_inst->msmeamflag = 1; - } else - error->all(FLERR, "Unknown pair style meam option {}", arg[0]); - } + if (narg != 0) error->all(FLERR,"Illegal pair_style {} command", myname); // set comm size needed by this Pair @@ -215,12 +209,7 @@ void PairMEAM::coeff(int narg, char **arg) if (!allocated) allocate(); - if (narg < 6) error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg < 6) error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); // check for presence of first meam file @@ -248,7 +237,7 @@ void PairMEAM::coeff(int narg, char **arg) } if (paridx < 0) error->all(FLERR,"No MEAM parameter file in pair coefficients"); if ((narg - paridx - 1) != atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); + error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); // MEAM element names between 2 filenames // nlibelements = # of MEAM elements @@ -291,7 +280,7 @@ void PairMEAM::coeff(int narg, char **arg) if (libelements[j] == arg[i]) break; if (j < nlibelements) map[m] = j; else if (strcmp(arg[i],"NULL") == 0) map[m] = -1; - else error->all(FLERR,"Incorrect args for pair coefficients"); + else error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); } // clear setflag since coeff() called once with I,J = * * @@ -316,7 +305,7 @@ void PairMEAM::coeff(int narg, char **arg) } } - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + if (count == 0) error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); } /* ---------------------------------------------------------------------- @@ -326,7 +315,7 @@ void PairMEAM::coeff(int narg, char **arg) void PairMEAM::init_style() { if (force->newton_pair == 0) - error->all(FLERR,"Pair style MEAM requires newton pair on"); + error->all(FLERR,"Pair style {} requires newton pair on", myname); // need a full and a half neighbor list @@ -436,8 +425,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) std::string lattice_type = values.next_string(); if (!MEAM::str_to_lat(lattice_type, true, lat[index])) - error->one(FLERR,"Unrecognized lattice type in MEAM " - "library file: {}", lattice_type); + error->one(FLERR,"Unrecognized lattice type in MEAM library file: {}", lattice_type); // store parameters @@ -470,11 +458,11 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) ibar[index] = values.next_int(); if (!isone(t0[index])) - error->one(FLERR,"Unsupported parameter in MEAM library file: t0!=1"); + error->one(FLERR,"Unsupported parameter in MEAM library file: t0 != 1"); // z given is ignored: if this is mismatched, we definitely won't do what the user said -> fatal error if (z[index] != MEAM::get_Zij(lat[index])) - error->one(FLERR,"Mismatched parameter in MEAM library file: z!=lat"); + error->one(FLERR,"Mismatched parameter in MEAM library file: z != lat"); nset++; } catch (TokenizerException &e) { diff --git a/src/MEAM/pair_meam.h b/src/MEAM/pair_meam.h index 0db599e74d..a89714bfa9 100644 --- a/src/MEAM/pair_meam.h +++ b/src/MEAM/pair_meam.h @@ -48,6 +48,7 @@ class PairMEAM : public Pair { double cutmax; // max cutoff for all elements int nlibelements; // # of library elements int msmeamflag; // 0 (default) for normal MEAM, 1 for MS-MEAM + std::string myname; // name of the pair style std::vector libelements; // names of library elements std::vector mass; // mass of library element diff --git a/src/MEAM/pair_meam_ms.cpp b/src/MEAM/pair_meam_ms.cpp new file mode 100644 index 0000000000..982a54f546 --- /dev/null +++ b/src/MEAM/pair_meam_ms.cpp @@ -0,0 +1,25 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "pair_meam_ms.h" +#include "meam.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +PairMEAMMS::PairMEAMMS(LAMMPS *lmp) : PairMEAM(lmp) +{ + meam_inst->msmeamflag = msmeamflag = 1; + myname = "meam/ms"; +} diff --git a/src/MEAM/pair_meam_ms.h b/src/MEAM/pair_meam_ms.h new file mode 100644 index 0000000000..25878203ed --- /dev/null +++ b/src/MEAM/pair_meam_ms.h @@ -0,0 +1,33 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(meam/ms,PairMEAMMS); +// clang-format on +#else + +#ifndef LMP_PAIR_MEAM_MS_H +#define LMP_PAIR_MEAM_MS_H + +#include "pair_meam.h" + +namespace LAMMPS_NS { + +class PairMEAMMS : public PairMEAM { + public: + PairMEAMMS(class LAMMPS *); +}; +} // namespace LAMMPS_NS +#endif +#endif From 18171af1ea5c2f6a4a3783b21841506b9c44de60 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 26 Jan 2023 15:28:34 -0500 Subject: [PATCH 35/43] add a unit test for MS-MEAM --- .../tests/atomic-pair-meam_ms.yaml | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 unittest/force-styles/tests/atomic-pair-meam_ms.yaml diff --git a/unittest/force-styles/tests/atomic-pair-meam_ms.yaml b/unittest/force-styles/tests/atomic-pair-meam_ms.yaml new file mode 100644 index 0000000000..e479514017 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-meam_ms.yaml @@ -0,0 +1,94 @@ +--- +lammps_version: 22 Dec 2022 +tags: slow +date_generated: Thu Jan 26 15:27:03 2023 +epsilon: 2.5e-12 +skip_tests: +prerequisites: ! | + pair meam/ms +pre_commands: ! | + variable newton_pair delete + if "$(is_active(package,gpu)) > 0.0" then "variable newton_pair index off" else "variable newton_pair index on" +post_commands: ! "" +input_file: in.metal +pair_style: meam/ms +pair_coeff: ! | + * * library.msmeam H Ga4 HGa.msmeam H Ga4 +extract: ! | + scale 2 +natoms: 32 +init_vdwl: 785.6030480758675 +init_coul: 0 +init_stress: ! |2- + 3.3502530994900699e+03 3.6405858278699407e+03 3.6349804214165547e+03 -3.1609283411508039e+02 -7.9448207656135153e+01 -1.9854140603340727e+02 +init_forces: ! |2 + 1 1.2872255079741514e+01 -7.5031848810810864e-01 4.5969595156096510e+01 + 2 -3.9028679722038632e+01 -1.5647800180326567e+02 -1.6643992152928173e+00 + 3 -6.1521549955194672e+01 2.6970968316419874e+02 -9.6866430262650326e+01 + 4 3.1462579880342336e+01 4.0240291291218455e+01 1.1654869213327775e+01 + 5 1.4859248182951113e+01 -3.4132880749392825e+01 6.7430378007130244e+01 + 6 6.4609571260694096e+00 -3.8973222482916441e+01 -2.8510000379627442e+01 + 7 7.8114612113500250e+00 -1.0421431668544374e+01 -4.2887607385766536e+01 + 8 -4.8934215863351795e+01 -6.3567347969802590e-01 1.1845972792272754e+02 + 9 9.4089549606898402e+01 -7.4342942103394511e+00 2.5331198575951383e+01 + 10 1.5130369934140692e+01 -5.9245630928969938e+01 -6.7469126603400198e+01 + 11 -2.5176547213746847e+01 1.1577205529172168e+02 -2.2897457133540517e+01 + 12 6.2237686199502349e+01 2.0501996047945163e+01 -2.8805091517252826e+01 + 13 -5.9438589221526925e+01 3.0453092653824072e+01 -1.9919245831196157e+01 + 14 6.9128305482543766e+01 -7.7400771634148342e+01 3.3376079908119145e+01 + 15 -4.9671207786831857e+01 -4.9520814527298228e+01 8.4325181097614305e+01 + 16 -1.1782591146017666e+01 -3.2478963020209051e+01 1.5503663677714293e+01 + 17 9.0881787245915220e+00 6.2377477671714963e+01 -4.0411006180232363e+01 + 18 -4.2285082775720454e+01 2.4883979527636967e+01 -4.4858149086530510e+00 + 19 -8.0259798420493979e+01 9.6356660229207137e+01 6.0543230952477984e+01 + 20 8.0924547938759346e+01 7.1034504027236025e+01 -7.1958482512489610e+01 + 21 1.0833434220705425e+02 -1.5973910256481020e+02 -2.5432700070393153e+01 + 22 -2.3754601906353900e+00 5.2216955012971823e+01 4.7112051341131576e+00 + 23 -2.7227169255996543e+01 8.1968603165764222e+01 4.6535834898716878e+01 + 24 -2.9230758067555616e+01 6.5909555829367733e+01 -2.8250697734131258e+01 + 25 -5.1310041582953993e+01 -3.0895272949222822e+01 -5.4271286813003794e+00 + 26 3.9605941911194620e+01 -5.5919050176828883e+01 -1.0209061328106253e+01 + 27 8.2934427989660890e+01 6.1956200199325636e+01 5.0072108788590960e+01 + 28 -7.8572755094413296e+01 -3.9613391730681300e+01 -2.6183413623428891e+00 + 29 6.9475725072041925e+01 -6.0535433603583563e+01 -1.4566536349135829e+01 + 30 -2.4347184151182930e+01 -1.9359391333689970e+02 -2.6718379302915952e+01 + 31 7.7351971629808688e+01 -7.0102650745312999e+01 -5.4615048867524763e+01 + 32 -1.5060591772899014e+02 8.4489763988097266e+01 2.9799482293372058e+01 +run_vdwl: 682.3107192428497 +run_coul: 0 +run_stress: ! |2- + 3.2247564044913129e+03 3.3749506031067485e+03 3.3223794967215117e+03 -2.8460979167554797e+02 -7.2614457076660575e+00 -3.1510685747732862e+02 +run_forces: ! |2 + 1 -1.2037185973996296e+01 -2.5090364403764944e+01 1.4014184973113366e+01 + 2 -3.7365848425239264e+01 -1.5871199357658887e+02 3.7846333470446991e+00 + 3 -3.2057228694304293e+01 2.5316344962361612e+02 -6.0679585186816752e+01 + 4 2.9086197614116237e+01 4.8267528016068823e+01 4.3387429619749920e+00 + 5 -1.1672554618399744e+01 -2.6840760926124332e+01 4.9694308545223279e+01 + 6 1.1892092913978592e+01 -4.9360840569608243e+01 -2.3083171938147949e+01 + 7 2.1084251901459215e+01 -4.8251731643401072e+00 -3.8474871193885967e+01 + 8 -5.7775944085787714e+01 1.3522956442661442e+01 1.1661345819661486e+02 + 9 7.2926105059437930e+01 4.8686056096860133e+00 2.3817134806042311e+01 + 10 1.7307367990304396e+01 -3.0865570121704572e+01 -1.2314307646704794e+01 + 11 -1.1341297645054201e+01 9.1441145595173211e+01 -2.1806407500802493e+01 + 12 4.0645024127126625e+01 1.2207243511090397e+01 -2.6757649464936929e+01 + 13 -5.2283270287937697e+01 3.4023912643812679e+01 -1.9030352703627774e+01 + 14 8.4403128243303399e+01 -9.3773678297574406e+01 1.6481720093363641e+01 + 15 -4.2790833192154764e+01 -4.3242943642279130e+01 7.1075696811865868e+01 + 16 -1.5041912007490836e+01 -3.3544044565611586e+01 2.4823109532967212e+01 + 17 -9.6413207346836316e-01 4.5826021602656141e+01 -3.9155163702194102e+01 + 18 -2.0337015515785971e+01 7.2815285567550134e+00 -8.2049879725129813e+00 + 19 -6.4105384732081120e+01 1.1564665740933788e+02 2.4163791756721466e+01 + 20 8.5723654185276146e+01 8.3354105531647818e+01 -6.6380939444134356e+01 + 21 7.2614253221132458e+01 -1.0858997173537107e+02 -9.7505297776024449e+00 + 22 -7.0420361713052930e+00 5.3431098224890221e+01 3.3089063930822551e+00 + 23 -2.6591358240682062e+01 5.7408565880721866e+01 2.7437106471305679e+01 + 24 -4.1792038450554799e+01 5.1730557789864775e+01 -4.0814677464080816e+01 + 25 -4.1432062506590214e+01 -2.5839213423062226e+01 4.2240164846210408e+00 + 26 4.7210066329871566e+01 -5.2462761136081880e+01 -7.3222050314410501e+00 + 27 7.1880187551772764e+01 6.4264938765955392e+01 4.3600944370341068e+01 + 28 -8.4540787660053340e+01 -3.5402262816619938e+01 -1.8100280797937039e+01 + 29 6.9538301274653790e+01 -6.3441028093040622e+01 -1.4636386232064458e+01 + 30 -1.0347208112535196e+01 -1.7647584813608077e+02 7.2581082578181517e+00 + 31 5.5139777976761025e+01 -4.2081916983382541e+01 -4.6602437208067727e+01 + 32 -1.0993230999577290e+02 3.4110056387297462e+01 1.8478090262857769e+01 +... From 1ded6320109441a4d6ae7a8aad06a369714ddc1a Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:02:52 -0700 Subject: [PATCH 36/43] Add new files to Kokkos Install.sh --- src/KOKKOS/Install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 1b58abe3a2..f493b5438a 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -316,6 +316,8 @@ action pair_lj_spica_kokkos.cpp pair_lj_spica.cpp action pair_lj_spica_kokkos.h pair_lj_spica.h action pair_meam_kokkos.cpp pair_meam.cpp action pair_meam_kokkos.h pair_meam.h +action pair_meam_ms_kokkos.cpp pair_meam_ms.cpp +action pair_meam_ms_kokkos.h pair_meam_ms.h action pair_mliap_kokkos.cpp pair_mliap.cpp action pair_mliap_kokkos.h pair_mliap.h action pair_morse_kokkos.cpp From 3e334fe10c28e3749fe0e48bd1fef1b1c6d49b8b Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:03:20 -0700 Subject: [PATCH 37/43] Remove 'this->' in device code --- src/KOKKOS/meam_dens_init_kokkos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index a1a184f0a2..60bb6553d8 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -43,7 +43,7 @@ void MEAMKokkos::operator()(TagMEAMZero, const int &i) const { d_rho0[i] = 0.0; d_arho2b[i] = 0.0; d_arho1(i,0) = d_arho1(i,1) = d_arho1(i,2) = 0.0; - if (this->msmeamflag) { + if (msmeamflag) { d_arho2mb[i] = 0.0; d_arho1m(i,0) = d_arho1m(i,1) = d_arho1m(i,2) = 0.0; } From a7b357b951b6f5d17ea51e631ba99113affb1d0e Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:10:01 -0700 Subject: [PATCH 38/43] Rename example --- examples/meam/msmeam/README.md | 4 +- .../meam/msmeam/{test.data => data.msmeam} | 0 .../msmeam/{test.data.bu => data.msmeam.bu} | 0 .../msmeam/{test.dump.bu => dump.msmeam.bu} | 0 examples/meam/msmeam/{test.in => in.msmeam} | 6 +- examples/meam/msmeam/log.msmeam.bu | 107 ++++++++++++++++++ examples/meam/msmeam/msmeam.data | 25 ++++ examples/meam/msmeam/msmeam.dump.bu | 24 ++++ 8 files changed, 161 insertions(+), 5 deletions(-) rename examples/meam/msmeam/{test.data => data.msmeam} (100%) rename examples/meam/msmeam/{test.data.bu => data.msmeam.bu} (100%) rename examples/meam/msmeam/{test.dump.bu => dump.msmeam.bu} (100%) rename examples/meam/msmeam/{test.in => in.msmeam} (80%) create mode 100644 examples/meam/msmeam/log.msmeam.bu create mode 100644 examples/meam/msmeam/msmeam.data create mode 100644 examples/meam/msmeam/msmeam.dump.bu diff --git a/examples/meam/msmeam/README.md b/examples/meam/msmeam/README.md index 1b542ed867..dbf569d4b3 100644 --- a/examples/meam/msmeam/README.md +++ b/examples/meam/msmeam/README.md @@ -1,9 +1,9 @@ To run Baske's test, do - lmp -in test.in + lmp -in in.msmeam Then - diff test.dump test.dump.bu + diff dump.msmeam dump.msmeam.bu diff --git a/examples/meam/msmeam/test.data b/examples/meam/msmeam/data.msmeam similarity index 100% rename from examples/meam/msmeam/test.data rename to examples/meam/msmeam/data.msmeam diff --git a/examples/meam/msmeam/test.data.bu b/examples/meam/msmeam/data.msmeam.bu similarity index 100% rename from examples/meam/msmeam/test.data.bu rename to examples/meam/msmeam/data.msmeam.bu diff --git a/examples/meam/msmeam/test.dump.bu b/examples/meam/msmeam/dump.msmeam.bu similarity index 100% rename from examples/meam/msmeam/test.dump.bu rename to examples/meam/msmeam/dump.msmeam.bu diff --git a/examples/meam/msmeam/test.in b/examples/meam/msmeam/in.msmeam similarity index 80% rename from examples/meam/msmeam/test.in rename to examples/meam/msmeam/in.msmeam index d3ce0173e6..82ffb89a13 100644 --- a/examples/meam/msmeam/test.in +++ b/examples/meam/msmeam/in.msmeam @@ -1,5 +1,5 @@ echo both -log test.log +log log.msmeam # Test of MEAM potential for HGa # ------------------------ INITIALIZATION ---------------------------- @@ -24,8 +24,8 @@ create_atoms 2 single 0.3 2.3 0 units box variable teng equal "c_eatoms" compute pot_energy all pe/atom compute stress all stress/atom NULL -dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +dump 1 all custom 1 dump.msmeam id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] run 1 -write_data test.data +write_data data.msmeam print "All done!" diff --git a/examples/meam/msmeam/log.msmeam.bu b/examples/meam/msmeam/log.msmeam.bu new file mode 100644 index 0000000000..8eac453c1e --- /dev/null +++ b/examples/meam/msmeam/log.msmeam.bu @@ -0,0 +1,107 @@ +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box +Created orthogonal box = (-4 -4 -4) to (4 4 4) + 1 by 1 by 1 MPI processor grid + +# + +include potential.mod +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +potential chosen H +# Choose potential +pair_style MSmeam +print "we just executed" +we just executed + +pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 +pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 +Reading potential file library.MSmeam with DATE: 2018-09-22 +# Setup neighbor style +neighbor 1.0 nsq +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +min_modify dmax 0.01 line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes +create_atoms 1 single 0 0 0 units box +Created 1 atoms +create_atoms 2 single 2.2 0 0 units box +Created 1 atoms +create_atoms 2 single 0.3 2.3 0 units box +Created 1 atoms +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +dump 1 all custom 1 dump.msmeam id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +WARNING: No fixes defined, atoms won't move (../verlet.cpp:55) +Neighbor list info ... + 2 neighbor list requests + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.9 + ghost atom cutoff = 6.9 +Memory usage per processor = 12.9295 Mbytes +Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume eatoms + 0 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 + 1 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 +Loop time of 0.000172138 on 1 procs for 1 steps with 3 atoms + +Performance: 501.922 ns/day, 0.048 hours/ns, 5809.285 timesteps/s +81.3% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 6.6996e-05 | 6.6996e-05 | 6.6996e-05 | 0.0 | 38.92 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 1.9073e-06 | 1.9073e-06 | 1.9073e-06 | 0.0 | 1.11 +Output | 9.7036e-05 | 9.7036e-05 | 9.7036e-05 | 0.0 | 56.37 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 6.199e-06 | | | 3.60 + +Nlocal: 3 ave 3 max 3 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 78 ave 78 max 78 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7 ave 7 max 7 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 14 ave 14 max 14 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 14 +Ave neighs/atom = 4.66667 +Neighbor list builds = 0 +Dangerous builds = 0 +write_data data.msmeam + +print "All done!" +All done! +Total wall time: 0:00:00 + diff --git a/examples/meam/msmeam/msmeam.data b/examples/meam/msmeam/msmeam.data new file mode 100644 index 0000000000..69be174e2d --- /dev/null +++ b/examples/meam/msmeam/msmeam.data @@ -0,0 +1,25 @@ +LAMMPS data file via write_data, version 22 Dec 2022, timestep = 1 + +3 atoms +2 atom types + +-4 4 xlo xhi +-4 4 ylo yhi +-4 4 zlo zhi + +Masses + +1 1.0079 +2 69.723 + +Atoms # atomic/kk + +1 1 0 0 0 0 0 0 +2 2 2.2 0 0 0 0 0 +3 2 0.3 2.3 0 0 0 0 + +Velocities + +1 0 0 0 +2 0 0 0 +3 0 0 0 diff --git a/examples/meam/msmeam/msmeam.dump.bu b/examples/meam/msmeam/msmeam.dump.bu new file mode 100644 index 0000000000..039f630073 --- /dev/null +++ b/examples/meam/msmeam/msmeam.dump.bu @@ -0,0 +1,24 @@ +ITEM: TIMESTEP +0 +ITEM: NUMBER OF ATOMS +3 +ITEM: BOX BOUNDS pp pp pp +-4 4 +-4 4 +-4 4 +ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 +2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 +ITEM: TIMESTEP +1 +ITEM: NUMBER OF ATOMS +3 +ITEM: BOX BOUNDS pp pp pp +-4 4 +-4 4 +-4 4 +ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 +2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 +3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 From b7dfa3db05e1c603fee40178d1f6883c5d964c9e Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:12:34 -0700 Subject: [PATCH 39/43] Whack extra files from #3532 --- lib/kokkos/kokkos_5538.diff | 199 -------- lib/kokkos/kokkos_5706.diff | 523 --------------------- lib/kokkos/kokkos_5731.diff | 46 -- lib/kokkos/kokkos_5739.diff | 204 -------- lib/kokkos/kokkos_fix_5706_apply_last.diff | 63 --- 5 files changed, 1035 deletions(-) delete mode 100644 lib/kokkos/kokkos_5538.diff delete mode 100644 lib/kokkos/kokkos_5706.diff delete mode 100644 lib/kokkos/kokkos_5731.diff delete mode 100644 lib/kokkos/kokkos_5739.diff delete mode 100644 lib/kokkos/kokkos_fix_5706_apply_last.diff diff --git a/lib/kokkos/kokkos_5538.diff b/lib/kokkos/kokkos_5538.diff deleted file mode 100644 index 6bf2ccf6a4..0000000000 --- a/lib/kokkos/kokkos_5538.diff +++ /dev/null @@ -1,199 +0,0 @@ -diff --git a/lib/kokkos/Makefile.kokkos b/lib/kokkos/Makefile.kokkos -index 22af411f32..530510a0d1 100644 ---- a/lib/kokkos/Makefile.kokkos -+++ b/lib/kokkos/Makefile.kokkos -@@ -20,7 +20,7 @@ KOKKOS_DEVICES ?= "OpenMP" - #KOKKOS_DEVICES ?= "Threads" - # Options: - # Intel: KNC,KNL,SNB,HSW,BDW,SKL,SKX,ICL,ICX,SPR --# NVIDIA: Kepler,Kepler30,Kepler32,Kepler35,Kepler37,Maxwell,Maxwell50,Maxwell52,Maxwell53,Pascal60,Pascal61,Volta70,Volta72,Turing75,Ampere80,Ampere86 -+# NVIDIA: Kepler,Kepler30,Kepler32,Kepler35,Kepler37,Maxwell,Maxwell50,Maxwell52,Maxwell53,Pascal60,Pascal61,Volta70,Volta72,Turing75,Ampere80,Ampere86,Hopper90 - # ARM: ARMv80,ARMv81,ARMv8-ThunderX,ARMv8-TX2,A64FX - # IBM: BGQ,Power7,Power8,Power9 - # AMD-GPUS: Vega900,Vega906,Vega908,Vega90A -@@ -401,6 +401,7 @@ KOKKOS_INTERNAL_USE_ARCH_VOLTA72 := $(call kokkos_has_string,$(KOKKOS_ARCH),Volt - KOKKOS_INTERNAL_USE_ARCH_TURING75 := $(call kokkos_has_string,$(KOKKOS_ARCH),Turing75) - KOKKOS_INTERNAL_USE_ARCH_AMPERE80 := $(call kokkos_has_string,$(KOKKOS_ARCH),Ampere80) - KOKKOS_INTERNAL_USE_ARCH_AMPERE86 := $(call kokkos_has_string,$(KOKKOS_ARCH),Ampere86) -+KOKKOS_INTERNAL_USE_ARCH_HOPPER90 := $(call kokkos_has_string,$(KOKKOS_ARCH),Hopper90) - KOKKOS_INTERNAL_USE_ARCH_NVIDIA := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_KEPLER30) \ - + $(KOKKOS_INTERNAL_USE_ARCH_KEPLER32) \ - + $(KOKKOS_INTERNAL_USE_ARCH_KEPLER35) \ -@@ -414,7 +415,8 @@ KOKKOS_INTERNAL_USE_ARCH_NVIDIA := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_KEPLE - + $(KOKKOS_INTERNAL_USE_ARCH_VOLTA72) \ - + $(KOKKOS_INTERNAL_USE_ARCH_TURING75) \ - + $(KOKKOS_INTERNAL_USE_ARCH_AMPERE80) \ -- + $(KOKKOS_INTERNAL_USE_ARCH_AMPERE86)) -+ + $(KOKKOS_INTERNAL_USE_ARCH_AMPERE86) \ -+ + $(KOKKOS_INTERNAL_USE_ARCH_HOPPER90)) - - #SEK: This seems like a bug to me - ifeq ($(KOKKOS_INTERNAL_USE_ARCH_NVIDIA), 0) -@@ -1194,6 +1196,11 @@ ifeq ($(KOKKOS_INTERNAL_USE_CUDA_ARCH), 1) - tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMPERE86") - KOKKOS_INTERNAL_CUDA_ARCH_FLAG := $(KOKKOS_INTERNAL_CUDA_ARCH_FLAG)=sm_86 - endif -+ ifeq ($(KOKKOS_INTERNAL_USE_ARCH_HOPPER90), 1) -+ tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_HOPPER") -+ tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_HOPPER90") -+ KOKKOS_INTERNAL_CUDA_ARCH_FLAG := $(KOKKOS_INTERNAL_CUDA_ARCH_FLAG)=sm_90 -+ endif - - ifneq ($(KOKKOS_INTERNAL_USE_ARCH_NVIDIA), 0) - KOKKOS_CXXFLAGS += $(KOKKOS_INTERNAL_CUDA_ARCH_FLAG) -diff --git a/lib/kokkos/cmake/KokkosCore_config.h.in b/lib/kokkos/cmake/KokkosCore_config.h.in -index 88ddc48378..b83ced9243 100644 ---- a/lib/kokkos/cmake/KokkosCore_config.h.in -+++ b/lib/kokkos/cmake/KokkosCore_config.h.in -@@ -102,6 +102,7 @@ - #cmakedefine KOKKOS_ARCH_AMPERE - #cmakedefine KOKKOS_ARCH_AMPERE80 - #cmakedefine KOKKOS_ARCH_AMPERE86 -+#cmakedefine KOKKOS_ARCH_HOPPER90 - #cmakedefine KOKKOS_ARCH_AMD_ZEN - #cmakedefine KOKKOS_ARCH_AMD_ZEN2 - #cmakedefine KOKKOS_ARCH_AMD_ZEN3 -diff --git a/lib/kokkos/cmake/compile_tests/cuda_compute_capability.cc b/lib/kokkos/cmake/compile_tests/cuda_compute_capability.cc -index f56cef1651..2585a6a64c 100644 ---- a/lib/kokkos/cmake/compile_tests/cuda_compute_capability.cc -+++ b/lib/kokkos/cmake/compile_tests/cuda_compute_capability.cc -@@ -74,6 +74,7 @@ int main() { - case 75: std::cout << "Set -DKokkos_ARCH_TURING75=ON ." << std::endl; break; - case 80: std::cout << "Set -DKokkos_ARCH_AMPERE80=ON ." << std::endl; break; - case 86: std::cout << "Set -DKokkos_ARCH_AMPERE86=ON ." << std::endl; break; -+ case 90: std::cout << "Set -DKokkos_ARCH_HOPPER90=ON ." << std::endl; break; - default: - std::cout << "Compute capability " << compute_capability - << " is not supported" << std::endl; -diff --git a/lib/kokkos/cmake/kokkos_arch.cmake b/lib/kokkos/cmake/kokkos_arch.cmake -index ef16aad047..c1d76cceeb 100644 ---- a/lib/kokkos/cmake/kokkos_arch.cmake -+++ b/lib/kokkos/cmake/kokkos_arch.cmake -@@ -86,6 +86,7 @@ KOKKOS_ARCH_OPTION(VOLTA72 GPU "NVIDIA Volta generation CC 7.2" "KOKK - KOKKOS_ARCH_OPTION(TURING75 GPU "NVIDIA Turing generation CC 7.5" "KOKKOS_SHOW_CUDA_ARCHS") - KOKKOS_ARCH_OPTION(AMPERE80 GPU "NVIDIA Ampere generation CC 8.0" "KOKKOS_SHOW_CUDA_ARCHS") - KOKKOS_ARCH_OPTION(AMPERE86 GPU "NVIDIA Ampere generation CC 8.6" "KOKKOS_SHOW_CUDA_ARCHS") -+KOKKOS_ARCH_OPTION(HOPPER90 GPU "NVIDIA Hopper generation CC 9.0" "KOKKOS_SHOW_CUDA_ARCHS") - - IF(Kokkos_ENABLE_HIP OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_UNSUPPORTED_ARCHS) - SET(KOKKOS_SHOW_HIP_ARCHS ON) -@@ -544,6 +545,7 @@ CHECK_CUDA_ARCH(VOLTA72 sm_72) - CHECK_CUDA_ARCH(TURING75 sm_75) - CHECK_CUDA_ARCH(AMPERE80 sm_80) - CHECK_CUDA_ARCH(AMPERE86 sm_86) -+CHECK_CUDA_ARCH(HOPPER90 sm_90) - - SET(AMDGPU_ARCH_ALREADY_SPECIFIED "") - FUNCTION(CHECK_AMDGPU_ARCH ARCH FLAG) -@@ -806,6 +808,10 @@ IF (KOKKOS_ARCH_AMPERE80 OR KOKKOS_ARCH_AMPERE86) - SET(KOKKOS_ARCH_AMPERE ON) - ENDIF() - -+IF (KOKKOS_ARCH_HOPPER90) -+ SET(KOKKOS_ARCH_HOPPER ON) -+ENDIF() -+ - #Regardless of version, make sure we define the general architecture name - IF (KOKKOS_ARCH_VEGA900 OR KOKKOS_ARCH_VEGA906 OR KOKKOS_ARCH_VEGA908 OR KOKKOS_ARCH_VEGA90A) - SET(KOKKOS_ARCH_VEGA ON) -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -index 56f9117844..fcd4773dbc 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -@@ -232,7 +232,8 @@ inline size_t get_shmem_per_sm_prefer_l1(cudaDeviceProp const& properties) { - case 61: return 96; - case 70: - case 80: -- case 86: return 8; -+ case 86: -+ case 90: return 8; - case 75: return 32; - default: - Kokkos::Impl::throw_runtime_exception( -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Half_Conversion.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Half_Conversion.hpp -index 40a263561f..8c40ebd60d 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Half_Conversion.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Half_Conversion.hpp -@@ -418,7 +418,7 @@ KOKKOS_INLINE_FUNCTION - #endif // CUDA_VERSION >= 11000 && CUDA_VERSION < 11010 - - #if CUDA_VERSION >= 11010 && \ -- ((defined(KOKKOS_ARCH_AMPERE80) || defined(KOKKOS_ARCH_AMPERE86))) -+ ((defined(KOKKOS_ARCH_AMPERE) || defined(KOKKOS_ARCH_HOPPER))) - KOKKOS_INLINE_FUNCTION - bhalf_t cast_to_bhalf(bhalf_t val) { return val; } - KOKKOS_INLINE_FUNCTION -diff --git a/lib/kokkos/core/src/OpenACC/Kokkos_OpenACC_Traits.hpp b/lib/kokkos/core/src/OpenACC/Kokkos_OpenACC_Traits.hpp -index f9451ecfe6..2ce1efb98c 100644 ---- a/lib/kokkos/core/src/OpenACC/Kokkos_OpenACC_Traits.hpp -+++ b/lib/kokkos/core/src/OpenACC/Kokkos_OpenACC_Traits.hpp -@@ -51,7 +51,7 @@ namespace Kokkos::Experimental::Impl { - - struct OpenACC_Traits { - #if defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -- defined(KOKKOS_ARCH_AMPERE) -+ defined(KOKKOS_ARCH_AMPERE) || defined(KOKKOS_ARCH_HOPPER) - static constexpr acc_device_t dev_type = acc_device_nvidia; - static constexpr bool may_fallback_to_host = false; - #else -diff --git a/lib/kokkos/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Instance.cpp b/lib/kokkos/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Instance.cpp -index a9bc085912..27ee1d4232 100644 ---- a/lib/kokkos/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Instance.cpp -+++ b/lib/kokkos/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Instance.cpp -@@ -115,8 +115,9 @@ void OpenMPTargetInternal::impl_initialize() { - - // FIXME_OPENMPTARGET: Only fix the number of teams for NVIDIA architectures - // from Pascal and upwards. --#if defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -- defined(KOKKOS_ARCH_TURING75) || defined(KOKKOS_ARCH_AMPERE) -+#if defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -+ defined(KOKKOS_ARCH_TURING75) || defined(KOKKOS_ARCH_AMPERE) || \ -+ defined(KOKKOS_ARCH_HOPPER) - #if defined(KOKKOS_COMPILER_CLANG) && (KOKKOS_COMPILER_CLANG >= 1300) - omp_set_num_teams(512); - #endif -diff --git a/lib/kokkos/core/src/SYCL/Kokkos_SYCL.cpp b/lib/kokkos/core/src/SYCL/Kokkos_SYCL.cpp -index 840db4327c..7e5addbc5b 100644 ---- a/lib/kokkos/core/src/SYCL/Kokkos_SYCL.cpp -+++ b/lib/kokkos/core/src/SYCL/Kokkos_SYCL.cpp -@@ -155,7 +155,7 @@ void SYCL::impl_initialize(InitializationSettings const& settings) { - #if !defined(KOKKOS_ARCH_INTEL_GPU) && !defined(KOKKOS_ARCH_KEPLER) && \ - !defined(KOKKOS_ARCH_MAXWELL) && !defined(KOKKOS_ARCH_PASCAL) && \ - !defined(KOKKOS_ARCH_VOLTA) && !defined(KOKKOS_ARCH_TURING75) && \ -- !defined(KOKKOS_ARCH_AMPERE) -+ !defined(KOKKOS_ARCH_AMPERE) && !defined(KOKKOS_ARCH_HOPPER) - if (!settings.has_device_id() && gpu_devices.empty()) { - Impl::SYCLInternal::singleton().initialize(sycl::device()); - return; -diff --git a/lib/kokkos/core/src/SYCL/Kokkos_SYCL_Parallel_Team.hpp b/lib/kokkos/core/src/SYCL/Kokkos_SYCL_Parallel_Team.hpp -index 5ac7d8af30..ba101f699e 100644 ---- a/lib/kokkos/core/src/SYCL/Kokkos_SYCL_Parallel_Team.hpp -+++ b/lib/kokkos/core/src/SYCL/Kokkos_SYCL_Parallel_Team.hpp -@@ -335,9 +335,10 @@ class TeamPolicyInternal - return std::min({ - int(m_space.impl_internal_space_instance()->m_maxWorkgroupSize), - // FIXME_SYCL Avoid requesting to many registers on NVIDIA GPUs. --#if defined(KOKKOS_ARCH_KEPLER) || defined(KOKKOS_ARCH_MAXWELL) || \ -- defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -- defined(KOKKOS_ARCH_TURING75) || defined(KOKKOS_ARCH_AMPERE) -+#if defined(KOKKOS_ARCH_KEPLER) || defined(KOKKOS_ARCH_MAXWELL) || \ -+ defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -+ defined(KOKKOS_ARCH_TURING75) || defined(KOKKOS_ARCH_AMPERE) || \ -+ defined(KOKKOS_ARCH_HOPPER) - 256, - #endif - max_threads_for_memory -@@ -367,9 +368,10 @@ class TeamPolicyInternal - return std::min({ - int(m_space.impl_internal_space_instance()->m_maxWorkgroupSize), - // FIXME_SYCL Avoid requesting to many registers on NVIDIA GPUs. --#if defined(KOKKOS_ARCH_KEPLER) || defined(KOKKOS_ARCH_MAXWELL) || \ -- defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -- defined(KOKKOS_ARCH_TURING75) || defined(KOKKOS_ARCH_AMPERE) -+#if defined(KOKKOS_ARCH_KEPLER) || defined(KOKKOS_ARCH_MAXWELL) || \ -+ defined(KOKKOS_ARCH_PASCAL) || defined(KOKKOS_ARCH_VOLTA) || \ -+ defined(KOKKOS_ARCH_TURING75) || defined(KOKKOS_ARCH_AMPERE) || \ -+ defined(KOKKOS_ARCH_HOPPER) - 256, - #endif - max_threads_for_memory diff --git a/lib/kokkos/kokkos_5706.diff b/lib/kokkos/kokkos_5706.diff deleted file mode 100644 index 2bfbb35b06..0000000000 --- a/lib/kokkos/kokkos_5706.diff +++ /dev/null @@ -1,523 +0,0 @@ -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -index fcd4773dbc..30b6958a67 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -@@ -207,7 +207,6 @@ int cuda_get_opt_block_size(const CudaInternal* cuda_instance, - LaunchBounds{}); - } - --// Assuming cudaFuncSetCacheConfig(MyKernel, cudaFuncCachePreferL1) - // NOTE these number can be obtained several ways: - // * One option is to download the CUDA Occupancy Calculator spreadsheet, select - // "Compute Capability" first and check what is the smallest "Shared Memory -@@ -242,6 +241,7 @@ inline size_t get_shmem_per_sm_prefer_l1(cudaDeviceProp const& properties) { - return 0; - }() * 1024; - } -+ - } // namespace Impl - } // namespace Kokkos - -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Instance.cpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Instance.cpp -index 5811498e01..e22eb3b842 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Instance.cpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Instance.cpp -@@ -569,12 +569,6 @@ Kokkos::Cuda::initialize WARNING: Cuda is allocating into UVMSpace by default - } - #endif - --#ifdef KOKKOS_ENABLE_PRE_CUDA_10_DEPRECATION_API -- cudaThreadSetCacheConfig(cudaFuncCachePreferShared); --#else -- cudaDeviceSetCacheConfig(cudaFuncCachePreferShared); --#endif -- - // Init the array for used for arbitrarily sized atomics - if (stream == nullptr) Impl::initialize_host_cuda_lock_arrays(); - -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -index b7a80ad84f..5c4c3a7d39 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -@@ -93,10 +93,6 @@ namespace Impl { - // __launch_bounds__(maxThreadsPerBlock,minBlocksPerMultiprocessor) - // function qualifier which could be used to improve performance. - //---------------------------------------------------------------------------- --// Maximize L1 cache and minimize shared memory: --// cudaFuncSetCacheConfig(MyKernel, cudaFuncCachePreferL1 ); --// For 2.0 capability: 48 KB L1 and 16 KB shared --//---------------------------------------------------------------------------- - - template - __global__ static void cuda_parallel_launch_constant_memory() { -@@ -158,63 +154,105 @@ inline void check_shmem_request(CudaInternal const* cuda_instance, int shmem) { - } - } - --// This function needs to be template on DriverType and LaunchBounds -+// These functions needs to be template on DriverType and LaunchBounds - // so that the static bool is unique for each type combo - // KernelFuncPtr does not necessarily contain that type information. -+ - template --inline void configure_shmem_preference(KernelFuncPtr const& func, -- bool prefer_shmem) { -+const cudaFuncAttributes& get_cuda_kernel_func_attributes( -+ const KernelFuncPtr& func) { -+ // Only call cudaFuncGetAttributes once for each unique kernel -+ // by leveraging static variable initialization rules -+ auto wrap_get_attributes = [&]() -> cudaFuncAttributes { -+ cudaFuncAttributes attr; -+ KOKKOS_IMPL_CUDA_SAFE_CALL(cudaFuncGetAttributes(&attr, func)); -+ return attr; -+ }; -+ static cudaFuncAttributes func_attr = wrap_get_attributes(); -+ return func_attr; -+} -+ -+template -+inline void configure_shmem_preference(const KernelFuncPtr& func, -+ const cudaDeviceProp& device_props, -+ const size_t block_size, int& shmem, -+ const size_t occupancy) { - #ifndef KOKKOS_ARCH_KEPLER -- // On Kepler the L1 has no benefit since it doesn't cache reads -+ -+ const auto& func_attr = -+ get_cuda_kernel_func_attributes(func); -+ -+ // Compute limits for number of blocks due to registers/SM -+ const size_t regs_per_sm = device_props.regsPerMultiprocessor; -+ const size_t regs_per_thread = func_attr.numRegs; -+ // The granularity of register allocation is chunks of 256 registers per warp -+ // -> 8 registers per thread -+ const size_t allocated_regs_per_thread = 8 * ((regs_per_thread + 8 - 1) / 8); -+ const size_t max_blocks_regs = -+ regs_per_sm / (allocated_regs_per_thread * block_size); -+ -+ // Compute how many threads per sm we actually want -+ const size_t max_threads_per_sm = device_props.maxThreadsPerMultiProcessor; -+ // only allocate multiples of warp size -+ const size_t num_threads_desired = -+ ((max_threads_per_sm * occupancy / 100 + 31) / 32) * 32; -+ // Get close to the desired occupancy, -+ // don't undershoot by much but also don't allocate a whole new block just -+ // because one is a few threads over otherwise. -+ size_t num_blocks_desired = -+ (num_threads_desired + block_size * 0.8) / block_size; -+ num_blocks_desired = ::std::min(max_blocks_regs, num_blocks_desired); -+ if (num_blocks_desired == 0) num_blocks_desired = 1; -+ -+ // Calculate how much shared memory we need per block -+ size_t shmem_per_block = shmem + func_attr.sharedSizeBytes; -+ -+ // The minimum shared memory allocation we can have in total per SM is 8kB. -+ // If we want to lower occupancy we have to make sure we request at least that -+ // much in aggregate over all blocks, so that shared memory actually becomes a -+ // limiting factor for occupancy -+ constexpr size_t min_shmem_size_per_sm = 8192; -+ if ((occupancy < 100) && -+ (shmem_per_block * num_blocks_desired < min_shmem_size_per_sm)) { -+ shmem_per_block = min_shmem_size_per_sm / num_blocks_desired; -+ // Need to set the caller's shmem variable so that the -+ // kernel launch uses the correct dynamic shared memory request -+ shmem = shmem_per_block - func_attr.sharedSizeBytes; -+ } -+ -+ // Compute the carveout fraction we need based on occupancy -+ // Use multiples of 8kB -+ const size_t max_shmem_per_sm = device_props.sharedMemPerMultiprocessor; -+ size_t carveout = shmem_per_block == 0 -+ ? 0 -+ : 100 * -+ (((num_blocks_desired * shmem_per_block + -+ min_shmem_size_per_sm - 1) / -+ min_shmem_size_per_sm) * -+ min_shmem_size_per_sm) / -+ max_shmem_per_sm; -+ if (carveout > 100) carveout = 100; -+ -+ // Set the carveout, but only call it once per kernel or when it changes - auto set_cache_config = [&] { -- KOKKOS_IMPL_CUDA_SAFE_CALL(cudaFuncSetCacheConfig( -- func, -- (prefer_shmem ? cudaFuncCachePreferShared : cudaFuncCachePreferL1))); -- return prefer_shmem; -+ KOKKOS_IMPL_CUDA_SAFE_CALL(cudaFuncSetAttribute( -+ func, cudaFuncAttributePreferredSharedMemoryCarveout, carveout)); -+ return carveout; - }; -- static bool cache_config_preference_cached = set_cache_config(); -- if (cache_config_preference_cached != prefer_shmem) { -+ // Store the value in a static variable so we only reset if needed -+ static size_t cache_config_preference_cached = set_cache_config(); -+ if (cache_config_preference_cached != carveout) { - cache_config_preference_cached = set_cache_config(); - } - #else - // Use the parameters so we don't get a warning - (void)func; -- (void)prefer_shmem; -+ (void)device_props; -+ (void)block_size; -+ (void)occupancy; - #endif - } - --template --std::enable_if_t --modify_launch_configuration_if_desired_occupancy_is_specified( -- Policy const& policy, cudaDeviceProp const& properties, -- cudaFuncAttributes const& attributes, dim3 const& block, int& shmem, -- bool& prefer_shmem) { -- int const block_size = block.x * block.y * block.z; -- int const desired_occupancy = policy.impl_get_desired_occupancy().value(); -- -- size_t const shmem_per_sm_prefer_l1 = get_shmem_per_sm_prefer_l1(properties); -- size_t const static_shmem = attributes.sharedSizeBytes; -- -- // round to nearest integer and avoid division by zero -- int active_blocks = std::max( -- 1, static_cast(std::round( -- static_cast(properties.maxThreadsPerMultiProcessor) / -- block_size * desired_occupancy / 100))); -- int const dynamic_shmem = -- shmem_per_sm_prefer_l1 / active_blocks - static_shmem; -- -- if (dynamic_shmem > shmem) { -- shmem = dynamic_shmem; -- prefer_shmem = false; -- } --} -- --template --std::enable_if_t --modify_launch_configuration_if_desired_occupancy_is_specified( -- Policy const&, cudaDeviceProp const&, cudaFuncAttributes const&, -- dim3 const& /*block*/, int& /*shmem*/, bool& /*prefer_shmem*/) {} -- - // end Some helper functions for launch code readability }}}1 - //============================================================================== - -@@ -348,7 +386,7 @@ struct CudaParallelLaunchKernelInvoker< - #ifdef KOKKOS_CUDA_ENABLE_GRAPHS - inline static void create_parallel_launch_graph_node( - DriverType const& driver, dim3 const& grid, dim3 const& block, int shmem, -- CudaInternal const* cuda_instance, bool prefer_shmem) { -+ CudaInternal const* cuda_instance) { - //---------------------------------------- - auto const& graph = Impl::get_cuda_graph_from_kernel(driver); - KOKKOS_EXPECTS(bool(graph)); -@@ -358,8 +396,15 @@ struct CudaParallelLaunchKernelInvoker< - - if (!Impl::is_empty_launch(grid, block)) { - Impl::check_shmem_request(cuda_instance, shmem); -- Impl::configure_shmem_preference( -- base_t::get_kernel_func(), prefer_shmem); -+ if (DriverType::Policy:: -+ experimental_contains_desired_occupancy) { -+ int desired_occupancy = -+ driver.get_policy().impl_get_desired_occupancy().value(); -+ size_t block_size = block.x * block.y * block.z; -+ Impl::configure_shmem_preference( -+ base_t::get_kernel_func(), cuda_instance->m_deviceProp, block_size, -+ shmem, desired_occupancy); -+ } - - void const* args[] = {&driver}; - -@@ -442,7 +487,7 @@ struct CudaParallelLaunchKernelInvoker< - #ifdef KOKKOS_CUDA_ENABLE_GRAPHS - inline static void create_parallel_launch_graph_node( - DriverType const& driver, dim3 const& grid, dim3 const& block, int shmem, -- CudaInternal const* cuda_instance, bool prefer_shmem) { -+ CudaInternal const* cuda_instance) { - //---------------------------------------- - auto const& graph = Impl::get_cuda_graph_from_kernel(driver); - KOKKOS_EXPECTS(bool(graph)); -@@ -452,8 +497,15 @@ struct CudaParallelLaunchKernelInvoker< - - if (!Impl::is_empty_launch(grid, block)) { - Impl::check_shmem_request(cuda_instance, shmem); -- Impl::configure_shmem_preference( -- base_t::get_kernel_func(), prefer_shmem); -+ if constexpr (DriverType::Policy:: -+ experimental_contains_desired_occupancy) { -+ int desired_occupancy = -+ driver.get_policy().impl_get_desired_occupancy().value(); -+ size_t block_size = block.x * block.y * block.z; -+ Impl::configure_shmem_preference( -+ base_t::get_kernel_func(), cuda_instance->m_deviceProp, block_size, -+ shmem, desired_occupancy); -+ } - - auto* driver_ptr = Impl::allocate_driver_storage_for_kernel(driver); - -@@ -566,7 +618,7 @@ struct CudaParallelLaunchKernelInvoker< - #ifdef KOKKOS_CUDA_ENABLE_GRAPHS - inline static void create_parallel_launch_graph_node( - DriverType const& driver, dim3 const& grid, dim3 const& block, int shmem, -- CudaInternal const* cuda_instance, bool prefer_shmem) { -+ CudaInternal const* cuda_instance) { - // Just use global memory; coordinating through events to share constant - // memory with the non-graph interface is not really reasonable since - // events don't work with Graphs directly, and this would anyway require -@@ -580,7 +632,7 @@ struct CudaParallelLaunchKernelInvoker< - DriverType, LaunchBounds, - Experimental::CudaLaunchMechanism::GlobalMemory>; - global_launch_impl_t::create_parallel_launch_graph_node( -- driver, grid, block, shmem, cuda_instance, prefer_shmem); -+ driver, grid, block, shmem, cuda_instance); - } - #endif - }; -@@ -613,8 +665,7 @@ struct CudaParallelLaunchImpl< - - inline static void launch_kernel(const DriverType& driver, const dim3& grid, - const dim3& block, int shmem, -- const CudaInternal* cuda_instance, -- bool prefer_shmem) { -+ const CudaInternal* cuda_instance) { - if (!Impl::is_empty_launch(grid, block)) { - // Prevent multiple threads to simultaneously set the cache configuration - // preference and launch the same kernel -@@ -623,18 +674,17 @@ struct CudaParallelLaunchImpl< - - Impl::check_shmem_request(cuda_instance, shmem); - -- // If a desired occupancy is specified, we compute how much shared memory -- // to ask for to achieve that occupancy, assuming that the cache -- // configuration is `cudaFuncCachePreferL1`. If the amount of dynamic -- // shared memory computed is actually smaller than `shmem` we overwrite -- // `shmem` and set `prefer_shmem` to `false`. -- modify_launch_configuration_if_desired_occupancy_is_specified( -- driver.get_policy(), cuda_instance->m_deviceProp, -- get_cuda_func_attributes(), block, shmem, prefer_shmem); -- -- Impl::configure_shmem_preference< -- DriverType, Kokkos::LaunchBounds>( -- base_t::get_kernel_func(), prefer_shmem); -+ if (DriverType::Policy:: -+ experimental_contains_desired_occupancy) { -+ int desired_occupancy = -+ driver.get_policy().impl_get_desired_occupancy().value(); -+ size_t block_size = block.x * block.y * block.z; -+ Impl::configure_shmem_preference< -+ DriverType, -+ Kokkos::LaunchBounds>( -+ base_t::get_kernel_func(), cuda_instance->m_deviceProp, block_size, -+ shmem, desired_occupancy); -+ } - - KOKKOS_ENSURE_CUDA_LOCK_ARRAYS_ON_DEVICE(); - -@@ -650,18 +700,9 @@ struct CudaParallelLaunchImpl< - } - - static cudaFuncAttributes get_cuda_func_attributes() { -- // Race condition inside of cudaFuncGetAttributes if the same address is -- // given requires using a local variable as input instead of a static Rely -- // on static variable initialization to make sure only one thread executes -- // the code and the result is visible. -- auto wrap_get_attributes = []() -> cudaFuncAttributes { -- cudaFuncAttributes attr_tmp; -- KOKKOS_IMPL_CUDA_SAFE_CALL( -- cudaFuncGetAttributes(&attr_tmp, base_t::get_kernel_func())); -- return attr_tmp; -- }; -- static cudaFuncAttributes attr = wrap_get_attributes(); -- return attr; -+ return get_cuda_kernel_func_attributes< -+ DriverType, Kokkos::LaunchBounds>( -+ base_t::get_kernel_func()); - } - }; - -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp -index e586bb4cc6..0e348c092a 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp -@@ -121,8 +121,7 @@ class ParallelFor, Kokkos::Cuda> { - maxblocks[1]), - 1); - CudaParallelLaunch( -- *this, grid, block, 0, m_rp.space().impl_internal_space_instance(), -- false); -+ *this, grid, block, 0, m_rp.space().impl_internal_space_instance()); - } else if (RP::rank == 3) { - const dim3 block(m_rp.m_tile[0], m_rp.m_tile[1], m_rp.m_tile[2]); - KOKKOS_ASSERT(block.x > 0); -@@ -139,8 +138,7 @@ class ParallelFor, Kokkos::Cuda> { - (m_rp.m_upper[2] - m_rp.m_lower[2] + block.z - 1) / block.z, - maxblocks[2])); - CudaParallelLaunch( -- *this, grid, block, 0, m_rp.space().impl_internal_space_instance(), -- false); -+ *this, grid, block, 0, m_rp.space().impl_internal_space_instance()); - } else if (RP::rank == 4) { - // id0,id1 encoded within threadIdx.x; id2 to threadIdx.y; id3 to - // threadIdx.z -@@ -158,8 +156,7 @@ class ParallelFor, Kokkos::Cuda> { - (m_rp.m_upper[3] - m_rp.m_lower[3] + block.z - 1) / block.z, - maxblocks[2])); - CudaParallelLaunch( -- *this, grid, block, 0, m_rp.space().impl_internal_space_instance(), -- false); -+ *this, grid, block, 0, m_rp.space().impl_internal_space_instance()); - } else if (RP::rank == 5) { - // id0,id1 encoded within threadIdx.x; id2,id3 to threadIdx.y; id4 to - // threadIdx.z -@@ -175,8 +172,7 @@ class ParallelFor, Kokkos::Cuda> { - (m_rp.m_upper[4] - m_rp.m_lower[4] + block.z - 1) / block.z, - maxblocks[2])); - CudaParallelLaunch( -- *this, grid, block, 0, m_rp.space().impl_internal_space_instance(), -- false); -+ *this, grid, block, 0, m_rp.space().impl_internal_space_instance()); - } else if (RP::rank == 6) { - // id0,id1 encoded within threadIdx.x; id2,id3 to threadIdx.y; id4,id5 to - // threadIdx.z -@@ -191,8 +187,7 @@ class ParallelFor, Kokkos::Cuda> { - std::min(m_rp.m_tile_end[4] * m_rp.m_tile_end[5], - maxblocks[2])); - CudaParallelLaunch( -- *this, grid, block, 0, m_rp.space().impl_internal_space_instance(), -- false); -+ *this, grid, block, 0, m_rp.space().impl_internal_space_instance()); - } else { - Kokkos::abort("Kokkos::MDRange Error: Exceeded rank bounds with Cuda\n"); - } -@@ -405,8 +400,8 @@ class ParallelReduce, ReducerType, - - CudaParallelLaunch( - *this, grid, block, shmem, -- m_policy.space().impl_internal_space_instance(), -- false); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - - if (!m_result_ptr_device_accessible) { - if (m_result_ptr) { -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Range.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Range.hpp -index ac160f8fe2..d1031751c2 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Range.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Range.hpp -@@ -135,8 +135,7 @@ class ParallelFor, Kokkos::Cuda> { - #endif - - CudaParallelLaunch( -- *this, grid, block, 0, m_policy.space().impl_internal_space_instance(), -- false); -+ *this, grid, block, 0, m_policy.space().impl_internal_space_instance()); - } - - ParallelFor(const FunctorType& arg_functor, const Policy& arg_policy) -@@ -375,8 +374,8 @@ class ParallelReduce, ReducerType, - - CudaParallelLaunch( - *this, grid, block, shmem, -- m_policy.space().impl_internal_space_instance(), -- false); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - - if (!m_result_ptr_device_accessible) { - if (m_result_ptr) { -@@ -726,16 +725,16 @@ class ParallelScan, Kokkos::Cuda> { - m_final = false; - CudaParallelLaunch( - *this, grid, block, shmem, -- m_policy.space().impl_internal_space_instance(), -- false); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - #ifdef KOKKOS_IMPL_DEBUG_CUDA_SERIAL_EXECUTION - } - #endif - m_final = true; - CudaParallelLaunch( - *this, grid, block, shmem, -- m_policy.space().impl_internal_space_instance(), -- false); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - } - } - -@@ -1038,16 +1037,16 @@ class ParallelScanWithTotal, - m_final = false; - CudaParallelLaunch( - *this, grid, block, shmem, -- m_policy.space().impl_internal_space_instance(), -- false); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - #ifdef KOKKOS_IMPL_DEBUG_CUDA_SERIAL_EXECUTION - } - #endif - m_final = true; - CudaParallelLaunch( - *this, grid, block, shmem, -- m_policy.space().impl_internal_space_instance(), -- false); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - - const int size = Analysis::value_size(m_functor); - #ifdef KOKKOS_IMPL_DEBUG_CUDA_SERIAL_EXECUTION -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp -index cdd16085b3..ea9430b812 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp -@@ -552,8 +552,8 @@ class ParallelFor, - - CudaParallelLaunch( - *this, grid, block, shmem_size_total, -- m_policy.space().impl_internal_space_instance(), -- true); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - } - - ParallelFor(const FunctorType& arg_functor, const Policy& arg_policy) -@@ -878,8 +878,8 @@ class ParallelReduce, - - CudaParallelLaunch( - *this, grid, block, shmem_size_total, -- m_policy.space().impl_internal_space_instance(), -- true); // copy to device and execute -+ m_policy.space() -+ .impl_internal_space_instance()); // copy to device and execute - - if (!m_result_ptr_device_accessible) { - m_policy.space().fence( -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_ReduceScan.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_ReduceScan.hpp -index 34d4bef9fd..178012431c 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_ReduceScan.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_ReduceScan.hpp -@@ -428,11 +428,6 @@ struct CudaReductionsFunctor { - // __launch_bounds__(maxThreadsPerBlock,minBlocksPerMultiprocessor) - // function qualifier which could be used to improve performance. - //---------------------------------------------------------------------------- --// Maximize shared memory and minimize L1 cache: --// cudaFuncSetCacheConfig(MyKernel, cudaFuncCachePreferShared ); --// For 2.0 capability: 48 KB shared and 16 KB L1 --//---------------------------------------------------------------------------- --//---------------------------------------------------------------------------- - /* - * Algorithmic constraints: - * (a) blockDim.y <= 1024 -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_WorkGraphPolicy.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_WorkGraphPolicy.hpp -index fb3a6b138f..a12378a891 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_WorkGraphPolicy.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_WorkGraphPolicy.hpp -@@ -100,8 +100,7 @@ class ParallelFor, - const int shared = 0; - - Kokkos::Impl::CudaParallelLaunch( -- *this, grid, block, shared, Cuda().impl_internal_space_instance(), -- false); -+ *this, grid, block, shared, Cuda().impl_internal_space_instance()); - } - - inline ParallelFor(const FunctorType& arg_functor, const Policy& arg_policy) diff --git a/lib/kokkos/kokkos_5731.diff b/lib/kokkos/kokkos_5731.diff deleted file mode 100644 index e95f4a1546..0000000000 --- a/lib/kokkos/kokkos_5731.diff +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -index 30b6958a67..b94f053272 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -@@ -207,41 +207,6 @@ int cuda_get_opt_block_size(const CudaInternal* cuda_instance, - LaunchBounds{}); - } - --// NOTE these number can be obtained several ways: --// * One option is to download the CUDA Occupancy Calculator spreadsheet, select --// "Compute Capability" first and check what is the smallest "Shared Memory --// Size Config" that is available. The "Shared Memory Per Multiprocessor" in --// bytes is then to be found below in the summary. --// * Another option would be to look for the information in the "Tuning --// Guide(s)" of the CUDA Toolkit Documentation for each GPU architecture, in --// the "Shared Memory" section (more tedious) --inline size_t get_shmem_per_sm_prefer_l1(cudaDeviceProp const& properties) { -- int const compute_capability = properties.major * 10 + properties.minor; -- return [compute_capability]() { -- switch (compute_capability) { -- case 30: -- case 32: -- case 35: return 16; -- case 37: return 80; -- case 50: -- case 53: -- case 60: -- case 62: return 64; -- case 52: -- case 61: return 96; -- case 70: -- case 80: -- case 86: -- case 90: return 8; -- case 75: return 32; -- default: -- Kokkos::Impl::throw_runtime_exception( -- "Unknown device in cuda block size deduction"); -- } -- return 0; -- }() * 1024; --} -- - } // namespace Impl - } // namespace Kokkos - diff --git a/lib/kokkos/kokkos_5739.diff b/lib/kokkos/kokkos_5739.diff deleted file mode 100644 index fe7a1ff551..0000000000 --- a/lib/kokkos/kokkos_5739.diff +++ /dev/null @@ -1,204 +0,0 @@ -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -index b94f053272..252c13c524 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_BlockSize_Deduction.hpp -@@ -53,17 +53,69 @@ - namespace Kokkos { - namespace Impl { - -+inline int cuda_warp_per_sm_allocation_granularity( -+ cudaDeviceProp const& properties) { -+ // Allocation granularity of warps in each sm -+ switch (properties.major) { -+ case 3: -+ case 5: -+ case 7: -+ case 8: -+ case 9: return 4; -+ case 6: return (properties.minor == 0 ? 2 : 4); -+ default: -+ throw_runtime_exception( -+ "Unknown device in cuda warp per sm allocation granularity"); -+ return 0; -+ } -+} -+ -+inline int cuda_max_warps_per_sm_registers( -+ cudaDeviceProp const& properties, cudaFuncAttributes const& attributes) { -+ // Maximum number of warps per sm as a function of register counts, -+ // subject to the constraint that warps are allocated with a fixed granularity -+ int const max_regs_per_block = properties.regsPerBlock; -+ int const regs_per_warp = attributes.numRegs * properties.warpSize; -+ int const warp_granularity = -+ cuda_warp_per_sm_allocation_granularity(properties); -+ // The granularity of register allocation is chunks of 256 registers per warp, -+ // which implies a need to over-allocate, so we round up -+ int const allocated_regs_per_warp = (regs_per_warp + 256 - 1) / 256; -+ -+ // The maximum number of warps per SM is constrained from above by register -+ // allocation. To satisfy the constraint that warps per SM is allocated at a -+ // finite granularity, we need to round down. -+ int const max_warps_per_sm = -+ warp_granularity * -+ (max_regs_per_block / (allocated_regs_per_warp * warp_granularity)); -+ -+ return max_warps_per_sm; -+} -+ - inline int cuda_max_active_blocks_per_sm(cudaDeviceProp const& properties, - cudaFuncAttributes const& attributes, - int block_size, size_t dynamic_shmem) { -- // Limits due do registers/SM -+ // Limits due to registers/SM - int const regs_per_sm = properties.regsPerMultiprocessor; - int const regs_per_thread = attributes.numRegs; - // The granularity of register allocation is chunks of 256 registers per warp - // -> 8 registers per thread - int const allocated_regs_per_thread = 8 * ((regs_per_thread + 8 - 1) / 8); -- int const max_blocks_regs = -- regs_per_sm / (allocated_regs_per_thread * block_size); -+ int max_blocks_regs = regs_per_sm / (allocated_regs_per_thread * block_size); -+ -+ // Compute the maximum number of warps as a function of the number of -+ // registers -+ int const max_warps_per_sm_registers = -+ cuda_max_warps_per_sm_registers(properties, attributes); -+ -+ // Constrain the number of blocks to respect the maximum number of warps per -+ // SM On face value this should be an equality, but due to the warp -+ // granularity constraints noted in `cuda_max_warps_per_sm_registers` the -+ // left-hand-side of this comparison can overshoot what the hardware allows -+ // based on register counts alone -+ while ((max_blocks_regs * block_size / properties.warpSize) > -+ max_warps_per_sm_registers) -+ max_blocks_regs--; - - // Limits due to shared memory/SM - size_t const shmem_per_sm = properties.sharedMemPerMultiprocessor; -@@ -207,6 +259,19 @@ int cuda_get_opt_block_size(const CudaInternal* cuda_instance, - LaunchBounds{}); - } - -+template -+int cuda_get_opt_block_size_no_shmem(const cudaFuncAttributes& attr, -+ LaunchBounds) { -+ auto const& prop = Kokkos::Cuda().cuda_device_prop(); -+ -+ // Thin version of cuda_get_opt_block_size for cases where there is no shared -+ // memory -+ auto const block_size_to_no_shmem = [&](int /*block_size*/) { return 0; }; -+ -+ return cuda_deduce_block_size(false, prop, attr, block_size_to_no_shmem, -+ LaunchBounds{}); -+} -+ - } // namespace Impl - } // namespace Kokkos - -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -index 5c4c3a7d39..170183ca0a 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -@@ -188,9 +188,23 @@ inline void configure_shmem_preference(const KernelFuncPtr& func, - // The granularity of register allocation is chunks of 256 registers per warp - // -> 8 registers per thread - const size_t allocated_regs_per_thread = 8 * ((regs_per_thread + 8 - 1) / 8); -- const size_t max_blocks_regs = -+ size_t max_blocks_regs = - regs_per_sm / (allocated_regs_per_thread * block_size); - -+ // Compute the maximum number of warps as a function of the number of -+ // registers -+ const size_t max_warps_per_sm_registers = -+ cuda_max_warps_per_sm_registers(device_props, func_attr); -+ -+ // Constrain the number of blocks to respect the maximum number of warps per -+ // SM On face value this should be an equality, but due to the warp -+ // granularity constraints noted in `cuda_max_warps_per_sm_registers` the -+ // left-hand-side of this comparison can overshoot what the hardware allows -+ // based on register counts alone -+ while ((max_blocks_regs * block_size / device_props.warpSize) > -+ max_warps_per_sm_registers) -+ max_blocks_regs--; -+ - // Compute how many threads per sm we actually want - const size_t max_threads_per_sm = device_props.maxThreadsPerMultiProcessor; - // only allocate multiples of warp size -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp -index 0e348c092a..7e4f62f12e 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp -@@ -67,6 +67,34 @@ - namespace Kokkos { - namespace Impl { - -+template -+int max_tile_size_product_helper(const Policy& pol, const LaunchBounds&) { -+ cudaFuncAttributes attr = -+ CudaParallelLaunch::get_cuda_func_attributes(); -+ auto const& prop = pol.space().cuda_device_prop(); -+ -+ // Limits due to registers/SM, MDRange doesn't have -+ // shared memory constraints -+ int const optimal_block_size = -+ Kokkos::Impl::cuda_get_opt_block_size_no_shmem(attr, LaunchBounds{}); -+ -+ // Compute how many blocks of this size we can launch, based on warp -+ // constraints -+ int const max_warps_per_sm_registers = -+ Kokkos::Impl::cuda_max_warps_per_sm_registers(prop, attr); -+ int const max_num_threads_from_warps = -+ max_warps_per_sm_registers * prop.warpSize; -+ int const max_num_blocks = max_num_threads_from_warps / optimal_block_size; -+ -+ // Compute the total number of threads -+ int const max_threads_per_sm = optimal_block_size * max_num_blocks; -+ -+ return std::min( -+ max_threads_per_sm, -+ static_cast(Kokkos::Impl::CudaTraits::MaxHierarchicalParallelism)); -+} -+ - template - class ParallelFor, Kokkos::Cuda> { - public: -@@ -85,18 +113,7 @@ class ParallelFor, Kokkos::Cuda> { - public: - template - static int max_tile_size_product(const Policy& pol, const Functor&) { -- cudaFuncAttributes attr = -- CudaParallelLaunch::get_cuda_func_attributes(); -- auto const& prop = pol.space().cuda_device_prop(); -- // Limits due to registers/SM, MDRange doesn't have -- // shared memory constraints -- int const regs_per_sm = prop.regsPerMultiprocessor; -- int const regs_per_thread = attr.numRegs; -- int const max_threads_per_sm = regs_per_sm / regs_per_thread; -- return std::min( -- max_threads_per_sm, -- static_cast(Kokkos::Impl::CudaTraits::MaxHierarchicalParallelism)); -+ return max_tile_size_product_helper(pol, LaunchBounds{}); - } - Policy const& get_policy() const { return m_rp; } - inline __device__ void operator()() const { -@@ -258,17 +275,7 @@ class ParallelReduce, ReducerType, - public: - template - static int max_tile_size_product(const Policy& pol, const Functor&) { -- cudaFuncAttributes attr = -- CudaParallelLaunch::get_cuda_func_attributes(); -- auto const& prop = pol.space().cuda_device_prop(); -- // Limits due do registers/SM -- int const regs_per_sm = prop.regsPerMultiprocessor; -- int const regs_per_thread = attr.numRegs; -- int const max_threads_per_sm = regs_per_sm / regs_per_thread; -- return std::min( -- max_threads_per_sm, -- static_cast(Kokkos::Impl::CudaTraits::MaxHierarchicalParallelism)); -+ return max_tile_size_product_helper(pol, LaunchBounds{}); - } - Policy const& get_policy() const { return m_policy; } - inline __device__ void exec_range(reference_type update) const { diff --git a/lib/kokkos/kokkos_fix_5706_apply_last.diff b/lib/kokkos/kokkos_fix_5706_apply_last.diff deleted file mode 100644 index 5d298323fd..0000000000 --- a/lib/kokkos/kokkos_fix_5706_apply_last.diff +++ /dev/null @@ -1,63 +0,0 @@ -diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -index 170183ca0a..ba43e362bb 100644 ---- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -+++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_KernelLaunch.hpp -@@ -412,12 +412,16 @@ struct CudaParallelLaunchKernelInvoker< - Impl::check_shmem_request(cuda_instance, shmem); - if (DriverType::Policy:: - experimental_contains_desired_occupancy) { -+ /* - int desired_occupancy = - driver.get_policy().impl_get_desired_occupancy().value(); - size_t block_size = block.x * block.y * block.z; - Impl::configure_shmem_preference( - base_t::get_kernel_func(), cuda_instance->m_deviceProp, block_size, -- shmem, desired_occupancy); -+ shmem, desired_occupancy);*/ -+ Kokkos::Impl::throw_runtime_exception( -+ std::string("Cuda graph node creation FAILED:" -+ " occupancy requests are currently broken.")); - } - - void const* args[] = {&driver}; -@@ -511,14 +515,17 @@ struct CudaParallelLaunchKernelInvoker< - - if (!Impl::is_empty_launch(grid, block)) { - Impl::check_shmem_request(cuda_instance, shmem); -- if constexpr (DriverType::Policy:: -+ if (DriverType::Policy:: - experimental_contains_desired_occupancy) { -- int desired_occupancy = -+ /*int desired_occupancy = - driver.get_policy().impl_get_desired_occupancy().value(); - size_t block_size = block.x * block.y * block.z; - Impl::configure_shmem_preference( - base_t::get_kernel_func(), cuda_instance->m_deviceProp, block_size, -- shmem, desired_occupancy); -+ shmem, desired_occupancy);*/ -+ Kokkos::Impl::throw_runtime_exception( -+ std::string("Cuda graph node creation FAILED:" -+ " occupancy requests are currently broken.")); - } - - auto* driver_ptr = Impl::allocate_driver_storage_for_kernel(driver); -@@ -690,14 +697,17 @@ struct CudaParallelLaunchImpl< - - if (DriverType::Policy:: - experimental_contains_desired_occupancy) { -- int desired_occupancy = -+ /*int desired_occupancy = - driver.get_policy().impl_get_desired_occupancy().value(); - size_t block_size = block.x * block.y * block.z; - Impl::configure_shmem_preference< - DriverType, - Kokkos::LaunchBounds>( - base_t::get_kernel_func(), cuda_instance->m_deviceProp, block_size, -- shmem, desired_occupancy); -+ shmem, desired_occupancy);*/ -+ Kokkos::Impl::throw_runtime_exception( -+ std::string("Cuda graph node creation FAILED:" -+ " occupancy requests are currently broken.")); - } - - KOKKOS_ENSURE_CUDA_LOCK_ARRAYS_ON_DEVICE(); From f99853fab8020b603453e1367d059481d0adea88 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:30:12 -0700 Subject: [PATCH 40/43] Update example with new syntax --- examples/meam/msmeam/potential.mod | 2 +- examples/meam/msmeam/test.log.bu | 107 ----------------------------- 2 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 examples/meam/msmeam/test.log.bu diff --git a/examples/meam/msmeam/potential.mod b/examples/meam/msmeam/potential.mod index 37596ce725..760cc93503 100644 --- a/examples/meam/msmeam/potential.mod +++ b/examples/meam/msmeam/potential.mod @@ -4,7 +4,7 @@ variable Pu string H print "potential chosen ${Pu}" # Choose potential -pair_style meam ms # the `ms` flag turns on MS-MEAM +pair_style meam/ms print "we just executed" pair_coeff * * library.msmeam ${Pu} Ga4 HGa.meam ${Pu} Ga4 diff --git a/examples/meam/msmeam/test.log.bu b/examples/meam/msmeam/test.log.bu deleted file mode 100644 index e7e414dbd4..0000000000 --- a/examples/meam/msmeam/test.log.bu +++ /dev/null @@ -1,107 +0,0 @@ -# Test of MEAM potential for HGa - -# ------------------------ INITIALIZATION ---------------------------- -units metal -dimension 3 -boundary p p p -atom_style atomic -variable latparam equal 4.646 -variable ncell equal 3 - -# ----------------------- ATOM DEFINITION ---------------------------- -region box block -4 4 -4 4 -4 4 -create_box 2 box -Created orthogonal box = (-4 -4 -4) to (4 4 4) - 1 by 1 by 1 MPI processor grid - -# - -include potential.mod -# NOTE: This script can be modified for different pair styles -# See in.elastic for more info. - -variable Pu string H -print "potential chosen ${Pu}" -potential chosen H -# Choose potential -pair_style MSmeam -print "we just executed" -we just executed - -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 -Reading potential file library.MSmeam with DATE: 2018-09-22 -# Setup neighbor style -neighbor 1.0 nsq -neigh_modify once no every 1 delay 0 check yes - -# Setup minimization style -variable dmax equal 1.0e-2 -min_style cg -min_modify dmax ${dmax} line quadratic -min_modify dmax 0.01 line quadratic -compute eng all pe/atom -compute eatoms all reduce sum c_eng - -# Setup output -thermo 100 -thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms -thermo_modify norm yes -create_atoms 1 single 0 0 0 units box -Created 1 atoms -create_atoms 2 single 2.2 0 0 units box -Created 1 atoms -create_atoms 2 single 0.3 2.3 0 units box -Created 1 atoms -# ---------- Define Settings --------------------- -variable teng equal "c_eatoms" -compute pot_energy all pe/atom -compute stress all stress/atom NULL -dump 1 all custom 1 test.dump id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -WARNING: No fixes defined, atoms won't move (../verlet.cpp:55) -Neighbor list info ... - 2 neighbor list requests - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.9 - ghost atom cutoff = 6.9 -Memory usage per processor = 12.9295 Mbytes -Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume eatoms - 0 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 - 1 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 -Loop time of 0.000172138 on 1 procs for 1 steps with 3 atoms - -Performance: 501.922 ns/day, 0.048 hours/ns, 5809.285 timesteps/s -81.3% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 6.6996e-05 | 6.6996e-05 | 6.6996e-05 | 0.0 | 38.92 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 1.9073e-06 | 1.9073e-06 | 1.9073e-06 | 0.0 | 1.11 -Output | 9.7036e-05 | 9.7036e-05 | 9.7036e-05 | 0.0 | 56.37 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 6.199e-06 | | | 3.60 - -Nlocal: 3 ave 3 max 3 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 78 ave 78 max 78 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 7 ave 7 max 7 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 14 ave 14 max 14 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 14 -Ave neighs/atom = 4.66667 -Neighbor list builds = 0 -Dangerous builds = 0 -write_data test.data - -print "All done!" -All done! -Total wall time: 0:00:00 - From 6c8aec1ff452ac05dc4294d52ab3421c5f6e96d9 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:35:08 -0700 Subject: [PATCH 41/43] whitespace --- examples/meam/in.meam | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/meam/in.meam b/examples/meam/in.meam index cfaf1db7c3..b4463be365 100644 --- a/examples/meam/in.meam +++ b/examples/meam/in.meam @@ -28,4 +28,3 @@ timestep 0.001 #dump_modify 3 pad 3 element Si C run 100 - From 2f8ba9dd324aecdba9cd2426203bf777642b78ec Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 26 Jan 2023 15:47:22 -0700 Subject: [PATCH 42/43] cleanup --- examples/meam/msmeam/data.msmeam | 25 ------------------------- examples/meam/msmeam/msmeam.data | 25 ------------------------- 2 files changed, 50 deletions(-) delete mode 100644 examples/meam/msmeam/data.msmeam delete mode 100644 examples/meam/msmeam/msmeam.data diff --git a/examples/meam/msmeam/data.msmeam b/examples/meam/msmeam/data.msmeam deleted file mode 100644 index 69be174e2d..0000000000 --- a/examples/meam/msmeam/data.msmeam +++ /dev/null @@ -1,25 +0,0 @@ -LAMMPS data file via write_data, version 22 Dec 2022, timestep = 1 - -3 atoms -2 atom types - --4 4 xlo xhi --4 4 ylo yhi --4 4 zlo zhi - -Masses - -1 1.0079 -2 69.723 - -Atoms # atomic/kk - -1 1 0 0 0 0 0 0 -2 2 2.2 0 0 0 0 0 -3 2 0.3 2.3 0 0 0 0 - -Velocities - -1 0 0 0 -2 0 0 0 -3 0 0 0 diff --git a/examples/meam/msmeam/msmeam.data b/examples/meam/msmeam/msmeam.data deleted file mode 100644 index 69be174e2d..0000000000 --- a/examples/meam/msmeam/msmeam.data +++ /dev/null @@ -1,25 +0,0 @@ -LAMMPS data file via write_data, version 22 Dec 2022, timestep = 1 - -3 atoms -2 atom types - --4 4 xlo xhi --4 4 ylo yhi --4 4 zlo zhi - -Masses - -1 1.0079 -2 69.723 - -Atoms # atomic/kk - -1 1 0 0 0 0 0 0 -2 2 2.2 0 0 0 0 0 -3 2 0.3 2.3 0 0 0 0 - -Velocities - -1 0 0 0 -2 0 0 0 -3 0 0 0 From 3bcb59b28466d76d112ede03517de16d7a8859af Mon Sep 17 00:00:00 2001 From: rohskopf Date: Thu, 26 Jan 2023 18:24:39 -0700 Subject: [PATCH 43/43] Minor typo in docs --- doc/src/pair_meam.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/pair_meam.rst b/doc/src/pair_meam.rst index 5a85d6b3e7..57c40aa6ee 100644 --- a/doc/src/pair_meam.rst +++ b/doc/src/pair_meam.rst @@ -58,7 +58,7 @@ been removed from LAMMPS after the 12 December 2018 release. Pair style *meam/ms* uses the multi-state MEAM (MS-MEAM) method according to :ref:`(Baskes2) `, which is an extension to MEAM. -This pair style is mostly equivalent to *meam* and is use differs only +This pair style is mostly equivalent to *meam* and differs only where noted in the documentation below. In the MEAM formulation, the total energy E of a system of atoms is