@@ -57,9 +57,12 @@ void Integrate::initialize(
5757 if (fixed_group < 0 ) {
5858 PRINT_INPUT_ERROR (" It is not allowed to have moving group but no fixed group." );
5959 }
60- if (move_group == fixed_group) {
60+ if (move_group == fixed_group && move_grouping_method == fixed_grouping_method ) {
6161 PRINT_INPUT_ERROR (" The fixed and moving groups cannot be the same." );
6262 }
63+ if (fixed_grouping_method != move_grouping_method) {
64+ PRINT_INPUT_ERROR (" The fixed and moving groups must use the same grouping method." );
65+ }
6366 if (type != 1 && type != 2 && type != 4 && type != 22 ) {
6467 PRINT_INPUT_ERROR (
6568 " It is only allowed to use nvt_ber, nvt_nhc, or nvt_bdp with a moving group." );
@@ -208,12 +211,16 @@ void Integrate::initialize(
208211 ensemble->total_steps = &this ->total_steps ;
209212 ensemble->thermo = &thermo;
210213 ensemble->fixed_group = fixed_group;
214+ ensemble->fixed_grouping_method = fixed_grouping_method;
215+ ensemble->move_grouping_method = move_grouping_method;
211216}
212217
213218void Integrate::finalize ()
214219{
215220 fixed_group = -1 ; // no group has an index of -1
216221 move_group = -1 ;
222+ fixed_grouping_method = 0 ;
223+ move_grouping_method = 0 ;
217224 deform_x = 0 ;
218225 deform_y = 0 ;
219226 deform_z = 0 ;
@@ -990,64 +997,105 @@ void Integrate::parse_ensemble(
990997
991998void Integrate::parse_fix (const char ** param, int num_param, std::vector<Group>& group)
992999{
993- if (num_param != 2 ) {
994- PRINT_INPUT_ERROR (" Keyword 'fix' should have 1 parameter." );
995- }
996-
997- if (!is_valid_int (param[1 ], &fixed_group)) {
998- PRINT_INPUT_ERROR (" Fixed group ID should be an integer." );
1000+ if (num_param != 2 && num_param != 3 ) {
1001+ PRINT_INPUT_ERROR (" Keyword 'fix' should have 1 or 2 parameters." );
9991002 }
10001003
10011004 if (group.size () < 1 ) {
10021005 PRINT_INPUT_ERROR (" Cannot use 'fix' without grouping method." );
10031006 }
10041007
1008+ if (num_param == 3 ) {
1009+ // fix grouping_method group_id
1010+ if (!is_valid_int (param[1 ], &fixed_grouping_method)) {
1011+ PRINT_INPUT_ERROR (" Grouping method for 'fix' should be an integer." );
1012+ }
1013+ if (fixed_grouping_method < 0 ) {
1014+ PRINT_INPUT_ERROR (" Grouping method for 'fix' should >= 0." );
1015+ }
1016+ if (fixed_grouping_method >= group.size ()) {
1017+ PRINT_INPUT_ERROR (" Grouping method for 'fix' should < number of grouping methods." );
1018+ }
1019+ if (!is_valid_int (param[2 ], &fixed_group)) {
1020+ PRINT_INPUT_ERROR (" Fixed group ID should be an integer." );
1021+ }
1022+ } else {
1023+ // fix group_id (default grouping_method = 0)
1024+ fixed_grouping_method = 0 ;
1025+ if (!is_valid_int (param[1 ], &fixed_group)) {
1026+ PRINT_INPUT_ERROR (" Fixed group ID should be an integer." );
1027+ }
1028+ }
1029+
10051030 if (fixed_group < 0 ) {
10061031 PRINT_INPUT_ERROR (" Fixed group ID should >= 0." );
10071032 }
10081033
1009- if (fixed_group >= group[0 ].number ) {
1034+ if (fixed_group >= group[fixed_grouping_method ].number ) {
10101035 PRINT_INPUT_ERROR (" Fixed group ID should < number of groups." );
10111036 }
10121037
1013- printf (" Group %d in grouping method 0 will be fixed.\n " , fixed_group);
1038+ printf (
1039+ " Group %d in grouping method %d will be fixed.\n " , fixed_group, fixed_grouping_method);
10141040}
10151041
10161042void Integrate::parse_move (const char ** param, int num_param, std::vector<Group>& group)
10171043{
1018- if (num_param != 5 ) {
1019- PRINT_INPUT_ERROR (" Keyword 'move' should have 4 parameters." );
1020- }
1021-
1022- if (!is_valid_int (param[1 ], &move_group)) {
1023- PRINT_INPUT_ERROR (" Moving group ID should be an integer." );
1044+ if (num_param != 5 && num_param != 6 ) {
1045+ PRINT_INPUT_ERROR (" Keyword 'move' should have 4 or 5 parameters." );
10241046 }
10251047
10261048 if (group.size () < 1 ) {
10271049 PRINT_INPUT_ERROR (" Cannot use 'move' without grouping method." );
10281050 }
10291051
1052+ int vid; // index where vx starts
1053+ if (num_param == 6 ) {
1054+ // move grouping_method group_id vx vy vz
1055+ if (!is_valid_int (param[1 ], &move_grouping_method)) {
1056+ PRINT_INPUT_ERROR (" Grouping method for 'move' should be an integer." );
1057+ }
1058+ if (move_grouping_method < 0 ) {
1059+ PRINT_INPUT_ERROR (" Grouping method for 'move' should >= 0." );
1060+ }
1061+ if (move_grouping_method >= group.size ()) {
1062+ PRINT_INPUT_ERROR (" Grouping method for 'move' should < number of grouping methods." );
1063+ }
1064+ if (!is_valid_int (param[2 ], &move_group)) {
1065+ PRINT_INPUT_ERROR (" Moving group ID should be an integer." );
1066+ }
1067+ vid = 3 ;
1068+ } else {
1069+ // move group_id vx vy vz (default grouping_method = 0)
1070+ move_grouping_method = 0 ;
1071+ if (!is_valid_int (param[1 ], &move_group)) {
1072+ PRINT_INPUT_ERROR (" Moving group ID should be an integer." );
1073+ }
1074+ vid = 2 ;
1075+ }
1076+
10301077 if (move_group < 0 ) {
10311078 PRINT_INPUT_ERROR (" Moving group ID should >= 0." );
10321079 }
10331080
1034- if (move_group >= group[0 ].number ) {
1081+ if (move_group >= group[move_grouping_method ].number ) {
10351082 PRINT_INPUT_ERROR (" Moving group ID should < number of groups." );
10361083 }
10371084
1038- if (!is_valid_real (param[2 ], &move_velocity[0 ])) {
1085+ if (!is_valid_real (param[vid ], &move_velocity[0 ])) {
10391086 PRINT_INPUT_ERROR (" Moving velocity in x direction should be a number." );
10401087 }
1041- if (!is_valid_real (param[3 ], &move_velocity[1 ])) {
1088+ if (!is_valid_real (param[vid + 1 ], &move_velocity[1 ])) {
10421089 PRINT_INPUT_ERROR (" Moving velocity in y direction should be a number." );
10431090 }
1044- if (!is_valid_real (param[4 ], &move_velocity[2 ])) {
1091+ if (!is_valid_real (param[vid + 2 ], &move_velocity[2 ])) {
10451092 PRINT_INPUT_ERROR (" Moving velocity in z direction should be a number." );
10461093 }
10471094
10481095 printf (
1049- " Group %d in grouping method 0 will move with velocity vector (%g, %g, %g) A/fs.\n " ,
1096+ " Group %d in grouping method %d will move with velocity vector (%g, %g, %g) A/fs.\n " ,
10501097 move_group,
1098+ move_grouping_method,
10511099 move_velocity[0 ],
10521100 move_velocity[1 ],
10531101 move_velocity[2 ]);
0 commit comments