Question on defining a bond coefficient as a variable, and printing out the data files related to each bond coefficient

Dear All,

I am reaching out for assistance with a code I’ve written for CNT elongation, where force is applied to two ends of the CNT in opposite directions to measure the change in length and calculate Young’s Modulus. My objective now is to tune the bond coefficients, and to achieve this, I’ve defined one of the bond coefficients as a variable within a loop.

Here’s the loop structure I’ve implemented in the parameter file for the bond coefficients:

variable a
loop 15
bond_coeff 1 100*${a} 0.77
bond_coeff 2 180 1.9607888988921507
run 30
next a
jump SELF loop

However, upon running the script, I encountered the following error:

ERROR: Illegal variable command: missing argument(s) (src/variable.cpp:175)
Last command: variable bc1

My first question is: what am I doing wrong and how can I rectify this error?

Additionally, I need guidance on how to modify the previous fix command (written below) used for writing the length data file so that it outputs all length data files related to each bc1 coefficient.

  variable L equal xcm(CNT_top,z)-xcm(CNT_bot,z)

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

Your assistance with these matters would be greatly appreciated.

Thank you sincerely for your help.

Please study the documentation of the variable command. Your command is definitely not consistent with the documentation.

1 Like

Thank you ,
from documentation I rewrote the loop:

label loop
variable a loop 15
bond_coeff 1 100*${a} 0.77
bond_coeff 2 180 1.9607888988921507
run 30
next a
jump cntelongation.edpd loop
label break
variable a delete

I am getting the error:
Expected floating point parameter instead of ‘100*1’ in input script or data file (src/MOLECULE/bond_harmonic.cpp:131)

Can you help me how to tell LAMMPS to read 100 instead of ‘1001’ , and 200 instead of '1002’
Could also answer my last question about outputting the related len.data files related to each coefficient.

Thanks a lot

Have you read this page?

1 Like

I cannot because I did not understand what you were asking.
As with almost anything that you have been asking so far, the answer is in the documentation.
I don’t like to be (ab-)used as a search engine or as a replacement for doing your homework and getting familiar with the general basics of running LAMMPS inputs and the documentation of all commands that you are using. That is something that people should do automatically, especially when LAMMPS stops with errors.

Introducing an intermediate variable fixed the following error:

Expected floating point parameter instead of ‘100*1’ in input script or data file (src/MOLECULE/bond_harmonic.cpp:131)

label       loop
 variable    a loop 15
 variable    b equal 100*${a}
 bond_coeff 1 ${b} 0.77
 bond_coeff 2 180 1.9607888988921507
 run 30
 next        a
 jump        SELF loop

Thanks.