2009-12-17 04:27:17 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
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
|
2012-06-07 06:47:51 +08:00
|
|
|
certain rights in this software. This software is distributed under
|
2009-12-17 04:27:17 +08:00
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
Contributing authors: Paul Crozier (SNL), Jeff Greathouse (SNL)
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2019-07-03 10:56:56 +08:00
|
|
|
#include "compute_rdf.h"
|
2015-10-31 04:04:06 +08:00
|
|
|
#include <mpi.h>
|
2018-04-28 05:41:04 +08:00
|
|
|
#include <cmath>
|
|
|
|
#include <cstring>
|
2009-12-17 04:27:17 +08:00
|
|
|
#include "atom.h"
|
|
|
|
#include "update.h"
|
|
|
|
#include "force.h"
|
|
|
|
#include "pair.h"
|
2009-12-17 07:01:17 +08:00
|
|
|
#include "domain.h"
|
2009-12-17 04:27:17 +08:00
|
|
|
#include "neighbor.h"
|
|
|
|
#include "neigh_request.h"
|
|
|
|
#include "neigh_list.h"
|
|
|
|
#include "group.h"
|
2011-10-20 08:11:49 +08:00
|
|
|
#include "math_const.h"
|
2009-12-17 04:27:17 +08:00
|
|
|
#include "memory.h"
|
|
|
|
#include "error.h"
|
2017-12-02 00:51:40 +08:00
|
|
|
#include "comm.h"
|
2009-12-17 04:27:17 +08:00
|
|
|
|
|
|
|
using namespace LAMMPS_NS;
|
2011-10-20 08:11:49 +08:00
|
|
|
using namespace MathConst;
|
2009-12-17 04:27:17 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) :
|
2016-08-30 06:52:03 +08:00
|
|
|
Compute(lmp, narg, arg),
|
|
|
|
rdfpair(NULL), nrdfpair(NULL), ilo(NULL), ihi(NULL), jlo(NULL), jhi(NULL),
|
2017-07-08 03:50:19 +08:00
|
|
|
hist(NULL), histall(NULL), typecount(NULL), icount(NULL), jcount(NULL),
|
2017-01-20 08:01:15 +08:00
|
|
|
duplicates(NULL)
|
2009-12-17 04:27:17 +08:00
|
|
|
{
|
2018-10-20 08:43:04 +08:00
|
|
|
if (narg < 4) error->all(FLERR,"Illegal compute rdf command");
|
2009-12-17 04:27:17 +08:00
|
|
|
|
|
|
|
array_flag = 1;
|
2009-12-17 07:01:17 +08:00
|
|
|
extarray = 0;
|
2009-12-17 04:27:17 +08:00
|
|
|
|
2013-06-29 03:00:58 +08:00
|
|
|
nbin = force->inumeric(FLERR,arg[3]);
|
2011-09-24 02:06:55 +08:00
|
|
|
if (nbin < 1) error->all(FLERR,"Illegal compute rdf command");
|
2017-02-22 06:49:21 +08:00
|
|
|
|
|
|
|
// optional args
|
|
|
|
// nargpair = # of pairwise args, starting at iarg = 4
|
|
|
|
|
|
|
|
cutflag = 0;
|
|
|
|
|
|
|
|
int iarg;
|
|
|
|
for (iarg = 4; iarg < narg; iarg++)
|
|
|
|
if (strcmp(arg[iarg],"cutoff") == 0) break;
|
|
|
|
|
|
|
|
int nargpair = iarg - 4;
|
|
|
|
|
|
|
|
while (iarg < narg) {
|
|
|
|
if (strcmp(arg[iarg],"cutoff") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all(FLERR,"Illegal compute rdf command");
|
|
|
|
cutoff_user = force->numeric(FLERR,arg[iarg+1]);
|
|
|
|
if (cutoff_user <= 0.0) cutflag = 0;
|
|
|
|
else cutflag = 1;
|
|
|
|
iarg += 2;
|
|
|
|
} else error->all(FLERR,"Illegal compute rdf command");
|
|
|
|
}
|
2017-07-08 03:50:19 +08:00
|
|
|
|
2017-02-22 06:49:21 +08:00
|
|
|
// pairwise args
|
|
|
|
|
|
|
|
if (nargpair == 0) npairs = 1;
|
2018-12-01 21:14:02 +08:00
|
|
|
else {
|
2018-10-20 08:43:04 +08:00
|
|
|
if (nargpair % 2) error->all(FLERR,"Illegal compute rdf command");
|
|
|
|
npairs = nargpair/2;
|
|
|
|
}
|
2009-12-17 04:27:17 +08:00
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
size_array_rows = nbin;
|
|
|
|
size_array_cols = 1 + 2*npairs;
|
2009-12-17 04:27:17 +08:00
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
int ntypes = atom->ntypes;
|
2011-03-26 03:40:12 +08:00
|
|
|
memory->create(rdfpair,npairs,ntypes+1,ntypes+1,"rdf:rdfpair");
|
|
|
|
memory->create(nrdfpair,ntypes+1,ntypes+1,"rdf:nrdfpair");
|
2009-12-17 07:01:17 +08:00
|
|
|
ilo = new int[npairs];
|
|
|
|
ihi = new int[npairs];
|
|
|
|
jlo = new int[npairs];
|
|
|
|
jhi = new int[npairs];
|
|
|
|
|
2017-02-22 06:49:21 +08:00
|
|
|
if (nargpair == 0) {
|
2009-12-17 07:01:17 +08:00
|
|
|
ilo[0] = 1; ihi[0] = ntypes;
|
|
|
|
jlo[0] = 1; jhi[0] = ntypes;
|
|
|
|
} else {
|
2017-02-22 06:49:21 +08:00
|
|
|
iarg = 4;
|
2018-10-20 08:43:04 +08:00
|
|
|
for (int ipair = 0; ipair < npairs; ipair++) {
|
|
|
|
force->bounds(FLERR,arg[iarg],atom->ntypes,ilo[ipair],ihi[ipair]);
|
|
|
|
force->bounds(FLERR,arg[iarg+1],atom->ntypes,jlo[ipair],jhi[ipair]);
|
|
|
|
if (ilo[ipair] > ihi[ipair] || jlo[ipair] > jhi[ipair])
|
2012-06-07 06:47:51 +08:00
|
|
|
error->all(FLERR,"Illegal compute rdf command");
|
2009-12-17 07:01:17 +08:00
|
|
|
iarg += 2;
|
|
|
|
}
|
2009-12-17 04:27:17 +08:00
|
|
|
}
|
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
int i,j;
|
|
|
|
for (i = 1; i <= ntypes; i++)
|
|
|
|
for (j = 1; j <= ntypes; j++)
|
|
|
|
nrdfpair[i][j] = 0;
|
|
|
|
|
2018-10-20 08:43:04 +08:00
|
|
|
int ihisto;
|
2009-12-17 07:01:17 +08:00
|
|
|
for (int m = 0; m < npairs; m++)
|
|
|
|
for (i = ilo[m]; i <= ihi[m]; i++)
|
2018-10-20 08:43:04 +08:00
|
|
|
for (j = jlo[m]; j <= jhi[m]; j++) {
|
|
|
|
ihisto = nrdfpair[i][j]++;
|
|
|
|
rdfpair[ihisto][i][j] = m;
|
|
|
|
}
|
2009-12-17 07:01:17 +08:00
|
|
|
|
2011-03-26 05:13:51 +08:00
|
|
|
memory->create(hist,npairs,nbin,"rdf:hist");
|
|
|
|
memory->create(histall,npairs,nbin,"rdf:histall");
|
|
|
|
memory->create(array,nbin,1+2*npairs,"rdf:array");
|
2009-12-17 07:01:17 +08:00
|
|
|
typecount = new int[ntypes+1];
|
|
|
|
icount = new int[npairs];
|
|
|
|
jcount = new int[npairs];
|
2015-10-22 02:29:37 +08:00
|
|
|
duplicates = new int[npairs];
|
2017-07-08 03:39:25 +08:00
|
|
|
|
|
|
|
dynamic = 0;
|
|
|
|
natoms_old = 0;
|
2009-12-17 04:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
ComputeRDF::~ComputeRDF()
|
|
|
|
{
|
2011-03-26 03:40:12 +08:00
|
|
|
memory->destroy(rdfpair);
|
2011-03-26 05:13:51 +08:00
|
|
|
memory->destroy(nrdfpair);
|
2009-12-17 07:01:17 +08:00
|
|
|
delete [] ilo;
|
|
|
|
delete [] ihi;
|
|
|
|
delete [] jlo;
|
|
|
|
delete [] jhi;
|
2011-03-26 05:13:51 +08:00
|
|
|
memory->destroy(hist);
|
|
|
|
memory->destroy(histall);
|
|
|
|
memory->destroy(array);
|
2009-12-17 07:01:17 +08:00
|
|
|
delete [] typecount;
|
|
|
|
delete [] icount;
|
|
|
|
delete [] jcount;
|
2015-10-22 02:29:37 +08:00
|
|
|
delete [] duplicates;
|
2009-12-17 04:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void ComputeRDF::init()
|
|
|
|
{
|
2009-12-17 07:01:17 +08:00
|
|
|
|
2017-02-22 06:49:21 +08:00
|
|
|
if (!force->pair && !cutflag)
|
|
|
|
error->all(FLERR,"Compute rdf requires a pair style be defined "
|
|
|
|
"or cutoff specified");
|
|
|
|
|
|
|
|
if (cutflag) {
|
|
|
|
double skin = neighbor->skin;
|
|
|
|
mycutneigh = cutoff_user + skin;
|
|
|
|
|
|
|
|
double cutghost; // as computed by Neighbor and Comm
|
2017-07-08 03:50:19 +08:00
|
|
|
if (force->pair)
|
2017-02-22 06:49:21 +08:00
|
|
|
cutghost = MAX(force->pair->cutforce+skin,comm->cutghostuser);
|
2017-07-08 03:50:19 +08:00
|
|
|
else
|
2017-02-22 06:49:21 +08:00
|
|
|
cutghost = comm->cutghostuser;
|
|
|
|
|
2017-07-08 03:50:19 +08:00
|
|
|
if (mycutneigh > cutghost)
|
2018-05-16 02:18:10 +08:00
|
|
|
error->all(FLERR,"Compute rdf cutoff exceeds ghost atom range - "
|
2017-02-22 06:49:21 +08:00
|
|
|
"use comm_modify cutoff command");
|
|
|
|
if (force->pair && mycutneigh < force->pair->cutforce + skin)
|
|
|
|
if (comm->me == 0)
|
|
|
|
error->warning(FLERR,"Compute rdf cutoff less than neighbor cutoff - "
|
|
|
|
"forcing a needless neighbor list build");
|
|
|
|
|
|
|
|
delr = cutoff_user / nbin;
|
|
|
|
} else delr = force->pair->cutforce / nbin;
|
|
|
|
|
2009-12-17 04:27:17 +08:00
|
|
|
delrinv = 1.0/delr;
|
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
// set 1st column of output array to bin coords
|
|
|
|
|
|
|
|
for (int i = 0; i < nbin; i++)
|
|
|
|
array[i][0] = (i+0.5) * delr;
|
|
|
|
|
2017-07-08 03:39:25 +08:00
|
|
|
// initialize normalization, finite size correction, and changing atom counts
|
|
|
|
|
|
|
|
natoms_old = atom->natoms;
|
|
|
|
dynamic = group->dynamic[igroup];
|
|
|
|
if (dynamic_user) dynamic = 1;
|
|
|
|
init_norm();
|
|
|
|
|
|
|
|
// need an occasional half neighbor list
|
|
|
|
// if user specified, request a cutoff = cutoff_user + skin
|
|
|
|
// skin is included b/c Neighbor uses this value similar
|
|
|
|
// to its cutneighmax = force cutoff + skin
|
|
|
|
// also, this NeighList may be used by this compute for multiple steps
|
|
|
|
// (until next reneighbor), so it needs to contain atoms further
|
|
|
|
// than cutoff_user apart, just like a normal neighbor list does
|
|
|
|
|
|
|
|
int irequest = neighbor->request(this,instance_me);
|
|
|
|
neighbor->requests[irequest]->pair = 0;
|
|
|
|
neighbor->requests[irequest]->compute = 1;
|
|
|
|
neighbor->requests[irequest]->occasional = 1;
|
|
|
|
if (cutflag) {
|
|
|
|
neighbor->requests[irequest]->cut = 1;
|
|
|
|
neighbor->requests[irequest]->cutoff = mycutneigh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2018-08-23 23:26:00 +08:00
|
|
|
void ComputeRDF::init_list(int /*id*/, NeighList *ptr)
|
2017-07-08 03:39:25 +08:00
|
|
|
{
|
|
|
|
list = ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void ComputeRDF::init_norm()
|
|
|
|
{
|
|
|
|
int i,j,m;
|
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
// count atoms of each type that are also in group
|
|
|
|
|
2017-07-08 03:39:25 +08:00
|
|
|
const int nlocal = atom->nlocal;
|
|
|
|
const int ntypes = atom->ntypes;
|
|
|
|
const int * const mask = atom->mask;
|
|
|
|
const int * const type = atom->type;
|
2009-12-17 07:01:17 +08:00
|
|
|
|
|
|
|
for (i = 1; i <= ntypes; i++) typecount[i] = 0;
|
|
|
|
for (i = 0; i < nlocal; i++)
|
|
|
|
if (mask[i] & groupbit) typecount[type[i]]++;
|
|
|
|
|
|
|
|
// icount = # of I atoms participating in I,J pairs for each histogram
|
|
|
|
// jcount = # of J atoms participating in I,J pairs for each histogram
|
2015-10-22 02:29:37 +08:00
|
|
|
// duplicates = # of atoms in both groups I and J for each histogram
|
2009-12-17 07:01:17 +08:00
|
|
|
|
|
|
|
for (m = 0; m < npairs; m++) {
|
|
|
|
icount[m] = 0;
|
|
|
|
for (i = ilo[m]; i <= ihi[m]; i++) icount[m] += typecount[i];
|
|
|
|
jcount[m] = 0;
|
|
|
|
for (i = jlo[m]; i <= jhi[m]; i++) jcount[m] += typecount[i];
|
2015-10-22 02:29:37 +08:00
|
|
|
duplicates[m] = 0;
|
|
|
|
for (i = ilo[m]; i <= ihi[m]; i++)
|
|
|
|
for (j = jlo[m]; j <= jhi[m]; j++)
|
|
|
|
if (i == j) duplicates[m] += typecount[i];
|
2009-12-17 07:01:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int *scratch = new int[npairs];
|
|
|
|
MPI_Allreduce(icount,scratch,npairs,MPI_INT,MPI_SUM,world);
|
|
|
|
for (i = 0; i < npairs; i++) icount[i] = scratch[i];
|
|
|
|
MPI_Allreduce(jcount,scratch,npairs,MPI_INT,MPI_SUM,world);
|
|
|
|
for (i = 0; i < npairs; i++) jcount[i] = scratch[i];
|
2015-10-22 02:29:37 +08:00
|
|
|
MPI_Allreduce(duplicates,scratch,npairs,MPI_INT,MPI_SUM,world);
|
|
|
|
for (i = 0; i < npairs; i++) duplicates[i] = scratch[i];
|
2009-12-17 07:01:17 +08:00
|
|
|
delete [] scratch;
|
2009-12-17 04:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void ComputeRDF::compute_array()
|
|
|
|
{
|
2009-12-17 07:01:17 +08:00
|
|
|
int i,j,m,ii,jj,inum,jnum,itype,jtype,ipair,jpair,ibin,ihisto;
|
2009-12-17 04:27:17 +08:00
|
|
|
double xtmp,ytmp,ztmp,delx,dely,delz,r;
|
|
|
|
int *ilist,*jlist,*numneigh,**firstneigh;
|
2011-04-06 03:10:43 +08:00
|
|
|
double factor_lj,factor_coul;
|
2009-12-17 04:27:17 +08:00
|
|
|
|
2017-07-08 03:39:25 +08:00
|
|
|
if (natoms_old != atom->natoms) {
|
|
|
|
dynamic = 1;
|
|
|
|
natoms_old = atom->natoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the number of atoms has changed or we have a dynamic group
|
|
|
|
// or dynamic updates are requested (e.g. when changing atom types)
|
|
|
|
// we need to recompute some normalization parameters
|
|
|
|
|
|
|
|
if (dynamic) init_norm();
|
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
invoked_array = update->ntimestep;
|
|
|
|
|
2009-12-17 04:27:17 +08:00
|
|
|
// invoke half neighbor list (will copy or build if necessary)
|
|
|
|
|
2014-10-01 07:20:03 +08:00
|
|
|
neighbor->build_one(list);
|
2009-12-17 04:27:17 +08:00
|
|
|
|
|
|
|
inum = list->inum;
|
|
|
|
ilist = list->ilist;
|
|
|
|
numneigh = list->numneigh;
|
|
|
|
firstneigh = list->firstneigh;
|
|
|
|
|
|
|
|
// zero the histogram counts
|
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
for (i = 0; i < npairs; i++)
|
|
|
|
for (j = 0; j < nbin; j++)
|
2009-12-17 04:27:17 +08:00
|
|
|
hist[i][j] = 0;
|
|
|
|
|
|
|
|
// tally the RDF
|
|
|
|
// both atom i and j must be in fix group
|
|
|
|
// itype,jtype must have been specified by user
|
2009-12-17 07:01:17 +08:00
|
|
|
// consider I,J as one interaction even if neighbor pair is stored on 2 procs
|
|
|
|
// tally I,J pair each time I is central atom, and each time J is central
|
|
|
|
|
|
|
|
double **x = atom->x;
|
|
|
|
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;
|
2009-12-17 04:27:17 +08:00
|
|
|
|
|
|
|
for (ii = 0; ii < inum; ii++) {
|
|
|
|
i = ilist[ii];
|
2009-12-17 07:01:17 +08:00
|
|
|
if (!(mask[i] & groupbit)) continue;
|
|
|
|
xtmp = x[i][0];
|
|
|
|
ytmp = x[i][1];
|
|
|
|
ztmp = x[i][2];
|
|
|
|
itype = type[i];
|
|
|
|
jlist = firstneigh[i];
|
|
|
|
jnum = numneigh[i];
|
|
|
|
|
|
|
|
for (jj = 0; jj < jnum; jj++) {
|
|
|
|
j = jlist[jj];
|
2011-04-06 03:10:43 +08:00
|
|
|
factor_lj = special_lj[sbmask(j)];
|
|
|
|
factor_coul = special_coul[sbmask(j)];
|
|
|
|
j &= NEIGHMASK;
|
2009-12-17 07:01:17 +08:00
|
|
|
|
2011-04-06 03:10:43 +08:00
|
|
|
// if both weighting factors are 0, skip this pair
|
|
|
|
// could be 0 and still be in neigh list for long-range Coulombics
|
|
|
|
// want consistency with non-charged pairs which wouldn't be in list
|
|
|
|
|
|
|
|
if (factor_lj == 0.0 && factor_coul == 0.0) continue;
|
2009-12-17 07:01:17 +08:00
|
|
|
|
|
|
|
if (!(mask[j] & groupbit)) continue;
|
|
|
|
jtype = type[j];
|
|
|
|
ipair = nrdfpair[itype][jtype];
|
|
|
|
jpair = nrdfpair[jtype][itype];
|
|
|
|
if (!ipair && !jpair) continue;
|
|
|
|
|
|
|
|
delx = xtmp - x[j][0];
|
|
|
|
dely = ytmp - x[j][1];
|
|
|
|
delz = ztmp - x[j][2];
|
|
|
|
r = sqrt(delx*delx + dely*dely + delz*delz);
|
|
|
|
ibin = static_cast<int> (r*delrinv);
|
|
|
|
if (ibin >= nbin) continue;
|
|
|
|
|
2018-10-20 08:43:04 +08:00
|
|
|
for (ihisto = 0; ihisto < ipair; ihisto++) {
|
|
|
|
m = rdfpair[ihisto][itype][jtype];
|
|
|
|
hist[m][ibin] += 1.0;
|
|
|
|
}
|
2009-12-17 07:01:17 +08:00
|
|
|
if (newton_pair || j < nlocal) {
|
2018-10-20 08:43:04 +08:00
|
|
|
for (ihisto = 0; ihisto < jpair; ihisto++) {
|
|
|
|
m = rdfpair[ihisto][jtype][itype];
|
|
|
|
hist[m][ibin] += 1.0;
|
|
|
|
}
|
2009-12-17 04:27:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
// sum histograms across procs
|
|
|
|
|
|
|
|
MPI_Allreduce(hist[0],histall[0],npairs*nbin,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
|
|
|
|
// convert counts to g(r) and coord(r) and copy into output array
|
2015-10-22 02:29:37 +08:00
|
|
|
// vfrac = fraction of volume in shell m
|
|
|
|
// npairs = number of pairs, corrected for duplicates
|
|
|
|
// duplicates = pairs in which both atoms are the same
|
2009-12-17 07:01:17 +08:00
|
|
|
|
2015-10-22 02:29:37 +08:00
|
|
|
double constant,vfrac,gr,ncoord,rlower,rupper,normfac;
|
2009-12-17 07:01:17 +08:00
|
|
|
|
|
|
|
if (domain->dimension == 3) {
|
2011-10-20 08:11:49 +08:00
|
|
|
constant = 4.0*MY_PI / (3.0*domain->xprd*domain->yprd*domain->zprd);
|
2009-12-17 07:01:17 +08:00
|
|
|
|
|
|
|
for (m = 0; m < npairs; m++) {
|
2015-10-22 02:29:37 +08:00
|
|
|
normfac = (icount[m] > 0) ? static_cast<double>(jcount[m])
|
|
|
|
- static_cast<double>(duplicates[m])/icount[m] : 0.0;
|
2009-12-17 07:01:17 +08:00
|
|
|
ncoord = 0.0;
|
|
|
|
for (ibin = 0; ibin < nbin; ibin++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
rlower = ibin*delr;
|
|
|
|
rupper = (ibin+1)*delr;
|
2015-10-22 02:29:37 +08:00
|
|
|
vfrac = constant * (rupper*rupper*rupper - rlower*rlower*rlower);
|
|
|
|
if (vfrac * normfac != 0.0)
|
|
|
|
gr = histall[m][ibin] / (vfrac * normfac * icount[m]);
|
2012-06-07 06:47:51 +08:00
|
|
|
else gr = 0.0;
|
2015-10-22 02:29:37 +08:00
|
|
|
if (icount[m] != 0)
|
|
|
|
ncoord += gr * vfrac * normfac;
|
2012-06-07 06:47:51 +08:00
|
|
|
array[ibin][1+2*m] = gr;
|
|
|
|
array[ibin][2+2*m] = ncoord;
|
2009-12-17 07:01:17 +08:00
|
|
|
}
|
|
|
|
}
|
2009-12-17 04:27:17 +08:00
|
|
|
|
2009-12-17 07:01:17 +08:00
|
|
|
} else {
|
2011-10-20 08:11:49 +08:00
|
|
|
constant = MY_PI / (domain->xprd*domain->yprd);
|
2009-12-17 07:01:17 +08:00
|
|
|
|
|
|
|
for (m = 0; m < npairs; m++) {
|
|
|
|
ncoord = 0.0;
|
2015-10-22 02:29:37 +08:00
|
|
|
normfac = (icount[m] > 0) ? static_cast<double>(jcount[m])
|
|
|
|
- static_cast<double>(duplicates[m])/icount[m] : 0.0;
|
2009-12-17 07:01:17 +08:00
|
|
|
for (ibin = 0; ibin < nbin; ibin++) {
|
2012-06-07 06:47:51 +08:00
|
|
|
rlower = ibin*delr;
|
|
|
|
rupper = (ibin+1)*delr;
|
2015-10-22 02:29:37 +08:00
|
|
|
vfrac = constant * (rupper*rupper - rlower*rlower);
|
|
|
|
if (vfrac * normfac != 0.0)
|
|
|
|
gr = histall[m][ibin] / (vfrac * normfac * icount[m]);
|
2012-06-07 06:47:51 +08:00
|
|
|
else gr = 0.0;
|
2015-10-22 02:29:37 +08:00
|
|
|
if (icount[m] != 0)
|
|
|
|
ncoord += gr * vfrac * normfac;
|
2012-06-07 06:47:51 +08:00
|
|
|
array[ibin][1+2*m] = gr;
|
|
|
|
array[ibin][2+2*m] = ncoord;
|
2009-12-17 07:01:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-17 04:27:17 +08:00
|
|
|
}
|