Question about FixNH‎

Hi.

I have some question about how the commands are parsed in the FixNH function. I don’t understand the meaning of `deviatoric flag` and the behaviour seem inconsistent with the documentation.
The keyword `iso` or similar ones does not modify it :

else if (strcmp(arg[iarg], "iso") == 0) {
      if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, fmt::format("fix {} iso", style), error);
      pcouple = XYZ;
      p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
      p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
      p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
      p_flag[0] = p_flag[1] = p_flag[2] = 1;
      if (dimension == 2) {
        p_start[2] = p_stop[2] = p_period[2] = 0.0;
        p_flag[2] = 0;
      }
      iarg += 4;

But by giving each keyword `x`, `y`, `z` individually, that variable is modified :

else if (strcmp(arg[iarg], "x") == 0) {
      if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, fmt::format("fix {} x", style), error);
      p_start[0] = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
      p_stop[0] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
      p_period[0] = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
      p_flag[0] = 1;
      deviatoric_flag = 1;
      iarg += 4;

Is there something else I don’t understand?

Best.

I don’t know, but perhaps @athomps or @sjplimp can provide some explanation.

deviatoric_flag is an implementation detail. The documentation does not describe implementation details, therefore it is not possible for deviatoric_flag to be inconsistent with the documentation. If you look at how deviatoric_flag is used, you will see that it triggers a call to compute_strain_energy(). This is only needed when the barostat target stress is non-hydrostatic i.e. the deviatoric stress is non-zero. For more information, read the paper cited in the documentation in reference to strain energy: (Parrinello) Parrinello and Rahman, J Appl Phys, 52, 7182 (1981).

3 Likes