Computation of dipole moment through variable command

I want to compute dipole moment as sigma(qi*ri) by using variable of atom style however I am getting an error of “Substitution for illegal variable Mnew”.

Here are my lines from the code:
variable charge atom “q”
variable x1 atom “xu”
variable y1 atom “yu”
variable z1 atom “zu”
variable r1 atom “v_x1+v_y1+v_z1”
variable Mnew atom “sum(v_charge*v_r1)”
fix 2 all print 100 “${Mnew}” file DMC.txt screen yes

Please advise.

Your commands have incorrect syntax and semantics in multiple places. You cannot “print” an atom style variable and the sum function does not work the way you are using it. This is all documented.

What is wrong with the compute dipole command?

I am currently running lammps version 3Mar2020 as the server’s compiler is not updated to C++11.

You can always install a compiler by yourself into your account by compiling from source.

If the operating system of that server is so old that it does not have a C++11 compatible compiler (that would be either RedHat or CentOS 6.x or Ubuntu 16.04LTS or something of similar age) than that server is running an operating system that does not receive any security updates because the vendor support has run out. That kind of machine should not be connected to the internet and is a significant security risk. The people responsible for operating such a server in such an irresponsible way should be given a hard time.

Also, if you don’t need to use MPI parallelization but can get by with multi-threading, you can also download the pre-compiled statically linked LAMMPS binaries for Linux 2.1. Download an executable for Linux — LAMMPS documentation

These should run correctly even on outdated Linux installation (it has been tested with Ubuntu 16.04LTS for example).

Okay. thanks Axel, I would try this out.