Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12201

Usage of if statement within loop variable in LAMMPS

$
0
0

THIS IS RELATED TO LAMMPS. PLEASE HELP IF YOU CAN.

label loop_start

variable i loop 100

variable sum_vx equal 0

variable sum_vy equal 0

variable count equal 0

label inner_loop_start

variable j loop 100

variable dx equal "x[i]-x[j]"

variable dy equal "y[i]-y[j]"

variable dx2 equal dx*dx

variable dy2 equal dy*dy

variable distt equal sqrt("dx2+dy2")

print "Done"if "${distt} < 2.0" then &

print "Ho ho ho" &

else &

print "no no no"

This is one part of the LAMMPS code that I am writing. Earlier, I have calculated the positions x for all atoms by property/atom command. So this code finds out the distances between all the atoms. If the distance is less than 2.0 it should print Ho ho ho and else no no no.

The out put of this code is-

Done

ERROR: Variable distt: Invalid syntax in variable formula(src/variable.cpp:2495)

Last command: ${distt

As Done is printed, this means the distances are correctly calculated for the all values of i and j. The problem lies in the if statement. But, I cant find the mistake. I have tried using ${} more often and also tried using v_ for designating the variables later after defining once. But nothing works. Please help me to resolve this issue if you can

I expect to print Ho ho ho each time the statement under if command is true and no no no otherwise.


Viewing all articles
Browse latest Browse all 12201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>