How can I create an output file that includes both the calculated variables and the corresponding loop steps?

Dear All,

I’m currently working on a project involving the elongation of a Carbon nanotube (CNT). In this setup, carbon atoms within the nanotube are connected by harmonic potentials, and I’m adjusting the bond coefficients to control these potentials. The length of the CNT, denoted as L, changes as a result of the forces applied to both ends in opposite directions.

To systematically vary the bond coefficients and repeat the CNT elongation experiment, I’ve implemented a loop in my simulation script:

  label       loop
  variable    a loop 15
  variable    b equal 100*${a}
  bond_coeff 1 ${b} 0.77
  next        a
  jump        SELF loop

In this loop, variable “a” iterates through 15 values, and “b” calculates the bond coefficient based on each value of “a”. The bond coefficient is then updated accordingly.

To output the length of the CNT (v_L) for each iteration of the loop, I’ve been using the following command:

      fix at2 all ave/time 10 100 1000 v_L file len{a}.dat

However, analyzing the output data files becomes challenging because it’s not immediately clear which length values correspond to which bond coefficient. I’m seeking a better approach to create an output data file that includes a column for the loop step (bond coefficient) and another column for the length values. This would greatly facilitate data analysis and interpretation.

Any advice or suggestions on how to achieve this would be greatly appreciated.

Thank you for your assistance.

How about using fix print?

1 Like

Note that the value of b can also be printed alongside L:

fix at2 all ave/time 10 100 1000 v_L v_b file len{a}.dat


1 Like

Thank you Simon. I was expecting to have all the files for different a’s , by writing the file as len{a}.dat but I am only getting the values for last run , here is a few lines I wrote for the loop

label       loop
variable    a loop 15
variable    c equal ${a}
variable    b equal 100*${a}
 bond_coeff 1 ${b} 0.77
 bond_coeff 2 180 1.9607888988921507

 fix at2 all ave/time 10 100 1000 v_c v_b v_L file len{a}.dat

and here is the data I got in len{a}.dat

Time-averaged data for fix at2

TimeStep v_c v_b v_L

29000 15 1500 24.9287
30000 15 1500 25.0287

I see , I should have written len${a}.dat