From 60c0270375bed62ce39e1c7b733cacffdb96dc8b Mon Sep 17 00:00:00 2001 From: Stefan Paquay Date: Wed, 11 Sep 2019 10:58:45 -0400 Subject: [PATCH] Added option to impose fix propel/self only to specific types --- .../fix_propel_self/2d_velocity/in.2d_langevin | 17 +++++++++++++++++ src/USER-MISC/fix_propel_self.cpp | 16 +++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/examples/USER/misc/fix_propel_self/2d_velocity/in.2d_langevin b/examples/USER/misc/fix_propel_self/2d_velocity/in.2d_langevin index b7a1b93745..563c0bd969 100644 --- a/examples/USER/misc/fix_propel_self/2d_velocity/in.2d_langevin +++ b/examples/USER/misc/fix_propel_self/2d_velocity/in.2d_langevin @@ -30,8 +30,25 @@ thermo_style custom time step pe ke etotal temp thermo 1000 run 25000 +group one type 1 +group two type 2 + +compute ke1 one ke +compute ke2 two ke + +thermo_style custom time step pe ke etotal temp c_ke1 c_ke2 + fix active all propel/self velocity 1.0 # With active force there is more motion so increase bin size: neighbor 1.0 bin run 25000 + +# Only make type 1 active: +fix active all propel/self velocity 1.0 types 1 + +# With active force there is more motion so increase bin size: +neighbor 1.0 bin +run 25000 + + diff --git a/src/USER-MISC/fix_propel_self.cpp b/src/USER-MISC/fix_propel_self.cpp index f8c00e5ca8..56f5e44869 100644 --- a/src/USER-MISC/fix_propel_self.cpp +++ b/src/USER-MISC/fix_propel_self.cpp @@ -88,8 +88,10 @@ FixPropelSelf::FixPropelSelf( LAMMPS *lmp, int narg, char **argv ) // In this case we need to allocate the type list. // First find the largest given type: int max_type_in_list = 0; - while (!isalpha(arg[iarg + n_types_filter][0])) { - int curr_type = force->numeric(FLERR, arg[iarg + n_types_filter]); + ++iarg; + while ( (iarg + n_types_filter < narg) && + (!isalpha(argv[iarg + n_types_filter][0]))) { + int curr_type = force->numeric(FLERR, argv[iarg + n_types_filter]); if (curr_type > max_type_in_list) max_type_in_list = curr_type; ++n_types_filter; } @@ -110,10 +112,11 @@ FixPropelSelf::FixPropelSelf( LAMMPS *lmp, int narg, char **argv ) } for (int i = 0; i < n_types_filter; ++i) { - int curr_type = force->numeric(FLERR, arg[iarg + i]); + int curr_type = force->numeric(FLERR, argv[iarg + i]); apply_to_type[curr_type] = 1; } // Done handling types argument. + iarg += n_types_filter; // -1 because we incremented by 1 previously. } else { char msg[2048]; sprintf(msg, "Illegal fix propel/self command: " @@ -158,6 +161,7 @@ void FixPropelSelf::post_force(int vflag ) case VELOCITY: if (n_types_filter) post_force_velocity<1>(vflag); else post_force_velocity<0>(vflag); + break; default: error->all(FLERR, "reached statement that should be unreachable"); } @@ -173,7 +177,9 @@ void FixPropelSelf::post_force_quaternion(int /* vflag */ ) int *mask = atom->mask; int nlocal = atom->nlocal; - + int *type = atom->type; + int* ellipsoid = atom->ellipsoid; + AtomVecEllipsoid::Bonus *bonus = av->bonus; // Add the active force to the atom force: for( int i = 0; i < nlocal; ++i ){ @@ -185,7 +191,6 @@ void FixPropelSelf::post_force_quaternion(int /* vflag */ ) double f_act[3] = { 0.0, 0.0, 1.0 }; double f_rot[3]; - int* ellipsoid = atom->ellipsoid; double *quat = bonus[ellipsoid[i]].quat; tagint *tag = atom->tag; @@ -228,6 +233,7 @@ void FixPropelSelf::post_force_velocity(int /*vflag*/ ) int *mask = atom->mask; int nlocal = atom->nlocal; tagint *tag = atom->tag; + int *type = atom->type; // Add the active force to the atom force: for( int i = 0; i < nlocal; ++i ){