Using an immediately-evaluated compute in a subsequent fix

Hello,

I am having some trouble figuring out how to use a value that LAMMPS can compute with a compute in a subsequent fix. e.g. if I have my system setup and have run it for a while, and I want to set the global pressure to the pressure of a subsystem, I want to do something like

…old steps that include run commands
compute subpress firstgroup pressure thermo_temp
fix 10 all NPT temp 298 298 100 x c_subpress[1] c_subpress[1] 1000 y c_subpress[2] c_subpress[2] 1000
uncompute subpress
run 1000

But when I run this, I get this error during the fix
ERROR: Expected floating point parameter in input script or data file

I tried to fix this by assigning the compute value to a variable and then immediately evaluating it in the fix, by

…old steps that include run commands

compute subpress firstgroup pressure thermo_temp
variable x equal c_subpress[1]
variable 2 equal c_subpress[2]

fix 10 all NPT temp 298 298 100 x $x $x 1000 y $y $y 1000
uncompute subpress
run 1000

But then I get this error during the fix
ERROR: Compute used in variable between runs is not current

Any good way to get around this?

~John

So you have to do it the 2nd way. The 1st way is not

correct syntax for fix npt (I assume you are not using NPT,

that would also be incorrect syntax).

The issue of variables being current is discussed

at the bottom of the variable page. Basically for

the compute subpress firstgroup pressure, you have to insure that it

was invoked on the last timestep of the previous run,

e.g. by making it part of the thermo output of that run.

This is b/c compute pressure needs the virial from the pair

styles to have been computed, which is only done on

timesteps when it is needed. So waiting until the

fix npt command is too late. LAMMPS can’t invoke

the pair styles and compute a virial at that point.

Steve

Hello,

I am having some trouble figuring out how to use a value that LAMMPS can
compute with a compute in a subsequent fix. e.g. if I have my system setup
and have run it for a while, and I want to set the global pressure to the
pressure of a subsystem, I want to do something like

...old steps that include run commands
compute subpress firstgroup pressure thermo_temp
fix 10 all NPT temp 298 298 100 x c_subpress[1] c_subpress[1] 1000 y
c_subpress[2] c_subpress[2] 1000
uncompute subpress
run 1000

But when I run this, I get this error during the fix
ERROR: Expected floating point parameter in input script or data file

this *cannot* work since fix npt requires numbers and does not accept
computes or on-the-fly computed data.

I tried to fix this by assigning the compute value to a variable and then
immediately evaluating it in the fix, by

...old steps that include run commands
compute subpress firstgroup pressure thermo_temp
variable x equal c_subpress[1]
variable 2 equal c_subpress[2]
fix 10 all NPT temp 298 298 100 x $x $x 1000 y $y $y 1000
uncompute subpress
run 1000

But then I get this error during the fix
ERROR: Compute used in variable between runs is not current

Any good way to get around this?

it doesn't make much sense to use a single instantaneous pressure
value; you want to have an averaged value over a suitably long period.
this you can get with fix ave/time. please note, that also the
barostat will not do an instantaneous "correction" but rather will try
to smoothly modify the forces, so that the target pressure is achieved
*on average* when sampling over a suitably long period of time
(controlled by the relaxation time parameter).

axel.