correctly determine the number of active pair style instances

This commit is contained in:
Axel Kohlmeyer
2021-04-23 05:13:36 -04:00
parent 7bae94cb49
commit 92cc30e7ba
3 changed files with 23 additions and 15 deletions

View File

@ -82,15 +82,18 @@ void ComputeSpin::init()
// loop 1: obtain # of Pairs, and # of Pair/Spin styles
if (force->pair_match("spin",0,0)) { // only one Pair/Spin style
pair = force->pair_match("spin",0,0);
npairs = pair->instance_total;
PairHybrid *hybrid = (PairHybrid *)force->pair_match("^hybrid",0);
if (force->pair_match("^spin",0,0)) { // only one Pair/Spin style
pair = force->pair_match("^spin",0,0);
if (hybrid == nullptr) npairs = 1;
else npairs = hybrid->nstyles;
npairspin = 1;
} else if (force->pair_match("spin",0,1)) { // more than one Pair/Spin style
pair = force->pair_match("spin",0,1);
npairs = pair->instance_total;
} else if (force->pair_match("^spin",0,1)) { // more than one Pair/Spin style
pair = force->pair_match("^spin",0,1);
if (hybrid == nullptr) npairs = 1;
else npairs = hybrid->nstyles;
for (int i = 0; i<npairs; i++) {
if (force->pair_match("spin",0,i)) {
if (force->pair_match("^spin",0,i)) {
npairspin ++;
}
}

View File

@ -172,15 +172,18 @@ void FixNVESpin::init()
// loop 1: obtain # of Pairs, and # of Pair/Spin styles
if (force->pair_match("spin",0,0)) { // only one Pair/Spin style
pair = force->pair_match("spin",0,0);
npairs = pair->instance_total;
PairHybrid *hybrid = (PairHybrid *)force->pair_match("^hybrid",0);
if (force->pair_match("^spin",0,0)) { // only one Pair/Spin style
pair = force->pair_match("^spin",0,0);
if (hybrid == nullptr) npairs = 1;
else npairs = hybrid->nstyles;
npairspin = 1;
} else if (force->pair_match("spin",0,1)) { // more than one Pair/Spin style
pair = force->pair_match("spin",0,1);
npairs = pair->instance_total;
} else if (force->pair_match("^spin",0,1)) { // more than one Pair/Spin style
pair = force->pair_match("^spin",0,1);
if (hybrid == nullptr) npairs = 1;
else npairs = hybrid->nstyles;
for (int i = 0; i<npairs; i++) {
if (force->pair_match("spin",0,i)) {
if (force->pair_match("^spin",0,i)) {
npairspin ++;
}
}

View File

@ -25,13 +25,15 @@ PairStyle(hybrid,PairHybrid)
namespace LAMMPS_NS {
class PairHybrid : public Pair {
friend class ComputeSpin;
friend class FixGPU;
friend class FixIntel;
friend class FixOMP;
friend class FixNVESpin;
friend class Force;
friend class Info;
friend class Neighbor;
friend class Respa;
friend class Info;
friend class PairDeprecated;
public:
PairHybrid(class LAMMPS *);