From 92cc30e7ba42fd26bc0795626fa5dbf401ed0e0d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 23 Apr 2021 05:13:36 -0400 Subject: [PATCH] correctly determine the number of active pair style instances --- src/SPIN/compute_spin.cpp | 17 ++++++++++------- src/SPIN/fix_nve_spin.cpp | 17 ++++++++++------- src/pair_hybrid.h | 4 +++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/SPIN/compute_spin.cpp b/src/SPIN/compute_spin.cpp index 9108cd7dfa..26b02aa7c3 100644 --- a/src/SPIN/compute_spin.cpp +++ b/src/SPIN/compute_spin.cpp @@ -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; ipair_match("spin",0,i)) { + if (force->pair_match("^spin",0,i)) { npairspin ++; } } diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index 855b82c30e..0c6a19b4ca 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -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; ipair_match("spin",0,i)) { + if (force->pair_match("^spin",0,i)) { npairspin ++; } } diff --git a/src/pair_hybrid.h b/src/pair_hybrid.h index ca79163fc2..1279bc04fa 100644 --- a/src/pair_hybrid.h +++ b/src/pair_hybrid.h @@ -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 *);