These functions only take one input as arguments. If I need to get one point of the variable, given two other points (e.g., given X,Y what is the Z), is there a built-in function for that?

compute_equal gives me 0, which I would assume means itâ€™s not equal, but have no idea what that means.

Variables take no arguments. If you want to compute an expression that is dependent on X and Y you have to define X and Y as variables, too and set their value. Example:

variable x equal 2.0
variable y equal 3.0
variable z equal v_x*v_z
print "z = ${z}"

A more elegant approach from within C++ code would be to use â€śinternalâ€ť style variables. But to use those properly, you need to spend some time reading LAMMPS source code and the comments in it.

No. Variable::compute_equal() will evaluate an equal (or compatible) style variable (hence the â€śequalâ€ť) and return its value as a double precision floating point number. Its purpose can be easily deduced from reading the comments in the source code of its implementation.

Thank you for such quick insights, @akohlmey , and sorry for these beginner questions, still getting the hang on LAMMPS.

Iâ€™ve been trying to apply the LAMMPS methods, but the comments in the code arenâ€™t as easy to understand as the documentation of LAMMPS. Will have to read it thoroughly, then.

Just to give closure to this topic, I found a solution that is likely far from ideal. However, the compute_equal method only seems to work with all independent variables defined, I found no other method to call it while supplying the values of X and Y. The solution I found was:

Obtain the expression as a string from the data[ivar][0] object. For this, I had to alter the Variable class, since it only gives the data[ivar][1] object, i.e., the result of calculation.

Change the v_xx and v_yy independent variables by the corresponding values, and crop the z < part. I want to keep spheres away from the space defined by the equation, and the center of the sphere is the X and Y.

I have to say it is my first time working with C++, so this solution is likely far away from an optimal solution. But it works. Btw, nice piece of code that evaluate method, really fun to see an implementation of string to mathematics.

I already told you, that that is not possible. The LAMMPS input script language is not designed to be a full programming language, but to provide sufficient flexibility to â€śconnectâ€ť the different modules and commands. So instead of stubbornly looking for something that does not exist or create a workaround that emulates that, you should try to â€śthink within the logic of what is availableâ€ť. This takes some getting used to, but if you are working with an existing code base, it is necessary for being effective and writing code that is maintainable and suitable for later inclusion into the code base.

The method to use in your workflow is to define v_xx and v_yy as â€śinternalâ€ť style variables and then you can easily set their values with calls to Variable::internal_set(). I had already mentioned internal variables, IIRC. No source code hacks needed for this.