forked from lijiext/lammps
separate out svector handling to new virtual functions, so it can be handled differently for pair styles hybrid and hybrid/overlay
This commit is contained in:
parent
5d0c86be48
commit
1e0cd0b202
|
@ -362,13 +362,21 @@ void PairHybrid::flags()
|
|||
if (styles[m]->tip4pflag) tip4pflag = 1;
|
||||
if (styles[m]->compute_flag) compute_flag = 1;
|
||||
}
|
||||
init_svector();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize Pair::svector array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairHybrid::init_svector()
|
||||
{
|
||||
// single_extra = list all sub-style single_extra
|
||||
// allocate svector
|
||||
|
||||
single_extra = 0;
|
||||
for (m = 0; m < nstyles; m++)
|
||||
single_extra += styles[m]->single_extra;
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
single_extra = MAX(single_extra,styles[m]->single_extra);
|
||||
|
||||
if (single_extra) {
|
||||
delete [] svector;
|
||||
|
@ -759,7 +767,6 @@ double PairHybrid::single(int i, int j, int itype, int jtype,
|
|||
fforce = 0.0;
|
||||
double esum = 0.0;
|
||||
int n = 0;
|
||||
if (single_extra) memset(svector,0,single_extra*sizeof(double));
|
||||
|
||||
for (int m = 0; m < nmap[itype][jtype]; m++) {
|
||||
if (rsq < styles[map[itype][jtype][m]]->cutsq[itype][jtype]) {
|
||||
|
@ -774,18 +781,29 @@ double PairHybrid::single(int i, int j, int itype, int jtype,
|
|||
esum += styles[map[itype][jtype][m]]->
|
||||
single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fone);
|
||||
fforce += fone;
|
||||
|
||||
// copy substyle extra values into hybrid's svector
|
||||
|
||||
if (single_extra && styles[map[itype][jtype][m]]->single_extra)
|
||||
for (int l = 0; l < styles[map[itype][jtype][m]]->single_extra; l++)
|
||||
svector[n++] = styles[map[itype][jtype][m]]->svector[l];
|
||||
}
|
||||
}
|
||||
|
||||
if (single_extra) copy_svector(itype,jtype);
|
||||
return esum;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy Pair::svector data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairHybrid::copy_svector(int itype, int jtype)
|
||||
{
|
||||
memset(svector,0,single_extra*sizeof(double));
|
||||
|
||||
// there is only one style in pair style hybrid for a pair of atom types
|
||||
Pair *this_style = styles[map[itype][jtype][0]];
|
||||
|
||||
for (int l = 0; this_style->single_extra; ++l) {
|
||||
svector[l] = this_style->svector[l];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify parameters of the pair style and its sub-styles
|
||||
------------------------------------------------------------------------- */
|
||||
|
|
|
@ -77,6 +77,9 @@ class PairHybrid : public Pair {
|
|||
void allocate();
|
||||
void flags();
|
||||
|
||||
virtual void init_svector();
|
||||
virtual void copy_svector(int,int);
|
||||
|
||||
void modify_special(int, int, char**);
|
||||
double *save_special();
|
||||
void set_special(int);
|
||||
|
|
|
@ -102,3 +102,52 @@ void PairHybridOverlay::coeff(int narg, char **arg)
|
|||
|
||||
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
we need to handle Pair::svector special for hybrid/overlay
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairHybridOverlay::init_svector()
|
||||
{
|
||||
// single_extra = list all sub-style single_extra
|
||||
// allocate svector
|
||||
|
||||
single_extra = 0;
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
single_extra += styles[m]->single_extra;
|
||||
|
||||
if (single_extra) {
|
||||
delete [] svector;
|
||||
svector = new double[single_extra];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
we need to handle Pair::svector special for hybrid/overlay
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairHybridOverlay::copy_svector(int itype, int jtype)
|
||||
{
|
||||
int n=0;
|
||||
Pair *this_style;
|
||||
|
||||
// fill svector array.
|
||||
// copy data from active styles and use 0.0 for inactive ones
|
||||
for (int m = 0; m < nstyles; m++) {
|
||||
for (int k = 0; k < nmap[itype][jtype]; ++k) {
|
||||
if (m == map[itype][jtype][k]) {
|
||||
this_style = styles[m];
|
||||
} else {
|
||||
this_style = NULL;
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < styles[m]->single_extra; ++l) {
|
||||
if (this_style) {
|
||||
svector[n++] = this_style->svector[l];
|
||||
} else {
|
||||
svector[n++] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ class PairHybridOverlay : public PairHybrid {
|
|||
PairHybridOverlay(class LAMMPS *);
|
||||
virtual ~PairHybridOverlay() {}
|
||||
void coeff(int, char **);
|
||||
|
||||
void init_svector();
|
||||
void copy_svector(int,int);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue