Modify pressure in fix NPT using per group pressure

Dear all,

We were trying to fix_modify pressure of NPT based on a per group of atom of pressure.

The per group of atom is easy to calculate we obtained it using the command below:

compute s1 A_2 stress/atom NULL
compute ps A_2 reduce sum c_s1[1] c_s1[2] c_s1[3]

variable sxx equal -(c_ps[1])/(v_vsolid)
variable syy equal -(c_ps[2])/(v_vsolid)
variable szz equal -(c_ps[3])/(v_vsolid)

fix 5 all npt temp {t_int} {t_fin} {t_damp} z 0.0 0.0 {p_damp} dilate A_4
fix_modify 5 press v_ssz

Error: Could not find compute pressure ID

We want to use these computed pressure for the group A_2 to be used for the fix_modify the system pressure.

But it seems there is no way around as we would ultimately need a “compute pressure/group” command to use in the fix_modify.

Is the last hope to make a new compute pressure/group style compute_pressure_group.cpp & a compute_pressure_group.h file? Or is there a way around so that fix NPT could be fix_modified so that the pressure of the entire system is controlled using the group pressure as reference?

Pleas help!

there are two problems here. a syntactical one and a conceptual one.

a) v_ssz is a reference to a “variable” not to an instance of a “compute”. fix npt will not just use the “value”, but needs to “control” the compute instance can call its compute_scalar() or compute_vector() method.

b) fix npt will vary the dimension of the entire cell so only a “global” pressure compute is applicable. there are multiple options for compute pressure, but those are your only choices. “local” pressure is not a well defined entity to begin with.

axel.

Thank you, Dr Axel, for your kind reply. We hope to clarify the discrepancy through the following:

(We also agree that local pressure is not well defined. And we also agree that variable should not be fed to fix_modify and requires a compute)

Our concerns:

  1. We wanted to impose NPT for the fluid region alone. And particularly for that region,
    we want to change the pressure using the reference to group’s pressure. So, is there a way around so that fix NPT could be fix_modify so that the pressure of the fluid is controlled?

  2. How can we use exiting computes to be used as inputs in the fix_npt to control the fluid region pressure?

  3. Since feeding to fix_modify requires a compute and there is no compute pressure/group in LAMMPS, would the last option be writing our own computes for calculating compute instances so that it can be given as inputs to fix_npt using fix_modify?

Thank you for your patience.

Thank you, Dr Axel, for your kind reply. We hope to clarify the discrepancy through the following:

(We also agree that local pressure is not well defined. And we also agree that variable should not be fed to fix_modify and requires a compute)

Our concerns:

  1. We wanted to impose NPT for the fluid region alone. And particularly for that region,
    we want to change the pressure using the reference to group’s pressure. So, is there a way around so that fix NPT could be fix_modify so that the pressure of the fluid is controlled?

fix modify requires a pressure compute since it will look up the compute and ask it to either compute a global scalar (for isotropic pressure) or a global vector (for aniosotropic pressure).

  1. How can we use exiting computes to be used as inputs in the fix_npt to control the fluid region pressure?

there is no such compute.

  1. Since feeding to fix_modify requires a compute and there is no compute pressure/group in LAMMPS, would the last option be writing our own computes for calculating compute instances so that it can be given as inputs to fix_npt using fix_modify?

it would be that, but let me re-iterate i have serious doubts about the physical meaning of such a construct.
if you are willing to go this far, you could also look into using fix controller in combination with fix wall to have a subset of atoms confined according to the force on those walls, i.e. the pressure. that would avoid having to write new code in LAMMPS, but writing a custom pressure compute is likely more straightforward to set up.

axel.