The way commands described in a LAMMPS input file is somehow different from C language and other programming languages. I was wondering if it’s possible to create nested commands (such as nested if command or nested loops as regularly done in the C language) in an input file. I gave it a try and included the following:
if "$(abs(v_T2-v_T1)) >1" then &
"if "${grossBrokenBonds}>=1.000000" then &
"variable T2 equal ${stemp}" &
"variable stemp equal (v_T1+v_T2)/2" &
elif "${grossBrokenBonds}<1.000000 && ${T1}>${T2}" &
"variable T1 equal ${stemp}" &
"variable stemp equal ${T1}+400 " &
elif "${grossBrokenBonds}<1.000000 && ${T1}<${T2} && $i>1" &
"variable T1 equal ${stemp}" &
"variable stemp equal (v_T1+v_T2)/2""
else "quit"
However it didn’t work out and it ended to an error. But, when I rewrote it in its regular way as follows:
if "${grossBrokenBonds}>=1.000000 && $(abs(v_T2-v_T1)) >1" then &
"variable T2 equal ${stemp}" &
"variable stemp equal (v_T1+v_T2)/2" &
elif "${grossBrokenBonds}<1.000000 && ${T1}>${T2}" &
"print 'the system is still stable because the broken bonds =${grossBrokenBonds}'" &
"variable T1 equal ${stemp}" &
"variable stemp equal ${T1}+400 " &
elif "${grossBrokenBonds}<1.000000 && ${T1}<${T2} && $(abs(v_T2-v_T1)) >1 && $i>1" &
"variable T1 equal ${stemp}" &
"variable stemp equal (v_T1+v_T2)/2" &
elif "$(abs(v_T2-v_T1)) <1" &
quit
it worked with no issues. Is this an indication that nested commands in LAMMPS are not possible? or is their any misstake in my script ?
This is the error message I received:
ERROR: Input line quote not followed by white-space (src/input.cpp:506)
Last command: if "$(abs(v_T2-v_T1)) >1" then "if "${grossBrokenBonds}>=1.000000" then "variable T2 equal ${stemp}" "variable stemp equal (v_T1+v_T2)/2" elif "${grossBrokenBonds}<1.000000 && ${T1}>${T2}" "variable T1 equal ${stemp}" "variable stemp equal ${T1}+400 " elif "${grossBrokenBonds}<1.000000 && ${T1}<${T2} && $i>1" "variable T1 equal ${stemp}" "variable stemp equal (v_T1+v_T2)/2"" else "quit"