Creating arrays in LAMMPS

Hello,

I was to do a simulation there I vary the control temperature in NPT according to the list T = [300,200,300,400].

Specifically, I want to have a loop that runs for a certain number of timesteps, changes the temperature, and continues the loop forward. Something like,

> label loopa
> variable a loop 15
> #
>   print "$a"
>   fix     fx2 all  npt temp ${T[$a]} ${T[$a]} 0.5 aniso ${P} ${P} 5.0
>   run           500
>   unfix   fx2
>   write_data    data.out.*
>   write_restart data.restart.*
> #
> next a
> jump SELF loopa

I am having some trouble defining the variable T in LAMMPS. Any suggestions?

Regards,

Please keep in mind that the LAMMPS input syntax is not a complete programming language and not meant to be one.
There are no indexed arrays in LAMMPS. However, the functionality you desire (looping over a sequence of numbers) can be easily implemented with an index style variable that holds the list of numbers and is used instead of the loop variable.

1 Like

Thank you! This works perfectly!

Regards,