[Moved from CFDEMcoupling used forum] How to create vector variables?

Submitted by JoshuaP on Thu, 07/31/2014 - 13:55

How can define a vector variable in Liggghts?

regards

JoshuaP | Thu, 07/31/2014 - 14:56

Is there maybe a chance to give a variable a name in dependence of an other variable?
Mayb sth. like :
variable k equal 1
variable phi${k} equal 1+3

JoshuaP | Fri, 08/01/2014 - 10:55

I found a solution, but maybe its not the best way.

variable k loop ${iter}
label loop1
variable phi equal ..........

variable this string phi${k}
variable ${this} equal ${phi}

next k
jump in.file loop1

AJ.Spin | Tue, 09/12/2017 - 17:16

So I came up with the same loop idea and then questioned if it was the best way. By the way this is not a vector, this is a series of n number of variables with just incremented names. The only way I have read so far to create your own vector is through a fix vector command in the lammps documentation. However, it seems that you can only manually insert all the size and values of the vector.

The issue that I have is I am trying to automate my code better and cannot figure out the next step of using all those variables in a fix. Once I create the list of variables, I want to print all the names automatically. In my example, I typed up to atoms 3 in but I want to reach the point that I can make my loop size a variable and have the code be robust enough to print out the number of variables I am interested in.

It is like this idea of automatic variable generation works but there is no effective way of applying it in a case of a fix. Am I trying push liggghts into doing something it is no intended for? I am starting to think I am going for too complicated and trying to treat liggghts as full computer language instead of a list of commands that are meant to run a simulation program. If I cannot get this too work I can always just set a limit to the number of variables and just choose to not populate them all. The only downside would be that I would be writing to extra rows that uses extra space and time.

### loop that generates 7 groups and counts all the groups
label batcharray
variable test loop 7
variable batch string batch${test}
variable atoms string atoms${test}
variable ${atoms} equal count(${batch})
next test
jump in.Agitator batcharray
####
variable l equal round(v_DumpCSV/v_dt)
fix Mess all print $l "${Time}, ${total}, ${atoms1}, ${atoms2}, ${atoms3}" &
file post_csv/MassFlow_$a.csv screen no title "t[s],total"