If statement within run every command

Submitted by tapsab on Thu, 09/29/2011 - 18:51

Hi,
I want to change the value of a variable after a certain number of timesteps. I tried to do this using the following lines in my script

run 10 pre no post no every 1 &
"variable vke equal step" &
"if ${vke} > 5 then 'variable xp0 equal 1' "

I get an error after the 6th timestep (when the if condition becomes true): ERROR: Unknown command: 'variable

So it seems the nested quotes are a problem. I have also tried changing the quotes to

"if '${vke} > 5' then 'variable xp0 equal 1' "

but in this case the if condition is just completely ignored.

Any suggestions?

ckloss's picture

ckloss | Fri, 09/30/2011 - 08:51

what are you trying to implement? I am sure there is an easier way to do what you want...
Christoph

tapsab | Fri, 09/30/2011 - 16:02

In keeping with the quasi-static assumption I want to apply the total displacement of the walls in several tiny increments. After each increment I want to monitor the kinetic energy of the particles and wait for it to go close to zero and then apply the next displacement increment.

To do this I thought I could use the "fix move/mesh/gran" command with "variable" style so that I can set the value of the variable based on when my kinetic energy reaches close to zero.

Thanks for responding by the way and I would really appreciate your suggestions on how best to go about simulating the quasi-static test.

tapsab | Fri, 09/30/2011 - 19:45

I was able to solve the problem of using nested loops by updating my input.cpp and variable.h files based on patches that were provided for lammps in 2010 where they implemented nested loops using single/double quotes. This functionality is not available in the latest version of liggghts.

However the question of how to simulate a quasi-static test still eludes me. I will start a new topic since I guess its a completely different query than the one this thread started with.

ckloss's picture

ckloss | Mon, 10/03/2011 - 07:59

as I wrote in the other thread, there have been some updates (since the currently LIGGGHTS is based on 10Mar10 version) in lammps that have not been implemented yet in liggghts - that will happen with the next major release in a couple months

>>solve the problem of using nested loops by updating my input.cpp and variable.h files
>>based on patches that were provided for lammps in 2010
great - but be careful when applying LAMMPS patches without carefl testing - if you miss out something (and that can happen easily) this can lead to unpredictable behavior

Christoph