From 5f607fad5694e4866da35472a8354439a5968952 Mon Sep 17 00:00:00 2001 From: phankl Date: Tue, 11 Jan 2022 16:46:50 +0000 Subject: [PATCH 01/72] optimised memory management in chain generation --- src/MESONT/pair_mesocnt.cpp | 118 +++++++++++++++++++----------------- src/MESONT/pair_mesocnt.h | 1 - 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index 9ba677b31d..b840c8fd4b 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -73,8 +73,6 @@ PairMesoCNT::~PairMesoCNT() memory->destroy(phi_coeff); memory->destroy(usemi_coeff); - memory->destroy(reduced_neighlist); - memory->destroy(reduced_nlist); memory->destroy(numchainlist); memory->destroy(nchainlist); memory->destroy(endlist); @@ -388,8 +386,7 @@ void PairMesoCNT::allocate() { allocated = 1; int ntypes = atom->ntypes; - nlocal_size = 512; - reduced_neigh_size = 64; + int init_size = 64; memory->create(cutsq,ntypes+1,ntypes+1,"pair:cutsq"); memory->create(setflag,ntypes+1,ntypes+1,"pair:setflag"); @@ -402,21 +399,17 @@ void PairMesoCNT::allocate() memory->create(phi_coeff,phi_points,phi_points,4,4,"pair:phi_coeff"); memory->create(usemi_coeff,usemi_points,usemi_points,4,4,"pair:usemi_coeff"); - memory->create(reduced_nlist,nlocal_size,"pair:reduced_nlist"); - memory->create(numchainlist,nlocal_size,"pair:numchainlist"); + memory->create(numchainlist,init_size,"pair:numchainlist"); + memory->create(nchainlist,init_size,init_size,"pair:nchainlist"); + memory->create(endlist,init_size,init_size,"pair:endlist"); + memory->create(chainlist,init_size, + init_size,init_size,"pair:chainlist"); - memory->create(reduced_neighlist, - nlocal_size,reduced_neigh_size,"pair:reduced_neighlist"); - memory->create(nchainlist,nlocal_size,reduced_neigh_size,"pair:nchainlist"); - memory->create(endlist,nlocal_size,reduced_neigh_size,"pair:endlist"); - memory->create(chainlist,nlocal_size, - reduced_neigh_size,reduced_neigh_size,"pair:chainlist"); - - memory->create(w,reduced_neigh_size,"pair:w"); - memory->create(wnode,reduced_neigh_size,"pair:wnode"); - memory->create(dq_w,reduced_neigh_size,3,"pair:dq_w"); - memory->create(q1_dq_w,reduced_neigh_size,3,3,"pair:q1_dq_w"); - memory->create(q2_dq_w,reduced_neigh_size,3,3,"pair:q2_dq_w"); + memory->create(w,init_size,"pair:w"); + memory->create(wnode,init_size,"pair:wnode"); + memory->create(dq_w,init_size,3,"pair:dq_w"); + memory->create(q1_dq_w,init_size,3,3,"pair:q1_dq_w"); + memory->create(q2_dq_w,init_size,3,3,"pair:q2_dq_w"); memory->create(param,7,"pair:param"); @@ -528,11 +521,6 @@ void PairMesoCNT::bond_neigh() int nbondlist = neighbor->nbondlist; int nlocal = atom->nlocal; - int update_memory = 0; - if (nbondlist > nlocal_size) { - nlocal_size = 2 * nbondlist; - update_memory = 1; - } int *numneigh = list->numneigh; int numneigh_max = 0; for (int i = 0; i < nbondlist; i++) { @@ -547,50 +535,47 @@ void PairMesoCNT::bond_neigh() int numneigh_max_local = numneigh1 + numneigh2; if (numneigh_max_local > numneigh_max) numneigh_max = numneigh_max_local; } - if (numneigh_max > reduced_neigh_size) { - reduced_neigh_size = 2 * numneigh_max; - update_memory = 1; - } - // grow arrays if necessary - - if (update_memory) { - memory->destroy(reduced_neighlist); - memory->destroy(numchainlist); - memory->destroy(reduced_nlist); - memory->destroy(nchainlist); - memory->destroy(endlist); - memory->destroy(chainlist); - - memory->create(reduced_nlist,nlocal_size,"pair:reduced_nlist"); - memory->create(numchainlist,nlocal_size,"pair:numchainlist"); - memory->create(reduced_neighlist, - nlocal_size,reduced_neigh_size,"pair:reduced_neighlist"); - memory->create(nchainlist,nlocal_size,reduced_neigh_size,"pair:nchainlist"); - memory->create(endlist,nlocal_size,reduced_neigh_size,"pair:endlist"); - memory->create(chainlist,nlocal_size, - reduced_neigh_size,reduced_neigh_size,"pair:chainlist"); - - memory->grow(w,reduced_neigh_size,"pair:w"); - memory->grow(wnode,reduced_neigh_size,"pair:wnode"); - memory->grow(dq_w,reduced_neigh_size,3,"pair:dq_w"); - memory->grow(q1_dq_w,reduced_neigh_size,3,3,"pair:q1_dq_w"); - memory->grow(q2_dq_w,reduced_neigh_size,3,3,"pair:q2_dq_w"); - } + // create temporary arrays for chain creation + + memory->create(reduced_nlist,nbondlist,"pair:reduced_nlist"); + memory->create(reduced_neighlist, + nbondlist,numneigh_max,"pair:reduced_neighlist"); + + // reduce neighbors to common list and find longest common list size + numneigh_max = 0; for (int i = 0; i < nbondlist; i++) { int i1 = bondlist[i][0]; int i2 = bondlist[i][1]; + int *reduced_neigh = reduced_neighlist[i]; + neigh_common(i1,i2,reduced_nlist[i],reduced_neigh); + + if (numneigh_max < reduced_nlist[i]) + numneigh_max = reduced_nlist[i]; + } + + // resize chain arrays + + memory->destroy(numchainlist); + memory->destroy(nchainlist); + memory->destroy(endlist); + memory->destroy(chainlist); + + memory->create(numchainlist,nbondlist,"pair:numchainlist"); + memory->create(nchainlist,nbondlist,numneigh_max,"pair:nchainlist"); + memory->create(endlist,nbondlist,numneigh_max,"pair:endlist"); + memory->create(chainlist,nbondlist, + numneigh_max,numneigh_max,"pair:chainlist"); + + int nchain_max = 0; + for (int i = 0; i < nbondlist; i++) { int *reduced_neigh = reduced_neighlist[i]; int *end = endlist[i]; int *nchain = nchainlist[i]; int **chain = chainlist[i]; - // reduce neighbors to common list - - neigh_common(i1,i2,reduced_nlist[i],reduced_neigh); - // sort list according to atom-id sort(reduced_neigh,reduced_nlist[i]); @@ -599,7 +584,28 @@ void PairMesoCNT::bond_neigh() chain_split(reduced_neigh, reduced_nlist[i],numchainlist[i],chain,nchain,end); + + // find longest chain + + for (int j = 0; j < numchainlist[i]; j++) + if (nchain_max < nchain[j]) + nchain_max = nchain[j]; } + + // resize potential arrays + + memory->grow(w,nchain_max,"pair:w"); + memory->grow(wnode,nchain_max,"pair:wnode"); + memory->grow(dq_w,nchain_max,3,"pair:dq_w"); + memory->grow(q1_dq_w,nchain_max,3,3,"pair:q1_dq_w"); + memory->grow(q2_dq_w,nchain_max,3,3,"pair:q2_dq_w"); + + + // destroy temporary arrays for chain creation + + memory->destroy(reduced_neighlist); + memory->destroy(reduced_nlist); + } /* ---------------------------------------------------------------------- diff --git a/src/MESONT/pair_mesocnt.h b/src/MESONT/pair_mesocnt.h index 3db576ad7d..3fcbd0a4ba 100644 --- a/src/MESONT/pair_mesocnt.h +++ b/src/MESONT/pair_mesocnt.h @@ -36,7 +36,6 @@ class PairMesoCNT : public Pair { protected: int uinf_points, gamma_points, phi_points, usemi_points; - int nlocal_size, reduced_neigh_size; int *reduced_nlist, *numchainlist; int **reduced_neighlist, **nchainlist, **endlist; int ***chainlist; From b1ed5e5b27fed05c13ca8c6364d34d6788e0e84d Mon Sep 17 00:00:00 2001 From: phankl Date: Wed, 12 Jan 2022 17:02:09 +0000 Subject: [PATCH 02/72] memory optimised with ragged arrays, implemented 3D ragged arrays --- src/MESONT/pair_mesocnt.cpp | 145 +++++++++++++++++++++++++++--------- src/MESONT/pair_mesocnt.h | 5 +- src/memory.h | 34 ++++++++- 3 files changed, 145 insertions(+), 39 deletions(-) diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index b840c8fd4b..91af0745ff 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -386,7 +386,7 @@ void PairMesoCNT::allocate() { allocated = 1; int ntypes = atom->ntypes; - int init_size = 64; + int init_size = 1; memory->create(cutsq,ntypes+1,ntypes+1,"pair:cutsq"); memory->create(setflag,ntypes+1,ntypes+1,"pair:setflag"); @@ -517,9 +517,10 @@ double PairMesoCNT::init_one(int /* i */, int /* j */) void PairMesoCNT::bond_neigh() { + int nlocal = atom->nlocal; + int nghost = atom->nghost; int **bondlist = neighbor->bondlist; int nbondlist = neighbor->nbondlist; - int nlocal = atom->nlocal; int *numneigh = list->numneigh; int numneigh_max = 0; @@ -527,17 +528,24 @@ void PairMesoCNT::bond_neigh() int i1 = bondlist[i][0]; int i2 = bondlist[i][1]; int numneigh1,numneigh2; - if (i1 > nlocal-1 && false) numneigh1 = 0; - else numneigh1 = numneigh[i1]; - if (i2 > nlocal-1 && false) numneigh2 = 0; - else numneigh2 = numneigh[i2]; + + // prevent ghost atom with undefined neighbors + + if (i1 > nlocal-1) + numneigh1 = 0; + else + numneigh1 = numneigh[i1]; + if (i2 > nlocal-1) + numneigh2 = 0; + else + numneigh2 = numneigh[i2]; int numneigh_max_local = numneigh1 + numneigh2; if (numneigh_max_local > numneigh_max) numneigh_max = numneigh_max_local; } // create temporary arrays for chain creation - + memory->create(reduced_nlist,nbondlist,"pair:reduced_nlist"); memory->create(reduced_neighlist, nbondlist,numneigh_max,"pair:reduced_neighlist"); @@ -551,11 +559,15 @@ void PairMesoCNT::bond_neigh() int *reduced_neigh = reduced_neighlist[i]; neigh_common(i1,i2,reduced_nlist[i],reduced_neigh); + + // sort list according to atom-id + + sort(reduced_neigh,reduced_nlist[i]); if (numneigh_max < reduced_nlist[i]) numneigh_max = reduced_nlist[i]; } - + // resize chain arrays memory->destroy(numchainlist); @@ -563,11 +575,33 @@ void PairMesoCNT::bond_neigh() memory->destroy(endlist); memory->destroy(chainlist); + // count neighbor chains per bond + memory->create(numchainlist,nbondlist,"pair:numchainlist"); - memory->create(nchainlist,nbondlist,numneigh_max,"pair:nchainlist"); - memory->create(endlist,nbondlist,numneigh_max,"pair:endlist"); - memory->create(chainlist,nbondlist, - numneigh_max,numneigh_max,"pair:chainlist"); + + int numchain_max = 0; + for (int i = 0; i < nbondlist; i++) { + numchainlist[i] = count_chains(reduced_neighlist[i],reduced_nlist[i]); + if (numchain_max < numchainlist[i]) + numchain_max = numchainlist[i]; + } + + // count neighbor chain lengths per bond + + memory->create_ragged(nchainlist,nbondlist,numchainlist,"pair:nchainlist"); + + for (int i = 0; i < nbondlist; i++) + chain_lengths(reduced_neighlist[i],reduced_nlist[i],nchainlist[i]); + + // create connected neighbor chains and check for ends + // MEMORY: prevent zero-size array creation for chainlist + + memory->create_ragged(endlist,nbondlist,numchainlist,"pair:endlist"); + if (numchain_max > 0) + memory->create_ragged(chainlist,nbondlist,numchainlist,nchainlist, + "pair:chainlist"); + else + memory->create(chainlist,1,1,1,"pair:chainlist"); int nchain_max = 0; for (int i = 0; i < nbondlist; i++) { @@ -576,14 +610,9 @@ void PairMesoCNT::bond_neigh() int *nchain = nchainlist[i]; int **chain = chainlist[i]; - // sort list according to atom-id + // set up connected chains and check for ends - sort(reduced_neigh,reduced_nlist[i]); - - // set up connected chains - - chain_split(reduced_neigh, - reduced_nlist[i],numchainlist[i],chain,nchain,end); + chain_split(reduced_neigh,reduced_nlist[i],nchain,chain,end); // find longest chain @@ -621,16 +650,18 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) int **firstneigh = list->firstneigh; int numneigh1,numneigh2; int *neighlist1,*neighlist2; + + // prevent ghost atom with undefined neighbors - if (i1 > nlocal-1) { + if (i1 > nlocal-1) numneigh1 = 0; - } else { + else { neighlist1 = firstneigh[i1]; numneigh1 = numneigh[i1]; } - if (i2 > nlocal-1) { + if (i2 > nlocal-1) numneigh2 = 0; - } else { + else { neighlist2 = firstneigh[i2]; numneigh2 = numneigh[i2]; } @@ -664,19 +695,65 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) } } +/* ---------------------------------------------------------------------- + count neighbor chains of given bond +------------------------------------------------------------------------- */ + +int PairMesoCNT::count_chains(int *redlist, int numred) +{ + if (numred == 0) return 0; + + tagint *tag = atom->tag; + tagint *mol = atom->molecule; + int count = 1; + + // split neighbor list and count chains + + for (int j = 0; j < numred-1; j++) { + int j1 = redlist[j]; + int j2 = redlist[j+1]; + if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) + count++; + } + + return count; +} +/* ---------------------------------------------------------------------- + count lengths of neighbor chains of given bond +------------------------------------------------------------------------- */ + +void PairMesoCNT::chain_lengths(int *redlist, int numred, int *nchain) +{ + if (numred == 0) return; + + tagint *tag = atom->tag; + tagint *mol = atom->molecule; + int clen = 0; + int cid = 0; + + // split neighbor list into connected chains + + for (int j = 0; j < numred-1; j++) { + int j1 = redlist[j]; + int j2 = redlist[j+1]; + clen++; + if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) { + nchain[cid++] = clen; + clen = 0; + } + } + clen++; + nchain[cid++] = clen; +} + /* ---------------------------------------------------------------------- split neighbors into chains and identify ends ------------------------------------------------------------------------- */ -void PairMesoCNT::chain_split(int *redlist, int numred, - int &numchain, int **chain, int *nchain, int *end) +void PairMesoCNT::chain_split(int *redlist, int numred, int *nchain, + int **chain, int *end) { - // empty neighbor list - - if (numred == 0) { - numchain = 0; - return; - } + if (numred == 0) return; tagint *tag = atom->tag; tagint *mol = atom->molecule; @@ -690,12 +767,12 @@ void PairMesoCNT::chain_split(int *redlist, int numred, int j2 = redlist[j+1]; chain[cid][clen++] = j1; if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) { - nchain[cid++] = clen; + cid++; clen = 0; } } chain[cid][clen++] = redlist[numred-1]; - nchain[cid++] = clen; + cid++; // check for chain ends @@ -718,8 +795,6 @@ void PairMesoCNT::chain_split(int *redlist, int numred, if (mol[cend] != mol[idnext]) end[j] = 2; } } - - numchain = cid; } /* ---------------------------------------------------------------------- diff --git a/src/MESONT/pair_mesocnt.h b/src/MESONT/pair_mesocnt.h index 3fcbd0a4ba..76c1bf6b0f 100644 --- a/src/MESONT/pair_mesocnt.h +++ b/src/MESONT/pair_mesocnt.h @@ -58,10 +58,13 @@ class PairMesoCNT : public Pair { char *file; + int count_chains(int *, int); + void allocate(); void bond_neigh(); void neigh_common(int, int, int &, int *); - void chain_split(int *, int, int &, int **, int *, int *); + void chain_lengths(int *, int, int *); + void chain_split(int *, int, int *, int **, int *); void sort(int *, int); void read_file(); void read_data(FILE *, double *, double &, double &, int); diff --git a/src/memory.h b/src/memory.h index f7ea3bc4a7..2f84728b32 100644 --- a/src/memory.h +++ b/src/memory.h @@ -226,10 +226,38 @@ class Memory : protected Pointers { } template - TYPE ***create_ragged(TYPE ***& /*array*/, int /*n1*/, int * /*n2*/, const char *name) + TYPE ***create_ragged(TYPE ***& array, int n1, int *n2, int **n3, const char *name) { - fail(name); - return nullptr; + bigint size, nbytes; + int i, j; + + size = 0; + for (i = 0; i < n1; i++) + for (j = 0; j < n2[i]; j++) + size += n3[i][j]; + nbytes = ((bigint) sizeof(TYPE)) * size; + TYPE *data = (TYPE *) smalloc(nbytes, name); + + size = 0; + for (i = 0; i < n1; i++) size += n2[i]; + nbytes = ((bigint) sizeof(TYPE *)) * size; + TYPE **plane = (TYPE **) smalloc(nbytes, name); + + nbytes = ((bigint) sizeof(TYPE **)) * n1; + array = (TYPE ***) smalloc(nbytes, name); + + bigint m = 0; + bigint n = 0; + for (i = 0; i < n1; i++) { + array[i] = &plane[m]; + for (j = 0; j < n2[i]; j++) { + plane[m + j] = &data[n]; + n += n3[i][j]; + } + m += n2[i]; + } + + return array; } /* ---------------------------------------------------------------------- From 0540b93123943bd0dad086a91ef69e3a8eb0607c Mon Sep 17 00:00:00 2001 From: phankl Date: Thu, 13 Jan 2022 17:15:45 +0000 Subject: [PATCH 03/72] fixed division by zero issue in geometry --- src/MESONT/pair_mesocnt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index 91af0745ff..4214d2895f 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -1553,6 +1553,7 @@ void PairMesoCNT::geometry(const double *r1, const double *r2, sub3(pbar,rbar,delrbar); double h = len3(delrbar); + if (h*ang_inv < SMALL) h = SMALL * ang; copy3(delrbar,ex); copy3(l,ez); From 7cca49b14b088b54b6ac2f123844e271d7162d36 Mon Sep 17 00:00:00 2001 From: Nick Curtis Date: Mon, 21 Feb 2022 17:32:40 -0500 Subject: [PATCH 04/72] hide pow behind conditional Change-Id: I8bb3f7a069207dd0e5a5b980d2a7e3e1a7e22ccb --- src/KOKKOS/pair_reaxff_kokkos.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 70c034a70a..367d618212 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -1698,19 +1698,19 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { - C12 = p_bo1*pow(rij/r_s,p_bo2); + C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); BO_s = (1.0+bo_cut)*exp(C12); } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { - C34 = p_bo3*pow(rij/r_pi,p_bo4); + C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); BO_pi = exp(C34); } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { - C56 = p_bo5*pow(rij/r_pi2,p_bo6); + C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); BO_pi2 = exp(C56); } else BO_pi2 = C56 = 0.0; From e79e4c01348a815343853d03b9d7649471ae32c4 Mon Sep 17 00:00:00 2001 From: Nick Curtis Date: Tue, 22 Feb 2022 14:43:24 -0500 Subject: [PATCH 05/72] Seperate buildlists half into 'cheap' blocking-based preprocessor, and 'dense' finalizer Change-Id: Ic205c1e6f3578c033ec4d8c3c45070fd5b3d7a18 --- src/KOKKOS/pair_reaxff_kokkos.cpp | 282 ++++++++++++++---------------- src/KOKKOS/pair_reaxff_kokkos.h | 15 +- 2 files changed, 147 insertions(+), 150 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 367d618212..b753e8f369 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -840,14 +840,14 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) if (list_blocking_flag) { if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } else { if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } k_resize_bo.modify(); @@ -873,6 +873,11 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) } } + if (neighflag == HALF) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + else if (neighflag == HALFTHREAD) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + // allocate duplicated memory if (need_dup) { dup_CdDelta = Kokkos::Experimental::create_scatter_view(d_CdDelta); @@ -1568,15 +1573,9 @@ void PairReaxFFKokkos::operator()(TagPairReaxZero, const int &n) con template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking_preview, const int &ii) const { constexpr int blocksize = PairReaxFFKokkos::build_lists_half_blocksize; - const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); - const auto a_dDeltap_self = v_dDeltap_self.template access>(); - - const auto v_total_bo = ScatterViewHelper,decltype(dup_total_bo),decltype(ndup_total_bo)>::get(dup_total_bo,ndup_total_bo); - const auto a_total_bo = v_total_bo.template access>(); - const int i = d_ilist[ii]; const X_FLOAT xtmp = x(i,0); const X_FLOAT ytmp = x(i,1); @@ -1584,9 +1583,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const int itype = type(i); const int jnum = d_numneigh[i]; - const int three = 3; - F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[three], dBOp_i[three], dln_BOp_pi_i[three], dln_BOp_pi2_i[three]; - F_FLOAT total_bo = 0.0; + F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3];; int j_index,i_index; d_bo_first[i] = i*maxbo; @@ -1608,6 +1605,10 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< blocking_t selected_jj[blocksize]; int jj_current = 0; + double cutoffsq; + if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + else cutoffsq = cut_bosq; + while (jj_current < jnum) { nnz=0; @@ -1624,10 +1625,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< delij[2] = x(j,2) - ztmp; const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); - else cutoffsq = cut_bosq; - if (rsq <= cutoffsq) { + if (rsq <= cutoffsq){ selected_jj[nnz] = jj_current; nnz++; } @@ -1646,10 +1644,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< delij[2] = x(j,2) - ztmp; const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); - else cutoffsq = cut_bosq; - // hbond list if (i < nlocal && cut_hbsq > 0.0 && (ihb == 1 || ihb == 2) && rsq <= cut_hbsq) { jhb = paramssing(jtype).p_hbond; @@ -1736,67 +1730,120 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const int max_val = MAX(ii_index+1,jj_index+1); d_resize_bo() = MAX(d_resize_bo(),max_val); } else { - d_bo_list[j_index] = j; - d_bo_list[i_index] = i; - - // from BondOrder1 - - d_BO(i,jj_index) = BO; - d_BO_s(i,jj_index) = BO_s; - d_BO_pi(i,jj_index) = BO_pi; - d_BO_pi2(i,jj_index) = BO_pi2; - - d_BO(j,ii_index) = BO; - d_BO_s(j,ii_index) = BO_s; - d_BO_pi(j,ii_index) = BO_pi; - d_BO_pi2(j,ii_index) = BO_pi2; - - F_FLOAT Cln_BOp_s = p_bo2 * C12 / rij / rij; - F_FLOAT Cln_BOp_pi = p_bo4 * C34 / rij / rij; - F_FLOAT Cln_BOp_pi2 = p_bo6 * C56 / rij / rij; - - if (nlocal == 0) - Cln_BOp_s = Cln_BOp_pi = Cln_BOp_pi2 = 0.0; - - for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; - for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) a_dDeltap_self(i,d) += dBOp_i[d]; - for (int d = 0; d < 3; d++) a_dDeltap_self(j,d) += -dBOp_i[d]; - - d_dln_BOp_pix(i,jj_index) = dln_BOp_pi_i[0]; - d_dln_BOp_piy(i,jj_index) = dln_BOp_pi_i[1]; - d_dln_BOp_piz(i,jj_index) = dln_BOp_pi_i[2]; - - d_dln_BOp_pix(j,ii_index) = -dln_BOp_pi_i[0]; - d_dln_BOp_piy(j,ii_index) = -dln_BOp_pi_i[1]; - d_dln_BOp_piz(j,ii_index) = -dln_BOp_pi_i[2]; - - d_dln_BOp_pi2x(i,jj_index) = dln_BOp_pi2_i[0]; - d_dln_BOp_pi2y(i,jj_index) = dln_BOp_pi2_i[1]; - d_dln_BOp_pi2z(i,jj_index) = dln_BOp_pi2_i[2]; - - d_dln_BOp_pi2x(j,ii_index) = -dln_BOp_pi2_i[0]; - d_dln_BOp_pi2y(j,ii_index) = -dln_BOp_pi2_i[1]; - d_dln_BOp_pi2z(j,ii_index) = -dln_BOp_pi2_i[2]; - - d_dBOpx(i,jj_index) = dBOp_i[0]; - d_dBOpy(i,jj_index) = dBOp_i[1]; - d_dBOpz(i,jj_index) = dBOp_i[2]; - - d_dBOpx(j,ii_index) = -dBOp_i[0]; - d_dBOpy(j,ii_index) = -dBOp_i[1]; - d_dBOpz(j,ii_index) = -dBOp_i[2]; - - d_BO(i,jj_index) -= bo_cut; - d_BO(j,ii_index) -= bo_cut; - d_BO_s(i,jj_index) -= bo_cut; - d_BO_s(j,ii_index) -= bo_cut; - total_bo += d_BO(i,jj_index); - a_total_bo[j] += d_BO(j,ii_index); + d_bo_list[j_index] = j; + d_bo_list[i_index] = i; } } } +} + +template +template +KOKKOS_INLINE_FUNCTION +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_finalize, const int &ii) const { + + constexpr int blocksize = PairReaxFFKokkos::build_lists_half_blocksize; + + const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); + const auto a_dDeltap_self = v_dDeltap_self.template access>(); + + const auto v_total_bo = ScatterViewHelper,decltype(dup_total_bo),decltype(ndup_total_bo)>::get(dup_total_bo,ndup_total_bo); + const auto a_total_bo = v_total_bo.template access>(); + + const int i = d_ilist[ii]; + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int itype = type(i); + + F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3]; + F_FLOAT total_bo = 0.0; + + int j_index; + + + const int j_start = d_bo_first[i]; + const int j_end = j_start + d_bo_num[i]; + for (int jj = j_start; jj < j_end; jj++) { + int j = d_bo_list[jj]; + j &= NEIGHMASK; + const int jtype = type(j); + const int j_index = jj - j_start; + delij[0] = x(j,0) - xtmp; + delij[1] = x(j,1) - ytmp; + delij[2] = x(j,2) - ztmp; + const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; + const F_FLOAT rsq_inv = 1.0 / rsq; + + // bond_list + const F_FLOAT rij = sqrt(rsq); + const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1; + const F_FLOAT p_bo2 = paramstwbp(itype,jtype).p_bo2; + const F_FLOAT p_bo3 = paramstwbp(itype,jtype).p_bo3; + const F_FLOAT p_bo4 = paramstwbp(itype,jtype).p_bo4; + const F_FLOAT p_bo5 = paramstwbp(itype,jtype).p_bo5; + const F_FLOAT p_bo6 = paramstwbp(itype,jtype).p_bo6; + const F_FLOAT r_s = paramstwbp(itype,jtype).r_s; + const F_FLOAT r_pi = paramstwbp(itype,jtype).r_pi; + const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; + + if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { + C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); + BO_s = (1.0+bo_cut)*exp(C12); + } + else BO_s = C12 = 0.0; + + if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { + C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); + BO_pi = exp(C34); + } + else BO_pi = C34 = 0.0; + + if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { + C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); + BO_pi2 = exp(C56); + } + else BO_pi2 = C56 = 0.0; + + BO = BO_s + BO_pi + BO_pi2; + + // from BondOrder1 + + d_BO(i,j_index) = BO; + d_BO_s(i,j_index) = BO_s; + d_BO_pi(i,j_index) = BO_pi; + d_BO_pi2(i,j_index) = BO_pi2; + + + F_FLOAT Cln_BOp_s = p_bo2 * C12 * rsq_inv; + F_FLOAT Cln_BOp_pi = p_bo4 * C34 * rsq_inv; + F_FLOAT Cln_BOp_pi2 = p_bo6 * C56 * rsq_inv; + + if (nlocal == 0) + Cln_BOp_s = Cln_BOp_pi = Cln_BOp_pi2 = 0.0; + + for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; + for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; + for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; + for (int d = 0; d < 3; d++) a_dDeltap_self(i,d) += dBOp_i[d]; + + d_dln_BOp_pix(i,j_index) = dln_BOp_pi_i[0]; + d_dln_BOp_piy(i,j_index) = dln_BOp_pi_i[1]; + d_dln_BOp_piz(i,j_index) = dln_BOp_pi_i[2]; + + d_dln_BOp_pi2x(i,j_index) = dln_BOp_pi2_i[0]; + d_dln_BOp_pi2y(i,j_index) = dln_BOp_pi2_i[1]; + d_dln_BOp_pi2z(i,j_index) = dln_BOp_pi2_i[2]; + + d_dBOpx(i,j_index) = dBOp_i[0]; + d_dBOpy(i,j_index) = dBOp_i[1]; + d_dBOpz(i,j_index) = dBOp_i[2]; + + + d_BO(i,j_index) -= bo_cut; + d_BO_s(i,j_index) -= bo_cut; + total_bo += d_BO(i,j_index); + } a_total_bo[i] += total_bo; } @@ -1806,7 +1853,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_preview, const int &ii) const { const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); const auto a_dDeltap_self = v_dDeltap_self.template access>(); @@ -1841,6 +1888,10 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf::operator()(TagPairReaxBuildListsHalf cutoffsq) continue; - // hbond list if (i < nlocal && cut_hbsq > 0.0 && (ihb == 1 || ihb == 2) && rsq <= cut_hbsq) { jhb = paramssing(jtype).p_hbond; @@ -1908,19 +1953,19 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf 0.0 && paramssing(jtype).r_s > 0.0) { - C12 = p_bo1*pow(rij/r_s,p_bo2); + C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); BO_s = (1.0+bo_cut)*exp(C12); } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { - C34 = p_bo3*pow(rij/r_pi,p_bo4); + C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); BO_pi = exp(C34); } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { - C56 = p_bo5*pow(rij/r_pi2,p_bo6); + C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); BO_pi2 = exp(C56); } else BO_pi2 = C56 = 0.0; @@ -1947,64 +1992,9 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf struct TagPairReaxComputeTabulatedLJCoulomb{}; template -struct TagPairReaxBuildListsHalfBlocking{}; +struct TagPairReaxBuildListsHalfBlocking_preview{}; template -struct TagPairReaxBuildListsHalf{}; +struct TagPairReaxBuildListsHalf_finalize{}; + +template +struct TagPairReaxBuildListsHalf_preview{}; struct TagPairReaxZero{}; @@ -162,11 +165,15 @@ class PairReaxFFKokkos : public PairReaxFF { template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalfBlocking, const int&) const; + void operator()(TagPairReaxBuildListsHalfBlocking_preview, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalf, const int&) const; + void operator()(TagPairReaxBuildListsHalf_finalize, const int&) const; + + template + KOKKOS_INLINE_FUNCTION + void operator()(TagPairReaxBuildListsHalf_preview, const int&) const; KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxZero, const int&) const; From 4ad27034f2357d9196d6f7fefa53efb7141db39c Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Wed, 2 Mar 2022 09:04:13 -0700 Subject: [PATCH 06/72] Small tweaks, cleanup --- src/KOKKOS/fix_qeq_reaxff_kokkos.cpp | 2 +- src/KOKKOS/fix_qeq_reaxff_kokkos.h | 4 +-- src/KOKKOS/pair_reaxff_kokkos.cpp | 48 +++++++++++----------------- src/KOKKOS/pair_reaxff_kokkos.h | 24 +++++++------- 4 files changed, 34 insertions(+), 44 deletions(-) diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index bdac648772..bd5baa81f5 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -788,7 +788,7 @@ int FixQEqReaxFFKokkos::cg_solve() } // tmp = parallel_dot(d, q, nn); - Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nn),*this,my_dot); + Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nn),*this,my_dot); MPI_Allreduce(&my_dot.v, &dot_sqr.v, 2, MPI_DOUBLE, MPI_SUM, world); tmp = dot_sqr; if (!(converged & 1)) diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.h b/src/KOKKOS/fix_qeq_reaxff_kokkos.h index 9a22a0f0d0..5c2509129a 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.h +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.h @@ -82,7 +82,7 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { template KOKKOS_INLINE_FUNCTION - void compute_h_team(const typename Kokkos::TeamPolicy ::member_type &team, int, int) const; + void compute_h_team(const typename Kokkos::TeamPolicy::member_type &team, int, int) const; KOKKOS_INLINE_FUNCTION void operator()(TagQEqSparseMatvec1, const int&) const; @@ -94,7 +94,7 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { KOKKOS_INLINE_FUNCTION void operator()(TagQEqSparseMatvec2_Half, const int&) const; - typedef typename Kokkos::TeamPolicy ::member_type membertype_vec; + typedef typename Kokkos::TeamPolicy::member_type membertype_vec; KOKKOS_INLINE_FUNCTION void operator()(TagQEqSparseMatvec2_Full, const membertype_vec &team) const; diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index b753e8f369..1a5702eea2 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -840,14 +840,14 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) if (list_blocking_flag) { if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } else { if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } k_resize_bo.modify(); @@ -874,9 +874,9 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) } if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); // allocate duplicated memory if (need_dup) { @@ -981,15 +981,15 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) if (neighflag == HALF) { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,nnz),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,nnz),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy>(0,nnz),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,nnz),*this); ev_all += ev; } else { if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,nnz),*this,ev); + Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,nnz),*this,ev); else - Kokkos::parallel_for(Kokkos::RangePolicy>(0,nnz),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,nnz),*this); ev_all += ev; } @@ -1573,7 +1573,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxZero, const int &n) con template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking_preview, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingPreview, const int &ii) const { constexpr int blocksize = PairReaxFFKokkos::build_lists_half_blocksize; const int i = d_ilist[ii]; @@ -1583,7 +1583,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking_ const int itype = type(i); const int jnum = d_numneigh[i]; - F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3];; + F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3]; int j_index,i_index; d_bo_first[i] = i*maxbo; @@ -1740,9 +1740,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking_ template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_finalize, const int &ii) const { - - constexpr int blocksize = PairReaxFFKokkos::build_lists_half_blocksize; +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf, const int &ii) const { const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); const auto a_dDeltap_self = v_dDeltap_self.template access>(); @@ -1759,9 +1757,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_finalize F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3]; F_FLOAT total_bo = 0.0; - int j_index; - - const int j_start = d_bo_first[i]; const int j_end = j_start + d_bo_num[i]; for (int jj = j_start; jj < j_end; jj++) { @@ -1853,7 +1848,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_finalize template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_preview, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfPreview, const int &ii) const { const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); const auto a_dDeltap_self = v_dDeltap_self.template access>(); @@ -1868,8 +1863,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_preview< const int itype = type(i); const int jnum = d_numneigh[i]; - const int three = 3; - F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[three], dBOp_i[three], dln_BOp_pi_i[three], dln_BOp_pi2_i[three]; + F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3]; F_FLOAT total_bo = 0.0; int j_index,i_index; @@ -1888,10 +1882,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf_preview< } } - double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); - else cutoffsq = cut_bosq; - for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); j &= NEIGHMASK; @@ -2686,7 +2676,7 @@ template KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsionPreview, const int &ii) const { - F_FLOAT bo_ij, bo_ik, bo_jl; + F_FLOAT bo_ij, bo_ik; int counter = 0; const int i = d_ilist[ii]; @@ -2760,7 +2750,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsionPreview, template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsionBlocking, const int &iii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsion, const int &iii, EV_FLOAT_REAX& ev) const { constexpr int blocksize = PairReaxFFKokkos::compute_torsion_blocksize; @@ -3187,10 +3177,10 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsionBlocking< template template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsionBlocking, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsion, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(TagPairReaxComputeTorsionBlocking(), ii, ev); + this->template operator()(TagPairReaxComputeTorsion(), ii, ev); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 221a9847f9..39d49b8e95 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -58,13 +58,13 @@ template struct TagPairReaxComputeTabulatedLJCoulomb{}; template -struct TagPairReaxBuildListsHalfBlocking_preview{}; +struct TagPairReaxBuildListsHalfBlockingPreview{}; template -struct TagPairReaxBuildListsHalf_finalize{}; +struct TagPairReaxBuildListsHalfPreview{}; template -struct TagPairReaxBuildListsHalf_preview{}; +struct TagPairReaxBuildListsHalf{}; struct TagPairReaxZero{}; @@ -95,7 +95,7 @@ struct TagPairReaxComputeAngular{}; struct TagPairReaxComputeTorsionPreview{}; template -struct TagPairReaxComputeTorsionBlocking{}; +struct TagPairReaxComputeTorsion{}; template struct TagPairReaxComputeHydrogen{}; @@ -165,15 +165,15 @@ class PairReaxFFKokkos : public PairReaxFF { template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalfBlocking_preview, const int&) const; + void operator()(TagPairReaxBuildListsHalfBlockingPreview, const int&) const; + + template + KOKKOS_INLINE_FUNCTION + void operator()(TagPairReaxBuildListsHalfPreview, const int&) const; template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalf_finalize, const int&) const; - - template - KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalf_preview, const int&) const; + void operator()(TagPairReaxBuildListsHalf, const int&) const; KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxZero, const int&) const; @@ -232,11 +232,11 @@ class PairReaxFFKokkos : public PairReaxFF { template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeTorsionBlocking, const int&, EV_FLOAT_REAX&) const; + void operator()(TagPairReaxComputeTorsion, const int&, EV_FLOAT_REAX&) const; template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeTorsionBlocking, const int&) const; + void operator()(TagPairReaxComputeTorsion, const int&) const; template KOKKOS_INLINE_FUNCTION From adefb287c55b1ef45c04e77ea8413f2724381a3c Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Wed, 2 Mar 2022 09:29:07 -0700 Subject: [PATCH 07/72] whitespace --- src/KOKKOS/pair_reaxff_kokkos.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 39d49b8e95..4adb35b52c 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -167,7 +167,7 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsHalfBlockingPreview, const int&) const; - template + template KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsHalfPreview, const int&) const; From 083d166885a787bbb75fe3336d73d2652b946574 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Wed, 2 Mar 2022 09:46:25 -0700 Subject: [PATCH 08/72] More cleanup --- src/KOKKOS/pair_reaxff_kokkos.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 1a5702eea2..b450de4a61 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -840,14 +840,14 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) if (list_blocking_flag) { if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } else { if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } k_resize_bo.modify(); @@ -1606,7 +1606,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP int jj_current = 0; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; while (jj_current < jnum) { @@ -1625,7 +1625,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP delij[2] = x(j,2) - ztmp; const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - if (rsq <= cutoffsq){ + if (rsq <= cutoffsq) { selected_jj[nnz] = jj_current; nnz++; } @@ -1809,7 +1809,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf::operator()(TagPairReaxBuildListsHalf KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfPreview, const int &ii) const { - const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); - const auto a_dDeltap_self = v_dDeltap_self.template access>(); - - const auto v_total_bo = ScatterViewHelper,decltype(dup_total_bo),decltype(ndup_total_bo)>::get(dup_total_bo,ndup_total_bo); - const auto a_total_bo = v_total_bo.template access>(); - const int i = d_ilist[ii]; const X_FLOAT xtmp = x(i,0); const X_FLOAT ytmp = x(i,1); @@ -1984,8 +1976,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfPreview Date: Wed, 2 Mar 2022 10:04:35 -0700 Subject: [PATCH 09/72] cleanup --- src/KOKKOS/pair_reaxff_kokkos.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index b450de4a61..b5db8c9dba 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -1610,7 +1610,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP else cutoffsq = cut_bosq; while (jj_current < jnum) { - nnz=0; + nnz = 0; while (nnz < blocksize) { int jj = jj_current; @@ -1737,6 +1737,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP } } +/* ---------------------------------------------------------------------- */ + template template KOKKOS_INLINE_FUNCTION @@ -1785,20 +1787,17 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf 0.0 && paramssing(jtype).r_s > 0.0) { C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); BO_s = (1.0+bo_cut)*exp(C12); - } - else BO_s = C12 = 0.0; + } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); BO_pi = exp(C34); - } - else BO_pi = C34 = 0.0; + } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); BO_pi2 = exp(C56); - } - else BO_pi2 = C56 = 0.0; + } else BO_pi2 = C56 = 0.0; BO = BO_s + BO_pi + BO_pi2; @@ -1856,7 +1855,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfPreview::operator()(TagPairReaxBuildListsHalfPreview::operator()(TagPairReaxBuildListsHalfPreview 0.0 && paramssing(jtype).r_s > 0.0) { C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); BO_s = (1.0+bo_cut)*exp(C12); - } - else BO_s = C12 = 0.0; + } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); BO_pi = exp(C34); - } - else BO_pi = C34 = 0.0; + } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); BO_pi2 = exp(C56); - } - else BO_pi2 = C56 = 0.0; + } else BO_pi2 = C56 = 0.0; BO = BO_s + BO_pi + BO_pi2; if (BO < bo_cut) continue; From 30517fad688ceeecb835b9fb1ad1a144f06258f8 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Wed, 2 Mar 2022 10:34:49 -0700 Subject: [PATCH 10/72] Remove unnecessary atomics/duplication --- src/KOKKOS/pair_reaxff_kokkos.cpp | 25 +++++++++++-------------- src/KOKKOS/pair_reaxff_kokkos.h | 6 ++---- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index b5db8c9dba..5d0623cfe5 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -874,9 +874,9 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) } if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); // allocate duplicated memory if (need_dup) { @@ -1740,15 +1740,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP /* ---------------------------------------------------------------------- */ template -template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf, const int &ii) const { - - const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); - const auto a_dDeltap_self = v_dDeltap_self.template access>(); - - const auto v_total_bo = ScatterViewHelper,decltype(dup_total_bo),decltype(ndup_total_bo)>::get(dup_total_bo,ndup_total_bo); - const auto a_total_bo = v_total_bo.template access>(); +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsFull, const int &ii) const { const int i = d_ilist[ii]; const X_FLOAT xtmp = x(i,0); @@ -1757,7 +1750,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalf::operator()(TagPairReaxBuildListsHalf::operator()(TagPairReaxBuildListsHalf struct TagPairReaxBuildListsHalfPreview{}; -template -struct TagPairReaxBuildListsHalf{}; +struct TagPairReaxBuildListsFull{}; struct TagPairReaxZero{}; @@ -171,9 +170,8 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsHalfPreview, const int&) const; - template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalf, const int&) const; + void operator()(TagPairReaxBuildListsFull, const int&) const; KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxZero, const int&) const; From 0a2a252f0889f6d11f4ee9244f3bfca578596246 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Wed, 2 Mar 2022 10:42:41 -0700 Subject: [PATCH 11/72] cleanup --- src/KOKKOS/pair_reaxff_kokkos.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 5d0623cfe5..da3d0dd744 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -873,10 +873,7 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) } } - if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); - else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); // allocate duplicated memory if (need_dup) { @@ -1651,9 +1648,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP if (NEIGHFLAG == HALF) { j_index = hb_first_i + d_hb_num[i]; d_hb_num[i]++; - } else { + } else j_index = hb_first_i + Kokkos::atomic_fetch_add(&d_hb_num[i],1); - } const int jj_index = j_index - hb_first_i; @@ -1694,20 +1690,17 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); BO_s = (1.0+bo_cut)*exp(C12); - } - else BO_s = C12 = 0.0; + } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); BO_pi = exp(C34); - } - else BO_pi = C34 = 0.0; + } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); BO_pi2 = exp(C56); - } - else BO_pi2 = C56 = 0.0; + } else BO_pi2 = C56 = 0.0; BO = BO_s + BO_pi + BO_pi2; if (BO < bo_cut) continue; @@ -1717,8 +1710,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP i_index = d_bo_first[j] + d_bo_num[j]; d_bo_num[i]++; d_bo_num[j]++; - } - else { + } else { j_index = bo_first_i + Kokkos::atomic_fetch_add(&d_bo_num[i],1); i_index = d_bo_first[j] + Kokkos::atomic_fetch_add(&d_bo_num[j],1); } @@ -1889,9 +1881,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfPreview::operator()(TagPairReaxBuildListsHalfPreview Date: Thu, 3 Mar 2022 07:20:53 -0700 Subject: [PATCH 12/72] Change default for list/blocking option --- doc/src/pair_reaxff.rst | 7 +++---- src/REAXFF/pair_reaxff.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/src/pair_reaxff.rst b/doc/src/pair_reaxff.rst index d0c333af4b..4e88a3585c 100644 --- a/doc/src/pair_reaxff.rst +++ b/doc/src/pair_reaxff.rst @@ -163,9 +163,8 @@ The keyword *list/blocking* is only supported by the Kokkos version of ReaxFF and ignored otherwise. Setting the value to *yes* enables the "blocking" scheme (dynamically building interaction lists) for the ReaxFF bond neighbor list. This reduces the number of empty -interactions and can improve performance in some cases (e.g. large -number of atoms/GPU on AMD hardware). It is also enabled by default -when running the CPU with Kokkos. +interactions but can reduce performance in some cases (e.g. small +number of atoms/GPU on AMD hardware). The thermo variable *evdwl* stores the sum of all the ReaxFF potential energy contributions, with the exception of the Coulombic and charge @@ -370,7 +369,7 @@ Default """"""" The keyword defaults are checkqeq = yes, enobonds = yes, lgvdw = no, -safezone = 1.2, mincap = 50, minhbonds = 25, list/blocking = yes on CPU, no on GPU. +safezone = 1.2, mincap = 50, minhbonds = 25, list/blocking = yes. ---------- diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 39b6221d3d..6dc2f7685b 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -113,7 +113,7 @@ PairReaxFF::PairReaxFF(LAMMPS *lmp) : Pair(lmp) nmax = 0; - list_blocking_flag = 0; + list_blocking_flag = 1; } /* ---------------------------------------------------------------------- */ From beee3126e03e9619639537cc041f9437e826ff50 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 07:21:40 -0700 Subject: [PATCH 13/72] Recover CPU performance by bifurcating code --- src/KOKKOS/pair_reaxff_kokkos.cpp | 262 +++++++++++++++++++++++++++++- src/KOKKOS/pair_reaxff_kokkos.h | 7 + 2 files changed, 261 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index da3d0dd744..97799d7e3a 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -838,16 +838,23 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) // zero Kokkos::parallel_for(Kokkos::RangePolicy(0,nmax),*this); - if (list_blocking_flag) { + if (execution_space == Host) { // CPU if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); } else { - if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); - else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + if (list_blocking_flag) { + if (neighflag == HALF) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + else if (neighflag == HALFTHREAD) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + } else { + if (neighflag == HALF) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + else if (neighflag == HALFTHREAD) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); + } } k_resize_bo.modify(); @@ -873,7 +880,8 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) } } - Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); + if (execution_space != Host) // GPU + Kokkos::parallel_for(Kokkos::RangePolicy(0,ignum),*this); // allocate duplicated memory if (need_dup) { @@ -1567,6 +1575,244 @@ void PairReaxFFKokkos::operator()(TagPairReaxZero, const int &n) con /* ---------------------------------------------------------------------- */ +template +template +KOKKOS_INLINE_FUNCTION +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking, const int &ii) const { + constexpr int blocksize = PairReaxFFKokkos::build_lists_half_blocksize; + + const auto v_dDeltap_self = ScatterViewHelper,decltype(dup_dDeltap_self),decltype(ndup_dDeltap_self)>::get(dup_dDeltap_self,ndup_dDeltap_self); + const auto a_dDeltap_self = v_dDeltap_self.template access>(); + + const auto v_total_bo = ScatterViewHelper,decltype(dup_total_bo),decltype(ndup_total_bo)>::get(dup_total_bo,ndup_total_bo); + const auto a_total_bo = v_total_bo.template access>(); + + const int i = d_ilist[ii]; + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int itype = type(i); + const int jnum = d_numneigh[i]; + + const int three = 3; + F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[three], dBOp_i[three], dln_BOp_pi_i[three], dln_BOp_pi2_i[three]; + F_FLOAT total_bo = 0.0; + + int j_index,i_index; + d_bo_first[i] = i*maxbo; + const int bo_first_i = d_bo_first[i]; + + int ihb = -1; + int jhb = -1; + + int hb_first_i; + if (cut_hbsq > 0.0) { + ihb = paramssing(itype).p_hbond; + if (ihb == 1) { + d_hb_first[i] = i*maxhb; + hb_first_i = d_hb_first[i]; + } + } + + int nnz; + blocking_t selected_jj[blocksize]; + int jj_current = 0; + + while (jj_current < jnum) { + nnz=0; + + while (nnz < blocksize) { + int jj = jj_current; + int j = d_neighbors(i,jj); + j &= NEIGHMASK; + + d_bo_first[j] = j*maxbo; + d_hb_first[j] = j*maxhb; + + delij[0] = x(j,0) - xtmp; + delij[1] = x(j,1) - ytmp; + delij[2] = x(j,2) - ztmp; + const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; + + double cutoffsq; + if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + else cutoffsq = cut_bosq; + if (rsq <= cutoffsq) { + selected_jj[nnz] = jj_current; + nnz++; + } + jj_current++; + + if (jj_current == jnum) break; + } + + for (int jj_inner = 0; jj_inner < nnz; jj_inner++) { + const int jj = selected_jj[jj_inner]; + int j = d_neighbors(i,jj); + j &= NEIGHMASK; + const int jtype = type(j); + delij[0] = x(j,0) - xtmp; + delij[1] = x(j,1) - ytmp; + delij[2] = x(j,2) - ztmp; + const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; + + double cutoffsq; + if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + else cutoffsq = cut_bosq; + + // hbond list + if (i < nlocal && cut_hbsq > 0.0 && (ihb == 1 || ihb == 2) && rsq <= cut_hbsq) { + jhb = paramssing(jtype).p_hbond; + if (ihb == 1 && jhb == 2) { + if (NEIGHFLAG == HALF) { + j_index = hb_first_i + d_hb_num[i]; + d_hb_num[i]++; + } else { + j_index = hb_first_i + Kokkos::atomic_fetch_add(&d_hb_num[i],1); + } + + const int jj_index = j_index - hb_first_i; + + if (jj_index >= maxhb) + d_resize_hb() = MAX(d_resize_hb(),jj_index+1); + else + d_hb_list[j_index] = j; + } else if (j < nlocal && ihb == 2 && jhb == 1) { + if (NEIGHFLAG == HALF) { + i_index = d_hb_first[j] + d_hb_num[j]; + d_hb_num[j]++; + } else + i_index = d_hb_first[j] + Kokkos::atomic_fetch_add(&d_hb_num[j],1); + + const int ii_index = i_index - d_hb_first[j]; + + if (ii_index >= maxhb) + d_resize_hb() = MAX(d_resize_hb(),ii_index+1); + else + d_hb_list[i_index] = i; + } + } + + if (rsq > cut_bosq) continue; + + // bond_list + const F_FLOAT rij = sqrt(rsq); + const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1; + const F_FLOAT p_bo2 = paramstwbp(itype,jtype).p_bo2; + const F_FLOAT p_bo3 = paramstwbp(itype,jtype).p_bo3; + const F_FLOAT p_bo4 = paramstwbp(itype,jtype).p_bo4; + const F_FLOAT p_bo5 = paramstwbp(itype,jtype).p_bo5; + const F_FLOAT p_bo6 = paramstwbp(itype,jtype).p_bo6; + const F_FLOAT r_s = paramstwbp(itype,jtype).r_s; + const F_FLOAT r_pi = paramstwbp(itype,jtype).r_pi; + const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; + + if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { + C12 = p_bo1*pow(rij/r_s,p_bo2); + BO_s = (1.0+bo_cut)*exp(C12); + } + else BO_s = C12 = 0.0; + + if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { + C34 = p_bo3*pow(rij/r_pi,p_bo4); + BO_pi = exp(C34); + } + else BO_pi = C34 = 0.0; + + if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { + C56 = p_bo5*pow(rij/r_pi2,p_bo6); + BO_pi2 = exp(C56); + } + else BO_pi2 = C56 = 0.0; + + BO = BO_s + BO_pi + BO_pi2; + if (BO < bo_cut) continue; + + if (NEIGHFLAG == HALF) { + j_index = bo_first_i + d_bo_num[i]; + i_index = d_bo_first[j] + d_bo_num[j]; + d_bo_num[i]++; + d_bo_num[j]++; + } + else { + j_index = bo_first_i + Kokkos::atomic_fetch_add(&d_bo_num[i],1); + i_index = d_bo_first[j] + Kokkos::atomic_fetch_add(&d_bo_num[j],1); + } + + const int jj_index = j_index - bo_first_i; + const int ii_index = i_index - d_bo_first[j]; + + if (jj_index >= maxbo || ii_index >= maxbo) { + const int max_val = MAX(ii_index+1,jj_index+1); + d_resize_bo() = MAX(d_resize_bo(),max_val); + } else { + d_bo_list[j_index] = j; + d_bo_list[i_index] = i; + + // from BondOrder1 + + d_BO(i,jj_index) = BO; + d_BO_s(i,jj_index) = BO_s; + d_BO_pi(i,jj_index) = BO_pi; + d_BO_pi2(i,jj_index) = BO_pi2; + + d_BO(j,ii_index) = BO; + d_BO_s(j,ii_index) = BO_s; + d_BO_pi(j,ii_index) = BO_pi; + d_BO_pi2(j,ii_index) = BO_pi2; + + F_FLOAT Cln_BOp_s = p_bo2 * C12 / rij / rij; + F_FLOAT Cln_BOp_pi = p_bo4 * C34 / rij / rij; + F_FLOAT Cln_BOp_pi2 = p_bo6 * C56 / rij / rij; + + if (nlocal == 0) + Cln_BOp_s = Cln_BOp_pi = Cln_BOp_pi2 = 0.0; + + for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; + for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; + for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; + for (int d = 0; d < 3; d++) a_dDeltap_self(i,d) += dBOp_i[d]; + for (int d = 0; d < 3; d++) a_dDeltap_self(j,d) += -dBOp_i[d]; + + d_dln_BOp_pix(i,jj_index) = dln_BOp_pi_i[0]; + d_dln_BOp_piy(i,jj_index) = dln_BOp_pi_i[1]; + d_dln_BOp_piz(i,jj_index) = dln_BOp_pi_i[2]; + + d_dln_BOp_pix(j,ii_index) = -dln_BOp_pi_i[0]; + d_dln_BOp_piy(j,ii_index) = -dln_BOp_pi_i[1]; + d_dln_BOp_piz(j,ii_index) = -dln_BOp_pi_i[2]; + + d_dln_BOp_pi2x(i,jj_index) = dln_BOp_pi2_i[0]; + d_dln_BOp_pi2y(i,jj_index) = dln_BOp_pi2_i[1]; + d_dln_BOp_pi2z(i,jj_index) = dln_BOp_pi2_i[2]; + + d_dln_BOp_pi2x(j,ii_index) = -dln_BOp_pi2_i[0]; + d_dln_BOp_pi2y(j,ii_index) = -dln_BOp_pi2_i[1]; + d_dln_BOp_pi2z(j,ii_index) = -dln_BOp_pi2_i[2]; + + d_dBOpx(i,jj_index) = dBOp_i[0]; + d_dBOpy(i,jj_index) = dBOp_i[1]; + d_dBOpz(i,jj_index) = dBOp_i[2]; + + d_dBOpx(j,ii_index) = -dBOp_i[0]; + d_dBOpy(j,ii_index) = -dBOp_i[1]; + d_dBOpz(j,ii_index) = -dBOp_i[2]; + + d_BO(i,jj_index) -= bo_cut; + d_BO(j,ii_index) -= bo_cut; + d_BO_s(i,jj_index) -= bo_cut; + d_BO_s(j,ii_index) -= bo_cut; + total_bo += d_BO(i,jj_index); + a_total_bo[j] += d_BO(j,ii_index); + } + } + } + + a_total_bo[i] += total_bo; +} + +/* ---------------------------------------------------------------------- */ + template template KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index c1f792ead6..c22a8ed275 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -63,6 +63,9 @@ struct TagPairReaxBuildListsHalfBlockingPreview{}; template struct TagPairReaxBuildListsHalfPreview{}; +template +struct TagPairReaxBuildListsHalfBlocking{}; + struct TagPairReaxBuildListsFull{}; struct TagPairReaxZero{}; @@ -170,6 +173,10 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsHalfPreview, const int&) const; + template + KOKKOS_INLINE_FUNCTION + void operator()(TagPairReaxBuildListsHalfBlocking, const int&) const; + KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsFull, const int&) const; From b6b7846c5077e56c607039a3388e405b879730d9 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 07:46:35 -0700 Subject: [PATCH 14/72] Optimization to reduce atomics on CPU --- src/KOKKOS/pair_reaxff_kokkos.cpp | 212 +++++++++++++++--------------- src/KOKKOS/pair_reaxff_kokkos.h | 14 +- 2 files changed, 115 insertions(+), 111 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 97799d7e3a..9f43ee1820 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -1596,7 +1596,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const int three = 3; F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[three], dBOp_i[three], dln_BOp_pi_i[three], dln_BOp_pi2_i[three]; - F_FLOAT total_bo = 0.0; + F_FLOAT dDeltap_self_i[3] = {0.0,0.0,0.0}; + F_FLOAT total_bo_i = 0.0; int j_index,i_index; d_bo_first[i] = i*maxbo; @@ -1771,7 +1772,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) a_dDeltap_self(i,d) += dBOp_i[d]; + for (int d = 0; d < 3; d++) dDeltap_self_i[d] += dBOp_i[d]; for (int d = 0; d < 3; d++) a_dDeltap_self(j,d) += -dBOp_i[d]; d_dln_BOp_pix(i,jj_index) = dln_BOp_pi_i[0]; @@ -1802,13 +1803,16 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< d_BO(j,ii_index) -= bo_cut; d_BO_s(i,jj_index) -= bo_cut; d_BO_s(j,ii_index) -= bo_cut; - total_bo += d_BO(i,jj_index); + total_bo_i += d_BO(i,jj_index); a_total_bo[j] += d_BO(j,ii_index); } } } - a_total_bo[i] += total_bo; + for (int d = 0; d < 3; d++) + a_dDeltap_self(i,d) += dDeltap_self_i[d]; + + a_total_bo[i] += total_bo_i; } /* ---------------------------------------------------------------------- */ @@ -1977,106 +1981,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlockingP /* ---------------------------------------------------------------------- */ -template -KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxBuildListsFull, const int &ii) const { - - const int i = d_ilist[ii]; - const X_FLOAT xtmp = x(i,0); - const X_FLOAT ytmp = x(i,1); - const X_FLOAT ztmp = x(i,2); - const int itype = type(i); - - F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3]; - F_FLOAT dDeltap_self_i[3] = {0.0,0.0,0.0}; - F_FLOAT total_bo_i = 0.0; - - const int j_start = d_bo_first[i]; - const int j_end = j_start + d_bo_num[i]; - for (int jj = j_start; jj < j_end; jj++) { - int j = d_bo_list[jj]; - j &= NEIGHMASK; - const int jtype = type(j); - const int j_index = jj - j_start; - delij[0] = x(j,0) - xtmp; - delij[1] = x(j,1) - ytmp; - delij[2] = x(j,2) - ztmp; - const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - const F_FLOAT rsq_inv = 1.0 / rsq; - - // bond_list - const F_FLOAT rij = sqrt(rsq); - const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1; - const F_FLOAT p_bo2 = paramstwbp(itype,jtype).p_bo2; - const F_FLOAT p_bo3 = paramstwbp(itype,jtype).p_bo3; - const F_FLOAT p_bo4 = paramstwbp(itype,jtype).p_bo4; - const F_FLOAT p_bo5 = paramstwbp(itype,jtype).p_bo5; - const F_FLOAT p_bo6 = paramstwbp(itype,jtype).p_bo6; - const F_FLOAT r_s = paramstwbp(itype,jtype).r_s; - const F_FLOAT r_pi = paramstwbp(itype,jtype).r_pi; - const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; - - if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { - C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); - BO_s = (1.0+bo_cut)*exp(C12); - } else BO_s = C12 = 0.0; - - if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { - C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); - BO_pi = exp(C34); - } else BO_pi = C34 = 0.0; - - if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { - C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); - BO_pi2 = exp(C56); - } else BO_pi2 = C56 = 0.0; - - BO = BO_s + BO_pi + BO_pi2; - - // from BondOrder1 - - d_BO(i,j_index) = BO; - d_BO_s(i,j_index) = BO_s; - d_BO_pi(i,j_index) = BO_pi; - d_BO_pi2(i,j_index) = BO_pi2; - - F_FLOAT Cln_BOp_s = p_bo2 * C12 * rsq_inv; - F_FLOAT Cln_BOp_pi = p_bo4 * C34 * rsq_inv; - F_FLOAT Cln_BOp_pi2 = p_bo6 * C56 * rsq_inv; - - if (nlocal == 0) - Cln_BOp_s = Cln_BOp_pi = Cln_BOp_pi2 = 0.0; - - for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; - for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; - for (int d = 0; d < 3; d++) dDeltap_self_i[d] += dBOp_i[d]; - - d_dln_BOp_pix(i,j_index) = dln_BOp_pi_i[0]; - d_dln_BOp_piy(i,j_index) = dln_BOp_pi_i[1]; - d_dln_BOp_piz(i,j_index) = dln_BOp_pi_i[2]; - - d_dln_BOp_pi2x(i,j_index) = dln_BOp_pi2_i[0]; - d_dln_BOp_pi2y(i,j_index) = dln_BOp_pi2_i[1]; - d_dln_BOp_pi2z(i,j_index) = dln_BOp_pi2_i[2]; - - d_dBOpx(i,j_index) = dBOp_i[0]; - d_dBOpy(i,j_index) = dBOp_i[1]; - d_dBOpz(i,j_index) = dBOp_i[2]; - - d_BO(i,j_index) -= bo_cut; - d_BO_s(i,j_index) -= bo_cut; - total_bo_i += d_BO(i,j_index); - } - - for (int d = 0; d < 3; d++) - d_dDeltap_self(i,d) = dDeltap_self_i[d]; - - d_total_bo[i] = total_bo_i; -} - -/* ---------------------------------------------------------------------- */ - template template KOKKOS_INLINE_FUNCTION @@ -2209,6 +2113,106 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfPreview +KOKKOS_INLINE_FUNCTION +void PairReaxFFKokkos::operator()(TagPairReaxBuildListsFull, const int &ii) const { + + const int i = d_ilist[ii]; + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int itype = type(i); + + F_FLOAT C12, C34, C56, BO_s, BO_pi, BO_pi2, BO, delij[3], dBOp_i[3], dln_BOp_pi_i[3], dln_BOp_pi2_i[3]; + F_FLOAT dDeltap_self_i[3] = {0.0,0.0,0.0}; + F_FLOAT total_bo_i = 0.0; + + const int j_start = d_bo_first[i]; + const int j_end = j_start + d_bo_num[i]; + for (int jj = j_start; jj < j_end; jj++) { + int j = d_bo_list[jj]; + j &= NEIGHMASK; + const int jtype = type(j); + const int j_index = jj - j_start; + delij[0] = x(j,0) - xtmp; + delij[1] = x(j,1) - ytmp; + delij[2] = x(j,2) - ztmp; + const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; + const F_FLOAT rsq_inv = 1.0 / rsq; + + // bond_list + const F_FLOAT rij = sqrt(rsq); + const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1; + const F_FLOAT p_bo2 = paramstwbp(itype,jtype).p_bo2; + const F_FLOAT p_bo3 = paramstwbp(itype,jtype).p_bo3; + const F_FLOAT p_bo4 = paramstwbp(itype,jtype).p_bo4; + const F_FLOAT p_bo5 = paramstwbp(itype,jtype).p_bo5; + const F_FLOAT p_bo6 = paramstwbp(itype,jtype).p_bo6; + const F_FLOAT r_s = paramstwbp(itype,jtype).r_s; + const F_FLOAT r_pi = paramstwbp(itype,jtype).r_pi; + const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; + + if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { + C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); + BO_s = (1.0+bo_cut)*exp(C12); + } else BO_s = C12 = 0.0; + + if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { + C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); + BO_pi = exp(C34); + } else BO_pi = C34 = 0.0; + + if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { + C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); + BO_pi2 = exp(C56); + } else BO_pi2 = C56 = 0.0; + + BO = BO_s + BO_pi + BO_pi2; + + // from BondOrder1 + + d_BO(i,j_index) = BO; + d_BO_s(i,j_index) = BO_s; + d_BO_pi(i,j_index) = BO_pi; + d_BO_pi2(i,j_index) = BO_pi2; + + F_FLOAT Cln_BOp_s = p_bo2 * C12 * rsq_inv; + F_FLOAT Cln_BOp_pi = p_bo4 * C34 * rsq_inv; + F_FLOAT Cln_BOp_pi2 = p_bo6 * C56 * rsq_inv; + + if (nlocal == 0) + Cln_BOp_s = Cln_BOp_pi = Cln_BOp_pi2 = 0.0; + + for (int d = 0; d < 3; d++) dln_BOp_pi_i[d] = -(BO_pi*Cln_BOp_pi)*delij[d]; + for (int d = 0; d < 3; d++) dln_BOp_pi2_i[d] = -(BO_pi2*Cln_BOp_pi2)*delij[d]; + for (int d = 0; d < 3; d++) dBOp_i[d] = -(BO_s*Cln_BOp_s+BO_pi*Cln_BOp_pi+BO_pi2*Cln_BOp_pi2)*delij[d]; + for (int d = 0; d < 3; d++) dDeltap_self_i[d] += dBOp_i[d]; + + d_dln_BOp_pix(i,j_index) = dln_BOp_pi_i[0]; + d_dln_BOp_piy(i,j_index) = dln_BOp_pi_i[1]; + d_dln_BOp_piz(i,j_index) = dln_BOp_pi_i[2]; + + d_dln_BOp_pi2x(i,j_index) = dln_BOp_pi2_i[0]; + d_dln_BOp_pi2y(i,j_index) = dln_BOp_pi2_i[1]; + d_dln_BOp_pi2z(i,j_index) = dln_BOp_pi2_i[2]; + + d_dBOpx(i,j_index) = dBOp_i[0]; + d_dBOpy(i,j_index) = dBOp_i[1]; + d_dBOpz(i,j_index) = dBOp_i[2]; + + d_BO(i,j_index) -= bo_cut; + d_BO_s(i,j_index) -= bo_cut; + total_bo_i += d_BO(i,j_index); + } + + for (int d = 0; d < 3; d++) + d_dDeltap_self(i,d) = dDeltap_self_i[d]; + + d_total_bo[i] = total_bo_i; +} + +/* ---------------------------------------------------------------------- */ + template KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::operator()(TagPairReaxBondOrder1, const int &ii) const { diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index c22a8ed275..e3dd3418b2 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -57,15 +57,15 @@ struct TagPairReaxComputeLJCoulombShortNeigh{}; template struct TagPairReaxComputeTabulatedLJCoulomb{}; +template +struct TagPairReaxBuildListsHalfBlocking{}; + template struct TagPairReaxBuildListsHalfBlockingPreview{}; template struct TagPairReaxBuildListsHalfPreview{}; -template -struct TagPairReaxBuildListsHalfBlocking{}; - struct TagPairReaxBuildListsFull{}; struct TagPairReaxZero{}; @@ -165,6 +165,10 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxComputeLJCoulombShortNeigh, const int&) const; + template + KOKKOS_INLINE_FUNCTION + void operator()(TagPairReaxBuildListsHalfBlocking, const int&) const; + template KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsHalfBlockingPreview, const int&) const; @@ -173,10 +177,6 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsHalfPreview, const int&) const; - template - KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxBuildListsHalfBlocking, const int&) const; - KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxBuildListsFull, const int&) const; From ee2b9f28cb2bbbda831163fd9daada80ddac3b5f Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 08:09:25 -0700 Subject: [PATCH 15/72] Switch to vector parallelism for half list in QEq --- src/KOKKOS/fix_qeq_reaxff_kokkos.cpp | 92 +++++++++++++++------------- src/KOKKOS/fix_qeq_reaxff_kokkos.h | 2 +- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index bd5baa81f5..8634ebc56a 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -858,6 +858,19 @@ void FixQEqReaxFFKokkos::sparse_matvec_kokkos(typename AT::t_ffloat2 Kokkos::parallel_for(Kokkos::RangePolicy(0,nn),*this); + int teamsize; + int vectorsize; + int leaguesize; + if (execution_space == Host) { + teamsize = 1; + vectorsize = 1; + leaguesize = nn; + } else { + teamsize = FixQEqReaxFFKokkos::spmv_teamsize; + vectorsize = FixQEqReaxFFKokkos::vectorsize; + leaguesize = (nn + teamsize - 1) / (teamsize); + } + if (neighflag != FULL) { Kokkos::parallel_for(Kokkos::RangePolicy(nn,NN),*this); @@ -865,28 +878,14 @@ void FixQEqReaxFFKokkos::sparse_matvec_kokkos(typename AT::t_ffloat2 dup_o.reset_except(d_o); if (neighflag == HALF) - Kokkos::parallel_for(Kokkos::RangePolicy >(0,nn),*this); + Kokkos::parallel_for(Kokkos::TeamPolicy>(leaguesize, teamsize, vectorsize), *this); else if (neighflag == HALFTHREAD) - Kokkos::parallel_for(Kokkos::RangePolicy >(0,nn),*this); + Kokkos::parallel_for(Kokkos::TeamPolicy>(leaguesize, teamsize, vectorsize), *this); if (need_dup) Kokkos::Experimental::contribute(d_o, dup_o); - } else { // FULL - int teamsize; - int vectorsize; - int leaguesize; - if (execution_space == Host) { - teamsize = 1; - vectorsize = 1; - leaguesize = nn; - } else { - teamsize = FixQEqReaxFFKokkos::spmv_teamsize; - vectorsize = FixQEqReaxFFKokkos::vectorsize; - leaguesize = (nn + teamsize - 1) / (teamsize); - } - + } else // FULL Kokkos::parallel_for(Kokkos::TeamPolicy (leaguesize, teamsize, vectorsize), *this); - } } /* ---------------------------------------------------------------------- */ @@ -925,34 +924,39 @@ void FixQEqReaxFFKokkos::operator()(TagQEqZeroQGhosts, const int &i) template template KOKKOS_INLINE_FUNCTION -void FixQEqReaxFFKokkos::operator()(TagQEqSparseMatvec2_Half, const int &ii) const -{ - // The q array is duplicated for OpenMP, atomic for CUDA, and neither for Serial - auto v_o = ScatterViewHelper,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); - auto a_o = v_o.template access>(); - - const int i = d_ilist[ii]; - if (mask[i] & groupbit) { - F_FLOAT2 tmp; - const auto d_xx_i0 = d_xx(i,0); - const auto d_xx_i1 = d_xx(i,1); - - for (int jj = d_firstnbr[i]; jj < d_firstnbr[i] + d_numnbrs[i]; jj++) { - const int j = d_jlist(jj); - const auto d_val_jj = d_val(jj); - if (!(converged & 1)) { - tmp.v[0] += d_val_jj * d_xx(j,0); - a_o(j,0) += d_val_jj * d_xx_i0; - } - if (!(converged & 2)) { - tmp.v[1] += d_val_jj * d_xx(j,1); - a_o(j,1) += d_val_jj * d_xx_i1; - } +void FixQEqReaxFFKokkos::operator()(TagQEqSparseMatvec2_Half, const typename Kokkos::TeamPolicy>::member_type &team) const +{ + int k = team.league_rank() * team.team_size() + team.team_rank(); + if (k < nn) { + // The q array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + auto v_o = ScatterViewHelper,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); + auto a_o = v_o.template access>(); + + const int i = d_ilist[k]; + if (mask[i] & groupbit) { + F_FLOAT2 tmp; + const double d_xx_i0 = d_xx(i,0); + const double d_xx_i1 = d_xx(i,1); + + Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, d_firstnbr[i], d_firstnbr[i] + d_numnbrs[i]), [&] (const int &jj, F_FLOAT2& tmp) { + const int j = d_jlist(jj); + const auto d_val_jj = d_val(jj); + if (!(converged & 1)) { + tmp.v[0] += d_val_jj * d_xx(j,0); + a_o(j,0) += d_val_jj * d_xx_i0; + } + if (!(converged & 2)) { + tmp.v[1] += d_val_jj * d_xx(j,1); + a_o(j,1) += d_val_jj * d_xx_i1; + } + }, tmp); + Kokkos::single(Kokkos::PerThread(team), [&] () { + if (!(converged & 1)) + a_o(i,0) += tmp.v[0]; + if (!(converged & 2)) + a_o(i,1) += tmp.v[1]; + }); } - if (!(converged & 1)) - a_o(i,0) += tmp.v[0]; - if (!(converged & 2)) - a_o(i,1) += tmp.v[1]; } } diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.h b/src/KOKKOS/fix_qeq_reaxff_kokkos.h index 5c2509129a..bd38522811 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.h +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.h @@ -92,7 +92,7 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { template KOKKOS_INLINE_FUNCTION - void operator()(TagQEqSparseMatvec2_Half, const int&) const; + void operator()(TagQEqSparseMatvec2_Half, const typename Kokkos::TeamPolicy>::member_type &team) const; typedef typename Kokkos::TeamPolicy::member_type membertype_vec; KOKKOS_INLINE_FUNCTION From 9083ff867e4fba16cebf9dade5fccc94bfcdd844 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 08:48:36 -0700 Subject: [PATCH 16/72] whitespace --- src/KOKKOS/fix_qeq_reaxff_kokkos.cpp | 6 +++--- src/KOKKOS/pair_reaxff_kokkos.cpp | 29 ++++++++++++---------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index 8634ebc56a..a23212f4b7 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -925,19 +925,19 @@ template template KOKKOS_INLINE_FUNCTION void FixQEqReaxFFKokkos::operator()(TagQEqSparseMatvec2_Half, const typename Kokkos::TeamPolicy>::member_type &team) const -{ +{ int k = team.league_rank() * team.team_size() + team.team_rank(); if (k < nn) { // The q array is duplicated for OpenMP, atomic for CUDA, and neither for Serial auto v_o = ScatterViewHelper,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); auto a_o = v_o.template access>(); - + const int i = d_ilist[k]; if (mask[i] & groupbit) { F_FLOAT2 tmp; const double d_xx_i0 = d_xx(i,0); const double d_xx_i1 = d_xx(i,1); - + Kokkos::parallel_reduce(Kokkos::ThreadVectorRange(team, d_firstnbr[i], d_firstnbr[i] + d_numnbrs[i]), [&] (const int &jj, F_FLOAT2& tmp) { const int j = d_jlist(jj); const auto d_val_jj = d_val(jj); diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 9f43ee1820..2d46cb99c8 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -1620,7 +1620,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< int jj_current = 0; while (jj_current < jnum) { - nnz=0; + nnz = 0; while (nnz < blocksize) { int jj = jj_current; @@ -1636,7 +1636,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; if (rsq <= cutoffsq) { selected_jj[nnz] = jj_current; @@ -1658,7 +1658,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; double cutoffsq; - if(i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); + if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); else cutoffsq = cut_bosq; // hbond list @@ -1668,9 +1668,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< if (NEIGHFLAG == HALF) { j_index = hb_first_i + d_hb_num[i]; d_hb_num[i]++; - } else { + } else j_index = hb_first_i + Kokkos::atomic_fetch_add(&d_hb_num[i],1); - } const int jj_index = j_index - hb_first_i; @@ -1711,20 +1710,17 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { C12 = p_bo1*pow(rij/r_s,p_bo2); BO_s = (1.0+bo_cut)*exp(C12); - } - else BO_s = C12 = 0.0; + } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { C34 = p_bo3*pow(rij/r_pi,p_bo4); BO_pi = exp(C34); - } - else BO_pi = C34 = 0.0; + } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { C56 = p_bo5*pow(rij/r_pi2,p_bo6); BO_pi2 = exp(C56); - } - else BO_pi2 = C56 = 0.0; + } else BO_pi2 = C56 = 0.0; BO = BO_s + BO_pi + BO_pi2; if (BO < bo_cut) continue; @@ -1734,8 +1730,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< i_index = d_bo_first[j] + d_bo_num[j]; d_bo_num[i]++; d_bo_num[j]++; - } - else { + } else { j_index = bo_first_i + Kokkos::atomic_fetch_add(&d_bo_num[i],1); i_index = d_bo_first[j] + Kokkos::atomic_fetch_add(&d_bo_num[j],1); } @@ -3157,7 +3152,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) tan_ijk_i = cos_ijk / 1e-10; - else if(sin_ijk <= 0 && sin_ijk >= -1e-10) + else if (sin_ijk <= 0 && sin_ijk >= -1e-10) tan_ijk_i = -cos_ijk / 1e-10; else tan_ijk_i = cos_ijk / sin_ijk; @@ -3199,7 +3194,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsion= 0 && sin_jil <= 1e-10) tan_jil_i = cos_jil / 1e-10; - else if(sin_jil <= 0 && sin_jil >= -1e-10) + else if (sin_jil <= 0 && sin_jil >= -1e-10) tan_jil_i = -cos_jil / 1e-10; else tan_jil_i = cos_jil / sin_jil; @@ -3250,9 +3245,9 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTorsion= 0 && sin_ijk <= 1e-10) sin_ijk_rnd = 1e-10; - else if(sin_ijk <= 0 && sin_ijk >= -1e-10) sin_ijk_rnd = -1e-10; + else if (sin_ijk <= 0 && sin_ijk >= -1e-10) sin_ijk_rnd = -1e-10; if (sin_jil >= 0 && sin_jil <= 1e-10) sin_jil_rnd = 1e-10; - else if(sin_jil <= 0 && sin_jil >= -1e-10) sin_jil_rnd = -1e-10; + else if (sin_jil <= 0 && sin_jil >= -1e-10) sin_jil_rnd = -1e-10; // dcos_omega_di for (int d = 0; d < 3; d++) dcos_omega_dk[d] = ((htra-arg*hnra)/rik) * delik[d] - dellk[d]; From 0fbacd4c5d484b466c558ec11da64a325b907360 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 09:02:47 -0700 Subject: [PATCH 17/72] Add missing optimization to CPU version --- src/KOKKOS/pair_reaxff_kokkos.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 2d46cb99c8..0cfc3fd464 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -21,6 +21,7 @@ number of exponentials evaluated, etc. - Added blocking to the Torsion and (optionally) BuildLists kernels, to reduce thread divergence on GPUs + - Added preview to BuildLists kernels along with full version ------------------------------------------------------------------------- */ #include "pair_reaxff_kokkos.h" @@ -1708,17 +1709,17 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< const F_FLOAT r_pi2 = paramstwbp(itype,jtype).r_pi2; if (paramssing(itype).r_s > 0.0 && paramssing(jtype).r_s > 0.0) { - C12 = p_bo1*pow(rij/r_s,p_bo2); + C12 = p_bo1 * ((p_bo2 != 0) ? (pow(rij/r_s,p_bo2)) : 1.0); BO_s = (1.0+bo_cut)*exp(C12); } else BO_s = C12 = 0.0; if (paramssing(itype).r_pi > 0.0 && paramssing(jtype).r_pi > 0.0) { - C34 = p_bo3*pow(rij/r_pi,p_bo4); + C34 = p_bo3 * ((p_bo4 != 0) ? (pow(rij/r_pi,p_bo4)) : 1.0); BO_pi = exp(C34); } else BO_pi = C34 = 0.0; if (paramssing(itype).r_pi2 > 0.0 && paramssing(jtype).r_pi2 > 0.0) { - C56 = p_bo5*pow(rij/r_pi2,p_bo6); + C56 = p_bo5 * ((p_bo6 != 0) ? (pow(rij/r_pi2,p_bo6)) : 1.0); BO_pi2 = exp(C56); } else BO_pi2 = C56 = 0.0; From 569147bf1180b80ca81c8c9be36e170e44d60714 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 09:30:16 -0700 Subject: [PATCH 18/72] Revert change of default value for list/blocking --- doc/src/pair_reaxff.rst | 7 ++++--- src/REAXFF/pair_reaxff.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/src/pair_reaxff.rst b/doc/src/pair_reaxff.rst index 4e88a3585c..d0c333af4b 100644 --- a/doc/src/pair_reaxff.rst +++ b/doc/src/pair_reaxff.rst @@ -163,8 +163,9 @@ The keyword *list/blocking* is only supported by the Kokkos version of ReaxFF and ignored otherwise. Setting the value to *yes* enables the "blocking" scheme (dynamically building interaction lists) for the ReaxFF bond neighbor list. This reduces the number of empty -interactions but can reduce performance in some cases (e.g. small -number of atoms/GPU on AMD hardware). +interactions and can improve performance in some cases (e.g. large +number of atoms/GPU on AMD hardware). It is also enabled by default +when running the CPU with Kokkos. The thermo variable *evdwl* stores the sum of all the ReaxFF potential energy contributions, with the exception of the Coulombic and charge @@ -369,7 +370,7 @@ Default """"""" The keyword defaults are checkqeq = yes, enobonds = yes, lgvdw = no, -safezone = 1.2, mincap = 50, minhbonds = 25, list/blocking = yes. +safezone = 1.2, mincap = 50, minhbonds = 25, list/blocking = yes on CPU, no on GPU. ---------- diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 6dc2f7685b..39b6221d3d 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -113,7 +113,7 @@ PairReaxFF::PairReaxFF(LAMMPS *lmp) : Pair(lmp) nmax = 0; - list_blocking_flag = 1; + list_blocking_flag = 0; } /* ---------------------------------------------------------------------- */ From e5d2555cf2a3ad470ff76da32267c9857c42b1a9 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 10:01:16 -0700 Subject: [PATCH 19/72] small tweaks --- src/KOKKOS/fix_qeq_reaxff_kokkos.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index a23212f4b7..2a73a4ece2 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -934,27 +934,27 @@ void FixQEqReaxFFKokkos::operator()(TagQEqSparseMatvec2_Half KOKKOS_INLINE_FUNCTION void FixQEqReaxFFKokkos::operator()(TagQEqSparseMatvec2_Full, const membertype_vec &team) const { - int k = team.league_rank () * team.team_size () + team.team_rank (); + int k = team.league_rank() * team.team_size() + team.team_rank(); if (k < nn) { const int i = d_ilist[k]; if (mask[i] & groupbit) { From e4d920d5826df340169168e58a905900a5754a9d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 3 Mar 2022 17:02:07 -0500 Subject: [PATCH 20/72] add minimal test for testing compute styles that compute global scalars --- unittest/commands/CMakeLists.txt | 5 + unittest/commands/test_compute_global.cpp | 115 ++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 unittest/commands/test_compute_global.cpp diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index d4f437dc4c..6d5ea802d4 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -41,6 +41,11 @@ target_compile_definitions(test_reset_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CU target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock) add_test(NAME ResetIDs COMMAND test_reset_ids) +add_executable(test_compute_global test_compute_global.cpp) +target_compile_definitions(test_compute_global PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(test_compute_global PRIVATE lammps GTest::GMock) +add_test(NAME ComputeGlobal COMMAND test_compute_global) + add_executable(test_mpi_load_balancing test_mpi_load_balancing.cpp) target_link_libraries(test_mpi_load_balancing PRIVATE lammps GTest::GMock) target_compile_definitions(test_mpi_load_balancing PRIVATE ${TEST_CONFIG_DEFS}) diff --git a/unittest/commands/test_compute_global.cpp b/unittest/commands/test_compute_global.cpp new file mode 100644 index 0000000000..b4511bc178 --- /dev/null +++ b/unittest/commands/test_compute_global.cpp @@ -0,0 +1,115 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 "../testing/core.h" +#include "info.h" +#include "input.h" +#include "lammps.h" +#include "library.h" +#include "utils.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include +#include + +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + +using LAMMPS_NS::utils::split_words; + +namespace LAMMPS_NS { + +#define STRINGIFY(val) XSTR(val) +#define XSTR(val) #val + +class ComputeGlobalTest : public LAMMPSTest { +protected: + void SetUp() override + { + testbinary = "ComputeGlobalTest"; + LAMMPSTest::SetUp(); + if (info->has_style("atom", "full")) { + BEGIN_HIDE_OUTPUT(); + command("variable input_dir index \"" STRINGIFY(TEST_INPUT_FOLDER) "\""); + command("include \"${input_dir}/in.fourmol\""); + END_HIDE_OUTPUT(); + } + } +}; + +TEST_F(ComputeGlobalTest, Energy) +{ + void *handle = (void *) lmp; + if (lammps_get_natoms(handle) == 0.0) GTEST_SKIP(); + + BEGIN_HIDE_OUTPUT(); + command("group allwater molecule 3:6"); + command("compute ke1 all ke"); + command("compute ke2 allwater ke"); + command("compute pe1 all pe"); + command("compute pe2 all pe bond"); + command("compute pe3 all pe angle dihedral"); + command("pair_style lj/cut 10.0"); + command("pair_coeff * * 0.01 3.0"); + command("bond_style harmonic"); + command("bond_coeff * 100.0 1.5"); + command("thermo_style custom c_ke1 c_ke2 c_pe1 c_pe2 c_pe3"); + command("run 0 post no"); + END_HIDE_OUTPUT(); + + double ke1 = *(double *)lammps_extract_compute(handle, "ke1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + double ke2 = *(double *)lammps_extract_compute(handle, "ke2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + double pe1 = *(double *)lammps_extract_compute(handle, "pe1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + double pe2 = *(double *)lammps_extract_compute(handle, "pe2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + double pe3 = *(double *)lammps_extract_compute(handle, "pe3", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + + EXPECT_DOUBLE_EQ(ke1, 2.3405256449146168); + EXPECT_DOUBLE_EQ(ke2, 1.192924237073665); + EXPECT_DOUBLE_EQ(pe1, 24280.922367235136); + EXPECT_DOUBLE_EQ(pe2, 361.37528652881286); + EXPECT_DOUBLE_EQ(pe3, 0.0); + + + TEST_FAILURE(".*ERROR: Reuse of compute ID 'pe2'.*", command("compute pe2 all pe");); + TEST_FAILURE(".*ERROR: Compute pe must use group all.*", command("compute pe allwater pe");); + TEST_FAILURE(".*ERROR: Illegal compute command.*", command("compute pe potential");); +} + +} // namespace LAMMPS_NS + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + + if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions()) + std::cout << "Warning: using OpenMPI without exceptions. " + "Death tests will be skipped\n"; + + // handle arguments passed via environment variable + if (const char *var = getenv("TEST_ARGS")) { + std::vector env = split_words(var); + for (auto arg : env) { + if (arg == "-v") { + verbose = true; + } + } + } + + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; +} From 3bfb03bcb8f26d44560e859f5053226b0dbd7035 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 3 Mar 2022 17:26:12 -0500 Subject: [PATCH 21/72] test compute com and compute dipole --- unittest/commands/test_compute_global.cpp | 55 ++++++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/unittest/commands/test_compute_global.cpp b/unittest/commands/test_compute_global.cpp index b4511bc178..e14f071f0d 100644 --- a/unittest/commands/test_compute_global.cpp +++ b/unittest/commands/test_compute_global.cpp @@ -50,7 +50,7 @@ protected: TEST_F(ComputeGlobalTest, Energy) { - void *handle = (void *) lmp; + void *handle = (void *)lmp; if (lammps_get_natoms(handle) == 0.0) GTEST_SKIP(); BEGIN_HIDE_OUTPUT(); @@ -68,24 +68,65 @@ TEST_F(ComputeGlobalTest, Energy) command("run 0 post no"); END_HIDE_OUTPUT(); - double ke1 = *(double *)lammps_extract_compute(handle, "ke1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - double ke2 = *(double *)lammps_extract_compute(handle, "ke2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - double pe1 = *(double *)lammps_extract_compute(handle, "pe1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - double pe2 = *(double *)lammps_extract_compute(handle, "pe2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - double pe3 = *(double *)lammps_extract_compute(handle, "pe3", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto ke1 = *(double *)lammps_extract_compute(handle, "ke1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto ke2 = *(double *)lammps_extract_compute(handle, "ke2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto pe1 = *(double *)lammps_extract_compute(handle, "pe1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto pe2 = *(double *)lammps_extract_compute(handle, "pe2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto pe3 = *(double *)lammps_extract_compute(handle, "pe3", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); EXPECT_DOUBLE_EQ(ke1, 2.3405256449146168); EXPECT_DOUBLE_EQ(ke2, 1.192924237073665); EXPECT_DOUBLE_EQ(pe1, 24280.922367235136); EXPECT_DOUBLE_EQ(pe2, 361.37528652881286); EXPECT_DOUBLE_EQ(pe3, 0.0); - TEST_FAILURE(".*ERROR: Reuse of compute ID 'pe2'.*", command("compute pe2 all pe");); TEST_FAILURE(".*ERROR: Compute pe must use group all.*", command("compute pe allwater pe");); TEST_FAILURE(".*ERROR: Illegal compute command.*", command("compute pe potential");); } +TEST_F(ComputeGlobalTest, Geometry) +{ + void *handle = (void *)lmp; + if (lammps_get_natoms(handle) == 0.0) GTEST_SKIP(); + + BEGIN_HIDE_OUTPUT(); + command("group allwater molecule 3:6"); + command("compute com1 all com"); + command("compute com2 allwater com"); + command("compute mu1 all dipole"); + command("compute mu2 allwater dipole geometry "); + command("pair_style lj/cut 10.0"); + command("pair_coeff * * 0.01 3.0"); + command("bond_style harmonic"); + command("bond_coeff * 100.0 1.5"); + command("thermo_style custom c_com1[*] c_com2[*] c_mu1 c_mu2"); + command("run 0 post no"); + END_HIDE_OUTPUT(); + + auto com1 = (double *)lammps_extract_compute(handle, "com1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + auto com2 = (double *)lammps_extract_compute(handle, "com2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + auto mu1 = *(double *)lammps_extract_compute(handle, "mu1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto mu2 = *(double *)lammps_extract_compute(handle, "mu2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto dip1 = (double *)lammps_extract_compute(handle, "mu1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + auto dip2 = (double *)lammps_extract_compute(handle, "mu2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + + EXPECT_DOUBLE_EQ(com1[0], 1.4300952724948282); + EXPECT_DOUBLE_EQ(com1[1], -0.29759806705328351); + EXPECT_DOUBLE_EQ(com1[2], -0.7245120195899285); + EXPECT_DOUBLE_EQ(com2[0], 1.7850913321989679); + EXPECT_DOUBLE_EQ(com2[1], -0.45168408952146238); + EXPECT_DOUBLE_EQ(com2[2], -0.60215022088294912); + EXPECT_DOUBLE_EQ(mu1, 1.8335537504770163); + EXPECT_DOUBLE_EQ(mu2, 1.7849382239204072); + EXPECT_DOUBLE_EQ(dip1[0], 0.41613191281297729); + EXPECT_DOUBLE_EQ(dip1[1], 1.0056523085627747); + EXPECT_DOUBLE_EQ(dip1[2], -1.4756073398127658); + EXPECT_DOUBLE_EQ(dip2[0], -0.029474795088977768); + EXPECT_DOUBLE_EQ(dip2[1], 1.153516133030746); + EXPECT_DOUBLE_EQ(dip2[2], -1.3618135814069394); +} + } // namespace LAMMPS_NS int main(int argc, char **argv) From 5888ba05146f12a618ef2125a29ac385c3167f5c Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 16:16:13 -0700 Subject: [PATCH 22/72] QEq does not require ghosts in the neighbor list --- src/KOKKOS/fix_acks2_reaxff_kokkos.cpp | 1 - src/KOKKOS/fix_qeq_reaxff_kokkos.cpp | 1 - src/REAXFF/fix_qeq_reaxff.cpp | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp b/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp index 2f7ed201a4..b131cc2be1 100644 --- a/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp @@ -115,7 +115,6 @@ void FixACKS2ReaxFFKokkos::init() neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - neighbor->requests[irequest]->ghost = 1; } int ntypes = atom->ntypes; diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index 2a73a4ece2..ba4c85e98c 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -117,7 +117,6 @@ void FixQEqReaxFFKokkos::init() neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->full = 0; neighbor->requests[irequest]->half = 1; - neighbor->requests[irequest]->ghost = 1; } int ntypes = atom->ntypes; diff --git a/src/REAXFF/fix_qeq_reaxff.cpp b/src/REAXFF/fix_qeq_reaxff.cpp index 796d363972..db5d5100ba 100644 --- a/src/REAXFF/fix_qeq_reaxff.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -416,14 +416,13 @@ void FixQEqReaxFF::init() "boundary when using charge equilibration with ReaxFF."); } - // we need a half neighbor list w/ Newton off and ghost neighbors + // we need a half neighbor list w/ Newton off // built whenever re-neighboring occurs int irequest = neighbor->request(this,instance_me); neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->fix = 1; neighbor->requests[irequest]->newton = 2; - neighbor->requests[irequest]->ghost = 1; init_shielding(); init_taper(); From f97a2d341c3bda067076577a6dcb38f42febefba Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 3 Mar 2022 16:44:53 -0700 Subject: [PATCH 23/72] Clean up evflags --- src/KOKKOS/pair_reaxff_kokkos.cpp | 121 +++++++++++++++--------------- src/KOKKOS/pair_reaxff_kokkos.h | 10 +-- 2 files changed, 67 insertions(+), 64 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 0cfc3fd464..a941bf2101 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -705,7 +705,7 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) k_params_fbp.template sync(); k_params_hbp.template sync(); - if (eflag || vflag) atomKK->modified(execution_space,datamask_modify); + if (eflag_either || vflag_either) atomKK->modified(execution_space,datamask_modify); else atomKK->modified(execution_space,F_MASK); x = atomKK->k_x.view(); @@ -762,15 +762,15 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) // Polarization (self) if (neighflag == HALF) { - if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); - else - Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); + if (eflag_global) + Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); + else if (eflag_atom) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); } else { //if (neighflag == HALFTHREAD) { - if (evflag) - Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); - else - Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); + if (eflag_global) + Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); + else if (eflag_atom) + Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); } ev_all += ev; pvector[13] = ev.ecoul; @@ -1125,9 +1125,9 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) /* ---------------------------------------------------------------------- */ template -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputePolar, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputePolar, const int &ii, EV_FLOAT_REAX& ev) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -1141,18 +1141,18 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputePolartemplate ev_tally(ev,i,i,epol,0.0,0.0,0.0,0.0); if (eflag_atom) this->template e_tally_single(ev,i,epol); } template -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputePolar, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputePolar, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(TagPairReaxComputePolar(), ii, ev); -} + this->template operator()(TagPairReaxComputePolar(), ii, ev); + } /* ---------------------------------------------------------------------- */ @@ -1329,10 +1329,12 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeLJCoulombtemplate ev_tally(ev,i,j,evdwl+ecoul,-ftotal,delx,dely,delz); + if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,evdwl+ecoul,-ftotal,delx,dely,delz); + } } a_f(i,0) += fxtmp; @@ -1474,10 +1476,12 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeTabulatedLJCoulo a_f(j,1) -= dely*ftotal; a_f(j,2) -= delz*ftotal; - if (eflag) ev.evdwl += evdwl; - if (eflag) ev.ecoul += ecoul; + if (EVFLAG) { + if (eflag_global) ev.evdwl += evdwl; + if (eflag_global) ev.ecoul += ecoul; - if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,evdwl+ecoul,-ftotal,delx,dely,delz); + if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,evdwl+ecoul,-ftotal,delx,dely,delz); + } } a_f(i,0) += fxtmp; @@ -2469,7 +2473,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2 0 || enobondsflag) a_CdDelta[i] += CElp; - if (eflag) ev.ereax[0] += e_lp; + if (EVFLAG && eflag_global) ev.ereax[0] += e_lp; //if (vflag_either || eflag_atom) this->template ev_tally(ev,i,i,e_lp,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,i,e_lp); @@ -2485,7 +2489,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2template ev_tally(ev,i,i,e_ov,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,i,e_ov); @@ -2506,7 +2510,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2 0 || enobondsflag) e_un = -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; - if (eflag) ev.ereax[2] += e_un; + if (EVFLAG && eflag_global) ev.ereax[2] += e_un; //if (eflag_atom) this->template ev_tally(ev,i,i,e_un,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,i,e_un); @@ -2549,8 +2553,10 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2template e_tally(ev,i,j,e_lph); + if (EVFLAG) { + if (eflag_global) ev.ereax[0] += e_lph; + if (eflag_atom) this->template e_tally(ev,i,j,e_lph); + } } } @@ -2790,7 +2796,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeAngular::operator()(TagPairReaxComputeAngular::operator()(TagPairReaxComputeAngular::operator()(TagPairReaxComputeTorsion::operator()(TagPairReaxComputeTorsion::operator()(TagPairReaxComputeHydrogen::operator()(TagPairReaxComputeHydrogentemplate e_tally(ev,i,j,e_hb); - if (vflag_either) this->template v_tally3(ev,i,j,k,fj_tmp,fk_tmp,delji,delki); + + if (EVFLAG) { + if (eflag_atom) this->template e_tally(ev,i,j,e_hb); + if (vflag_either) this->template v_tally3(ev,i,j,k,fj_tmp,fk_tmp,delji,delki); + } } } for (int d = 0; d < 3; d++) a_f(i,d) += fitmp[d]; @@ -3667,7 +3676,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1template ev_tally(ev,i,j,ebond,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,j,ebond); @@ -3689,7 +3698,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1template ev_tally(ev,i,j,estriph,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,j,estriph); @@ -3826,8 +3835,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2template v_tally(ev,i,temp,delij); + if (EVFLAG && vflag_either) this->template v_tally(ev,i,temp,delij); fitmp[0] -= temp[0]; fitmp[1] -= temp[1]; @@ -3849,11 +3857,10 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2template v_tally(ev,j,temp,tmpvec); - } + if (EVFLAG && vflag_either) { + for (int d = 0; d < 3; d++) tmpvec[d] = -delij[d]; + this->template v_tally(ev,j,temp,tmpvec); + } // forces on k: i neighbor for (int kk = j_start; kk < j_end; kk++) { @@ -3871,14 +3878,13 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2template v_tally(ev,k,temp,tmpvec); - } + if (EVFLAG && vflag_either) { + delik[0] = x(k,0) - xtmp; + delik[1] = x(k,1) - ytmp; + delik[2] = x(k,2) - ztmp; + for (int d = 0; d < 3; d++) tmpvec[d] = x(j,d) - x(k,d) - delik[d]; + this->template v_tally(ev,k,temp,tmpvec); + } } @@ -3898,14 +3904,11 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2template v_tally(ev,k,temp,tmpvec); - } + if (EVFLAG && vflag_either) { + for (int d = 0; d < 3; d++) deljk[d] = x(k,d) - x(j,d); + for (int d = 0; d < 3; d++) tmpvec[d] = x(i,d) - x(k,d) - deljk[d]; + this->template v_tally(ev,k,temp,tmpvec); } - } } for (int d = 0; d < 3; d++) a_f(i,d) += fitmp[d]; diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index e3dd3418b2..af4c4cc11d 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -46,7 +46,7 @@ struct LR_lookup_table_kk t_cubic_spline_coef_1d d_ele, d_CEclmb; }; -template +template struct TagPairReaxComputePolar{}; template @@ -138,13 +138,13 @@ class PairReaxFFKokkos : public PairReaxFF { void PackBondBuffer(DAT::tdual_ffloat_1d, int &); void FindBondSpecies(); - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputePolar, const int&, EV_FLOAT_REAX&) const; + void operator()(TagPairReaxComputePolar, const int&, EV_FLOAT_REAX&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputePolar, const int&) const; + void operator()(TagPairReaxComputePolar, const int&) const; template KOKKOS_INLINE_FUNCTION From 550d523c9e85f8d2552ec2e0b8f92a49b791aead Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Mar 2022 04:41:43 -0500 Subject: [PATCH 24/72] add gyration --- unittest/commands/test_compute_global.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/unittest/commands/test_compute_global.cpp b/unittest/commands/test_compute_global.cpp index e14f071f0d..1d879993fb 100644 --- a/unittest/commands/test_compute_global.cpp +++ b/unittest/commands/test_compute_global.cpp @@ -96,6 +96,8 @@ TEST_F(ComputeGlobalTest, Geometry) command("compute com2 allwater com"); command("compute mu1 all dipole"); command("compute mu2 allwater dipole geometry "); + command("compute rg1 all gyration"); + command("compute rg2 allwater gyration"); command("pair_style lj/cut 10.0"); command("pair_coeff * * 0.01 3.0"); command("bond_style harmonic"); @@ -110,6 +112,10 @@ TEST_F(ComputeGlobalTest, Geometry) auto mu2 = *(double *)lammps_extract_compute(handle, "mu2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); auto dip1 = (double *)lammps_extract_compute(handle, "mu1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); auto dip2 = (double *)lammps_extract_compute(handle, "mu2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + auto rg1 = *(double *)lammps_extract_compute(handle, "rg1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto rg2 = *(double *)lammps_extract_compute(handle, "rg2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + auto gyr1 = (double *)lammps_extract_compute(handle, "rg1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + auto gyr2 = (double *)lammps_extract_compute(handle, "rg2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); EXPECT_DOUBLE_EQ(com1[0], 1.4300952724948282); EXPECT_DOUBLE_EQ(com1[1], -0.29759806705328351); @@ -125,6 +131,20 @@ TEST_F(ComputeGlobalTest, Geometry) EXPECT_DOUBLE_EQ(dip2[0], -0.029474795088977768); EXPECT_DOUBLE_EQ(dip2[1], 1.153516133030746); EXPECT_DOUBLE_EQ(dip2[2], -1.3618135814069394); + EXPECT_DOUBLE_EQ(rg1, 1.8335537504770163 ); + EXPECT_DOUBLE_EQ(rg2, 1.7849382239204072 ); + EXPECT_DOUBLE_EQ(gyr1[0], 0.41613191281297729); + EXPECT_DOUBLE_EQ(gyr1[1], 1.0056523085627747 ); + EXPECT_DOUBLE_EQ(gyr1[2], -1.4756073398127658); + EXPECT_DOUBLE_EQ(gyr1[3], 0.41613191281297729); + EXPECT_DOUBLE_EQ(gyr1[4], 1.0056523085627747 ); + EXPECT_DOUBLE_EQ(gyr1[5], -1.4756073398127658); + EXPECT_DOUBLE_EQ(gyr2[0], -0.0294747950889778); + EXPECT_DOUBLE_EQ(gyr2[1], 1.153516133030746 ); + EXPECT_DOUBLE_EQ(gyr2[2], -1.3618135814069394); + EXPECT_DOUBLE_EQ(gyr2[3], -0.0294747950889778); + EXPECT_DOUBLE_EQ(gyr2[4], 1.153516133030746 ); + EXPECT_DOUBLE_EQ(gyr2[5], -1.3618135814069394); } } // namespace LAMMPS_NS From a70e895e062d598b7ccc984fc56b831605ee81e8 Mon Sep 17 00:00:00 2001 From: phankl Date: Fri, 4 Mar 2022 10:37:45 +0000 Subject: [PATCH 25/72] updated documentation --- doc/src/pair_mesocnt.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/src/pair_mesocnt.rst b/doc/src/pair_mesocnt.rst index 78a6680b6b..8779759618 100644 --- a/doc/src/pair_mesocnt.rst +++ b/doc/src/pair_mesocnt.rst @@ -94,10 +94,6 @@ boron nitride nanotubes. Atoms belonging to different CNTs need to be assigned different molecule IDs. -A full summary of the method and LAMMPS implementation details -is expected to soon become available in Computer Physics -Communications. - ---------- Mixing, shift, table, tail correction, restart, rRESPA info From b94995cf5b30b0b7adb3ea79ba9405c8244444b1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Mar 2022 06:24:37 -0500 Subject: [PATCH 26/72] add some TALLY package compute. simplify some code with convenience functions --- unittest/commands/test_compute_global.cpp | 119 ++++++++++++---------- 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/unittest/commands/test_compute_global.cpp b/unittest/commands/test_compute_global.cpp index 1d879993fb..2b8f86d4ce 100644 --- a/unittest/commands/test_compute_global.cpp +++ b/unittest/commands/test_compute_global.cpp @@ -43,42 +43,64 @@ protected: BEGIN_HIDE_OUTPUT(); command("variable input_dir index \"" STRINGIFY(TEST_INPUT_FOLDER) "\""); command("include \"${input_dir}/in.fourmol\""); + command("group allwater molecule 3:6"); END_HIDE_OUTPUT(); } } + + double get_scalar(const char *id) + { + return *(double *)lammps_extract_compute(lmp, id, LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + } + + double *get_vector(const char *id) + { + return (double *)lammps_extract_compute(lmp, id, LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + } }; TEST_F(ComputeGlobalTest, Energy) { - void *handle = (void *)lmp; - if (lammps_get_natoms(handle) == 0.0) GTEST_SKIP(); + if (lammps_get_natoms(lmp) == 0.0) GTEST_SKIP(); + int has_tally = lammps_config_has_package("TALLY"); BEGIN_HIDE_OUTPUT(); - command("group allwater molecule 3:6"); command("compute ke1 all ke"); command("compute ke2 allwater ke"); command("compute pe1 all pe"); command("compute pe2 all pe bond"); command("compute pe3 all pe angle dihedral"); - command("pair_style lj/cut 10.0"); + if (has_tally) { + command("compute pe4 all pe/tally allwater"); + command("compute pe5 all pe/mol/tally all"); + command("compute pe6 all pe pair"); + } + command("pair_style lj/cut/coul/cut 10.0"); command("pair_coeff * * 0.01 3.0"); command("bond_style harmonic"); command("bond_coeff * 100.0 1.5"); - command("thermo_style custom c_ke1 c_ke2 c_pe1 c_pe2 c_pe3"); + if (has_tally) { + command("thermo_style custom c_ke1 c_ke2 c_pe1 c_pe2 c_pe3 c_pe4 c_pe5[*]"); + } else { + command("thermo_style custom c_ke1 c_ke2 c_pe1 c_pe2 c_pe3"); + } command("run 0 post no"); END_HIDE_OUTPUT(); - auto ke1 = *(double *)lammps_extract_compute(handle, "ke1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto ke2 = *(double *)lammps_extract_compute(handle, "ke2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto pe1 = *(double *)lammps_extract_compute(handle, "pe1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto pe2 = *(double *)lammps_extract_compute(handle, "pe2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto pe3 = *(double *)lammps_extract_compute(handle, "pe3", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); + EXPECT_DOUBLE_EQ(get_scalar("ke1"), 2.3405256449146168); + EXPECT_DOUBLE_EQ(get_scalar("ke2"), 1.192924237073665); + EXPECT_DOUBLE_EQ(get_scalar("pe1"), 24155.155261642241); + EXPECT_DOUBLE_EQ(get_scalar("pe2"), 361.37528652881286); + EXPECT_DOUBLE_EQ(get_scalar("pe3"), 0.0); - EXPECT_DOUBLE_EQ(ke1, 2.3405256449146168); - EXPECT_DOUBLE_EQ(ke2, 1.192924237073665); - EXPECT_DOUBLE_EQ(pe1, 24280.922367235136); - EXPECT_DOUBLE_EQ(pe2, 361.37528652881286); - EXPECT_DOUBLE_EQ(pe3, 0.0); + if (has_tally) { + EXPECT_DOUBLE_EQ(get_scalar("pe4"), 15425.840923850392); + auto pe5 = get_vector("pe5"); + EXPECT_DOUBLE_EQ(pe5[0], 23803.966677151559); + EXPECT_DOUBLE_EQ(pe5[1], -94.210004432380643); + EXPECT_DOUBLE_EQ(pe5[2], 115.58040355478101); + EXPECT_DOUBLE_EQ(pe5[3], -31.557101160514257); + } TEST_FAILURE(".*ERROR: Reuse of compute ID 'pe2'.*", command("compute pe2 all pe");); TEST_FAILURE(".*ERROR: Compute pe must use group all.*", command("compute pe allwater pe");); @@ -87,11 +109,9 @@ TEST_F(ComputeGlobalTest, Energy) TEST_F(ComputeGlobalTest, Geometry) { - void *handle = (void *)lmp; - if (lammps_get_natoms(handle) == 0.0) GTEST_SKIP(); + if (lammps_get_natoms(lmp) == 0.0) GTEST_SKIP(); BEGIN_HIDE_OUTPUT(); - command("group allwater molecule 3:6"); command("compute com1 all com"); command("compute com2 allwater com"); command("compute mu1 all dipole"); @@ -106,16 +126,12 @@ TEST_F(ComputeGlobalTest, Geometry) command("run 0 post no"); END_HIDE_OUTPUT(); - auto com1 = (double *)lammps_extract_compute(handle, "com1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); - auto com2 = (double *)lammps_extract_compute(handle, "com2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); - auto mu1 = *(double *)lammps_extract_compute(handle, "mu1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto mu2 = *(double *)lammps_extract_compute(handle, "mu2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto dip1 = (double *)lammps_extract_compute(handle, "mu1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); - auto dip2 = (double *)lammps_extract_compute(handle, "mu2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); - auto rg1 = *(double *)lammps_extract_compute(handle, "rg1", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto rg2 = *(double *)lammps_extract_compute(handle, "rg2", LMP_STYLE_GLOBAL, LMP_TYPE_SCALAR); - auto gyr1 = (double *)lammps_extract_compute(handle, "rg1", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); - auto gyr2 = (double *)lammps_extract_compute(handle, "rg2", LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); + auto com1 = get_vector("com1"); + auto com2 = get_vector("com2"); + auto mu1 = get_vector("mu1"); + auto mu2 = get_vector("mu2"); + auto rg1 = get_vector("rg1"); + auto rg2 = get_vector("rg2"); EXPECT_DOUBLE_EQ(com1[0], 1.4300952724948282); EXPECT_DOUBLE_EQ(com1[1], -0.29759806705328351); @@ -123,28 +139,28 @@ TEST_F(ComputeGlobalTest, Geometry) EXPECT_DOUBLE_EQ(com2[0], 1.7850913321989679); EXPECT_DOUBLE_EQ(com2[1], -0.45168408952146238); EXPECT_DOUBLE_EQ(com2[2], -0.60215022088294912); - EXPECT_DOUBLE_EQ(mu1, 1.8335537504770163); - EXPECT_DOUBLE_EQ(mu2, 1.7849382239204072); - EXPECT_DOUBLE_EQ(dip1[0], 0.41613191281297729); - EXPECT_DOUBLE_EQ(dip1[1], 1.0056523085627747); - EXPECT_DOUBLE_EQ(dip1[2], -1.4756073398127658); - EXPECT_DOUBLE_EQ(dip2[0], -0.029474795088977768); - EXPECT_DOUBLE_EQ(dip2[1], 1.153516133030746); - EXPECT_DOUBLE_EQ(dip2[2], -1.3618135814069394); - EXPECT_DOUBLE_EQ(rg1, 1.8335537504770163 ); - EXPECT_DOUBLE_EQ(rg2, 1.7849382239204072 ); - EXPECT_DOUBLE_EQ(gyr1[0], 0.41613191281297729); - EXPECT_DOUBLE_EQ(gyr1[1], 1.0056523085627747 ); - EXPECT_DOUBLE_EQ(gyr1[2], -1.4756073398127658); - EXPECT_DOUBLE_EQ(gyr1[3], 0.41613191281297729); - EXPECT_DOUBLE_EQ(gyr1[4], 1.0056523085627747 ); - EXPECT_DOUBLE_EQ(gyr1[5], -1.4756073398127658); - EXPECT_DOUBLE_EQ(gyr2[0], -0.0294747950889778); - EXPECT_DOUBLE_EQ(gyr2[1], 1.153516133030746 ); - EXPECT_DOUBLE_EQ(gyr2[2], -1.3618135814069394); - EXPECT_DOUBLE_EQ(gyr2[3], -0.0294747950889778); - EXPECT_DOUBLE_EQ(gyr2[4], 1.153516133030746 ); - EXPECT_DOUBLE_EQ(gyr2[5], -1.3618135814069394); + EXPECT_DOUBLE_EQ(get_scalar("mu1"), 1.8335537504770163); + EXPECT_DOUBLE_EQ(get_scalar("mu2"), 1.7849382239204072); + EXPECT_DOUBLE_EQ(mu1[0], 0.41613191281297729); + EXPECT_DOUBLE_EQ(mu1[1], 1.0056523085627747); + EXPECT_DOUBLE_EQ(mu1[2], -1.4756073398127658); + EXPECT_DOUBLE_EQ(mu2[0], -0.029474795088977768); + EXPECT_DOUBLE_EQ(mu2[1], 1.153516133030746); + EXPECT_DOUBLE_EQ(mu2[2], -1.3618135814069394); + EXPECT_DOUBLE_EQ(get_scalar("rg1"), 3.8495643473797196); + EXPECT_DOUBLE_EQ(get_scalar("rg2"), 5.4558163385611342); + EXPECT_DOUBLE_EQ(rg1[0], 3.6747807397432752); + EXPECT_DOUBLE_EQ(rg1[1], 6.5440303159316278); + EXPECT_DOUBLE_EQ(rg1[2], 4.6003346089421457); + EXPECT_DOUBLE_EQ(rg1[3], -0.4639249501367636); + EXPECT_DOUBLE_EQ(rg1[4], -1.8859032304357459); + EXPECT_DOUBLE_EQ(rg1[5], 0.2339161878440186); + EXPECT_DOUBLE_EQ(rg2[0], 6.2582260148310143); + EXPECT_DOUBLE_EQ(rg2[1], 13.353763805454184); + EXPECT_DOUBLE_EQ(rg2[2], 10.153942099825425); + EXPECT_DOUBLE_EQ(rg2[3], 1.2965604701522486); + EXPECT_DOUBLE_EQ(rg2[4], -5.0315240817290841); + EXPECT_DOUBLE_EQ(rg2[5], 1.1103378503822141); } } // namespace LAMMPS_NS @@ -155,8 +171,7 @@ int main(int argc, char **argv) ::testing::InitGoogleMock(&argc, argv); if (platform::mpi_vendor() == "Open MPI" && !LAMMPS_NS::Info::has_exceptions()) - std::cout << "Warning: using OpenMPI without exceptions. " - "Death tests will be skipped\n"; + std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n"; // handle arguments passed via environment variable if (const char *var = getenv("TEST_ARGS")) { From 8b9be5bf0ad7b1e63d180432437d92e695dabe9e Mon Sep 17 00:00:00 2001 From: phankl Date: Fri, 4 Mar 2022 12:47:36 +0000 Subject: [PATCH 27/72] applied clang-format --- src/MESONT/pair_mesocnt.cpp | 1275 +++++++++++++++++------------------ src/MESONT/pair_mesocnt.h | 2 - 2 files changed, 607 insertions(+), 670 deletions(-) diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index 4214d2895f..ae9b460a11 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -96,27 +95,27 @@ PairMesoCNT::~PairMesoCNT() void PairMesoCNT::compute(int eflag, int vflag) { - int i,j,k,i1,i2,j1,j2; - int endflag,endindex; - int clen,numchain; - int *end,*nchain; + int i, j, k, i1, i2, j1, j2; + int endflag, endindex; + int clen, numchain; + int *end, *nchain; int **chain; - double fend,lp,scale,sumw,sumw_inv; - double evdwl,evdwl_chain; - double *r1,*r2,*q1,*q2,*qe; - double ftotal[3],ftorque[3],torque[3],delr1[3],delr2[3]; - double t1[3],t2[3]; - double dr1_sumw[3],dr2_sumw[3]; - double dr1_w[3],dr2_w[3],dq1_w[3],dq2_w[3]; - double fgrad_r1_p1[3],fgrad_r1_p2[3],fgrad_r2_p1[3],fgrad_r2_p2[3]; - double fgrad_q_p1[3],fgrad_q_p2[3]; - double q1_dr1_w[3][3],q1_dr2_w[3][3],q2_dr1_w[3][3],q2_dr2_w[3][3]; - double dr1_p1[3][3],dr1_p2[3][3],dr2_p1[3][3],dr2_p2[3][3]; - double dq_p1[3][3],dq_p2[3][3]; + double fend, lp, scale, sumw, sumw_inv; + double evdwl, evdwl_chain; + double *r1, *r2, *q1, *q2, *qe; + double ftotal[3], ftorque[3], torque[3], delr1[3], delr2[3]; + double t1[3], t2[3]; + double dr1_sumw[3], dr2_sumw[3]; + double dr1_w[3], dr2_w[3], dq1_w[3], dq2_w[3]; + double fgrad_r1_p1[3], fgrad_r1_p2[3], fgrad_r2_p1[3], fgrad_r2_p2[3]; + double fgrad_q_p1[3], fgrad_q_p2[3]; + double q1_dr1_w[3][3], q1_dr2_w[3][3], q2_dr1_w[3][3], q2_dr2_w[3][3]; + double dr1_p1[3][3], dr1_p2[3][3], dr2_p1[3][3], dr2_p2[3][3]; + double dq_p1[3][3], dq_p2[3][3]; double temp[3][3]; evdwl = 0.0; - ev_init(eflag,vflag); + ev_init(eflag, vflag); double **x = atom->x; double **f = atom->f; @@ -154,7 +153,7 @@ void PairMesoCNT::compute(int eflag, int vflag) endindex = chain[j][0]; qe = x[endindex]; } else if (endflag == 2) { - endindex = chain[j][clen-1]; + endindex = chain[j][clen - 1]; qe = x[endindex]; } @@ -176,159 +175,161 @@ void PairMesoCNT::compute(int eflag, int vflag) } sumw = 0.0; - for (k = 0; k < clen-1; k++) { + for (k = 0; k < clen - 1; k++) { j1 = chain[j][k]; - j2 = chain[j][k+1]; + j2 = chain[j][k + 1]; j1 &= NEIGHMASK; j2 &= NEIGHMASK; q1 = x[j1]; q2 = x[j2]; - weight(r1,r2,q1,q2,w[k],dr1_w,dr2_w,dq1_w,dq2_w); + weight(r1, r2, q1, q2, w[k], dr1_w, dr2_w, dq1_w, dq2_w); if (w[k] == 0.0) { - if (endflag == 1 && k == 0) endflag = 0; - else if (endflag == 2 && k == clen-2) endflag = 0; + if (endflag == 1 && k == 0) + endflag = 0; + else if (endflag == 2 && k == clen - 2) + endflag = 0; continue; } sumw += w[k]; wnode[k] += w[k]; - wnode[k+1] += w[k]; + wnode[k + 1] += w[k]; - scaleadd3(w[k],q1,p1,p1); - scaleadd3(w[k],q2,p2,p2); + scaleadd3(w[k], q1, p1, p1); + scaleadd3(w[k], q2, p2, p2); // weight gradient terms - add3(dr1_w,dr1_sumw,dr1_sumw); - add3(dr2_w,dr2_sumw,dr2_sumw); + add3(dr1_w, dr1_sumw, dr1_sumw); + add3(dr2_w, dr2_sumw, dr2_sumw); - outer3(q1,dr1_w,temp); - plus3(temp,q1_dr1_w,q1_dr1_w); - outer3(q2,dr1_w,temp); - plus3(temp,q2_dr1_w,q2_dr1_w); - outer3(q1,dr2_w,temp); - plus3(temp,q1_dr2_w,q1_dr2_w); - outer3(q2,dr2_w,temp); - plus3(temp,q2_dr2_w,q2_dr2_w); + outer3(q1, dr1_w, temp); + plus3(temp, q1_dr1_w, q1_dr1_w); + outer3(q2, dr1_w, temp); + plus3(temp, q2_dr1_w, q2_dr1_w); + outer3(q1, dr2_w, temp); + plus3(temp, q1_dr2_w, q1_dr2_w); + outer3(q2, dr2_w, temp); + plus3(temp, q2_dr2_w, q2_dr2_w); - add3(dq1_w,dq_w[k],dq_w[k]); - add3(dq2_w,dq_w[k+1],dq_w[k+1]); + add3(dq1_w, dq_w[k], dq_w[k]); + add3(dq2_w, dq_w[k + 1], dq_w[k + 1]); - outer3(q1,dq1_w,temp); - plus3(temp,q1_dq_w[k],q1_dq_w[k]); - outer3(q1,dq2_w,temp); - plus3(temp,q1_dq_w[k+1],q1_dq_w[k+1]); - outer3(q2,dq1_w,temp); - plus3(temp,q2_dq_w[k],q2_dq_w[k]); - outer3(q2,dq2_w,temp); - plus3(temp,q2_dq_w[k+1],q2_dq_w[k+1]); + outer3(q1, dq1_w, temp); + plus3(temp, q1_dq_w[k], q1_dq_w[k]); + outer3(q1, dq2_w, temp); + plus3(temp, q1_dq_w[k + 1], q1_dq_w[k + 1]); + outer3(q2, dq1_w, temp); + plus3(temp, q2_dq_w[k], q2_dq_w[k]); + outer3(q2, dq2_w, temp); + plus3(temp, q2_dq_w[k + 1], q2_dq_w[k + 1]); } if (sumw == 0.0) continue; sumw_inv = 1.0 / sumw; - scale3(sumw_inv,p1); - scale3(sumw_inv,p2); + scale3(sumw_inv, p1); + scale3(sumw_inv, p2); // compute geometry and forces // infinite CNT case if (endflag == 0) { - geometry(r1,r2,p1,p2,nullptr,p,m,param,basis); + geometry(r1, r2, p1, p2, nullptr, p, m, param, basis); if (param[0] > cutoff) continue; - finf(param,evdwl,flocal); + finf(param, evdwl, flocal); // semi-infinite CNT case with end at start of chain } else if (endflag == 1) { - geometry(r1,r2,p1,p2,qe,p,m,param,basis); + geometry(r1, r2, p1, p2, qe, p, m, param, basis); if (param[0] > cutoff) continue; - fsemi(param,evdwl,fend,flocal); + fsemi(param, evdwl, fend, flocal); // semi-infinite CNT case with end at end of chain } else { - geometry(r1,r2,p2,p1,qe,p,m,param,basis); + geometry(r1, r2, p2, p1, qe, p, m, param, basis); if (param[0] > cutoff) continue; - fsemi(param,evdwl,fend,flocal); + fsemi(param, evdwl, fend, flocal); } evdwl *= 0.5; // transform to global coordinate system - matvec(basis[0],basis[1],basis[2],flocal[0],fglobal[0]); - matvec(basis[0],basis[1],basis[2],flocal[1],fglobal[1]); + matvec(basis[0], basis[1], basis[2], flocal[0], fglobal[0]); + matvec(basis[0], basis[1], basis[2], flocal[1], fglobal[1]); // forces acting on approximate chain - add3(fglobal[0],fglobal[1],ftotal); - if (endflag) scaleadd3(fend,m,ftotal,ftotal); - scale3(-0.5,ftotal); + add3(fglobal[0], fglobal[1], ftotal); + if (endflag) scaleadd3(fend, m, ftotal, ftotal); + scale3(-0.5, ftotal); - sub3(r1,p,delr1); - sub3(r2,p,delr2); - cross3(delr1,fglobal[0],t1); - cross3(delr2,fglobal[1],t2); - add3(t1,t2,torque); + sub3(r1, p, delr1); + sub3(r2, p, delr2); + cross3(delr1, fglobal[0], t1); + cross3(delr2, fglobal[1], t2); + add3(t1, t2, torque); - cross3(torque,m,ftorque); + cross3(torque, m, ftorque); lp = param[5] - param[4]; - scale3(1.0/lp,ftorque); + scale3(1.0 / lp, ftorque); if (endflag == 2) { - add3(ftotal,ftorque,fglobal[3]); - sub3(ftotal,ftorque,fglobal[2]); + add3(ftotal, ftorque, fglobal[3]); + sub3(ftotal, ftorque, fglobal[2]); } else { - add3(ftotal,ftorque,fglobal[2]); - sub3(ftotal,ftorque,fglobal[3]); + add3(ftotal, ftorque, fglobal[2]); + sub3(ftotal, ftorque, fglobal[3]); } - scale3(0.5,fglobal[0]); - scale3(0.5,fglobal[1]); - scale3(0.5,fglobal[2]); - scale3(0.5,fglobal[3]); + scale3(0.5, fglobal[0]); + scale3(0.5, fglobal[1]); + scale3(0.5, fglobal[2]); + scale3(0.5, fglobal[3]); // weight gradient terms acting on current segment - outer3(p1,dr1_sumw,temp); - minus3(q1_dr1_w,temp,dr1_p1); - outer3(p2,dr1_sumw,temp); - minus3(q2_dr1_w,temp,dr1_p2); - outer3(p1,dr2_sumw,temp); - minus3(q1_dr2_w,temp,dr2_p1); - outer3(p2,dr2_sumw,temp); - minus3(q2_dr2_w,temp,dr2_p2); + outer3(p1, dr1_sumw, temp); + minus3(q1_dr1_w, temp, dr1_p1); + outer3(p2, dr1_sumw, temp); + minus3(q2_dr1_w, temp, dr1_p2); + outer3(p1, dr2_sumw, temp); + minus3(q1_dr2_w, temp, dr2_p1); + outer3(p2, dr2_sumw, temp); + minus3(q2_dr2_w, temp, dr2_p2); - transpose_matvec(dr1_p1,fglobal[2],fgrad_r1_p1); - transpose_matvec(dr1_p2,fglobal[3],fgrad_r1_p2); - transpose_matvec(dr2_p1,fglobal[2],fgrad_r2_p1); - transpose_matvec(dr2_p2,fglobal[3],fgrad_r2_p2); + transpose_matvec(dr1_p1, fglobal[2], fgrad_r1_p1); + transpose_matvec(dr1_p2, fglobal[3], fgrad_r1_p2); + transpose_matvec(dr2_p1, fglobal[2], fgrad_r2_p1); + transpose_matvec(dr2_p2, fglobal[3], fgrad_r2_p2); // add forces to nodes in current segment - add3(fglobal[0],f[i1],f[i1]); - add3(fglobal[1],f[i2],f[i2]); + add3(fglobal[0], f[i1], f[i1]); + add3(fglobal[1], f[i2], f[i2]); - scaleadd3(sumw_inv,fgrad_r1_p1,f[i1],f[i1]); - scaleadd3(sumw_inv,fgrad_r1_p2,f[i1],f[i1]); - scaleadd3(sumw_inv,fgrad_r2_p1,f[i2],f[i2]); - scaleadd3(sumw_inv,fgrad_r2_p2,f[i2],f[i2]); + scaleadd3(sumw_inv, fgrad_r1_p1, f[i1], f[i1]); + scaleadd3(sumw_inv, fgrad_r1_p2, f[i1], f[i1]); + scaleadd3(sumw_inv, fgrad_r2_p1, f[i2], f[i2]); + scaleadd3(sumw_inv, fgrad_r2_p2, f[i2], f[i2]); // add forces in approximate chain - for (k = 0; k < clen-1; k++) { + for (k = 0; k < clen - 1; k++) { if (w[k] == 0.0) continue; j1 = chain[j][k]; - j2 = chain[j][k+1]; + j2 = chain[j][k + 1]; j1 &= NEIGHMASK; j2 &= NEIGHMASK; scale = w[k] * sumw_inv; - scaleadd3(scale,fglobal[2],f[j1],f[j1]); - scaleadd3(scale,fglobal[3],f[j2],f[j2]); + scaleadd3(scale, fglobal[2], f[j1], f[j1]); + scaleadd3(scale, fglobal[3], f[j2], f[j2]); } // weight gradient terms acting on approximate chain @@ -339,21 +340,21 @@ void PairMesoCNT::compute(int eflag, int vflag) j1 = chain[j][k]; j1 &= NEIGHMASK; - outer3(p1,dq_w[k],temp); - minus3(q1_dq_w[k],temp,dq_p1); - outer3(p2,dq_w[k],temp); - minus3(q2_dq_w[k],temp,dq_p2); + outer3(p1, dq_w[k], temp); + minus3(q1_dq_w[k], temp, dq_p1); + outer3(p2, dq_w[k], temp); + minus3(q2_dq_w[k], temp, dq_p2); - transpose_matvec(dq_p1,fglobal[2],fgrad_q_p1); - transpose_matvec(dq_p2,fglobal[3],fgrad_q_p2); + transpose_matvec(dq_p1, fglobal[2], fgrad_q_p1); + transpose_matvec(dq_p2, fglobal[3], fgrad_q_p2); - scaleadd3(sumw_inv,fgrad_q_p1,f[j1],f[j1]); - scaleadd3(sumw_inv,fgrad_q_p2,f[j1],f[j1]); + scaleadd3(sumw_inv, fgrad_q_p1, f[j1], f[j1]); + scaleadd3(sumw_inv, fgrad_q_p2, f[j1], f[j1]); } // force on node at CNT end - if (endflag) scaleadd3(0.5*fend,m,f[endindex],f[endindex]); + if (endflag) scaleadd3(0.5 * fend, m, f[endindex], f[endindex]); // compute energy @@ -362,10 +363,10 @@ void PairMesoCNT::compute(int eflag, int vflag) if (eflag_atom) { eatom[i1] += 0.25 * evdwl; eatom[i2] += 0.25 * evdwl; - for (k = 0; k < clen-1; k++) { + for (k = 0; k < clen - 1; k++) { if (w[k] == 0.0) continue; j1 = chain[j][k]; - j2 = chain[j][k+1]; + j2 = chain[j][k + 1]; j1 &= NEIGHMASK; j2 &= NEIGHMASK; evdwl_chain = 0.5 * w[k] * sumw_inv * evdwl; @@ -388,34 +389,32 @@ void PairMesoCNT::allocate() int ntypes = atom->ntypes; int init_size = 1; - memory->create(cutsq,ntypes+1,ntypes+1,"pair:cutsq"); - memory->create(setflag,ntypes+1,ntypes+1,"pair:setflag"); + memory->create(cutsq, ntypes + 1, ntypes + 1, "pair:cutsq"); + memory->create(setflag, ntypes + 1, ntypes + 1, "pair:setflag"); for (int i = 1; i <= ntypes; i++) - for (int j = i; j <= ntypes; j++) - setflag[i][j] = 0; + for (int j = i; j <= ntypes; j++) setflag[i][j] = 0; - memory->create(uinf_coeff,uinf_points,4,"pair:uinf_coeff"); - memory->create(gamma_coeff,gamma_points,4,"pair:gamma_coeff"); - memory->create(phi_coeff,phi_points,phi_points,4,4,"pair:phi_coeff"); - memory->create(usemi_coeff,usemi_points,usemi_points,4,4,"pair:usemi_coeff"); + memory->create(uinf_coeff, uinf_points, 4, "pair:uinf_coeff"); + memory->create(gamma_coeff, gamma_points, 4, "pair:gamma_coeff"); + memory->create(phi_coeff, phi_points, phi_points, 4, 4, "pair:phi_coeff"); + memory->create(usemi_coeff, usemi_points, usemi_points, 4, 4, "pair:usemi_coeff"); - memory->create(numchainlist,init_size,"pair:numchainlist"); - memory->create(nchainlist,init_size,init_size,"pair:nchainlist"); - memory->create(endlist,init_size,init_size,"pair:endlist"); - memory->create(chainlist,init_size, - init_size,init_size,"pair:chainlist"); + memory->create(numchainlist, init_size, "pair:numchainlist"); + memory->create(nchainlist, init_size, init_size, "pair:nchainlist"); + memory->create(endlist, init_size, init_size, "pair:endlist"); + memory->create(chainlist, init_size, init_size, init_size, "pair:chainlist"); - memory->create(w,init_size,"pair:w"); - memory->create(wnode,init_size,"pair:wnode"); - memory->create(dq_w,init_size,3,"pair:dq_w"); - memory->create(q1_dq_w,init_size,3,3,"pair:q1_dq_w"); - memory->create(q2_dq_w,init_size,3,3,"pair:q2_dq_w"); + memory->create(w, init_size, "pair:w"); + memory->create(wnode, init_size, "pair:wnode"); + memory->create(dq_w, init_size, 3, "pair:dq_w"); + memory->create(q1_dq_w, init_size, 3, 3, "pair:q1_dq_w"); + memory->create(q2_dq_w, init_size, 3, 3, "pair:q2_dq_w"); - memory->create(param,7,"pair:param"); + memory->create(param, 7, "pair:param"); - memory->create(flocal,2,3,"pair:flocal"); - memory->create(fglobal,4,3,"pair:fglobal"); - memory->create(basis,3,3,"pair:basis"); + memory->create(flocal, 2, 3, "pair:flocal"); + memory->create(fglobal, 4, 3, "pair:fglobal"); + memory->create(basis, 3, 3, "pair:basis"); } /* ---------------------------------------------------------------------- @@ -424,7 +423,7 @@ void PairMesoCNT::allocate() void PairMesoCNT::settings(int narg, char ** /* arg */) { - if (narg != 0) error->all(FLERR,"Illegal pair_style command"); + if (narg != 0) error->all(FLERR, "Illegal pair_style command"); } /* ---------------------------------------------------------------------- @@ -433,7 +432,7 @@ void PairMesoCNT::settings(int narg, char ** /* arg */) void PairMesoCNT::coeff(int narg, char **arg) { - if (narg != 3) error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg != 3) error->all(FLERR, "Incorrect args for pair coefficients"); file = arg[2]; read_file(); if (!allocated) allocate(); @@ -441,16 +440,24 @@ void PairMesoCNT::coeff(int narg, char **arg) // units, eV to energy unit conversion ang = force->angstrom; ang_inv = 1.0 / ang; - if (strcmp(update->unit_style,"lj") == 0) - error->all(FLERR,"Pair style mesocnt does not support lj units"); - else if (strcmp(update->unit_style,"real") == 0) eunit = 23.06054966; - else if (strcmp(update->unit_style,"metal") == 0) eunit = 1.0; - else if (strcmp(update->unit_style,"si") == 0) eunit = 1.6021765e-19; - else if (strcmp(update->unit_style,"cgs") == 0) eunit = 1.6021765e-12; - else if (strcmp(update->unit_style,"electron") == 0) eunit = 3.674932248e-2; - else if (strcmp(update->unit_style,"micro") == 0) eunit = 1.6021765e-4; - else if (strcmp(update->unit_style,"nano") == 0) eunit = 1.6021765e2; - else error->all(FLERR,"Pair style mesocnt does not recognize this units style"); + if (strcmp(update->unit_style, "lj") == 0) + error->all(FLERR, "Pair style mesocnt does not support lj units"); + else if (strcmp(update->unit_style, "real") == 0) + eunit = 23.06054966; + else if (strcmp(update->unit_style, "metal") == 0) + eunit = 1.0; + else if (strcmp(update->unit_style, "si") == 0) + eunit = 1.6021765e-19; + else if (strcmp(update->unit_style, "cgs") == 0) + eunit = 1.6021765e-12; + else if (strcmp(update->unit_style, "electron") == 0) + eunit = 3.674932248e-2; + else if (strcmp(update->unit_style, "micro") == 0) + eunit = 1.6021765e-4; + else if (strcmp(update->unit_style, "nano") == 0) + eunit = 1.6021765e2; + else + error->all(FLERR, "Pair style mesocnt does not recognize this units style"); funit = eunit * ang_inv; // potential variables @@ -464,14 +471,14 @@ void PairMesoCNT::coeff(int narg, char **arg) cutoffsq = cutoff * cutoff; cutoff_ang = cutoff * ang_inv; cutoffsq_ang = cutoff_ang * cutoff_ang; - comega = 0.275 * (1.0 - 1.0/(1.0 + 0.59*r_ang)); - ctheta = 0.35 + 0.0226*(r_ang - 6.785); + comega = 0.275 * (1.0 - 1.0 / (1.0 + 0.59 * r_ang)); + ctheta = 0.35 + 0.0226 * (r_ang - 6.785); // compute spline coefficients - spline_coeff(uinf_data,uinf_coeff,delh_uinf,uinf_points); - spline_coeff(gamma_data,gamma_coeff,delh_gamma,gamma_points); - spline_coeff(phi_data,phi_coeff,delh_phi,delpsi_phi,phi_points); - spline_coeff(usemi_data,usemi_coeff,delh_usemi,delxi_usemi,usemi_points); + spline_coeff(uinf_data, uinf_coeff, delh_uinf, uinf_points); + spline_coeff(gamma_data, gamma_coeff, delh_gamma, gamma_points); + spline_coeff(phi_data, phi_coeff, delh_phi, delpsi_phi, phi_points); + spline_coeff(usemi_data, usemi_coeff, delh_usemi, delxi_usemi, usemi_points); memory->destroy(uinf_data); memory->destroy(gamma_data); @@ -480,8 +487,7 @@ void PairMesoCNT::coeff(int narg, char **arg) int ntypes = atom->ntypes; for (int i = 1; i <= ntypes; i++) - for (int j = i; j <= ntypes; j++) - setflag[i][j] = 1; + for (int j = i; j <= ntypes; j++) setflag[i][j] = 1; } /* ---------------------------------------------------------------------- @@ -490,14 +496,12 @@ void PairMesoCNT::coeff(int narg, char **arg) void PairMesoCNT::init_style() { - if (atom->tag_enable == 0) - error->all(FLERR,"Pair style mesocnt requires atom IDs"); - if (force->newton_pair == 0) - error->all(FLERR,"Pair style mesocnt requires newton pair on"); + if (atom->tag_enable == 0) error->all(FLERR, "Pair style mesocnt requires atom IDs"); + if (force->newton_pair == 0) error->all(FLERR, "Pair style mesocnt requires newton pair on"); // need a full neighbor list - int irequest = neighbor->request(this,instance_me); + int irequest = neighbor->request(this, instance_me); neighbor->requests[irequest]->half = 0; neighbor->requests[irequest]->full = 1; } @@ -527,15 +531,15 @@ void PairMesoCNT::bond_neigh() for (int i = 0; i < nbondlist; i++) { int i1 = bondlist[i][0]; int i2 = bondlist[i][1]; - int numneigh1,numneigh2; + int numneigh1, numneigh2; // prevent ghost atom with undefined neighbors - if (i1 > nlocal-1) + if (i1 > nlocal - 1) numneigh1 = 0; else numneigh1 = numneigh[i1]; - if (i2 > nlocal-1) + if (i2 > nlocal - 1) numneigh2 = 0; else numneigh2 = numneigh[i2]; @@ -546,10 +550,9 @@ void PairMesoCNT::bond_neigh() // create temporary arrays for chain creation - memory->create(reduced_nlist,nbondlist,"pair:reduced_nlist"); - memory->create(reduced_neighlist, - nbondlist,numneigh_max,"pair:reduced_neighlist"); - + memory->create(reduced_nlist, nbondlist, "pair:reduced_nlist"); + memory->create(reduced_neighlist, nbondlist, numneigh_max, "pair:reduced_neighlist"); + // reduce neighbors to common list and find longest common list size numneigh_max = 0; @@ -558,16 +561,15 @@ void PairMesoCNT::bond_neigh() int i2 = bondlist[i][1]; int *reduced_neigh = reduced_neighlist[i]; - neigh_common(i1,i2,reduced_nlist[i],reduced_neigh); - + neigh_common(i1, i2, reduced_nlist[i], reduced_neigh); + // sort list according to atom-id - sort(reduced_neigh,reduced_nlist[i]); + sort(reduced_neigh, reduced_nlist[i]); - if (numneigh_max < reduced_nlist[i]) - numneigh_max = reduced_nlist[i]; + if (numneigh_max < reduced_nlist[i]) numneigh_max = reduced_nlist[i]; } - + // resize chain arrays memory->destroy(numchainlist); @@ -577,31 +579,29 @@ void PairMesoCNT::bond_neigh() // count neighbor chains per bond - memory->create(numchainlist,nbondlist,"pair:numchainlist"); + memory->create(numchainlist, nbondlist, "pair:numchainlist"); int numchain_max = 0; for (int i = 0; i < nbondlist; i++) { - numchainlist[i] = count_chains(reduced_neighlist[i],reduced_nlist[i]); - if (numchain_max < numchainlist[i]) - numchain_max = numchainlist[i]; + numchainlist[i] = count_chains(reduced_neighlist[i], reduced_nlist[i]); + if (numchain_max < numchainlist[i]) numchain_max = numchainlist[i]; } // count neighbor chain lengths per bond - - memory->create_ragged(nchainlist,nbondlist,numchainlist,"pair:nchainlist"); - + + memory->create_ragged(nchainlist, nbondlist, numchainlist, "pair:nchainlist"); + for (int i = 0; i < nbondlist; i++) - chain_lengths(reduced_neighlist[i],reduced_nlist[i],nchainlist[i]); + chain_lengths(reduced_neighlist[i], reduced_nlist[i], nchainlist[i]); // create connected neighbor chains and check for ends // MEMORY: prevent zero-size array creation for chainlist - memory->create_ragged(endlist,nbondlist,numchainlist,"pair:endlist"); + memory->create_ragged(endlist, nbondlist, numchainlist, "pair:endlist"); if (numchain_max > 0) - memory->create_ragged(chainlist,nbondlist,numchainlist,nchainlist, - "pair:chainlist"); + memory->create_ragged(chainlist, nbondlist, numchainlist, nchainlist, "pair:chainlist"); else - memory->create(chainlist,1,1,1,"pair:chainlist"); + memory->create(chainlist, 1, 1, 1, "pair:chainlist"); int nchain_max = 0; for (int i = 0; i < nbondlist; i++) { @@ -612,29 +612,26 @@ void PairMesoCNT::bond_neigh() // set up connected chains and check for ends - chain_split(reduced_neigh,reduced_nlist[i],nchain,chain,end); - + chain_split(reduced_neigh, reduced_nlist[i], nchain, chain, end); + // find longest chain for (int j = 0; j < numchainlist[i]; j++) - if (nchain_max < nchain[j]) - nchain_max = nchain[j]; + if (nchain_max < nchain[j]) nchain_max = nchain[j]; } // resize potential arrays - memory->grow(w,nchain_max,"pair:w"); - memory->grow(wnode,nchain_max,"pair:wnode"); - memory->grow(dq_w,nchain_max,3,"pair:dq_w"); - memory->grow(q1_dq_w,nchain_max,3,3,"pair:q1_dq_w"); - memory->grow(q2_dq_w,nchain_max,3,3,"pair:q2_dq_w"); - + memory->grow(w, nchain_max, "pair:w"); + memory->grow(wnode, nchain_max, "pair:wnode"); + memory->grow(dq_w, nchain_max, 3, "pair:dq_w"); + memory->grow(q1_dq_w, nchain_max, 3, 3, "pair:q1_dq_w"); + memory->grow(q2_dq_w, nchain_max, 3, 3, "pair:q2_dq_w"); // destroy temporary arrays for chain creation memory->destroy(reduced_neighlist); memory->destroy(reduced_nlist); - } /* ---------------------------------------------------------------------- @@ -648,18 +645,18 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) tagint *mol = atom->molecule; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; - int numneigh1,numneigh2; - int *neighlist1,*neighlist2; - + int numneigh1, numneigh2; + int *neighlist1, *neighlist2; + // prevent ghost atom with undefined neighbors - if (i1 > nlocal-1) + if (i1 > nlocal - 1) numneigh1 = 0; else { neighlist1 = firstneigh[i1]; numneigh1 = numneigh[i1]; } - if (i2 > nlocal-1) + if (i2 > nlocal - 1) numneigh2 = 0; else { neighlist2 = firstneigh[i2]; @@ -672,8 +669,7 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) for (int j = 0; j < numneigh1; j++) { int ind = neighlist1[j]; - if (mol[ind] == mol[i1] && abs(tag[ind] - tag[i1]) < SELF_CUTOFF) - continue; + if (mol[ind] == mol[i1] && abs(tag[ind] - tag[i1]) < SELF_CUTOFF) continue; redlist[numred++] = ind; } int inflag = 0; @@ -681,7 +677,7 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) for (int j1 = 0; j1 < numneigh1; j1++) { if (neighlist1[j1] == neighlist2[j2]) { inflag = 1; - break; + break; } } if (inflag) { @@ -689,8 +685,7 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) continue; } int ind = neighlist2[j2]; - if (mol[ind] == mol[i2] && abs(tag[ind] - tag[i2]) < SELF_CUTOFF) - continue; + if (mol[ind] == mol[i2] && abs(tag[ind] - tag[i2]) < SELF_CUTOFF) continue; redlist[numred++] = ind; } } @@ -699,7 +694,7 @@ void PairMesoCNT::neigh_common(int i1, int i2, int &numred, int *redlist) count neighbor chains of given bond ------------------------------------------------------------------------- */ -int PairMesoCNT::count_chains(int *redlist, int numred) +int PairMesoCNT::count_chains(int *redlist, int numred) { if (numred == 0) return 0; @@ -709,11 +704,10 @@ int PairMesoCNT::count_chains(int *redlist, int numred) // split neighbor list and count chains - for (int j = 0; j < numred-1; j++) { + for (int j = 0; j < numred - 1; j++) { int j1 = redlist[j]; - int j2 = redlist[j+1]; - if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) - count++; + int j2 = redlist[j + 1]; + if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) count++; } return count; @@ -722,7 +716,7 @@ int PairMesoCNT::count_chains(int *redlist, int numred) count lengths of neighbor chains of given bond ------------------------------------------------------------------------- */ -void PairMesoCNT::chain_lengths(int *redlist, int numred, int *nchain) +void PairMesoCNT::chain_lengths(int *redlist, int numred, int *nchain) { if (numred == 0) return; @@ -733,9 +727,9 @@ void PairMesoCNT::chain_lengths(int *redlist, int numred, int *nchain) // split neighbor list into connected chains - for (int j = 0; j < numred-1; j++) { + for (int j = 0; j < numred - 1; j++) { int j1 = redlist[j]; - int j2 = redlist[j+1]; + int j2 = redlist[j + 1]; clen++; if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) { nchain[cid++] = clen; @@ -750,8 +744,7 @@ void PairMesoCNT::chain_lengths(int *redlist, int numred, int *nchain) split neighbors into chains and identify ends ------------------------------------------------------------------------- */ -void PairMesoCNT::chain_split(int *redlist, int numred, int *nchain, - int **chain, int *end) +void PairMesoCNT::chain_split(int *redlist, int numred, int *nchain, int **chain, int *end) { if (numred == 0) return; @@ -762,36 +755,36 @@ void PairMesoCNT::chain_split(int *redlist, int numred, int *nchain, // split neighbor list into connected chains - for (int j = 0; j < numred-1; j++) { + for (int j = 0; j < numred - 1; j++) { int j1 = redlist[j]; - int j2 = redlist[j+1]; + int j2 = redlist[j + 1]; chain[cid][clen++] = j1; if (tag[j2] - tag[j1] != 1 || mol[j1] != mol[j2]) { cid++; clen = 0; } } - chain[cid][clen++] = redlist[numred-1]; + chain[cid][clen++] = redlist[numred - 1]; cid++; // check for chain ends for (int j = 0; j < cid; j++) { int cstart = chain[j][0]; - int cend = chain[j][nchain[j]-1]; + int cend = chain[j][nchain[j] - 1]; tagint tagstart = tag[cstart]; tagint tagend = tag[cend]; end[j] = 0; if (tagstart == 1) { end[j] = 1; } else { - int idprev = atom->map(tagstart-1); + int idprev = atom->map(tagstart - 1); if (mol[cstart] != mol[idprev]) end[j] = 1; } if (tagend == atom->natoms) { end[j] = 2; } else { - int idnext = atom->map(tagend+1); + int idnext = atom->map(tagend + 1); if (mol[cend] != mol[idnext]) end[j] = 2; } } @@ -803,17 +796,17 @@ void PairMesoCNT::chain_split(int *redlist, int numred, int *nchain, void PairMesoCNT::sort(int *list, int size) { - int i,j,temp1,temp2; + int i, j, temp1, temp2; tagint *tag = atom->tag; for (i = 1; i < size; i++) { j = i; - temp1 = list[j-1]; + temp1 = list[j - 1]; temp2 = list[j]; while (j > 0 && tag[temp1] > tag[temp2]) { list[j] = temp1; - list[j-1] = temp2; + list[j - 1] = temp2; j--; - temp1 = list[j-1]; + temp1 = list[j - 1]; temp2 = list[j]; } } @@ -826,113 +819,111 @@ void PairMesoCNT::sort(int *list, int size) void PairMesoCNT::read_file() { int me, num; - MPI_Comm_rank(world,&me); + MPI_Comm_rank(world, &me); FILE *fp; if (me == 0) { - char line[MAXLINE]; + char line[MAXLINE]; // open file - fp = utils::open_potential(file,lmp,nullptr); - if (fp == nullptr) - error->one(FLERR,"Cannot open mesocnt file: {}",file); + fp = utils::open_potential(file, lmp, nullptr); + if (fp == nullptr) error->one(FLERR, "Cannot open mesocnt file: {}", file); - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); + utils::sfgets(FLERR, line, MAXLINE, fp, file, error); // potential parameters - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - num = sscanf(line,"%d %d %d %d", - &uinf_points,&gamma_points,&phi_points,&usemi_points); + utils::sfgets(FLERR, line, MAXLINE, fp, file, error); + num = sscanf(line, "%d %d %d %d", &uinf_points, &gamma_points, &phi_points, &usemi_points); if (num != 4) - error->one(FLERR,"Could not correctly parse line 2 in " - "mesocnt file: {}",file); + error->one(FLERR, + "Could not correctly parse line 2 in " + "mesocnt file: {}", + file); - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - num = sscanf(line,"%lg %lg %lg %lg",&r_ang,&sig_ang,&delta1,&delta2); + utils::sfgets(FLERR, line, MAXLINE, fp, file, error); + num = sscanf(line, "%lg %lg %lg %lg", &r_ang, &sig_ang, &delta1, &delta2); if (num != 4) - error->one(FLERR,"Could not correctly parse line 3 in " - "mesocnt file: {}",file); + error->one(FLERR, + "Could not correctly parse line 3 in " + "mesocnt file: {}", + file); } - MPI_Bcast(&uinf_points,1,MPI_INT,0,world); - MPI_Bcast(&gamma_points,1,MPI_INT,0,world); - MPI_Bcast(&phi_points,1,MPI_INT,0,world); - MPI_Bcast(&usemi_points,1,MPI_INT,0,world); - MPI_Bcast(&r_ang,1,MPI_DOUBLE,0,world); - MPI_Bcast(&sig_ang,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delta1,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delta2,1,MPI_DOUBLE,0,world); + MPI_Bcast(&uinf_points, 1, MPI_INT, 0, world); + MPI_Bcast(&gamma_points, 1, MPI_INT, 0, world); + MPI_Bcast(&phi_points, 1, MPI_INT, 0, world); + MPI_Bcast(&usemi_points, 1, MPI_INT, 0, world); + MPI_Bcast(&r_ang, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&sig_ang, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delta1, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delta2, 1, MPI_DOUBLE, 0, world); // potential tables - memory->create(uinf_data,uinf_points,"pair:uinf_data"); - memory->create(gamma_data,gamma_points,"pair:gamma_data"); - memory->create(phi_data,phi_points,phi_points,"pair:phi_data"); - memory->create(usemi_data,usemi_points,usemi_points,"pair:usemi_data"); + memory->create(uinf_data, uinf_points, "pair:uinf_data"); + memory->create(gamma_data, gamma_points, "pair:gamma_data"); + memory->create(phi_data, phi_points, phi_points, "pair:phi_data"); + memory->create(usemi_data, usemi_points, usemi_points, "pair:usemi_data"); if (me == 0) { - read_data(fp,uinf_data,hstart_uinf,delh_uinf,uinf_points); - read_data(fp,gamma_data,hstart_gamma,delh_gamma,gamma_points); - read_data(fp,phi_data,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_points); - read_data(fp,usemi_data,hstart_usemi,xistart_usemi, - delh_usemi,delxi_usemi,usemi_points); + read_data(fp, uinf_data, hstart_uinf, delh_uinf, uinf_points); + read_data(fp, gamma_data, hstart_gamma, delh_gamma, gamma_points); + read_data(fp, phi_data, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_points); + read_data(fp, usemi_data, hstart_usemi, xistart_usemi, delh_usemi, delxi_usemi, usemi_points); fclose(fp); } - MPI_Bcast(&hstart_uinf,1,MPI_DOUBLE,0,world); - MPI_Bcast(&hstart_gamma,1,MPI_DOUBLE,0,world); - MPI_Bcast(&hstart_phi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&psistart_phi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&hstart_usemi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&xistart_usemi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delh_uinf,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delh_gamma,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delh_phi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delpsi_phi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delh_usemi,1,MPI_DOUBLE,0,world); - MPI_Bcast(&delxi_usemi,1,MPI_DOUBLE,0,world); + MPI_Bcast(&hstart_uinf, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&hstart_gamma, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&hstart_phi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&psistart_phi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&hstart_usemi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&xistart_usemi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delh_uinf, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delh_gamma, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delh_phi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delpsi_phi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delh_usemi, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&delxi_usemi, 1, MPI_DOUBLE, 0, world); - MPI_Bcast(uinf_data,uinf_points,MPI_DOUBLE,0,world); - MPI_Bcast(gamma_data,gamma_points,MPI_DOUBLE,0,world); - for (int i = 0; i < phi_points; i++) - MPI_Bcast(phi_data[i],phi_points,MPI_DOUBLE,0,world); + MPI_Bcast(uinf_data, uinf_points, MPI_DOUBLE, 0, world); + MPI_Bcast(gamma_data, gamma_points, MPI_DOUBLE, 0, world); + for (int i = 0; i < phi_points; i++) MPI_Bcast(phi_data[i], phi_points, MPI_DOUBLE, 0, world); for (int i = 0; i < usemi_points; i++) - MPI_Bcast(usemi_data[i],usemi_points,MPI_DOUBLE,0,world); + MPI_Bcast(usemi_data[i], usemi_points, MPI_DOUBLE, 0, world); } /* ---------------------------------------------------------------------- read 1D data file ------------------------------------------------------------------------- */ -void PairMesoCNT::read_data(FILE *fp, double *data, - double &xstart, double &dx, int ninput) +void PairMesoCNT::read_data(FILE *fp, double *data, double &xstart, double &dx, int ninput) { char line[MAXLINE]; - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); + utils::sfgets(FLERR, line, MAXLINE, fp, file, error); // read values from file int cerror = 0; int serror = 0; - double x,xtemp,dxtemp; + double x, xtemp, dxtemp; for (int i = 0; i < ninput; i++) { - if (nullptr == fgets(line,MAXLINE,fp)) - error->one(FLERR,"Premature end of file in pair table: {}",file); + if (nullptr == fgets(line, MAXLINE, fp)) + error->one(FLERR, "Premature end of file in pair table: {}", file); if (i > 0) xtemp = x; - if (2 != sscanf(line,"%lg %lg",&x,&data[i])) cerror++; + if (2 != sscanf(line, "%lg %lg", &x, &data[i])) cerror++; if (i == 0) { xstart = x; } else { dxtemp = x - xtemp; if (i == 1) dx = dxtemp; - if (fabs(dxtemp - dx)/dx > SMALL) serror++; + if (fabs(dxtemp - dx) / dx > SMALL) serror++; } } @@ -941,16 +932,18 @@ void PairMesoCNT::read_data(FILE *fp, double *data, if (cerror) { std::string mesg = fmt::format("{} of {} lines were incomplete or could " "or could not be parsed completely in " - " pair table: {}",cerror,ninput,file); - error->warning(FLERR,mesg); + " pair table: {}", + cerror, ninput, file); + error->warning(FLERR, mesg); } // warn if spacing between data points is not constant if (serror) { std::string mesg = fmt::format("{} spacings in first column were different " - " from first spacing in pair table: {}",serror,file); - error->warning(FLERR,mesg); + " from first spacing in pair table: {}", + serror, file); + error->warning(FLERR, mesg); } } @@ -958,33 +951,32 @@ void PairMesoCNT::read_data(FILE *fp, double *data, read 2D data file ------------------------------------------------------------------------- */ -void PairMesoCNT::read_data(FILE *fp, double **data, - double &xstart, double &ystart, - double &dx, double &dy, int ninput) +void PairMesoCNT::read_data(FILE *fp, double **data, double &xstart, double &ystart, double &dx, + double &dy, int ninput) { char line[MAXLINE]; - fgets(line,MAXLINE,fp); + fgets(line, MAXLINE, fp); // read values from file int cerror = 0; int sxerror = 0; int syerror = 0; - double x,y,xtemp,ytemp,dxtemp,dytemp; + double x, y, xtemp, ytemp, dxtemp, dytemp; for (int i = 0; i < ninput; i++) { if (i > 0) xtemp = x; for (int j = 0; j < ninput; j++) { - if (nullptr == fgets(line,MAXLINE,fp)) - error->one(FLERR,"Premature end of file in pair table: {}",file); + if (nullptr == fgets(line, MAXLINE, fp)) + error->one(FLERR, "Premature end of file in pair table: {}", file); if (j > 0) ytemp = y; - if (3 != sscanf(line,"%lg %lg %lg",&x,&y,&data[i][j])) cerror++; + if (3 != sscanf(line, "%lg %lg %lg", &x, &y, &data[i][j])) cerror++; if (i == 0 && j == 0) ystart = y; if (j > 0) { - dytemp = y - ytemp; - if (j == 1) dy = dytemp; - if (fabs(dytemp - dy)/dy > SMALL) syerror++; + dytemp = y - ytemp; + if (j == 1) dy = dytemp; + if (fabs(dytemp - dy) / dy > SMALL) syerror++; } } if (i == 0) { @@ -992,94 +984,92 @@ void PairMesoCNT::read_data(FILE *fp, double **data, } else { dxtemp = x - xtemp; if (i == 1) dx = dxtemp; - if (fabs(dxtemp - dx)/dx > SMALL) sxerror++; + if (fabs(dxtemp - dx) / dx > SMALL) sxerror++; } } // warn if data was read incompletely, e.g. columns were missing if (cerror) - error->warning(FLERR,"{} of {} lines were incomplete or could not be parsed " - "completely in pair table: {}",cerror,ninput*ninput,file); + error->warning(FLERR, + "{} of {} lines were incomplete or could not be parsed " + "completely in pair table: {}", + cerror, ninput * ninput, file); // warn if spacing between data points is not constant if (sxerror) - error->warning(FLERR,"{} spacings in first column were different from " - "first spacing in pair table: {}",sxerror,file); + error->warning(FLERR, + "{} spacings in first column were different from " + "first spacing in pair table: {}", + sxerror, file); if (syerror) - error->warning(FLERR,"{} spacings in second column were different from " - "first spacing in pair table: {}",syerror,file); + error->warning(FLERR, + "{} spacings in second column were different from " + "first spacing in pair table: {}", + syerror, file); } /* ---------------------------------------------------------------------- compute cubic spline coefficients ------------------------------------------------------------------------- */ -void PairMesoCNT::spline_coeff(double *data, double **coeff, - double dx, int size) +void PairMesoCNT::spline_coeff(double *data, double **coeff, double dx, int size) { double *u = data; double **g = coeff; int n = size; - double d,*p,*bprime,*dprime,**b; - memory->create(p,n,"pair:p"); - memory->create(b,n,n,"pair:b"); - memory->create(bprime,n,"pair:bprime"); - memory->create(dprime,n,"pair:dprime"); + double d, *p, *bprime, *dprime, **b; + memory->create(p, n, "pair:p"); + memory->create(b, n, n, "pair:b"); + memory->create(bprime, n, "pair:bprime"); + memory->create(dprime, n, "pair:dprime"); double dx_inv = 1.0 / dx; double dxsq_inv = dx_inv * dx_inv; double dxcb_inv = dx_inv * dxsq_inv; - double ax[4][4] = - { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {-3*dxsq_inv, -2*dx_inv, 3*dxsq_inv, -dx_inv}, - {2*dxcb_inv, dxsq_inv, -2*dxcb_inv, dxsq_inv} - }; + double ax[4][4] = {{1, 0, 0, 0}, + {0, 1, 0, 0}, + {-3 * dxsq_inv, -2 * dx_inv, 3 * dxsq_inv, -dx_inv}, + {2 * dxcb_inv, dxsq_inv, -2 * dxcb_inv, dxsq_inv}}; // compute finite difference derivatives at boundaries p[0] = (u[1] - u[0]) * dx_inv; - p[n-1] = (u[n-1] - u[n-2]) * dx_inv; + p[n - 1] = (u[n - 1] - u[n - 2]) * dx_inv; // compute derivatives inside domain - for (int i = 1; i < n-1; i++) { - if (i > 1) b[i][i-1] = dx; + for (int i = 1; i < n - 1; i++) { + if (i > 1) b[i][i - 1] = dx; b[i][i] = 4 * dx; - if (i < n-2) b[i][i+1] = dx; + if (i < n - 2) b[i][i + 1] = dx; } bprime[1] = b[1][1]; - for (int i = 2; i < n-1; i++) - bprime[i] = b[i][i] - b[i][i-1]*b[i-1][i]/bprime[i-1]; + for (int i = 2; i < n - 1; i++) bprime[i] = b[i][i] - b[i][i - 1] * b[i - 1][i] / bprime[i - 1]; - for (int i = 1; i < n-1; i++) { - d = 3 * (u[i+1] - u[i-1]); - if (i == 1) d -= dx * p[i-1]; - if (i == n-2) d -= dx * p[i+1]; + for (int i = 1; i < n - 1; i++) { + d = 3 * (u[i + 1] - u[i - 1]); + if (i == 1) d -= dx * p[i - 1]; + if (i == n - 2) d -= dx * p[i + 1]; dprime[i] = d; - if (i != 1) dprime[i] -= b[i][i-1] * dprime[i-1] / bprime[i-1]; + if (i != 1) dprime[i] -= b[i][i - 1] * dprime[i - 1] / bprime[i - 1]; } - p[n-2] = dprime[n-2] / bprime[n-2]; - for (int i = n-3; i > 0; i--) - p[i] = (dprime[i] - b[i][i+1]*p[i+1]) / bprime[i]; + p[n - 2] = dprime[n - 2] / bprime[n - 2]; + for (int i = n - 3; i > 0; i--) p[i] = (dprime[i] - b[i][i + 1] * p[i + 1]) / bprime[i]; // compute spline coefficients for (int i = 1; i < n; i++) { - for (int j = 0; j < 4; j++) - g[i][j] = 0; + for (int j = 0; j < 4; j++) g[i][j] = 0; - double k[4] = {u[i-1], p[i-1], u[i], p[i]}; + double k[4] = {u[i - 1], p[i - 1], u[i], p[i]}; for (int j = 0; j < 4; j++) - for (int l = 0; l < 4; l++) - g[i][j] += ax[j][l] * k[l]; + for (int l = 0; l < 4; l++) g[i][j] += ax[j][l] * k[l]; } memory->destroy(p); @@ -1092,20 +1082,19 @@ void PairMesoCNT::spline_coeff(double *data, double **coeff, compute bicubic spline coefficients ------------------------------------------------------------------------- */ -void PairMesoCNT::spline_coeff(double **data, double ****coeff, - double dx, double dy, int size) +void PairMesoCNT::spline_coeff(double **data, double ****coeff, double dx, double dy, int size) { double **u = data; double ****g = coeff; int n = size; - double d,*bprime,*dprime,**p,**q,**s,**b; - memory->create(p,n,n,"pair:p"); - memory->create(q,n,n,"pair:q"); - memory->create(s,n,n,"pair:s"); - memory->create(b,n,n,"pair:b"); - memory->create(bprime,n,"pair:bprime"); - memory->create(dprime,n,"pair:dprime"); + double d, *bprime, *dprime, **p, **q, **s, **b; + memory->create(p, n, n, "pair:p"); + memory->create(q, n, n, "pair:q"); + memory->create(s, n, n, "pair:s"); + memory->create(b, n, n, "pair:b"); + memory->create(bprime, n, "pair:bprime"); + memory->create(dprime, n, "pair:dprime"); double dx_inv = 1.0 / dx; double dy_inv = 1.0 / dy; @@ -1114,145 +1103,128 @@ void PairMesoCNT::spline_coeff(double **data, double ****coeff, double dxcb_inv = dx_inv * dxsq_inv; double dycb_inv = dy_inv * dysq_inv; - double ax[4][4] = - { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {-3*dxsq_inv, -2*dx_inv, 3*dxsq_inv, -dx_inv}, - {2*dxcb_inv, dxsq_inv, -2*dxcb_inv, dxsq_inv} - }; - double ay[4][4] = - { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {-3*dysq_inv, -2*dy_inv, 3*dysq_inv, -dy_inv}, - {2*dycb_inv, dysq_inv, -2*dycb_inv, dysq_inv} - }; + double ax[4][4] = {{1, 0, 0, 0}, + {0, 1, 0, 0}, + {-3 * dxsq_inv, -2 * dx_inv, 3 * dxsq_inv, -dx_inv}, + {2 * dxcb_inv, dxsq_inv, -2 * dxcb_inv, dxsq_inv}}; + double ay[4][4] = {{1, 0, 0, 0}, + {0, 1, 0, 0}, + {-3 * dysq_inv, -2 * dy_inv, 3 * dysq_inv, -dy_inv}, + {2 * dycb_inv, dysq_inv, -2 * dycb_inv, dysq_inv}}; // compute finite difference derivatives at boundaries for (int i = 0; i < n; i++) { p[0][i] = (u[1][i] - u[0][i]) * dx_inv; - p[n-1][i] = (u[n-1][i] - u[n-2][i]) * dx_inv; + p[n - 1][i] = (u[n - 1][i] - u[n - 2][i]) * dx_inv; } for (int i = 0; i < n; i++) { q[i][0] = (u[i][1] - u[i][0]) * dy_inv; - q[i][n-1] = (u[i][n-1] - u[i][n-2]) * dy_inv; + q[i][n - 1] = (u[i][n - 1] - u[i][n - 2]) * dy_inv; } s[0][0] = (p[0][1] - p[0][0]) * dy_inv; - s[0][n-1] = (p[0][n-1] - p[0][n-2]) * dy_inv; - s[n-1][0] = (p[n-1][1] - p[n-1][0]) * dy_inv; - s[n-1][n-1] = (p[n-1][n-1] - p[n-1][n-2]) * dy_inv; + s[0][n - 1] = (p[0][n - 1] - p[0][n - 2]) * dy_inv; + s[n - 1][0] = (p[n - 1][1] - p[n - 1][0]) * dy_inv; + s[n - 1][n - 1] = (p[n - 1][n - 1] - p[n - 1][n - 2]) * dy_inv; // compute derivatives inside domain // sweep in x - for (int i = 1; i < n-1; i++) { - if (i > 1) b[i][i-1] = dx; + for (int i = 1; i < n - 1; i++) { + if (i > 1) b[i][i - 1] = dx; b[i][i] = 4 * dx; - if (i < n-2) b[i][i+1] = dx; + if (i < n - 2) b[i][i + 1] = dx; } bprime[1] = b[1][1]; - for (int i = 2; i < n-1; i++) - bprime[i] = b[i][i] - b[i][i-1]*b[i-1][i]/bprime[i-1]; + for (int i = 2; i < n - 1; i++) bprime[i] = b[i][i] - b[i][i - 1] * b[i - 1][i] / bprime[i - 1]; // compute p for (int j = 0; j < n; j++) { - for (int i = 1; i < n-1; i++) { - d = 3 * (u[i+1][j] - u[i-1][j]); - if (i == 1) d -= dx * p[i-1][j]; - if (i == n-2) d -= dx * p[i+1][j]; + for (int i = 1; i < n - 1; i++) { + d = 3 * (u[i + 1][j] - u[i - 1][j]); + if (i == 1) d -= dx * p[i - 1][j]; + if (i == n - 2) d -= dx * p[i + 1][j]; dprime[i] = d; - if (i != 1) dprime[i] -= b[i][i-1] * dprime[i-1] / bprime[i-1]; + if (i != 1) dprime[i] -= b[i][i - 1] * dprime[i - 1] / bprime[i - 1]; } - p[n-2][j] = dprime[n-2] / bprime[n-2]; - for (int i = n-3; i > 0; i--) - p[i][j] = (dprime[i] - b[i][i+1]*p[i+1][j]) / bprime[i]; + p[n - 2][j] = dprime[n - 2] / bprime[n - 2]; + for (int i = n - 3; i > 0; i--) p[i][j] = (dprime[i] - b[i][i + 1] * p[i + 1][j]) / bprime[i]; } // compute s - for (int j = 0; j < n; j += n-1) { - for (int i = 1; i < n-1; i++) { - d = 3 * (q[i+1][j] - q[i-1][j]); - if (i == 1) d -= dx * s[i-1][j]; - if (i == n-2) d -= dx * s[i+1][j]; + for (int j = 0; j < n; j += n - 1) { + for (int i = 1; i < n - 1; i++) { + d = 3 * (q[i + 1][j] - q[i - 1][j]); + if (i == 1) d -= dx * s[i - 1][j]; + if (i == n - 2) d -= dx * s[i + 1][j]; dprime[i] = d; - if (i != 1) dprime[i] -= b[i][i-1] * dprime[i-1] / bprime[i-1]; + if (i != 1) dprime[i] -= b[i][i - 1] * dprime[i - 1] / bprime[i - 1]; } - s[n-2][j] = dprime[n-2] / bprime[n-2]; - for (int i = n-3; i > 0; i--) - s[i][j] = (dprime[i] - b[i][i+1]*s[i+1][j]) / bprime[i]; + s[n - 2][j] = dprime[n - 2] / bprime[n - 2]; + for (int i = n - 3; i > 0; i--) s[i][j] = (dprime[i] - b[i][i + 1] * s[i + 1][j]) / bprime[i]; } // sweep in y - for (int i = 1; i < n-1; i++) { - if (i > 1) b[i][i-1] = dy; + for (int i = 1; i < n - 1; i++) { + if (i > 1) b[i][i - 1] = dy; b[i][i] = 4 * dy; - if (i < n-2) b[i][i+1] = dy; + if (i < n - 2) b[i][i + 1] = dy; } bprime[1] = b[1][1]; - for (int i = 2; i < n-1; i++) - bprime[i] = b[i][i] - b[i][i-1]*b[i-1][i]/bprime[i-1]; + for (int i = 2; i < n - 1; i++) bprime[i] = b[i][i] - b[i][i - 1] * b[i - 1][i] / bprime[i - 1]; // compute q for (int i = 0; i < n; i++) { - for (int j = 1; j < n-1; j++) { - d = 3 * (u[i][j+1] - u[i][j-1]); - if (j == 1) d -= dy * q[i][j-1]; - if (j == n-2) d -= dy * q[i][j+1]; + for (int j = 1; j < n - 1; j++) { + d = 3 * (u[i][j + 1] - u[i][j - 1]); + if (j == 1) d -= dy * q[i][j - 1]; + if (j == n - 2) d -= dy * q[i][j + 1]; dprime[j] = d; - if (j != 1) dprime[j] -= b[j][j-1] * dprime[j-1] / bprime[j-1]; + if (j != 1) dprime[j] -= b[j][j - 1] * dprime[j - 1] / bprime[j - 1]; } - q[i][n-2] = dprime[n-2] / bprime[n-2]; - for (int j = n-3; j > 0; j--) - q[i][j] = (dprime[j] - b[j][j+1]*q[i][j+1]) / bprime[j]; + q[i][n - 2] = dprime[n - 2] / bprime[n - 2]; + for (int j = n - 3; j > 0; j--) q[i][j] = (dprime[j] - b[j][j + 1] * q[i][j + 1]) / bprime[j]; } // compute s for (int i = 0; i < n; i++) { - for (int j = 1; j < n-1; j++) { - d = 3 * (p[i][j+1] - p[i][j-1]); - if (j == 1) d -= dy * s[i][j-1]; - if (j == n-2) d -= dy * s[i][j+1]; + for (int j = 1; j < n - 1; j++) { + d = 3 * (p[i][j + 1] - p[i][j - 1]); + if (j == 1) d -= dy * s[i][j - 1]; + if (j == n - 2) d -= dy * s[i][j + 1]; dprime[j] = d; - if (j != 1) dprime[j] -= b[j][j-1] * dprime[j-1] / bprime[j-1]; + if (j != 1) dprime[j] -= b[j][j - 1] * dprime[j - 1] / bprime[j - 1]; } - s[i][n-2] = dprime[n-2] / bprime[n-2]; - for (int j = n-3; j > 0; j--) - s[i][j] = (dprime[j] - b[j][j+1]*s[i][j+1]) / bprime[j]; + s[i][n - 2] = dprime[n - 2] / bprime[n - 2]; + for (int j = n - 3; j > 0; j--) s[i][j] = (dprime[j] - b[j][j + 1] * s[i][j + 1]) / bprime[j]; } for (int i = 1; i < n; i++) for (int j = 1; j < n; j++) { for (int l = 0; l < 4; l++) - for (int m = 0; m < 4; m++) - g[i][j][l][m] = 0; + for (int m = 0; m < 4; m++) g[i][j][l][m] = 0; - double k[4][4] = - { - {u[i-1][j-1], q[i-1][j-1], u[i-1][j], q[i-1][j]}, - {p[i-1][j-1], s[i-1][j-1], p[i-1][j], s[i-1][j]}, - {u[i][j-1], q[i][j-1], u[i][j], q[i][j]}, - {p[i][j-1], s[i][j-1], p[i][j], s[i][j]} - }; + double k[4][4] = {{u[i - 1][j - 1], q[i - 1][j - 1], u[i - 1][j], q[i - 1][j]}, + {p[i - 1][j - 1], s[i - 1][j - 1], p[i - 1][j], s[i - 1][j]}, + {u[i][j - 1], q[i][j - 1], u[i][j], q[i][j]}, + {p[i][j - 1], s[i][j - 1], p[i][j], s[i][j]}}; for (int l = 0; l < 4; l++) for (int m = 0; m < 4; m++) for (int n = 0; n < 4; n++) - for (int o = 0; o < 4; o++) - g[i][j][l][m] += ax[l][n] * k[n][o] * ay[m][o]; + for (int o = 0; o < 4; o++) g[i][j][l][m] += ax[l][n] * k[n][o] * ay[m][o]; } memory->destroy(p); @@ -1263,314 +1235,284 @@ void PairMesoCNT::spline_coeff(double **data, double ****coeff, memory->destroy(dprime); } - /* ---------------------------------------------------------------------- cubic spline evaluation ------------------------------------------------------------------------- */ -double PairMesoCNT::spline(double x, double xstart, double dx, - double **coeff, int coeff_size) +double PairMesoCNT::spline(double x, double xstart, double dx, double **coeff, int coeff_size) { - int i = ceil((x - xstart)/dx); + int i = ceil((x - xstart) / dx); // linear extrapolation if (i < 1) { - return coeff[1][0] + coeff[1][1]*(x - xstart); + return coeff[1][0] + coeff[1][1] * (x - xstart); - // constant extrapolation + // constant extrapolation - } else if (i > coeff_size-1) { + } else if (i > coeff_size - 1) { i = coeff_size - 1; - x = xstart + (coeff_size-1)*dx; + x = xstart + (coeff_size - 1) * dx; } // cubic interpolation - double xlo = xstart + (i-1)*dx; + double xlo = xstart + (i - 1) * dx; double xbar = x - xlo; - return coeff[i][0] - + xbar*(coeff[i][1] + xbar*(coeff[i][2] + xbar*coeff[i][3])); + return coeff[i][0] + xbar * (coeff[i][1] + xbar * (coeff[i][2] + xbar * coeff[i][3])); } /* ---------------------------------------------------------------------- cubic spline derivative ------------------------------------------------------------------------- */ -double PairMesoCNT::dspline(double x, double xstart, double dx, - double **coeff, int coeff_size) +double PairMesoCNT::dspline(double x, double xstart, double dx, double **coeff, int coeff_size) { - int i = ceil((x - xstart)/dx); + int i = ceil((x - xstart) / dx); // constant extrapolation if (i < 1) { return coeff[1][1]; - // constant extrapolation + // constant extrapolation - } else if (i > coeff_size-1) { + } else if (i > coeff_size - 1) { i = coeff_size - 1; - x = xstart + (coeff_size-1)*dx; + x = xstart + (coeff_size - 1) * dx; } // cubic interpolation - double xlo = xstart + (i-1)*dx; + double xlo = xstart + (i - 1) * dx; double xbar = x - xlo; - return coeff[i][1] + xbar*(2*coeff[i][2] + 3*xbar*coeff[i][3]); + return coeff[i][1] + xbar * (2 * coeff[i][2] + 3 * xbar * coeff[i][3]); } /* ---------------------------------------------------------------------- bicubic spline evaluation ------------------------------------------------------------------------- */ -double PairMesoCNT::spline(double x, double y, - double xstart, double ystart, - double dx, double dy, - double ****coeff, int coeff_size) +double PairMesoCNT::spline(double x, double y, double xstart, double ystart, double dx, double dy, + double ****coeff, int coeff_size) { - int i = ceil((x - xstart)/dx); - int j = ceil((y - ystart)/dy); + int i = ceil((x - xstart) / dx); + int j = ceil((y - ystart) / dy); // constant extrapolation if (i < 1) { i = 1; x = xstart; - } else if (i > coeff_size-1) { + } else if (i > coeff_size - 1) { i = coeff_size - 1; - x = xstart + (coeff_size-1)*dx; + x = xstart + (coeff_size - 1) * dx; } if (j < 1) { j = 1; y = ystart; - } else if (j > coeff_size-1) { + } else if (j > coeff_size - 1) { j = coeff_size - 1; - y = ystart + (coeff_size-1)*dy; + y = ystart + (coeff_size - 1) * dy; } // cubic interpolation - double xlo = xstart + (i-1)*dx; - double ylo = ystart + (j-1)*dy; + double xlo = xstart + (i - 1) * dx; + double ylo = ystart + (j - 1) * dy; double xbar = x - xlo; double ybar = y - ylo; - double y0 = coeff[i][j][0][0] - + ybar*(coeff[i][j][0][1] - + ybar*(coeff[i][j][0][2] - + ybar*(coeff[i][j][0][3]))); - double y1 = coeff[i][j][1][0] - + ybar*(coeff[i][j][1][1] - + ybar*(coeff[i][j][1][2] - + ybar*(coeff[i][j][1][3]))); - double y2 = coeff[i][j][2][0] - + ybar*(coeff[i][j][2][1] - + ybar*(coeff[i][j][2][2] - + ybar*(coeff[i][j][2][3]))); - double y3 = coeff[i][j][3][0] - + ybar*(coeff[i][j][3][1] - + ybar*(coeff[i][j][3][2] - + ybar*(coeff[i][j][3][3]))); + double y0 = coeff[i][j][0][0] + + ybar * (coeff[i][j][0][1] + ybar * (coeff[i][j][0][2] + ybar * (coeff[i][j][0][3]))); + double y1 = coeff[i][j][1][0] + + ybar * (coeff[i][j][1][1] + ybar * (coeff[i][j][1][2] + ybar * (coeff[i][j][1][3]))); + double y2 = coeff[i][j][2][0] + + ybar * (coeff[i][j][2][1] + ybar * (coeff[i][j][2][2] + ybar * (coeff[i][j][2][3]))); + double y3 = coeff[i][j][3][0] + + ybar * (coeff[i][j][3][1] + ybar * (coeff[i][j][3][2] + ybar * (coeff[i][j][3][3]))); - return y0 + xbar*(y1 + xbar*(y2 + xbar*y3)); + return y0 + xbar * (y1 + xbar * (y2 + xbar * y3)); } /* ---------------------------------------------------------------------- bicubic spline partial x derivative ------------------------------------------------------------------------- */ -double PairMesoCNT::dxspline(double x, double y, - double xstart, double ystart, - double dx, double dy, - double ****coeff, int coeff_size) +double PairMesoCNT::dxspline(double x, double y, double xstart, double ystart, double dx, double dy, + double ****coeff, int coeff_size) { - int i = ceil((x - xstart)/dx); - int j = ceil((y - ystart)/dy); + int i = ceil((x - xstart) / dx); + int j = ceil((y - ystart) / dy); // constant extrapolation if (i < 1) { i = 1; x = xstart; - } else if (i > coeff_size-1) { + } else if (i > coeff_size - 1) { i = coeff_size - 1; - x = xstart + (coeff_size-1)*dx; + x = xstart + (coeff_size - 1) * dx; } if (j < 1) { j = 1; y = ystart; - } else if (j > coeff_size-1) { + } else if (j > coeff_size - 1) { j = coeff_size - 1; - y = ystart + (coeff_size-1)*dy; + y = ystart + (coeff_size - 1) * dy; } // cubic interpolation - double xlo = xstart + (i-1)*dx; - double ylo = ystart + (j-1)*dy; + double xlo = xstart + (i - 1) * dx; + double ylo = ystart + (j - 1) * dy; double xbar = x - xlo; double ybar = y - ylo; - double y1 = coeff[i][j][1][0] - + ybar*(coeff[i][j][1][1] - + ybar*(coeff[i][j][1][2] - + ybar*(coeff[i][j][1][3]))); - double y2 = coeff[i][j][2][0] - + ybar*(coeff[i][j][2][1] - + ybar*(coeff[i][j][2][2] - + ybar*(coeff[i][j][2][3]))); - double y3 = coeff[i][j][3][0] - + ybar*(coeff[i][j][3][1] - + ybar*(coeff[i][j][3][2] - + ybar*(coeff[i][j][3][3]))); + double y1 = coeff[i][j][1][0] + + ybar * (coeff[i][j][1][1] + ybar * (coeff[i][j][1][2] + ybar * (coeff[i][j][1][3]))); + double y2 = coeff[i][j][2][0] + + ybar * (coeff[i][j][2][1] + ybar * (coeff[i][j][2][2] + ybar * (coeff[i][j][2][3]))); + double y3 = coeff[i][j][3][0] + + ybar * (coeff[i][j][3][1] + ybar * (coeff[i][j][3][2] + ybar * (coeff[i][j][3][3]))); - return y1 + xbar*(2*y2 + 3*xbar*y3); + return y1 + xbar * (2 * y2 + 3 * xbar * y3); } /* ---------------------------------------------------------------------- bicubic spline partial y derivative ------------------------------------------------------------------------- */ -double PairMesoCNT::dyspline(double x, double y, - double xstart, double ystart, - double dx, double dy, - double ****coeff, int coeff_size) +double PairMesoCNT::dyspline(double x, double y, double xstart, double ystart, double dx, double dy, + double ****coeff, int coeff_size) { - int i = ceil((x - xstart)/dx); - int j = ceil((y - ystart)/dy); + int i = ceil((x - xstart) / dx); + int j = ceil((y - ystart) / dy); // constant extrapolation if (i < 1) { i = 1; x = xstart; - } else if (i > coeff_size-1) { + } else if (i > coeff_size - 1) { i = coeff_size - 1; - x = xstart + (coeff_size-1)*dx; + x = xstart + (coeff_size - 1) * dx; } if (j < 1) { j = 1; y = ystart; - } else if (j > coeff_size-1) { + } else if (j > coeff_size - 1) { j = coeff_size - 1; - y = ystart + (coeff_size-1)*dy; + y = ystart + (coeff_size - 1) * dy; } // cubic interpolation - double xlo = xstart + (i-1)*dx; - double ylo = ystart + (j-1)*dy; + double xlo = xstart + (i - 1) * dx; + double ylo = ystart + (j - 1) * dy; double xbar = x - xlo; double ybar = y - ylo; - double y0 = coeff[i][j][0][1] - + ybar*(2*coeff[i][j][0][2] - + 3*ybar*coeff[i][j][0][3]); - double y1 = coeff[i][j][1][1] - + ybar*(2*coeff[i][j][1][2] - + 3*ybar*coeff[i][j][1][3]); - double y2 = coeff[i][j][2][1] - + ybar*(2*coeff[i][j][2][2] - + 3*ybar*coeff[i][j][2][3]); - double y3 = coeff[i][j][3][1] - + ybar*(2*coeff[i][j][3][2] - + 3*ybar*coeff[i][j][3][3]); + double y0 = coeff[i][j][0][1] + ybar * (2 * coeff[i][j][0][2] + 3 * ybar * coeff[i][j][0][3]); + double y1 = coeff[i][j][1][1] + ybar * (2 * coeff[i][j][1][2] + 3 * ybar * coeff[i][j][1][3]); + double y2 = coeff[i][j][2][1] + ybar * (2 * coeff[i][j][2][2] + 3 * ybar * coeff[i][j][2][3]); + double y3 = coeff[i][j][3][1] + ybar * (2 * coeff[i][j][3][2] + 3 * ybar * coeff[i][j][3][3]); - return y0 + xbar*(y1 + xbar*(y2 + xbar*y3)); + return y0 + xbar * (y1 + xbar * (y2 + xbar * y3)); } /* ---------------------------------------------------------------------- compute local geometric parameters ------------------------------------------------------------------------- */ -void PairMesoCNT::geometry(const double *r1, const double *r2, - const double *p1, const double *p2, const double *qe, - double *p, double *m, double *param, double **basis) +void PairMesoCNT::geometry(const double *r1, const double *r2, const double *p1, const double *p2, + const double *qe, double *p, double *m, double *param, double **basis) { - double r[3],delr[3],l[3],rbar[3],pbar[3],delrbar[3]; - double psil[3],psim[3],dell_psim[3],delpsil_m[3]; - double delr1[3],delr2[3],delp1[3],delp2[3],delpqe[3]; + double r[3], delr[3], l[3], rbar[3], pbar[3], delrbar[3]; + double psil[3], psim[3], dell_psim[3], delpsil_m[3]; + double delr1[3], delr2[3], delp1[3], delp2[3], delpqe[3]; double *ex = basis[0]; double *ey = basis[1]; double *ez = basis[2]; - add3(r1,r2,r); - scale3(0.5,r); - add3(p1,p2,p); - scale3(0.5,p); + add3(r1, r2, r); + scale3(0.5, r); + add3(p1, p2, p); + scale3(0.5, p); - sub3(p,r,delr); + sub3(p, r, delr); - sub3(r2,r1,l); + sub3(r2, r1, l); norm3(l); - sub3(p2,p1,m); + sub3(p2, p1, m); norm3(m); - double psi = dot3(l,m); - if (psi > 1.0) psi = 1.0; - else if (psi < -1.0) psi = -1.0; - double denom = 1.0 - psi*psi; + double psi = dot3(l, m); + if (psi > 1.0) + psi = 1.0; + else if (psi < -1.0) + psi = -1.0; + double denom = 1.0 - psi * psi; - copy3(l,psil); - scale3(psi,psil); - copy3(m,psim); - scale3(psi,psim); + copy3(l, psil); + scale3(psi, psil); + copy3(m, psim); + scale3(psi, psim); - double rhoe,etae,taur,taup; + double rhoe, etae, taur, taup; if (qe) { - sub3(p,qe,delpqe); - rhoe = dot3(delpqe,m); - } else rhoe = 0; + sub3(p, qe, delpqe); + rhoe = dot3(delpqe, m); + } else + rhoe = 0; // parallel case if (denom < SWITCH) { - taur = dot3(delr,l) - rhoe*psi; + taur = dot3(delr, l) - rhoe * psi; taup = -rhoe; etae = 0; - // non-parallel case + // non-parallel case } else { double frac = 1.0 / denom; - sub3(l,psim,dell_psim); - sub3(psil,m,delpsil_m); - taur = dot3(delr,dell_psim) * frac; - taup = dot3(delr,delpsil_m) * frac; + sub3(l, psim, dell_psim); + sub3(psil, m, delpsil_m); + taur = dot3(delr, dell_psim) * frac; + taup = dot3(delr, delpsil_m) * frac; etae = -rhoe - taup; } - scaleadd3(taur,l,r,rbar); - scaleadd3(taup,m,p,pbar); - sub3(pbar,rbar,delrbar); + scaleadd3(taur, l, r, rbar); + scaleadd3(taup, m, p, pbar); + sub3(pbar, rbar, delrbar); double h = len3(delrbar); - if (h*ang_inv < SMALL) h = SMALL * ang; + if (h * ang_inv < SMALL) h = SMALL * ang; - copy3(delrbar,ex); - copy3(l,ez); - scale3(1.0/h,ex); - cross3(ez,ex,ey); + copy3(delrbar, ex); + copy3(l, ez); + scale3(1.0 / h, ex); + cross3(ez, ex, ey); double alpha; - alpha = (dot3(m,ey) < 0) ? acos(psi) : MY_2PI - acos(psi); + alpha = (dot3(m, ey) < 0) ? acos(psi) : MY_2PI - acos(psi); - sub3(r1,rbar,delr1); - sub3(r2,rbar,delr2); - sub3(p1,pbar,delp1); - sub3(p2,pbar,delp2); - double xi1 = dot3(delr1,l); - double xi2 = dot3(delr2,l); - double eta1 = dot3(delp1,m); - double eta2 = dot3(delp2,m); + sub3(r1, rbar, delr1); + sub3(r2, rbar, delr2); + sub3(p1, pbar, delp1); + sub3(p2, pbar, delp2); + double xi1 = dot3(delr1, l); + double xi2 = dot3(delr2, l); + double eta1 = dot3(delp1, m); + double eta2 = dot3(delp2, m); param[0] = h; param[1] = alpha; @@ -1581,30 +1523,27 @@ void PairMesoCNT::geometry(const double *r1, const double *r2, param[6] = etae; } - /* ---------------------------------------------------------------------- weight for substitute CNT chain ------------------------------------------------------------------------- */ -void PairMesoCNT::weight(const double *r1, const double *r2, - const double *p1, const double *p2, double &w, - double *dr1_w, double *dr2_w, - double *dp1_w, double *dp2_w) +void PairMesoCNT::weight(const double *r1, const double *r2, const double *p1, const double *p2, + double &w, double *dr1_w, double *dr2_w, double *dp1_w, double *dp2_w) { - double dr,dp,rhoc,rhomin,rho,frac,arg,factor; - double r[3],p[3]; - double dr_rho[3],dr_rhoc[3],dp_rhoc[3]; + double dr, dp, rhoc, rhomin, rho, frac, arg, factor; + double r[3], p[3]; + double dr_rho[3], dr_rhoc[3], dp_rhoc[3]; - add3(r1,r2,r); - add3(p1,p2,p); - scale3(0.5,r); - scale3(0.5,p); + add3(r1, r2, r); + add3(p1, p2, p); + scale3(0.5, r); + scale3(0.5, p); - dr = sqrt(0.25*distsq3(r1,r2) + rsq); - dp = sqrt(0.25*distsq3(p1,p2) + rsq); + dr = sqrt(0.25 * distsq3(r1, r2) + rsq); + dp = sqrt(0.25 * distsq3(p1, p2) + rsq); rhoc = dr + dp + rc; rhomin = 20.0 * ang; - rho = sqrt(distsq3(r,p)); + rho = sqrt(distsq3(r, p)); frac = 1.0 / (rhoc - rhomin); arg = frac * (rho - rhomin); @@ -1618,22 +1557,22 @@ void PairMesoCNT::weight(const double *r1, const double *r2, } else { factor = ds(arg) * frac; - sub3(r,p,dr_rho); - sub3(r1,r2,dr_rhoc); - sub3(p1,p2,dp_rhoc); - scale3(0.5/rho,dr_rho); - scale3(0.25/dr,dr_rhoc); - scale3(0.25/dp,dp_rhoc); + sub3(r, p, dr_rho); + sub3(r1, r2, dr_rhoc); + sub3(p1, p2, dp_rhoc); + scale3(0.5 / rho, dr_rho); + scale3(0.25 / dr, dr_rhoc); + scale3(0.25 / dp, dp_rhoc); - scaleadd3(-arg,dr_rhoc,dr_rho,dr1_w); - scaleadd3(arg,dr_rhoc,dr_rho,dr2_w); + scaleadd3(-arg, dr_rhoc, dr_rho, dr1_w); + scaleadd3(arg, dr_rhoc, dr_rho, dr2_w); negate3(dr_rho); - scaleadd3(-arg,dp_rhoc,dr_rho,dp1_w); - scaleadd3(arg,dp_rhoc,dr_rho,dp2_w); - scale3(factor,dr1_w); - scale3(factor,dr2_w); - scale3(factor,dp1_w); - scale3(factor,dp2_w); + scaleadd3(-arg, dp_rhoc, dr_rho, dp1_w); + scaleadd3(arg, dp_rhoc, dr_rho, dp2_w); + scale3(factor, dr1_w); + scale3(factor, dr2_w); + scale3(factor, dp1_w); + scale3(factor, dp2_w); } } @@ -1654,11 +1593,9 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) // parallel case if (sin_alphasq < SWITCH) { - double ubar = spline(h,hstart_uinf,delh_uinf,uinf_coeff,uinf_points); + double ubar = spline(h, hstart_uinf, delh_uinf, uinf_coeff, uinf_points); double delxi = xi2 - xi1; - f[0][0] = 0.5 * delxi - * dspline(h,hstart_uinf,delh_uinf,uinf_coeff,uinf_points) - * funit; + f[0][0] = 0.5 * delxi * dspline(h, hstart_uinf, delh_uinf, uinf_coeff, uinf_points) * funit; f[1][0] = f[0][0]; f[0][1] = 0; f[1][1] = 0; @@ -1666,7 +1603,7 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) f[1][2] = -f[0][2]; evdwl = ubar * delxi * eunit; - // non-parallel case + // non-parallel case } else { double sin_alpha_inv = 1.0 / sin_alpha; @@ -1674,16 +1611,14 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) double cos_alpha = cos(alpha); double cot_alpha = cos_alpha * sin_alpha_inv; - double omega = 1.0 / (1.0 - comega*sin_alphasq); + double omega = 1.0 / (1.0 - comega * sin_alphasq); double c1 = omega * sin_alpha; double c1_inv = 1.0 / c1; double domega = 2 * comega * cos_alpha * c1 * omega; - double gamma_orth = - spline(h,hstart_gamma,delh_gamma,gamma_coeff,gamma_points); - double dgamma_orth = - dspline(h,hstart_gamma,delh_gamma,gamma_coeff,gamma_points); - double gamma = 1.0 + (gamma_orth - 1.0)*sin_alphasq; + double gamma_orth = spline(h, hstart_gamma, delh_gamma, gamma_coeff, gamma_points); + double dgamma_orth = dspline(h, hstart_gamma, delh_gamma, gamma_coeff, gamma_points); + double gamma = 1.0 + (gamma_orth - 1.0) * sin_alphasq; double gamma_inv = 1.0 / gamma; double dalpha_gamma = 2 * (gamma_orth - 1) * sin_alpha * cos_alpha; double dh_gamma = dgamma_orth * sin_alphasq; @@ -1691,22 +1626,25 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) double zeta1 = xi1 * c1; double zeta2 = xi2 * c1; - double smooth = s5((h-d_ang-delta1)/(delta2-delta1)); - double dsmooth = ds5((h-d_ang-delta1)/(delta2-delta1)); + double smooth = s5((h - d_ang - delta1) / (delta2 - delta1)); + double dsmooth = ds5((h - d_ang - delta1) / (delta2 - delta1)); double g = d_ang + delta2; double hsq = h * h; double zetaminbar; - if (h >= g) zetaminbar = 0; - else zetaminbar = sqrt(g*g - hsq); + if (h >= g) + zetaminbar = 0; + else + zetaminbar = sqrt(g * g - hsq); double zetamin = smooth * zetaminbar; double zetamax = sqrt(cutoffsq_ang - hsq); double dzetaminbar; - if (h >= g) dzetaminbar = 0; - else dzetaminbar = -h / zetaminbar; - double dzetamin = - dzetaminbar*smooth + zetaminbar*dsmooth/(delta2-delta1); + if (h >= g) + dzetaminbar = 0; + else + dzetaminbar = -h / zetaminbar; + double dzetamin = dzetaminbar * smooth + zetaminbar * dsmooth / (delta2 - delta1); double dzetamax = -h / zetamax; double zeta_range_inv = 1.0 / (zetamax - zetamin); @@ -1716,24 +1654,24 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) double psi1 = delzeta1 * zeta_range_inv; double psi2 = delzeta2 * zeta_range_inv; - double phi1 = spline(h,psi1,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_coeff,phi_points); - double dh_phibar1 = dxspline(h,psi1,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_coeff,phi_points); - double dpsi_phibar1 = dyspline(h,psi1,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_coeff,phi_points); - double phi2 = spline(h,psi2,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_coeff,phi_points); - double dh_phibar2 = dxspline(h,psi2,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_coeff,phi_points); - double dpsi_phibar2 = dyspline(h,psi2,hstart_phi,psistart_phi, - delh_phi,delpsi_phi,phi_coeff,phi_points); + double phi1 = + spline(h, psi1, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_coeff, phi_points); + double dh_phibar1 = + dxspline(h, psi1, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_coeff, phi_points); + double dpsi_phibar1 = + dyspline(h, psi1, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_coeff, phi_points); + double phi2 = + spline(h, psi2, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_coeff, phi_points); + double dh_phibar2 = + dxspline(h, psi2, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_coeff, phi_points); + double dpsi_phibar2 = + dyspline(h, psi2, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_coeff, phi_points); double dzeta_range = dzetamax - dzetamin; - double dh_psi1 = -zeta_range_inv * (dzetamin + dzeta_range*psi1); - double dh_psi2 = -zeta_range_inv * (dzetamin + dzeta_range*psi2); - double dh_phi1 = dh_phibar1 + dpsi_phibar1*dh_psi1; - double dh_phi2 = dh_phibar2 + dpsi_phibar2*dh_psi2; + double dh_psi1 = -zeta_range_inv * (dzetamin + dzeta_range * psi1); + double dh_psi2 = -zeta_range_inv * (dzetamin + dzeta_range * psi2); + double dh_phi1 = dh_phibar1 + dpsi_phibar1 * dh_psi1; + double dh_phi2 = dh_phibar2 + dpsi_phibar2 * dh_psi2; double dzeta_phi1 = dpsi_phibar1 * zeta_range_inv; double dzeta_phi2 = dpsi_phibar2 * zeta_range_inv; @@ -1754,19 +1692,19 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) double u = c2 * (phi2 - phi1); double c3 = u * gamma_inv; - double dh_u = dh_gamma*c3 + c2*(dh_phi2 - dh_phi1); - double dalpha_u = dalpha_gamma*c3 - + c1_inv*(domega*sin_alpha + omega*cos_alpha) - * (gamma*(xi2*dzeta_phi2 - xi1*dzeta_phi1) - u); + double dh_u = dh_gamma * c3 + c2 * (dh_phi2 - dh_phi1); + double dalpha_u = dalpha_gamma * c3 + + c1_inv * (domega * sin_alpha + omega * cos_alpha) * + (gamma * (xi2 * dzeta_phi2 - xi1 * dzeta_phi1) - u); double lr_inv = 1.0 / (xi2 - xi1); double cx = h * gamma * sin_alphasq_inv * deldzeta_phi; double cy = gamma * cot_alpha * deldzeta_phi; - f[0][0] = lr_inv * (xi2*dh_u - cx) * funit; - f[1][0] = lr_inv * (-xi1*dh_u + cx) * funit; - f[0][1] = lr_inv * (dalpha_u - xi2*cy) * funit; - f[1][1] = lr_inv * (-dalpha_u + xi1*cy) * funit; + f[0][0] = lr_inv * (xi2 * dh_u - cx) * funit; + f[1][0] = lr_inv * (-xi1 * dh_u + cx) * funit; + f[0][1] = lr_inv * (dalpha_u - xi2 * cy) * funit; + f[1][1] = lr_inv * (-dalpha_u + xi1 * cy) * funit; f[0][2] = gamma * dzeta_phi1 * funit; f[1][2] = -gamma * dzeta_phi2 * funit; evdwl = u * eunit; @@ -1777,8 +1715,7 @@ void PairMesoCNT::finf(const double *param, double &evdwl, double **f) forces for semi-infinite CNT case ------------------------------------------------------------------------- */ -void PairMesoCNT::fsemi(const double *param, double &evdwl, - double &fend, double **f) +void PairMesoCNT::fsemi(const double *param, double &evdwl, double &fend, double **f) { double h = param[0] * ang_inv; double alpha = param[1]; @@ -1790,22 +1727,20 @@ void PairMesoCNT::fsemi(const double *param, double &evdwl, double sin_alphasq = sin_alpha * sin_alpha; double cos_alpha = cos(alpha); - double omega = 1.0 / (1.0 - comega*sin_alphasq); + double omega = 1.0 / (1.0 - comega * sin_alphasq); double omegasq = omega * omega; double domega = 2 * comega * sin_alpha * cos_alpha * omegasq; - double theta = 1.0 - ctheta*sin_alphasq; + double theta = 1.0 - ctheta * sin_alphasq; double dtheta = -2 * ctheta * sin_alpha * cos_alpha; double c1 = omega * sin_alpha; double c1sq = c1 * c1; double c2 = theta * etae; - double gamma_orth = spline(h,hstart_gamma,delh_gamma, - gamma_coeff,gamma_points); - double dgamma_orth = dspline(h,hstart_gamma,delh_gamma, - gamma_coeff,gamma_points); - double gamma = 1.0 + (gamma_orth - 1)*sin_alphasq; + double gamma_orth = spline(h, hstart_gamma, delh_gamma, gamma_coeff, gamma_points); + double dgamma_orth = dspline(h, hstart_gamma, delh_gamma, gamma_coeff, gamma_points); + double gamma = 1.0 + (gamma_orth - 1) * sin_alphasq; double gamma_inv = 1.0 / gamma; double dalpha_gamma = 2 * (gamma_orth - 1) * sin_alpha * cos_alpha; double dh_gamma = dgamma_orth * sin_alphasq; @@ -1821,22 +1756,27 @@ void PairMesoCNT::fsemi(const double *param, double &evdwl, double ubar = 0; for (int i = 0; i < QUADRATURE; i++) { - double xibar = xi1 + i*delxi; + double xibar = xi1 + i * delxi; double g = xibar * c1; - double hbar = sqrt(h*h + g*g); - double thetabar = xibar*cos_alpha - c2; + double hbar = sqrt(h * h + g * g); + double thetabar = xibar * cos_alpha - c2; double c = 1.0; - if (i == 0 || i == QUADRATURE-1) c = 0.5; + if (i == 0 || i == QUADRATURE - 1) c = 0.5; - double u = c * spline(hbar,thetabar,hstart_usemi,xistart_usemi, - delh_usemi,delxi_usemi,usemi_coeff,usemi_points); + double u = c * + spline(hbar, thetabar, hstart_usemi, xistart_usemi, delh_usemi, delxi_usemi, usemi_coeff, + usemi_points); double uh; - if (hbar == 0) uh = 0; - else uh = c / hbar * dxspline(hbar,thetabar,hstart_usemi,xistart_usemi, - delh_usemi,delxi_usemi,usemi_coeff,usemi_points); - double uxi = c * dyspline(hbar,thetabar,hstart_usemi,xistart_usemi, - delh_usemi,delxi_usemi,usemi_coeff,usemi_points); + if (hbar == 0) + uh = 0; + else + uh = c / hbar * + dxspline(hbar, thetabar, hstart_usemi, xistart_usemi, delh_usemi, delxi_usemi, + usemi_coeff, usemi_points); + double uxi = c * + dyspline(hbar, thetabar, hstart_usemi, xistart_usemi, delh_usemi, delxi_usemi, usemi_coeff, + usemi_points); double uh1 = xibar * uh; jh += uh; @@ -1855,23 +1795,22 @@ void PairMesoCNT::fsemi(const double *param, double &evdwl, ubar *= c3; double c4 = gamma_inv * ubar; - double dh_ubar = dh_gamma*c4 + h*jh; - double dalpha_ubar = dalpha_gamma*c4 - + c1*(domega*sin_alpha + omega*cos_alpha)*jh2 - - sin_alpha*jxi1 - dtheta*etae*jxi; + double dh_ubar = dh_gamma * c4 + h * jh; + double dalpha_ubar = dalpha_gamma * c4 + c1 * (domega * sin_alpha + omega * cos_alpha) * jh2 - + sin_alpha * jxi1 - dtheta * etae * jxi; - double cx = h * (omegasq*jh1 + cos_alpha*ctheta*jxi); - double cy = sin_alpha * (cos_alpha*omegasq*jh1 + (ctheta-1)*jxi); - double cz1 = c1sq*jh1 + cos_alpha*jxi; - double cz2 = c1sq*jh2 + cos_alpha*jxi1; + double cx = h * (omegasq * jh1 + cos_alpha * ctheta * jxi); + double cy = sin_alpha * (cos_alpha * omegasq * jh1 + (ctheta - 1) * jxi); + double cz1 = c1sq * jh1 + cos_alpha * jxi; + double cz2 = c1sq * jh2 + cos_alpha * jxi1; double l_inv = 1.0 / (xi2 - xi1); - f[0][0] = l_inv * (xi2*dh_ubar - cx) * funit; - f[1][0] = l_inv * (cx - xi1*dh_ubar) * funit; - f[0][1] = l_inv * (dalpha_ubar - xi2*cy) * funit; - f[1][1] = l_inv * (xi1*cy - dalpha_ubar) * funit; - f[0][2] = l_inv * (cz2 + ubar - xi2*cz1) * funit; - f[1][2] = l_inv * (xi1*cz1 - cz2 - ubar) * funit; + f[0][0] = l_inv * (xi2 * dh_ubar - cx) * funit; + f[1][0] = l_inv * (cx - xi1 * dh_ubar) * funit; + f[0][1] = l_inv * (dalpha_ubar - xi2 * cy) * funit; + f[1][1] = l_inv * (xi1 * cy - dalpha_ubar) * funit; + f[0][2] = l_inv * (cz2 + ubar - xi2 * cz1) * funit; + f[1][2] = l_inv * (xi1 * cz1 - cz2 - ubar) * funit; evdwl = ubar * eunit; fend = theta * jxi * funit; diff --git a/src/MESONT/pair_mesocnt.h b/src/MESONT/pair_mesocnt.h index 76c1bf6b0f..94ea2b8133 100644 --- a/src/MESONT/pair_mesocnt.h +++ b/src/MESONT/pair_mesocnt.h @@ -12,9 +12,7 @@ ------------------------------------------------------------------------- */ #ifdef PAIR_CLASS -// clang-format off PairStyle(mesocnt, PairMesoCNT); -// clang-format on #else #ifndef LMP_PAIR_MESOCNT_H From 7288828439fbeb6e837fd28ba62645d45007cc27 Mon Sep 17 00:00:00 2001 From: phankl Date: Fri, 4 Mar 2022 13:48:44 +0000 Subject: [PATCH 28/72] defined np1 = ntypes + 1 to shorten allocation commands --- src/MESONT/pair_mesocnt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index ae9b460a11..c0c815d793 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -387,10 +387,11 @@ void PairMesoCNT::allocate() { allocated = 1; int ntypes = atom->ntypes; + int np1 = ntypes + 1; int init_size = 1; - memory->create(cutsq, ntypes + 1, ntypes + 1, "pair:cutsq"); - memory->create(setflag, ntypes + 1, ntypes + 1, "pair:setflag"); + memory->create(cutsq, np1, np1, "pair:cutsq"); + memory->create(setflag, np1, np1, "pair:setflag"); for (int i = 1; i <= ntypes; i++) for (int j = i; j <= ntypes; j++) setflag[i][j] = 0; From 760d85b9c4f4bc324ddbb675478ad54b7d096bc6 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:04:18 +0100 Subject: [PATCH 29/72] Two computes that computes the local mechanical pressure tensor in Cartesian and spherical coordinates --- doc/src/compute_pressure_cartesian.rst | 63 ++ doc/src/compute_pressure_spherical.rst | 61 ++ .../compute_pressure_cartesian.cpp | 537 ++++++++++++++++++ .../compute_pressure_cartesian.h | 71 +++ .../compute_pressure_spherical.cpp | 413 ++++++++++++++ .../compute_pressure_spherical.h | 69 +++ 6 files changed, 1214 insertions(+) create mode 100644 doc/src/compute_pressure_cartesian.rst create mode 100644 doc/src/compute_pressure_spherical.rst create mode 100644 src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp create mode 100644 src/EXTRA-COMPUTE/compute_pressure_cartesian.h create mode 100644 src/EXTRA-COMPUTE/compute_pressure_spherical.cpp create mode 100644 src/EXTRA-COMPUTE/compute_pressure_spherical.h diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_pressure_cartesian.rst new file mode 100644 index 0000000000..7a6f0be652 --- /dev/null +++ b/doc/src/compute_pressure_cartesian.rst @@ -0,0 +1,63 @@ +.. index:: compute pressure/cartesian + +compute pressure/cartesian command +================================== + +Syntax +"""""" + +.. parsed-literal:: + + compute ID group-ID pressure/cartesian dim bin_width + +* ID, group-ID are documented in :doc:`compute ` command +* pressure/cartesian = style name of this compute command +* one or two dim/bin_width pairs may be appended +* dim = x, y, or z +* bin_width = width of the bin + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all pressure/cartesian x 0.1 + compute 1 all pressure/cartesian y 0.25 z 0.1 + +Description +""""""""""" + +This computes the Cartesian pressure tensor in one or two dimensions, as described in :ref:`(Ikeshoji)`. This can for example be used to calculate the local pressure tensor of flat liquid-vapor interfaces. This compute obeys momentum balance, such that the pressure tensor component normal to a surface is constant. This compute uses the Irving-Kirkwood contour, which is the straight line between particle pairs. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the total pressure tensor :math:`P = P^k+P^v`. + +Output info +""""""""""" + +The output is a global array with 8 columns when only one dimension is specified and 9 columns when two dimensions are specified. There are (L1*L2)/(bin_width1*bin_width2) rows, where L1 and L2 are the size of the simulation box in the relevant dimensions. The output columns are position of the center of the local volume in the first and second dimension (when two dimensions are specified), number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. + +This array can be output with the :doc:`fix ave/time `, + +.. code-block:: LAMMPS + + compute p all pressure/cartesian x 0.1 + fix 2 all ave/time 100 1 100 c_p[*] file dump_p.out mode vector + +Restrictions +"""""""""""" + +This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. + +Related commands +"""""""""""""""" + +:doc:`compute stress/atom `, :doc:`compute pressure/cylinder `, :doc:`compute pressure/spherical ` + +Default +""""""" + +none + +---------- + +.. _Ikeshoji2: + +**(Ikeshoji)** Ikeshoji, Hafskjold, Furuholt, Mol Sim, 29, 101-109, (2003). diff --git a/doc/src/compute_pressure_spherical.rst b/doc/src/compute_pressure_spherical.rst new file mode 100644 index 0000000000..2e772f057f --- /dev/null +++ b/doc/src/compute_pressure_spherical.rst @@ -0,0 +1,61 @@ +.. index:: compute pressure/spherical + +compute pressure/spherical command +================================== + +Syntax +"""""" + +.. parsed-literal:: + + compute ID group-ID pressure/spherical x0 y0 z0 bin_width Rmax + +* ID, group-ID are documented in :doc:`compute ` command +* pressure/cartesian = style name of this compute command +* x0, y0, z0 = origin of the spherical coordinate system +* bin_width = width of spherical shells +* Rmax = maximum radius of spherical shells + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all pressure/spherical 0 0 0 0.1 10 + +Description +""""""""""" + +This computes the diagonal components of the spherical pressure tensor in spherical shells, as described in :ref:`(Ikeshoji)`. This can be used to calculate the local pressure tensor components of for example droplets and bubbles. This compute obeys momentum balance. This compute uses the Irving-Kirkwood contour, whici is the straight line between particle pairs. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the pressure :math:`P = P^k+P^v`. + +Output info +""""""""""" + +This compute outputs a global array with 8 columns and Rmax/bin_width. The output columns are position of the center of the local spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. + +This array can be output with :doc:`fix ave/time `, + +.. code-block:: LAMMPS + + compute p all pressure/spherical 0 0 0 0.1 10 + fix 2 all ave/time 100 1 100 c_p[*] file dump_p.out mode vector + +Restrictions +"""""""""""" + +This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. + +Related commands +"""""""""""""""" + +:doc:`compute stress/atom `, :doc:`compute pressure/cylinder `, :doc:`compute pressure/cartesian ` + +Default +""""""" + +none + +---------- + +.. _Ikeshoji2: +**(Ikeshoji)** Ikeshoji, Hafskjold, Furuholt, Mol Sim, 29, 101-109, (2003). diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp new file mode 100644 index 0000000000..586bc463f8 --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -0,0 +1,537 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 dir1ectory. +------------------------------------------------------------------------- */ + +#include "compute_pressure_cartesian.h" +#include +#include +#include +#include "atom.h" +#include "force.h" +#include "pair.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_request.h" +#include "neigh_list.h" +#include "memory.h" +#include "error.h" +#include "citeme.h" +#include "domain.h" +#include "math_const.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +static const char cite_compute_pressure_cartesian[] = + "compute pressure/cartesian:\n\n" + "@article{ikeshoji2003molecular,\n" + "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bjørn and Furuholt, Hilde},\n" + "journal={Molecular Simulation},\n" + "volume={29},\n" + "number={2},\n" + "pages={101--109},\n" + "year={2003},\n" + "publisher={Taylor & Francis}\n" + "}\n\n"; + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ + +ComputePressureCart::ComputePressureCart(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + dens(NULL), + pkxx(NULL), pkyy(NULL), pkzz(NULL), + pcxx(NULL), pcyy(NULL), pczz(NULL), + tdens(NULL), + tpkxx(NULL), tpkyy(NULL), tpkzz(NULL), + tpcxx(NULL), tpcyy(NULL), tpczz(NULL) +{ + + if (lmp->citeme) + lmp->citeme->add(cite_compute_pressure_cartesian); + + // narg == 5 for one-dimensional and narg == 7 for two-dimensional + if (narg == 5) dims = 1; + else if (narg == 7) dims = 2; + else error->all(FLERR,"Illegal compute pressure/cartesian command. Illegal number of arguments."); + + if (strcmp(arg[3], "x") == 0) dir1 = 0; + else if (strcmp(arg[3], "y") == 0) dir1 = 1; + else if (strcmp(arg[3], "z") == 0) dir1 = 2; + else error->all(FLERR,"Illegal compute pressure/cartesian command."); + + dir2 = 0; + bin_width1 = utils::numeric(FLERR, arg[4], false, lmp); + bin_width2 = 0.0; + nbins1 = (int)((domain->boxhi[dir1]-domain->boxlo[dir1])/bin_width1); + nbins2 = 1; + invV = bin_width1; + + if (bin_width1 <= 0.0) + error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be > 0"); + else if (bin_width1 > domain->boxhi[dir1]-domain->boxlo[dir1]) + error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); + + if (dims == 2){ + if (strcmp(arg[5], "x") == 0) dir2 = 0; + else if (strcmp(arg[5], "y") == 0) dir2 = 1; + else if (strcmp(arg[5], "z") == 0) dir2 = 2; + else error->all(FLERR,"Illegal compute pressure/cartesian command."); + + bin_width2 = utils::numeric(FLERR, arg[6], false, lmp); + nbins2 = (int)((domain->boxhi[dir2]-domain->boxlo[dir2])/bin_width2); + invV *= bin_width2; + + if (bin_width2 <= 0.0) + error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be > 0"); + else if (bin_width2 > domain->boxhi[dir2]-domain->boxlo[dir2]) + error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); + } + + for (int i = 0; i < 3; i++) + if ((dims == 1 && i != dir1) || (dims == 2 && (i != dir1 && i != dir2))) + invV *= domain->boxhi[i] - domain->boxlo[i]; + invV = 1.0/invV; + + array_flag = 1; + vector_flag = 0; + extarray = 0; + size_array_cols = 7+dims; // dir1, dir2, number density, pkxx, pkyy, pkzz, pcxx, pcyy, pczz + size_array_rows = nbins1*nbins2; + + memory->create(dens, nbins1*nbins2, "dens" ); + memory->create(pkxx, nbins1*nbins2, "pkxx" ); + memory->create(pkyy, nbins1*nbins2, "pkyy" ); + memory->create(pkzz, nbins1*nbins2, "pkzz" ); + memory->create(pcxx, nbins1*nbins2, "pcxx" ); + memory->create(pcyy, nbins1*nbins2, "pcyy" ); + memory->create(pczz, nbins1*nbins2, "pczz" ); + memory->create(tdens, nbins1*nbins2, "tdens"); + memory->create(tpkxx, nbins1*nbins2, "tpkxx"); + memory->create(tpkyy, nbins1*nbins2, "tpkyy"); + memory->create(tpkzz, nbins1*nbins2, "tpkzz"); + memory->create(tpcxx, nbins1*nbins2, "tpcxx"); + memory->create(tpcyy, nbins1*nbins2, "tpcyy"); + memory->create(tpczz, nbins1*nbins2, "tpczz"); + memory->create(array, size_array_rows, size_array_cols, "pressure:cartesian:output"); +} + +/* ---------------------------------------------------------------------- */ + +ComputePressureCart::~ComputePressureCart() +{ + memory->destroy(dens); + memory->destroy(pkxx); + memory->destroy(pkyy); + memory->destroy(pkzz); + memory->destroy(pcxx); + memory->destroy(pcyy); + memory->destroy(pczz); + memory->destroy(tdens); + memory->destroy(tpkxx); + memory->destroy(tpkyy); + memory->destroy(tpkzz); + memory->destroy(tpcxx); + memory->destroy(tpcyy); + memory->destroy(tpczz); + memory->destroy(array); +} + +/* ---------------------------------------------------------------------- */ + +void ComputePressureCart::init() +{ + if (force->pair == NULL) + error->all(FLERR,"No pair style is defined for compute pressure/cartesian"); + if (force->pair->single_enable == 0) + error->all(FLERR,"Pair style does not support compute pressure/cartesian"); + + // need an occasional half neighbor list. + int irequest = neighbor->request(this, instance_me); + neighbor->requests[irequest]->pair = 0; + neighbor->requests[irequest]->compute = 1; + neighbor->requests[irequest]->occasional = 1; +} + +/* ---------------------------------------------------------------------- */ + +void ComputePressureCart::init_list(int /* id */, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + + +/* ---------------------------------------------------------------------- + count pairs and compute pair info on this proc + only count pair once if newton_pair is off + both atom I,J must be in group + if flag is set, compute requested info about pair +------------------------------------------------------------------------- */ + +void ComputePressureCart::compute_array() +{ + //invoked_array = update->ntimestep; + int me; + MPI_Comm_rank(world, &me); + + int i, j, ii, jj, inum, jnum, itype, jtype; + int bin, bin1, bin2, bin3; + tagint itag, jtag; + double xtmp, ytmp, ztmp, delx, dely, delz; + double rsq, fpair, factor_coul, factor_lj; + int *ilist, *jlist, *numneigh, **firstneigh; + + double **x = atom->x; + double **v = atom->v; + double *mass = atom->mass; + tagint *tag = atom->tag; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + + // invoke half neighbor list (will copy or build if necessary) + neighbor->build_one(list); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // Zero arrays + for (bin = 0; bin < nbins1*nbins2; bin++) { + tdens[bin] = 0; + tpkxx[bin] = 0; + tpkyy[bin] = 0; + tpkzz[bin] = 0; + tpcxx[bin] = 0; + tpcyy[bin] = 0; + tpczz[bin] = 0; + } + + // calculate number density and kinetic contribution to pressure + for (i = 0; i < nlocal; i++){ + bin1 = (int)(x[i][dir1]/bin_width1)%nbins1; + bin2 = 0; + if (dims == 2) + bin2 = (int)(x[i][dir2]/bin_width2)%nbins2; + + j = bin1+bin2*nbins1; + tdens[j] += 1; + // TODO: Subtract streaming velocity + tpkxx[j] += mass[type[i]]*v[i][0]*v[i][0]; + tpkyy[j] += mass[type[i]]*v[i][1]*v[i][1]; + tpkzz[j] += mass[type[i]]*v[i][2]*v[i][2]; + } + + // loop over neighbors of my atoms + // skip if I or J are not in group + // for newton = 0 and J = ghost atom, + // need to insure I,J pair is only output by one proc + // use same itag,jtag logic as in Neighbor::neigh_half_nsq() + // for flag = 0, just count pair interactions within force cutoff + // for flag = 1, calculate requested output fields + + Pair *pair = force->pair; + double **cutsq = force->pair->cutsq; + + double risq, rjsq; + double xi1, xi2, xj1, xj2; + + for (ii = 0; ii < inum; ii++){ + i = ilist[ii]; + if (!(mask[i] & groupbit)) continue; + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + xi1 = x[i][dir1]; + xi2 = x[i][dir2]; + itag = tag[i]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + j &= NEIGHMASK; + if (!(mask[j] & groupbit)) continue; + + // itag = jtag is possible for long cutoffs that include images of self + // do calculation only on appropriate processor + if (newton_pair == 0 && j >= nlocal) { + jtag = tag[j]; + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + } + } + xj1 = x[j][dir1]; + xj2 = x[j][dir2]; + + delx = x[j][0]-xtmp; + dely = x[j][1]-ytmp; + delz = x[j][2]-ztmp; + + rsq = delx*delx + dely*dely + delz*delz; + jtype = type[j]; + + // Check if inside cut-off + if (rsq >= cutsq[itype][jtype]) continue; + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); + if (dims == 1) + compute_pressure_1d(fpair, xi1, xj1, delx, dely, delz); + if (dims == 2) + compute_pressure_2d(fpair, xi1, xi2, xj1, xj2, delx, dely, delz); + } + } + + // normalize pressure + for (bin = 0; bin < nbins1*nbins2; bin++) { + tdens[bin] *= invV; + tpkxx[bin] *= invV; + tpkyy[bin] *= invV; + tpkzz[bin] *= invV; + tpcxx[bin] *= invV; + tpcyy[bin] *= invV; + tpczz[bin] *= invV; + } + + // communicate across processors + MPI_Allreduce(tdens, dens, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkxx, pkxx, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkyy, pkyy, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkzz, pkzz, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpcxx, pcxx, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpcyy, pcyy, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpczz, pczz, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); + + // populate array to output. + for (bin = 0; bin < nbins1*nbins2; bin++) { + array[bin][0] = (bin%nbins1+0.5)*bin_width1; + if (dims == 2) + array[bin][1] = ((int)(bin/nbins1)+0.5)*bin_width2; + array[bin][0+dims] = dens[bin]; + array[bin][1+dims] = pkxx[bin]; + array[bin][2+dims] = pkyy[bin]; + array[bin][3+dims] = pkzz[bin]; + array[bin][4+dims] = pcxx[bin]; + array[bin][5+dims] = pcyy[bin]; + array[bin][6+dims] = pczz[bin]; + } +} + + +void ComputePressureCart::compute_pressure_1d(double fpair, double xi, double xj, double delx, double dely, double delz) +{ + int bin_s, bin_e, bin_step, bin, bin_limit; + double xa, xb, l_sum; + + if (xi < domain->boxlo[dir1]) + xi += (domain->boxhi[dir1]-domain->boxlo[dir1]); + else if (xi > domain->boxhi[dir1]) + xi -= (domain->boxhi[dir1]-domain->boxlo[dir1]); + if (xj < domain->boxlo[dir1]) + xj += (domain->boxhi[dir1]-domain->boxlo[dir1]); + else if (xj > domain->boxhi[dir1]) + xj -= (domain->boxhi[dir1]-domain->boxlo[dir1]); + + // Integrating contour from bin_s to bin_e + bin_s = lround((int)((xi - domain->boxlo[dir1])/bin_width1)%nbins1); + bin_e = lround((int)((xj - domain->boxlo[dir1])/bin_width1)%nbins1); + + // If not periodic in dir1 + if (domain->periodicity[dir1] == 0){ + bin_s = lround((int)((xi - domain->boxlo[dir1])/bin_width1)); + bin_e = lround((int)((xj - domain->boxlo[dir1])/bin_width1)); + + if (bin_e == nbins1) + bin_e--; + if (bin_s == nbins1) + bin_s--; + } + + bin_step = 1; + if (domain->periodicity[dir1] == 1){ + if (bin_e - bin_s > 0.5*nbins1) + bin_step = -1; + else if (bin_s - bin_e > 0.5*nbins1) + bin_step = 1; + else if (bin_s > bin_e) + bin_step = -1; + } + else { + if (bin_s > bin_e) + bin_step = -1; + } + if (domain->periodicity[dir1] == 1) + bin_limit = (bin_e+bin_step)%nbins1 < 0 ? (bin_e+bin_step)%nbins1+nbins1 : (bin_e+bin_step)%nbins1; + else + bin_limit = bin_e+bin_step; + + bin = bin_s; + // Integrate from bin_s to bin_e with step bin_step. + while (bin != bin_limit){ + + // Calculating exit and entry point (xa, xb). Checking if inside current bin. + if (bin == bin_s){ + if (domain->periodicity[dir1] == 1) + xa = fmod(xi, domain->boxhi[dir1])+domain->boxlo[dir1]; + else + xa = xi; + } + else + xa = (bin_step == 1) ? bin*bin_width1 : (bin+1)*bin_width1; + if (bin == bin_e){ + if (domain->periodicity[dir1] == 1) + xb = fmod(xj, domain->boxhi[dir1])+domain->boxlo[dir1]; + else + xb = xj; + } + else + xb = (bin_step == 1) ? (bin+1)*bin_width1 : bin*bin_width1; + + if (bin < 0 || bin >= nbins1) + error->all(FLERR,"ERROR: Bin outside simulation."); + + + if (bin_s != bin_e){ + if (dir1 == 0){ + tpcxx[bin] += (fpair*delx*delx) * (xb - xa)/delx; + tpcyy[bin] += (fpair*dely*dely) * (xb - xa)/delx; + tpczz[bin] += (fpair*delz*delz) * (xb - xa)/delx; + } + else if (dir1 == 1){ + tpcxx[bin] += (fpair*delx*delx) * (xb - xa)/dely; + tpcyy[bin] += (fpair*dely*dely) * (xb - xa)/dely; + tpczz[bin] += (fpair*delz*delz) * (xb - xa)/dely; + } + else if (dir1 == 2){ + tpcxx[bin] += (fpair*delx*delx) * (xb - xa)/delz; + tpcyy[bin] += (fpair*dely*dely) * (xb - xa)/delz; + tpczz[bin] += (fpair*delz*delz) * (xb - xa)/delz; + } + } + // Particle i and j in same bin. Avoiding zero divided by zero. + else { + tpcxx[bin] += fpair*delx*delx; + tpcyy[bin] += fpair*dely*dely; + tpczz[bin] += fpair*delz*delz; + } + + // Stepping bin to next bin + if (domain->periodicity[dir1] == 1) + bin = (bin+bin_step)%nbins1 < 0 ? (bin+bin_step)%nbins1+nbins1 : (bin+bin_step)%nbins1; + else + bin = bin+bin_step; + } +} + + +void ComputePressureCart::compute_pressure_2d(double fpair, double xi, double yi, double xj, double yj, double delx, double dely, double delz) +{ + int bin1, bin2, next_bin1, next_bin2; + double la = 0.0, lb = 0.0, l_sum = 0.0; + double rij[3] = {delx, dely, delz}; + double l1 = 0.0, l2, rij1, rij2; + double SMALL = 10e-5; + rij1 = rij[dir1]; + rij2 = rij[dir2]; + + next_bin1 = (int)floor(xi/bin_width1); + next_bin2 = (int)floor(yi/bin_width2); + + // Integrating along line + while (lb != 1.0){ + bin1 = next_bin1; + bin2 = next_bin2; + + if (rij1 > 0) + l1 = ((bin1+1)*bin_width1 - xi)/rij1; + else + l1 = (bin1*bin_width1 - xi)/rij1; + if (rij2 > 0) + l2 = ((bin2+1)*bin_width2 - yi)/rij2; + else + l2 = (bin2*bin_width2 - yi)/rij2; + + if ((l1 < l2 || l2 < lb+SMALL) && l1 <= 1.0 && l1 > lb){ + lb = l1; + next_bin1 = bin1+(int)(rij1/fabs(rij1)); + } + else if (l2 <= 1.0 && l2 > lb){ + lb = l2; + next_bin2 = bin2+(int)(rij2/fabs(rij2)); + } + else + lb = 1.0; + + // Periodic boundary conditions + if (domain->periodicity[dir1] == 1){ + if (bin1 < 0) + bin1 += nbins1; + else if (bin1 >= nbins1) + bin1 -= nbins1; + } + else if (bin1 < 0) + bin1 = 0; + else if (bin1 >= nbins1) + bin1 = nbins1-1; + + if (domain->periodicity[dir2] == 1){ + if (bin2 < 0) + bin2 += nbins2; + else if (bin2 >= nbins2) + bin2 -= nbins2; + } + else if (bin2 < 0) + bin2 = 0; + else if (bin2 >= nbins2) + bin2 = nbins2-1; + + if (bin1+bin2*nbins1 >= nbins1*nbins2) + error->all(FLERR, "Bin outside"); + + tpcxx[bin1+bin2*nbins1] += (fpair*delx*delx*(lb-la)); + tpcyy[bin1+bin2*nbins1] += (fpair*dely*dely*(lb-la)); + tpczz[bin1+bin2*nbins1] += (fpair*delz*delz*(lb-la)); + + l_sum += lb-la; + la = lb; + } + + if (l_sum > 1.0+SMALL || l_sum < 1.0-SMALL) + error->all(FLERR,"Sum of fractional line segments does not equal 1."); +} + +/* ---------------------------------------------------------------------- +memory usage of data +------------------------------------------------------------------------- */ + +double ComputePressureCart::memory_usage() +{ + return (14.0+dims+7)*(double)(nbins1*nbins2)*sizeof(double); +} diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h new file mode 100644 index 0000000000..63f5d1fa48 --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h @@ -0,0 +1,71 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 COMPUTE_CLASS + +ComputeStyle(pressure/cartesian,ComputePressureCart) + +#else + +#ifndef LMP_COMPUTE_PRESSURE_CARTESIAN +#define LMP_COMPUTE_PRESSURE_CARTESIAN + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputePressureCart : public Compute { + public: + ComputePressureCart(class LAMMPS *, int, char **); + ~ComputePressureCart(); + void init(); + void init_list(int, class NeighList *); + void compute_array(); + double memory_usage(); + + private: + int nbins1, nbins2, dir1, dir2, dims; + double bin_width1, bin_width2, invV; + + // Number density, kinetic and configurational contribution to the pressure. + double *dens, *pkxx, *pkyy, *pkzz, *pcxx, *pcyy, *pczz; + double *tdens, *tpkxx, *tpkyy, *tpkzz, *tpcxx, *tpcyy, *tpczz; + class NeighList *list; + void compute_pressure_1d(double, double, double, double, double, double); + void compute_pressure_2d(double, double, double, double, double, double, double, double); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: No pair style is defined for compute pressure/cartesian + +Self-explanatory. + +E: Pair style does not support compute pressure/cartesian + +The pair style does not have a single() function, so it can +not be invoked by compute pressure/cartesian. + +*/ + diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp new file mode 100644 index 0000000000..b99966623b --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -0,0 +1,413 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 dir1ectory. +------------------------------------------------------------------------- */ + +#include "compute_pressure_spherical.h" +#include +#include +#include +#include "atom.h" +#include "update.h" +#include "force.h" +#include "pair.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_request.h" +#include "neigh_list.h" +#include "memory.h" +#include "error.h" +#include "citeme.h" +#include "domain.h" +#include "math_const.h" + +using namespace LAMMPS_NS; +using namespace MathConst; + +static const char cite_compute_pressure_sphere[] = + "compute pressure/spherical:\n\n" + "@article{ikeshoji2003molecular,\n" + "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bjørn and Furuholt, Hilde},\n" + "journal={Molecular Simulation},\n" + "volume={29},\n" + "number={2},\n" + "pages={101--109},\n" + "year={2003},\n" + "publisher={Taylor & Francis}\n" + "}\n\n"; + +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ + +ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + dens(nullptr), + pkrr(nullptr), pktt(nullptr), pkpp(nullptr), + pcrr(nullptr), pctt(nullptr), pcpp(nullptr), + tdens(nullptr), + tpkrr(nullptr), tpktt(nullptr), tpkpp(nullptr), + tpcrr(nullptr), tpctt(nullptr), tpcpp(nullptr) +{ + + if (lmp->citeme) + lmp->citeme->add(cite_compute_pressure_sphere); + if (narg != 8) + error->all(FLERR,"Illegal compute pressure/spherical command. Illegal number of arguments."); + + x0 = utils::numeric(FLERR, arg[3], false, lmp); + y0 = utils::numeric(FLERR, arg[4], false, lmp); + z0 = utils::numeric(FLERR, arg[5], false, lmp); + bin_width = utils::numeric(FLERR, arg[6], false, lmp); + Rmax = utils::numeric(FLERR, arg[7], false, lmp); + nbins = (int)(Rmax/bin_width)+1; + + if (bin_width <= 0.0) + error->all(FLERR,"Illegal compute pressure/spherical command. Bin width must be > 0"); + + array_flag = 1; + vector_flag = 0; + extarray = 0; + size_array_cols = 8; // r, dens, pkrr, pktt, pkpp, pcrr, pctt, pcpp + size_array_rows = nbins; + + memory->create(invV, nbins, "compute/pressure/spherical:invV"); + memory->create(dens, nbins, "compute/pressure/spherical:dens"); + memory->create(pkrr, nbins, "compute/pressure/spherical:pkrr"); + memory->create(pktt, nbins, "compute/pressure/spherical:pktt"); + memory->create(pkpp, nbins, "compute/pressure/spherical:pkpp"); + memory->create(pcrr, nbins, "compute/pressure/spherical:pcrr"); + memory->create(pctt, nbins, "compute/pressure/spherical:pctt"); + memory->create(pcpp, nbins, "compute/pressure/spherical:pcpp"); + memory->create(tdens, nbins, "compute/pressure/spherical:tdens"); + memory->create(tpkrr, nbins, "compute/pressure/spherical:tpkrr"); + memory->create(tpktt, nbins, "compute/pressure/spherical:tpktt"); + memory->create(tpkpp, nbins, "compute/pressure/spherical:tpkpp"); + memory->create(tpcrr, nbins, "compute/pressure/spherical:tpcrr"); + memory->create(tpctt, nbins, "compute/pressure/spherical:tpctt"); + memory->create(tpcpp, nbins, "compute/pressure/spherical:tpcpp"); + memory->create(array, size_array_rows, size_array_cols, "compute/pressure/spherical:array"); +} + +/* ---------------------------------------------------------------------- */ + +ComputePressureSpherical::~ComputePressureSpherical() +{ + memory->destroy(invV); + memory->destroy(dens); + memory->destroy(pkrr); + memory->destroy(pktt); + memory->destroy(pkpp); + memory->destroy(pcrr); + memory->destroy(pctt); + memory->destroy(pcpp); + memory->destroy(tdens); + memory->destroy(tpkrr); + memory->destroy(tpktt); + memory->destroy(tpkpp); + memory->destroy(tpcrr); + memory->destroy(tpctt); + memory->destroy(tpcpp); + memory->destroy(array); +} + +/* ---------------------------------------------------------------------- */ + +void ComputePressureSpherical::init() +{ + if (force->pair == nullptr) + error->all(FLERR,"No pair style is defined for compute pressure/spherical"); + if (force->pair->single_enable == 0) + error->all(FLERR,"Pair style does not support compute pressure/spherical"); + + for (int bin = 0; bin < nbins; bin++) + invV[bin] = 3.0 / (4.0*MY_PI*(pow((bin+1)*bin_width, 3.0) - pow(bin*bin_width, 3.0))); + + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->pair = 0; + neighbor->requests[irequest]->compute = 1; + neighbor->requests[irequest]->occasional = 1; +} + +/* ---------------------------------------------------------------------- */ + +void ComputePressureSpherical::init_list(int /* id */, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + + +/* ---------------------------------------------------------------------- + count pairs and compute pair info on this proc + only count pair once if newton_pair is off + both atom I,J must be in group + if flag is set, compute requested info about pair +------------------------------------------------------------------------- */ + +void ComputePressureSpherical::compute_array() +{ + invoked_array = update->ntimestep; + + + int me; + MPI_Comm_rank(world, &me); + int bin; + // Zero arrays + for (int bin = 0; bin < nbins; bin++) { + tdens[bin] = 0.0; + tpkrr[bin] = 0.0; + tpktt[bin] = 0.0; + tpkpp[bin] = 0.0; + tpcrr[bin] = 0.0; + tpctt[bin] = 0.0; + tpcpp[bin] = 0.0; + } + + int i, j, ii, jj, inum, jnum, itype, jtype; + tagint itag, jtag; + double ri[3], xtmp, ytmp, ztmp, tmp; + double rsq, fpair, factor_coul, factor_lj; + int *ilist, *jlist, *numneigh, **firstneigh; + + double r, vr, vt, vp, theta; + double **x = atom->x; + double **v = atom->v; + double *mass = atom->mass; + tagint *tag = atom->tag; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; + + // invoke half neighbor list (will copy or build if necessary) + neighbor->build_one(list); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // calculate number density and kinetic contribution to pressure + for (i = 0; i < nlocal; i++){ + ri[0] = x[i][0]-x0; + ri[1] = x[i][1]-y0; + ri[2] = x[i][2]-z0; + for (j = 0; j < 3; j++){ + tmp = domain->boxhi[j]-domain->boxlo[j]; + if (ri[j] > 0.5*tmp) + ri[j] -= tmp; + else if (ri[j] < -0.5*tmp) + ri[j] += tmp; + } + r = sqrt(ri[0]*ri[0]+ri[1]*ri[1]+ri[2]*ri[2]); + if (r >= Rmax) continue; + bin = (int)(r/bin_width); + + // Avoiding division by zero + if (r != 0){ + theta = acos(ri[2]/r); + tdens[bin] += 1.0; + vr = (ri[0]*v[i][0]+ri[1]*v[i][1]+ri[2]*v[i][2]) / r; + vt = r*sin(theta)/(pow(ri[1]/ri[0], 2.0) + 1.0)*((ri[0]*v[i][1] - ri[1]*v[i][0])/(ri[0]*ri[0])); + vp = (ri[2]*vr - r*v[i][2])/(r*sqrt(1.0 - pow(ri[2]/r, 2.0))); + tpkrr[bin] += vr*vr; + tpktt[bin] += vt*vt; + tpkpp[bin] += vp*vp; + } + } + + // loop over neighbors of my atoms + // skip if I or J are not in group + // for newton = 0 and J = ghost atom, + // need to insure I,J pair is only output by one proc + // use same itag,jtag logic as in Neighbor::neigh_half_nsq() + // for flag = 0, just count pair interactions within force cutoff + // for flag = 1, calculate requested output fields + + Pair *pair = force->pair; + double **cutsq = force->pair->cutsq; + + double risq, rjsq; + double dir1i, dir2i, dir3i, dir1j, dir2j, dir3j; + double xi, yi, zi, xj, yj, zj; + + double qi[3], l1, l2, l3, l4, R1, R2, Fa, Fb, l_sum; + double rij, f, ririj, sqr, la, lb, sql0, lambda0; + double SMALL = 10e-12; + double rsqxy, ririjxy, sqrixy, sqlxy0, A, B, C; + int end_bin; + + for (ii = 0; ii < inum; ii++){ + i = ilist[ii]; + if (!(mask[i] & groupbit)) continue; + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itag = tag[i]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + factor_coul = special_coul[sbmask(j)]; + j &= NEIGHMASK; + if (!(mask[j] & groupbit)) continue; + + // itag = jtag is possible for long cutoffs that include images of self + // do calculation only on appropriate processor + if (newton_pair == 0 && j >= nlocal) { + jtag = tag[j]; + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + } + } + + ri[0] = x[j][0]-xtmp; + ri[1] = x[j][1]-ytmp; + ri[2] = x[j][2]-ztmp; + + rsq = ri[0]*ri[0]+ri[1]*ri[1]+ri[2]*ri[2]; + jtype = type[j]; + + // Check if inside cut-off + if (rsq >= cutsq[itype][jtype]) continue; + + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); + qi[0] = xtmp-x0; + qi[1] = ytmp-y0; + qi[2] = ztmp-z0; + for (int k = 0; k < 3; k++){ + tmp = domain->boxhi[k]-domain->boxlo[k]; + if (qi[k] > 0.5*tmp) + qi[k] -= tmp; + else if (qi[k] < -0.5*tmp) + qi[k] += tmp; + } + l_sum = 0.0; + rij = sqrt(rsq); + f = -rij*fpair; + ririj = qi[0]*ri[0] + qi[1]*ri[1] + qi[2]*ri[2]; + sqr = qi[0]*qi[0] + qi[1]*qi[1] + qi[2]*qi[2]; + la = 0.0; + lb = 0.0; + sql0 = sqr - ririj*ririj/rsq; + lambda0 = -ririj/rsq; + rsqxy = ri[0]*ri[0]+ri[1]*ri[1]; + ririjxy = qi[0]*ri[0]+qi[1]*ri[1]; + sqrixy = qi[0]*qi[0]+qi[1]*qi[1]; + sqlxy0 = sqrixy - ririjxy*ririjxy / rsqxy; + A = pow(qi[0]*ri[1] - qi[1]*ri[0], 2.0); + C = sqrt(rsqxy*sqrixy - ririjxy*ririjxy); + B = sqrt(rsq*sqr - ririj*ririj); + end_bin = (int)(sqrt(rsq+2.0*ririj+sqr)/bin_width); + + while (lb < 1.0) { + l1 = lb+SMALL; + bin = (int)floor(sqrt(rsq*l1*l1+2.0*ririj*l1+sqr)/bin_width); + R1 = (bin)*bin_width; + R2 = (bin+1)*bin_width; + + l1 = lambda0 + sqrt((R1*R1 - sql0)/rsq); + l2 = lambda0 - sqrt((R1*R1 - sql0)/rsq); + l3 = lambda0 + sqrt((R2*R2 - sql0)/rsq); + l4 = lambda0 - sqrt((R2*R2 - sql0)/rsq); + + if (l4 >= 0.0 && l4 <= 1.0 && l4 > la) + lb = l4; + else if (l3 >= 0.0 && l3 <= 1.0 && l3 > la) + lb = l3; + else if (l2 >= 0.0 && l2 <= 1.0 && l2 > la) + lb = l2; + else if (l1 >= 0.0 && l1 <= 1.0 && l1 > la) + lb = l1; + else + lb = 1.0; + + if (bin == end_bin) + lb = 1.0; + if (la > lb) + error->all(FLERR,"Error: la > lb\n"); + if (bin >= 0 && bin < nbins){ + if (sql0 > SMALL){ + Fa = -B*atan2(rsq*la+ririj, B); + Fb = -B*atan2(rsq*lb+ririj, B); + tpcrr[bin] -= (f/rij)*( rsq*(lb - la) + Fb - Fa ); + tpcpp[bin] -= (f/rij)*( Fa - Fb )/2.0; + } + else + tpcrr[bin] -= f*rij*(lb-la); + + if (sqlxy0 > SMALL){ + tpctt[bin] -= (f/rij)*A/C*(atan2(rsqxy*lb + ririjxy, C) - atan2(rsqxy*la + ririjxy, C)); + } + } + l_sum += lb-la; + la = lb; + } + + // Error check + if (fabs(l_sum - 1.0) > SMALL) + error->all(FLERR,"ERROR: The sum of the fractional line segments, calculated in spherical pressure tensor, does not sum up to 1."); + } + } + + // normalize pressure + for (bin = 0; bin < nbins; bin++) { + tdens[bin] *= invV[bin]; + tpkrr[bin] *= invV[bin]; + tpktt[bin] *= invV[bin]; + tpkpp[bin] *= invV[bin]; + tpcrr[bin] *= invV[bin]; + tpctt[bin] *= invV[bin]; + tpcpp[bin] *= invV[bin]; + } + // communicate across processors + MPI_Allreduce(tdens, dens, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkrr, pkrr, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpktt, pktt, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkpp, pkpp, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpcrr, pcrr, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpctt, pctt, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpcpp, pcpp, nbins, MPI_DOUBLE, MPI_SUM, world); + + // populate array to output. + for (bin = 0; bin < nbins; bin++) { + array[bin][0] = (bin+0.5)*bin_width; + array[bin][1] = dens[bin]; + array[bin][2] = pkrr[bin]; + array[bin][3] = pktt[bin]; + array[bin][4] = pkpp[bin]; + array[bin][5] = pcrr[bin]; + array[bin][6] = pctt[bin]; + array[bin][7] = pcpp[bin]; + } +} + +double ComputePressureSpherical::memory_usage() +{ + return 15.0*(double)(nbins+size_array_rows*size_array_cols)*sizeof(double); +} diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_pressure_spherical.h new file mode 100644 index 0000000000..918f87e653 --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 COMPUTE_CLASS + +ComputeStyle(pressure/spherical,ComputePressureSpherical) + +#else + +#ifndef LMP_COMPUTE_PRESSURE_SPHERICAL +#define LMP_COMPUTE_PRESSURE_SPHERICAL + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputePressureSpherical : public Compute { + public: + ComputePressureSpherical(class LAMMPS *, int, char **); + ~ComputePressureSpherical(); + void init(); + void init_list(int, class NeighList *); + void compute_array(); + double memory_usage(); + + private: + int nbins; + double bin_width, x0, y0, z0, Rmax; + + // Number density, kinetic and configurational contribution to the pressure. + double *invV, *dens, *pkrr, *pktt, *pkpp, *pcrr, *pctt, *pcpp; + double *tdens, *tpkrr, *tpktt, *tpkpp, *tpcrr, *tpctt, *tpcpp; + class NeighList *list; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: No pair style is defined for compute pressure/cartesian + +Self-explanatory. + +E: Pair style does not support compute pressure/cartesian + +The pair style does not have a single() function, so it can +not be invoked by compute pressure/cartesian. + +*/ + From df9a772020ba93b461503cc840cf5578fbdd8561 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 4 Mar 2022 08:36:27 -0700 Subject: [PATCH 30/72] More EVFLAG cleanup --- src/KOKKOS/pair_reaxff_kokkos.cpp | 96 ++++++++++++++----------------- src/KOKKOS/pair_reaxff_kokkos.h | 34 ++++++----- 2 files changed, 59 insertions(+), 71 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index a941bf2101..9d4616cb6f 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -908,14 +908,14 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) // Bond energy if (neighflag == HALF) { - if (evflag) + if (eflag_either) Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); ev_all += ev; pvector[0] = ev.evdwl; } else { //if (neighflag == HALFTHREAD) { - if (evflag) + if (eflag_either) Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); @@ -925,15 +925,15 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) // Multi-body corrections if (neighflag == HALF) { - Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); - if (evflag) + Kokkos::parallel_for(Kokkos::RangePolicy(0,inum),*this); + if (eflag_either) Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); ev_all += ev; } else { //if (neighflag == HALFTHREAD) { - Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); - if (evflag) + Kokkos::parallel_for(Kokkos::RangePolicy(0,inum),*this); + if (eflag_either) Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,inum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy>(0,inum),*this); @@ -1046,7 +1046,7 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) // Kokkos::Experimental::contribute(d_Cdbopi2, dup_Cdbopi2); // needed in ComputeBond2 //} - if (evflag) + if (vflag_either) Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,ignum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); @@ -1062,7 +1062,7 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) // Kokkos::Experimental::contribute(d_Cdbopi2, dup_Cdbopi2); // needed in ComputeBond2 //} - if (evflag) + if (vflag_either) Kokkos::parallel_reduce(Kokkos::RangePolicy>(0,ignum),*this,ev); else Kokkos::parallel_for(Kokkos::RangePolicy>(0,ignum),*this); @@ -1078,6 +1078,7 @@ void PairReaxFFKokkos::compute(int eflag_in, int vflag_in) eng_vdwl += ev_all.evdwl; eng_coul += ev_all.ecoul; } + if (vflag_global) { virial[0] += ev_all.v[0]; virial[1] += ev_all.v[1]; @@ -1152,7 +1153,7 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::operator()(TagPairReaxComputePolar, const int &ii) const { EV_FLOAT_REAX ev; this->template operator()(TagPairReaxComputePolar(), ii, ev); - } +} /* ---------------------------------------------------------------------- */ @@ -2395,9 +2396,8 @@ void PairReaxFFKokkos::operator()(TagPairReaxBondOrder3, const int & /* ---------------------------------------------------------------------- */ template -template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti1, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti1, const int &ii) const { const int i = d_ilist[ii]; const int itype = type(i); @@ -2429,9 +2429,9 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti1 -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2, const int &ii, EV_FLOAT_REAX& ev) const { auto v_CdDelta = ScatterViewHelper,decltype(dup_CdDelta),decltype(ndup_CdDelta)>::get(dup_CdDelta,ndup_CdDelta); auto a_CdDelta = v_CdDelta.template access>(); @@ -2473,7 +2473,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2 0 || enobondsflag) a_CdDelta[i] += CElp; - if (EVFLAG && eflag_global) ev.ereax[0] += e_lp; + if (EFLAG && eflag_global) ev.ereax[0] += e_lp; //if (vflag_either || eflag_atom) this->template ev_tally(ev,i,i,e_lp,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,i,e_lp); @@ -2489,7 +2489,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2template ev_tally(ev,i,i,e_ov,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,i,e_ov); @@ -2510,7 +2510,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2 0 || enobondsflag) e_un = -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; - if (EVFLAG && eflag_global) ev.ereax[2] += e_un; + if (EFLAG && eflag_global) ev.ereax[2] += e_un; //if (eflag_atom) this->template ev_tally(ev,i,i,e_un,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,i,e_un); @@ -2553,7 +2553,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2template e_tally(ev,i,j,e_lph); } @@ -2572,11 +2572,11 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2 -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeMulti2, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(TagPairReaxComputeMulti2(), ii, ev); + this->template operator()(TagPairReaxComputeMulti2(), ii, ev); } /* ---------------------------------------------------------------------- */ @@ -3614,11 +3614,9 @@ void PairReaxFFKokkos::operator()(TagPairReaxUpdateBond, /* ---------------------------------------------------------------------- */ template -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1, const int &ii, EV_FLOAT_REAX& ev) const { - - auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); +void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1, const int &ii, EV_FLOAT_REAX& ev) const { auto v_CdDelta = ScatterViewHelper,decltype(dup_CdDelta),decltype(ndup_CdDelta)>::get(dup_CdDelta,ndup_CdDelta); auto a_CdDelta = v_CdDelta.template access>(); @@ -3676,7 +3674,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1template ev_tally(ev,i,j,ebond,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,j,ebond); @@ -3698,7 +3696,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1template ev_tally(ev,i,j,estriph,0.0,0.0,0.0,0.0); //if (eflag_atom) this->template e_tally(ev,i,j,estriph); @@ -3721,19 +3719,19 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1 -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeBond1, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(TagPairReaxComputeBond1(), ii, ev); + this->template operator()(TagPairReaxComputeBond1(), ii, ev); } /* ---------------------------------------------------------------------- */ template -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2, const int &ii, EV_FLOAT_REAX& ev) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2, const int &ii, EV_FLOAT_REAX& ev) const { auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -3835,7 +3833,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2template v_tally(ev,i,temp,delij); + if (VFLAG && vflag_either) this->template v_tally(ev,i,temp,delij); fitmp[0] -= temp[0]; fitmp[1] -= temp[1]; @@ -3857,7 +3855,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2template v_tally(ev,j,temp,tmpvec); } @@ -3878,7 +3876,7 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2::operator()(TagPairReaxComputeBond2template v_tally(ev,k,temp,tmpvec); @@ -3915,11 +3913,11 @@ void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2 -template +template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2, const int &ii) const { +void PairReaxFFKokkos::operator()(TagPairReaxComputeBond2, const int &ii) const { EV_FLOAT_REAX ev; - this->template operator()(TagPairReaxComputeBond2(), ii, ev); + this->template operator()(TagPairReaxComputeBond2(), ii, ev); } /* ---------------------------------------------------------------------- */ @@ -3931,8 +3929,6 @@ void PairReaxFFKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, con const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - const int VFLAG = vflag_either; - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); @@ -3947,7 +3943,7 @@ void PairReaxFFKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, con a_eatom[j] += epairhalf; } - if (VFLAG) { + if (vflag_either) { const E_FLOAT v0 = delx*delx*fpair; const E_FLOAT v1 = dely*dely*fpair; const E_FLOAT v2 = delz*delz*fpair; @@ -3989,18 +3985,14 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::e_tally(EV_FLOAT_REAX & /*ev*/, const int &i, const int &j, const F_FLOAT &epair) const { - // The eatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); + auto a_eatom = v_eatom.template access>(); - if (eflag_atom) { - auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); - auto a_eatom = v_eatom.template access>(); - - const E_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; - } + const E_FLOAT epairhalf = 0.5 * epair; + a_eatom[i] += epairhalf; + a_eatom[j] += epairhalf; } /* ---------------------------------------------------------------------- */ @@ -4012,6 +4004,7 @@ void PairReaxFFKokkos::e_tally_single(EV_FLOAT_REAX & /*ev*/, const const F_FLOAT &epair) const { // The eatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -4026,7 +4019,6 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::v_tally(EV_FLOAT_REAX &ev, const int &i, F_FLOAT *fi, F_FLOAT *drij) const { - F_FLOAT v[6]; v[0] = 0.5*drij[0]*fi[0]; @@ -4062,7 +4054,6 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::v_tally3(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); @@ -4103,7 +4094,6 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::v_tally4(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, const int &l, F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *dril, F_FLOAT *drjl, F_FLOAT *drkl) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial F_FLOAT v[6]; diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index af4c4cc11d..782704b0ca 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -79,16 +79,15 @@ struct TagPairReaxBondOrder3{}; template struct TagPairReaxUpdateBond{}; -template +template struct TagPairReaxComputeBond1{}; -template +template struct TagPairReaxComputeBond2{}; -template struct TagPairReaxComputeMulti1{}; -template +template struct TagPairReaxComputeMulti2{}; template @@ -196,33 +195,32 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxUpdateBond, const int&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeBond1, const int&, EV_FLOAT_REAX&) const; + void operator()(TagPairReaxComputeBond1, const int&, EV_FLOAT_REAX&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeBond1, const int&) const; + void operator()(TagPairReaxComputeBond1, const int&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeBond2, const int&, EV_FLOAT_REAX&) const; + void operator()(TagPairReaxComputeBond2, const int&, EV_FLOAT_REAX&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeBond2, const int&) const; + void operator()(TagPairReaxComputeBond2, const int&) const; - template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeMulti1, const int&) const; + void operator()(TagPairReaxComputeMulti1, const int&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeMulti2, const int&, EV_FLOAT_REAX&) const; + void operator()(TagPairReaxComputeMulti2, const int&, EV_FLOAT_REAX&) const; - template + template KOKKOS_INLINE_FUNCTION - void operator()(TagPairReaxComputeMulti2, const int&) const; + void operator()(TagPairReaxComputeMulti2, const int&) const; template KOKKOS_INLINE_FUNCTION From 939171094b37f97e9f716d505cd20d46df06c83a Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 4 Mar 2022 08:40:22 -0700 Subject: [PATCH 31/72] Whitespace --- src/KOKKOS/pair_reaxff_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 9d4616cb6f..e2d3c38273 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4004,7 +4004,7 @@ void PairReaxFFKokkos::e_tally_single(EV_FLOAT_REAX & /*ev*/, const const F_FLOAT &epair) const { // The eatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial - // + auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); From a396ed2b36eb990723eaa44571df26926dc472fb Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:45:31 +0100 Subject: [PATCH 32/72] Fixed LAMMPS homepage --- src/EXTRA-COMPUTE/compute_pressure_cartesian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h index 63f5d1fa48..a458d0b53f 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract From 2687228f09f004e513e79901a6b1dcebc6cfeb1f Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:47:16 +0100 Subject: [PATCH 33/72] =?UTF-8?q?Fixed=20LAMMPS=20homepage=20and=20changed?= =?UTF-8?q?=20=C3=B8=20to=20{\o}=20it=20reference?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EXTRA-COMPUTE/compute_pressure_spherical.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index b99966623b..d29e89f63a 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -36,7 +36,7 @@ static const char cite_compute_pressure_sphere[] = "compute pressure/spherical:\n\n" "@article{ikeshoji2003molecular,\n" "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bjørn and Furuholt, Hilde},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bj{\o}rn and Furuholt, Hilde},\n" "journal={Molecular Simulation},\n" "volume={29},\n" "number={2},\n" From 47de1234c06f8129770f73cfb7fd8a3b91118b59 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:49:03 +0100 Subject: [PATCH 34/72] =?UTF-8?q?LAMMPS=20homepage=20and=20=C3=B8->{\o}=20?= =?UTF-8?q?in=20reference?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index 586bc463f8..eeb4e6353b 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -35,7 +35,7 @@ static const char cite_compute_pressure_cartesian[] = "compute pressure/cartesian:\n\n" "@article{ikeshoji2003molecular,\n" "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bjørn and Furuholt, Hilde},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bj{\o}rn and Furuholt, Hilde},\n" "journal={Molecular Simulation},\n" "volume={29},\n" "number={2},\n" From 9f0607876a5b5a57ca4b1860f4ba8059dee9f2a3 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:49:42 +0100 Subject: [PATCH 35/72] LAMMPS Homepage --- src/EXTRA-COMPUTE/compute_pressure_spherical.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_pressure_spherical.h index 918f87e653..ce3ec8836c 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.h +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract From a7112f173a58a4b8579cbcdeaf8277dcc32dc905 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:56:39 +0100 Subject: [PATCH 36/72] Trailing whitespace --- doc/src/compute_pressure_cartesian.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_pressure_cartesian.rst index 7a6f0be652..797f658a77 100644 --- a/doc/src/compute_pressure_cartesian.rst +++ b/doc/src/compute_pressure_cartesian.rst @@ -8,13 +8,13 @@ Syntax .. parsed-literal:: - compute ID group-ID pressure/cartesian dim bin_width + compute ID group-ID pressure/cartesian dim bin_width * ID, group-ID are documented in :doc:`compute ` command * pressure/cartesian = style name of this compute command * one or two dim/bin_width pairs may be appended * dim = x, y, or z -* bin_width = width of the bin +* bin_width = width of the bin Examples """""""" From 6d48ba1577134ae0fd6d7905d70ee4f2ed49355c Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:57:59 +0100 Subject: [PATCH 37/72] Trailing whitespace --- src/EXTRA-COMPUTE/compute_pressure_cartesian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h index a458d0b53f..1f4ae7d61c 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h @@ -36,7 +36,7 @@ class ComputePressureCart : public Compute { private: int nbins1, nbins2, dir1, dir2, dims; double bin_width1, bin_width2, invV; - + // Number density, kinetic and configurational contribution to the pressure. double *dens, *pkxx, *pkyy, *pkzz, *pcxx, *pcyy, *pczz; double *tdens, *tpkxx, *tpkyy, *tpkzz, *tpcxx, *tpcyy, *tpczz; From 98d2dca83f5dd0bf2a6239729afab680bf026f47 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 16:58:31 +0100 Subject: [PATCH 38/72] Trailing whitespace --- src/EXTRA-COMPUTE/compute_pressure_spherical.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_pressure_spherical.h index ce3ec8836c..a6fc633e37 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.h +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.h @@ -36,7 +36,7 @@ class ComputePressureSpherical : public Compute { private: int nbins; double bin_width, x0, y0, z0, Rmax; - + // Number density, kinetic and configurational contribution to the pressure. double *invV, *dens, *pkrr, *pktt, *pkpp, *pcrr, *pctt, *pcpp; double *tdens, *tpkrr, *tpktt, *tpkpp, *tpcrr, *tpctt, *tpcpp; From 06e9c096acd17f81e80edf200d051189cd5abb77 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 4 Mar 2022 09:13:43 -0700 Subject: [PATCH 39/72] Remove unused code --- src/KOKKOS/pair_reaxff_kokkos.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index e2d3c38273..876654e628 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -1663,10 +1663,6 @@ void PairReaxFFKokkos::operator()(TagPairReaxBuildListsHalfBlocking< delij[2] = x(j,2) - ztmp; const F_FLOAT rsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; - double cutoffsq; - if (i < nlocal) cutoffsq = MAX(cut_bosq,cut_hbsq); - else cutoffsq = cut_bosq; - // hbond list if (i < nlocal && cut_hbsq > 0.0 && (ihb == 1 || ihb == 2) && rsq <= cut_hbsq) { jhb = paramssing(jtype).p_hbond; From cdeaa83f6db4f2b8f40c323c7c8a49de2b3cf2e2 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 4 Mar 2022 12:34:51 -0700 Subject: [PATCH 40/72] Make it easier to enable tabulation in ReaxFF --- src/REAXFF/pair_reaxff.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 39b6221d3d..3ed197cf1e 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -263,6 +263,10 @@ void PairReaxFF::settings(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); list_blocking_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; + } else if (strcmp(arg[iarg],"tabulate") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + api->control->tabulate = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + iarg += 2; } else error->all(FLERR,"Illegal pair_style reaxff command"); } } From 23580d8ca533a68511160416d40584849fbea183 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 20:54:33 +0100 Subject: [PATCH 41/72] Integrated pressure/cartesian and pressure/spherical --- doc/src/Commands_compute.rst | 2 ++ doc/src/compute.rst | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 91910ccdaa..d3cd9a367a 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -100,7 +100,9 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`pe/tally ` * :doc:`plasticity/atom ` * :doc:`pressure ` + * :doc:`pressure/cartesian ` * :doc:`pressure/cylinder ` + * :doc:`pressure/spherical ` * :doc:`pressure/uef ` * :doc:`property/atom ` * :doc:`property/chunk ` diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 9edd7e8474..f3f22ce422 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -246,7 +246,9 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`pe/tally ` - potential energy between two groups of atoms via the tally callback mechanism * :doc:`plasticity/atom ` - Peridynamic plasticity for each atom * :doc:`pressure ` - total pressure and pressure tensor +* :doc:`pressure/cartesian ` - pressure tensor in cartesian coordinates * :doc:`pressure/cylinder ` - pressure tensor in cylindrical coordinates +* :doc:`pressure/spherical ` - pressure tensor in spherical coordinates * :doc:`pressure/uef ` - pressure tensor in the reference frame of an applied flow field * :doc:`property/atom ` - convert atom attributes to per-atom vectors/arrays * :doc:`property/chunk ` - extract various per-chunk attributes From 1e530dbd19c100b805552a24ad63873d256ed20c Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 20:55:29 +0100 Subject: [PATCH 42/72] Changed ref name to avoid duplicate --- doc/src/compute_pressure_spherical.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/compute_pressure_spherical.rst b/doc/src/compute_pressure_spherical.rst index 2e772f057f..578153583b 100644 --- a/doc/src/compute_pressure_spherical.rst +++ b/doc/src/compute_pressure_spherical.rst @@ -26,7 +26,7 @@ Examples Description """"""""""" -This computes the diagonal components of the spherical pressure tensor in spherical shells, as described in :ref:`(Ikeshoji)`. This can be used to calculate the local pressure tensor components of for example droplets and bubbles. This compute obeys momentum balance. This compute uses the Irving-Kirkwood contour, whici is the straight line between particle pairs. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the pressure :math:`P = P^k+P^v`. +This computes the diagonal components of the spherical pressure tensor in spherical shells, as described in :ref:`(Ikeshoji)`. This can be used to calculate the local pressure tensor components of for example droplets and bubbles. This compute obeys momentum balance. This compute uses the Irving-Kirkwood contour, whici is the straight line between particle pairs. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the pressure :math:`P = P^k+P^v`. Output info """"""""""" @@ -57,5 +57,5 @@ none ---------- -.. _Ikeshoji2: +.. _Ikeshoji3: **(Ikeshoji)** Ikeshoji, Hafskjold, Furuholt, Mol Sim, 29, 101-109, (2003). From 401180699d58fadecd02651b4570cd6056f1bbd8 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 4 Mar 2022 13:10:25 -0700 Subject: [PATCH 43/72] Update docs --- doc/src/pair_reaxff.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/src/pair_reaxff.rst b/doc/src/pair_reaxff.rst index d0c333af4b..4640307105 100644 --- a/doc/src/pair_reaxff.rst +++ b/doc/src/pair_reaxff.rst @@ -19,13 +19,14 @@ Syntax .. parsed-literal:: - keyword = *checkqeq* or *lgvdw* or *safezone* or *mincap* or *minhbonds* or *list/blocking* + keyword = *checkqeq* or *lgvdw* or *safezone* or *mincap* or *minhbonds* or *tabulate* or *list/blocking* *checkqeq* value = *yes* or *no* = whether or not to require qeq/reaxff or acks2/reaxff fix *enobonds* value = *yes* or *no* = whether or not to tally energy of atoms with no bonds *lgvdw* value = *yes* or *no* = whether or not to use a low gradient vdW correction *safezone* = factor used for array allocation *mincap* = minimum size for array allocation *minhbonds* = minimum size use for storing hydrogen bonds + *tabulate* value = size of interpolation table for Lennard-Jones and Coulomb interactions *list/blocking* value = *yes* or *no* = whether or not to use "blocking" scheme for bond list build Examples @@ -159,6 +160,13 @@ the Kokkos version, which instead uses a more robust memory allocation scheme that checks if the sizes of the arrays have been exceeded and automatically allocates more memory. +The keyword *tabulate* controls the size of interpolation table for +Lennard-Jones and Coulomb interactions. Tabulation may also be set in the +control file (see below). If tabulation is set in both the input script and the +control file, the value in the control file will be ignored. A size of 10000 is +typically used for the interpolation table. A value of 0 means no tabulation +will be used. + The keyword *list/blocking* is only supported by the Kokkos version of ReaxFF and ignored otherwise. Setting the value to *yes* enables the "blocking" scheme (dynamically building interaction lists) for the @@ -369,8 +377,9 @@ Related commands Default """"""" -The keyword defaults are checkqeq = yes, enobonds = yes, lgvdw = no, -safezone = 1.2, mincap = 50, minhbonds = 25, list/blocking = yes on CPU, no on GPU. +The keyword defaults are checkqeq = yes, enobonds = yes, lgvdw = no, safezone = +1.2, mincap = 50, minhbonds = 25, tabulate = 0, list/blocking = yes on CPU, no +on GPU. ---------- From 577eac201b19f0c2172713afc3179b3da7d4cc30 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Mar 2022 16:03:50 -0500 Subject: [PATCH 44/72] add sanity check --- src/REAXFF/pair_reaxff.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 3ed197cf1e..bd2c1e2428 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -266,6 +266,8 @@ void PairReaxFF::settings(int narg, char **arg) } else if (strcmp(arg[iarg],"tabulate") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); api->control->tabulate = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (api->system->tabulate < 0) + error->all(FLERR,"Illegal pair_style reaxff tabulate command"); iarg += 2; } else error->all(FLERR,"Illegal pair_style reaxff command"); } From 5c8f506edff9719d9cbcf0adee1675a9d6dfcc02 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Mar 2022 16:04:04 -0500 Subject: [PATCH 45/72] add unit test input --- .../atomic-pair-reaxff_tabulate_flag.yaml | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 unittest/force-styles/tests/atomic-pair-reaxff_tabulate_flag.yaml diff --git a/unittest/force-styles/tests/atomic-pair-reaxff_tabulate_flag.yaml b/unittest/force-styles/tests/atomic-pair-reaxff_tabulate_flag.yaml new file mode 100644 index 0000000000..cc75136ead --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-reaxff_tabulate_flag.yaml @@ -0,0 +1,178 @@ +--- +lammps_version: 17 Feb 2022 +tags: slow, unstable, noWindows +date_generated: Fri Mar 4 16:03:19 2022 +epsilon: 1e-10 +skip_tests: +prerequisites: ! | + pair reaxff + fix qeq/reaxff +pre_commands: ! | + echo screen + shell cp ${input_dir}/reaxff.control reaxff-1.control + variable newton_pair delete + variable newton_pair index on + atom_modify map array + units real + atom_style charge + lattice diamond 3.77 + region box block 0 2 0 2 0 2 + create_box 3 box + create_atoms 1 box + displace_atoms all random 0.1 0.1 0.1 623426 + mass 1 1.0 + mass 2 12.0 + mass 3 16.0 + set type 1 type/fraction 2 0.5 998877 + set type 2 type/fraction 3 0.5 887766 + set type 1 charge 0.00 + set type 2 charge 0.01 + set type 3 charge -0.01 + velocity all create 100 4534624 loop geom +post_commands: ! | + fix qeq all qeq/reaxff 1 0.0 8.0 1.0e-20 reaxff +input_file: in.empty +pair_style: reaxff NULL checkqeq yes tabulate 10000 +pair_coeff: ! | + * * ffield.reax.mattsson H C O +extract: ! "" +natoms: 64 +init_vdwl: -3296.3503506626625 +init_coul: -327.06551252279456 +init_stress: ! |- + -1.0522112314767783e+03 -1.2629480788300502e+03 -8.6765541430814096e+02 -2.5149818635818667e+02 2.0624598409312171e+02 -6.4309968343212176e+02 +init_forces: ! |2 + 1 -8.8484559491556311e+01 -2.5824737864573919e+01 1.0916228789487879e+02 + 2 -1.1227736122977259e+02 -1.8092349731667591e+02 -2.2420586526897358e+02 + 3 -1.7210817575848930e+02 1.8292439782307812e+02 1.3552618819707996e+01 + 4 3.2997500231077133e+01 -5.1076027616179566e+01 9.0475628837081729e+01 + 5 1.8144778146276320e+02 1.6797701000584901e+01 -8.1725507301130719e+01 + 6 1.3634094180728027e+02 -3.0056789473999606e+02 2.9661495129812735e+01 + 7 -5.3287158661290654e+01 -1.2872927610193426e+02 -1.6347871108898190e+02 + 8 -1.5334883257588743e+02 4.0171483324132673e+01 1.5317461163040247e+02 + 9 1.8364155867626707e+01 8.1986572088184730e+01 2.8272397798085997e+01 + 10 8.4246730110716001e+01 1.4177487113457059e+02 1.2330079878579895e+02 + 11 -4.3218423112503736e+01 6.5551082199269430e+01 1.3464882148701872e+02 + 12 -9.7317470492946029e+01 -2.6234999414165394e+01 7.2277941881737986e+00 + 13 -6.3183329836750751e+01 -4.7368101002963456e+01 -3.7592654029327335e+01 + 14 7.8642975316494343e+01 -6.7997612991911723e+01 -9.9044775614588801e+01 + 15 -6.6373732796047989e+01 2.1787558547533163e+02 8.0103149369097395e+01 + 16 1.9216166082224797e+02 5.3228015320736127e+01 6.6260214054225145e+01 + 17 1.4496007689503486e+02 -3.9700923044581373e+01 -9.7503851828125278e+01 + 18 -4.4989550233791114e+01 -1.9360605894359682e+02 1.1274792197022767e+02 + 19 2.6657528138946049e+02 3.7189510796653087e+02 -3.3847307488286714e+02 + 20 -7.6341040242475458e+01 -8.8478925962195476e+01 1.3557778211945350e+00 + 21 -7.1188591900927975e+01 -5.1591439985149563e+01 -1.2279442803768845e+02 + 22 1.5504836733040739e+02 -1.3094504458747133e+02 8.1474408030773787e+01 + 23 7.8015302036850315e+01 -1.3272310040531950e+01 -2.2771427736555761e+01 + 24 -2.0546718065740683e+02 2.1611071031056338e+02 -1.2423208053538573e+02 + 25 -1.1402686646199389e+02 1.9100238121127509e+02 -8.3504908417575109e+01 + 26 2.8663576552100710e+02 -2.1773884754172596e+02 2.3144300100085047e+02 + 27 -6.3247409025600724e+01 6.9122196748088982e+01 1.8606936744368682e+02 + 28 -3.5426011056021354e+00 3.8764809029448436e+01 3.2874001946771685e+01 + 29 -7.1069178571898220e+01 3.5485903180456084e+01 2.7311648896337775e+01 + 30 -1.7036987830119276e+02 -1.9851827590032582e+02 -1.1511401829122866e+02 + 31 -1.3970409889743564e+02 1.6660943915627308e+02 -1.2913930522474990e+02 + 32 2.7179130444097289e+01 -6.0169059447608035e+01 -1.7669495182016857e+02 + 33 -6.2659679124097778e+01 -6.4422131921802787e+01 6.4150928205326551e+01 + 34 -2.2119065265688906e+01 1.0450386886831188e+02 -7.3998379587547575e+01 + 35 2.6982987783289082e+02 -2.1519317040004481e+02 1.3051628460667428e+02 + 36 1.0368628874510237e+02 1.8817377639771817e+02 -1.9748944223862600e+02 + 37 -1.8009522406830379e+02 1.2993653092252060e+02 -6.3523043394127292e+01 + 38 -2.9571205878459318e+02 1.0441609933480134e+02 1.5582204859043426e+02 + 39 8.7398805727037910e+01 -6.0025559644662437e+01 2.2209742009840294e+01 + 40 2.0540672579010501e+01 -1.0735874009092470e+02 5.8655918369889896e+01 + 41 -5.8895846271433264e+01 1.1852345624580526e+01 -6.6147257724520202e+01 + 42 -9.6895512314625066e+01 3.8928741136637001e+01 -7.5791929957169600e+01 + 43 2.2476051812062838e+02 9.5505204283227684e+01 1.2309042240718360e+02 + 44 8.9817373579481654e+01 -1.0616333580629222e+02 -8.6321519086261901e+01 + 45 1.7202629662563513e+01 1.2890307246702790e+02 5.2916171301120244e+01 + 46 1.3547783972599857e+01 -2.9276223331262678e+01 2.2187412696868783e+01 + 47 3.3389762514713034e+01 -1.9217585014964843e+02 -6.9956213241084782e+01 + 48 7.3631720332058023e+01 -2.0953007324684350e+02 -2.3183566221369460e+01 + 49 -3.7589944473226200e+02 -2.4083165714761812e+01 1.0770339502610176e+02 + 50 3.8603083564804351e+01 -7.3616481568807856e+01 9.0414065019653634e+01 + 51 1.3736420686697048e+02 -1.0204157331499390e+02 1.5813725581140869e+02 + 52 -1.0797257051088970e+02 1.1876975735152035e+02 -1.3295758126487456e+02 + 53 -5.3807540206216466e+01 3.3259462625846481e+02 -3.8426832264377708e-03 + 54 -1.0690184616179764e+01 6.2820270853641873e+01 1.8343158343322312e+02 + 55 1.1231900459987538e+02 -1.7906654831317351e+02 7.6533681064342247e+01 + 56 -4.1027190034880718e+01 -1.4085413191126113e+02 3.7483064289929565e+01 + 57 9.9904315214043478e+01 7.0938939080466696e+01 -6.8654961257655216e+01 + 58 -2.7563642882025157e+01 -6.7445498717118166e+00 -1.8442640542825114e+01 + 59 -6.6628933617811725e+01 1.0613066354106411e+02 8.7736153919801964e+01 + 60 -1.7748415247445266e+01 6.3757605316885879e+01 -1.5086907478327478e+02 + 61 -3.3560907195794982e+01 -1.0076987083174131e+02 -7.4536106106935335e+01 + 62 1.5883428926665676e+01 -5.8433760297919051e+00 2.8392494016028817e+01 + 63 1.3294494001299771e+02 -1.2724568063769999e+02 -6.4886848316829841e+01 + 64 1.0738157273931067e+02 1.2062173788161793e+02 7.4541400611720690e+01 +run_vdwl: -3296.3468823779367 +run_coul: -327.065399507389 +run_stress: ! |- + -1.0521225462933094e+03 -1.2628780139897610e+03 -8.6757617693170891e+02 -2.5158592653599595e+02 2.0619472152439258e+02 -6.4312943979319141e+02 +run_forces: ! |2 + 1 -8.8486129396000166e+01 -2.5824483374468670e+01 1.0916517213634302e+02 + 2 -1.1227648453174439e+02 -1.8093214754186079e+02 -2.2420118533941442e+02 + 3 -1.7210894875994904e+02 1.8292263268450841e+02 1.3551979435674342e+01 + 4 3.2999405001001634e+01 -5.1077312719540167e+01 9.0478579144055772e+01 + 5 1.8144963583124775e+02 1.6798391906829387e+01 -8.1723378082079023e+01 + 6 1.3640835897739180e+02 -3.0059507544861378e+02 2.9594750460791829e+01 + 7 -5.3287619129788197e+01 -1.2872953167027578e+02 -1.6348317368624896e+02 + 8 -1.5334990952322417e+02 4.0171746946782790e+01 1.5317542403105386e+02 + 9 1.8362961213920698e+01 8.1984428717781981e+01 2.8273598253031487e+01 + 10 8.4245458094792369e+01 1.4177227430519417e+02 1.2329899933660860e+02 + 11 -4.3217035356327358e+01 6.5547850976490437e+01 1.3463983671941662e+02 + 12 -9.7319343004584653e+01 -2.6236499899243690e+01 7.2232061905837615e+00 + 13 -6.3184735475527191e+01 -4.7368090836529937e+01 -3.7590268076048019e+01 + 14 7.8642680121812262e+01 -6.7994653297660548e+01 -9.9042134233426268e+01 + 15 -6.6371195967091907e+01 2.1787700653340673e+02 8.0102624694811539e+01 + 16 1.9215832443893075e+02 5.3231888618096207e+01 6.6253846562708489e+01 + 17 1.4496126989603599e+02 -3.9700366098755531e+01 -9.7506725874205443e+01 + 18 -4.4989211400009481e+01 -1.9360716191976402e+02 1.1274798810456159e+02 + 19 2.6657546213783030e+02 3.7189369483259844e+02 -3.3847202166066995e+02 + 20 -7.6352829159886937e+01 -8.8469178952293859e+01 1.3384778816960481e+00 + 21 -7.1188597560669123e+01 -5.1592404200753641e+01 -1.2279357314243131e+02 + 22 1.5504965184742042e+02 -1.3094582932681607e+02 8.1473922626951364e+01 + 23 7.8017376001381663e+01 -1.3263023728618043e+01 -2.2771654676285653e+01 + 24 -2.0547634460481828e+02 2.1612342044351524e+02 -1.2423651650061259e+02 + 25 -1.1402944116092229e+02 1.9100648219390607e+02 -8.3505645569840254e+01 + 26 2.8664542299412386e+02 -2.1774609219882657e+02 2.3144720166991996e+02 + 27 -6.3243843868032563e+01 6.9123801262967206e+01 1.8607035157681565e+02 + 28 -3.5444604842081140e+00 3.8760531647711296e+01 3.2869123667284754e+01 + 29 -7.1069494158200598e+01 3.5486459158788925e+01 2.7311657876198531e+01 + 30 -1.7037059987991734e+02 -1.9851840131670701e+02 -1.1511410156294959e+02 + 31 -1.3970663440086241e+02 1.6660841802304265e+02 -1.2914070628113083e+02 + 32 2.7179939937123105e+01 -6.0162678551463884e+01 -1.7668459764112279e+02 + 33 -6.2659124615696278e+01 -6.4421915847949109e+01 6.4151176691093482e+01 + 34 -2.2118740875414915e+01 1.0450303589341836e+02 -7.3997370482692659e+01 + 35 2.6987081482971496e+02 -2.1523754104001341e+02 1.3052736086177524e+02 + 36 1.0368798521809144e+02 1.8816694370717582e+02 -1.9748485159165222e+02 + 37 -1.8012152563997313e+02 1.2997662140310993e+02 -6.3547259053662522e+01 + 38 -2.9571525697590329e+02 1.0441941743732623e+02 1.5582112543443273e+02 + 39 8.7399620724583841e+01 -6.0025787992404162e+01 2.2209357601285014e+01 + 40 2.0541458171950477e+01 -1.0735817059033120e+02 5.8656280350522032e+01 + 41 -5.8893965304960815e+01 1.1850504754255629e+01 -6.6138932258972176e+01 + 42 -9.6894702780974512e+01 3.8926449644122947e+01 -7.5794133002818526e+01 + 43 2.2475651760389809e+02 9.5503072846826768e+01 1.2308683766845004e+02 + 44 8.9821846939836348e+01 -1.0615882525758133e+02 -8.6326896770196470e+01 + 45 1.7193681344320954e+01 1.2889564928825573e+02 5.2922372841304153e+01 + 46 1.3549091739277978e+01 -2.9276447091759906e+01 2.2187152043657633e+01 + 47 3.3389460345593953e+01 -1.9217121673024195e+02 -6.9954603582949176e+01 + 48 7.3644268618797824e+01 -2.0953201921818757e+02 -2.3192562071377562e+01 + 49 -3.7593958318939679e+02 -2.4028439106858276e+01 1.0779151134440338e+02 + 50 3.8603926624309238e+01 -7.3615255297997734e+01 9.0412505212301156e+01 + 51 1.3736689552205240e+02 -1.0204490780180460e+02 1.5814099219642884e+02 + 52 -1.0797151154268900e+02 1.1876989597627048e+02 -1.3296150756378307e+02 + 53 -5.3843453069379677e+01 3.3257024143948763e+02 -2.3416395286659508e-02 + 54 -1.0678049522660388e+01 6.2807424617051886e+01 1.8344969045861680e+02 + 55 1.1232135576105590e+02 -1.7906994470562014e+02 7.6534265234549295e+01 + 56 -4.1035945990490148e+01 -1.4084577238057466e+02 3.7489705598222940e+01 + 57 9.9903872061949016e+01 7.0936213558029195e+01 -6.8656338416446374e+01 + 58 -2.7563844572722473e+01 -6.7426705471903592e+00 -1.8442803060446948e+01 + 59 -6.6637290503326199e+01 1.0613630918456350e+02 8.7741455199743768e+01 + 60 -1.7749706497443679e+01 6.3756413885649771e+01 -1.5086911682893657e+02 + 61 -3.3559889608753309e+01 -1.0076809277084797e+02 -7.4536003122045500e+01 + 62 1.5883833834736830e+01 -5.8439916924713566e+00 2.8393403991140676e+01 + 63 1.3294237052897739e+02 -1.2724619636182949e+02 -6.4882384014241481e+01 + 64 1.0738250214939015e+02 1.2062290362869132e+02 7.4541927445538889e+01 +... From f8089bd0077fa3e4438462252e4e3fdf20f842f5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Mar 2022 16:08:14 -0500 Subject: [PATCH 46/72] fix cut-n-paste error --- src/REAXFF/pair_reaxff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index bd2c1e2428..991b6f0a30 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -266,7 +266,7 @@ void PairReaxFF::settings(int narg, char **arg) } else if (strcmp(arg[iarg],"tabulate") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); api->control->tabulate = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (api->system->tabulate < 0) + if (api->control->tabulate < 0) error->all(FLERR,"Illegal pair_style reaxff tabulate command"); iarg += 2; } else error->all(FLERR,"Illegal pair_style reaxff command"); From c9563d08146cc4e27e38c04a4c4b8169113d4312 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Fri, 4 Mar 2022 22:30:25 +0100 Subject: [PATCH 47/72] Fixed style changes --- .../compute_pressure_cartesian.cpp | 532 +++++++++--------- .../compute_pressure_cartesian.h | 23 +- .../compute_pressure_spherical.cpp | 354 ++++++------ .../compute_pressure_spherical.h | 17 +- 4 files changed, 463 insertions(+), 463 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index 586bc463f8..1762018c0b 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -12,124 +12,142 @@ ------------------------------------------------------------------------- */ #include "compute_pressure_cartesian.h" -#include -#include -#include + #include "atom.h" -#include "force.h" -#include "pair.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_request.h" -#include "neigh_list.h" -#include "memory.h" -#include "error.h" #include "citeme.h" #include "domain.h" +#include "error.h" +#include "force.h" #include "math_const.h" +#include "memory.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" + +#include +#include +#include using namespace LAMMPS_NS; using namespace MathConst; +/*----------------------------------------------------------------------------------- + Contributing author: Olav Galteland (Norwegian University of Science and Technology) + olav.galteland@ntnu.no +------------------------------------------------------------------------------------*/ + static const char cite_compute_pressure_cartesian[] = - "compute pressure/cartesian:\n\n" - "@article{ikeshoji2003molecular,\n" - "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bjørn and Furuholt, Hilde},\n" - "journal={Molecular Simulation},\n" - "volume={29},\n" - "number={2},\n" - "pages={101--109},\n" - "year={2003},\n" - "publisher={Taylor & Francis}\n" - "}\n\n"; + "compute pressure/cartesian:\n\n" + "@article{ikeshoji2003molecular,\n" + "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and " + "spherical layers},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" + "journal={Molecular Simulation},\n" + "volume={29},\n" + "number={2},\n" + "pages={101--109},\n" + "year={2003},\n" + "publisher={Taylor & Francis}\n" + "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ -ComputePressureCart::ComputePressureCart(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - dens(NULL), - pkxx(NULL), pkyy(NULL), pkzz(NULL), - pcxx(NULL), pcyy(NULL), pczz(NULL), - tdens(NULL), - tpkxx(NULL), tpkyy(NULL), tpkzz(NULL), - tpcxx(NULL), tpcyy(NULL), tpczz(NULL) +ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), dens(NULL), pkxx(NULL), pkyy(NULL), pkzz(NULL), pcxx(NULL), pcyy(NULL), + pczz(NULL), tdens(NULL), tpkxx(NULL), tpkyy(NULL), tpkzz(NULL), tpcxx(NULL), tpcyy(NULL), + tpczz(NULL) { - - if (lmp->citeme) - lmp->citeme->add(cite_compute_pressure_cartesian); - + + if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_cartesian); + // narg == 5 for one-dimensional and narg == 7 for two-dimensional - if (narg == 5) dims = 1; - else if (narg == 7) dims = 2; - else error->all(FLERR,"Illegal compute pressure/cartesian command. Illegal number of arguments."); + if (narg == 5) + dims = 1; + else if (narg == 7) + dims = 2; + else + error->all(FLERR, "Illegal compute pressure/cartesian command. Illegal number of arguments."); - if (strcmp(arg[3], "x") == 0) dir1 = 0; - else if (strcmp(arg[3], "y") == 0) dir1 = 1; - else if (strcmp(arg[3], "z") == 0) dir1 = 2; - else error->all(FLERR,"Illegal compute pressure/cartesian command."); + if (strcmp(arg[3], "x") == 0) + dir1 = 0; + else if (strcmp(arg[3], "y") == 0) + dir1 = 1; + else if (strcmp(arg[3], "z") == 0) + dir1 = 2; + else + error->all(FLERR, "Illegal compute pressure/cartesian command."); - dir2 = 0; - bin_width1 = utils::numeric(FLERR, arg[4], false, lmp); - bin_width2 = 0.0; - nbins1 = (int)((domain->boxhi[dir1]-domain->boxlo[dir1])/bin_width1); - nbins2 = 1; - invV = bin_width1; + dir2 = 0; + bin_width1 = utils::numeric(FLERR, arg[4], false, lmp); + bin_width2 = 0.0; + nbins1 = (int) ((domain->boxhi[dir1] - domain->boxlo[dir1]) / bin_width1); + nbins2 = 1; + invV = bin_width1; if (bin_width1 <= 0.0) - error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be > 0"); - else if (bin_width1 > domain->boxhi[dir1]-domain->boxlo[dir1]) - error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); - - if (dims == 2){ - if (strcmp(arg[5], "x") == 0) dir2 = 0; - else if (strcmp(arg[5], "y") == 0) dir2 = 1; - else if (strcmp(arg[5], "z") == 0) dir2 = 2; - else error->all(FLERR,"Illegal compute pressure/cartesian command."); + error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); + else if (bin_width1 > domain->boxhi[dir1] - domain->boxlo[dir1]) + error->all( + FLERR, + "Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); + + if (dims == 2) { + if (strcmp(arg[5], "x") == 0) + dir2 = 0; + else if (strcmp(arg[5], "y") == 0) + dir2 = 1; + else if (strcmp(arg[5], "z") == 0) + dir2 = 2; + else + error->all(FLERR, "Illegal compute pressure/cartesian command."); + + bin_width2 = utils::numeric(FLERR, arg[6], false, lmp); + nbins2 = (int) ((domain->boxhi[dir2] - domain->boxlo[dir2]) / bin_width2); + invV *= bin_width2; - bin_width2 = utils::numeric(FLERR, arg[6], false, lmp); - nbins2 = (int)((domain->boxhi[dir2]-domain->boxlo[dir2])/bin_width2); - invV *= bin_width2; - if (bin_width2 <= 0.0) - error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be > 0"); - else if (bin_width2 > domain->boxhi[dir2]-domain->boxlo[dir2]) - error->all(FLERR,"Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); + error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); + else if (bin_width2 > domain->boxhi[dir2] - domain->boxlo[dir2]) + error->all( + FLERR, + "Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); } for (int i = 0; i < 3; i++) if ((dims == 1 && i != dir1) || (dims == 2 && (i != dir1 && i != dir2))) invV *= domain->boxhi[i] - domain->boxlo[i]; - invV = 1.0/invV; + invV = 1.0 / invV; - array_flag = 1; - vector_flag = 0; - extarray = 0; - size_array_cols = 7+dims; // dir1, dir2, number density, pkxx, pkyy, pkzz, pcxx, pcyy, pczz - size_array_rows = nbins1*nbins2; - - memory->create(dens, nbins1*nbins2, "dens" ); - memory->create(pkxx, nbins1*nbins2, "pkxx" ); - memory->create(pkyy, nbins1*nbins2, "pkyy" ); - memory->create(pkzz, nbins1*nbins2, "pkzz" ); - memory->create(pcxx, nbins1*nbins2, "pcxx" ); - memory->create(pcyy, nbins1*nbins2, "pcyy" ); - memory->create(pczz, nbins1*nbins2, "pczz" ); - memory->create(tdens, nbins1*nbins2, "tdens"); - memory->create(tpkxx, nbins1*nbins2, "tpkxx"); - memory->create(tpkyy, nbins1*nbins2, "tpkyy"); - memory->create(tpkzz, nbins1*nbins2, "tpkzz"); - memory->create(tpcxx, nbins1*nbins2, "tpcxx"); - memory->create(tpcyy, nbins1*nbins2, "tpcyy"); - memory->create(tpczz, nbins1*nbins2, "tpczz"); + array_flag = 1; + vector_flag = 0; + extarray = 0; + size_array_cols = 7 + dims; // dir1, dir2, number density, pkxx, pkyy, pkzz, pcxx, pcyy, pczz + size_array_rows = nbins1 * nbins2; + + memory->create(dens, nbins1 * nbins2, "dens"); + memory->create(pkxx, nbins1 * nbins2, "pkxx"); + memory->create(pkyy, nbins1 * nbins2, "pkyy"); + memory->create(pkzz, nbins1 * nbins2, "pkzz"); + memory->create(pcxx, nbins1 * nbins2, "pcxx"); + memory->create(pcyy, nbins1 * nbins2, "pcyy"); + memory->create(pczz, nbins1 * nbins2, "pczz"); + memory->create(tdens, nbins1 * nbins2, "tdens"); + memory->create(tpkxx, nbins1 * nbins2, "tpkxx"); + memory->create(tpkyy, nbins1 * nbins2, "tpkyy"); + memory->create(tpkzz, nbins1 * nbins2, "tpkzz"); + memory->create(tpcxx, nbins1 * nbins2, "tpcxx"); + memory->create(tpcyy, nbins1 * nbins2, "tpcyy"); + memory->create(tpczz, nbins1 * nbins2, "tpczz"); memory->create(array, size_array_rows, size_array_cols, "pressure:cartesian:output"); } /* ---------------------------------------------------------------------- */ -ComputePressureCart::~ComputePressureCart() -{ +ComputePressureCartesian::~ComputePressureCartesian() +{ memory->destroy(dens); memory->destroy(pkxx); memory->destroy(pkyy); @@ -149,12 +167,12 @@ ComputePressureCart::~ComputePressureCart() /* ---------------------------------------------------------------------- */ -void ComputePressureCart::init() +void ComputePressureCartesian::init() { if (force->pair == NULL) - error->all(FLERR,"No pair style is defined for compute pressure/cartesian"); + error->all(FLERR, "No pair style is defined for compute pressure/cartesian"); if (force->pair->single_enable == 0) - error->all(FLERR,"Pair style does not support compute pressure/cartesian"); + error->all(FLERR, "Pair style does not support compute pressure/cartesian"); // need an occasional half neighbor list. int irequest = neighbor->request(this, instance_me); @@ -165,14 +183,13 @@ void ComputePressureCart::init() /* ---------------------------------------------------------------------- */ -void ComputePressureCart::init_list(int /* id */, NeighList *ptr) +void ComputePressureCartesian::init_list(int /* id */, NeighList *ptr) { list = ptr; } /* ---------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- count pairs and compute pair info on this proc only count pair once if newton_pair is off @@ -180,7 +197,7 @@ void ComputePressureCart::init_list(int /* id */, NeighList *ptr) if flag is set, compute requested info about pair ------------------------------------------------------------------------- */ -void ComputePressureCart::compute_array() +void ComputePressureCartesian::compute_array() { //invoked_array = update->ntimestep; int me; @@ -193,27 +210,27 @@ void ComputePressureCart::compute_array() double rsq, fpair, factor_coul, factor_lj; int *ilist, *jlist, *numneigh, **firstneigh; - double **x = atom->x; - double **v = atom->v; - double *mass = atom->mass; - tagint *tag = atom->tag; - int *type = atom->type; - int *mask = atom->mask; - int nlocal = atom->nlocal; - double *special_coul = force->special_coul; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; + double **x = atom->x; + double **v = atom->v; + double *mass = atom->mass; + tagint *tag = atom->tag; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; // invoke half neighbor list (will copy or build if necessary) neighbor->build_one(list); - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + // Zero arrays - for (bin = 0; bin < nbins1*nbins2; bin++) { + for (bin = 0; bin < nbins1 * nbins2; bin++) { tdens[bin] = 0; tpkxx[bin] = 0; tpkyy[bin] = 0; @@ -224,18 +241,17 @@ void ComputePressureCart::compute_array() } // calculate number density and kinetic contribution to pressure - for (i = 0; i < nlocal; i++){ - bin1 = (int)(x[i][dir1]/bin_width1)%nbins1; + for (i = 0; i < nlocal; i++) { + bin1 = (int) (x[i][dir1] / bin_width1) % nbins1; bin2 = 0; - if (dims == 2) - bin2 = (int)(x[i][dir2]/bin_width2)%nbins2; - - j = bin1+bin2*nbins1; + if (dims == 2) bin2 = (int) (x[i][dir2] / bin_width2) % nbins2; + + j = bin1 + bin2 * nbins1; tdens[j] += 1; // TODO: Subtract streaming velocity - tpkxx[j] += mass[type[i]]*v[i][0]*v[i][0]; - tpkyy[j] += mass[type[i]]*v[i][1]*v[i][1]; - tpkzz[j] += mass[type[i]]*v[i][2]*v[i][2]; + tpkxx[j] += mass[type[i]] * v[i][0] * v[i][0]; + tpkyy[j] += mass[type[i]] * v[i][1] * v[i][1]; + tpkzz[j] += mass[type[i]] * v[i][2] * v[i][2]; } // loop over neighbors of my atoms @@ -246,13 +262,13 @@ void ComputePressureCart::compute_array() // for flag = 0, just count pair interactions within force cutoff // for flag = 1, calculate requested output fields - Pair *pair = force->pair; - double **cutsq = force->pair->cutsq; + Pair *pair = force->pair; + double **cutsq = force->pair->cutsq; double risq, rjsq; double xi1, xi2, xj1, xj2; - - for (ii = 0; ii < inum; ii++){ + + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (!(mask[i] & groupbit)) continue; @@ -278,9 +294,9 @@ void ComputePressureCart::compute_array() if (newton_pair == 0 && j >= nlocal) { jtag = tag[j]; if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; + if ((itag + jtag) % 2 == 0) continue; } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; + if ((itag + jtag) % 2 == 1) continue; } else { if (x[j][2] < ztmp) continue; if (x[j][2] == ztmp) { @@ -291,26 +307,24 @@ void ComputePressureCart::compute_array() } xj1 = x[j][dir1]; xj2 = x[j][dir2]; - - delx = x[j][0]-xtmp; - dely = x[j][1]-ytmp; - delz = x[j][2]-ztmp; - - rsq = delx*delx + dely*dely + delz*delz; + + delx = x[j][0] - xtmp; + dely = x[j][1] - ytmp; + delz = x[j][2] - ztmp; + + rsq = delx * delx + dely * dely + delz * delz; jtype = type[j]; - - // Check if inside cut-off + + // Check if inside cut-off if (rsq >= cutsq[itype][jtype]) continue; pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); - if (dims == 1) - compute_pressure_1d(fpair, xi1, xj1, delx, dely, delz); - if (dims == 2) - compute_pressure_2d(fpair, xi1, xi2, xj1, xj2, delx, dely, delz); + if (dims == 1) compute_pressure_1d(fpair, xi1, xj1, delx, dely, delz); + if (dims == 2) compute_pressure_2d(fpair, xi1, xi2, xj1, xj2, delx, dely, delz); } } // normalize pressure - for (bin = 0; bin < nbins1*nbins2; bin++) { + for (bin = 0; bin < nbins1 * nbins2; bin++) { tdens[bin] *= invV; tpkxx[bin] *= invV; tpkyy[bin] *= invV; @@ -319,139 +333,130 @@ void ComputePressureCart::compute_array() tpcyy[bin] *= invV; tpczz[bin] *= invV; } - + // communicate across processors - MPI_Allreduce(tdens, dens, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - MPI_Allreduce(tpkxx, pkxx, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - MPI_Allreduce(tpkyy, pkyy, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - MPI_Allreduce(tpkzz, pkzz, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - MPI_Allreduce(tpcxx, pcxx, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - MPI_Allreduce(tpcyy, pcyy, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - MPI_Allreduce(tpczz, pczz, nbins1*nbins2, MPI_DOUBLE, MPI_SUM, world); - + MPI_Allreduce(tdens, dens, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkxx, pkxx, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkyy, pkyy, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpkzz, pkzz, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpcxx, pcxx, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpcyy, pcyy, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(tpczz, pczz, nbins1 * nbins2, MPI_DOUBLE, MPI_SUM, world); + // populate array to output. - for (bin = 0; bin < nbins1*nbins2; bin++) { - array[bin][0] = (bin%nbins1+0.5)*bin_width1; - if (dims == 2) - array[bin][1] = ((int)(bin/nbins1)+0.5)*bin_width2; - array[bin][0+dims] = dens[bin]; - array[bin][1+dims] = pkxx[bin]; - array[bin][2+dims] = pkyy[bin]; - array[bin][3+dims] = pkzz[bin]; - array[bin][4+dims] = pcxx[bin]; - array[bin][5+dims] = pcyy[bin]; - array[bin][6+dims] = pczz[bin]; + for (bin = 0; bin < nbins1 * nbins2; bin++) { + array[bin][0] = (bin % nbins1 + 0.5) * bin_width1; + if (dims == 2) array[bin][1] = ((int) (bin / nbins1) + 0.5) * bin_width2; + array[bin][0 + dims] = dens[bin]; + array[bin][1 + dims] = pkxx[bin]; + array[bin][2 + dims] = pkyy[bin]; + array[bin][3 + dims] = pkzz[bin]; + array[bin][4 + dims] = pcxx[bin]; + array[bin][5 + dims] = pcyy[bin]; + array[bin][6 + dims] = pczz[bin]; } } - -void ComputePressureCart::compute_pressure_1d(double fpair, double xi, double xj, double delx, double dely, double delz) +void ComputePressureCartesian::compute_pressure_1d(double fpair, double xi, double xj, double delx, + double dely, double delz) { int bin_s, bin_e, bin_step, bin, bin_limit; double xa, xb, l_sum; - + if (xi < domain->boxlo[dir1]) - xi += (domain->boxhi[dir1]-domain->boxlo[dir1]); + xi += (domain->boxhi[dir1] - domain->boxlo[dir1]); else if (xi > domain->boxhi[dir1]) - xi -= (domain->boxhi[dir1]-domain->boxlo[dir1]); + xi -= (domain->boxhi[dir1] - domain->boxlo[dir1]); if (xj < domain->boxlo[dir1]) - xj += (domain->boxhi[dir1]-domain->boxlo[dir1]); + xj += (domain->boxhi[dir1] - domain->boxlo[dir1]); else if (xj > domain->boxhi[dir1]) - xj -= (domain->boxhi[dir1]-domain->boxlo[dir1]); + xj -= (domain->boxhi[dir1] - domain->boxlo[dir1]); // Integrating contour from bin_s to bin_e - bin_s = lround((int)((xi - domain->boxlo[dir1])/bin_width1)%nbins1); - bin_e = lround((int)((xj - domain->boxlo[dir1])/bin_width1)%nbins1); - + bin_s = (int) lround(((xi - domain->boxlo[dir1]) / bin_width1)) % nbins1; + bin_e = (int) lround(((xj - domain->boxlo[dir1]) / bin_width1)) % nbins1; + // If not periodic in dir1 - if (domain->periodicity[dir1] == 0){ - bin_s = lround((int)((xi - domain->boxlo[dir1])/bin_width1)); - bin_e = lround((int)((xj - domain->boxlo[dir1])/bin_width1)); - - if (bin_e == nbins1) - bin_e--; - if (bin_s == nbins1) - bin_s--; + if (domain->periodicity[dir1] == 0) { + bin_s = (int) lround(((xi - domain->boxlo[dir1]) / bin_width1)); + bin_e = (int) lround(((xj - domain->boxlo[dir1]) / bin_width1)); + + if (bin_e == nbins1) bin_e--; + if (bin_s == nbins1) bin_s--; } bin_step = 1; - if (domain->periodicity[dir1] == 1){ - if (bin_e - bin_s > 0.5*nbins1) + if (domain->periodicity[dir1] == 1) { + if (bin_e - bin_s > 0.5 * nbins1) bin_step = -1; - else if (bin_s - bin_e > 0.5*nbins1) + else if (bin_s - bin_e > 0.5 * nbins1) bin_step = 1; else if (bin_s > bin_e) bin_step = -1; - } - else { - if (bin_s > bin_e) - bin_step = -1; + } else { + if (bin_s > bin_e) bin_step = -1; } if (domain->periodicity[dir1] == 1) - bin_limit = (bin_e+bin_step)%nbins1 < 0 ? (bin_e+bin_step)%nbins1+nbins1 : (bin_e+bin_step)%nbins1; + bin_limit = (bin_e + bin_step) % nbins1 < 0 ? (bin_e + bin_step) % nbins1 + nbins1 + : (bin_e + bin_step) % nbins1; else - bin_limit = bin_e+bin_step; - + bin_limit = bin_e + bin_step; + bin = bin_s; // Integrate from bin_s to bin_e with step bin_step. - while (bin != bin_limit){ - + while (bin != bin_limit) { + // Calculating exit and entry point (xa, xb). Checking if inside current bin. - if (bin == bin_s){ + if (bin == bin_s) { if (domain->periodicity[dir1] == 1) - xa = fmod(xi, domain->boxhi[dir1])+domain->boxlo[dir1]; + xa = fmod(xi, domain->boxhi[dir1]) + domain->boxlo[dir1]; else xa = xi; - } - else - xa = (bin_step == 1) ? bin*bin_width1 : (bin+1)*bin_width1; - if (bin == bin_e){ + } else + xa = (bin_step == 1) ? bin * bin_width1 : (bin + 1) * bin_width1; + if (bin == bin_e) { if (domain->periodicity[dir1] == 1) - xb = fmod(xj, domain->boxhi[dir1])+domain->boxlo[dir1]; + xb = fmod(xj, domain->boxhi[dir1]) + domain->boxlo[dir1]; else xb = xj; - } - else - xb = (bin_step == 1) ? (bin+1)*bin_width1 : bin*bin_width1; - - if (bin < 0 || bin >= nbins1) - error->all(FLERR,"ERROR: Bin outside simulation."); + } else + xb = (bin_step == 1) ? (bin + 1) * bin_width1 : bin * bin_width1; + if (bin < 0 || bin >= nbins1) error->all(FLERR, "ERROR: Bin outside simulation."); - if (bin_s != bin_e){ - if (dir1 == 0){ - tpcxx[bin] += (fpair*delx*delx) * (xb - xa)/delx; - tpcyy[bin] += (fpair*dely*dely) * (xb - xa)/delx; - tpczz[bin] += (fpair*delz*delz) * (xb - xa)/delx; - } - else if (dir1 == 1){ - tpcxx[bin] += (fpair*delx*delx) * (xb - xa)/dely; - tpcyy[bin] += (fpair*dely*dely) * (xb - xa)/dely; - tpczz[bin] += (fpair*delz*delz) * (xb - xa)/dely; - } - else if (dir1 == 2){ - tpcxx[bin] += (fpair*delx*delx) * (xb - xa)/delz; - tpcyy[bin] += (fpair*dely*dely) * (xb - xa)/delz; - tpczz[bin] += (fpair*delz*delz) * (xb - xa)/delz; + if (bin_s != bin_e) { + if (dir1 == 0) { + tpcxx[bin] += (fpair * delx * delx) * (xb - xa) / delx; + tpcyy[bin] += (fpair * dely * dely) * (xb - xa) / delx; + tpczz[bin] += (fpair * delz * delz) * (xb - xa) / delx; + } else if (dir1 == 1) { + tpcxx[bin] += (fpair * delx * delx) * (xb - xa) / dely; + tpcyy[bin] += (fpair * dely * dely) * (xb - xa) / dely; + tpczz[bin] += (fpair * delz * delz) * (xb - xa) / dely; + } else if (dir1 == 2) { + tpcxx[bin] += (fpair * delx * delx) * (xb - xa) / delz; + tpcyy[bin] += (fpair * dely * dely) * (xb - xa) / delz; + tpczz[bin] += (fpair * delz * delz) * (xb - xa) / delz; } } // Particle i and j in same bin. Avoiding zero divided by zero. else { - tpcxx[bin] += fpair*delx*delx; - tpcyy[bin] += fpair*dely*dely; - tpczz[bin] += fpair*delz*delz; + tpcxx[bin] += fpair * delx * delx; + tpcyy[bin] += fpair * dely * dely; + tpczz[bin] += fpair * delz * delz; } // Stepping bin to next bin if (domain->periodicity[dir1] == 1) - bin = (bin+bin_step)%nbins1 < 0 ? (bin+bin_step)%nbins1+nbins1 : (bin+bin_step)%nbins1; + bin = (bin + bin_step) % nbins1 < 0 ? (bin + bin_step) % nbins1 + nbins1 + : (bin + bin_step) % nbins1; else - bin = bin+bin_step; + bin = bin + bin_step; } } - -void ComputePressureCart::compute_pressure_2d(double fpair, double xi, double yi, double xj, double yj, double delx, double dely, double delz) +void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, double yi, double xj, + double yj, double delx, double dely, double delz) { int bin1, bin2, next_bin1, next_bin2; double la = 0.0, lb = 0.0, l_sum = 0.0; @@ -459,79 +464,74 @@ void ComputePressureCart::compute_pressure_2d(double fpair, double xi, double yi double l1 = 0.0, l2, rij1, rij2; double SMALL = 10e-5; rij1 = rij[dir1]; - rij2 = rij[dir2]; - - next_bin1 = (int)floor(xi/bin_width1); - next_bin2 = (int)floor(yi/bin_width2); - + rij2 = rij[dir2]; + + next_bin1 = (int) floor(xi / bin_width1); + next_bin2 = (int) floor(yi / bin_width2); + // Integrating along line - while (lb != 1.0){ + while (lb != 1.0) { bin1 = next_bin1; bin2 = next_bin2; - - if (rij1 > 0) - l1 = ((bin1+1)*bin_width1 - xi)/rij1; - else - l1 = (bin1*bin_width1 - xi)/rij1; - if (rij2 > 0) - l2 = ((bin2+1)*bin_width2 - yi)/rij2; - else - l2 = (bin2*bin_width2 - yi)/rij2; - if ((l1 < l2 || l2 < lb+SMALL) && l1 <= 1.0 && l1 > lb){ - lb = l1; - next_bin1 = bin1+(int)(rij1/fabs(rij1)); - } - else if (l2 <= 1.0 && l2 > lb){ - lb = l2; - next_bin2 = bin2+(int)(rij2/fabs(rij2)); - } + if (rij1 > 0) + l1 = ((bin1 + 1) * bin_width1 - xi) / rij1; else + l1 = (bin1 * bin_width1 - xi) / rij1; + if (rij2 > 0) + l2 = ((bin2 + 1) * bin_width2 - yi) / rij2; + else + l2 = (bin2 * bin_width2 - yi) / rij2; + + if ((l1 < l2 || l2 < lb + SMALL) && l1 <= 1.0 && l1 > lb) { + lb = l1; + next_bin1 = bin1 + (int) (rij1 / fabs(rij1)); + } else if (l2 <= 1.0 && l2 > lb) { + lb = l2; + next_bin2 = bin2 + (int) (rij2 / fabs(rij2)); + } else lb = 1.0; - + // Periodic boundary conditions - if (domain->periodicity[dir1] == 1){ + if (domain->periodicity[dir1] == 1) { if (bin1 < 0) bin1 += nbins1; else if (bin1 >= nbins1) bin1 -= nbins1; - } - else if (bin1 < 0) + } else if (bin1 < 0) bin1 = 0; else if (bin1 >= nbins1) - bin1 = nbins1-1; + bin1 = nbins1 - 1; - if (domain->periodicity[dir2] == 1){ + if (domain->periodicity[dir2] == 1) { if (bin2 < 0) bin2 += nbins2; else if (bin2 >= nbins2) bin2 -= nbins2; - } - else if (bin2 < 0) + } else if (bin2 < 0) bin2 = 0; else if (bin2 >= nbins2) - bin2 = nbins2-1; - - if (bin1+bin2*nbins1 >= nbins1*nbins2) - error->all(FLERR, "Bin outside"); + bin2 = nbins2 - 1; - tpcxx[bin1+bin2*nbins1] += (fpair*delx*delx*(lb-la)); - tpcyy[bin1+bin2*nbins1] += (fpair*dely*dely*(lb-la)); - tpczz[bin1+bin2*nbins1] += (fpair*delz*delz*(lb-la)); - - l_sum += lb-la; + if (bin1 + bin2 * nbins1 >= nbins1 * nbins2) error->all(FLERR, "Bin outside"); + + tpcxx[bin1 + bin2 * nbins1] += (fpair * delx * delx * (lb - la)); + tpcyy[bin1 + bin2 * nbins1] += (fpair * dely * dely * (lb - la)); + tpczz[bin1 + bin2 * nbins1] += (fpair * delz * delz * (lb - la)); + + l_sum += lb - la; la = lb; } - if (l_sum > 1.0+SMALL || l_sum < 1.0-SMALL) - error->all(FLERR,"Sum of fractional line segments does not equal 1."); + if (l_sum > 1.0 + SMALL || l_sum < 1.0 - SMALL) + error->all(FLERR, "Sum of fractional line segments does not equal 1."); } /* ---------------------------------------------------------------------- memory usage of data ------------------------------------------------------------------------- */ -double ComputePressureCart::memory_usage() +double ComputePressureCartesian::memory_usage() { - return (14.0+dims+7)*(double)(nbins1*nbins2)*sizeof(double); + return (14.0 + dims + 7) * (double) (nbins1 * nbins2) * sizeof(double); } diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h index 63f5d1fa48..6b58f73897 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -12,22 +12,22 @@ ------------------------------------------------------------------------- */ #ifdef COMPUTE_CLASS - -ComputeStyle(pressure/cartesian,ComputePressureCart) - +// clang-format off +ComputeStyle(pressure/cartesian,ComputePressureCartesian); +// clang-format on #else -#ifndef LMP_COMPUTE_PRESSURE_CARTESIAN -#define LMP_COMPUTE_PRESSURE_CARTESIAN +#ifndef LMP_COMPUTE_PRESSURE_CARTESIAN_H +#define LMP_COMPUTE_PRESSURE_CARTESIAN_H #include "compute.h" namespace LAMMPS_NS { -class ComputePressureCart : public Compute { +class ComputePressureCartesian : public Compute { public: - ComputePressureCart(class LAMMPS *, int, char **); - ~ComputePressureCart(); + ComputePressureCartesian(class LAMMPS *, int, char **); + ~ComputePressureCartesian(); void init(); void init_list(int, class NeighList *); void compute_array(); @@ -36,7 +36,7 @@ class ComputePressureCart : public Compute { private: int nbins1, nbins2, dir1, dir2, dims; double bin_width1, bin_width2, invV; - + // Number density, kinetic and configurational contribution to the pressure. double *dens, *pkxx, *pkyy, *pkzz, *pcxx, *pcyy, *pczz; double *tdens, *tpkxx, *tpkyy, *tpkzz, *tpcxx, *tpcyy, *tpczz; @@ -45,7 +45,7 @@ class ComputePressureCart : public Compute { void compute_pressure_2d(double, double, double, double, double, double, double, double); }; -} +} // namespace LAMMPS_NS #endif #endif @@ -68,4 +68,3 @@ The pair style does not have a single() function, so it can not be invoked by compute pressure/cartesian. */ - diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index b99966623b..188de5e3a4 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -12,81 +12,84 @@ ------------------------------------------------------------------------- */ #include "compute_pressure_spherical.h" -#include -#include -#include + #include "atom.h" -#include "update.h" -#include "force.h" -#include "pair.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_request.h" -#include "neigh_list.h" -#include "memory.h" -#include "error.h" #include "citeme.h" #include "domain.h" +#include "error.h" +#include "force.h" #include "math_const.h" +#include "memory.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include +#include +#include using namespace LAMMPS_NS; using namespace MathConst; +/*----------------------------------------------------------------------------------- + Contributing author: Olav Galteland (Norwegian University of Science and Technology) + olav.galteland@ntnu.no +------------------------------------------------------------------------------------*/ + static const char cite_compute_pressure_sphere[] = - "compute pressure/spherical:\n\n" - "@article{ikeshoji2003molecular,\n" - "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bjørn and Furuholt, Hilde},\n" - "journal={Molecular Simulation},\n" - "volume={29},\n" - "number={2},\n" - "pages={101--109},\n" - "year={2003},\n" - "publisher={Taylor & Francis}\n" - "}\n\n"; + "compute pressure/spherical:\n\n" + "@article{ikeshoji2003molecular,\n" + "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and " + "spherical layers},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" + "journal={Molecular Simulation},\n" + "volume={29},\n" + "number={2},\n" + "pages={101--109},\n" + "year={2003},\n" + "publisher={Taylor & Francis}\n" + "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - dens(nullptr), - pkrr(nullptr), pktt(nullptr), pkpp(nullptr), - pcrr(nullptr), pctt(nullptr), pcpp(nullptr), - tdens(nullptr), - tpkrr(nullptr), tpktt(nullptr), tpkpp(nullptr), - tpcrr(nullptr), tpctt(nullptr), tpcpp(nullptr) + Compute(lmp, narg, arg), dens(nullptr), pkrr(nullptr), pktt(nullptr), pkpp(nullptr), + pcrr(nullptr), pctt(nullptr), pcpp(nullptr), tdens(nullptr), tpkrr(nullptr), tpktt(nullptr), + tpkpp(nullptr), tpcrr(nullptr), tpctt(nullptr), tpcpp(nullptr) { - - if (lmp->citeme) - lmp->citeme->add(cite_compute_pressure_sphere); - if (narg != 8) - error->all(FLERR,"Illegal compute pressure/spherical command. Illegal number of arguments."); - - x0 = utils::numeric(FLERR, arg[3], false, lmp); - y0 = utils::numeric(FLERR, arg[4], false, lmp); - z0 = utils::numeric(FLERR, arg[5], false, lmp); - bin_width = utils::numeric(FLERR, arg[6], false, lmp); - Rmax = utils::numeric(FLERR, arg[7], false, lmp); - nbins = (int)(Rmax/bin_width)+1; - - if (bin_width <= 0.0) - error->all(FLERR,"Illegal compute pressure/spherical command. Bin width must be > 0"); - array_flag = 1; - vector_flag = 0; - extarray = 0; - size_array_cols = 8; // r, dens, pkrr, pktt, pkpp, pcrr, pctt, pcpp + if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_sphere); + if (narg != 8) + error->all(FLERR, "Illegal compute pressure/spherical command. Illegal number of arguments."); + + x0 = utils::numeric(FLERR, arg[3], false, lmp); + y0 = utils::numeric(FLERR, arg[4], false, lmp); + z0 = utils::numeric(FLERR, arg[5], false, lmp); + bin_width = utils::numeric(FLERR, arg[6], false, lmp); + Rmax = utils::numeric(FLERR, arg[7], false, lmp); + nbins = (int) (Rmax / bin_width) + 1; + + if (bin_width <= 0.0) + error->all(FLERR, "Illegal compute pressure/spherical command. Bin width must be > 0"); + + array_flag = 1; + vector_flag = 0; + extarray = 0; + size_array_cols = 8; // r, dens, pkrr, pktt, pkpp, pcrr, pctt, pcpp size_array_rows = nbins; - memory->create(invV, nbins, "compute/pressure/spherical:invV"); - memory->create(dens, nbins, "compute/pressure/spherical:dens"); - memory->create(pkrr, nbins, "compute/pressure/spherical:pkrr"); - memory->create(pktt, nbins, "compute/pressure/spherical:pktt"); - memory->create(pkpp, nbins, "compute/pressure/spherical:pkpp"); - memory->create(pcrr, nbins, "compute/pressure/spherical:pcrr"); - memory->create(pctt, nbins, "compute/pressure/spherical:pctt"); - memory->create(pcpp, nbins, "compute/pressure/spherical:pcpp"); + memory->create(invV, nbins, "compute/pressure/spherical:invV"); + memory->create(dens, nbins, "compute/pressure/spherical:dens"); + memory->create(pkrr, nbins, "compute/pressure/spherical:pkrr"); + memory->create(pktt, nbins, "compute/pressure/spherical:pktt"); + memory->create(pkpp, nbins, "compute/pressure/spherical:pkpp"); + memory->create(pcrr, nbins, "compute/pressure/spherical:pcrr"); + memory->create(pctt, nbins, "compute/pressure/spherical:pctt"); + memory->create(pcpp, nbins, "compute/pressure/spherical:pcpp"); memory->create(tdens, nbins, "compute/pressure/spherical:tdens"); memory->create(tpkrr, nbins, "compute/pressure/spherical:tpkrr"); memory->create(tpktt, nbins, "compute/pressure/spherical:tpktt"); @@ -94,7 +97,7 @@ ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char * memory->create(tpcrr, nbins, "compute/pressure/spherical:tpcrr"); memory->create(tpctt, nbins, "compute/pressure/spherical:tpctt"); memory->create(tpcpp, nbins, "compute/pressure/spherical:tpcpp"); - memory->create(array, size_array_rows, size_array_cols, "compute/pressure/spherical:array"); + memory->create(array, size_array_rows, size_array_cols, "compute/pressure/spherical:array"); } /* ---------------------------------------------------------------------- */ @@ -124,14 +127,14 @@ ComputePressureSpherical::~ComputePressureSpherical() void ComputePressureSpherical::init() { if (force->pair == nullptr) - error->all(FLERR,"No pair style is defined for compute pressure/spherical"); + error->all(FLERR, "No pair style is defined for compute pressure/spherical"); if (force->pair->single_enable == 0) - error->all(FLERR,"Pair style does not support compute pressure/spherical"); - - for (int bin = 0; bin < nbins; bin++) - invV[bin] = 3.0 / (4.0*MY_PI*(pow((bin+1)*bin_width, 3.0) - pow(bin*bin_width, 3.0))); + error->all(FLERR, "Pair style does not support compute pressure/spherical"); - int irequest = neighbor->request(this,instance_me); + for (int bin = 0; bin < nbins; bin++) + invV[bin] = 3.0 / (4.0 * MY_PI * (pow((bin + 1) * bin_width, 3.0) - pow(bin * bin_width, 3.0))); + + int irequest = neighbor->request(this, instance_me); neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->compute = 1; neighbor->requests[irequest]->occasional = 1; @@ -146,7 +149,6 @@ void ComputePressureSpherical::init_list(int /* id */, NeighList *ptr) /* ---------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- count pairs and compute pair info on this proc only count pair once if newton_pair is off @@ -158,10 +160,9 @@ void ComputePressureSpherical::compute_array() { invoked_array = update->ntimestep; - int me; MPI_Comm_rank(world, &me); - int bin; + int bin; // Zero arrays for (int bin = 0; bin < nbins; bin++) { tdens[bin] = 0.0; @@ -180,51 +181,52 @@ void ComputePressureSpherical::compute_array() int *ilist, *jlist, *numneigh, **firstneigh; double r, vr, vt, vp, theta; - double **x = atom->x; - double **v = atom->v; - double *mass = atom->mass; - tagint *tag = atom->tag; - int *type = atom->type; - int *mask = atom->mask; - int nlocal = atom->nlocal; - double *special_coul = force->special_coul; - double *special_lj = force->special_lj; - int newton_pair = force->newton_pair; + double **x = atom->x; + double **v = atom->v; + double *mass = atom->mass; + tagint *tag = atom->tag; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + double *special_coul = force->special_coul; + double *special_lj = force->special_lj; + int newton_pair = force->newton_pair; // invoke half neighbor list (will copy or build if necessary) neighbor->build_one(list); - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; // calculate number density and kinetic contribution to pressure - for (i = 0; i < nlocal; i++){ - ri[0] = x[i][0]-x0; - ri[1] = x[i][1]-y0; - ri[2] = x[i][2]-z0; - for (j = 0; j < 3; j++){ - tmp = domain->boxhi[j]-domain->boxlo[j]; - if (ri[j] > 0.5*tmp) + for (i = 0; i < nlocal; i++) { + ri[0] = x[i][0] - x0; + ri[1] = x[i][1] - y0; + ri[2] = x[i][2] - z0; + for (j = 0; j < 3; j++) { + tmp = domain->boxhi[j] - domain->boxlo[j]; + if (ri[j] > 0.5 * tmp) ri[j] -= tmp; - else if (ri[j] < -0.5*tmp) + else if (ri[j] < -0.5 * tmp) ri[j] += tmp; } - r = sqrt(ri[0]*ri[0]+ri[1]*ri[1]+ri[2]*ri[2]); + r = sqrt(ri[0] * ri[0] + ri[1] * ri[1] + ri[2] * ri[2]); if (r >= Rmax) continue; - bin = (int)(r/bin_width); - - // Avoiding division by zero - if (r != 0){ - theta = acos(ri[2]/r); + bin = (int) (r / bin_width); + + // Avoiding division by zero + if (r != 0) { + theta = acos(ri[2] / r); tdens[bin] += 1.0; - vr = (ri[0]*v[i][0]+ri[1]*v[i][1]+ri[2]*v[i][2]) / r; - vt = r*sin(theta)/(pow(ri[1]/ri[0], 2.0) + 1.0)*((ri[0]*v[i][1] - ri[1]*v[i][0])/(ri[0]*ri[0])); - vp = (ri[2]*vr - r*v[i][2])/(r*sqrt(1.0 - pow(ri[2]/r, 2.0))); - tpkrr[bin] += vr*vr; - tpktt[bin] += vt*vt; - tpkpp[bin] += vp*vp; + vr = (ri[0] * v[i][0] + ri[1] * v[i][1] + ri[2] * v[i][2]) / r; + vt = r * sin(theta) / (pow(ri[1] / ri[0], 2.0) + 1.0) * + ((ri[0] * v[i][1] - ri[1] * v[i][0]) / (ri[0] * ri[0])); + vp = (ri[2] * vr - r * v[i][2]) / (r * sqrt(1.0 - pow(ri[2] / r, 2.0))); + tpkrr[bin] += vr * vr; + tpktt[bin] += vt * vt; + tpkpp[bin] += vp * vp; } } @@ -236,8 +238,8 @@ void ComputePressureSpherical::compute_array() // for flag = 0, just count pair interactions within force cutoff // for flag = 1, calculate requested output fields - Pair *pair = force->pair; - double **cutsq = force->pair->cutsq; + Pair *pair = force->pair; + double **cutsq = force->pair->cutsq; double risq, rjsq; double dir1i, dir2i, dir3i, dir1j, dir2j, dir3j; @@ -249,7 +251,7 @@ void ComputePressureSpherical::compute_array() double rsqxy, ririjxy, sqrixy, sqlxy0, A, B, C; int end_bin; - for (ii = 0; ii < inum; ii++){ + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (!(mask[i] & groupbit)) continue; @@ -274,9 +276,9 @@ void ComputePressureSpherical::compute_array() if (newton_pair == 0 && j >= nlocal) { jtag = tag[j]; if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; + if ((itag + jtag) % 2 == 0) continue; } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; + if ((itag + jtag) % 2 == 1) continue; } else { if (x[j][2] < ztmp) continue; if (x[j][2] == ztmp) { @@ -285,57 +287,57 @@ void ComputePressureSpherical::compute_array() } } } - - ri[0] = x[j][0]-xtmp; - ri[1] = x[j][1]-ytmp; - ri[2] = x[j][2]-ztmp; - - rsq = ri[0]*ri[0]+ri[1]*ri[1]+ri[2]*ri[2]; + + ri[0] = x[j][0] - xtmp; + ri[1] = x[j][1] - ytmp; + ri[2] = x[j][2] - ztmp; + + rsq = ri[0] * ri[0] + ri[1] * ri[1] + ri[2] * ri[2]; jtype = type[j]; - - // Check if inside cut-off + + // Check if inside cut-off if (rsq >= cutsq[itype][jtype]) continue; - + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); - qi[0] = xtmp-x0; - qi[1] = ytmp-y0; - qi[2] = ztmp-z0; - for (int k = 0; k < 3; k++){ - tmp = domain->boxhi[k]-domain->boxlo[k]; - if (qi[k] > 0.5*tmp) + qi[0] = xtmp - x0; + qi[1] = ytmp - y0; + qi[2] = ztmp - z0; + for (int k = 0; k < 3; k++) { + tmp = domain->boxhi[k] - domain->boxlo[k]; + if (qi[k] > 0.5 * tmp) qi[k] -= tmp; - else if (qi[k] < -0.5*tmp) + else if (qi[k] < -0.5 * tmp) qi[k] += tmp; } l_sum = 0.0; rij = sqrt(rsq); - f = -rij*fpair; - ririj = qi[0]*ri[0] + qi[1]*ri[1] + qi[2]*ri[2]; - sqr = qi[0]*qi[0] + qi[1]*qi[1] + qi[2]*qi[2]; + f = -rij * fpair; + ririj = qi[0] * ri[0] + qi[1] * ri[1] + qi[2] * ri[2]; + sqr = qi[0] * qi[0] + qi[1] * qi[1] + qi[2] * qi[2]; la = 0.0; lb = 0.0; - sql0 = sqr - ririj*ririj/rsq; - lambda0 = -ririj/rsq; - rsqxy = ri[0]*ri[0]+ri[1]*ri[1]; - ririjxy = qi[0]*ri[0]+qi[1]*ri[1]; - sqrixy = qi[0]*qi[0]+qi[1]*qi[1]; - sqlxy0 = sqrixy - ririjxy*ririjxy / rsqxy; - A = pow(qi[0]*ri[1] - qi[1]*ri[0], 2.0); - C = sqrt(rsqxy*sqrixy - ririjxy*ririjxy); - B = sqrt(rsq*sqr - ririj*ririj); - end_bin = (int)(sqrt(rsq+2.0*ririj+sqr)/bin_width); + sql0 = sqr - ririj * ririj / rsq; + lambda0 = -ririj / rsq; + rsqxy = ri[0] * ri[0] + ri[1] * ri[1]; + ririjxy = qi[0] * ri[0] + qi[1] * ri[1]; + sqrixy = qi[0] * qi[0] + qi[1] * qi[1]; + sqlxy0 = sqrixy - ririjxy * ririjxy / rsqxy; + A = pow(qi[0] * ri[1] - qi[1] * ri[0], 2.0); + C = sqrt(rsqxy * sqrixy - ririjxy * ririjxy); + B = sqrt(rsq * sqr - ririj * ririj); + end_bin = (int) (sqrt(rsq + 2.0 * ririj + sqr) / bin_width); while (lb < 1.0) { - l1 = lb+SMALL; - bin = (int)floor(sqrt(rsq*l1*l1+2.0*ririj*l1+sqr)/bin_width); - R1 = (bin)*bin_width; - R2 = (bin+1)*bin_width; - - l1 = lambda0 + sqrt((R1*R1 - sql0)/rsq); - l2 = lambda0 - sqrt((R1*R1 - sql0)/rsq); - l3 = lambda0 + sqrt((R2*R2 - sql0)/rsq); - l4 = lambda0 - sqrt((R2*R2 - sql0)/rsq); - + l1 = lb + SMALL; + bin = (int) floor(sqrt(rsq * l1 * l1 + 2.0 * ririj * l1 + sqr) / bin_width); + R1 = (bin) *bin_width; + R2 = (bin + 1) * bin_width; + + l1 = lambda0 + sqrt((R1 * R1 - sql0) / rsq); + l2 = lambda0 - sqrt((R1 * R1 - sql0) / rsq); + l3 = lambda0 + sqrt((R2 * R2 - sql0) / rsq); + l4 = lambda0 - sqrt((R2 * R2 - sql0) / rsq); + if (l4 >= 0.0 && l4 <= 1.0 && l4 > la) lb = l4; else if (l3 >= 0.0 && l3 <= 1.0 && l3 > la) @@ -344,34 +346,34 @@ void ComputePressureSpherical::compute_array() lb = l2; else if (l1 >= 0.0 && l1 <= 1.0 && l1 > la) lb = l1; - else + else lb = 1.0; - - if (bin == end_bin) - lb = 1.0; - if (la > lb) - error->all(FLERR,"Error: la > lb\n"); - if (bin >= 0 && bin < nbins){ - if (sql0 > SMALL){ - Fa = -B*atan2(rsq*la+ririj, B); - Fb = -B*atan2(rsq*lb+ririj, B); - tpcrr[bin] -= (f/rij)*( rsq*(lb - la) + Fb - Fa ); - tpcpp[bin] -= (f/rij)*( Fa - Fb )/2.0; - } - else - tpcrr[bin] -= f*rij*(lb-la); - if (sqlxy0 > SMALL){ - tpctt[bin] -= (f/rij)*A/C*(atan2(rsqxy*lb + ririjxy, C) - atan2(rsqxy*la + ririjxy, C)); + if (bin == end_bin) lb = 1.0; + if (la > lb) error->all(FLERR, "Error: la > lb\n"); + if (bin >= 0 && bin < nbins) { + if (sql0 > SMALL) { + Fa = -B * atan2(rsq * la + ririj, B); + Fb = -B * atan2(rsq * lb + ririj, B); + tpcrr[bin] -= (f / rij) * (rsq * (lb - la) + Fb - Fa); + tpcpp[bin] -= (f / rij) * (Fa - Fb) / 2.0; + } else + tpcrr[bin] -= f * rij * (lb - la); + + if (sqlxy0 > SMALL) { + tpctt[bin] -= (f / rij) * A / C * + (atan2(rsqxy * lb + ririjxy, C) - atan2(rsqxy * la + ririjxy, C)); } } - l_sum += lb-la; + l_sum += lb - la; la = lb; } - + // Error check if (fabs(l_sum - 1.0) > SMALL) - error->all(FLERR,"ERROR: The sum of the fractional line segments, calculated in spherical pressure tensor, does not sum up to 1."); + error->all(FLERR, + "ERROR: The sum of the fractional line segments, calculated in spherical " + "pressure tensor, does not sum up to 1."); } } @@ -393,21 +395,21 @@ void ComputePressureSpherical::compute_array() MPI_Allreduce(tpcrr, pcrr, nbins, MPI_DOUBLE, MPI_SUM, world); MPI_Allreduce(tpctt, pctt, nbins, MPI_DOUBLE, MPI_SUM, world); MPI_Allreduce(tpcpp, pcpp, nbins, MPI_DOUBLE, MPI_SUM, world); - + // populate array to output. for (bin = 0; bin < nbins; bin++) { - array[bin][0] = (bin+0.5)*bin_width; - array[bin][1] = dens[bin]; - array[bin][2] = pkrr[bin]; - array[bin][3] = pktt[bin]; - array[bin][4] = pkpp[bin]; - array[bin][5] = pcrr[bin]; - array[bin][6] = pctt[bin]; - array[bin][7] = pcpp[bin]; + array[bin][0] = (bin + 0.5) * bin_width; + array[bin][1] = dens[bin]; + array[bin][2] = pkrr[bin]; + array[bin][3] = pktt[bin]; + array[bin][4] = pkpp[bin]; + array[bin][5] = pcrr[bin]; + array[bin][6] = pctt[bin]; + array[bin][7] = pcpp[bin]; } } double ComputePressureSpherical::memory_usage() { - return 15.0*(double)(nbins+size_array_rows*size_array_cols)*sizeof(double); + return 15.0 * (double) (nbins + size_array_rows * size_array_cols) * sizeof(double); } diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_pressure_spherical.h index 918f87e653..2c2792f006 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.h +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -12,13 +12,13 @@ ------------------------------------------------------------------------- */ #ifdef COMPUTE_CLASS - -ComputeStyle(pressure/spherical,ComputePressureSpherical) - +// clang-format off +ComputeStyle(pressure/spherical,ComputePressureSpherical); +// clang-format on #else -#ifndef LMP_COMPUTE_PRESSURE_SPHERICAL -#define LMP_COMPUTE_PRESSURE_SPHERICAL +#ifndef LMP_COMPUTE_PRESSURE_SPHERICAL_H +#define LMP_COMPUTE_PRESSURE_SPHERICAL_H #include "compute.h" @@ -36,14 +36,14 @@ class ComputePressureSpherical : public Compute { private: int nbins; double bin_width, x0, y0, z0, Rmax; - + // Number density, kinetic and configurational contribution to the pressure. double *invV, *dens, *pkrr, *pktt, *pkpp, *pcrr, *pctt, *pcpp; double *tdens, *tpkrr, *tpktt, *tpkpp, *tpcrr, *tpctt, *tpcpp; class NeighList *list; }; -} +} // namespace LAMMPS_NS #endif #endif @@ -66,4 +66,3 @@ The pair style does not have a single() function, so it can not be invoked by compute pressure/cartesian. */ - From 9ea0c581ace9093d991baf9586c8963a9a5a6f71 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Sat, 5 Mar 2022 10:25:28 +0100 Subject: [PATCH 48/72] Adding kinetic contribution to prssure/cylinder --- .../compute_pressure_cylinder.cpp | 431 +++++++++--------- src/EXTRA-COMPUTE/compute_pressure_cylinder.h | 3 +- 2 files changed, 221 insertions(+), 213 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp b/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp index a2a44ca084..b124e14647 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -14,33 +13,34 @@ #include "compute_pressure_cylinder.h" -#include #include "atom.h" -#include "update.h" -#include "force.h" -#include "pair.h" -#include "neighbor.h" -#include "neigh_request.h" -#include "neigh_list.h" -#include "memory.h" -#include "error.h" #include "citeme.h" #include "domain.h" +#include "error.h" +#include "force.h" #include "math_const.h" +#include "memory.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include using namespace LAMMPS_NS; using namespace MathConst; static const char cite_compute_pressure_cylinder[] = - "compute pressure/cylinder:\n\n" - "@Article{Addington,\n" - " author = {C. K. Addington, Y. Long, K. E. Gubbins},\n" - " title = {The pressure in interfaces having cylindrical geometry},\n" - " journal = {J.~Chem.~Phys.},\n" - " year = 2018,\n" - " volume = 149,\n" - " pages = {084109}\n" - "}\n\n"; + "compute pressure/cylinder:\n\n" + "@Article{Addington,\n" + " author = {C. K. Addington, Y. Long, K. E. Gubbins},\n" + " title = {The pressure in interfaces having cylindrical geometry},\n" + " journal = {J.~Chem.~Phys.},\n" + " year = 2018,\n" + " volume = 149,\n" + " pages = {084109}\n" + "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Calculate the configurational components of the pressure tensor in @@ -48,96 +48,103 @@ static const char cite_compute_pressure_cylinder[] = +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - Pr_temp(nullptr), Pr_all(nullptr), Pz_temp(nullptr), Pz_all(nullptr), Pphi_temp(nullptr), - Pphi_all(nullptr), R(nullptr), Rinv(nullptr), R2(nullptr), PrAinv(nullptr), PzAinv(nullptr), - R2kin(nullptr), density_temp(nullptr), invVbin(nullptr), density_all(nullptr), - tangent(nullptr), ephi_x(nullptr), ephi_y(nullptr), binz(nullptr) + Compute(lmp, narg, arg), Pvr_temp(nullptr), Pvr_all(nullptr), Pvz_temp(nullptr), Pvz_all(nullptr), + Pvphi_temp(nullptr), Pvphi_all(nullptr), R(nullptr), Rinv(nullptr), R2(nullptr), PrAinv(nullptr), + PzAinv(nullptr), R2kin(nullptr), density_temp(nullptr), invVbin(nullptr), density_all(nullptr), + tangent(nullptr), ephi_x(nullptr), ephi_y(nullptr), binz(nullptr) { if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_cylinder); - if (narg != 7) error->all(FLERR,"Illegal compute pressure/cylinder command"); + if (narg != 7) error->all(FLERR, "Illegal compute pressure/cylinder command"); - zlo=utils::numeric(FLERR,arg[3],false,lmp); - zhi=utils::numeric(FLERR,arg[4],false,lmp); - Rmax=utils::numeric(FLERR,arg[5],false,lmp); - bin_width=utils::numeric(FLERR,arg[6],false,lmp); + zlo = utils::numeric(FLERR, arg[3], false, lmp); + zhi = utils::numeric(FLERR, arg[4], false, lmp); + Rmax = utils::numeric(FLERR, arg[5], false, lmp); + bin_width = utils::numeric(FLERR, arg[6], false, lmp); if ((bin_width <= 0.0) || (bin_width > Rmax)) - error->all(FLERR,"Illegal compute pressure/cylinder command"); - if ((zhi < zlo) || ((zhi-zlo) < bin_width)) - error->all(FLERR,"Illegal compute pressure/cylinder command"); + error->all(FLERR, "Illegal compute pressure/cylinder command"); + if ((zhi < zlo) || ((zhi - zlo) < bin_width)) + error->all(FLERR, "Illegal compute pressure/cylinder command"); if ((zhi > domain->boxhi[2]) || (zlo < domain->boxlo[2])) - error->all(FLERR,"Illegal compute pressure/cylinder command"); + error->all(FLERR, "Illegal compute pressure/cylinder command"); - nbins=(int)(Rmax/bin_width); - nzbins=(int)((zhi-zlo)/bin_width); + nbins = (int) (Rmax / bin_width); + nzbins = (int) ((zhi - zlo) / bin_width); // NOTE: at 2^22 = 4.2M bins, we will be close to exhausting allocatable // memory on a 32-bit environment. so we use this as an upper limit. - if ((nbins < 1) || (nzbins < 1) || (nbins > 2<<22) || (nzbins > 2<<22)) - error->all(FLERR,"Illegal compute pressure/cylinder command"); + if ((nbins < 1) || (nzbins < 1) || (nbins > 2 << 22) || (nzbins > 2 << 22)) + error->all(FLERR, "Illegal compute pressure/cylinder command"); - array_flag=1; - vector_flag=0; - extarray=0; - size_array_cols = 5; // r, number density, Pr, Pphi, Pz + array_flag = 1; + vector_flag = 0; + extarray = 0; + size_array_cols = 8; // r, number density, pkr, pkphi, pkz, pvr, pvphi, pz size_array_rows = nbins; + + memory->create(density_all, nbins, "density_all"); + memory->create(Pkr_all, nbins, "Pkr_all"); + memory->create(Pkphi_all, nbins, "Pkphi_all"); + memory->create(Pkz_all, nbins, "Pkz_all"); + memory->create(Pvr_all, nbins, "Pvr_all"); + memory->create(Pvphi_all, nbins, "Pvphi_all"); + memory->create(Pvz_all, nbins, "Pvz_all"); + memory->create(density_temp, nbins, "density_temp"); + memory->create(Pkr_temp, nbins, "Pkr_temp"); + memory->create(Pkphi_temp, nbins, "Pkphi_temp"); + memory->create(Pkz_temp, nbins, "Pkz_temp"); + memory->create(Pvr_temp, nbins, "Pvr_temp"); + memory->create(Pvphi_temp, nbins, "Pvphi_temp"); + memory->create(Pvz_temp, nbins, "Pvz_temp"); + memory->create(R,nbins, "R"); + memory->create(R2,nbins, "R2"); + memory->create(PrAinv,nbins, "PrAinv"); + memory->create(PzAinv,nbins, "PzAinv"); + memory->create(Rinv,nbins, "Rinv"); + memory->create(binz,nbins, "binz"); + memory->create(invVbin,nbins, "invVbin"); - Pr_temp = new double[nbins]; - Pr_all = new double[nbins]; - Pz_temp = new double[nbins]; - Pz_all = new double[nbins]; - Pphi_temp = new double[nbins]; - Pphi_all = new double[nbins]; - R = new double[nbins]; - R2 = new double[nbins]; - PrAinv = new double[nbins]; - PzAinv = new double[nbins]; - Rinv = new double[nbins]; - binz = new double[nzbins]; - - R2kin = new double[nbins]; - density_temp = new double[nbins]; - invVbin = new double[nbins]; - density_all = new double[nbins]; - - memory->create(array,nbins,5,"PN:array"); - - nphi=360; - tangent = new double[nphi]; - ephi_x = new double[nphi]; - ephi_y = new double[nphi]; + nphi = 360; + memory->create(tangent,nbins, "tangent"); + memory->create(ephi_x,nbins, "ephi_x"); + memory->create(ephi_y,nbins, "ephi_y"); + memory->create(array, nbins, 5, "PN:array"); nktv2p = force->nktv2p; - + printf("Constructor done"); } /* ---------------------------------------------------------------------- */ ComputePressureCyl::~ComputePressureCyl() { - // count all of these for memory usage memory->destroy(array); - delete [] R; - delete [] Rinv; - delete [] R2; - delete [] R2kin; - delete [] invVbin; - delete [] density_temp; - delete [] density_all; - delete [] tangent; - delete [] ephi_x; - delete [] ephi_y; - delete [] Pr_temp; - delete [] Pr_all; - delete [] Pz_temp; - delete [] Pz_all; - delete [] Pphi_temp; - delete [] Pphi_all; - delete [] PrAinv; - delete [] PzAinv; - delete [] binz; + memory->destroy(density_all); + memory->destroy(Pkr_all); + memory->destroy(Pkphi_all); + memory->destroy(Pkz_all); + memory->destroy(Pvr_all); + memory->destroy(Pvphi_all); + memory->destroy(Pvz_all); + memory->destroy(density_temp); + memory->destroy(Pkr_temp); + memory->destroy(Pkphi_temp); + memory->destroy(Pkz_temp); + memory->destroy(Pvr_temp); + memory->destroy(Pvphi_temp); + memory->destroy(Pvz_temp); + memory->destroy(R); + memory->destroy(R2); + memory->destroy(PrAinv); + memory->destroy(PzAinv); + memory->destroy(Rinv); + memory->destroy(binz); + memory->destroy(invVbin); + memory->destroy(tangent); + memory->destroy(ephi_x); + memory->destroy(ephi_y); + memory->destroy(array); } /* ---------------------------------------------------------------------- */ @@ -145,45 +152,44 @@ ComputePressureCyl::~ComputePressureCyl() void ComputePressureCyl::init() { if (force->pair == nullptr) - error->all(FLERR,"No pair style is defined for compute pressure/cylinder"); + error->all(FLERR, "No pair style is defined for compute pressure/cylinder"); if (force->pair->single_enable == 0) - error->all(FLERR,"Pair style does not support compute pressure/cylinder"); + error->all(FLERR, "Pair style does not support compute pressure/cylinder"); double phi; for (int iphi = 0; iphi < nphi; iphi++) { - phi=((double)iphi)*MY_PI/180.0; - tangent[iphi]=tan(phi); - ephi_x[iphi]=-sin(phi); - ephi_y[iphi]=cos(phi); + phi = ((double) iphi) * MY_PI / 180.0; + tangent[iphi] = tan(phi); + ephi_x[iphi] = -sin(phi); + ephi_y[iphi] = cos(phi); } for (int iq = 0; iq < nbins; iq++) { - R[iq]=((double)iq+0.5)*bin_width; - Rinv[iq]=1.0/R[iq]; - R2[iq]=R[iq]*R[iq]; - R2kin[iq]=(((double)iq)+1.0)*bin_width; - R2kin[iq]*=R2kin[iq]; - PrAinv[iq]=1.0/(2.0*MY_PI*(zhi-zlo)*R[iq]); + R[iq] = ((double) iq + 0.5) * bin_width; + Rinv[iq] = 1.0 / R[iq]; + R2[iq] = R[iq] * R[iq]; + R2kin[iq] = (((double) iq) + 1.0) * bin_width; + R2kin[iq] *= R2kin[iq]; + PrAinv[iq] = 1.0 / (2.0 * MY_PI * (zhi - zlo) * R[iq]); } - PphiAinv=1.0/((zhi-zlo)*bin_width*2.0*(double)nphi); + PphiAinv = 1.0 / ((zhi - zlo) * bin_width * 2.0 * (double) nphi); - invVbin[0]=1.0/((zhi-zlo)*MY_PI*R2kin[0]); - PzAinv[0]=1.0/(MY_PI*R2kin[0]*((double)nzbins)); + invVbin[0] = 1.0 / ((zhi - zlo) * MY_PI * R2kin[0]); + PzAinv[0] = 1.0 / (MY_PI * R2kin[0] * ((double) nzbins)); for (int jq = 1; jq < nbins; jq++) { - invVbin[jq]=1.0/((zhi-zlo)*MY_PI*(R2kin[jq]-R2kin[jq-1])); - PzAinv[jq]=1.0/(MY_PI*(R2kin[jq]-R2kin[jq-1])*((double)nzbins)); + invVbin[jq] = 1.0 / ((zhi - zlo) * MY_PI * (R2kin[jq] - R2kin[jq - 1])); + PzAinv[jq] = 1.0 / (MY_PI * (R2kin[jq] - R2kin[jq - 1]) * ((double) nzbins)); } // need an occasional half neighbor list - int irequest = neighbor->request(this,instance_me); + int irequest = neighbor->request(this, instance_me); neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->compute = 1; neighbor->requests[irequest]->occasional = 1; - for (int zzz = 0; zzz < nzbins; zzz++) binz[zzz]=(((double)zzz)+0.5)*bin_width+zlo; - + for (int zzz = 0; zzz < nzbins; zzz++) binz[zzz] = (((double) zzz) + 0.5) * bin_width + zlo; } /* ---------------------------------------------------------------------- */ @@ -195,7 +201,6 @@ void ComputePressureCyl::init_list(int /* id */, NeighList *ptr) /* ---------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- count pairs and compute pair info on this proc only count pair once if newton_pair is off @@ -211,25 +216,25 @@ void ComputePressureCyl::compute_array() // clear pressures for (ibin = 0; ibin < nbins; ibin++) { - density_temp[ibin]=0.0; - density_all[ibin]=0.0; - Pr_temp[ibin]=0.0; - Pr_all[ibin]=0.0; - Pphi_temp[ibin]=0.0; - Pphi_all[ibin]=0.0; - Pz_temp[ibin]=0.0; - Pz_all[ibin]=0.0; + density_temp[ibin] = 0.0; + density_all[ibin] = 0.0; + Pvr_temp[ibin] = 0.0; + Pvr_all[ibin] = 0.0; + Pvphi_temp[ibin] = 0.0; + Pvphi_all[ibin] = 0.0; + Pvz_temp[ibin] = 0.0; + Pvz_all[ibin] = 0.0; } // what processor am I? int me; - MPI_Comm_rank(world,&me); + MPI_Comm_rank(world, &me); - int i,j,ii,jj,inum,jnum,itype,jtype; - tagint itag,jtag; - double xtmp,ytmp,ztmp,delx,dely,delz; - double rsq,fpair,factor_coul,factor_lj; - int *ilist,*jlist,*numneigh,**firstneigh; + int i, j, ii, jj, inum, jnum, itype, jtype; + tagint itag, jtag; + double xtmp, ytmp, ztmp, delx, dely, delz; + double rsq, fpair, factor_coul, factor_lj; + int *ilist, *jlist, *numneigh, **firstneigh; double **x = atom->x; tagint *tag = atom->tag; @@ -250,16 +255,18 @@ void ComputePressureCyl::compute_array() // calculate number density (by radius) double temp_R2; - for (i = 0; i < nlocal; i++) if ((x[i][2] < zhi) && (x[i][2] > zlo)) { - temp_R2=x[i][0]*x[i][0]+x[i][1]*x[i][1]; - if (temp_R2 > R2kin[nbins-1]) continue; // outside of Rmax + for (i = 0; i < nlocal; i++) + if ((x[i][2] < zhi) && (x[i][2] > zlo)) { + temp_R2 = x[i][0] * x[i][0] + x[i][1] * x[i][1]; + if (temp_R2 > R2kin[nbins - 1]) continue; // outside of Rmax - for (j = 0; j < nbins; j++) if (temp_R2 < R2kin[j]) break; + for (j = 0; j < nbins; j++) + if (temp_R2 < R2kin[j]) break; - density_temp[j]+=invVbin[j]; - } - MPI_Allreduce(density_temp,density_all,nbins,MPI_DOUBLE,MPI_SUM,world); - for (i = 0; i < nbins; i++) array[i][1]=density_all[i]; // NEW + density_temp[j] += invVbin[j]; + } + MPI_Allreduce(density_temp, density_all, nbins, MPI_DOUBLE, MPI_SUM, world); + for (i = 0; i < nbins; i++) array[i][1] = density_all[i]; // NEW // loop over neighbors of my atoms // skip if I or J are not in group @@ -272,14 +279,14 @@ void ComputePressureCyl::compute_array() Pair *pair = force->pair; double **cutsq = force->pair->cutsq; - double r1=0.0; - double r2=0.0; - double risq,rjsq; - double A,B,C,D; - double alpha1,alpha2; - double xi,yi,zi,dx,dy,dz; - double xR,yR,zR,fn; - double alpha,xL,yL,zL,L2,ftphi,ftz; + double r1 = 0.0; + double r2 = 0.0; + double risq, rjsq; + double A, B, C, D; + double alpha1, alpha2; + double xi, yi, zi, dx, dy, dz; + double xR, yR, zR, fn; + double alpha, xL, yL, zL, L2, ftphi, ftz; double sqrtD; for (ii = 0; ii < inum; ii++) { @@ -294,7 +301,7 @@ void ComputePressureCyl::compute_array() jlist = firstneigh[i]; jnum = numneigh[i]; - r1=x[i][0]*x[i][0]+x[i][1]*x[i][1]; + r1 = x[i][0] * x[i][0] + x[i][1] * x[i][1]; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -309,9 +316,9 @@ void ComputePressureCyl::compute_array() if (newton_pair == 0 && j >= nlocal) { jtag = tag[j]; if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; + if ((itag + jtag) % 2 == 0) continue; } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; + if ((itag + jtag) % 2 == 1) continue; } else { if (x[j][2] < ztmp) continue; if (x[j][2] == ztmp) { @@ -325,102 +332,102 @@ void ComputePressureCyl::compute_array() dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; - r2=x[j][0]*x[j][0]+x[j][1]*x[j][1]; + r2 = x[j][0] * x[j][0] + x[j][1] * x[j][1]; // ri is smaller of r1 and r2 if (r2 < r1) { - risq=r2; - rjsq=r1; - xi=x[j][0]; - yi=x[j][1]; - zi=x[j][2]; - dx=x[i][0]-x[j][0]; - dy=x[i][1]-x[j][1]; - dz=x[i][2]-x[j][2]; + risq = r2; + rjsq = r1; + xi = x[j][0]; + yi = x[j][1]; + zi = x[j][2]; + dx = x[i][0] - x[j][0]; + dy = x[i][1] - x[j][1]; + dz = x[i][2] - x[j][2]; } else { - risq=r1; - rjsq=r2; - xi=x[i][0]; - yi=x[i][1]; - zi=x[i][2]; - dx=x[j][0]-x[i][0]; - dy=x[j][1]-x[i][1]; - dz=x[j][2]-x[i][2]; + risq = r1; + rjsq = r2; + xi = x[i][0]; + yi = x[i][1]; + zi = x[i][2]; + dx = x[j][0] - x[i][0]; + dy = x[j][1] - x[i][1]; + dz = x[j][2] - x[i][2]; } - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; jtype = type[j]; if (rsq >= cutsq[itype][jtype]) continue; - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); - A=dx*dx+dy*dy; - B=2.0*(xi*dx+yi*dy); + A = dx * dx + dy * dy; + B = 2.0 * (xi * dx + yi * dy); // normal pressure contribution P_rhorho for (ibin = 0; ibin < nbins; ibin++) { // completely inside of R if (rjsq < R2[ibin]) continue; - C=risq-R2[ibin]; - D=B*B-4.0*A*C; + C = risq - R2[ibin]; + D = B * B - 4.0 * A * C; // completely outside of R if (D < 0.0) continue; - sqrtD=sqrt(D); - alpha1=0.5*(-B+sqrtD)/A; - alpha2=0.5*(-B-sqrtD)/A; + sqrtD = sqrt(D); + alpha1 = 0.5 * (-B + sqrtD) / A; + alpha2 = 0.5 * (-B - sqrtD) / A; if ((alpha1 > 0.0) && (alpha1 < 1.0)) { - zR=zi+alpha1*dz; - if ((zR < zhi) && (zR > zlo)) - { - xR=xi+alpha1*dx; - yR=yi+alpha1*dy; - fn=fpair*fabs(xR*dx+yR*dy); + zR = zi + alpha1 * dz; + if ((zR < zhi) && (zR > zlo)) { + xR = xi + alpha1 * dx; + yR = yi + alpha1 * dy; + fn = fpair * fabs(xR * dx + yR * dy); - Pr_temp[ibin]+=fn; + Pvr_temp[ibin] += fn; } } if ((alpha2 > 0.0) && (alpha2 < 1.0)) { - zR=zi+alpha2*dz; + zR = zi + alpha2 * dz; if ((zR < zhi) && (zR > zlo)) { - xR=xi+alpha2*dx; - yR=yi+alpha2*dy; - fn=fpair*fabs(xR*dx+yR*dy); + xR = xi + alpha2 * dx; + yR = yi + alpha2 * dy; + fn = fpair * fabs(xR * dx + yR * dy); - Pr_temp[ibin]+=fn; + Pvr_temp[ibin] += fn; } } } // azimuthal pressure contribution (P_phiphi) for (int iphi = 0; iphi < nphi; iphi++) { - alpha=(yi-xi*tangent[iphi])/(dx*tangent[iphi]-dy); + alpha = (yi - xi * tangent[iphi]) / (dx * tangent[iphi] - dy); // no intersection with phi surface if ((alpha >= 1.0) || (alpha <= 0.0)) continue; // no contribution (outside of averaging region) - zL=zi+alpha*dz; + zL = zi + alpha * dz; if ((zL > zhi) || (zL < zlo)) continue; - xL=xi+alpha*dx; - yL=yi+alpha*dy; + xL = xi + alpha * dx; + yL = yi + alpha * dy; - L2=xL*xL+yL*yL; + L2 = xL * xL + yL * yL; // no intersection (outside of Rmax) - if (L2 > R2kin[nbins-1]) continue; + if (L2 > R2kin[nbins - 1]) continue; - ftphi=fabs(dx*ephi_x[iphi]+dy*ephi_y[iphi])*fpair; + ftphi = fabs(dx * ephi_x[iphi] + dy * ephi_y[iphi]) * fpair; // add to appropriate bin - for (ibin = 0; ibin < nbins; ibin++) if (L2 < R2kin[ibin]) { - Pphi_temp[ibin]+=ftphi; - break; - } + for (ibin = 0; ibin < nbins; ibin++) + if (L2 < R2kin[ibin]) { + Pvphi_temp[ibin] += ftphi; + break; + } } // z pressure contribution (P_zz) @@ -429,55 +436,55 @@ void ComputePressureCyl::compute_array() if ((x[i][2] > binz[zbin]) && (x[j][2] > binz[zbin])) continue; if ((x[i][2] < binz[zbin]) && (x[j][2] < binz[zbin])) continue; - alpha=(binz[zbin]-zi)/dz; + alpha = (binz[zbin] - zi) / dz; - xL=xi+alpha*dx; - yL=yi+alpha*dy; + xL = xi + alpha * dx; + yL = yi + alpha * dy; - L2=xL*xL+yL*yL; + L2 = xL * xL + yL * yL; - if (L2 > R2kin[nbins-1]) continue; + if (L2 > R2kin[nbins - 1]) continue; - ftz=fabs(dz)*fpair; + ftz = fabs(dz) * fpair; // add to appropriate bin - for (ibin = 0; ibin < nbins; ibin++) if (L2 < R2kin[ibin]) { - Pz_temp[ibin]+=ftz; - break; - } + for (ibin = 0; ibin < nbins; ibin++) + if (L2 < R2kin[ibin]) { + Pvz_temp[ibin] += ftz; + break; + } } } } // calculate pressure (force over area) for (ibin = 0; ibin < nbins; ibin++) { - Pr_temp[ibin]*=PrAinv[ibin]*Rinv[ibin]; - Pphi_temp[ibin]*=PphiAinv; - Pz_temp[ibin]*=PzAinv[ibin]; + Pvr_temp[ibin] *= PrAinv[ibin] * Rinv[ibin]; + Pvphi_temp[ibin] *= PphiAinv; + Pvz_temp[ibin] *= PzAinv[ibin]; } // communicate these values across processors - MPI_Allreduce(Pr_temp,Pr_all,nbins,MPI_DOUBLE,MPI_SUM,world); - MPI_Allreduce(Pphi_temp,Pphi_all,nbins,MPI_DOUBLE,MPI_SUM,world); - MPI_Allreduce(Pz_temp,Pz_all,nbins,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(Pvr_temp, Pvr_all, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(Pvphi_temp, Pvphi_all, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(Pvz_temp, Pvz_all, nbins, MPI_DOUBLE, MPI_SUM, world); // populate array for (ibin = 0; ibin < nbins; ibin++) { - array[ibin][0]=R[ibin]; - array[ibin][2]=Pr_all[ibin]*nktv2p; - array[ibin][3]=Pphi_all[ibin]*nktv2p; - array[ibin][4]=Pz_all[ibin]*nktv2p; + array[ibin][0] = R[ibin]; + array[ibin][2] = Pvr_all[ibin] * nktv2p; + array[ibin][3] = Pvphi_all[ibin] * nktv2p; + array[ibin][4] = Pvz_all[ibin] * nktv2p; } - } /* ---------------------------------------------------------------------- memory usage of data ------------------------------------------------------------------------- */ - +// TODO: update this double ComputePressureCyl::memory_usage() { double bytes = - (3.0*(double)nphi + 16.0*(double)nbins+5.0*(double)nbins) * sizeof(double); + (3.0 * (double) nphi + 16.0 * (double) nbins + 5.0 * (double) nbins) * sizeof(double); return bytes; } diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.h b/src/EXTRA-COMPUTE/compute_pressure_cylinder.h index 871c820910..2f8a1b7804 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.h +++ b/src/EXTRA-COMPUTE/compute_pressure_cylinder.h @@ -35,7 +35,8 @@ class ComputePressureCyl : public Compute { private: int nbins, nphi, nzbins; - double *Pr_temp, *Pr_all, *Pz_temp, *Pz_all, *Pphi_temp, *Pphi_all; + double *Pvr_temp, *Pvr_all, *Pvz_temp, *Pvz_all, *Pvphi_temp, *Pvphi_all; + double *Pkr_temp, *Pkr_all, *Pkz_temp, *Pkz_all, *Pkphi_temp, *Pkphi_all; double *R, *Rinv, *R2, *PrAinv, *PzAinv, PphiAinv; double Rmax, bin_width, nktv2p; double *R2kin, *density_temp, *invVbin, *density_all; From 87c96aeeb1aa079ba18086f5521339fb2a71edfa Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 10:07:54 -0500 Subject: [PATCH 49/72] add tests for more compute styles --- unittest/commands/test_compute_global.cpp | 162 ++++++++++++++++++++-- 1 file changed, 148 insertions(+), 14 deletions(-) diff --git a/unittest/commands/test_compute_global.cpp b/unittest/commands/test_compute_global.cpp index 2b8f86d4ce..1c9be99ba4 100644 --- a/unittest/commands/test_compute_global.cpp +++ b/unittest/commands/test_compute_global.cpp @@ -44,6 +44,7 @@ protected: command("variable input_dir index \"" STRINGIFY(TEST_INPUT_FOLDER) "\""); command("include \"${input_dir}/in.fourmol\""); command("group allwater molecule 3:6"); + command("region half block 0.0 INF INF INF INF INF"); END_HIDE_OUTPUT(); } } @@ -57,6 +58,11 @@ protected: { return (double *)lammps_extract_compute(lmp, id, LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR); } + + double **get_array(const char *id) + { + return (double **)lammps_extract_compute(lmp, id, LMP_STYLE_GLOBAL, LMP_TYPE_ARRAY); + } }; TEST_F(ComputeGlobalTest, Energy) @@ -65,25 +71,29 @@ TEST_F(ComputeGlobalTest, Energy) int has_tally = lammps_config_has_package("TALLY"); BEGIN_HIDE_OUTPUT(); + command("pair_style lj/cut/coul/cut 10.0"); + command("pair_coeff * * 0.01 3.0"); + command("bond_style harmonic"); + command("bond_coeff * 100.0 1.5"); + command("compute ke1 all ke"); command("compute ke2 allwater ke"); command("compute pe1 all pe"); command("compute pe2 all pe bond"); command("compute pe3 all pe angle dihedral"); + command("compute pr1 all pressure thermo_temp"); + command("compute pr2 all pressure NULL virial"); + command("compute pr3 all pressure NULL angle dihedral"); + std::string thermo_style = "c_ke1 c_ke2 c_pe1 c_pe2 c_pe3 c_pr1 c_pr2 c_pr3"; + if (has_tally) { command("compute pe4 all pe/tally allwater"); command("compute pe5 all pe/mol/tally all"); command("compute pe6 all pe pair"); + thermo_style += " c_pe4 c_pe5[*]"; } - command("pair_style lj/cut/coul/cut 10.0"); - command("pair_coeff * * 0.01 3.0"); - command("bond_style harmonic"); - command("bond_coeff * 100.0 1.5"); - if (has_tally) { - command("thermo_style custom c_ke1 c_ke2 c_pe1 c_pe2 c_pe3 c_pe4 c_pe5[*]"); - } else { - command("thermo_style custom c_ke1 c_ke2 c_pe1 c_pe2 c_pe3"); - } + + command("thermo_style custom " + thermo_style); command("run 0 post no"); END_HIDE_OUTPUT(); @@ -92,6 +102,30 @@ TEST_F(ComputeGlobalTest, Energy) EXPECT_DOUBLE_EQ(get_scalar("pe1"), 24155.155261642241); EXPECT_DOUBLE_EQ(get_scalar("pe2"), 361.37528652881286); EXPECT_DOUBLE_EQ(get_scalar("pe3"), 0.0); + EXPECT_DOUBLE_EQ(get_scalar("pr1"), 1956948.4735454607); + EXPECT_DOUBLE_EQ(get_scalar("pr2"), 1956916.7725807722); + EXPECT_DOUBLE_EQ(get_scalar("pr3"), 0.0); + auto pr1 = get_vector("pr1"); + auto pr2 = get_vector("pr2"); + auto pr3 = get_vector("pr3"); + EXPECT_DOUBLE_EQ(pr1[0], 2150600.9207200543); + EXPECT_DOUBLE_EQ(pr1[1], 1466949.7512112649); + EXPECT_DOUBLE_EQ(pr1[2], 2253294.7487050635); + EXPECT_DOUBLE_EQ(pr1[3], 856643.16926486336); + EXPECT_DOUBLE_EQ(pr1[4], 692710.86929464422); + EXPECT_DOUBLE_EQ(pr1[5], -44403.909298603547); + EXPECT_DOUBLE_EQ(pr2[0], 2150575.6989334146); + EXPECT_DOUBLE_EQ(pr2[1], 1466911.3911461537); + EXPECT_DOUBLE_EQ(pr2[2], 2253263.2276627473); + EXPECT_DOUBLE_EQ(pr2[3], 856632.34707690508); + EXPECT_DOUBLE_EQ(pr2[4], 692712.89222328411); + EXPECT_DOUBLE_EQ(pr2[5], -44399.277068014424); + EXPECT_DOUBLE_EQ(pr3[0], 0.0); + EXPECT_DOUBLE_EQ(pr3[1], 0.0); + EXPECT_DOUBLE_EQ(pr3[2], 0.0); + EXPECT_DOUBLE_EQ(pr3[3], 0.0); + EXPECT_DOUBLE_EQ(pr3[4], 0.0); + EXPECT_DOUBLE_EQ(pr3[5], 0.0); if (has_tally) { EXPECT_DOUBLE_EQ(get_scalar("pe4"), 15425.840923850392); @@ -102,6 +136,13 @@ TEST_F(ComputeGlobalTest, Energy) EXPECT_DOUBLE_EQ(pe5[3], -31.557101160514257); } + TEST_FAILURE(".*ERROR: Compute pressure must use group all.*", + command("compute pr5 allwater pressure thermo_temp");); + TEST_FAILURE(".*ERROR: Compute pressure requires temperature ID to include kinetic energy.*", + command("compute pr5 all pressure NULL");); + TEST_FAILURE(".*ERROR: Could not find compute pressure temperature ID", + command("compute pr5 all pressure xxx");); + TEST_FAILURE(".*ERROR: Reuse of compute ID 'pe2'.*", command("compute pe2 all pe");); TEST_FAILURE(".*ERROR: Compute pe must use group all.*", command("compute pe allwater pe");); TEST_FAILURE(".*ERROR: Illegal compute command.*", command("compute pe potential");); @@ -110,19 +151,31 @@ TEST_F(ComputeGlobalTest, Energy) TEST_F(ComputeGlobalTest, Geometry) { if (lammps_get_natoms(lmp) == 0.0) GTEST_SKIP(); + int has_extra = lammps_config_has_package("EXTRA-COMPUTE"); BEGIN_HIDE_OUTPUT(); + command("pair_style lj/cut 10.0"); + command("pair_coeff * * 0.01 3.0"); + command("bond_style harmonic"); + command("bond_coeff * 100.0 1.5"); + command("compute com1 all com"); command("compute com2 allwater com"); command("compute mu1 all dipole"); command("compute mu2 allwater dipole geometry "); command("compute rg1 all gyration"); command("compute rg2 allwater gyration"); - command("pair_style lj/cut 10.0"); - command("pair_coeff * * 0.01 3.0"); - command("bond_style harmonic"); - command("bond_coeff * 100.0 1.5"); - command("thermo_style custom c_com1[*] c_com2[*] c_mu1 c_mu2"); + std::string thermo_style = "c_com1[*] c_com2[*] c_rg1[*] c_rg2[*]"; + + if (has_extra) { + command("compute mom1 all momentum"); + command("compute mom2 allwater momentum"); + command("compute mop1 all stress/mop x 0.0 total"); + command("compute mop2 all stress/mop/profile z lower 0.5 kin conf"); + thermo_style += " c_mu1 c_mu2 c_mop1[*] c_mop2[1][1]"; + } + + command("thermo_style custom " + thermo_style); command("run 0 post no"); END_HIDE_OUTPUT(); @@ -139,6 +192,7 @@ TEST_F(ComputeGlobalTest, Geometry) EXPECT_DOUBLE_EQ(com2[0], 1.7850913321989679); EXPECT_DOUBLE_EQ(com2[1], -0.45168408952146238); EXPECT_DOUBLE_EQ(com2[2], -0.60215022088294912); + EXPECT_DOUBLE_EQ(get_scalar("mu1"), 1.8335537504770163); EXPECT_DOUBLE_EQ(get_scalar("mu2"), 1.7849382239204072); EXPECT_DOUBLE_EQ(mu1[0], 0.41613191281297729); @@ -147,6 +201,7 @@ TEST_F(ComputeGlobalTest, Geometry) EXPECT_DOUBLE_EQ(mu2[0], -0.029474795088977768); EXPECT_DOUBLE_EQ(mu2[1], 1.153516133030746); EXPECT_DOUBLE_EQ(mu2[2], -1.3618135814069394); + EXPECT_DOUBLE_EQ(get_scalar("rg1"), 3.8495643473797196); EXPECT_DOUBLE_EQ(get_scalar("rg2"), 5.4558163385611342); EXPECT_DOUBLE_EQ(rg1[0], 3.6747807397432752); @@ -161,6 +216,85 @@ TEST_F(ComputeGlobalTest, Geometry) EXPECT_DOUBLE_EQ(rg2[3], 1.2965604701522486); EXPECT_DOUBLE_EQ(rg2[4], -5.0315240817290841); EXPECT_DOUBLE_EQ(rg2[5], 1.1103378503822141); + if (has_extra) { + auto mom1 = get_vector("mom1"); + auto mom2 = get_vector("mom2"); + auto mop1 = get_vector("mop1"); + auto mop2 = get_array("mop2"); + EXPECT_DOUBLE_EQ(mom1[0], 0.0054219056685341164); + EXPECT_DOUBLE_EQ(mom1[1], -0.054897225112275558); + EXPECT_DOUBLE_EQ(mom1[2], 0.059097392692385661); + EXPECT_DOUBLE_EQ(mom2[0], -0.022332069630161717); + EXPECT_DOUBLE_EQ(mom2[1], -0.056896553865696115); + EXPECT_DOUBLE_EQ(mom2[2], 0.069179891052881484); + EXPECT_DOUBLE_EQ(mop1[0], 3522311.3572200728); + EXPECT_DOUBLE_EQ(mop1[1], 2871104.9055934539); + EXPECT_DOUBLE_EQ(mop1[2], -4136077.5224247416); + EXPECT_DOUBLE_EQ(mop2[0][0], -8.0869239999999998); + EXPECT_DOUBLE_EQ(mop2[0][1], 0.0); + EXPECT_DOUBLE_EQ(mop2[0][2], 0.0); + EXPECT_DOUBLE_EQ(mop2[1][0], -7.5869239999999998); + EXPECT_DOUBLE_EQ(mop2[1][1], 0.0); + EXPECT_DOUBLE_EQ(mop2[1][2], 0.0); + } +} + +TEST_F(ComputeGlobalTest, Reduction) +{ + if (lammps_get_natoms(lmp) == 0.0) GTEST_SKIP(); + + BEGIN_HIDE_OUTPUT(); + command("pair_style lj/cut 10.0"); + command("pair_coeff * * 0.01 3.0"); + command("bond_style harmonic"); + command("bond_coeff * 100.0 1.5"); + + command("variable v atom sqrt(vx*vx+vy*vy+vz*vz)"); + command("variable id atom id"); + command("fix chg all store/state 0 q"); + command("compute ke all ke/atom"); + command("compute min allwater reduce min x fx v_v"); + command("compute chg all reduce max f_chg"); + command("compute max all reduce max y fy v_v"); + command("compute ave all reduce/region half ave z fz v_v"); + command("compute sum allwater reduce/region half sum vx vy vz"); + command("compute rep all reduce max v_id v_v v_id y replace 1 2 replace 3 4"); + std::string thermo_style = "c_min[*] c_chg c_max[*] c_sum[*] c_ave[*] c_rep[*]"; + + command("thermo_style custom " + thermo_style); + command("run 0 post no"); + END_HIDE_OUTPUT(); + + auto min = get_vector("min"); + auto max = get_vector("max"); + auto sum = get_vector("sum"); + auto ave = get_vector("ave"); + auto rep = get_vector("rep"); + + EXPECT_DOUBLE_EQ(get_scalar("chg"), 0.51000000000000001); + + EXPECT_DOUBLE_EQ(min[0], -2.7406520384725965); + EXPECT_DOUBLE_EQ(min[1], -20385.448391361348); + EXPECT_DOUBLE_EQ(min[2], 0.00071995632406981081); + + EXPECT_DOUBLE_EQ(max[0], 4.0120175892854135); + EXPECT_DOUBLE_EQ(max[1], 21193.39005673242); + EXPECT_DOUBLE_EQ(max[2], 0.0072167889062371513); + + EXPECT_DOUBLE_EQ(sum[0], 0.0021436162503408024); + EXPECT_DOUBLE_EQ(sum[1], -0.013760203913131267); + EXPECT_DOUBLE_EQ(sum[2], 0.017517003988402391); + + EXPECT_DOUBLE_EQ(ave[0], -1.3013763067943667); + EXPECT_DOUBLE_EQ(ave[1], -619.60864441905312); + EXPECT_DOUBLE_EQ(ave[2], 0.0035263629500884397); + + // index of max v_v + EXPECT_DOUBLE_EQ(rep[0], 20); + EXPECT_DOUBLE_EQ(rep[1], max[2]); + // index of max y + EXPECT_DOUBLE_EQ(rep[2], 26); + EXPECT_DOUBLE_EQ(rep[3], max[0]); } } // namespace LAMMPS_NS From 4e125ccfc610da17e1d4cd835ce16b7ed32259c3 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Sat, 5 Mar 2022 16:22:11 +0100 Subject: [PATCH 50/72] Combined pressure profile documentation into one page --- doc/src/Commands_compute.rst | 4 +- doc/src/compute.rst | 4 +- doc/src/compute_pressure_cartesian.rst | 63 +++++++++++++++--- doc/src/compute_pressure_cylinder.rst | 88 -------------------------- doc/src/compute_pressure_spherical.rst | 61 ------------------ 5 files changed, 57 insertions(+), 163 deletions(-) delete mode 100644 doc/src/compute_pressure_cylinder.rst delete mode 100644 doc/src/compute_pressure_spherical.rst diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index d3cd9a367a..71774d555e 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -101,8 +101,8 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`plasticity/atom ` * :doc:`pressure ` * :doc:`pressure/cartesian ` - * :doc:`pressure/cylinder ` - * :doc:`pressure/spherical ` + * :doc:`pressure/cylinder ` + * :doc:`pressure/spherical ` * :doc:`pressure/uef ` * :doc:`property/atom ` * :doc:`property/chunk ` diff --git a/doc/src/compute.rst b/doc/src/compute.rst index f3f22ce422..79ee4f0c73 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -247,8 +247,8 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`plasticity/atom ` - Peridynamic plasticity for each atom * :doc:`pressure ` - total pressure and pressure tensor * :doc:`pressure/cartesian ` - pressure tensor in cartesian coordinates -* :doc:`pressure/cylinder ` - pressure tensor in cylindrical coordinates -* :doc:`pressure/spherical ` - pressure tensor in spherical coordinates +* :doc:`pressure/cylinder ` - pressure tensor in cylindrical coordinates +* :doc:`pressure/spherical ` - pressure tensor in spherical coordinates * :doc:`pressure/uef ` - pressure tensor in the reference frame of an applied flow field * :doc:`property/atom ` - convert atom attributes to per-atom vectors/arrays * :doc:`property/chunk ` - extract various per-chunk attributes diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_pressure_cartesian.rst index 797f658a77..2a3abe3f83 100644 --- a/doc/src/compute_pressure_cartesian.rst +++ b/doc/src/compute_pressure_cartesian.rst @@ -1,20 +1,44 @@ .. index:: compute pressure/cartesian +.. index:: compute pressure/cylinder +.. index:: compute pressure/spherical + compute pressure/cartesian command ================================== +compute pressure/cylinder command +================================= + +compute pressure/spherical command +================================== + Syntax """""" .. parsed-literal:: - compute ID group-ID pressure/cartesian dim bin_width + compute ID group-ID style args * ID, group-ID are documented in :doc:`compute ` command -* pressure/cartesian = style name of this compute command -* one or two dim/bin_width pairs may be appended -* dim = x, y, or z -* bin_width = width of the bin +* style = pressure/cartesian or pressure/spherical or pressure/cylinder +* args = argument specific to the compute style + +.. parsed-literal:: + + *pressure/cartesian* args = dim bin_width + dim = x, y, or z. One or two dim/bin_width pairs may be appended + bin_width = width of the bin + *pressure/cylinder* args = zlo zh Rmax bin_width keyword + zlo = minimum z-boundary for cylinder + zhi = maximum z-boundary for cylinder + Rmax = maximum radius to perform calculation to + bin_width = width of radial bins to use for calculation + keyword = ke (zero or one can be specified) + ke = yes or no + *pressure/spherical* + x0, y0, z0 = origin of the spherical coordinate system + bin_width = width of spherical shells + Rmax = maximum radius of spherical shells Examples """""""" @@ -23,41 +47,60 @@ Examples compute 1 all pressure/cartesian x 0.1 compute 1 all pressure/cartesian y 0.25 z 0.1 + compute 1 all pressure/cylinder -10.0 10.0 15.0 0.25 + compute 1 all pressure/cylinder -10.0 10.0 15.0 0.25 ke no + compute 1 all pressure/spherical 0 0 0 0.1 10 Description """"""""""" -This computes the Cartesian pressure tensor in one or two dimensions, as described in :ref:`(Ikeshoji)`. This can for example be used to calculate the local pressure tensor of flat liquid-vapor interfaces. This compute obeys momentum balance, such that the pressure tensor component normal to a surface is constant. This compute uses the Irving-Kirkwood contour, which is the straight line between particle pairs. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the total pressure tensor :math:`P = P^k+P^v`. +Compute *pressure/cartesian*, compute *pressure/cylinder*, and compute *pressure/spherical* define computations that calculate profiles of the diagonal components of the local pressure tensor in the specified coordiante system. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the total pressure tensor :math:`P = P^k+P^v`. These computes can for example be used to calculate the diagonal components of the local pressure tensor of interfaces with flat, cylindrical, or spherical symmetry. These computes obeys momentum balance through fluid interfaces. These computes uses the Irving-Kirkwood contour, which is the straight line between particle pairs. + +The *pressure/cartesian* computes the pressure profile along one or two Cartesian corodinates, as described in :ref:`(Ikeshoji)`. The compute *pressure/cylinder* computes the pressure profile along the radial direction in cylindrical coordinates, as described in :ref:`(Addington)`. The compute *pressure/spherical* computes the pressure profile along the radial direction in spherical coordinates, as described in :ref:`(Ikeshoji)`. + Output info """"""""""" -The output is a global array with 8 columns when only one dimension is specified and 9 columns when two dimensions are specified. There are (L1*L2)/(bin_width1*bin_width2) rows, where L1 and L2 are the size of the simulation box in the relevant dimensions. The output columns are position of the center of the local volume in the first and second dimension (when two dimensions are specified), number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. +The output columns for *pressure/cartesian* are: position of the center of the local volume in the first and second dimensions, local number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. There are 8 columns when one dimension is specified and 9 columns when two dimensions are specified. The number of bins/rows are (L1/bin_width1)*(L2/bin_width2), L1 and L2 are the size of the simulation box in the specified dimensions, and bin_widt1 and bin_width2 are the specified bin widths. When only one dimension is specified the number of bins/rows are L1/bin_width. -This array can be output with the :doc:`fix ave/time `, +The default output columns for *pressure/cylinder* are: position of the center of the local volume, local number density, :math:`P^k_{rr}`, :math:`P^k_{\phi\phi}`, :math:`P^k_{zz}`, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, and :math:`P^v_{zz}`. When the keyword *ke* is set to no, the kinetic contributions are not calculated and consequently there are only 5 columns: radius to the center of the cylindrical shell, number density, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, :math:`P^v_{zz}`. The number of bins/rows are Rmax/bin_width. + +The output columns for *pressure/spherical* are: radius to the center of the spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. There are 8 columns and the number of bins/rows are Rmax/bin_width. + +This array can be output with :doc:`fix ave/time `, .. code-block:: LAMMPS compute p all pressure/cartesian x 0.1 fix 2 all ave/time 100 1 100 c_p[*] file dump_p.out mode vector +The values calculated by this compute are "intensive". The pressure values will be in pressure :doc:`units `. The number density values are in inverse volume :doc:`units `. + + Restrictions """""""""""" +This compute currently calculates the pressure tensor contributions for pair styles only (i.e. no bond, angle, dihedral, etc. contributions and in the presence of bonded interactions, the result will be incorrect due to exclusions for special bonds) and requires pairwise force calculations not available for most many-body pair styles. K-space calculations are also excluded. + This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. Related commands """""""""""""""" -:doc:`compute stress/atom `, :doc:`compute pressure/cylinder `, :doc:`compute pressure/spherical ` +:doc:`compute stress/atom `, :doc:`compute pressure `, :doc:`compute stress/mop ` Default """"""" -none +The keyword default for ke in style *pressure/cylinder* is yes. ---------- .. _Ikeshoji2: **(Ikeshoji)** Ikeshoji, Hafskjold, Furuholt, Mol Sim, 29, 101-109, (2003). + +.. _Addington1: + +**(Addington)** Addington, Long, Gubbins, J Chem Phys, 149, 084109 (2018). diff --git a/doc/src/compute_pressure_cylinder.rst b/doc/src/compute_pressure_cylinder.rst deleted file mode 100644 index 9913ef159b..0000000000 --- a/doc/src/compute_pressure_cylinder.rst +++ /dev/null @@ -1,88 +0,0 @@ -.. index:: compute pressure/cylinder - -compute pressure/cylinder command -================================= - -Syntax -"""""" - -.. parsed-literal:: - - compute ID group-ID pressure/cylinder zlo zhi Rmax bin_width - -* ID, group-ID are documented in :doc:`compute ` command -* pressure/cylinder = style name of this compute command -* zlo = minimum z-boundary for cylinder -* zhi = maximum z-boundary for cylinder -* Rmax = maximum radius to perform calculation to -* bin_width = width of radial bins to use for calculation - -Examples -"""""""" - -.. code-block:: LAMMPS - - compute 1 all pressure/cylinder -10.0 10.0 15.0 0.25 - -Description -""""""""""" - -Define a computation that calculates the pressure tensor of a system in -cylindrical coordinates, as discussed in :ref:`(Addington) `. -This is useful for systems with a single axis of rotational symmetry, -such as cylindrical micelles or carbon nanotubes. The compute splits the -system into radial, cylindrical-shell-type bins of width bin_width, -centered at x=0,y=0, and calculates the radial (P_rhorho), azimuthal -(P_phiphi), and axial (P_zz) components of the configurational pressure -tensor. The local density is also calculated for each bin, so that the -true pressure can be recovered as P_kin+P_conf=density\*k\*T+P_conf. The -output is a global array with 5 columns; one each for bin radius, local -number density, P_rhorho, P_phiphi, and P_zz. The number of rows is -governed by the values of Rmax and bin_width. Pressure tensor values are -output in pressure units. - -Output info -""""""""""" - -This compute calculates a global array with 5 columns and Rmax/bin_width -rows. The output columns are: R (distance units), number density (inverse -volume units), configurational radial pressure (pressure units), -configurational azimuthal pressure (pressure units), and configurational -axial pressure (pressure units). - -The values calculated by this compute are -"intensive". The pressure values will be in pressure -:doc:`units `. The number density values will be in -inverse volume :doc:`units `. - -Restrictions -"""""""""""" - -This compute currently calculates the pressure tensor contributions -for pair styles only (i.e. no bond, angle, dihedral, etc. contributions -and in the presence of bonded interactions, the result will be incorrect -due to exclusions for special bonds) and requires pairwise force -calculations not available for most many-body pair styles. K-space -calculations are also excluded. Note that this pressure compute outputs -the configurational terms only; the kinetic contribution is not included -and may be calculated from the number density output by P_kin=density\*k\*T. - -This compute is part of the EXTRA-COMPUTE package. It is only enabled -if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. - -Related commands -"""""""""""""""" - -:doc:`compute temp `, :doc:`compute stress/atom `, -:doc:`thermo_style `, - -Default -""""""" - -none - ----------- - -.. _Addington1: - -**(Addington)** Addington, Long, Gubbins, J Chem Phys, 149, 084109 (2018). diff --git a/doc/src/compute_pressure_spherical.rst b/doc/src/compute_pressure_spherical.rst deleted file mode 100644 index 578153583b..0000000000 --- a/doc/src/compute_pressure_spherical.rst +++ /dev/null @@ -1,61 +0,0 @@ -.. index:: compute pressure/spherical - -compute pressure/spherical command -================================== - -Syntax -"""""" - -.. parsed-literal:: - - compute ID group-ID pressure/spherical x0 y0 z0 bin_width Rmax - -* ID, group-ID are documented in :doc:`compute ` command -* pressure/cartesian = style name of this compute command -* x0, y0, z0 = origin of the spherical coordinate system -* bin_width = width of spherical shells -* Rmax = maximum radius of spherical shells - -Examples -"""""""" - -.. code-block:: LAMMPS - - compute 1 all pressure/spherical 0 0 0 0.1 10 - -Description -""""""""""" - -This computes the diagonal components of the spherical pressure tensor in spherical shells, as described in :ref:`(Ikeshoji)`. This can be used to calculate the local pressure tensor components of for example droplets and bubbles. This compute obeys momentum balance. This compute uses the Irving-Kirkwood contour, whici is the straight line between particle pairs. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the pressure :math:`P = P^k+P^v`. - -Output info -""""""""""" - -This compute outputs a global array with 8 columns and Rmax/bin_width. The output columns are position of the center of the local spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. - -This array can be output with :doc:`fix ave/time `, - -.. code-block:: LAMMPS - - compute p all pressure/spherical 0 0 0 0.1 10 - fix 2 all ave/time 100 1 100 c_p[*] file dump_p.out mode vector - -Restrictions -"""""""""""" - -This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. - -Related commands -"""""""""""""""" - -:doc:`compute stress/atom `, :doc:`compute pressure/cylinder `, :doc:`compute pressure/cartesian ` - -Default -""""""" - -none - ----------- - -.. _Ikeshoji3: -**(Ikeshoji)** Ikeshoji, Hafskjold, Furuholt, Mol Sim, 29, 101-109, (2003). From 089e46a5409d957ed9d554d33b16d67e2d350b72 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Sat, 5 Mar 2022 16:29:42 +0100 Subject: [PATCH 51/72] Fixed some gramma --- doc/src/compute_pressure_cartesian.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_pressure_cartesian.rst index 2a3abe3f83..2301bbd78f 100644 --- a/doc/src/compute_pressure_cartesian.rst +++ b/doc/src/compute_pressure_cartesian.rst @@ -54,19 +54,19 @@ Examples Description """"""""""" -Compute *pressure/cartesian*, compute *pressure/cylinder*, and compute *pressure/spherical* define computations that calculate profiles of the diagonal components of the local pressure tensor in the specified coordiante system. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the total pressure tensor :math:`P = P^k+P^v`. These computes can for example be used to calculate the diagonal components of the local pressure tensor of interfaces with flat, cylindrical, or spherical symmetry. These computes obeys momentum balance through fluid interfaces. These computes uses the Irving-Kirkwood contour, which is the straight line between particle pairs. +Compute *pressure/cartesian*, compute *pressure/cylinder*, and compute *pressure/spherical* define computations that calculate profiles of the diagonal components of the local pressure tensor in the specified coordinate system. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the total pressure tensor :math:`P = P^k+P^v`. These computes can for example be used to calculate the diagonal components of the local pressure tensor of interfaces with flat, cylindrical, or spherical symmetry. These computes obeys momentum balance through fluid interfaces. They use the Irving-Kirkwood contour, which is the straight line between particle pairs. -The *pressure/cartesian* computes the pressure profile along one or two Cartesian corodinates, as described in :ref:`(Ikeshoji)`. The compute *pressure/cylinder* computes the pressure profile along the radial direction in cylindrical coordinates, as described in :ref:`(Addington)`. The compute *pressure/spherical* computes the pressure profile along the radial direction in spherical coordinates, as described in :ref:`(Ikeshoji)`. +The *pressure/cartesian* computes the pressure profile along one or two Cartesian coordinates, as described in :ref:`(Ikeshoji)`. The compute *pressure/cylinder* computes the pressure profile along the radial direction in cylindrical coordinates, as described in :ref:`(Addington)`. The compute *pressure/spherical* computes the pressure profile along the radial direction in spherical coordinates, as described in :ref:`(Ikeshoji)`. Output info """"""""""" -The output columns for *pressure/cartesian* are: position of the center of the local volume in the first and second dimensions, local number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. There are 8 columns when one dimension is specified and 9 columns when two dimensions are specified. The number of bins/rows are (L1/bin_width1)*(L2/bin_width2), L1 and L2 are the size of the simulation box in the specified dimensions, and bin_widt1 and bin_width2 are the specified bin widths. When only one dimension is specified the number of bins/rows are L1/bin_width. +The output columns for *pressure/cartesian* are the position of the center of the local volume in the first and second dimensions, number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. There are 8 columns when one dimension is specified and 9 columns when two dimensions are specified. The number of bins/rows are (L1/bin_width1)*(L2/bin_width2), L1 and L2 are the sizes of the simulation box in the specified dimensions, and bin_widt1 and bin_width2 are the specified bin widths. When only one dimension is specified the number of bins/rows are L1/bin_width. -The default output columns for *pressure/cylinder* are: position of the center of the local volume, local number density, :math:`P^k_{rr}`, :math:`P^k_{\phi\phi}`, :math:`P^k_{zz}`, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, and :math:`P^v_{zz}`. When the keyword *ke* is set to no, the kinetic contributions are not calculated and consequently there are only 5 columns: radius to the center of the cylindrical shell, number density, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, :math:`P^v_{zz}`. The number of bins/rows are Rmax/bin_width. +The default output columns for *pressure/cylinder* are the radius to the center of the cylindrical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\phi\phi}`, :math:`P^k_{zz}`, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, and :math:`P^v_{zz}`. When the keyword *ke* is set to no, the kinetic contributions are not calculated, and consequently there are only 5 columns the radius to the center of the cylindrical shell, number density, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, :math:`P^v_{zz}`. The number of bins/rows are Rmax/bin_width. -The output columns for *pressure/spherical* are: radius to the center of the spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. There are 8 columns and the number of bins/rows are Rmax/bin_width. +The output columns for *pressure/spherical* are the radius to the center of the spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. There are 8 columns and the number of bins/rows are Rmax/bin_width. This array can be output with :doc:`fix ave/time `, @@ -81,7 +81,7 @@ The values calculated by this compute are "intensive". The pressure values will Restrictions """""""""""" -This compute currently calculates the pressure tensor contributions for pair styles only (i.e. no bond, angle, dihedral, etc. contributions and in the presence of bonded interactions, the result will be incorrect due to exclusions for special bonds) and requires pairwise force calculations not available for most many-body pair styles. K-space calculations are also excluded. +These computes calculate the pressure tensor contributions for pair styles only (i.e. no bond, angle, dihedral, etc. contributions, and in the presence of bonded interactions, the result will be incorrect due to exclusions for special bonds) and requires pairwise force calculations not available for most many-body pair styles. K-space calculations are also excluded. This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. From 99d29ea86a9e662ddcd69e318726d465ca0acc9c Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Sat, 5 Mar 2022 16:30:47 +0100 Subject: [PATCH 52/72] Added kinetic contribution to pressure/cylinder and clang-format on all --- .../compute_pressure_cartesian.cpp | 24 +- .../compute_pressure_cartesian.h | 10 +- .../compute_pressure_cylinder.cpp | 206 ++++++++++++------ src/EXTRA-COMPUTE/compute_pressure_cylinder.h | 5 +- .../compute_pressure_spherical.cpp | 24 +- .../compute_pressure_spherical.h | 12 +- 6 files changed, 178 insertions(+), 103 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index 6d28bb75fc..999eeba254 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -39,17 +39,18 @@ using namespace MathConst; ------------------------------------------------------------------------------------*/ static const char cite_compute_pressure_cartesian[] = - "compute pressure/cartesian:\n\n" - "@article{ikeshoji2003molecular,\n" - "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" - "journal={Molecular Simulation},\n" - "volume={29},\n" - "number={2},\n" - "pages={101--109},\n" - "year={2003},\n" - "publisher={Taylor & Francis}\n" - "}\n\n"; + "compute pressure/cartesian:\n\n" + "@article{ikeshoji2003molecular,\n" + "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and " + "spherical layers},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" + "journal={Molecular Simulation},\n" + "volume={29},\n" + "number={2},\n" + "pages={101--109},\n" + "year={2003},\n" + "publisher={Taylor & Francis}\n" + "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ @@ -247,7 +248,6 @@ void ComputePressureCartesian::compute_array() j = bin1 + bin2 * nbins1; tdens[j] += 1; - // TODO: Subtract streaming velocity tpkxx[j] += mass[type[i]] * v[i][0] * v[i][0]; tpkyy[j] += mass[type[i]] * v[i][1] * v[i][1]; tpkzz[j] += mass[type[i]] * v[i][2] * v[i][2]; diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h index 6b58f73897..eaef900239 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.h @@ -27,11 +27,11 @@ namespace LAMMPS_NS { class ComputePressureCartesian : public Compute { public: ComputePressureCartesian(class LAMMPS *, int, char **); - ~ComputePressureCartesian(); - void init(); - void init_list(int, class NeighList *); - void compute_array(); - double memory_usage(); + ~ComputePressureCartesian() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_array() override; + double memory_usage() override; private: int nbins1, nbins2, dir1, dir2, dims; diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp b/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp index b124e14647..13efd5c68d 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp @@ -20,6 +20,7 @@ #include "force.h" #include "math_const.h" #include "memory.h" +#include "modify.h" #include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" @@ -27,10 +28,19 @@ #include "update.h" #include +#include +#include using namespace LAMMPS_NS; using namespace MathConst; +/*----------------------------------------------------------------------------------- + Contributing authors: Cody K. Addington (North Carolina State University) + (Kinetic contribution) : Olav Galteland, + (Norwegian University of Science and Technology), + olav.galteland@ntnu.no +------------------------------------------------------------------------------------*/ + static const char cite_compute_pressure_cylinder[] = "compute pressure/cylinder:\n\n" "@Article{Addington,\n" @@ -48,19 +58,32 @@ static const char cite_compute_pressure_cylinder[] = +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), Pvr_temp(nullptr), Pvr_all(nullptr), Pvz_temp(nullptr), Pvz_all(nullptr), - Pvphi_temp(nullptr), Pvphi_all(nullptr), R(nullptr), Rinv(nullptr), R2(nullptr), PrAinv(nullptr), - PzAinv(nullptr), R2kin(nullptr), density_temp(nullptr), invVbin(nullptr), density_all(nullptr), - tangent(nullptr), ephi_x(nullptr), ephi_y(nullptr), binz(nullptr) + Compute(lmp, narg, arg), Pvr_temp(nullptr), Pvr_all(nullptr), Pvz_temp(nullptr), + Pvz_all(nullptr), Pvphi_temp(nullptr), Pvphi_all(nullptr), R(nullptr), Rinv(nullptr), + R2(nullptr), PrAinv(nullptr), PzAinv(nullptr), R2kin(nullptr), density_temp(nullptr), + invVbin(nullptr), density_all(nullptr), tangent(nullptr), ephi_x(nullptr), ephi_y(nullptr), + binz(nullptr) { if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_cylinder); - if (narg != 7) error->all(FLERR, "Illegal compute pressure/cylinder command"); + if ((narg != 7) && (narg != 9)) error->all(FLERR, "Illegal compute pressure/cylinder command"); zlo = utils::numeric(FLERR, arg[3], false, lmp); zhi = utils::numeric(FLERR, arg[4], false, lmp); Rmax = utils::numeric(FLERR, arg[5], false, lmp); bin_width = utils::numeric(FLERR, arg[6], false, lmp); + // Option to include/exclude kinetic contribution. Default is to include + kinetic_flag = 1; + int iarg = 7; + if (narg > iarg) { + if (strcmp("ke", arg[iarg]) == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Invalid compute pressure/cylinder command"); + kinetic_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); + iarg += 2; + } else + error->all(FLERR, "Unknown compute pressure/cylinder command"); + } + if ((bin_width <= 0.0) || (bin_width > Rmax)) error->all(FLERR, "Illegal compute pressure/cylinder command"); if ((zhi < zlo) || ((zhi - zlo) < bin_width)) @@ -80,39 +103,44 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : array_flag = 1; vector_flag = 0; extarray = 0; - size_array_cols = 8; // r, number density, pkr, pkphi, pkz, pvr, pvphi, pz + size_array_cols = 5; // r, number density, pvr, pvphi, pz size_array_rows = nbins; - - memory->create(density_all, nbins, "density_all"); - memory->create(Pkr_all, nbins, "Pkr_all"); - memory->create(Pkphi_all, nbins, "Pkphi_all"); - memory->create(Pkz_all, nbins, "Pkz_all"); - memory->create(Pvr_all, nbins, "Pvr_all"); - memory->create(Pvphi_all, nbins, "Pvphi_all"); - memory->create(Pvz_all, nbins, "Pvz_all"); - memory->create(density_temp, nbins, "density_temp"); - memory->create(Pkr_temp, nbins, "Pkr_temp"); - memory->create(Pkphi_temp, nbins, "Pkphi_temp"); - memory->create(Pkz_temp, nbins, "Pkz_temp"); - memory->create(Pvr_temp, nbins, "Pvr_temp"); - memory->create(Pvphi_temp, nbins, "Pvphi_temp"); - memory->create(Pvz_temp, nbins, "Pvz_temp"); - memory->create(R,nbins, "R"); - memory->create(R2,nbins, "R2"); - memory->create(PrAinv,nbins, "PrAinv"); - memory->create(PzAinv,nbins, "PzAinv"); - memory->create(Rinv,nbins, "Rinv"); - memory->create(binz,nbins, "binz"); - memory->create(invVbin,nbins, "invVbin"); + + if (kinetic_flag == 1) { + size_array_cols = 8; // r, number density, pkr, pkphi, pkz, pvr, pvphi, pz + Pkr_temp = new double[nbins]; + Pkr_all = new double[nbins]; + Pkz_temp = new double[nbins]; + Pkz_all = new double[nbins]; + Pkphi_temp = new double[nbins]; + Pkphi_all = new double[nbins]; + } + Pvr_temp = new double[nbins]; + Pvr_all = new double[nbins]; + Pvz_temp = new double[nbins]; + Pvz_all = new double[nbins]; + Pvphi_temp = new double[nbins]; + Pvphi_all = new double[nbins]; + R = new double[nbins]; + R2 = new double[nbins]; + PrAinv = new double[nbins]; + PzAinv = new double[nbins]; + Rinv = new double[nbins]; + binz = new double[nzbins]; + + R2kin = new double[nbins]; + density_temp = new double[nbins]; + invVbin = new double[nbins]; + density_all = new double[nbins]; nphi = 360; - memory->create(tangent,nbins, "tangent"); - memory->create(ephi_x,nbins, "ephi_x"); - memory->create(ephi_y,nbins, "ephi_y"); - memory->create(array, nbins, 5, "PN:array"); + tangent = new double[nphi]; + ephi_x = new double[nphi]; + ephi_y = new double[nphi]; + + memory->create(array, size_array_rows, size_array_cols, "PN:array"); nktv2p = force->nktv2p; - printf("Constructor done"); } /* ---------------------------------------------------------------------- */ @@ -120,31 +148,33 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : ComputePressureCyl::~ComputePressureCyl() { memory->destroy(array); - memory->destroy(density_all); - memory->destroy(Pkr_all); - memory->destroy(Pkphi_all); - memory->destroy(Pkz_all); - memory->destroy(Pvr_all); - memory->destroy(Pvphi_all); - memory->destroy(Pvz_all); - memory->destroy(density_temp); - memory->destroy(Pkr_temp); - memory->destroy(Pkphi_temp); - memory->destroy(Pkz_temp); - memory->destroy(Pvr_temp); - memory->destroy(Pvphi_temp); - memory->destroy(Pvz_temp); - memory->destroy(R); - memory->destroy(R2); - memory->destroy(PrAinv); - memory->destroy(PzAinv); - memory->destroy(Rinv); - memory->destroy(binz); - memory->destroy(invVbin); - memory->destroy(tangent); - memory->destroy(ephi_x); - memory->destroy(ephi_y); - memory->destroy(array); + if (kinetic_flag == 1) { + delete[] Pkr_temp; + delete[] Pkr_all; + delete[] Pkz_temp; + delete[] Pkz_all; + delete[] Pkphi_temp; + delete[] Pkphi_all; + } + delete[] R; + delete[] Rinv; + delete[] R2; + delete[] R2kin; + delete[] invVbin; + delete[] density_temp; + delete[] density_all; + delete[] tangent; + delete[] ephi_x; + delete[] ephi_y; + delete[] Pvr_temp; + delete[] Pvr_all; + delete[] Pvz_temp; + delete[] Pvz_all; + delete[] Pvphi_temp; + delete[] Pvphi_all; + delete[] PrAinv; + delete[] PzAinv; + delete[] binz; } /* ---------------------------------------------------------------------- */ @@ -157,14 +187,12 @@ void ComputePressureCyl::init() error->all(FLERR, "Pair style does not support compute pressure/cylinder"); double phi; - for (int iphi = 0; iphi < nphi; iphi++) { phi = ((double) iphi) * MY_PI / 180.0; tangent[iphi] = tan(phi); ephi_x[iphi] = -sin(phi); ephi_y[iphi] = cos(phi); } - for (int iq = 0; iq < nbins; iq++) { R[iq] = ((double) iq + 0.5) * bin_width; Rinv[iq] = 1.0 / R[iq]; @@ -213,9 +241,16 @@ void ComputePressureCyl::compute_array() invoked_array = update->ntimestep; int ibin; - // clear pressures for (ibin = 0; ibin < nbins; ibin++) { + if (kinetic_flag == 1) { + Pkr_temp[ibin] = 0.0; + Pkr_all[ibin] = 0.0; + Pkphi_temp[ibin] = 0.0; + Pkphi_all[ibin] = 0.0; + Pkz_temp[ibin] = 0.0; + Pkz_all[ibin] = 0.0; + } density_temp[ibin] = 0.0; density_all[ibin] = 0.0; Pvr_temp[ibin] = 0.0; @@ -236,7 +271,10 @@ void ComputePressureCyl::compute_array() double rsq, fpair, factor_coul, factor_lj; int *ilist, *jlist, *numneigh, **firstneigh; + double vr, vp; double **x = atom->x; + double **v = atom->v; + double *mass = atom->mass; tagint *tag = atom->tag; int *type = atom->type; int *mask = atom->mask; @@ -253,7 +291,7 @@ void ComputePressureCyl::compute_array() numneigh = list->numneigh; firstneigh = list->firstneigh; - // calculate number density (by radius) + // calculate number density and kinetic contribution (by radius) double temp_R2; for (i = 0; i < nlocal; i++) if ((x[i][2] < zhi) && (x[i][2] > zlo)) { @@ -264,6 +302,21 @@ void ComputePressureCyl::compute_array() if (temp_R2 < R2kin[j]) break; density_temp[j] += invVbin[j]; + + // Check if kinetic option is set to yes + if (kinetic_flag == 1) { + if (temp_R2 != 0) { + // Radial velocity times R + vr = (x[i][0] * v[i][0] + x[i][1] * v[i][1]); + // Azimuthal velocity divided by R + vp = (v[i][1] / x[i][0] - x[i][1] * v[i][0] / (x[i][0] * x[i][0])) / + (pow(x[i][1] / x[i][0], 2.0) + 1.0); + + Pkr_temp[j] += mass[type[i]] * vr * vr / temp_R2; + Pkphi_temp[j] += mass[type[i]] * temp_R2 * vp * vp; + Pkz_temp[j] += mass[type[i]] * v[i][2] * v[i][2]; + } + } } MPI_Allreduce(density_temp, density_all, nbins, MPI_DOUBLE, MPI_SUM, world); for (i = 0; i < nbins; i++) array[i][1] = density_all[i]; // NEW @@ -459,12 +512,22 @@ void ComputePressureCyl::compute_array() // calculate pressure (force over area) for (ibin = 0; ibin < nbins; ibin++) { + if (kinetic_flag == 1) { + Pkr_temp[ibin] *= invVbin[ibin]; + Pkphi_temp[ibin] *= invVbin[ibin]; + Pkz_temp[ibin] *= invVbin[ibin]; + } Pvr_temp[ibin] *= PrAinv[ibin] * Rinv[ibin]; Pvphi_temp[ibin] *= PphiAinv; Pvz_temp[ibin] *= PzAinv[ibin]; } // communicate these values across processors + if (kinetic_flag == 1) { + MPI_Allreduce(Pkr_temp, Pkr_all, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(Pkphi_temp, Pkphi_all, nbins, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce(Pkz_temp, Pkz_all, nbins, MPI_DOUBLE, MPI_SUM, world); + } MPI_Allreduce(Pvr_temp, Pvr_all, nbins, MPI_DOUBLE, MPI_SUM, world); MPI_Allreduce(Pvphi_temp, Pvphi_all, nbins, MPI_DOUBLE, MPI_SUM, world); MPI_Allreduce(Pvz_temp, Pvz_all, nbins, MPI_DOUBLE, MPI_SUM, world); @@ -472,19 +535,28 @@ void ComputePressureCyl::compute_array() // populate array for (ibin = 0; ibin < nbins; ibin++) { array[ibin][0] = R[ibin]; - array[ibin][2] = Pvr_all[ibin] * nktv2p; - array[ibin][3] = Pvphi_all[ibin] * nktv2p; - array[ibin][4] = Pvz_all[ibin] * nktv2p; + if (kinetic_flag == 1) { + array[ibin][2] = Pkr_all[ibin] * nktv2p; + array[ibin][3] = Pkphi_all[ibin] * nktv2p; + array[ibin][4] = Pkz_all[ibin] * nktv2p; + array[ibin][5] = Pvr_all[ibin] * nktv2p; + array[ibin][6] = Pvphi_all[ibin] * nktv2p; + array[ibin][7] = Pvz_all[ibin] * nktv2p; + } else { + array[ibin][2] = Pvr_all[ibin] * nktv2p; + array[ibin][3] = Pvphi_all[ibin] * nktv2p; + array[ibin][4] = Pvz_all[ibin] * nktv2p; + } } } /* ---------------------------------------------------------------------- memory usage of data ------------------------------------------------------------------------- */ -// TODO: update this double ComputePressureCyl::memory_usage() { double bytes = - (3.0 * (double) nphi + 16.0 * (double) nbins + 5.0 * (double) nbins) * sizeof(double); + (3.0 * (double) nphi + 16.0 * (double) nbins + (5.0 + 3.0 * kinetic_flag) * (double) nbins) * + sizeof(double); return bytes; } diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.h b/src/EXTRA-COMPUTE/compute_pressure_cylinder.h index 2f8a1b7804..48f04b0c34 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.h +++ b/src/EXTRA-COMPUTE/compute_pressure_cylinder.h @@ -17,8 +17,8 @@ ComputeStyle(pressure/cylinder,ComputePressureCyl); // clang-format on #else -#ifndef LMP_COMPUTE_PRESSURE_CYLINDER -#define LMP_COMPUTE_PRESSURE_CYLINDER +#ifndef LMP_COMPUTE_PRESSURE_CYLINDER_H +#define LMP_COMPUTE_PRESSURE_CYLINDER_H #include "compute.h" @@ -34,6 +34,7 @@ class ComputePressureCyl : public Compute { double memory_usage() override; private: + int kinetic_flag; int nbins, nphi, nzbins; double *Pvr_temp, *Pvr_all, *Pvz_temp, *Pvz_all, *Pvphi_temp, *Pvphi_all; double *Pkr_temp, *Pkr_all, *Pkz_temp, *Pkz_all, *Pkphi_temp, *Pkphi_all; diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index 132d97082d..3126af1368 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -40,17 +40,18 @@ using namespace MathConst; ------------------------------------------------------------------------------------*/ static const char cite_compute_pressure_sphere[] = - "compute pressure/spherical:\n\n" - "@article{ikeshoji2003molecular,\n" - "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" - "journal={Molecular Simulation},\n" - "volume={29},\n" - "number={2},\n" - "pages={101--109},\n" - "year={2003},\n" - "publisher={Taylor & Francis}\n" - "}\n\n"; + "compute pressure/spherical:\n\n" + "@article{ikeshoji2003molecular,\n" + "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and " + "spherical layers},\n" + "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" + "journal={Molecular Simulation},\n" + "volume={29},\n" + "number={2},\n" + "pages={101--109},\n" + "year={2003},\n" + "publisher={Taylor & Francis}\n" + "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ @@ -130,6 +131,7 @@ void ComputePressureSpherical::init() if (force->pair->single_enable == 0) error->all(FLERR, "Pair style does not support compute pressure/spherical"); + // Inverse volume of each spherical shell (bin) for (int bin = 0; bin < nbins; bin++) invV[bin] = 3.0 / (4.0 * MY_PI * (pow((bin + 1) * bin_width, 3.0) - pow(bin * bin_width, 3.0))); diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_pressure_spherical.h index 78d38b327e..3f996a94ca 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.h +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.h @@ -27,16 +27,16 @@ namespace LAMMPS_NS { class ComputePressureSpherical : public Compute { public: ComputePressureSpherical(class LAMMPS *, int, char **); - ~ComputePressureSpherical(); - void init(); - void init_list(int, class NeighList *); - void compute_array(); - double memory_usage(); + ~ComputePressureSpherical() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_array() override; + double memory_usage() override; private: int nbins; double bin_width, x0, y0, z0, Rmax; - + // Number density, kinetic and configurational contribution to the pressure. double *invV, *dens, *pkrr, *pktt, *pkpp, *pcrr, *pctt, *pcpp; double *tdens, *tpkrr, *tpktt, *tpkpp, *tpcrr, *tpctt, *tpcpp; From 9a9881756736482550742283c345dc607a06aac9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 11:35:37 -0500 Subject: [PATCH 53/72] reformat doc page and address spelling issues --- doc/src/compute_pressure_cartesian.rst | 62 ++++++++++++++++++--- doc/utils/sphinx-config/false_positives.txt | 2 + 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_pressure_cartesian.rst index 2301bbd78f..cb5f9e6956 100644 --- a/doc/src/compute_pressure_cartesian.rst +++ b/doc/src/compute_pressure_cartesian.rst @@ -54,19 +54,56 @@ Examples Description """"""""""" -Compute *pressure/cartesian*, compute *pressure/cylinder*, and compute *pressure/spherical* define computations that calculate profiles of the diagonal components of the local pressure tensor in the specified coordinate system. The pressure tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum gives the total pressure tensor :math:`P = P^k+P^v`. These computes can for example be used to calculate the diagonal components of the local pressure tensor of interfaces with flat, cylindrical, or spherical symmetry. These computes obeys momentum balance through fluid interfaces. They use the Irving-Kirkwood contour, which is the straight line between particle pairs. +Compute *pressure/cartesian*, compute *pressure/cylinder*, and compute +*pressure/spherical* define computations that calculate profiles of the +diagonal components of the local pressure tensor in the specified +coordinate system. The pressure tensor is split into a kinetic +contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum +gives the total pressure tensor :math:`P = P^k+P^v`. These computes can +for example be used to calculate the diagonal components of the local +pressure tensor of interfaces with flat, cylindrical, or spherical +symmetry. These computes obeys momentum balance through fluid +interfaces. They use the Irving-Kirkwood contour, which is the straight +line between particle pairs. -The *pressure/cartesian* computes the pressure profile along one or two Cartesian coordinates, as described in :ref:`(Ikeshoji)`. The compute *pressure/cylinder* computes the pressure profile along the radial direction in cylindrical coordinates, as described in :ref:`(Addington)`. The compute *pressure/spherical* computes the pressure profile along the radial direction in spherical coordinates, as described in :ref:`(Ikeshoji)`. +The *pressure/cartesian* computes the pressure profile along one or two +Cartesian coordinates, as described in :ref:`(Ikeshoji)`. The +compute *pressure/cylinder* computes the pressure profile along the +radial direction in cylindrical coordinates, as described in +:ref:`(Addington)`. The compute *pressure/spherical* +computes the pressure profile along the radial direction in spherical +coordinates, as described in :ref:`(Ikeshoji)`. Output info """"""""""" -The output columns for *pressure/cartesian* are the position of the center of the local volume in the first and second dimensions, number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. There are 8 columns when one dimension is specified and 9 columns when two dimensions are specified. The number of bins/rows are (L1/bin_width1)*(L2/bin_width2), L1 and L2 are the sizes of the simulation box in the specified dimensions, and bin_widt1 and bin_width2 are the specified bin widths. When only one dimension is specified the number of bins/rows are L1/bin_width. +The output columns for *pressure/cartesian* are the position of the +center of the local volume in the first and second dimensions, number +density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, +:math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. There are 8 +columns when one dimension is specified and 9 columns when two +dimensions are specified. The number of bins/rows are +(L1/bin_width1)*(L2/bin_width2), L1 and L2 are the sizes of the +simulation box in the specified dimensions, and bin_width1 and +bin_width2 are the specified bin widths. When only one dimension is +specified the number of bins/rows are L1/bin_width. -The default output columns for *pressure/cylinder* are the radius to the center of the cylindrical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\phi\phi}`, :math:`P^k_{zz}`, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, and :math:`P^v_{zz}`. When the keyword *ke* is set to no, the kinetic contributions are not calculated, and consequently there are only 5 columns the radius to the center of the cylindrical shell, number density, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, :math:`P^v_{zz}`. The number of bins/rows are Rmax/bin_width. +The default output columns for *pressure/cylinder* are the radius to the +center of the cylindrical shell, number density, :math:`P^k_{rr}`, +:math:`P^k_{\phi\phi}`, :math:`P^k_{zz}`, :math:`P^v_{rr}`, +:math:`P^v_{\phi\phi}`, and :math:`P^v_{zz}`. When the keyword *ke* is +set to no, the kinetic contributions are not calculated, and +consequently there are only 5 columns the radius to the center of the +cylindrical shell, number density, :math:`P^v_{rr}`, +:math:`P^v_{\phi\phi}`, :math:`P^v_{zz}`. The number of bins/rows are +Rmax/bin_width. -The output columns for *pressure/spherical* are the radius to the center of the spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. There are 8 columns and the number of bins/rows are Rmax/bin_width. +The output columns for *pressure/spherical* are the radius to the center +of the spherical shell, number density, :math:`P^k_{rr}`, +:math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, +:math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. There are 8 +columns and the number of bins/rows are Rmax/bin_width. This array can be output with :doc:`fix ave/time `, @@ -75,15 +112,24 @@ This array can be output with :doc:`fix ave/time `, compute p all pressure/cartesian x 0.1 fix 2 all ave/time 100 1 100 c_p[*] file dump_p.out mode vector -The values calculated by this compute are "intensive". The pressure values will be in pressure :doc:`units `. The number density values are in inverse volume :doc:`units `. +The values calculated by this compute are "intensive". The pressure +values will be in pressure :doc:`units `. The number density +values are in inverse volume :doc:`units `. Restrictions """""""""""" -These computes calculate the pressure tensor contributions for pair styles only (i.e. no bond, angle, dihedral, etc. contributions, and in the presence of bonded interactions, the result will be incorrect due to exclusions for special bonds) and requires pairwise force calculations not available for most many-body pair styles. K-space calculations are also excluded. +These computes calculate the pressure tensor contributions for pair +styles only (i.e. no bond, angle, dihedral, etc. contributions, and in +the presence of bonded interactions, the result will be incorrect due to +exclusions for special bonds) and requires pairwise force calculations +not available for most many-body pair styles. K-space calculations are +also excluded. -This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. +These computes are part of the EXTRA-COMPUTE package. They are only +enabled if LAMMPS was built with that package. See the :doc:`Build +package ` doc page for more info. Related commands """""""""""""""" diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 31e03140f1..e033b9088f 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1112,6 +1112,7 @@ funcs functionalities functionals funroll +Furuholt fx fy fz @@ -1594,6 +1595,7 @@ Ki Kikugawa kim kinetostats +Kirkwood kJ kk Klahn From c24e46c547db11342d3f4d20a3d5fafe54411cc9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 12:30:40 -0500 Subject: [PATCH 54/72] don't apply modulus to doubles but integers --- src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index 999eeba254..3df0e82e3c 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -372,13 +372,13 @@ void ComputePressureCartesian::compute_pressure_1d(double fpair, double xi, doub xj -= (domain->boxhi[dir1] - domain->boxlo[dir1]); // Integrating contour from bin_s to bin_e - bin_s = (int) lround(((xi - domain->boxlo[dir1]) / bin_width1)) % nbins1; - bin_e = (int) lround(((xj - domain->boxlo[dir1]) / bin_width1)) % nbins1; + bin_s = ((int) lround((xi - domain->boxlo[dir1]) / bin_width1)) % nbins1; + bin_e = ((int) lround((xj - domain->boxlo[dir1]) / bin_width1)) % nbins1; // If not periodic in dir1 if (domain->periodicity[dir1] == 0) { - bin_s = (int) lround(((xi - domain->boxlo[dir1]) / bin_width1)); - bin_e = (int) lround(((xj - domain->boxlo[dir1]) / bin_width1)); + bin_s = ((int) lround((xi - domain->boxlo[dir1]) / bin_width1)); + bin_e = ((int) lround((xj - domain->boxlo[dir1]) / bin_width1)); if (bin_e == nbins1) bin_e--; if (bin_s == nbins1) bin_s--; From 43ac557a9b79653857ad9d86ccaf214af274f1fa Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 12:31:36 -0500 Subject: [PATCH 55/72] remove unused headers and dead code. reformat a few small items --- src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp | 15 ++------------- src/EXTRA-COMPUTE/compute_pressure_spherical.cpp | 7 +------ 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index 3df0e82e3c..e86e9de9c3 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -18,7 +18,6 @@ #include "domain.h" #include "error.h" #include "force.h" -#include "math_const.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" @@ -28,10 +27,8 @@ #include #include -#include using namespace LAMMPS_NS; -using namespace MathConst; /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) @@ -90,9 +87,7 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * if (bin_width1 <= 0.0) error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); else if (bin_width1 > domain->boxhi[dir1] - domain->boxlo[dir1]) - error->all( - FLERR, - "Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); + error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width larger than box."); if (dims == 2) { if (strcmp(arg[5], "x") == 0) @@ -111,9 +106,7 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * if (bin_width2 <= 0.0) error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); else if (bin_width2 > domain->boxhi[dir2] - domain->boxlo[dir2]) - error->all( - FLERR, - "Illegal compute pressure/cartesian command. Bin width must be smaller than box size."); + error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width larger than box"); } for (int i = 0; i < 3; i++) @@ -199,10 +192,6 @@ void ComputePressureCartesian::init_list(int /* id */, NeighList *ptr) void ComputePressureCartesian::compute_array() { - //invoked_array = update->ntimestep; - int me; - MPI_Comm_rank(world, &me); - int i, j, ii, jj, inum, jnum, itype, jtype; int bin, bin1, bin2, bin3; tagint itag, jtag; diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index 3126af1368..a261c10270 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -29,7 +29,6 @@ #include #include -#include using namespace LAMMPS_NS; using namespace MathConst; @@ -161,8 +160,6 @@ void ComputePressureSpherical::compute_array() { invoked_array = update->ntimestep; - int me; - MPI_Comm_rank(world, &me); int bin; // Zero arrays for (int bin = 0; bin < nbins; bin++) { @@ -372,9 +369,7 @@ void ComputePressureSpherical::compute_array() // Error check if (fabs(l_sum - 1.0) > SMALL) - error->all(FLERR, - "ERROR: The sum of the fractional line segments, calculated in spherical " - "pressure tensor, does not sum up to 1."); + error->all(FLERR, "ERROR: The sum of the fractional line segments is not 1.0"); } } From 15fa6049f27cd0b655d132edbabc6a103b81cf1a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 12:33:54 -0500 Subject: [PATCH 56/72] update comments --- src/EXTRA-COMPUTE/compute_pressure_spherical.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_pressure_spherical.h index 3f996a94ca..17de44a5a6 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.h +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.h @@ -56,13 +56,13 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: No pair style is defined for compute pressure/cartesian +E: No pair style is defined for compute pressure/spherical Self-explanatory. -E: Pair style does not support compute pressure/cartesian +E: Pair style does not support compute pressure/spherical The pair style does not have a single() function, so it can -not be invoked by compute pressure/cartesian. +not be invoked by compute pressure/spherical */ From ece25a95ad213ee49f765bf26d8a4cb6562fbacf Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 13:46:56 -0500 Subject: [PATCH 57/72] stability improvements: recompute bin width for perfect match, don't test for floating point identity --- .../compute_pressure_cartesian.cpp | 22 +++++++--- .../compute_pressure_spherical.cpp | 44 ++++++++++++------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index e86e9de9c3..a18c16eb12 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -15,6 +15,7 @@ #include "atom.h" #include "citeme.h" +#include "comm.h" #include "domain.h" #include "error.h" #include "force.h" @@ -30,6 +31,7 @@ using namespace LAMMPS_NS; +#define SMALL 1.0e-10 /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) olav.galteland@ntnu.no @@ -82,7 +84,12 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * bin_width2 = 0.0; nbins1 = (int) ((domain->boxhi[dir1] - domain->boxlo[dir1]) / bin_width1); nbins2 = 1; - invV = bin_width1; + // adjust bin width if not a perfect match + invV = (domain->boxhi[dir1] - domain->boxlo[dir1]) / nbins1; + if ((fabs(invV - bin_width1) > SMALL) && (comm->me == 0)) + utils::logmesg(lmp, "Adjusting first bin width for compute {} from {:.6f} to {:.6f}\n", style, + bin_width1, invV); + bin_width1 = invV; if (bin_width1 <= 0.0) error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); @@ -101,6 +108,12 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * bin_width2 = utils::numeric(FLERR, arg[6], false, lmp); nbins2 = (int) ((domain->boxhi[dir2] - domain->boxlo[dir2]) / bin_width2); + double tmp_binwidth = (domain->boxhi[dir2] - domain->boxlo[dir2]) / nbins2; + if ((fabs(tmp_binwidth - bin_width2) > SMALL) && (comm->me == 0)) + utils::logmesg(lmp, "Adjusting second bin width for compute {} from {:.6f} to {:.6f}\n", + style, bin_width2, tmp_binwidth); + bin_width2 = tmp_binwidth; + invV *= bin_width2; if (bin_width2 <= 0.0) @@ -392,7 +405,7 @@ void ComputePressureCartesian::compute_pressure_1d(double fpair, double xi, doub bin = bin_s; // Integrate from bin_s to bin_e with step bin_step. - while (bin != bin_limit) { + while (bin < bin_limit) { // Calculating exit and entry point (xa, xb). Checking if inside current bin. if (bin == bin_s) { @@ -450,7 +463,6 @@ void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, doub double la = 0.0, lb = 0.0, l_sum = 0.0; double rij[3] = {delx, dely, delz}; double l1 = 0.0, l2, rij1, rij2; - double SMALL = 10e-5; rij1 = rij[dir1]; rij2 = rij[dir2]; @@ -458,7 +470,7 @@ void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, doub next_bin2 = (int) floor(yi / bin_width2); // Integrating along line - while (lb != 1.0) { + while (lb < 1.0) { bin1 = next_bin1; bin2 = next_bin2; @@ -501,7 +513,7 @@ void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, doub else if (bin2 >= nbins2) bin2 = nbins2 - 1; - if (bin1 + bin2 * nbins1 >= nbins1 * nbins2) error->all(FLERR, "Bin outside"); + if (bin1 + bin2 * nbins1 > nbins1 * nbins2) error->all(FLERR, "Bin outside: lb={:.16g}", lb); tpcxx[bin1 + bin2 * nbins1] += (fpair * delx * delx * (lb - la)); tpcyy[bin1 + bin2 * nbins1] += (fpair * dely * dely * (lb - la)); diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index a261c10270..86afd8f000 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -15,6 +15,7 @@ #include "atom.h" #include "citeme.h" +#include "comm.h" #include "domain.h" #include "error.h" #include "force.h" @@ -33,6 +34,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +#define SMALL 1.0e-10 + /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) olav.galteland@ntnu.no @@ -71,6 +74,11 @@ ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char * bin_width = utils::numeric(FLERR, arg[6], false, lmp); Rmax = utils::numeric(FLERR, arg[7], false, lmp); nbins = (int) (Rmax / bin_width) + 1; + double tmp_width = Rmax / nbins; + if ((fabs(bin_width - tmp_width) > SMALL) && (comm->me == 0)) + utils::logmesg(lmp, "Adjusting bin width for compute {} from {:.6f} to {:.6f}\n", style, + bin_width, tmp_width); + bin_width = tmp_width; if (bin_width <= 0.0) error->all(FLERR, "Illegal compute pressure/spherical command. Bin width must be > 0"); @@ -245,7 +253,6 @@ void ComputePressureSpherical::compute_array() double qi[3], l1, l2, l3, l4, R1, R2, Fa, Fb, l_sum; double rij, f, ririj, sqr, la, lb, sql0, lambda0; - double SMALL = 10e-12; double rsqxy, ririjxy, sqrixy, sqlxy0, A, B, C; int end_bin; @@ -328,24 +335,29 @@ void ComputePressureSpherical::compute_array() while (lb < 1.0) { l1 = lb + SMALL; bin = (int) floor(sqrt(rsq * l1 * l1 + 2.0 * ririj * l1 + sqr) / bin_width); - R1 = (bin) *bin_width; + R1 = bin * bin_width; R2 = (bin + 1) * bin_width; - l1 = lambda0 + sqrt((R1 * R1 - sql0) / rsq); - l2 = lambda0 - sqrt((R1 * R1 - sql0) / rsq); - l3 = lambda0 + sqrt((R2 * R2 - sql0) / rsq); - l4 = lambda0 - sqrt((R2 * R2 - sql0) / rsq); - - if (l4 >= 0.0 && l4 <= 1.0 && l4 > la) - lb = l4; - else if (l3 >= 0.0 && l3 <= 1.0 && l3 > la) - lb = l3; - else if (l2 >= 0.0 && l2 <= 1.0 && l2 > la) - lb = l2; - else if (l1 >= 0.0 && l1 <= 1.0 && l1 > la) - lb = l1; - else + // we must not take the square root of a negative number or divide by zero. + if ((R1*R1 < sql0) || (R2*R2 < sql0) || (rsq <= 0.0)) { lb = 1.0; + } else { + l1 = lambda0 + sqrt((R1 * R1 - sql0) / rsq); + l2 = lambda0 - sqrt((R1 * R1 - sql0) / rsq); + l3 = lambda0 + sqrt((R2 * R2 - sql0) / rsq); + l4 = lambda0 - sqrt((R2 * R2 - sql0) / rsq); + + if (l4 >= 0.0 && l4 <= 1.0 && l4 > la) + lb = l4; + else if (l3 >= 0.0 && l3 <= 1.0 && l3 > la) + lb = l3; + else if (l2 >= 0.0 && l2 <= 1.0 && l2 > la) + lb = l2; + else if (l1 >= 0.0 && l1 <= 1.0 && l1 > la) + lb = l1; + else + lb = 1.0; + } if (bin == end_bin) lb = 1.0; if (la > lb) error->all(FLERR, "Error: la > lb\n"); From be4f5288d3a2e3ce4892d89831dc9565ea19042d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 16:47:06 -0500 Subject: [PATCH 58/72] modernize potential file reader in pair style mesocnt --- src/MESONT/pair_mesocnt.cpp | 210 ++++++++++++++++-------------------- src/MESONT/pair_mesocnt.h | 11 +- 2 files changed, 98 insertions(+), 123 deletions(-) diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index c0c815d793..4d6e30c191 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -19,6 +19,7 @@ #include "pair_mesocnt.h" #include "atom.h" +#include "comm.h" #include "error.h" #include "force.h" #include "math_const.h" @@ -27,6 +28,7 @@ #include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" +#include "potential_file_reader.h" #include "update.h" #include @@ -434,8 +436,7 @@ void PairMesoCNT::settings(int narg, char ** /* arg */) void PairMesoCNT::coeff(int narg, char **arg) { if (narg != 3) error->all(FLERR, "Incorrect args for pair coefficients"); - file = arg[2]; - read_file(); + read_file(arg[2]); if (!allocated) allocate(); // units, eV to energy unit conversion @@ -817,40 +818,45 @@ void PairMesoCNT::sort(int *list, int size) read mesocnt potential file ------------------------------------------------------------------------- */ -void PairMesoCNT::read_file() +void PairMesoCNT::read_file(const char *file) { - int me, num; - MPI_Comm_rank(world, &me); + if (comm->me == 0) { - FILE *fp; + // open file and skip first line - if (me == 0) { - char line[MAXLINE]; + PotentialFileReader reader(lmp, file, "mesocnt"); + reader.skip_line(); - // open file + // parse global parameters: 4x integer then 4x double - fp = utils::open_potential(file, lmp, nullptr); - if (fp == nullptr) error->one(FLERR, "Cannot open mesocnt file: {}", file); + try { + auto values = reader.next_values(4); + uinf_points = values.next_int(); + gamma_points = values.next_int(); + phi_points = values.next_int(); + usemi_points = values.next_int(); - utils::sfgets(FLERR, line, MAXLINE, fp, file, error); + values = reader.next_values(4); + r_ang = values.next_double(); + sig_ang = values.next_double(); + delta1 = values.next_double(); + delta2 = values.next_double(); + } catch (std::exception &e) { + error->one(FLERR, "Error parsing mesocnt potential file header: {}", e.what()); + } - // potential parameters + // allocate and read potential tables - utils::sfgets(FLERR, line, MAXLINE, fp, file, error); - num = sscanf(line, "%d %d %d %d", &uinf_points, &gamma_points, &phi_points, &usemi_points); - if (num != 4) - error->one(FLERR, - "Could not correctly parse line 2 in " - "mesocnt file: {}", - file); + memory->create(uinf_data, uinf_points, "pair:uinf_data"); + memory->create(gamma_data, gamma_points, "pair:gamma_data"); + memory->create(phi_data, phi_points, phi_points, "pair:phi_data"); + memory->create(usemi_data, usemi_points, usemi_points, "pair:usemi_data"); - utils::sfgets(FLERR, line, MAXLINE, fp, file, error); - num = sscanf(line, "%lg %lg %lg %lg", &r_ang, &sig_ang, &delta1, &delta2); - if (num != 4) - error->one(FLERR, - "Could not correctly parse line 3 in " - "mesocnt file: {}", - file); + read_data(reader, uinf_data, hstart_uinf, delh_uinf, uinf_points); + read_data(reader, gamma_data, hstart_gamma, delh_gamma, gamma_points); + read_data(reader, phi_data, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_points); + read_data(reader, usemi_data, hstart_usemi, xistart_usemi, delh_usemi, delxi_usemi, + usemi_points); } MPI_Bcast(&uinf_points, 1, MPI_INT, 0, world); @@ -862,22 +868,17 @@ void PairMesoCNT::read_file() MPI_Bcast(&delta1, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&delta2, 1, MPI_DOUBLE, 0, world); - // potential tables + // allocate table arrays on other MPI ranks - memory->create(uinf_data, uinf_points, "pair:uinf_data"); - memory->create(gamma_data, gamma_points, "pair:gamma_data"); - memory->create(phi_data, phi_points, phi_points, "pair:phi_data"); - memory->create(usemi_data, usemi_points, usemi_points, "pair:usemi_data"); - - if (me == 0) { - read_data(fp, uinf_data, hstart_uinf, delh_uinf, uinf_points); - read_data(fp, gamma_data, hstart_gamma, delh_gamma, gamma_points); - read_data(fp, phi_data, hstart_phi, psistart_phi, delh_phi, delpsi_phi, phi_points); - read_data(fp, usemi_data, hstart_usemi, xistart_usemi, delh_usemi, delxi_usemi, usemi_points); - - fclose(fp); + if (comm->me != 0) { + memory->create(uinf_data, uinf_points, "pair:uinf_data"); + memory->create(gamma_data, gamma_points, "pair:gamma_data"); + memory->create(phi_data, phi_points, phi_points, "pair:phi_data"); + memory->create(usemi_data, usemi_points, usemi_points, "pair:usemi_data"); } + // broadcast tables + MPI_Bcast(&hstart_uinf, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&hstart_gamma, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&hstart_phi, 1, MPI_DOUBLE, 0, world); @@ -893,122 +894,97 @@ void PairMesoCNT::read_file() MPI_Bcast(uinf_data, uinf_points, MPI_DOUBLE, 0, world); MPI_Bcast(gamma_data, gamma_points, MPI_DOUBLE, 0, world); - for (int i = 0; i < phi_points; i++) MPI_Bcast(phi_data[i], phi_points, MPI_DOUBLE, 0, world); - for (int i = 0; i < usemi_points; i++) - MPI_Bcast(usemi_data[i], usemi_points, MPI_DOUBLE, 0, world); + MPI_Bcast(&phi_data[0][0], phi_points*phi_points, MPI_DOUBLE, 0, world); + MPI_Bcast(&usemi_data[0][0], usemi_points*usemi_points, MPI_DOUBLE, 0, world); } /* ---------------------------------------------------------------------- - read 1D data file + read 1D data file. Only called from MPI rank 0 ------------------------------------------------------------------------- */ -void PairMesoCNT::read_data(FILE *fp, double *data, double &xstart, double &dx, int ninput) +void PairMesoCNT::read_data(PotentialFileReader &reader, double *data, double &xstart, double &dx, + int ninput) { - char line[MAXLINE]; - utils::sfgets(FLERR, line, MAXLINE, fp, file, error); - // read values from file - int cerror = 0; int serror = 0; double x, xtemp, dxtemp; for (int i = 0; i < ninput; i++) { - if (nullptr == fgets(line, MAXLINE, fp)) - error->one(FLERR, "Premature end of file in pair table: {}", file); + try { + auto values = reader.next_values(2); - if (i > 0) xtemp = x; - if (2 != sscanf(line, "%lg %lg", &x, &data[i])) cerror++; - if (i == 0) { - xstart = x; - } else { - dxtemp = x - xtemp; - if (i == 1) dx = dxtemp; - if (fabs(dxtemp - dx) / dx > SMALL) serror++; + if (i > 0) xtemp = x; + x = values.next_double(); + data[i] = values.next_double(); + + if (i == 0) { + xstart = x; + } else { + dxtemp = x - xtemp; + if (i == 1) dx = dxtemp; + if (fabs(dxtemp - dx) / dx > SMALL) serror++; + } + } catch (std::exception &e) { + error->one(FLERR, "Error parsing data for mesocnt potential: {}", e.what()); } - } - // warn if data was read incompletely, e.g. columns were missing + // warn if spacing between data points is not constant - if (cerror) { - std::string mesg = fmt::format("{} of {} lines were incomplete or could " - "or could not be parsed completely in " - " pair table: {}", - cerror, ninput, file); - error->warning(FLERR, mesg); - } - - // warn if spacing between data points is not constant - - if (serror) { - std::string mesg = fmt::format("{} spacings in first column were different " - " from first spacing in pair table: {}", - serror, file); - error->warning(FLERR, mesg); + if (serror) + error->warning(FLERR, "{} spacings in first column were different from first", serror); } } /* ---------------------------------------------------------------------- - read 2D data file + read 2D data file only called from MPI rank 0 ------------------------------------------------------------------------- */ -void PairMesoCNT::read_data(FILE *fp, double **data, double &xstart, double &ystart, double &dx, - double &dy, int ninput) +void PairMesoCNT::read_data(PotentialFileReader &reader, double **data, double &xstart, + double &ystart, double &dx, double &dy, int ninput) { - char line[MAXLINE]; - fgets(line, MAXLINE, fp); - // read values from file - int cerror = 0; int sxerror = 0; int syerror = 0; double x, y, xtemp, ytemp, dxtemp, dytemp; for (int i = 0; i < ninput; i++) { - if (i > 0) xtemp = x; - for (int j = 0; j < ninput; j++) { - if (nullptr == fgets(line, MAXLINE, fp)) - error->one(FLERR, "Premature end of file in pair table: {}", file); + try { + if (i > 0) xtemp = x; + for (int j = 0; j < ninput; j++) { + if (j > 0) ytemp = y; - if (j > 0) ytemp = y; - if (3 != sscanf(line, "%lg %lg %lg", &x, &y, &data[i][j])) cerror++; - if (i == 0 && j == 0) ystart = y; - if (j > 0) { - dytemp = y - ytemp; - if (j == 1) dy = dytemp; - if (fabs(dytemp - dy) / dy > SMALL) syerror++; + auto values = reader.next_values(3); + x = values.next_double(); + y = values.next_double(); + data[i][j] = values.next_double(); + + if (i == 0 && j == 0) ystart = y; + if (j > 0) { + dytemp = y - ytemp; + if (j == 1) dy = dytemp; + if (fabs(dytemp - dy) / dy > SMALL) syerror++; + } } - } - if (i == 0) { - xstart = x; - } else { - dxtemp = x - xtemp; - if (i == 1) dx = dxtemp; - if (fabs(dxtemp - dx) / dx > SMALL) sxerror++; + if (i == 0) { + xstart = x; + } else { + dxtemp = x - xtemp; + if (i == 1) dx = dxtemp; + if (fabs(dxtemp - dx) / dx > SMALL) sxerror++; + } + } catch (std::exception &e) { + error->one(FLERR, "Error parsing data for mesocnt potential: {}", e.what()); } } - // warn if data was read incompletely, e.g. columns were missing - - if (cerror) - error->warning(FLERR, - "{} of {} lines were incomplete or could not be parsed " - "completely in pair table: {}", - cerror, ninput * ninput, file); - // warn if spacing between data points is not constant if (sxerror) - error->warning(FLERR, - "{} spacings in first column were different from " - "first spacing in pair table: {}", - sxerror, file); + error->warning(FLERR, "{} spacings in first column were different from first", sxerror); if (syerror) - error->warning(FLERR, - "{} spacings in second column were different from " - "first spacing in pair table: {}", - syerror, file); + error->warning(FLERR, "{} spacings in second column were different from first", syerror); } /* ---------------------------------------------------------------------- diff --git a/src/MESONT/pair_mesocnt.h b/src/MESONT/pair_mesocnt.h index 3f1dca4abd..795b27f8ff 100644 --- a/src/MESONT/pair_mesocnt.h +++ b/src/MESONT/pair_mesocnt.h @@ -21,7 +21,7 @@ PairStyle(mesocnt, PairMesoCNT); #include "pair.h" namespace LAMMPS_NS { - +class PotentialFileReader; class PairMesoCNT : public Pair { public: PairMesoCNT(class LAMMPS *); @@ -54,8 +54,6 @@ class PairMesoCNT : public Pair { double **uinf_coeff, **gamma_coeff, ****phi_coeff, ****usemi_coeff; double **flocal, **fglobal, **basis; - char *file; - int count_chains(int *, int); void allocate(); @@ -64,9 +62,10 @@ class PairMesoCNT : public Pair { void chain_lengths(int *, int, int *); void chain_split(int *, int, int *, int **, int *); void sort(int *, int); - void read_file(); - void read_data(FILE *, double *, double &, double &, int); - void read_data(FILE *, double **, double &, double &, double &, double &, int); + void read_file(const char *); + void read_data(PotentialFileReader &, double *, double &, double &, int); + void read_data(PotentialFileReader &, double **, double &, double &, double &, double &, + int); void spline_coeff(double *, double **, double, int); void spline_coeff(double **, double ****, double, double, int); From 095c9ab9d19a2ab250af9cf003440dc79ba43c91 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Mar 2022 17:08:49 -0500 Subject: [PATCH 59/72] whitespace --- src/memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/memory.h b/src/memory.h index 2f84728b32..5095cbb0a6 100644 --- a/src/memory.h +++ b/src/memory.h @@ -237,7 +237,7 @@ class Memory : protected Pointers { size += n3[i][j]; nbytes = ((bigint) sizeof(TYPE)) * size; TYPE *data = (TYPE *) smalloc(nbytes, name); - + size = 0; for (i = 0; i < n1; i++) size += n2[i]; nbytes = ((bigint) sizeof(TYPE *)) * size; From fac3ce45073062c1b05f214738bfc144d6ade4f1 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Sun, 6 Mar 2022 12:43:37 +0100 Subject: [PATCH 60/72] example files for pressure/cartesian/cylinder/spherical --- examples/pressure/in.cylinder | 40 +++++++++++++++++++++++++++++++++ examples/pressure/in.flat | 42 +++++++++++++++++++++++++++++++++++ examples/pressure/in.sphere | 39 ++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 examples/pressure/in.cylinder create mode 100644 examples/pressure/in.flat create mode 100644 examples/pressure/in.sphere diff --git a/examples/pressure/in.cylinder b/examples/pressure/in.cylinder new file mode 100644 index 0000000000..59bcebbbc3 --- /dev/null +++ b/examples/pressure/in.cylinder @@ -0,0 +1,40 @@ +# compute pressure/cylinder for a cylindrical liquid-vapor interface + +units lj +atom_style atomic + +lattice fcc 0.8442 +region box block -10 10 -10 10 0 10 +region liquid cylinder z 0 0 5 0 10 +create_box 1 box +create_atoms 1 region liquid +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + + +thermo 50 +#dump id all atom 50 dump.cylinder + +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 NULL units lattice +compute p all pressure/cylinder 0 10 15 0.25 +fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector + + +run 1000 diff --git a/examples/pressure/in.flat b/examples/pressure/in.flat new file mode 100644 index 0000000000..1cbf9d6ff2 --- /dev/null +++ b/examples/pressure/in.flat @@ -0,0 +1,42 @@ +# compute pressure/cartesian for a flat liquid-vapor interface + +units lj +atom_style atomic + +lattice fcc 0.8442 +region box block 0 10 0 10 0 30 +region liquid block 0 10 0 10 10 20 +create_box 1 box +create_atoms 1 region liquid +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.7 0.7 0.2 + + +thermo 50 +#dump id all atom 50 dump.flat + +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter NULL NULL 15 units lattice +compute p1 all pressure/cartesian z 0.5 +fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector +#compute p2 all pressure/cartesian z 0.25 x 1 +#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector + + +run 1000 diff --git a/examples/pressure/in.sphere b/examples/pressure/in.sphere new file mode 100644 index 0000000000..8715c2d321 --- /dev/null +++ b/examples/pressure/in.sphere @@ -0,0 +1,39 @@ +# compute pressure/spherical for a spherical droplet + +units lj +atom_style atomic + +lattice fcc 0.8442 +region box block -10 10 -10 10 -10 10 +region liquid sphere 0 0 0 5 +create_box 1 box +create_atoms 1 region liquid +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + +#dump id all atom 50 dump.sphere + +thermo 50 +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 0 units lattice +compute p all pressure/spherical 0 0 0 0.25 15 +fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector + + +run 1000 From 44e38745413fa77bd4ef64f8135ff0f689418dab Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Sun, 6 Mar 2022 12:50:25 +0100 Subject: [PATCH 61/72] Changed citations --- .../compute_pressure_cartesian.cpp | 28 +++++++++---------- .../compute_pressure_spherical.cpp | 19 ++++++------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index a18c16eb12..838c3635b0 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -39,16 +39,16 @@ using namespace LAMMPS_NS; static const char cite_compute_pressure_cartesian[] = "compute pressure/cartesian:\n\n" - "@article{ikeshoji2003molecular,\n" - "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and " - "spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" - "journal={Molecular Simulation},\n" - "volume={29},\n" - "number={2},\n" - "pages={101--109},\n" - "year={2003},\n" - "publisher={Taylor & Francis}\n" + "@article{galteland2021nanothermodynamic,\n" + "title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a " + "slit pore},\n" + "author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe}\n," + "journal={Nanomaterials},\n" + "volume={11},\n" + "number={1},\n" + "pages={165},\n" + "year={2021},\n" + "publisher={Multidisciplinary Digital Publishing Institute}\n" "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -495,9 +495,9 @@ void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, doub // Periodic boundary conditions if (domain->periodicity[dir1] == 1) { if (bin1 < 0) - bin1 += nbins1; + bin1 = (bin1 + nbins1) % nbins1; else if (bin1 >= nbins1) - bin1 -= nbins1; + bin1 = (bin1 - nbins1) % nbins1; } else if (bin1 < 0) bin1 = 0; else if (bin1 >= nbins1) @@ -505,9 +505,9 @@ void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, doub if (domain->periodicity[dir2] == 1) { if (bin2 < 0) - bin2 += nbins2; + bin2 = (bin2 + nbins2) % nbins2; else if (bin2 >= nbins2) - bin2 -= nbins2; + bin2 = (bin2 - nbins2) % nbins2; } else if (bin2 < 0) bin2 = 0; else if (bin2 >= nbins2) diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index 86afd8f000..bebd9268d5 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -19,6 +19,7 @@ #include "domain.h" #include "error.h" #include "force.h" +#include "lattice.h" #include "math_const.h" #include "memory.h" #include "modify.h" @@ -43,16 +44,12 @@ using namespace MathConst; static const char cite_compute_pressure_sphere[] = "compute pressure/spherical:\n\n" - "@article{ikeshoji2003molecular,\n" - "title={Molecular-level calculation scheme for pressure in inhomogeneous systems of flat and " - "spherical layers},\n" - "author={Ikeshoji, Tamio and Hafskjold, Bj{\\o}rn and Furuholt, Hilde},\n" - "journal={Molecular Simulation},\n" - "volume={29},\n" - "number={2},\n" - "pages={101--109},\n" - "year={2003},\n" - "publisher={Taylor & Francis}\n" + "@article{galteland2022defining,\n" + "title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium},\n" + "author={Galteland, Olav and Rauter, Michael T and Varughese, Kevin K and Bedeaux, Dick and " + "Kjelstrup, Signe},\n" + "journal={arXiv preprint arXiv:2201.13060},\n" + "year={2022}\n" "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -339,7 +336,7 @@ void ComputePressureSpherical::compute_array() R2 = (bin + 1) * bin_width; // we must not take the square root of a negative number or divide by zero. - if ((R1*R1 < sql0) || (R2*R2 < sql0) || (rsq <= 0.0)) { + if ((R1 * R1 < sql0) || (R2 * R2 < sql0) || (rsq <= 0.0)) { lb = 1.0; } else { l1 = lambda0 + sqrt((R1 * R1 - sql0) / rsq); From 2f5f36cff8d0c2f86be53c8bf36dc94709140563 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 6 Mar 2022 11:03:57 -0500 Subject: [PATCH 62/72] move examples to a more appropriate folder. add logfiles --- examples/PACKAGES/pressure/in.cylinder | 40 +++++ examples/PACKAGES/pressure/in.flat | 43 ++++++ examples/PACKAGES/pressure/in.sphere | 39 +++++ .../pressure/log.6Mar2022.cylinder.g++.1 | 133 +++++++++++++++++ .../pressure/log.6Mar2022.cylinder.g++.4 | 133 +++++++++++++++++ .../PACKAGES/pressure/log.6Mar2022.flat.g++.1 | 139 ++++++++++++++++++ .../PACKAGES/pressure/log.6Mar2022.flat.g++.4 | 139 ++++++++++++++++++ .../pressure/log.6Mar2022.sphere.g++.1 | 131 +++++++++++++++++ .../pressure/log.6Mar2022.sphere.g++.4 | 131 +++++++++++++++++ examples/pressure/in.cylinder | 40 ----- examples/pressure/in.flat | 42 ------ examples/pressure/in.sphere | 39 ----- 12 files changed, 928 insertions(+), 121 deletions(-) create mode 100644 examples/PACKAGES/pressure/in.cylinder create mode 100644 examples/PACKAGES/pressure/in.flat create mode 100644 examples/PACKAGES/pressure/in.sphere create mode 100644 examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 create mode 100644 examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 create mode 100644 examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 create mode 100644 examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 create mode 100644 examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 create mode 100644 examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 delete mode 100644 examples/pressure/in.cylinder delete mode 100644 examples/pressure/in.flat delete mode 100644 examples/pressure/in.sphere diff --git a/examples/PACKAGES/pressure/in.cylinder b/examples/PACKAGES/pressure/in.cylinder new file mode 100644 index 0000000000..39c1c2ec99 --- /dev/null +++ b/examples/PACKAGES/pressure/in.cylinder @@ -0,0 +1,40 @@ +# compute pressure/cylinder for a cylindrical liquid-vapor interface + +units lj +atom_style atomic + +lattice fcc 0.8442 +region box block -10 10 -10 10 0 10 +region liquid cylinder z 0 0 5 0 10 +create_box 1 box +create_atoms 1 region liquid +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + + +thermo 50 +#dump id all atom 50 dump.cylinder + +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 NULL units lattice +compute p all pressure/cylinder 0 10 15 0.25 +fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector + + +run 1000 diff --git a/examples/PACKAGES/pressure/in.flat b/examples/PACKAGES/pressure/in.flat new file mode 100644 index 0000000000..8f7daa6aad --- /dev/null +++ b/examples/PACKAGES/pressure/in.flat @@ -0,0 +1,43 @@ +# compute pressure/cartesian for a flat liquid-vapor interface + +units lj +atom_style atomic +processors * * 1 + +lattice fcc 0.8442 +region box block 0 10 0 10 0 30 +region liquid block 0 10 0 10 10 20 +create_box 1 box +create_atoms 1 region liquid +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.7 0.7 0.2 + + +thermo 50 +#dump id all atom 50 dump.flat + +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter NULL NULL 15 units lattice +compute p1 all pressure/cartesian z 0.5 +fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector +#compute p2 all pressure/cartesian z 0.25 x 1 +#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector + + +run 1000 diff --git a/examples/PACKAGES/pressure/in.sphere b/examples/PACKAGES/pressure/in.sphere new file mode 100644 index 0000000000..423ee176ec --- /dev/null +++ b/examples/PACKAGES/pressure/in.sphere @@ -0,0 +1,39 @@ +# compute pressure/spherical for a spherical droplet + +units lj +atom_style atomic + +lattice fcc 0.8442 +region box block -10 10 -10 10 -10 10 +region liquid sphere 0 0 0 5 +create_box 1 box +create_atoms 1 region liquid +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + +#dump id all atom 50 dump.sphere + +thermo 50 +#dump 2 all image 25 image.*.jpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type & +# axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 0 units lattice +compute p all pressure/spherical 0 0 0 0.25 15 +fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector + + +run 1000 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 new file mode 100644 index 0000000000..fedf1470da --- /dev/null +++ b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 @@ -0,0 +1,133 @@ +LAMMPS (17 Feb 2022) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# compute pressure/cylinder for a cylindrical liquid-vapor interface + +units lj +atom_style atomic + +lattice fcc 0.8442 +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +region box block -10 10 -10 10 0 10 +region liquid cylinder z 0 0 5 0 10 +create_box 1 box +Created orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region liquid +Created 3170 atoms + using lattice units in orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) + create_atoms CPU = 0.001 seconds +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + + +thermo 50 +#dump id all atom 50 dump.cylinder + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 NULL units lattice +compute p all pressure/cylinder 0 10 15 0.25 +fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector + + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- compute pressure/cylinder: + +@Article{Addington, + author = {C. K. Addington, Y. Long, K. E. Gubbins}, + title = {The pressure in interfaces having cylindrical geometry}, + journal = {J.~Chem.~Phys.}, + year = 2018, + volume = 149, + pages = {084109} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + + generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update every 20 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 24 24 12 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard + (2) compute pressure/cylinder, occasional, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 3.878 | 3.878 | 3.878 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0.65 -6.2219331 0 -5.2472407 -1.0193897 + 50 0.40121817 -5.7782233 0 -5.1765859 -0.33373915 + 100 0.56963398 -5.8789288 0 -5.0247474 -0.16859926 + 150 0.68424117 -5.9319873 0 -4.9059493 0.062850222 + 200 0.68608162 -5.9987099 0 -4.9699121 0.21439145 + 250 0.63422098 -6.047104 0 -5.0960726 0.30980602 + 300 0.64028254 -6.107331 0 -5.1472102 0.32133372 + 350 0.64906334 -6.1101542 0 -5.1368663 0.22288375 + 400 0.61848053 -6.0090821 0 -5.081654 0.053336092 + 450 0.60600519 -5.8710484 0 -4.9623273 -0.085701075 + 500 0.60383908 -5.7254198 0 -4.8199469 -0.15560848 + 550 0.60342483 -5.582958 0 -4.6781063 -0.18389998 + 600 0.61415824 -5.4571678 0 -4.5362211 -0.18398358 + 650 0.61997958 -5.3337392 0 -4.4040632 -0.13933776 + 700 0.65521411 -5.2724025 0 -4.2898914 -0.13977767 + 750 0.6525752 -5.18782 0 -4.2092659 -0.087418448 + 800 0.6711302 -5.1682283 0 -4.1618506 -0.080863195 + 850 0.64374266 -5.1290236 0 -4.1637142 -0.012480639 + 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 + 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 + 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 +Loop time of 2.54244 on 1 procs for 1000 steps with 3170 atoms + +Performance: 169915.320 tau/day, 393.322 timesteps/s +99.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.1455 | 1.1455 | 1.1455 | 0.0 | 45.05 +Neigh | 0.17719 | 0.17719 | 0.17719 | 0.0 | 6.97 +Comm | 0.0067252 | 0.0067252 | 0.0067252 | 0.0 | 0.26 +Output | 0.00069549 | 0.00069549 | 0.00069549 | 0.0 | 0.03 +Modify | 1.2081 | 1.2081 | 1.2081 | 0.0 | 47.52 +Other | | 0.00421 | | | 0.17 + +Nlocal: 3170 ave 3170 max 3170 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1074 ave 1074 max 1074 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 101768 ave 101768 max 101768 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 101768 +Ave neighs/atom = 32.10347 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:02 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 new file mode 100644 index 0000000000..af787b7b58 --- /dev/null +++ b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 @@ -0,0 +1,133 @@ +LAMMPS (17 Feb 2022) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# compute pressure/cylinder for a cylindrical liquid-vapor interface + +units lj +atom_style atomic + +lattice fcc 0.8442 +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +region box block -10 10 -10 10 0 10 +region liquid cylinder z 0 0 5 0 10 +create_box 1 box +Created orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) + 2 by 2 by 1 MPI processor grid +create_atoms 1 region liquid +Created 3170 atoms + using lattice units in orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) + create_atoms CPU = 0.000 seconds +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + + +thermo 50 +#dump id all atom 50 dump.cylinder + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 NULL units lattice +compute p all pressure/cylinder 0 10 15 0.25 +fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector + + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- compute pressure/cylinder: + +@Article{Addington, + author = {C. K. Addington, Y. Long, K. E. Gubbins}, + title = {The pressure in interfaces having cylindrical geometry}, + journal = {J.~Chem.~Phys.}, + year = 2018, + volume = 149, + pages = {084109} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + + generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update every 20 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 24 24 12 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard + (2) compute pressure/cylinder, occasional, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 3.023 | 3.033 | 3.043 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0.65 -6.2219331 0 -5.2472407 -1.0193897 + 50 0.40121817 -5.7782233 0 -5.1765859 -0.33373915 + 100 0.56963398 -5.8789288 0 -5.0247474 -0.16859926 + 150 0.68424117 -5.9319873 0 -4.9059493 0.062850222 + 200 0.68608162 -5.9987099 0 -4.9699121 0.21439145 + 250 0.63422098 -6.047104 0 -5.0960726 0.30980602 + 300 0.64028254 -6.107331 0 -5.1472102 0.32133372 + 350 0.64906334 -6.1101542 0 -5.1368663 0.22288375 + 400 0.61848053 -6.0090821 0 -5.081654 0.053336092 + 450 0.60600519 -5.8710484 0 -4.9623273 -0.085701075 + 500 0.60383908 -5.7254198 0 -4.8199469 -0.15560848 + 550 0.60342483 -5.582958 0 -4.6781063 -0.18389998 + 600 0.61415824 -5.4571678 0 -4.5362211 -0.18398358 + 650 0.61997958 -5.3337392 0 -4.4040632 -0.13933776 + 700 0.65521411 -5.2724025 0 -4.2898914 -0.13977767 + 750 0.6525752 -5.18782 0 -4.2092659 -0.087418448 + 800 0.6711302 -5.1682283 0 -4.1618506 -0.080863195 + 850 0.64374266 -5.1290236 0 -4.1637142 -0.012480639 + 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 + 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 + 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 +Loop time of 0.709732 on 4 procs for 1000 steps with 3170 atoms + +Performance: 608680.564 tau/day, 1408.983 timesteps/s +99.6% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.28555 | 0.29497 | 0.30391 | 1.3 | 41.56 +Neigh | 0.046067 | 0.046753 | 0.047531 | 0.3 | 6.59 +Comm | 0.026197 | 0.037315 | 0.049469 | 4.6 | 5.26 +Output | 0.00049542 | 0.0013801 | 0.0016773 | 1.4 | 0.19 +Modify | 0.32518 | 0.32751 | 0.33044 | 0.3 | 46.15 +Other | | 0.001804 | | | 0.25 + +Nlocal: 792.5 ave 794 max 791 min +Histogram: 1 0 0 1 0 0 1 0 0 1 +Nghost: 1292 ave 1302 max 1284 min +Histogram: 1 0 1 0 0 1 0 0 0 1 +Neighs: 25442 ave 26560 max 24446 min +Histogram: 1 0 0 1 0 1 0 0 0 1 + +Total # of neighbors = 101768 +Ave neighs/atom = 32.10347 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 new file mode 100644 index 0000000000..0141824bcf --- /dev/null +++ b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 @@ -0,0 +1,139 @@ +LAMMPS (17 Feb 2022) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# compute pressure/cartesian for a flat liquid-vapor interface + +units lj +atom_style atomic +processors * * 1 + +lattice fcc 0.8442 +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +region box block 0 10 0 10 0 30 +region liquid block 0 10 0 10 10 20 +create_box 1 box +Created orthogonal box = (0 0 0) to (16.795962 16.795962 50.387886) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region liquid +Created 4200 atoms + using lattice units in orthogonal box = (0 0 0) to (16.795962 16.795962 50.387886) + create_atoms CPU = 0.001 seconds +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.7 0.7 0.2 + + +thermo 50 +#dump id all atom 50 dump.flat + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter NULL NULL 15 units lattice +compute p1 all pressure/cartesian z 0.5 +Adjusting first bin width for compute pressure/cartesian from 0.500000 to 0.503879 +fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector +#compute p2 all pressure/cartesian z 0.25 x 1 +#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector + + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- compute pressure/cartesian: + +@article{galteland2021nanothermodynamic, +title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a slit pore}, +author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe} +,journal={Nanomaterials}, +volume={11}, +number={1}, +pages={165}, +year={2021}, +publisher={Multidisciplinary Digital Publishing Institute} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + + generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update every 20 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 12 12 36 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard + (2) compute pressure/cartesian, occasional, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 3.943 | 3.943 | 3.943 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0.65 -6.5342767 0 -5.5595088 -1.9070205 + 50 0.36842234 -6.0304191 0 -5.4779172 -0.76896135 + 100 0.50896152 -6.0786202 0 -5.3153597 -0.58839893 + 150 0.63567071 -6.0832159 0 -5.1299368 -0.29587266 + 200 0.72324528 -6.0689996 0 -4.98439 -0.020342078 + 250 0.74387008 -6.1188743 0 -5.0033349 0.11337395 + 300 0.69112666 -6.1838992 0 -5.1474561 0.18290797 + 350 0.67772633 -6.2400592 0 -5.2237117 0.27698807 + 400 0.70714238 -6.2783031 0 -5.2178421 0.41150934 + 450 0.71843478 -6.2870874 0 -5.2096918 0.57099811 + 500 0.69813385 -6.3041653 0 -5.2572139 0.53883987 + 550 0.67043069 -6.3035289 0 -5.2981223 0.36370002 + 600 0.68196102 -6.26442 0 -5.241722 0.22122892 + 650 0.69413189 -6.1759937 0 -5.1350438 0.12782621 + 700 0.70034968 -6.1028735 0 -5.0525991 0.029208853 + 750 0.70266272 -6.036839 0 -4.9830959 -0.088703619 + 800 0.68551399 -5.9410263 0 -4.9130002 -0.18134075 + 850 0.6866836 -5.8390431 0 -4.8092629 -0.27593375 + 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 + 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 + 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 +Loop time of 2.13769 on 1 procs for 1000 steps with 4200 atoms + +Performance: 202087.264 tau/day, 467.795 timesteps/s +99.5% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.6853 | 1.6853 | 1.6853 | 0.0 | 78.84 +Neigh | 0.2494 | 0.2494 | 0.2494 | 0.0 | 11.67 +Comm | 0.020319 | 0.020319 | 0.020319 | 0.0 | 0.95 +Output | 0.0006408 | 0.0006408 | 0.0006408 | 0.0 | 0.03 +Modify | 0.17491 | 0.17491 | 0.17491 | 0.0 | 8.18 +Other | | 0.007093 | | | 0.33 + +Nlocal: 4200 ave 4200 max 4200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3393 ave 3393 max 3393 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 144737 ave 144737 max 144737 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 144737 +Ave neighs/atom = 34.46119 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:02 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 new file mode 100644 index 0000000000..04bed6e521 --- /dev/null +++ b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 @@ -0,0 +1,139 @@ +LAMMPS (17 Feb 2022) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# compute pressure/cartesian for a flat liquid-vapor interface + +units lj +atom_style atomic +processors * * 1 + +lattice fcc 0.8442 +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +region box block 0 10 0 10 0 30 +region liquid block 0 10 0 10 10 20 +create_box 1 box +Created orthogonal box = (0 0 0) to (16.795962 16.795962 50.387886) + 2 by 2 by 1 MPI processor grid +create_atoms 1 region liquid +Created 4200 atoms + using lattice units in orthogonal box = (0 0 0) to (16.795962 16.795962 50.387886) + create_atoms CPU = 0.001 seconds +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.7 0.7 0.2 + + +thermo 50 +#dump id all atom 50 dump.flat + +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter NULL NULL 15 units lattice +compute p1 all pressure/cartesian z 0.5 +Adjusting first bin width for compute pressure/cartesian from 0.500000 to 0.503879 +fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector +#compute p2 all pressure/cartesian z 0.25 x 1 +#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector + + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- compute pressure/cartesian: + +@article{galteland2021nanothermodynamic, +title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a slit pore}, +author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe} +,journal={Nanomaterials}, +volume={11}, +number={1}, +pages={165}, +year={2021}, +publisher={Multidisciplinary Digital Publishing Institute} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + + generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update every 20 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 12 12 36 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard + (2) compute pressure/cartesian, occasional, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 3.083 | 3.083 | 3.083 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0.65 -6.5342767 0 -5.5595088 -1.9070205 + 50 0.36842234 -6.0304191 0 -5.4779172 -0.76896135 + 100 0.50896152 -6.0786202 0 -5.3153597 -0.58839893 + 150 0.63567071 -6.0832159 0 -5.1299368 -0.29587266 + 200 0.72324528 -6.0689996 0 -4.98439 -0.020342078 + 250 0.74387008 -6.1188743 0 -5.0033349 0.11337395 + 300 0.69112666 -6.1838992 0 -5.1474561 0.18290797 + 350 0.67772633 -6.2400592 0 -5.2237117 0.27698807 + 400 0.70714238 -6.2783031 0 -5.2178421 0.41150934 + 450 0.71843478 -6.2870874 0 -5.2096918 0.57099811 + 500 0.69813385 -6.3041653 0 -5.2572139 0.53883987 + 550 0.67043069 -6.3035289 0 -5.2981223 0.36370002 + 600 0.68196102 -6.26442 0 -5.241722 0.22122892 + 650 0.69413189 -6.1759937 0 -5.1350438 0.12782621 + 700 0.70034968 -6.1028735 0 -5.0525991 0.029208853 + 750 0.70266272 -6.036839 0 -4.9830959 -0.088703619 + 800 0.68551399 -5.9410263 0 -4.9130002 -0.18134075 + 850 0.6866836 -5.8390431 0 -4.8092629 -0.27593375 + 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 + 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 + 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 +Loop time of 0.675356 on 4 procs for 1000 steps with 4200 atoms + +Performance: 639662.349 tau/day, 1480.700 timesteps/s +99.4% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.47174 | 0.48429 | 0.49671 | 1.5 | 71.71 +Neigh | 0.069839 | 0.071447 | 0.072509 | 0.4 | 10.58 +Comm | 0.046053 | 0.059527 | 0.073675 | 4.5 | 8.81 +Output | 0.0007041 | 0.0022594 | 0.0027829 | 1.9 | 0.33 +Modify | 0.054631 | 0.055179 | 0.056783 | 0.4 | 8.17 +Other | | 0.002651 | | | 0.39 + +Nlocal: 1050 ave 1071 max 1026 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Nghost: 1952.75 ave 1977 max 1936 min +Histogram: 1 0 1 0 1 0 0 0 0 1 +Neighs: 36184.2 ave 37407 max 34670 min +Histogram: 1 0 0 0 1 0 0 1 0 1 + +Total # of neighbors = 144737 +Ave neighs/atom = 34.46119 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 new file mode 100644 index 0000000000..c09f34f294 --- /dev/null +++ b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 @@ -0,0 +1,131 @@ +LAMMPS (17 Feb 2022) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# compute pressure/spherical for a spherical droplet + +units lj +atom_style atomic + +lattice fcc 0.8442 +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +region box block -10 10 -10 10 -10 10 +region liquid sphere 0 0 0 5 +create_box 1 box +Created orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region liquid +Created 2123 atoms + using lattice units in orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) + create_atoms CPU = 0.001 seconds +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + +#dump id all atom 50 dump.sphere + +thermo 50 +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 0 units lattice +compute p all pressure/spherical 0 0 0 0.25 15 +Adjusting bin width for compute pressure/spherical from 0.250000 to 0.245902 +fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector + + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- compute pressure/spherical: + +@article{galteland2022defining, +title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium}, +author={Galteland, Olav and Rauter, Michael T and Varughese, Kevin K and Bedeaux, Dick and Kjelstrup, Signe}, +journal={arXiv preprint arXiv:2201.13060}, +year={2022} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + + generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update every 20 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 24 24 24 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard + (2) compute pressure/spherical, occasional, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 3.11 | 3.11 | 3.11 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0.65 -5.982005 0 -5.0074642 -0.32476388 + 50 0.42414771 -5.5700167 0 -4.9340948 -0.074492286 + 100 0.64021145 -5.7405134 0 -4.7806486 -0.0054535408 + 150 0.72663247 -5.8366691 0 -4.7472338 0.089984367 + 200 0.63460122 -5.8577473 0 -4.9062939 0.14140872 + 250 0.62199115 -5.9027866 0 -4.9702393 0.13328919 + 300 0.62406364 -5.8889104 0 -4.9532559 0.063550326 + 350 0.6028994 -5.7552274 0 -4.8513043 -0.027499706 + 400 0.56811588 -5.5416058 0 -4.6898334 -0.061577561 + 450 0.54946762 -5.3409786 0 -4.5171654 -0.060007836 + 500 0.57962648 -5.2096808 0 -4.3406506 -0.052541306 + 550 0.61149882 -5.0920642 0 -4.175248 -0.03806361 + 600 0.63683327 -4.9975996 0 -4.0427996 -0.016868781 + 650 0.67007543 -4.9684574 0 -3.9638177 -0.00087204466 + 700 0.65648313 -4.9612522 0 -3.9769913 0.012954904 + 750 0.62636818 -4.9944273 0 -4.0553176 0.01206773 + 800 0.64474901 -5.0498682 0 -4.0832003 -0.0022579262 + 850 0.64765539 -5.0405969 0 -4.0695714 0.0061653637 + 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 + 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 + 1000 0.6407875 -4.9770134 0 -4.0162849 0.0064419231 +Loop time of 1.12311 on 1 procs for 1000 steps with 2123 atoms + +Performance: 384646.552 tau/day, 890.386 timesteps/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.72699 | 0.72699 | 0.72699 | 0.0 | 64.73 +Neigh | 0.11083 | 0.11083 | 0.11083 | 0.0 | 9.87 +Comm | 0.0011647 | 0.0011647 | 0.0011647 | 0.0 | 0.10 +Output | 0.0005541 | 0.0005541 | 0.0005541 | 0.0 | 0.05 +Modify | 0.28132 | 0.28132 | 0.28132 | 0.0 | 25.05 +Other | | 0.002256 | | | 0.20 + +Nlocal: 2123 ave 2123 max 2123 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 0 ave 0 max 0 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 63677 ave 63677 max 63677 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 63677 +Ave neighs/atom = 29.993877 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:01 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 new file mode 100644 index 0000000000..24267e6cf4 --- /dev/null +++ b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 @@ -0,0 +1,131 @@ +LAMMPS (17 Feb 2022) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# compute pressure/spherical for a spherical droplet + +units lj +atom_style atomic + +lattice fcc 0.8442 +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +region box block -10 10 -10 10 -10 10 +region liquid sphere 0 0 0 5 +create_box 1 box +Created orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) + 1 by 2 by 2 MPI processor grid +create_atoms 1 region liquid +Created 2123 atoms + using lattice units in orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) + create_atoms CPU = 0.001 seconds +mass 1 1.0 + +velocity all create 0.65 87287 loop geom + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 + +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no + +fix 1 all nvt temp 0.65 0.65 0.2 + +#dump id all atom 50 dump.sphere + +thermo 50 +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 + +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 + +fix 2 all recenter 0 0 0 units lattice +compute p all pressure/spherical 0 0 0 0.25 15 +Adjusting bin width for compute pressure/spherical from 0.250000 to 0.245902 +fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector + + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- compute pressure/spherical: + +@article{galteland2022defining, +title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium}, +author={Galteland, Olav and Rauter, Michael T and Varughese, Kevin K and Bedeaux, Dick and Kjelstrup, Signe}, +journal={arXiv preprint arXiv:2201.13060}, +year={2022} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + + generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update every 20 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 24 24 24 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard + (2) compute pressure/spherical, occasional, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 3.068 | 3.078 | 3.082 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 0.65 -5.982005 0 -5.0074642 -0.32476388 + 50 0.42414771 -5.5700167 0 -4.9340948 -0.074492286 + 100 0.64021145 -5.7405134 0 -4.7806486 -0.0054535408 + 150 0.72663247 -5.8366691 0 -4.7472338 0.089984367 + 200 0.63460122 -5.8577473 0 -4.9062939 0.14140872 + 250 0.62199115 -5.9027866 0 -4.9702393 0.13328919 + 300 0.62406364 -5.8889104 0 -4.9532559 0.063550326 + 350 0.6028994 -5.7552274 0 -4.8513043 -0.027499706 + 400 0.56811588 -5.5416058 0 -4.6898334 -0.061577561 + 450 0.54946762 -5.3409786 0 -4.5171654 -0.060007836 + 500 0.57962648 -5.2096808 0 -4.3406506 -0.052541306 + 550 0.61149882 -5.0920642 0 -4.175248 -0.03806361 + 600 0.63683327 -4.9975996 0 -4.0427996 -0.016868781 + 650 0.67007543 -4.9684574 0 -3.9638177 -0.00087204466 + 700 0.65648313 -4.9612522 0 -3.9769913 0.012954904 + 750 0.62636818 -4.9944273 0 -4.0553176 0.01206773 + 800 0.64474901 -5.0498682 0 -4.0832003 -0.0022579262 + 850 0.64765539 -5.0405969 0 -4.0695714 0.0061653637 + 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 + 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 + 1000 0.6407875 -4.9770134 0 -4.0162849 0.006441923 +Loop time of 0.35176 on 4 procs for 1000 steps with 2123 atoms + +Performance: 1228110.486 tau/day, 2842.848 timesteps/s +99.4% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.17072 | 0.18863 | 0.20606 | 3.7 | 53.63 +Neigh | 0.027172 | 0.030136 | 0.033131 | 1.7 | 8.57 +Comm | 0.024747 | 0.046514 | 0.067648 | 9.3 | 13.22 +Output | 0.00050033 | 0.0013632 | 0.0016527 | 1.3 | 0.39 +Modify | 0.082033 | 0.083964 | 0.086383 | 0.5 | 23.87 +Other | | 0.001148 | | | 0.33 + +Nlocal: 530.75 ave 542 max 513 min +Histogram: 1 0 0 0 1 0 0 0 0 2 +Nghost: 627.75 ave 650 max 612 min +Histogram: 1 0 1 0 1 0 0 0 0 1 +Neighs: 15919.2 ave 17564 max 14498 min +Histogram: 2 0 0 0 0 0 0 0 1 1 + +Total # of neighbors = 63677 +Ave neighs/atom = 29.993877 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:00 diff --git a/examples/pressure/in.cylinder b/examples/pressure/in.cylinder deleted file mode 100644 index 59bcebbbc3..0000000000 --- a/examples/pressure/in.cylinder +++ /dev/null @@ -1,40 +0,0 @@ -# compute pressure/cylinder for a cylindrical liquid-vapor interface - -units lj -atom_style atomic - -lattice fcc 0.8442 -region box block -10 10 -10 10 0 10 -region liquid cylinder z 0 0 5 0 10 -create_box 1 box -create_atoms 1 region liquid -mass 1 1.0 - -velocity all create 0.65 87287 loop geom - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 - -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no - -fix 1 all nvt temp 0.65 0.65 0.2 - - -thermo 50 -#dump id all atom 50 dump.cylinder - -#dump 2 all image 25 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 2 all recenter 0 0 NULL units lattice -compute p all pressure/cylinder 0 10 15 0.25 -fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector - - -run 1000 diff --git a/examples/pressure/in.flat b/examples/pressure/in.flat deleted file mode 100644 index 1cbf9d6ff2..0000000000 --- a/examples/pressure/in.flat +++ /dev/null @@ -1,42 +0,0 @@ -# compute pressure/cartesian for a flat liquid-vapor interface - -units lj -atom_style atomic - -lattice fcc 0.8442 -region box block 0 10 0 10 0 30 -region liquid block 0 10 0 10 10 20 -create_box 1 box -create_atoms 1 region liquid -mass 1 1.0 - -velocity all create 0.65 87287 loop geom - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 - -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no - -fix 1 all nvt temp 0.7 0.7 0.2 - - -thermo 50 -#dump id all atom 50 dump.flat - -#dump 2 all image 25 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 2 all recenter NULL NULL 15 units lattice -compute p1 all pressure/cartesian z 0.5 -fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector -#compute p2 all pressure/cartesian z 0.25 x 1 -#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector - - -run 1000 diff --git a/examples/pressure/in.sphere b/examples/pressure/in.sphere deleted file mode 100644 index 8715c2d321..0000000000 --- a/examples/pressure/in.sphere +++ /dev/null @@ -1,39 +0,0 @@ -# compute pressure/spherical for a spherical droplet - -units lj -atom_style atomic - -lattice fcc 0.8442 -region box block -10 10 -10 10 -10 10 -region liquid sphere 0 0 0 5 -create_box 1 box -create_atoms 1 region liquid -mass 1 1.0 - -velocity all create 0.65 87287 loop geom - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 - -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no - -fix 1 all nvt temp 0.65 0.65 0.2 - -#dump id all atom 50 dump.sphere - -thermo 50 -#dump 2 all image 25 image.*.jpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type & -# axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 - -fix 2 all recenter 0 0 0 units lattice -compute p all pressure/spherical 0 0 0 0.25 15 -fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector - - -run 1000 From aaa51d6fc61629b025cc7c1867cfa187de5a1832 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 6 Mar 2022 11:04:51 -0500 Subject: [PATCH 63/72] optimizations and avoiding floating point exceptions --- .../compute_pressure_cylinder.cpp | 11 ++++++---- .../compute_pressure_spherical.cpp | 22 ++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp b/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp index 13efd5c68d..d62f4d1fdf 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp @@ -19,6 +19,7 @@ #include "error.h" #include "force.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" @@ -33,6 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; +using MathSpecial::square; /*----------------------------------------------------------------------------------- Contributing authors: Cody K. Addington (North Carolina State University) @@ -305,12 +307,12 @@ void ComputePressureCyl::compute_array() // Check if kinetic option is set to yes if (kinetic_flag == 1) { - if (temp_R2 != 0) { + if ((temp_R2 != 0.0) && (x[i][0] != 0.0)) { // Radial velocity times R vr = (x[i][0] * v[i][0] + x[i][1] * v[i][1]); // Azimuthal velocity divided by R vp = (v[i][1] / x[i][0] - x[i][1] * v[i][0] / (x[i][0] * x[i][0])) / - (pow(x[i][1] / x[i][0], 2.0) + 1.0); + (square(x[i][1] / x[i][0]) + 1.0); Pkr_temp[j] += mass[type[i]] * vr * vr / temp_R2; Pkphi_temp[j] += mass[type[i]] * temp_R2 * vp * vp; @@ -425,8 +427,8 @@ void ComputePressureCyl::compute_array() C = risq - R2[ibin]; D = B * B - 4.0 * A * C; - // completely outside of R - if (D < 0.0) continue; + // completely outside of R or zero size bin + if ((D < 0.0) || (A == 0.0)) continue; sqrtD = sqrt(D); alpha1 = 0.5 * (-B + sqrtD) / A; @@ -456,6 +458,7 @@ void ComputePressureCyl::compute_array() // azimuthal pressure contribution (P_phiphi) for (int iphi = 0; iphi < nphi; iphi++) { + if ((dx * tangent[iphi] - dy) == 0.0) continue; alpha = (yi - xi * tangent[iphi]) / (dx * tangent[iphi] - dy); // no intersection with phi surface diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp index bebd9268d5..ef1e0e96ae 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp @@ -21,6 +21,7 @@ #include "force.h" #include "lattice.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" @@ -34,6 +35,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using MathSpecial::cube; +using MathSpecial::square; #define SMALL 1.0e-10 @@ -137,7 +140,7 @@ void ComputePressureSpherical::init() // Inverse volume of each spherical shell (bin) for (int bin = 0; bin < nbins; bin++) - invV[bin] = 3.0 / (4.0 * MY_PI * (pow((bin + 1) * bin_width, 3.0) - pow(bin * bin_width, 3.0))); + invV[bin] = 0.75 / (MY_PI * (cube((bin + 1) * bin_width) - cube(bin * bin_width))); int irequest = neighbor->request(this, instance_me); neighbor->requests[irequest]->pair = 0; @@ -220,13 +223,13 @@ void ComputePressureSpherical::compute_array() bin = (int) (r / bin_width); // Avoiding division by zero - if (r != 0) { + if ((r != 0.0) && (ri[0] != 0.0)) { theta = acos(ri[2] / r); tdens[bin] += 1.0; vr = (ri[0] * v[i][0] + ri[1] * v[i][1] + ri[2] * v[i][2]) / r; - vt = r * sin(theta) / (pow(ri[1] / ri[0], 2.0) + 1.0) * + vt = r * sin(theta) / (square(ri[1] / ri[0]) + 1.0) * ((ri[0] * v[i][1] - ri[1] * v[i][0]) / (ri[0] * ri[0])); - vp = (ri[2] * vr - r * v[i][2]) / (r * sqrt(1.0 - pow(ri[2] / r, 2.0))); + vp = (ri[2] * vr - r * v[i][2]) / (r * sqrt(1.0 - square(ri[2] / r))); tpkrr[bin] += vr * vr; tpktt[bin] += vt * vt; tpkpp[bin] += vp * vp; @@ -323,10 +326,10 @@ void ComputePressureSpherical::compute_array() rsqxy = ri[0] * ri[0] + ri[1] * ri[1]; ririjxy = qi[0] * ri[0] + qi[1] * ri[1]; sqrixy = qi[0] * qi[0] + qi[1] * qi[1]; - sqlxy0 = sqrixy - ririjxy * ririjxy / rsqxy; - A = pow(qi[0] * ri[1] - qi[1] * ri[0], 2.0); - C = sqrt(rsqxy * sqrixy - ririjxy * ririjxy); - B = sqrt(rsq * sqr - ririj * ririj); + sqlxy0 = (rsqxy != 0.0) ? sqrixy - ririjxy * ririjxy / rsqxy : 0.0; + A = square(qi[0] * ri[1] - qi[1] * ri[0]); + if (sqlxy0 > SMALL) C = sqrt(rsqxy * sqrixy - ririjxy * ririjxy); + if (sql0 > SMALL) B = sqrt(rsq * sqr - ririj * ririj); end_bin = (int) (sqrt(rsq + 2.0 * ririj + sqr) / bin_width); while (lb < 1.0) { @@ -367,10 +370,9 @@ void ComputePressureSpherical::compute_array() } else tpcrr[bin] -= f * rij * (lb - la); - if (sqlxy0 > SMALL) { + if (sqlxy0 > SMALL) tpctt[bin] -= (f / rij) * A / C * (atan2(rsqxy * lb + ririjxy, C) - atan2(rsqxy * la + ririjxy, C)); - } } l_sum += lb - la; la = lb; From 793db836d94b96a99d70283f216af9ac9a53a3c4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 6 Mar 2022 19:55:11 -0500 Subject: [PATCH 64/72] update .gitignore --- src/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/.gitignore b/src/.gitignore index a9eef4b371..4b924f6a99 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -489,10 +489,14 @@ /compute_plasticity_atom.h /compute_pressure_bocs.cpp /compute_pressure_bocs.h +/compute_pressure_cartesian.cpp +/compute_pressure_cartesian.h /compute_pressure_cylinder.cpp /compute_pressure_cylinder.h /compute_pressure_grem.cpp /compute_pressure_grem.h +/compute_pressure_spherical.cpp +/compute_pressure_spherical.h /compute_ptm_atom.cpp /compute_ptm_atom.h /compute_rigid_local.cpp From e857b923bc9f0b0aec988996554735f845da2235 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Sun, 6 Mar 2022 20:11:10 -0700 Subject: [PATCH 65/72] Added representative output to log files --- examples/PACKAGES/pressure/in.cylinder | 4 +- examples/PACKAGES/pressure/in.flat | 6 +- examples/PACKAGES/pressure/in.sphere | 3 +- .../pressure/log.6Mar2022.cylinder.g++.1 | 108 +++++++++-------- .../pressure/log.6Mar2022.cylinder.g++.4 | 110 +++++++++--------- .../PACKAGES/pressure/log.6Mar2022.flat.g++.1 | 72 ++++++------ .../PACKAGES/pressure/log.6Mar2022.flat.g++.4 | 70 ++++++----- .../pressure/log.6Mar2022.sphere.g++.1 | 105 +++++++++-------- .../pressure/log.6Mar2022.sphere.g++.4 | 107 +++++++++-------- 9 files changed, 285 insertions(+), 300 deletions(-) diff --git a/examples/PACKAGES/pressure/in.cylinder b/examples/PACKAGES/pressure/in.cylinder index 39c1c2ec99..8c7dfde595 100644 --- a/examples/PACKAGES/pressure/in.cylinder +++ b/examples/PACKAGES/pressure/in.cylinder @@ -20,8 +20,6 @@ neigh_modify every 20 delay 0 check no fix 1 all nvt temp 0.65 0.65 0.2 - -thermo 50 #dump id all atom 50 dump.cylinder #dump 2 all image 25 image.*.jpg type type & @@ -36,5 +34,7 @@ fix 2 all recenter 0 0 NULL units lattice compute p all pressure/cylinder 0 10 15 0.25 fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p[15][3] c_p[15][4] c_p[15][5] run 1000 diff --git a/examples/PACKAGES/pressure/in.flat b/examples/PACKAGES/pressure/in.flat index 8f7daa6aad..1c0e7873ba 100644 --- a/examples/PACKAGES/pressure/in.flat +++ b/examples/PACKAGES/pressure/in.flat @@ -21,8 +21,6 @@ neigh_modify every 20 delay 0 check no fix 1 all nvt temp 0.7 0.7 0.2 - -thermo 50 #dump id all atom 50 dump.flat #dump 2 all image 25 image.*.jpg type type & @@ -36,8 +34,8 @@ thermo 50 fix 2 all recenter NULL NULL 15 units lattice compute p1 all pressure/cartesian z 0.5 fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector -#compute p2 all pressure/cartesian z 0.25 x 1 -#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50][6] c_p1[50][7] c_p1[50][8] run 1000 diff --git a/examples/PACKAGES/pressure/in.sphere b/examples/PACKAGES/pressure/in.sphere index 423ee176ec..ed32705595 100644 --- a/examples/PACKAGES/pressure/in.sphere +++ b/examples/PACKAGES/pressure/in.sphere @@ -22,7 +22,6 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump id all atom 50 dump.sphere -thermo 50 #dump 2 all image 25 image.*.jpg type type & # axes yes 0.8 0.02 view 60 -30 #dump_modify 2 pad 3 @@ -35,5 +34,7 @@ fix 2 all recenter 0 0 0 units lattice compute p all pressure/spherical 0 0 0 0.25 15 fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] c_p[15][7] c_p[15][8] run 1000 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 index fedf1470da..5e8281e226 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 +++ b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 @@ -1,50 +1,48 @@ LAMMPS (17 Feb 2022) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task # compute pressure/cylinder for a cylindrical liquid-vapor interface -units lj -atom_style atomic +units lj +atom_style atomic -lattice fcc 0.8442 +lattice fcc 0.8442 Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 -region box block -10 10 -10 10 0 10 +region box block -10 10 -10 10 0 10 region liquid cylinder z 0 0 5 0 10 -create_box 1 box +create_box 1 box Created orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) 1 by 1 by 1 MPI processor grid -create_atoms 1 region liquid +create_atoms 1 region liquid Created 3170 atoms using lattice units in orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) create_atoms CPU = 0.001 seconds -mass 1 1.0 +mass 1 1.0 -velocity all create 0.65 87287 loop geom +velocity all create 0.65 87287 loop geom -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no -fix 1 all nvt temp 0.65 0.65 0.2 +fix 1 all nvt temp 0.65 0.65 0.2 +#dump id all atom 50 dump.cylinder -thermo 50 -#dump id all atom 50 dump.cylinder +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 fix 2 all recenter 0 0 NULL units lattice compute p all pressure/cylinder 0 10 15 0.25 fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p[15][3] c_p[15][4] c_p[15][5] -run 1000 +run 1000 CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE @@ -82,42 +80,42 @@ Neighbor list info ... stencil: none bin: none Per MPI rank memory allocation (min/avg/max) = 3.878 | 3.878 | 3.878 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0.65 -6.2219331 0 -5.2472407 -1.0193897 - 50 0.40121817 -5.7782233 0 -5.1765859 -0.33373915 - 100 0.56963398 -5.8789288 0 -5.0247474 -0.16859926 - 150 0.68424117 -5.9319873 0 -4.9059493 0.062850222 - 200 0.68608162 -5.9987099 0 -4.9699121 0.21439145 - 250 0.63422098 -6.047104 0 -5.0960726 0.30980602 - 300 0.64028254 -6.107331 0 -5.1472102 0.32133372 - 350 0.64906334 -6.1101542 0 -5.1368663 0.22288375 - 400 0.61848053 -6.0090821 0 -5.081654 0.053336092 - 450 0.60600519 -5.8710484 0 -4.9623273 -0.085701075 - 500 0.60383908 -5.7254198 0 -4.8199469 -0.15560848 - 550 0.60342483 -5.582958 0 -4.6781063 -0.18389998 - 600 0.61415824 -5.4571678 0 -4.5362211 -0.18398358 - 650 0.61997958 -5.3337392 0 -4.4040632 -0.13933776 - 700 0.65521411 -5.2724025 0 -4.2898914 -0.13977767 - 750 0.6525752 -5.18782 0 -4.2092659 -0.087418448 - 800 0.6711302 -5.1682283 0 -4.1618506 -0.080863195 - 850 0.64374266 -5.1290236 0 -4.1637142 -0.012480639 - 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 - 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 - 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 -Loop time of 2.54244 on 1 procs for 1000 steps with 3170 atoms +Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] + 0 0.65 -6.2219331 0 -5.2472407 -1.0193897 0.32064195 0.17340743 0.25100229 + 50 0.40121817 -5.7782233 0 -5.1765859 -0.33373915 0.25363113 0.28726307 0.31257228 + 100 0.56963398 -5.8789288 0 -5.0247474 -0.16859926 0.44360668 0.51390018 0.49962451 + 150 0.68424117 -5.9319873 0 -4.9059493 0.062850222 0.79698857 0.82006332 0.54174427 + 200 0.68608162 -5.9987099 0 -4.9699121 0.21439145 0.5262416 0.35324632 0.36677402 + 250 0.63422098 -6.047104 0 -5.0960726 0.30980602 0.31990528 0.51794384 0.55439151 + 300 0.64028254 -6.107331 0 -5.1472102 0.32133372 0.25974932 0.23423969 0.38800678 + 350 0.64906334 -6.1101542 0 -5.1368663 0.22288375 0.40593338 0.33184138 0.38346588 + 400 0.61848053 -6.0090821 0 -5.081654 0.053336092 0.32361049 0.23590707 0.30278183 + 450 0.60600519 -5.8710484 0 -4.9623273 -0.085701075 0.25062204 0.19408866 0.31948875 + 500 0.60383908 -5.7254198 0 -4.8199469 -0.15560848 0.4914663 0.20423135 0.31502277 + 550 0.60342483 -5.582958 0 -4.6781063 -0.18389998 0.81893511 0.48595334 0.52329443 + 600 0.61415824 -5.4571678 0 -4.5362211 -0.18398358 0.6604736 0.49706653 0.69658417 + 650 0.61997958 -5.3337392 0 -4.4040632 -0.13933776 0.51589832 0.70322669 0.59111363 + 700 0.65521411 -5.2724025 0 -4.2898914 -0.13977767 0.69933963 0.5964547 0.59421757 + 750 0.6525752 -5.18782 0 -4.2092659 -0.087418448 0.63261975 0.49555785 0.71379101 + 800 0.6711302 -5.1682283 0 -4.1618506 -0.080863195 0.66609099 0.56779202 0.64594057 + 850 0.64374266 -5.1290236 0 -4.1637142 -0.012480639 0.46355003 0.63364111 0.64701994 + 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 0.50996272 0.40697988 0.69606954 + 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 0.46323559 0.64562517 0.6484849 + 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 0.62372474 0.46065491 0.45844619 +Loop time of 3.23802 on 1 procs for 1000 steps with 3170 atoms -Performance: 169915.320 tau/day, 393.322 timesteps/s -99.8% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 133414.796 tau/day, 308.831 timesteps/s +99.9% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.1455 | 1.1455 | 1.1455 | 0.0 | 45.05 -Neigh | 0.17719 | 0.17719 | 0.17719 | 0.0 | 6.97 -Comm | 0.0067252 | 0.0067252 | 0.0067252 | 0.0 | 0.26 -Output | 0.00069549 | 0.00069549 | 0.00069549 | 0.0 | 0.03 -Modify | 1.2081 | 1.2081 | 1.2081 | 0.0 | 47.52 -Other | | 0.00421 | | | 0.17 +Pair | 0.90962 | 0.90962 | 0.90962 | 0.0 | 28.09 +Neigh | 0.13687 | 0.13687 | 0.13687 | 0.0 | 4.23 +Comm | 0.0048607 | 0.0048607 | 0.0048607 | 0.0 | 0.15 +Output | 1.4242 | 1.4242 | 1.4242 | 0.0 | 43.98 +Modify | 0.7598 | 0.7598 | 0.7598 | 0.0 | 23.46 +Other | | 0.002623 | | | 0.08 Nlocal: 3170 ave 3170 max 3170 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -130,4 +128,4 @@ Total # of neighbors = 101768 Ave neighs/atom = 32.10347 Neighbor list builds = 50 Dangerous builds not checked -Total wall time: 0:00:02 +Total wall time: 0:00:03 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 index af787b7b58..ca5f6969e5 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 +++ b/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 @@ -1,50 +1,48 @@ LAMMPS (17 Feb 2022) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task # compute pressure/cylinder for a cylindrical liquid-vapor interface -units lj -atom_style atomic +units lj +atom_style atomic -lattice fcc 0.8442 +lattice fcc 0.8442 Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 -region box block -10 10 -10 10 0 10 +region box block -10 10 -10 10 0 10 region liquid cylinder z 0 0 5 0 10 -create_box 1 box +create_box 1 box Created orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) 2 by 2 by 1 MPI processor grid -create_atoms 1 region liquid +create_atoms 1 region liquid Created 3170 atoms using lattice units in orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) - create_atoms CPU = 0.000 seconds -mass 1 1.0 + create_atoms CPU = 0.001 seconds +mass 1 1.0 -velocity all create 0.65 87287 loop geom +velocity all create 0.65 87287 loop geom -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no -fix 1 all nvt temp 0.65 0.65 0.2 +fix 1 all nvt temp 0.65 0.65 0.2 +#dump id all atom 50 dump.cylinder -thermo 50 -#dump id all atom 50 dump.cylinder +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 - -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 fix 2 all recenter 0 0 NULL units lattice compute p all pressure/cylinder 0 10 15 0.25 fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p[15][3] c_p[15][4] c_p[15][5] -run 1000 +run 1000 CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE @@ -82,42 +80,42 @@ Neighbor list info ... stencil: none bin: none Per MPI rank memory allocation (min/avg/max) = 3.023 | 3.033 | 3.043 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0.65 -6.2219331 0 -5.2472407 -1.0193897 - 50 0.40121817 -5.7782233 0 -5.1765859 -0.33373915 - 100 0.56963398 -5.8789288 0 -5.0247474 -0.16859926 - 150 0.68424117 -5.9319873 0 -4.9059493 0.062850222 - 200 0.68608162 -5.9987099 0 -4.9699121 0.21439145 - 250 0.63422098 -6.047104 0 -5.0960726 0.30980602 - 300 0.64028254 -6.107331 0 -5.1472102 0.32133372 - 350 0.64906334 -6.1101542 0 -5.1368663 0.22288375 - 400 0.61848053 -6.0090821 0 -5.081654 0.053336092 - 450 0.60600519 -5.8710484 0 -4.9623273 -0.085701075 - 500 0.60383908 -5.7254198 0 -4.8199469 -0.15560848 - 550 0.60342483 -5.582958 0 -4.6781063 -0.18389998 - 600 0.61415824 -5.4571678 0 -4.5362211 -0.18398358 - 650 0.61997958 -5.3337392 0 -4.4040632 -0.13933776 - 700 0.65521411 -5.2724025 0 -4.2898914 -0.13977767 - 750 0.6525752 -5.18782 0 -4.2092659 -0.087418448 - 800 0.6711302 -5.1682283 0 -4.1618506 -0.080863195 - 850 0.64374266 -5.1290236 0 -4.1637142 -0.012480639 - 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 - 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 - 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 -Loop time of 0.709732 on 4 procs for 1000 steps with 3170 atoms +Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] + 0 0.65 -6.2219331 0 -5.2472407 -1.0193897 0.32064195 0.17340743 0.25100229 + 50 0.40121817 -5.7782233 0 -5.1765859 -0.33373915 0.25363113 0.28726307 0.31257228 + 100 0.56963398 -5.8789288 0 -5.0247474 -0.16859926 0.44360668 0.51390018 0.49962451 + 150 0.68424117 -5.9319873 0 -4.9059493 0.062850222 0.79698857 0.82006332 0.54174427 + 200 0.68608162 -5.9987099 0 -4.9699121 0.21439145 0.5262416 0.35324632 0.36677402 + 250 0.63422098 -6.047104 0 -5.0960726 0.30980602 0.31990528 0.51794384 0.55439151 + 300 0.64028254 -6.107331 0 -5.1472102 0.32133372 0.25974932 0.23423969 0.38800678 + 350 0.64906334 -6.1101542 0 -5.1368663 0.22288375 0.40593338 0.33184138 0.38346588 + 400 0.61848053 -6.0090821 0 -5.081654 0.053336092 0.32361049 0.23590707 0.30278183 + 450 0.60600519 -5.8710484 0 -4.9623273 -0.085701075 0.25062204 0.19408866 0.31948875 + 500 0.60383908 -5.7254198 0 -4.8199469 -0.15560848 0.4914663 0.20423135 0.31502277 + 550 0.60342483 -5.582958 0 -4.6781063 -0.18389998 0.81893511 0.48595334 0.52329443 + 600 0.61415824 -5.4571678 0 -4.5362211 -0.18398358 0.6604736 0.49706653 0.69658417 + 650 0.61997958 -5.3337392 0 -4.4040632 -0.13933776 0.51589832 0.70322669 0.59111363 + 700 0.65521411 -5.2724025 0 -4.2898914 -0.13977767 0.69933963 0.5964547 0.59421757 + 750 0.6525752 -5.18782 0 -4.2092659 -0.087418448 0.63261975 0.49555785 0.71379101 + 800 0.6711302 -5.1682283 0 -4.1618506 -0.080863195 0.66609099 0.56779202 0.64594057 + 850 0.64374266 -5.1290236 0 -4.1637142 -0.012480639 0.46355003 0.63364111 0.64701994 + 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 0.50996272 0.40697988 0.69606954 + 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 0.46323559 0.64562517 0.6484849 + 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 0.62372474 0.46065491 0.45844619 +Loop time of 0.961057 on 4 procs for 1000 steps with 3170 atoms -Performance: 608680.564 tau/day, 1408.983 timesteps/s -99.6% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 449505.261 tau/day, 1040.521 timesteps/s +99.9% CPU use with 4 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.28555 | 0.29497 | 0.30391 | 1.3 | 41.56 -Neigh | 0.046067 | 0.046753 | 0.047531 | 0.3 | 6.59 -Comm | 0.026197 | 0.037315 | 0.049469 | 4.6 | 5.26 -Output | 0.00049542 | 0.0013801 | 0.0016773 | 1.4 | 0.19 -Modify | 0.32518 | 0.32751 | 0.33044 | 0.3 | 46.15 -Other | | 0.001804 | | | 0.25 +Pair | 0.24978 | 0.2556 | 0.26053 | 1.0 | 26.60 +Neigh | 0.036812 | 0.037364 | 0.03795 | 0.2 | 3.89 +Comm | 0.027115 | 0.033034 | 0.040202 | 3.2 | 3.44 +Output | 0.40636 | 0.40704 | 0.40727 | 0.1 | 42.35 +Modify | 0.22584 | 0.22683 | 0.2283 | 0.2 | 23.60 +Other | | 0.001187 | | | 0.12 Nlocal: 792.5 ave 794 max 791 min Histogram: 1 0 0 1 0 0 1 0 0 1 @@ -130,4 +128,4 @@ Total # of neighbors = 101768 Ave neighs/atom = 32.10347 Neighbor list builds = 50 Dangerous builds not checked -Total wall time: 0:00:00 +Total wall time: 0:00:01 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 index 0141824bcf..01fbd34e1b 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 +++ b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 @@ -1,6 +1,4 @@ LAMMPS (17 Feb 2022) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task # compute pressure/cartesian for a flat liquid-vapor interface units lj @@ -30,8 +28,6 @@ neigh_modify every 20 delay 0 check no fix 1 all nvt temp 0.7 0.7 0.2 - -thermo 50 #dump id all atom 50 dump.flat #dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 @@ -44,9 +40,9 @@ fix 2 all recenter NULL NULL 15 units lattice compute p1 all pressure/cartesian z 0.5 Adjusting first bin width for compute pressure/cartesian from 0.500000 to 0.503879 fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector -#compute p2 all pressure/cartesian z 0.25 x 1 -#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50][6] c_p1[50][7] c_p1[50][8] run 1000 @@ -88,42 +84,42 @@ Neighbor list info ... stencil: none bin: none Per MPI rank memory allocation (min/avg/max) = 3.943 | 3.943 | 3.943 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0.65 -6.5342767 0 -5.5595088 -1.9070205 - 50 0.36842234 -6.0304191 0 -5.4779172 -0.76896135 - 100 0.50896152 -6.0786202 0 -5.3153597 -0.58839893 - 150 0.63567071 -6.0832159 0 -5.1299368 -0.29587266 - 200 0.72324528 -6.0689996 0 -4.98439 -0.020342078 - 250 0.74387008 -6.1188743 0 -5.0033349 0.11337395 - 300 0.69112666 -6.1838992 0 -5.1474561 0.18290797 - 350 0.67772633 -6.2400592 0 -5.2237117 0.27698807 - 400 0.70714238 -6.2783031 0 -5.2178421 0.41150934 - 450 0.71843478 -6.2870874 0 -5.2096918 0.57099811 - 500 0.69813385 -6.3041653 0 -5.2572139 0.53883987 - 550 0.67043069 -6.3035289 0 -5.2981223 0.36370002 - 600 0.68196102 -6.26442 0 -5.241722 0.22122892 - 650 0.69413189 -6.1759937 0 -5.1350438 0.12782621 - 700 0.70034968 -6.1028735 0 -5.0525991 0.029208853 - 750 0.70266272 -6.036839 0 -4.9830959 -0.088703619 - 800 0.68551399 -5.9410263 0 -4.9130002 -0.18134075 - 850 0.6866836 -5.8390431 0 -4.8092629 -0.27593375 - 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 - 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 - 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 -Loop time of 2.13769 on 1 procs for 1000 steps with 4200 atoms +Step Temp E_pair E_mol TotEng Press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50][6] c_p1[50][7] c_p1[50][8] + 0 0.65 -6.5342767 0 -5.5595088 -1.9070205 0 0 0 -3.2273011 -3.2273011 -6.2353173 + 50 0.36842234 -6.0304191 0 -5.4779172 -0.76896135 0.17498049 0.24679132 0.30689944 -2.7027121 -3.7561009 -1.9919263 + 100 0.50896152 -6.0786202 0 -5.3153597 -0.58839893 0.23650081 0.36888111 0.20899869 0.022887179 -0.64485123 -2.1340762 + 150 0.63567071 -6.0832159 0 -5.1299368 -0.29587266 0.33559137 0.37138538 0.35269743 -0.68803817 -0.68430121 -1.7978609 + 200 0.72324528 -6.0689996 0 -4.98439 -0.020342078 0.34858492 0.37486254 0.35223764 -0.36879601 0.20311125 -1.0543778 + 250 0.74387008 -6.1188743 0 -5.0033349 0.11337395 0.55467125 0.43963204 0.5365495 1.5554907 1.4490947 0.71944827 + 300 0.69112666 -6.1838992 0 -5.1474561 0.18290797 0.7992109 0.68033596 0.58700814 3.5089443 4.2857349 3.2581159 + 350 0.67772633 -6.2400592 0 -5.2237117 0.27698807 0.67830305 0.6761273 0.49704933 4.5557554 4.9263741 3.1723378 + 400 0.70714238 -6.2783031 0 -5.2178421 0.41150934 0.49425756 0.60546702 0.7065831 4.2198909 3.9825086 2.8430036 + 450 0.71843478 -6.2870874 0 -5.2096918 0.57099811 0.46302073 0.39182703 0.63984313 3.4046591 4.6556487 1.9030295 + 500 0.69813385 -6.3041653 0 -5.2572139 0.53883987 0.68729617 0.59378012 0.48664837 7.3244236 5.6670237 2.596186 + 550 0.67043069 -6.3035289 0 -5.2981223 0.36370002 0.60222672 0.48812986 0.43026583 3.4315746 3.580443 1.541178 + 600 0.68196102 -6.26442 0 -5.241722 0.22122892 0.62489919 0.52111415 0.54877849 2.8361857 2.3873253 1.2353165 + 650 0.69413189 -6.1759937 0 -5.1350438 0.12782621 0.53663901 0.4268154 0.48481915 2.55077 2.4568322 0.98505597 + 700 0.70034968 -6.1028735 0 -5.0525991 0.029208853 0.40182056 0.43835043 0.4079067 2.639108 2.0850376 0.84200793 + 750 0.70266272 -6.036839 0 -4.9830959 -0.088703619 0.45987327 0.44507175 0.51137827 0.80703415 0.9388271 -0.94688133 + 800 0.68551399 -5.9410263 0 -4.9130002 -0.18134075 0.41401386 0.52006295 0.48363173 -0.51532128 -0.59039802 -1.6540483 + 850 0.6866836 -5.8390431 0 -4.8092629 -0.27593375 0.44348212 0.4806576 0.51909045 -0.32773941 -0.19125952 -1.746798 + 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 0.41295263 0.58244529 0.51061419 1.1176204 0.85808642 -0.50262868 + 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 0.50435084 0.49611677 0.5263358 -1.0396644 -0.85737705 -1.3764034 + 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 0.63890467 0.66446292 0.51353613 -0.39241484 -0.64122487 -0.78501452 +Loop time of 1.84234 on 1 procs for 1000 steps with 4200 atoms -Performance: 202087.264 tau/day, 467.795 timesteps/s -99.5% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 234484.767 tau/day, 542.789 timesteps/s +99.9% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.6853 | 1.6853 | 1.6853 | 0.0 | 78.84 -Neigh | 0.2494 | 0.2494 | 0.2494 | 0.0 | 11.67 -Comm | 0.020319 | 0.020319 | 0.020319 | 0.0 | 0.95 -Output | 0.0006408 | 0.0006408 | 0.0006408 | 0.0 | 0.03 -Modify | 0.17491 | 0.17491 | 0.17491 | 0.0 | 8.18 -Other | | 0.007093 | | | 0.33 +Pair | 1.3351 | 1.3351 | 1.3351 | 0.0 | 72.47 +Neigh | 0.19357 | 0.19357 | 0.19357 | 0.0 | 10.51 +Comm | 0.015339 | 0.015339 | 0.015339 | 0.0 | 0.83 +Output | 0.14428 | 0.14428 | 0.14428 | 0.0 | 7.83 +Modify | 0.14965 | 0.14965 | 0.14965 | 0.0 | 8.12 +Other | | 0.00435 | | | 0.24 Nlocal: 4200 ave 4200 max 4200 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -136,4 +132,4 @@ Total # of neighbors = 144737 Ave neighs/atom = 34.46119 Neighbor list builds = 50 Dangerous builds not checked -Total wall time: 0:00:02 +Total wall time: 0:00:01 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 index 04bed6e521..dd7b61973c 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 +++ b/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 @@ -1,6 +1,4 @@ LAMMPS (17 Feb 2022) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task # compute pressure/cartesian for a flat liquid-vapor interface units lj @@ -30,8 +28,6 @@ neigh_modify every 20 delay 0 check no fix 1 all nvt temp 0.7 0.7 0.2 - -thermo 50 #dump id all atom 50 dump.flat #dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 @@ -44,9 +40,9 @@ fix 2 all recenter NULL NULL 15 units lattice compute p1 all pressure/cartesian z 0.5 Adjusting first bin width for compute pressure/cartesian from 0.500000 to 0.503879 fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector -#compute p2 all pressure/cartesian z 0.25 x 1 -#fix 4 all ave/time 100 1 100 c_p2[*] file flat_2d.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50][6] c_p1[50][7] c_p1[50][8] run 1000 @@ -88,42 +84,42 @@ Neighbor list info ... stencil: none bin: none Per MPI rank memory allocation (min/avg/max) = 3.083 | 3.083 | 3.083 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0.65 -6.5342767 0 -5.5595088 -1.9070205 - 50 0.36842234 -6.0304191 0 -5.4779172 -0.76896135 - 100 0.50896152 -6.0786202 0 -5.3153597 -0.58839893 - 150 0.63567071 -6.0832159 0 -5.1299368 -0.29587266 - 200 0.72324528 -6.0689996 0 -4.98439 -0.020342078 - 250 0.74387008 -6.1188743 0 -5.0033349 0.11337395 - 300 0.69112666 -6.1838992 0 -5.1474561 0.18290797 - 350 0.67772633 -6.2400592 0 -5.2237117 0.27698807 - 400 0.70714238 -6.2783031 0 -5.2178421 0.41150934 - 450 0.71843478 -6.2870874 0 -5.2096918 0.57099811 - 500 0.69813385 -6.3041653 0 -5.2572139 0.53883987 - 550 0.67043069 -6.3035289 0 -5.2981223 0.36370002 - 600 0.68196102 -6.26442 0 -5.241722 0.22122892 - 650 0.69413189 -6.1759937 0 -5.1350438 0.12782621 - 700 0.70034968 -6.1028735 0 -5.0525991 0.029208853 - 750 0.70266272 -6.036839 0 -4.9830959 -0.088703619 - 800 0.68551399 -5.9410263 0 -4.9130002 -0.18134075 - 850 0.6866836 -5.8390431 0 -4.8092629 -0.27593375 - 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 - 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 - 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 -Loop time of 0.675356 on 4 procs for 1000 steps with 4200 atoms +Step Temp E_pair E_mol TotEng Press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50][6] c_p1[50][7] c_p1[50][8] + 0 0.65 -6.5342767 0 -5.5595088 -1.9070205 0 0 0 -3.2273011 -3.2273011 -6.2353173 + 50 0.36842234 -6.0304191 0 -5.4779172 -0.76896135 0.17498049 0.24679132 0.30689944 -2.7166373 -3.7637224 -2.0127226 + 100 0.50896152 -6.0786202 0 -5.3153597 -0.58839893 0.23650081 0.36888111 0.20899869 0.075982565 -0.67149414 -2.0813638 + 150 0.63567071 -6.0832159 0 -5.1299368 -0.29587266 0.33559137 0.37138538 0.35269743 -0.594738 -0.64300667 -1.8205987 + 200 0.72324528 -6.0689996 0 -4.98439 -0.020342078 0.34858492 0.37486254 0.35223764 -0.41021281 0.2947434 -1.1236003 + 250 0.74387008 -6.1188743 0 -5.0033349 0.11337395 0.55467125 0.43963204 0.5365495 1.6429753 1.5080502 0.71159566 + 300 0.69112666 -6.1838992 0 -5.1474561 0.18290797 0.7992109 0.68033596 0.58700814 3.7385773 4.4487825 3.2496799 + 350 0.67772633 -6.2400592 0 -5.2237117 0.27698807 0.67830305 0.6761273 0.49704933 4.417328 4.2774375 2.9659443 + 400 0.70714238 -6.2783031 0 -5.2178421 0.41150934 0.49425756 0.60546702 0.7065831 4.0688803 3.6955596 2.4302757 + 450 0.71843478 -6.2870874 0 -5.2096918 0.57099811 0.46302073 0.39182703 0.63984313 3.2262414 4.6575131 1.7427299 + 500 0.69813385 -6.3041653 0 -5.2572139 0.53883987 0.68729617 0.59378012 0.48664837 7.3183445 5.4826447 2.4408851 + 550 0.67043069 -6.3035289 0 -5.2981223 0.36370002 0.60222672 0.48812986 0.43026583 3.150271 3.4293302 1.3715771 + 600 0.68196102 -6.26442 0 -5.241722 0.22122892 0.62489919 0.52111415 0.54877849 2.7015405 2.3052992 1.1698065 + 650 0.69413189 -6.1759937 0 -5.1350438 0.12782621 0.53663901 0.4268154 0.48481915 2.5493901 2.4516896 0.94798771 + 700 0.70034968 -6.1028735 0 -5.0525991 0.029208853 0.40182056 0.43835043 0.4079067 2.3705988 1.8595619 0.58948475 + 750 0.70266272 -6.036839 0 -4.9830959 -0.088703619 0.45987327 0.44507175 0.51137827 0.81818861 0.92355985 -0.96989084 + 800 0.68551399 -5.9410263 0 -4.9130002 -0.18134075 0.41401386 0.52006295 0.48363173 -0.5096947 -0.71814258 -1.7601911 + 850 0.6866836 -5.8390431 0 -4.8092629 -0.27593375 0.44348212 0.4806576 0.51909045 -0.35276239 -0.19119571 -1.8079633 + 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 0.41295263 0.58244529 0.51061419 1.0812494 0.85110914 -0.52125789 + 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 0.50435084 0.49611677 0.5263358 -1.1084255 -0.87093225 -1.4488231 + 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 0.63890467 0.66446292 0.51353613 -0.39754859 -0.7422202 -0.84836654 +Loop time of 0.575049 on 4 procs for 1000 steps with 4200 atoms -Performance: 639662.349 tau/day, 1480.700 timesteps/s -99.4% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 751240.091 tau/day, 1738.982 timesteps/s +99.8% CPU use with 4 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.47174 | 0.48429 | 0.49671 | 1.5 | 71.71 -Neigh | 0.069839 | 0.071447 | 0.072509 | 0.4 | 10.58 -Comm | 0.046053 | 0.059527 | 0.073675 | 4.5 | 8.81 -Output | 0.0007041 | 0.0022594 | 0.0027829 | 1.9 | 0.33 -Modify | 0.054631 | 0.055179 | 0.056783 | 0.4 | 8.17 -Other | | 0.002651 | | | 0.39 +Pair | 0.37292 | 0.38209 | 0.39205 | 1.1 | 66.44 +Neigh | 0.054607 | 0.054984 | 0.055671 | 0.2 | 9.56 +Comm | 0.036134 | 0.046597 | 0.055864 | 3.3 | 8.10 +Output | 0.042435 | 0.043507 | 0.043865 | 0.3 | 7.57 +Modify | 0.045591 | 0.046196 | 0.04751 | 0.4 | 8.03 +Other | | 0.001678 | | | 0.29 Nlocal: 1050 ave 1071 max 1026 min Histogram: 1 0 0 0 0 2 0 0 0 1 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 index c09f34f294..636a90b1fa 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 +++ b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 @@ -1,50 +1,49 @@ LAMMPS (17 Feb 2022) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task # compute pressure/spherical for a spherical droplet -units lj -atom_style atomic +units lj +atom_style atomic -lattice fcc 0.8442 +lattice fcc 0.8442 Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 -region box block -10 10 -10 10 -10 10 +region box block -10 10 -10 10 -10 10 region liquid sphere 0 0 0 5 -create_box 1 box +create_box 1 box Created orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) 1 by 1 by 1 MPI processor grid -create_atoms 1 region liquid +create_atoms 1 region liquid Created 2123 atoms using lattice units in orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) create_atoms CPU = 0.001 seconds -mass 1 1.0 +mass 1 1.0 -velocity all create 0.65 87287 loop geom +velocity all create 0.65 87287 loop geom -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no -fix 1 all nvt temp 0.65 0.65 0.2 +fix 1 all nvt temp 0.65 0.65 0.2 -#dump id all atom 50 dump.sphere +#dump id all atom 50 dump.sphere -thermo 50 -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 fix 2 all recenter 0 0 0 units lattice compute p all pressure/spherical 0 0 0 0.25 15 Adjusting bin width for compute pressure/spherical from 0.250000 to 0.245902 fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] c_p[15][7] c_p[15][8] -run 1000 +run 1000 CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE @@ -80,42 +79,42 @@ Neighbor list info ... stencil: none bin: none Per MPI rank memory allocation (min/avg/max) = 3.11 | 3.11 | 3.11 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0.65 -5.982005 0 -5.0074642 -0.32476388 - 50 0.42414771 -5.5700167 0 -4.9340948 -0.074492286 - 100 0.64021145 -5.7405134 0 -4.7806486 -0.0054535408 - 150 0.72663247 -5.8366691 0 -4.7472338 0.089984367 - 200 0.63460122 -5.8577473 0 -4.9062939 0.14140872 - 250 0.62199115 -5.9027866 0 -4.9702393 0.13328919 - 300 0.62406364 -5.8889104 0 -4.9532559 0.063550326 - 350 0.6028994 -5.7552274 0 -4.8513043 -0.027499706 - 400 0.56811588 -5.5416058 0 -4.6898334 -0.061577561 - 450 0.54946762 -5.3409786 0 -4.5171654 -0.060007836 - 500 0.57962648 -5.2096808 0 -4.3406506 -0.052541306 - 550 0.61149882 -5.0920642 0 -4.175248 -0.03806361 - 600 0.63683327 -4.9975996 0 -4.0427996 -0.016868781 - 650 0.67007543 -4.9684574 0 -3.9638177 -0.00087204466 - 700 0.65648313 -4.9612522 0 -3.9769913 0.012954904 - 750 0.62636818 -4.9944273 0 -4.0553176 0.01206773 - 800 0.64474901 -5.0498682 0 -4.0832003 -0.0022579262 - 850 0.64765539 -5.0405969 0 -4.0695714 0.0061653637 - 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 - 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 - 1000 0.6407875 -4.9770134 0 -4.0162849 0.0064419231 -Loop time of 1.12311 on 1 procs for 1000 steps with 2123 atoms +Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] c_p[15][7] c_p[15][8] + 0 0.65 -5.982005 0 -5.0074642 -0.32476388 0.35627939 0.62462251 0.46815062 -6.0757313 -6.2674721 -6.2664951 + 50 0.42414771 -5.5700167 0 -4.9340948 -0.074492286 0.28886433 0.24978381 0.44948344 -3.0743795 -3.1577945 -3.3227869 + 100 0.64021145 -5.7405134 0 -4.7806486 -0.0054535408 0.66078235 0.50006981 0.71100403 -1.4906387 -2.2744728 -2.4525275 + 150 0.72663247 -5.8366691 0 -4.7472338 0.089984367 0.67171939 0.88397719 0.68237586 1.7071253 0.70667671 0.24254734 + 200 0.63460122 -5.8577473 0 -4.9062939 0.14140872 0.42462947 0.59385606 0.7268978 3.72768 5.4212679 5.6873694 + 250 0.62199115 -5.9027866 0 -4.9702393 0.13328919 0.59870532 0.36146182 0.42120197 4.6777028 2.6837762 2.5065016 + 300 0.62406364 -5.8889104 0 -4.9532559 0.063550326 0.52789691 0.2680398 0.54676177 0.46537388 -0.050263067 0.083348197 + 350 0.6028994 -5.7552274 0 -4.8513043 -0.027499706 0.50997812 0.70982549 0.6490879 -1.0217051 -2.1273075 -1.9062299 + 400 0.56811588 -5.5416058 0 -4.6898334 -0.061577561 0.47083533 0.77746521 0.675965 -1.3048699 -2.2462223 -2.1474791 + 450 0.54946762 -5.3409786 0 -4.5171654 -0.060007836 0.79992593 0.45761929 0.41283856 -1.6618299 -2.8617998 -2.6660581 + 500 0.57962648 -5.2096808 0 -4.3406506 -0.052541306 0.58252285 0.62111149 0.53587504 -2.0015685 -3.0227113 -2.7113064 + 550 0.61149882 -5.0920642 0 -4.175248 -0.03806361 0.69036525 0.44434221 0.43153208 -1.919538 -2.3974949 -2.3053297 + 600 0.63683327 -4.9975996 0 -4.0427996 -0.016868781 0.61515828 0.47182625 0.4742184 -1.2064203 -1.1407252 -0.58758361 + 650 0.67007543 -4.9684574 0 -3.9638177 -0.00087204466 0.78120956 1.0550498 0.80318482 0.51859121 -0.46675133 -0.49805387 + 700 0.65648313 -4.9612522 0 -3.9769913 0.012954904 0.94001121 0.61816695 0.54104923 -0.95635736 -1.4524645 -1.0781047 + 750 0.62636818 -4.9944273 0 -4.0553176 0.01206773 0.75957119 0.70733827 0.60927279 -0.034744141 -1.0763778 -1.160248 + 800 0.64474901 -5.0498682 0 -4.0832003 -0.0022579262 0.63509307 0.56543999 0.51633686 -0.84957679 -0.13098346 -0.76445249 + 850 0.64765539 -5.0405969 0 -4.0695714 0.0061653637 0.56204713 0.59190191 0.44560131 -0.45171595 -0.58981086 0.10218425 + 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 0.50392257 0.49473611 0.46727165 -0.096394732 -1.3622008 -1.0134429 + 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 0.47764992 0.56974826 0.58927977 0.93251392 -0.29722045 0.17614353 + 1000 0.6407875 -4.9770134 0 -4.0162849 0.0064419231 0.87635667 0.51303644 0.45437033 0.14319333 0.10005421 0.29188404 +Loop time of 1.33554 on 1 procs for 1000 steps with 2123 atoms -Performance: 384646.552 tau/day, 890.386 timesteps/s -99.7% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 323464.483 tau/day, 748.760 timesteps/s +99.8% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.72699 | 0.72699 | 0.72699 | 0.0 | 64.73 -Neigh | 0.11083 | 0.11083 | 0.11083 | 0.0 | 9.87 -Comm | 0.0011647 | 0.0011647 | 0.0011647 | 0.0 | 0.10 -Output | 0.0005541 | 0.0005541 | 0.0005541 | 0.0 | 0.05 -Modify | 0.28132 | 0.28132 | 0.28132 | 0.0 | 25.05 -Other | | 0.002256 | | | 0.20 +Pair | 0.57217 | 0.57217 | 0.57217 | 0.0 | 42.84 +Neigh | 0.084723 | 0.084723 | 0.084723 | 0.0 | 6.34 +Comm | 0.0010257 | 0.0010257 | 0.0010257 | 0.0 | 0.08 +Output | 0.42685 | 0.42685 | 0.42685 | 0.0 | 31.96 +Modify | 0.24946 | 0.24946 | 0.24946 | 0.0 | 18.68 +Other | | 0.001311 | | | 0.10 Nlocal: 2123 ave 2123 max 2123 min Histogram: 1 0 0 0 0 0 0 0 0 0 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 index 24267e6cf4..33ee78ba4c 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 +++ b/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 @@ -1,50 +1,49 @@ LAMMPS (17 Feb 2022) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task # compute pressure/spherical for a spherical droplet -units lj -atom_style atomic +units lj +atom_style atomic -lattice fcc 0.8442 +lattice fcc 0.8442 Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 -region box block -10 10 -10 10 -10 10 +region box block -10 10 -10 10 -10 10 region liquid sphere 0 0 0 5 -create_box 1 box +create_box 1 box Created orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) 1 by 2 by 2 MPI processor grid -create_atoms 1 region liquid +create_atoms 1 region liquid Created 2123 atoms using lattice units in orthogonal box = (-16.795962 -16.795962 -16.795962) to (16.795962 16.795962 16.795962) - create_atoms CPU = 0.001 seconds -mass 1 1.0 + create_atoms CPU = 0.000 seconds +mass 1 1.0 -velocity all create 0.65 87287 loop geom +velocity all create 0.65 87287 loop geom -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 2.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 2.5 -neighbor 0.3 bin -neigh_modify every 20 delay 0 check no +neighbor 0.3 bin +neigh_modify every 20 delay 0 check no -fix 1 all nvt temp 0.65 0.65 0.2 +fix 1 all nvt temp 0.65 0.65 0.2 -#dump id all atom 50 dump.sphere +#dump id all atom 50 dump.sphere -thermo 50 -#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 2 pad 3 +#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 2 pad 3 -#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 -#dump_modify 3 pad 3 +#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30 +#dump_modify 3 pad 3 fix 2 all recenter 0 0 0 units lattice compute p all pressure/spherical 0 0 0 0.25 15 Adjusting bin width for compute pressure/spherical from 0.250000 to 0.245902 fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector +thermo 50 +thermo_style custom step temp epair emol etotal press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] c_p[15][7] c_p[15][8] -run 1000 +run 1000 CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE @@ -80,42 +79,42 @@ Neighbor list info ... stencil: none bin: none Per MPI rank memory allocation (min/avg/max) = 3.068 | 3.078 | 3.082 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0.65 -5.982005 0 -5.0074642 -0.32476388 - 50 0.42414771 -5.5700167 0 -4.9340948 -0.074492286 - 100 0.64021145 -5.7405134 0 -4.7806486 -0.0054535408 - 150 0.72663247 -5.8366691 0 -4.7472338 0.089984367 - 200 0.63460122 -5.8577473 0 -4.9062939 0.14140872 - 250 0.62199115 -5.9027866 0 -4.9702393 0.13328919 - 300 0.62406364 -5.8889104 0 -4.9532559 0.063550326 - 350 0.6028994 -5.7552274 0 -4.8513043 -0.027499706 - 400 0.56811588 -5.5416058 0 -4.6898334 -0.061577561 - 450 0.54946762 -5.3409786 0 -4.5171654 -0.060007836 - 500 0.57962648 -5.2096808 0 -4.3406506 -0.052541306 - 550 0.61149882 -5.0920642 0 -4.175248 -0.03806361 - 600 0.63683327 -4.9975996 0 -4.0427996 -0.016868781 - 650 0.67007543 -4.9684574 0 -3.9638177 -0.00087204466 - 700 0.65648313 -4.9612522 0 -3.9769913 0.012954904 - 750 0.62636818 -4.9944273 0 -4.0553176 0.01206773 - 800 0.64474901 -5.0498682 0 -4.0832003 -0.0022579262 - 850 0.64765539 -5.0405969 0 -4.0695714 0.0061653637 - 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 - 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 - 1000 0.6407875 -4.9770134 0 -4.0162849 0.006441923 -Loop time of 0.35176 on 4 procs for 1000 steps with 2123 atoms +Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] c_p[15][7] c_p[15][8] + 0 0.65 -5.982005 0 -5.0074642 -0.32476388 0.35627939 0.62462251 0.46815062 -6.0757313 -6.2674721 -6.2664951 + 50 0.42414771 -5.5700167 0 -4.9340948 -0.074492286 0.28886433 0.24978381 0.44948344 -3.0740097 -3.1912376 -3.3440998 + 100 0.64021145 -5.7405134 0 -4.7806486 -0.0054535408 0.66078235 0.50006981 0.71100403 -1.475414 -2.2837434 -2.4415617 + 150 0.72663247 -5.8366691 0 -4.7472338 0.089984367 0.67171939 0.88397719 0.68237586 1.6770061 0.61270415 0.21817975 + 200 0.63460122 -5.8577473 0 -4.9062939 0.14140872 0.42462947 0.59385606 0.7268978 3.724825 5.4164976 5.6793442 + 250 0.62199115 -5.9027866 0 -4.9702393 0.13328919 0.59870532 0.36146182 0.42120197 4.6915309 2.7849546 2.5902987 + 300 0.62406364 -5.8889104 0 -4.9532559 0.063550326 0.52789691 0.2680398 0.54676177 0.46527871 -0.070774015 0.067168511 + 350 0.6028994 -5.7552274 0 -4.8513043 -0.027499706 0.50997812 0.70982549 0.6490879 -1.0149299 -2.1276797 -1.9078706 + 400 0.56811588 -5.5416058 0 -4.6898334 -0.061577561 0.47083533 0.77746521 0.675965 -1.2938321 -2.202316 -2.1025453 + 450 0.54946762 -5.3409786 0 -4.5171654 -0.060007836 0.79992593 0.45761929 0.41283856 -1.652204 -2.8165097 -2.6321599 + 500 0.57962648 -5.2096808 0 -4.3406506 -0.052541306 0.58252285 0.62111149 0.53587504 -1.9875759 -2.9154918 -2.5749065 + 550 0.61149882 -5.0920642 0 -4.175248 -0.03806361 0.69036525 0.44434221 0.43153208 -1.9183958 -2.3974591 -2.3022723 + 600 0.63683327 -4.9975996 0 -4.0427996 -0.016868781 0.61515828 0.47182625 0.4742184 -1.1994753 -1.1131664 -0.56565765 + 650 0.67007543 -4.9684574 0 -3.9638177 -0.00087204466 0.78120956 1.0550498 0.80318482 0.5193751 -0.45357228 -0.48936452 + 700 0.65648313 -4.9612522 0 -3.9769913 0.012954904 0.94001121 0.61816695 0.54104923 -0.9625773 -1.4649033 -1.0873728 + 750 0.62636818 -4.9944273 0 -4.0553176 0.01206773 0.75957119 0.70733827 0.60927279 -0.054590821 -1.1571206 -1.2288301 + 800 0.64474901 -5.0498682 0 -4.0832003 -0.0022579262 0.63509307 0.56543999 0.51633686 -0.85275527 -0.12649302 -0.79080252 + 850 0.64765539 -5.0405969 0 -4.0695714 0.0061653637 0.56204713 0.59190191 0.44560131 -0.51984418 -0.92559078 -0.14336782 + 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 0.50392257 0.49473611 0.46727165 -0.093317056 -1.3498298 -0.99991957 + 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 0.47764992 0.56974826 0.58927977 0.93251392 -0.29722045 0.17614353 + 1000 0.6407875 -4.9770134 0 -4.0162849 0.006441923 0.87635667 0.51303643 0.45437033 0.19199806 0.09464003 0.42241535 +Loop time of 0.445005 on 4 procs for 1000 steps with 2123 atoms -Performance: 1228110.486 tau/day, 2842.848 timesteps/s -99.4% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 970776.406 tau/day, 2247.168 timesteps/s +99.8% CPU use with 4 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.17072 | 0.18863 | 0.20606 | 3.7 | 53.63 -Neigh | 0.027172 | 0.030136 | 0.033131 | 1.7 | 8.57 -Comm | 0.024747 | 0.046514 | 0.067648 | 9.3 | 13.22 -Output | 0.00050033 | 0.0013632 | 0.0016527 | 1.3 | 0.39 -Modify | 0.082033 | 0.083964 | 0.086383 | 0.5 | 23.87 -Other | | 0.001148 | | | 0.33 +Pair | 0.14588 | 0.16497 | 0.18451 | 4.0 | 37.07 +Neigh | 0.021027 | 0.023815 | 0.026465 | 1.6 | 5.35 +Comm | 0.01933 | 0.042225 | 0.064711 | 9.3 | 9.49 +Output | 0.133 | 0.13376 | 0.13402 | 0.1 | 30.06 +Modify | 0.07858 | 0.079474 | 0.080939 | 0.3 | 17.86 +Other | | 0.000762 | | | 0.17 Nlocal: 530.75 ave 542 max 513 min Histogram: 1 0 0 0 1 0 0 0 0 2 From c8b7fc21449f29baba9023f4a74af0e3c3f64004 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Sun, 6 Mar 2022 20:19:38 -0700 Subject: [PATCH 66/72] Added cross-reference to compute pressure/cartesian --- doc/src/compute_stress_mop.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index bcc1a87e5f..f9a7c1daa6 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -107,7 +107,7 @@ intra-molecular interactions, and long range (kspace) interactions. Related commands """""""""""""""" -:doc:`compute stress/atom ` +:doc:`compute stress/atom `, :doc:`compute pressure `, :doc:`compute pressure/cartesian `, :doc:`compute pressure/cylinder `, :doc:`compute pressure/spherical ` Default """"""" From 8f10953e9251444ebce42ea14ca252adf940ddd5 Mon Sep 17 00:00:00 2001 From: Olav Galteland Date: Mon, 7 Mar 2022 10:27:23 +0100 Subject: [PATCH 67/72] Small comma error in citation --- src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp index 838c3635b0..6bd9937114 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp @@ -42,7 +42,7 @@ static const char cite_compute_pressure_cartesian[] = "@article{galteland2021nanothermodynamic,\n" "title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a " "slit pore},\n" - "author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe}\n," + "author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe},\n" "journal={Nanomaterials},\n" "volume={11},\n" "number={1},\n" From c2b0347b30b0c35e9826b5bd3ce5e4acefa5f2fa Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 7 Mar 2022 09:09:29 -0700 Subject: [PATCH 68/72] Added notes on similarity between these computes --- doc/src/compute_pressure_cartesian.rst | 14 +++++++++++++- doc/src/compute_stress_mop.rst | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_pressure_cartesian.rst index cb5f9e6956..3f002a28e5 100644 --- a/doc/src/compute_pressure_cartesian.rst +++ b/doc/src/compute_pressure_cartesian.rst @@ -116,6 +116,18 @@ The values calculated by this compute are "intensive". The pressure values will be in pressure :doc:`units `. The number density values are in inverse volume :doc:`units `. +NOTE 1: The local stress does not include any Lennard-Jones tail +corrections to the pressure added by the :doc:`pair_modify tail yes ` command, since those are contributions to the global system pressure. + +NOTE 2: The local stress profiles generated by these computes are +similar to those obtained by the +:doc:`method-of-planes (MOP) `. +A key difference +is that compute `stress/mop/profile ` +considers particles crossing a set of planes, while +*pressure/cartesian* computes averages for a set of small volumes. +More information on the similarities and differences can be found in +:ref:`(Ikeshoji)`. Restrictions """""""""""" @@ -134,7 +146,7 @@ package ` doc page for more info. Related commands """""""""""""""" -:doc:`compute stress/atom `, :doc:`compute pressure `, :doc:`compute stress/mop ` +:doc:`compute stress/atom `, :doc:`compute pressure `, :doc:`compute stress/mop/profile ` Default """"""" diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index f9a7c1daa6..573c1ba85b 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -70,6 +70,17 @@ NOTE 1: The configurational stress is computed considering all pairs of atoms wh NOTE 2: The local stress does not include any Lennard-Jones tail corrections to the pressure added by the :doc:`pair_modify tail yes ` command, since those are contributions to the global system pressure. +NOTE 3: The local stress profile generated by compute *stress/mop/profile* +is similar to that obtained by compute +:doc:`pressure/cartesian `. +A key difference +is that compute *stress/mop/profile* considers particles +crossing a set of planes, +while compute *pressure/cartesian* computes averages for a set of +small volumes. More information +on the similarities and differences can be found in +:ref:`(Ikeshoji)`. + Output info """"""""""" @@ -120,3 +131,7 @@ none **(Todd)** B. D. Todd, Denis J. Evans, and Peter J. Daivis: "Pressure tensor for inhomogeneous fluids", Phys. Rev. E 52, 1627 (1995). + +.. _Ikeshoji3: + +**(Ikeshoji)** Ikeshoji, Hafskjold, Furuholt, Mol Sim, 29, 101-109, (2003). From 8d5a59c0fa6e9736700d26af050870830d40e5f3 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 7 Mar 2022 11:27:37 -0700 Subject: [PATCH 69/72] Switched all command and class names from pressure to stress --- doc/src/Commands_compute.rst | 6 +- doc/src/compute.rst | 6 +- ...esian.rst => compute_stress_cartesian.rst} | 69 ++++++++++--------- doc/src/compute_stress_mop.rst | 14 ++-- .../{pressure => stressprofile}/in.cylinder | 4 +- .../{pressure => stressprofile}/in.flat | 4 +- .../{pressure => stressprofile}/in.sphere | 4 +- .../log.6Mar2022.cylinder.g++.1 | 28 ++++---- .../log.6Mar2022.cylinder.g++.4 | 28 ++++---- .../log.6Mar2022.flat.g++.1 | 34 ++++----- .../log.6Mar2022.flat.g++.4 | 34 ++++----- .../log.6Mar2022.sphere.g++.1 | 28 ++++---- .../log.6Mar2022.sphere.g++.4 | 28 ++++---- src/.gitignore | 12 ++-- ...esian.cpp => compute_stress_cartesian.cpp} | 44 ++++++------ ...cartesian.h => compute_stress_cartesian.h} | 18 ++--- ...linder.cpp => compute_stress_cylinder.cpp} | 40 +++++------ ...e_cylinder.h => compute_stress_cylinder.h} | 18 ++--- ...rical.cpp => compute_stress_spherical.cpp} | 60 ++++++++-------- ...spherical.h => compute_stress_spherical.h} | 18 ++--- 20 files changed, 251 insertions(+), 246 deletions(-) rename doc/src/{compute_pressure_cartesian.rst => compute_stress_cartesian.rst} (68%) rename examples/PACKAGES/{pressure => stressprofile}/in.cylinder (89%) rename examples/PACKAGES/{pressure => stressprofile}/in.flat (90%) rename examples/PACKAGES/{pressure => stressprofile}/in.sphere (90%) rename examples/PACKAGES/{pressure => stressprofile}/log.6Mar2022.cylinder.g++.1 (87%) rename examples/PACKAGES/{pressure => stressprofile}/log.6Mar2022.cylinder.g++.4 (87%) rename examples/PACKAGES/{pressure => stressprofile}/log.6Mar2022.flat.g++.1 (87%) rename examples/PACKAGES/{pressure => stressprofile}/log.6Mar2022.flat.g++.4 (86%) rename examples/PACKAGES/{pressure => stressprofile}/log.6Mar2022.sphere.g++.1 (88%) rename examples/PACKAGES/{pressure => stressprofile}/log.6Mar2022.sphere.g++.4 (88%) rename src/EXTRA-COMPUTE/{compute_pressure_cartesian.cpp => compute_stress_cartesian.cpp} (91%) rename src/EXTRA-COMPUTE/{compute_pressure_cartesian.h => compute_stress_cartesian.h} (79%) rename src/EXTRA-COMPUTE/{compute_pressure_cylinder.cpp => compute_stress_cylinder.cpp} (93%) rename src/EXTRA-COMPUTE/{compute_pressure_cylinder.h => compute_stress_cylinder.h} (80%) rename src/EXTRA-COMPUTE/{compute_pressure_spherical.cpp => compute_stress_spherical.cpp} (86%) rename src/EXTRA-COMPUTE/{compute_pressure_spherical.h => compute_stress_spherical.h} (77%) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 71774d555e..590b3d2ea8 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -100,9 +100,6 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`pe/tally ` * :doc:`plasticity/atom ` * :doc:`pressure ` - * :doc:`pressure/cartesian ` - * :doc:`pressure/cylinder ` - * :doc:`pressure/spherical ` * :doc:`pressure/uef ` * :doc:`property/atom ` * :doc:`property/chunk ` @@ -145,8 +142,11 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`sph/t/atom ` * :doc:`spin ` * :doc:`stress/atom ` + * :doc:`stress/cartesian ` + * :doc:`stress/cylinder ` * :doc:`stress/mop ` * :doc:`stress/mop/profile ` + * :doc:`stress/spherical ` * :doc:`stress/tally ` * :doc:`tdpd/cc/atom ` * :doc:`temp (k) ` diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 79ee4f0c73..6973559d16 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -246,9 +246,6 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`pe/tally ` - potential energy between two groups of atoms via the tally callback mechanism * :doc:`plasticity/atom ` - Peridynamic plasticity for each atom * :doc:`pressure ` - total pressure and pressure tensor -* :doc:`pressure/cartesian ` - pressure tensor in cartesian coordinates -* :doc:`pressure/cylinder ` - pressure tensor in cylindrical coordinates -* :doc:`pressure/spherical ` - pressure tensor in spherical coordinates * :doc:`pressure/uef ` - pressure tensor in the reference frame of an applied flow field * :doc:`property/atom ` - convert atom attributes to per-atom vectors/arrays * :doc:`property/chunk ` - extract various per-chunk attributes @@ -291,8 +288,11 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`sph/t/atom ` - per-atom internal temperature of Smooth-Particle Hydrodynamics atoms * :doc:`spin ` - magnetic quantities for a system of atoms having spins * :doc:`stress/atom ` - stress tensor for each atom +* :doc:`stress/cartesian ` - stress tensor in cartesian coordinates +* :doc:`stress/cylinder ` - stress tensor in cylindrical coordinates * :doc:`stress/mop ` - normal components of the local stress tensor using the method of planes * :doc:`stress/mop/profile ` - profile of the normal components of the local stress tensor using the method of planes +* :doc:`stress/spherical ` - stress tensor in spherical coordinates * :doc:`stress/tally ` - stress between two groups of atoms via the tally callback mechanism * :doc:`tdpd/cc/atom ` - per-atom chemical concentration of a specified species for each tDPD particle * :doc:`temp ` - temperature of group of atoms diff --git a/doc/src/compute_pressure_cartesian.rst b/doc/src/compute_stress_cartesian.rst similarity index 68% rename from doc/src/compute_pressure_cartesian.rst rename to doc/src/compute_stress_cartesian.rst index 3f002a28e5..9cd89fdb07 100644 --- a/doc/src/compute_pressure_cartesian.rst +++ b/doc/src/compute_stress_cartesian.rst @@ -1,15 +1,15 @@ -.. index:: compute pressure/cartesian -.. index:: compute pressure/cylinder -.. index:: compute pressure/spherical +.. index:: compute stress/cartesian +.. index:: compute stress/cylinder +.. index:: compute stress/spherical -compute pressure/cartesian command +compute stress/cartesian command ================================== -compute pressure/cylinder command +compute stress/cylinder command ================================= -compute pressure/spherical command +compute stress/spherical command ================================== Syntax @@ -20,22 +20,22 @@ Syntax compute ID group-ID style args * ID, group-ID are documented in :doc:`compute ` command -* style = pressure/cartesian or pressure/spherical or pressure/cylinder +* style = stress/cartesian or stress/spherical or stress/cylinder * args = argument specific to the compute style .. parsed-literal:: - *pressure/cartesian* args = dim bin_width + *stress/cartesian* args = dim bin_width dim = x, y, or z. One or two dim/bin_width pairs may be appended bin_width = width of the bin - *pressure/cylinder* args = zlo zh Rmax bin_width keyword + *stress/cylinder* args = zlo zh Rmax bin_width keyword zlo = minimum z-boundary for cylinder zhi = maximum z-boundary for cylinder Rmax = maximum radius to perform calculation to bin_width = width of radial bins to use for calculation keyword = ke (zero or one can be specified) ke = yes or no - *pressure/spherical* + *stress/spherical* x0, y0, z0 = origin of the spherical coordinate system bin_width = width of spherical shells Rmax = maximum radius of spherical shells @@ -45,40 +45,40 @@ Examples .. code-block:: LAMMPS - compute 1 all pressure/cartesian x 0.1 - compute 1 all pressure/cartesian y 0.25 z 0.1 - compute 1 all pressure/cylinder -10.0 10.0 15.0 0.25 - compute 1 all pressure/cylinder -10.0 10.0 15.0 0.25 ke no - compute 1 all pressure/spherical 0 0 0 0.1 10 + compute 1 all stress/cartesian x 0.1 + compute 1 all stress/cartesian y 0.25 z 0.1 + compute 1 all stress/cylinder -10.0 10.0 15.0 0.25 + compute 1 all stress/cylinder -10.0 10.0 15.0 0.25 ke no + compute 1 all stress/spherical 0 0 0 0.1 10 Description """"""""""" -Compute *pressure/cartesian*, compute *pressure/cylinder*, and compute -*pressure/spherical* define computations that calculate profiles of the -diagonal components of the local pressure tensor in the specified -coordinate system. The pressure tensor is split into a kinetic +Compute *stress/cartesian*, compute *stress/cylinder*, and compute +*stress/spherical* define computations that calculate profiles of the +diagonal components of the local stress tensor in the specified +coordinate system. The stress tensor is split into a kinetic contribution :math:`P^k` and a virial contribution :math:`P^v`. The sum -gives the total pressure tensor :math:`P = P^k+P^v`. These computes can +gives the total stress tensor :math:`P = P^k+P^v`. These computes can for example be used to calculate the diagonal components of the local -pressure tensor of interfaces with flat, cylindrical, or spherical +stress tensor of interfaces with flat, cylindrical, or spherical symmetry. These computes obeys momentum balance through fluid interfaces. They use the Irving-Kirkwood contour, which is the straight line between particle pairs. -The *pressure/cartesian* computes the pressure profile along one or two +The *stress/cartesian* computes the stress profile along one or two Cartesian coordinates, as described in :ref:`(Ikeshoji)`. The -compute *pressure/cylinder* computes the pressure profile along the +compute *stress/cylinder* computes the stress profile along the radial direction in cylindrical coordinates, as described in -:ref:`(Addington)`. The compute *pressure/spherical* -computes the pressure profile along the radial direction in spherical +:ref:`(Addington)`. The compute *stress/spherical* +computes the stress profile along the radial direction in spherical coordinates, as described in :ref:`(Ikeshoji)`. Output info """"""""""" -The output columns for *pressure/cartesian* are the position of the +The output columns for *stress/cartesian* are the position of the center of the local volume in the first and second dimensions, number density, :math:`P^k_{xx}`, :math:`P^k_{yy}`, :math:`P^k_{zz}`, :math:`P^v_{xx}`, :math:`P^v_{yy}`, and :math:`P^v_{zz}`. There are 8 @@ -89,7 +89,7 @@ simulation box in the specified dimensions, and bin_width1 and bin_width2 are the specified bin widths. When only one dimension is specified the number of bins/rows are L1/bin_width. -The default output columns for *pressure/cylinder* are the radius to the +The default output columns for *stress/cylinder* are the radius to the center of the cylindrical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\phi\phi}`, :math:`P^k_{zz}`, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, and :math:`P^v_{zz}`. When the keyword *ke* is @@ -99,7 +99,7 @@ cylindrical shell, number density, :math:`P^v_{rr}`, :math:`P^v_{\phi\phi}`, :math:`P^v_{zz}`. The number of bins/rows are Rmax/bin_width. -The output columns for *pressure/spherical* are the radius to the center +The output columns for *stress/spherical* are the radius to the center of the spherical shell, number density, :math:`P^k_{rr}`, :math:`P^k_{\theta\theta}`, :math:`P^k_{\phi\phi}`, :math:`P^v_{rr}`, :math:`P^v_{\theta\theta}`, and :math:`P^v_{\phi\phi}`. There are 8 @@ -109,15 +109,16 @@ This array can be output with :doc:`fix ave/time `, .. code-block:: LAMMPS - compute p all pressure/cartesian x 0.1 + compute p all stress/cartesian x 0.1 fix 2 all ave/time 100 1 100 c_p[*] file dump_p.out mode vector -The values calculated by this compute are "intensive". The pressure +The values calculated by this compute are "intensive". The stress values will be in pressure :doc:`units `. The number density values are in inverse volume :doc:`units `. NOTE 1: The local stress does not include any Lennard-Jones tail -corrections to the pressure added by the :doc:`pair_modify tail yes ` command, since those are contributions to the global system pressure. +corrections to the stress added by the :doc:`pair_modify tail yes ` +command, since those are contributions to the global system pressure. NOTE 2: The local stress profiles generated by these computes are similar to those obtained by the @@ -125,14 +126,14 @@ similar to those obtained by the A key difference is that compute `stress/mop/profile ` considers particles crossing a set of planes, while -*pressure/cartesian* computes averages for a set of small volumes. +*stress/cartesian* computes averages for a set of small volumes. More information on the similarities and differences can be found in :ref:`(Ikeshoji)`. Restrictions """""""""""" -These computes calculate the pressure tensor contributions for pair +These computes calculate the stress tensor contributions for pair styles only (i.e. no bond, angle, dihedral, etc. contributions, and in the presence of bonded interactions, the result will be incorrect due to exclusions for special bonds) and requires pairwise force calculations @@ -151,7 +152,7 @@ Related commands Default """"""" -The keyword default for ke in style *pressure/cylinder* is yes. +The keyword default for ke in style *stress/cylinder* is yes. ---------- diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index 573c1ba85b..18b9e703c5 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -68,15 +68,16 @@ configurational stress (conf), and/or total stress (total). NOTE 1: The configurational stress is computed considering all pairs of atoms where at least one atom belongs to group group-ID. NOTE 2: The local stress does not include any Lennard-Jones tail -corrections to the pressure added by the :doc:`pair_modify tail yes ` command, since those are contributions to the global system pressure. +corrections to the stress added by the :doc:`pair_modify tail yes ` +command, since those are contributions to the global system pressure. NOTE 3: The local stress profile generated by compute *stress/mop/profile* is similar to that obtained by compute -:doc:`pressure/cartesian `. +:doc:`stress/cartesian `. A key difference is that compute *stress/mop/profile* considers particles crossing a set of planes, -while compute *pressure/cartesian* computes averages for a set of +while compute *stress/cartesian* computes averages for a set of small volumes. More information on the similarities and differences can be found in :ref:`(Ikeshoji)`. @@ -98,7 +99,10 @@ and stress_dir,z. The values are in pressure :doc:`units `. -The values produced by this compute can be accessed by various :doc:`output commands `. For instance, the results can be written to a file using the :doc:`fix ave/time ` command. Please see the example in the examples/PACKAGES/mop folder. +The values produced by this compute can be accessed by various :doc:`output commands `. +For instance, the results can be written to a file using the +:doc:`fix ave/time ` command. Please see the example +in the examples/PACKAGES/mop folder. Restrictions """""""""""" @@ -118,7 +122,7 @@ intra-molecular interactions, and long range (kspace) interactions. Related commands """""""""""""""" -:doc:`compute stress/atom `, :doc:`compute pressure `, :doc:`compute pressure/cartesian `, :doc:`compute pressure/cylinder `, :doc:`compute pressure/spherical ` +:doc:`compute stress/atom `, :doc:`compute pressure `, :doc:`compute stress/cartesian `, :doc:`compute stress/cylinder `, :doc:`compute stress/spherical ` Default """"""" diff --git a/examples/PACKAGES/pressure/in.cylinder b/examples/PACKAGES/stressprofile/in.cylinder similarity index 89% rename from examples/PACKAGES/pressure/in.cylinder rename to examples/PACKAGES/stressprofile/in.cylinder index 8c7dfde595..48e35b1959 100644 --- a/examples/PACKAGES/pressure/in.cylinder +++ b/examples/PACKAGES/stressprofile/in.cylinder @@ -1,4 +1,4 @@ -# compute pressure/cylinder for a cylindrical liquid-vapor interface +# compute stress/cylinder for a cylindrical liquid-vapor interface units lj atom_style atomic @@ -31,7 +31,7 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump_modify 3 pad 3 fix 2 all recenter 0 0 NULL units lattice -compute p all pressure/cylinder 0 10 15 0.25 +compute p all stress/cylinder 0 10 15 0.25 fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector thermo 50 diff --git a/examples/PACKAGES/pressure/in.flat b/examples/PACKAGES/stressprofile/in.flat similarity index 90% rename from examples/PACKAGES/pressure/in.flat rename to examples/PACKAGES/stressprofile/in.flat index 1c0e7873ba..8b484a423f 100644 --- a/examples/PACKAGES/pressure/in.flat +++ b/examples/PACKAGES/stressprofile/in.flat @@ -1,4 +1,4 @@ -# compute pressure/cartesian for a flat liquid-vapor interface +# compute stress/cartesian for a flat liquid-vapor interface units lj atom_style atomic @@ -32,7 +32,7 @@ fix 1 all nvt temp 0.7 0.7 0.2 #dump_modify 3 pad 3 fix 2 all recenter NULL NULL 15 units lattice -compute p1 all pressure/cartesian z 0.5 +compute p1 all stress/cartesian z 0.5 fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector thermo 50 diff --git a/examples/PACKAGES/pressure/in.sphere b/examples/PACKAGES/stressprofile/in.sphere similarity index 90% rename from examples/PACKAGES/pressure/in.sphere rename to examples/PACKAGES/stressprofile/in.sphere index ed32705595..42084f018b 100644 --- a/examples/PACKAGES/pressure/in.sphere +++ b/examples/PACKAGES/stressprofile/in.sphere @@ -1,4 +1,4 @@ -# compute pressure/spherical for a spherical droplet +# compute stress/spherical for a spherical droplet units lj atom_style atomic @@ -31,7 +31,7 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump_modify 3 pad 3 fix 2 all recenter 0 0 0 units lattice -compute p all pressure/spherical 0 0 0 0.25 15 +compute p all stress/spherical 0 0 0 0.25 15 fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector thermo 50 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 b/examples/PACKAGES/stressprofile/log.6Mar2022.cylinder.g++.1 similarity index 87% rename from examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 rename to examples/PACKAGES/stressprofile/log.6Mar2022.cylinder.g++.1 index 5e8281e226..f1991ddbfc 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.1 +++ b/examples/PACKAGES/stressprofile/log.6Mar2022.cylinder.g++.1 @@ -1,5 +1,5 @@ LAMMPS (17 Feb 2022) -# compute pressure/cylinder for a cylindrical liquid-vapor interface +# compute stress/cylinder for a cylindrical liquid-vapor interface units lj atom_style atomic @@ -36,7 +36,7 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump_modify 3 pad 3 fix 2 all recenter 0 0 NULL units lattice -compute p all pressure/cylinder 0 10 15 0.25 +compute p all stress/cylinder 0 10 15 0.25 fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector thermo 50 @@ -48,7 +48,7 @@ CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE Your simulation uses code contributions which should be cited: -- compute pressure/cylinder: +- compute stress/cylinder: @Article{Addington, author = {C. K. Addington, Y. Long, K. E. Gubbins}, @@ -74,7 +74,7 @@ Neighbor list info ... pair build: half/bin/atomonly/newton stencil: half/bin/3d bin: standard - (2) compute pressure/cylinder, occasional, copy from (1) + (2) compute stress/cylinder, occasional, copy from (1) attributes: half, newton on pair build: copy stencil: none @@ -102,20 +102,20 @@ Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 0.50996272 0.40697988 0.69606954 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 0.46323559 0.64562517 0.6484849 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 0.62372474 0.46065491 0.45844619 -Loop time of 3.23802 on 1 procs for 1000 steps with 3170 atoms +Loop time of 4.13231 on 1 procs for 1000 steps with 3170 atoms -Performance: 133414.796 tau/day, 308.831 timesteps/s -99.9% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 104542.050 tau/day, 241.995 timesteps/s +99.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 | 0.90962 | 0.90962 | 0.90962 | 0.0 | 28.09 -Neigh | 0.13687 | 0.13687 | 0.13687 | 0.0 | 4.23 -Comm | 0.0048607 | 0.0048607 | 0.0048607 | 0.0 | 0.15 -Output | 1.4242 | 1.4242 | 1.4242 | 0.0 | 43.98 -Modify | 0.7598 | 0.7598 | 0.7598 | 0.0 | 23.46 -Other | | 0.002623 | | | 0.08 +Pair | 1.1551 | 1.1551 | 1.1551 | 0.0 | 27.95 +Neigh | 0.17391 | 0.17391 | 0.17391 | 0.0 | 4.21 +Comm | 0.0064512 | 0.0064512 | 0.0064512 | 0.0 | 0.16 +Output | 1.7974 | 1.7974 | 1.7974 | 0.0 | 43.50 +Modify | 0.99617 | 0.99617 | 0.99617 | 0.0 | 24.11 +Other | | 0.003226 | | | 0.08 Nlocal: 3170 ave 3170 max 3170 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -128,4 +128,4 @@ Total # of neighbors = 101768 Ave neighs/atom = 32.10347 Neighbor list builds = 50 Dangerous builds not checked -Total wall time: 0:00:03 +Total wall time: 0:00:04 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 b/examples/PACKAGES/stressprofile/log.6Mar2022.cylinder.g++.4 similarity index 87% rename from examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 rename to examples/PACKAGES/stressprofile/log.6Mar2022.cylinder.g++.4 index ca5f6969e5..450d6698de 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.cylinder.g++.4 +++ b/examples/PACKAGES/stressprofile/log.6Mar2022.cylinder.g++.4 @@ -1,5 +1,5 @@ LAMMPS (17 Feb 2022) -# compute pressure/cylinder for a cylindrical liquid-vapor interface +# compute stress/cylinder for a cylindrical liquid-vapor interface units lj atom_style atomic @@ -14,7 +14,7 @@ Created orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.79 create_atoms 1 region liquid Created 3170 atoms using lattice units in orthogonal box = (-16.795962 -16.795962 0) to (16.795962 16.795962 16.795962) - create_atoms CPU = 0.001 seconds + create_atoms CPU = 0.000 seconds mass 1 1.0 velocity all create 0.65 87287 loop geom @@ -36,7 +36,7 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump_modify 3 pad 3 fix 2 all recenter 0 0 NULL units lattice -compute p all pressure/cylinder 0 10 15 0.25 +compute p all stress/cylinder 0 10 15 0.25 fix 3 all ave/time 100 1 100 c_p[*] file cylinder.out mode vector thermo 50 @@ -48,7 +48,7 @@ CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE Your simulation uses code contributions which should be cited: -- compute pressure/cylinder: +- compute stress/cylinder: @Article{Addington, author = {C. K. Addington, Y. Long, K. E. Gubbins}, @@ -74,7 +74,7 @@ Neighbor list info ... pair build: half/bin/atomonly/newton stencil: half/bin/3d bin: standard - (2) compute pressure/cylinder, occasional, copy from (1) + (2) compute stress/cylinder, occasional, copy from (1) attributes: half, newton on pair build: copy stencil: none @@ -102,20 +102,20 @@ Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] 900 0.64904492 -5.1463816 0 -4.1731214 -0.015999133 0.50996272 0.40697988 0.69606954 950 0.64624835 -5.1529515 0 -4.1838847 0.0037696411 0.46323559 0.64562517 0.6484849 1000 0.64602274 -5.1525985 0 -4.1838701 0.022248112 0.62372474 0.46065491 0.45844619 -Loop time of 0.961057 on 4 procs for 1000 steps with 3170 atoms +Loop time of 1.33052 on 4 procs for 1000 steps with 3170 atoms -Performance: 449505.261 tau/day, 1040.521 timesteps/s -99.9% CPU use with 4 MPI tasks x no OpenMP threads +Performance: 324683.906 tau/day, 751.583 timesteps/s +98.5% CPU use with 4 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.24978 | 0.2556 | 0.26053 | 1.0 | 26.60 -Neigh | 0.036812 | 0.037364 | 0.03795 | 0.2 | 3.89 -Comm | 0.027115 | 0.033034 | 0.040202 | 3.2 | 3.44 -Output | 0.40636 | 0.40704 | 0.40727 | 0.1 | 42.35 -Modify | 0.22584 | 0.22683 | 0.2283 | 0.2 | 23.60 -Other | | 0.001187 | | | 0.12 +Pair | 0.35212 | 0.36191 | 0.36751 | 1.0 | 27.20 +Neigh | 0.05132 | 0.052345 | 0.053278 | 0.3 | 3.93 +Comm | 0.060839 | 0.06792 | 0.079544 | 2.9 | 5.10 +Output | 0.54 | 0.54103 | 0.54137 | 0.1 | 40.66 +Modify | 0.30402 | 0.30522 | 0.30726 | 0.2 | 22.94 +Other | | 0.002104 | | | 0.16 Nlocal: 792.5 ave 794 max 791 min Histogram: 1 0 0 1 0 0 1 0 0 1 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 b/examples/PACKAGES/stressprofile/log.6Mar2022.flat.g++.1 similarity index 87% rename from examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 rename to examples/PACKAGES/stressprofile/log.6Mar2022.flat.g++.1 index 01fbd34e1b..452b273dd3 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.1 +++ b/examples/PACKAGES/stressprofile/log.6Mar2022.flat.g++.1 @@ -1,5 +1,5 @@ LAMMPS (17 Feb 2022) -# compute pressure/cartesian for a flat liquid-vapor interface +# compute stress/cartesian for a flat liquid-vapor interface units lj atom_style atomic @@ -37,8 +37,8 @@ fix 1 all nvt temp 0.7 0.7 0.2 #dump_modify 3 pad 3 fix 2 all recenter NULL NULL 15 units lattice -compute p1 all pressure/cartesian z 0.5 -Adjusting first bin width for compute pressure/cartesian from 0.500000 to 0.503879 +compute p1 all stress/cartesian z 0.5 +Adjusting first bin width for compute stress/cartesian from 0.500000 to 0.503879 fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector thermo 50 @@ -50,12 +50,12 @@ CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE Your simulation uses code contributions which should be cited: -- compute pressure/cartesian: +- compute stress/cartesian: @article{galteland2021nanothermodynamic, title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a slit pore}, -author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe} -,journal={Nanomaterials}, +author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe}, +journal={Nanomaterials}, volume={11}, number={1}, pages={165}, @@ -78,7 +78,7 @@ Neighbor list info ... pair build: half/bin/atomonly/newton stencil: half/bin/3d bin: standard - (2) compute pressure/cartesian, occasional, copy from (1) + (2) compute stress/cartesian, occasional, copy from (1) attributes: half, newton on pair build: copy stencil: none @@ -106,20 +106,20 @@ Step Temp E_pair E_mol TotEng Press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50] 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 0.41295263 0.58244529 0.51061419 1.1176204 0.85808642 -0.50262868 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 0.50435084 0.49611677 0.5263358 -1.0396644 -0.85737705 -1.3764034 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 0.63890467 0.66446292 0.51353613 -0.39241484 -0.64122487 -0.78501452 -Loop time of 1.84234 on 1 procs for 1000 steps with 4200 atoms +Loop time of 2.06097 on 1 procs for 1000 steps with 4200 atoms -Performance: 234484.767 tau/day, 542.789 timesteps/s -99.9% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 209609.664 tau/day, 485.208 timesteps/s +99.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 | 1.3351 | 1.3351 | 1.3351 | 0.0 | 72.47 -Neigh | 0.19357 | 0.19357 | 0.19357 | 0.0 | 10.51 -Comm | 0.015339 | 0.015339 | 0.015339 | 0.0 | 0.83 -Output | 0.14428 | 0.14428 | 0.14428 | 0.0 | 7.83 -Modify | 0.14965 | 0.14965 | 0.14965 | 0.0 | 8.12 -Other | | 0.00435 | | | 0.24 +Pair | 1.4899 | 1.4899 | 1.4899 | 0.0 | 72.29 +Neigh | 0.22785 | 0.22785 | 0.22785 | 0.0 | 11.06 +Comm | 0.017142 | 0.017142 | 0.017142 | 0.0 | 0.83 +Output | 0.15511 | 0.15511 | 0.15511 | 0.0 | 7.53 +Modify | 0.16608 | 0.16608 | 0.16608 | 0.0 | 8.06 +Other | | 0.004898 | | | 0.24 Nlocal: 4200 ave 4200 max 4200 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -132,4 +132,4 @@ Total # of neighbors = 144737 Ave neighs/atom = 34.46119 Neighbor list builds = 50 Dangerous builds not checked -Total wall time: 0:00:01 +Total wall time: 0:00:02 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 b/examples/PACKAGES/stressprofile/log.6Mar2022.flat.g++.4 similarity index 86% rename from examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 rename to examples/PACKAGES/stressprofile/log.6Mar2022.flat.g++.4 index dd7b61973c..2b1c8b2b9d 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.flat.g++.4 +++ b/examples/PACKAGES/stressprofile/log.6Mar2022.flat.g++.4 @@ -1,5 +1,5 @@ LAMMPS (17 Feb 2022) -# compute pressure/cartesian for a flat liquid-vapor interface +# compute stress/cartesian for a flat liquid-vapor interface units lj atom_style atomic @@ -15,7 +15,7 @@ Created orthogonal box = (0 0 0) to (16.795962 16.795962 50.387886) create_atoms 1 region liquid Created 4200 atoms using lattice units in orthogonal box = (0 0 0) to (16.795962 16.795962 50.387886) - create_atoms CPU = 0.001 seconds + create_atoms CPU = 0.000 seconds mass 1 1.0 velocity all create 0.65 87287 loop geom @@ -37,8 +37,8 @@ fix 1 all nvt temp 0.7 0.7 0.2 #dump_modify 3 pad 3 fix 2 all recenter NULL NULL 15 units lattice -compute p1 all pressure/cartesian z 0.5 -Adjusting first bin width for compute pressure/cartesian from 0.500000 to 0.503879 +compute p1 all stress/cartesian z 0.5 +Adjusting first bin width for compute stress/cartesian from 0.500000 to 0.503879 fix 3 all ave/time 100 1 100 c_p1[*] file flat.out mode vector thermo 50 @@ -50,12 +50,12 @@ CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE Your simulation uses code contributions which should be cited: -- compute pressure/cartesian: +- compute stress/cartesian: @article{galteland2021nanothermodynamic, title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a slit pore}, -author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe} -,journal={Nanomaterials}, +author={Galteland, Olav and Bedeaux, Dick and Kjelstrup, Signe}, +journal={Nanomaterials}, volume={11}, number={1}, pages={165}, @@ -78,7 +78,7 @@ Neighbor list info ... pair build: half/bin/atomonly/newton stencil: half/bin/3d bin: standard - (2) compute pressure/cartesian, occasional, copy from (1) + (2) compute stress/cartesian, occasional, copy from (1) attributes: half, newton on pair build: copy stencil: none @@ -106,20 +106,20 @@ Step Temp E_pair E_mol TotEng Press c_p1[50][3] c_p1[50][4] c_p1[50][5] c_p1[50] 900 0.67608249 -5.711593 0 -4.6977107 -0.28650991 0.41295263 0.58244529 0.51061419 1.0812494 0.85110914 -0.52125789 950 0.68080988 -5.6043546 0 -4.5833829 -0.29765481 0.50435084 0.49611677 0.5263358 -1.1084255 -0.87093225 -1.4488231 1000 0.68792271 -5.5015077 0 -4.4698694 -0.27955533 0.63890467 0.66446292 0.51353613 -0.39754859 -0.7422202 -0.84836654 -Loop time of 0.575049 on 4 procs for 1000 steps with 4200 atoms +Loop time of 0.67272 on 4 procs for 1000 steps with 4200 atoms -Performance: 751240.091 tau/day, 1738.982 timesteps/s -99.8% CPU use with 4 MPI tasks x no OpenMP threads +Performance: 642168.946 tau/day, 1486.502 timesteps/s +99.2% CPU use with 4 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.37292 | 0.38209 | 0.39205 | 1.1 | 66.44 -Neigh | 0.054607 | 0.054984 | 0.055671 | 0.2 | 9.56 -Comm | 0.036134 | 0.046597 | 0.055864 | 3.3 | 8.10 -Output | 0.042435 | 0.043507 | 0.043865 | 0.3 | 7.57 -Modify | 0.045591 | 0.046196 | 0.04751 | 0.4 | 8.03 -Other | | 0.001678 | | | 0.29 +Pair | 0.42649 | 0.43416 | 0.44515 | 1.2 | 64.54 +Neigh | 0.063766 | 0.064411 | 0.065468 | 0.3 | 9.57 +Comm | 0.053491 | 0.065409 | 0.07366 | 3.2 | 9.72 +Output | 0.050856 | 0.052036 | 0.052435 | 0.3 | 7.74 +Modify | 0.054128 | 0.054608 | 0.055873 | 0.3 | 8.12 +Other | | 0.002091 | | | 0.31 Nlocal: 1050 ave 1071 max 1026 min Histogram: 1 0 0 0 0 2 0 0 0 1 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 b/examples/PACKAGES/stressprofile/log.6Mar2022.sphere.g++.1 similarity index 88% rename from examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 rename to examples/PACKAGES/stressprofile/log.6Mar2022.sphere.g++.1 index 636a90b1fa..7c93a95c97 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.1 +++ b/examples/PACKAGES/stressprofile/log.6Mar2022.sphere.g++.1 @@ -1,5 +1,5 @@ LAMMPS (17 Feb 2022) -# compute pressure/spherical for a spherical droplet +# compute stress/spherical for a spherical droplet units lj atom_style atomic @@ -36,8 +36,8 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump_modify 3 pad 3 fix 2 all recenter 0 0 0 units lattice -compute p all pressure/spherical 0 0 0 0.25 15 -Adjusting bin width for compute pressure/spherical from 0.250000 to 0.245902 +compute p all stress/spherical 0 0 0 0.25 15 +Adjusting bin width for compute stress/spherical from 0.250000 to 0.245902 fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector thermo 50 @@ -49,7 +49,7 @@ CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE Your simulation uses code contributions which should be cited: -- compute pressure/spherical: +- compute stress/spherical: @article{galteland2022defining, title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium}, @@ -73,7 +73,7 @@ Neighbor list info ... pair build: half/bin/atomonly/newton stencil: half/bin/3d bin: standard - (2) compute pressure/spherical, occasional, copy from (1) + (2) compute stress/spherical, occasional, copy from (1) attributes: half, newton on pair build: copy stencil: none @@ -101,20 +101,20 @@ Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 0.50392257 0.49473611 0.46727165 -0.096394732 -1.3622008 -1.0134429 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 0.47764992 0.56974826 0.58927977 0.93251392 -0.29722045 0.17614353 1000 0.6407875 -4.9770134 0 -4.0162849 0.0064419231 0.87635667 0.51303644 0.45437033 0.14319333 0.10005421 0.29188404 -Loop time of 1.33554 on 1 procs for 1000 steps with 2123 atoms +Loop time of 1.69288 on 1 procs for 1000 steps with 2123 atoms -Performance: 323464.483 tau/day, 748.760 timesteps/s -99.8% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 255186.474 tau/day, 590.709 timesteps/s +99.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 | 0.57217 | 0.57217 | 0.57217 | 0.0 | 42.84 -Neigh | 0.084723 | 0.084723 | 0.084723 | 0.0 | 6.34 -Comm | 0.0010257 | 0.0010257 | 0.0010257 | 0.0 | 0.08 -Output | 0.42685 | 0.42685 | 0.42685 | 0.0 | 31.96 -Modify | 0.24946 | 0.24946 | 0.24946 | 0.0 | 18.68 -Other | | 0.001311 | | | 0.10 +Pair | 0.71479 | 0.71479 | 0.71479 | 0.0 | 42.22 +Neigh | 0.10962 | 0.10962 | 0.10962 | 0.0 | 6.48 +Comm | 0.0014258 | 0.0014258 | 0.0014258 | 0.0 | 0.08 +Output | 0.53333 | 0.53333 | 0.53333 | 0.0 | 31.50 +Modify | 0.3319 | 0.3319 | 0.3319 | 0.0 | 19.61 +Other | | 0.001817 | | | 0.11 Nlocal: 2123 ave 2123 max 2123 min Histogram: 1 0 0 0 0 0 0 0 0 0 diff --git a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 b/examples/PACKAGES/stressprofile/log.6Mar2022.sphere.g++.4 similarity index 88% rename from examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 rename to examples/PACKAGES/stressprofile/log.6Mar2022.sphere.g++.4 index 33ee78ba4c..3a0e5a5e63 100644 --- a/examples/PACKAGES/pressure/log.6Mar2022.sphere.g++.4 +++ b/examples/PACKAGES/stressprofile/log.6Mar2022.sphere.g++.4 @@ -1,5 +1,5 @@ LAMMPS (17 Feb 2022) -# compute pressure/spherical for a spherical droplet +# compute stress/spherical for a spherical droplet units lj atom_style atomic @@ -36,8 +36,8 @@ fix 1 all nvt temp 0.65 0.65 0.2 #dump_modify 3 pad 3 fix 2 all recenter 0 0 0 units lattice -compute p all pressure/spherical 0 0 0 0.25 15 -Adjusting bin width for compute pressure/spherical from 0.250000 to 0.245902 +compute p all stress/spherical 0 0 0 0.25 15 +Adjusting bin width for compute stress/spherical from 0.250000 to 0.245902 fix 3 all ave/time 100 1 100 c_p[*] file sphere.out mode vector thermo 50 @@ -49,7 +49,7 @@ CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE Your simulation uses code contributions which should be cited: -- compute pressure/spherical: +- compute stress/spherical: @article{galteland2022defining, title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium}, @@ -73,7 +73,7 @@ Neighbor list info ... pair build: half/bin/atomonly/newton stencil: half/bin/3d bin: standard - (2) compute pressure/spherical, occasional, copy from (1) + (2) compute stress/spherical, occasional, copy from (1) attributes: half, newton on pair build: copy stencil: none @@ -101,20 +101,20 @@ Step Temp E_pair E_mol TotEng Press c_p[15][3] c_p[15][4] c_p[15][5] c_p[15][6] 900 0.65308258 -5.0187376 0 -4.0395752 0.016798783 0.50392257 0.49473611 0.46727165 -0.093317056 -1.3498298 -0.99991957 950 0.65225966 -4.9974305 0 -4.0195019 0.0195366 0.47764992 0.56974826 0.58927977 0.93251392 -0.29722045 0.17614353 1000 0.6407875 -4.9770134 0 -4.0162849 0.006441923 0.87635667 0.51303643 0.45437033 0.19199806 0.09464003 0.42241535 -Loop time of 0.445005 on 4 procs for 1000 steps with 2123 atoms +Loop time of 0.482332 on 4 procs for 1000 steps with 2123 atoms -Performance: 970776.406 tau/day, 2247.168 timesteps/s -99.8% CPU use with 4 MPI tasks x no OpenMP threads +Performance: 895649.023 tau/day, 2073.262 timesteps/s +99.5% CPU use with 4 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.14588 | 0.16497 | 0.18451 | 4.0 | 37.07 -Neigh | 0.021027 | 0.023815 | 0.026465 | 1.6 | 5.35 -Comm | 0.01933 | 0.042225 | 0.064711 | 9.3 | 9.49 -Output | 0.133 | 0.13376 | 0.13402 | 0.1 | 30.06 -Modify | 0.07858 | 0.079474 | 0.080939 | 0.3 | 17.86 -Other | | 0.000762 | | | 0.17 +Pair | 0.16099 | 0.1807 | 0.19799 | 3.5 | 37.46 +Neigh | 0.024387 | 0.027158 | 0.030308 | 1.6 | 5.63 +Comm | 0.022206 | 0.043381 | 0.066483 | 8.5 | 8.99 +Output | 0.14055 | 0.14125 | 0.14149 | 0.1 | 29.29 +Modify | 0.087967 | 0.088908 | 0.090377 | 0.3 | 18.43 +Other | | 0.0009305 | | | 0.19 Nlocal: 530.75 ave 542 max 513 min Histogram: 1 0 0 0 1 0 0 0 0 2 diff --git a/src/.gitignore b/src/.gitignore index 4b924f6a99..8b60afb189 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -489,14 +489,8 @@ /compute_plasticity_atom.h /compute_pressure_bocs.cpp /compute_pressure_bocs.h -/compute_pressure_cartesian.cpp -/compute_pressure_cartesian.h -/compute_pressure_cylinder.cpp -/compute_pressure_cylinder.h /compute_pressure_grem.cpp /compute_pressure_grem.h -/compute_pressure_spherical.cpp -/compute_pressure_spherical.h /compute_ptm_atom.cpp /compute_ptm_atom.h /compute_rigid_local.cpp @@ -505,10 +499,16 @@ /compute_smd_triangle_vertices.h /compute_spec_atom.cpp /compute_spec_atom.h +/compute_stress_cartesian.cpp +/compute_stress_cartesian.h +/compute_stress_cylinder.cpp +/compute_stress_cylinder.h /compute_stress_mop.cpp /compute_stress_mop.h /compute_stress_mop_profile.cpp /compute_stress_mop_profile.h +/compute_stress_spherical.cpp +/compute_stress_spherical.h /compute_stress_tally.cpp /compute_stress_tally.h /compute_temp_asphere.cpp diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp similarity index 91% rename from src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp rename to src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index 6bd9937114..476f89da1a 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS dir1ectory. ------------------------------------------------------------------------- */ -#include "compute_pressure_cartesian.h" +#include "compute_stress_cartesian.h" #include "atom.h" #include "citeme.h" @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; olav.galteland@ntnu.no ------------------------------------------------------------------------------------*/ -static const char cite_compute_pressure_cartesian[] = - "compute pressure/cartesian:\n\n" +static const char cite_compute_stress_cartesian[] = + "compute stress/cartesian:\n\n" "@article{galteland2021nanothermodynamic,\n" "title={Nanothermodynamic description and molecular simulation of a single-phase fluid in a " "slit pore},\n" @@ -54,13 +54,13 @@ static const char cite_compute_pressure_cartesian[] = /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ -ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char **arg) : +ComputeStressCartesian::ComputeStressCartesian(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), dens(NULL), pkxx(NULL), pkyy(NULL), pkzz(NULL), pcxx(NULL), pcyy(NULL), pczz(NULL), tdens(NULL), tpkxx(NULL), tpkyy(NULL), tpkzz(NULL), tpcxx(NULL), tpcyy(NULL), tpczz(NULL) { - if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_cartesian); + if (lmp->citeme) lmp->citeme->add(cite_compute_stress_cartesian); // narg == 5 for one-dimensional and narg == 7 for two-dimensional if (narg == 5) @@ -68,7 +68,7 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * else if (narg == 7) dims = 2; else - error->all(FLERR, "Illegal compute pressure/cartesian command. Illegal number of arguments."); + error->all(FLERR, "Illegal compute stress/cartesian command. Illegal number of arguments."); if (strcmp(arg[3], "x") == 0) dir1 = 0; @@ -77,7 +77,7 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * else if (strcmp(arg[3], "z") == 0) dir1 = 2; else - error->all(FLERR, "Illegal compute pressure/cartesian command."); + error->all(FLERR, "Illegal compute stress/cartesian command."); dir2 = 0; bin_width1 = utils::numeric(FLERR, arg[4], false, lmp); @@ -92,9 +92,9 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * bin_width1 = invV; if (bin_width1 <= 0.0) - error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); + error->all(FLERR, "Illegal compute stress/cartesian command. Bin width must be > 0"); else if (bin_width1 > domain->boxhi[dir1] - domain->boxlo[dir1]) - error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width larger than box."); + error->all(FLERR, "Illegal compute stress/cartesian command. Bin width larger than box."); if (dims == 2) { if (strcmp(arg[5], "x") == 0) @@ -104,7 +104,7 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * else if (strcmp(arg[5], "z") == 0) dir2 = 2; else - error->all(FLERR, "Illegal compute pressure/cartesian command."); + error->all(FLERR, "Illegal compute stress/cartesian command."); bin_width2 = utils::numeric(FLERR, arg[6], false, lmp); nbins2 = (int) ((domain->boxhi[dir2] - domain->boxlo[dir2]) / bin_width2); @@ -117,9 +117,9 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * invV *= bin_width2; if (bin_width2 <= 0.0) - error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width must be > 0"); + error->all(FLERR, "Illegal compute stress/cartesian command. Bin width must be > 0"); else if (bin_width2 > domain->boxhi[dir2] - domain->boxlo[dir2]) - error->all(FLERR, "Illegal compute pressure/cartesian command. Bin width larger than box"); + error->all(FLERR, "Illegal compute stress/cartesian command. Bin width larger than box"); } for (int i = 0; i < 3; i++) @@ -147,12 +147,12 @@ ComputePressureCartesian::ComputePressureCartesian(LAMMPS *lmp, int narg, char * memory->create(tpcxx, nbins1 * nbins2, "tpcxx"); memory->create(tpcyy, nbins1 * nbins2, "tpcyy"); memory->create(tpczz, nbins1 * nbins2, "tpczz"); - memory->create(array, size_array_rows, size_array_cols, "pressure:cartesian:output"); + memory->create(array, size_array_rows, size_array_cols, "stress:cartesian:output"); } /* ---------------------------------------------------------------------- */ -ComputePressureCartesian::~ComputePressureCartesian() +ComputeStressCartesian::~ComputeStressCartesian() { memory->destroy(dens); memory->destroy(pkxx); @@ -173,12 +173,12 @@ ComputePressureCartesian::~ComputePressureCartesian() /* ---------------------------------------------------------------------- */ -void ComputePressureCartesian::init() +void ComputeStressCartesian::init() { if (force->pair == NULL) - error->all(FLERR, "No pair style is defined for compute pressure/cartesian"); + error->all(FLERR, "No pair style is defined for compute stress/cartesian"); if (force->pair->single_enable == 0) - error->all(FLERR, "Pair style does not support compute pressure/cartesian"); + error->all(FLERR, "Pair style does not support compute stress/cartesian"); // need an occasional half neighbor list. int irequest = neighbor->request(this, instance_me); @@ -189,7 +189,7 @@ void ComputePressureCartesian::init() /* ---------------------------------------------------------------------- */ -void ComputePressureCartesian::init_list(int /* id */, NeighList *ptr) +void ComputeStressCartesian::init_list(int /* id */, NeighList *ptr) { list = ptr; } @@ -203,7 +203,7 @@ void ComputePressureCartesian::init_list(int /* id */, NeighList *ptr) if flag is set, compute requested info about pair ------------------------------------------------------------------------- */ -void ComputePressureCartesian::compute_array() +void ComputeStressCartesian::compute_array() { int i, j, ii, jj, inum, jnum, itype, jtype; int bin, bin1, bin2, bin3; @@ -358,7 +358,7 @@ void ComputePressureCartesian::compute_array() } } -void ComputePressureCartesian::compute_pressure_1d(double fpair, double xi, double xj, double delx, +void ComputeStressCartesian::compute_pressure_1d(double fpair, double xi, double xj, double delx, double dely, double delz) { int bin_s, bin_e, bin_step, bin, bin_limit; @@ -456,7 +456,7 @@ void ComputePressureCartesian::compute_pressure_1d(double fpair, double xi, doub } } -void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, double yi, double xj, +void ComputeStressCartesian::compute_pressure_2d(double fpair, double xi, double yi, double xj, double yj, double delx, double dely, double delz) { int bin1, bin2, next_bin1, next_bin2; @@ -531,7 +531,7 @@ void ComputePressureCartesian::compute_pressure_2d(double fpair, double xi, doub memory usage of data ------------------------------------------------------------------------- */ -double ComputePressureCartesian::memory_usage() +double ComputeStressCartesian::memory_usage() { return (14.0 + dims + 7) * (double) (nbins1 * nbins2) * sizeof(double); } diff --git a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h b/src/EXTRA-COMPUTE/compute_stress_cartesian.h similarity index 79% rename from src/EXTRA-COMPUTE/compute_pressure_cartesian.h rename to src/EXTRA-COMPUTE/compute_stress_cartesian.h index eaef900239..aa44e82269 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cartesian.h +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(pressure/cartesian,ComputePressureCartesian); +ComputeStyle(stress/cartesian,ComputeStressCartesian); // clang-format on #else -#ifndef LMP_COMPUTE_PRESSURE_CARTESIAN_H -#define LMP_COMPUTE_PRESSURE_CARTESIAN_H +#ifndef LMP_COMPUTE_STRESS_CARTESIAN_H +#define LMP_COMPUTE_STRESS_CARTESIAN_H #include "compute.h" namespace LAMMPS_NS { -class ComputePressureCartesian : public Compute { +class ComputeStressCartesian : public Compute { public: - ComputePressureCartesian(class LAMMPS *, int, char **); - ~ComputePressureCartesian() override; + ComputeStressCartesian(class LAMMPS *, int, char **); + ~ComputeStressCartesian() override; void init() override; void init_list(int, class NeighList *) override; void compute_array() override; @@ -58,13 +58,13 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: No pair style is defined for compute pressure/cartesian +E: No pair style is defined for compute stress/cartesian Self-explanatory. -E: Pair style does not support compute pressure/cartesian +E: Pair style does not support compute stress/cartesian The pair style does not have a single() function, so it can -not be invoked by compute pressure/cartesian. +not be invoked by compute stress/cartesian. */ diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp b/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp similarity index 93% rename from src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp rename to src/EXTRA-COMPUTE/compute_stress_cylinder.cpp index d62f4d1fdf..45cf8b54cd 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "compute_pressure_cylinder.h" +#include "compute_stress_cylinder.h" #include "atom.h" #include "citeme.h" @@ -43,8 +43,8 @@ using MathSpecial::square; olav.galteland@ntnu.no ------------------------------------------------------------------------------------*/ -static const char cite_compute_pressure_cylinder[] = - "compute pressure/cylinder:\n\n" +static const char cite_compute_stress_cylinder[] = + "compute stress/cylinder:\n\n" "@Article{Addington,\n" " author = {C. K. Addington, Y. Long, K. E. Gubbins},\n" " title = {The pressure in interfaces having cylindrical geometry},\n" @@ -55,19 +55,19 @@ static const char cite_compute_pressure_cylinder[] = "}\n\n"; /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - Calculate the configurational components of the pressure tensor in + Calculate the configurational components of the stress tensor in cylindrical geometry, according to the formulation of Addington et al. (2018) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ -ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : +ComputeStressCyl::ComputeStressCyl(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), Pvr_temp(nullptr), Pvr_all(nullptr), Pvz_temp(nullptr), Pvz_all(nullptr), Pvphi_temp(nullptr), Pvphi_all(nullptr), R(nullptr), Rinv(nullptr), R2(nullptr), PrAinv(nullptr), PzAinv(nullptr), R2kin(nullptr), density_temp(nullptr), invVbin(nullptr), density_all(nullptr), tangent(nullptr), ephi_x(nullptr), ephi_y(nullptr), binz(nullptr) { - if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_cylinder); - if ((narg != 7) && (narg != 9)) error->all(FLERR, "Illegal compute pressure/cylinder command"); + if (lmp->citeme) lmp->citeme->add(cite_compute_stress_cylinder); + if ((narg != 7) && (narg != 9)) error->all(FLERR, "Illegal compute stress/cylinder command"); zlo = utils::numeric(FLERR, arg[3], false, lmp); zhi = utils::numeric(FLERR, arg[4], false, lmp); @@ -79,19 +79,19 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : int iarg = 7; if (narg > iarg) { if (strcmp("ke", arg[iarg]) == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Invalid compute pressure/cylinder command"); + if (iarg + 2 > narg) error->all(FLERR, "Invalid compute stress/cylinder command"); kinetic_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else - error->all(FLERR, "Unknown compute pressure/cylinder command"); + error->all(FLERR, "Unknown compute stress/cylinder command"); } if ((bin_width <= 0.0) || (bin_width > Rmax)) - error->all(FLERR, "Illegal compute pressure/cylinder command"); + error->all(FLERR, "Illegal compute stress/cylinder command"); if ((zhi < zlo) || ((zhi - zlo) < bin_width)) - error->all(FLERR, "Illegal compute pressure/cylinder command"); + error->all(FLERR, "Illegal compute stress/cylinder command"); if ((zhi > domain->boxhi[2]) || (zlo < domain->boxlo[2])) - error->all(FLERR, "Illegal compute pressure/cylinder command"); + error->all(FLERR, "Illegal compute stress/cylinder command"); nbins = (int) (Rmax / bin_width); nzbins = (int) ((zhi - zlo) / bin_width); @@ -100,7 +100,7 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : // memory on a 32-bit environment. so we use this as an upper limit. if ((nbins < 1) || (nzbins < 1) || (nbins > 2 << 22) || (nzbins > 2 << 22)) - error->all(FLERR, "Illegal compute pressure/cylinder command"); + error->all(FLERR, "Illegal compute stress/cylinder command"); array_flag = 1; vector_flag = 0; @@ -147,7 +147,7 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -ComputePressureCyl::~ComputePressureCyl() +ComputeStressCyl::~ComputeStressCyl() { memory->destroy(array); if (kinetic_flag == 1) { @@ -181,12 +181,12 @@ ComputePressureCyl::~ComputePressureCyl() /* ---------------------------------------------------------------------- */ -void ComputePressureCyl::init() +void ComputeStressCyl::init() { if (force->pair == nullptr) - error->all(FLERR, "No pair style is defined for compute pressure/cylinder"); + error->all(FLERR, "No pair style is defined for compute stress/cylinder"); if (force->pair->single_enable == 0) - error->all(FLERR, "Pair style does not support compute pressure/cylinder"); + error->all(FLERR, "Pair style does not support compute stress/cylinder"); double phi; for (int iphi = 0; iphi < nphi; iphi++) { @@ -224,7 +224,7 @@ void ComputePressureCyl::init() /* ---------------------------------------------------------------------- */ -void ComputePressureCyl::init_list(int /* id */, NeighList *ptr) +void ComputeStressCyl::init_list(int /* id */, NeighList *ptr) { list = ptr; } @@ -238,7 +238,7 @@ void ComputePressureCyl::init_list(int /* id */, NeighList *ptr) if flag is set, compute requested info about pair ------------------------------------------------------------------------- */ -void ComputePressureCyl::compute_array() +void ComputeStressCyl::compute_array() { invoked_array = update->ntimestep; @@ -556,7 +556,7 @@ void ComputePressureCyl::compute_array() /* ---------------------------------------------------------------------- memory usage of data ------------------------------------------------------------------------- */ -double ComputePressureCyl::memory_usage() +double ComputeStressCyl::memory_usage() { double bytes = (3.0 * (double) nphi + 16.0 * (double) nbins + (5.0 + 3.0 * kinetic_flag) * (double) nbins) * diff --git a/src/EXTRA-COMPUTE/compute_pressure_cylinder.h b/src/EXTRA-COMPUTE/compute_stress_cylinder.h similarity index 80% rename from src/EXTRA-COMPUTE/compute_pressure_cylinder.h rename to src/EXTRA-COMPUTE/compute_stress_cylinder.h index 48f04b0c34..04f1da943e 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_cylinder.h +++ b/src/EXTRA-COMPUTE/compute_stress_cylinder.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(pressure/cylinder,ComputePressureCyl); +ComputeStyle(stress/cylinder,ComputeStressCyl); // clang-format on #else -#ifndef LMP_COMPUTE_PRESSURE_CYLINDER_H -#define LMP_COMPUTE_PRESSURE_CYLINDER_H +#ifndef LMP_COMPUTE_STRESS_CYLINDER_H +#define LMP_COMPUTE_STRESS_CYLINDER_H #include "compute.h" namespace LAMMPS_NS { -class ComputePressureCyl : public Compute { +class ComputeStressCyl : public Compute { public: - ComputePressureCyl(class LAMMPS *, int, char **); - ~ComputePressureCyl() override; + ComputeStressCyl(class LAMMPS *, int, char **); + ~ComputeStressCyl() override; void init() override; void init_list(int, class NeighList *) override; void compute_array() override; @@ -62,13 +62,13 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: No pair style is defined for compute pressure/cylinder +E: No pair style is defined for compute stress/cylinder Self-explanatory. -E: Pair style does not support compute pressure/cylinder +E: Pair style does not support compute stress/cylinder The pair style does not have a single() function, so it can -not be invoked by compute pressure/cylinder. +not be invoked by compute stress/cylinder. */ diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp similarity index 86% rename from src/EXTRA-COMPUTE/compute_pressure_spherical.cpp rename to src/EXTRA-COMPUTE/compute_stress_spherical.cpp index ef1e0e96ae..4f4570048f 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS dir1ectory. ------------------------------------------------------------------------- */ -#include "compute_pressure_spherical.h" +#include "compute_stress_spherical.h" #include "atom.h" #include "citeme.h" @@ -45,8 +45,8 @@ using MathSpecial::square; olav.galteland@ntnu.no ------------------------------------------------------------------------------------*/ -static const char cite_compute_pressure_sphere[] = - "compute pressure/spherical:\n\n" +static const char cite_compute_stress_sphere[] = + "compute stress/spherical:\n\n" "@article{galteland2022defining,\n" "title={Defining the pressures of a fluid in a nanoporous, heterogeneous medium},\n" "author={Galteland, Olav and Rauter, Michael T and Varughese, Kevin K and Bedeaux, Dick and " @@ -58,15 +58,15 @@ static const char cite_compute_pressure_sphere[] = /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ -ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char **arg) : +ComputeStressSpherical::ComputeStressSpherical(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), dens(nullptr), pkrr(nullptr), pktt(nullptr), pkpp(nullptr), pcrr(nullptr), pctt(nullptr), pcpp(nullptr), tdens(nullptr), tpkrr(nullptr), tpktt(nullptr), tpkpp(nullptr), tpcrr(nullptr), tpctt(nullptr), tpcpp(nullptr) { - if (lmp->citeme) lmp->citeme->add(cite_compute_pressure_sphere); + if (lmp->citeme) lmp->citeme->add(cite_compute_stress_sphere); if (narg != 8) - error->all(FLERR, "Illegal compute pressure/spherical command. Illegal number of arguments."); + error->all(FLERR, "Illegal compute stress/spherical command. Illegal number of arguments."); x0 = utils::numeric(FLERR, arg[3], false, lmp); y0 = utils::numeric(FLERR, arg[4], false, lmp); @@ -81,7 +81,7 @@ ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char * bin_width = tmp_width; if (bin_width <= 0.0) - error->all(FLERR, "Illegal compute pressure/spherical command. Bin width must be > 0"); + error->all(FLERR, "Illegal compute stress/spherical command. Bin width must be > 0"); array_flag = 1; vector_flag = 0; @@ -89,27 +89,27 @@ ComputePressureSpherical::ComputePressureSpherical(LAMMPS *lmp, int narg, char * size_array_cols = 8; // r, dens, pkrr, pktt, pkpp, pcrr, pctt, pcpp size_array_rows = nbins; - memory->create(invV, nbins, "compute/pressure/spherical:invV"); - memory->create(dens, nbins, "compute/pressure/spherical:dens"); - memory->create(pkrr, nbins, "compute/pressure/spherical:pkrr"); - memory->create(pktt, nbins, "compute/pressure/spherical:pktt"); - memory->create(pkpp, nbins, "compute/pressure/spherical:pkpp"); - memory->create(pcrr, nbins, "compute/pressure/spherical:pcrr"); - memory->create(pctt, nbins, "compute/pressure/spherical:pctt"); - memory->create(pcpp, nbins, "compute/pressure/spherical:pcpp"); - memory->create(tdens, nbins, "compute/pressure/spherical:tdens"); - memory->create(tpkrr, nbins, "compute/pressure/spherical:tpkrr"); - memory->create(tpktt, nbins, "compute/pressure/spherical:tpktt"); - memory->create(tpkpp, nbins, "compute/pressure/spherical:tpkpp"); - memory->create(tpcrr, nbins, "compute/pressure/spherical:tpcrr"); - memory->create(tpctt, nbins, "compute/pressure/spherical:tpctt"); - memory->create(tpcpp, nbins, "compute/pressure/spherical:tpcpp"); - memory->create(array, size_array_rows, size_array_cols, "compute/pressure/spherical:array"); + memory->create(invV, nbins, "compute/stress/spherical:invV"); + memory->create(dens, nbins, "compute/stress/spherical:dens"); + memory->create(pkrr, nbins, "compute/stress/spherical:pkrr"); + memory->create(pktt, nbins, "compute/stress/spherical:pktt"); + memory->create(pkpp, nbins, "compute/stress/spherical:pkpp"); + memory->create(pcrr, nbins, "compute/stress/spherical:pcrr"); + memory->create(pctt, nbins, "compute/stress/spherical:pctt"); + memory->create(pcpp, nbins, "compute/stress/spherical:pcpp"); + memory->create(tdens, nbins, "compute/stress/spherical:tdens"); + memory->create(tpkrr, nbins, "compute/stress/spherical:tpkrr"); + memory->create(tpktt, nbins, "compute/stress/spherical:tpktt"); + memory->create(tpkpp, nbins, "compute/stress/spherical:tpkpp"); + memory->create(tpcrr, nbins, "compute/stress/spherical:tpcrr"); + memory->create(tpctt, nbins, "compute/stress/spherical:tpctt"); + memory->create(tpcpp, nbins, "compute/stress/spherical:tpcpp"); + memory->create(array, size_array_rows, size_array_cols, "compute/stress/spherical:array"); } /* ---------------------------------------------------------------------- */ -ComputePressureSpherical::~ComputePressureSpherical() +ComputeStressSpherical::~ComputeStressSpherical() { memory->destroy(invV); memory->destroy(dens); @@ -131,12 +131,12 @@ ComputePressureSpherical::~ComputePressureSpherical() /* ---------------------------------------------------------------------- */ -void ComputePressureSpherical::init() +void ComputeStressSpherical::init() { if (force->pair == nullptr) - error->all(FLERR, "No pair style is defined for compute pressure/spherical"); + error->all(FLERR, "No pair style is defined for compute stress/spherical"); if (force->pair->single_enable == 0) - error->all(FLERR, "Pair style does not support compute pressure/spherical"); + error->all(FLERR, "Pair style does not support compute stress/spherical"); // Inverse volume of each spherical shell (bin) for (int bin = 0; bin < nbins; bin++) @@ -150,7 +150,7 @@ void ComputePressureSpherical::init() /* ---------------------------------------------------------------------- */ -void ComputePressureSpherical::init_list(int /* id */, NeighList *ptr) +void ComputeStressSpherical::init_list(int /* id */, NeighList *ptr) { list = ptr; } @@ -164,7 +164,7 @@ void ComputePressureSpherical::init_list(int /* id */, NeighList *ptr) if flag is set, compute requested info about pair ------------------------------------------------------------------------- */ -void ComputePressureSpherical::compute_array() +void ComputeStressSpherical::compute_array() { invoked_array = update->ntimestep; @@ -416,7 +416,7 @@ void ComputePressureSpherical::compute_array() } } -double ComputePressureSpherical::memory_usage() +double ComputeStressSpherical::memory_usage() { return 15.0 * (double) (nbins + size_array_rows * size_array_cols) * sizeof(double); } diff --git a/src/EXTRA-COMPUTE/compute_pressure_spherical.h b/src/EXTRA-COMPUTE/compute_stress_spherical.h similarity index 77% rename from src/EXTRA-COMPUTE/compute_pressure_spherical.h rename to src/EXTRA-COMPUTE/compute_stress_spherical.h index 17de44a5a6..61a32e3ff2 100644 --- a/src/EXTRA-COMPUTE/compute_pressure_spherical.h +++ b/src/EXTRA-COMPUTE/compute_stress_spherical.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(pressure/spherical,ComputePressureSpherical); +ComputeStyle(stress/spherical,ComputeStressSpherical); // clang-format on #else -#ifndef LMP_COMPUTE_PRESSURE_SPHERICAL_H -#define LMP_COMPUTE_PRESSURE_SPHERICAL_H +#ifndef LMP_COMPUTE_STRESS_SPHERICAL_H +#define LMP_COMPUTE_STRESS_SPHERICAL_H #include "compute.h" namespace LAMMPS_NS { -class ComputePressureSpherical : public Compute { +class ComputeStressSpherical : public Compute { public: - ComputePressureSpherical(class LAMMPS *, int, char **); - ~ComputePressureSpherical() override; + ComputeStressSpherical(class LAMMPS *, int, char **); + ~ComputeStressSpherical() override; void init() override; void init_list(int, class NeighList *) override; void compute_array() override; @@ -56,13 +56,13 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: No pair style is defined for compute pressure/spherical +E: No pair style is defined for compute stress/spherical Self-explanatory. -E: Pair style does not support compute pressure/spherical +E: Pair style does not support compute stress/spherical The pair style does not have a single() function, so it can -not be invoked by compute pressure/spherical +not be invoked by compute stress/spherical */ From 1f3a3bb80bb1dc63945752603091b48a33980a64 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Mar 2022 13:51:16 -0500 Subject: [PATCH 70/72] missing updates --- src/Purge.list | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Purge.list b/src/Purge.list index feb30a9ad7..8284961e1e 100644 --- a/src/Purge.list +++ b/src/Purge.list @@ -51,6 +51,9 @@ lmpinstalledpkgs.h lmpgitversion.h mliap_model_python_couple.cpp mliap_model_python_couple.h +# renamed on 7 March 2022 +compute_pressure_cylinder.cpp +compute_pressure_cylinder.h # renamed on 21 July 2021 fix_qeq_reax_kokkos.cpp fix_qeq_reax_kokkos.h From 5206d81742edb1fb81d3d3639641bb20245626e6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Mar 2022 14:09:01 -0500 Subject: [PATCH 71/72] make class name consistent with file name and add backward compatibility --- doc/utils/check-styles.py | 7 ++++--- src/EXTRA-COMPUTE/compute_stress_cartesian.cpp | 4 ++-- src/EXTRA-COMPUTE/compute_stress_cylinder.cpp | 12 ++++++------ src/EXTRA-COMPUTE/compute_stress_cylinder.h | 9 +++++---- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/doc/utils/check-styles.py b/doc/utils/check-styles.py index 4294f5a5bc..9633c1080f 100755 --- a/doc/utils/check-styles.py +++ b/doc/utils/check-styles.py @@ -256,12 +256,13 @@ print("Total number of style index entries:", total_index) skip_fix = ('python', 'NEIGH_HISTORY/omp','acks2/reax','qeq/reax','reax/c/bonds','reax/c/species') skip_pair = ('meam/c','lj/sf','reax/c') +skip_compute = ('pressure/cylinder') counter = 0 counter += check_style('Commands_all.rst', doc_dir, ":doc:`(.+) <.+>`",command,'Command',suffix=True) -counter += check_style('Commands_compute.rst', doc_dir, ":doc:`(.+) `",compute,'Compute',suffix=True) -counter += check_style('compute.rst', doc_dir, ":doc:`(.+) ` -",compute,'Compute',suffix=False) +counter += check_style('Commands_compute.rst', doc_dir, ":doc:`(.+) `",compute,'Compute',skip=skip_compute,suffix=True) +counter += check_style('compute.rst', doc_dir, ":doc:`(.+) ` -",compute,'Compute',skip=skip_compute,suffix=False) counter += check_style('Commands_fix.rst', doc_dir, ":doc:`(.+) `",fix,'Fix',skip=skip_fix,suffix=True) counter += check_style('fix.rst', doc_dir, ":doc:`(.+) ` -",fix,'Fix',skip=skip_fix,suffix=False) counter += check_style('Commands_pair.rst', doc_dir, ":doc:`(.+) `",pair,'Pair',skip=skip_pair,suffix=True) @@ -281,7 +282,7 @@ if counter: counter = 0 -counter += check_style_index("compute", compute, index["compute"]) +counter += check_style_index("compute", compute, index["compute"], skip=['pressure/cylinder']) counter += check_style_index("fix", fix, index["fix"], skip=['python','acks2/reax','qeq/reax','reax/c/bonds','reax/c/species']) counter += check_style_index("angle_style", angle, index["angle_style"]) counter += check_style_index("bond_style", bond, index["bond_style"]) diff --git a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index 476f89da1a..c9d8513622 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -359,7 +359,7 @@ void ComputeStressCartesian::compute_array() } void ComputeStressCartesian::compute_pressure_1d(double fpair, double xi, double xj, double delx, - double dely, double delz) + double dely, double delz) { int bin_s, bin_e, bin_step, bin, bin_limit; double xa, xb, l_sum; @@ -457,7 +457,7 @@ void ComputeStressCartesian::compute_pressure_1d(double fpair, double xi, double } void ComputeStressCartesian::compute_pressure_2d(double fpair, double xi, double yi, double xj, - double yj, double delx, double dely, double delz) + double yj, double delx, double dely, double delz) { int bin1, bin2, next_bin1, next_bin2; double la = 0.0, lb = 0.0, l_sum = 0.0; diff --git a/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp b/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp index 45cf8b54cd..c829871ccd 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cylinder.cpp @@ -59,7 +59,7 @@ static const char cite_compute_stress_cylinder[] = cylindrical geometry, according to the formulation of Addington et al. (2018) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ -ComputeStressCyl::ComputeStressCyl(LAMMPS *lmp, int narg, char **arg) : +ComputeStressCylinder::ComputeStressCylinder(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), Pvr_temp(nullptr), Pvr_all(nullptr), Pvz_temp(nullptr), Pvz_all(nullptr), Pvphi_temp(nullptr), Pvphi_all(nullptr), R(nullptr), Rinv(nullptr), R2(nullptr), PrAinv(nullptr), PzAinv(nullptr), R2kin(nullptr), density_temp(nullptr), @@ -147,7 +147,7 @@ ComputeStressCyl::ComputeStressCyl(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -ComputeStressCyl::~ComputeStressCyl() +ComputeStressCylinder::~ComputeStressCylinder() { memory->destroy(array); if (kinetic_flag == 1) { @@ -181,7 +181,7 @@ ComputeStressCyl::~ComputeStressCyl() /* ---------------------------------------------------------------------- */ -void ComputeStressCyl::init() +void ComputeStressCylinder::init() { if (force->pair == nullptr) error->all(FLERR, "No pair style is defined for compute stress/cylinder"); @@ -224,7 +224,7 @@ void ComputeStressCyl::init() /* ---------------------------------------------------------------------- */ -void ComputeStressCyl::init_list(int /* id */, NeighList *ptr) +void ComputeStressCylinder::init_list(int /* id */, NeighList *ptr) { list = ptr; } @@ -238,7 +238,7 @@ void ComputeStressCyl::init_list(int /* id */, NeighList *ptr) if flag is set, compute requested info about pair ------------------------------------------------------------------------- */ -void ComputeStressCyl::compute_array() +void ComputeStressCylinder::compute_array() { invoked_array = update->ntimestep; @@ -556,7 +556,7 @@ void ComputeStressCyl::compute_array() /* ---------------------------------------------------------------------- memory usage of data ------------------------------------------------------------------------- */ -double ComputeStressCyl::memory_usage() +double ComputeStressCylinder::memory_usage() { double bytes = (3.0 * (double) nphi + 16.0 * (double) nbins + (5.0 + 3.0 * kinetic_flag) * (double) nbins) * diff --git a/src/EXTRA-COMPUTE/compute_stress_cylinder.h b/src/EXTRA-COMPUTE/compute_stress_cylinder.h index 04f1da943e..1a7ff874a6 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cylinder.h +++ b/src/EXTRA-COMPUTE/compute_stress_cylinder.h @@ -13,7 +13,8 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(stress/cylinder,ComputeStressCyl); +ComputeStyle(stress/cylinder,ComputeStressCylinderinder); +ComputeStyle(pressure/cylinder,ComputeStressCylinderinder); // clang-format on #else @@ -24,10 +25,10 @@ ComputeStyle(stress/cylinder,ComputeStressCyl); namespace LAMMPS_NS { -class ComputeStressCyl : public Compute { +class ComputeStressCylinder : public Compute { public: - ComputeStressCyl(class LAMMPS *, int, char **); - ~ComputeStressCyl() override; + ComputeStressCylinder(class LAMMPS *, int, char **); + ~ComputeStressCylinder() override; void init() override; void init_list(int, class NeighList *) override; void compute_array() override; From bfb9638e6c0841b8b9880a9a9bd4db195a61beb1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Mar 2022 14:19:29 -0500 Subject: [PATCH 72/72] correct issue introduced by global pattern replacement --- src/EXTRA-COMPUTE/compute_stress_cylinder.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_cylinder.h b/src/EXTRA-COMPUTE/compute_stress_cylinder.h index 1a7ff874a6..76be8aff9a 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cylinder.h +++ b/src/EXTRA-COMPUTE/compute_stress_cylinder.h @@ -13,8 +13,8 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(stress/cylinder,ComputeStressCylinderinder); -ComputeStyle(pressure/cylinder,ComputeStressCylinderinder); +ComputeStyle(stress/cylinder,ComputeStressCylinder); +ComputeStyle(pressure/cylinder,ComputeStressCylinder); // clang-format on #else