Changing fix with if statements in run/every

Hi all,

In my code, I am looking to compare system pe (potential energy) to a certain value every N timesteps. When pe approaches a certain value, I want to change the fix from an nvt to an npt ensemble. To do this, I use an if statement inside of run/every in order to change the fix. Below is the command that is currently included in my code:

fix 1 all nvt temp 50 50 0.1
thermo 100

dump 1 all atom 1000 dump.lj01
run 100000

run 100000 every 50 “variable p equal pe” &
“if ‘($p >=-19.3450) && ($p <=-19.3448)’ then ‘unfix 1’&‘fix 1 all npt temp 50 50 0.04283 iso 0.0 0.0 0.2’”

However, when I run my code, I get the following error: “Illegal unfix command”. I am not sure what the problem is here.

Any help would be much appreciated!

Zimu

If I add these lines to the bottom of bench/in.lj, it works as you want:

run 100 every 50 &
  "variable p equal pe" &
  "if '($p >= -5.8) && ($p <= -5.7)' then &
  'unfix 1' &
  'fix 1 all npt temp 2.0 2.0 0.1 iso 10.0 10.0 0.2' &
  'print MADE-CHANGE'"

Steve