Hello everyone! I find an interesting problem when I use the command “compute reduce”.
I just want to compute the mass center’s x coordinate of a group. So I use the code below:
compute FxArea FxArea reduce ave x
variable FxAreaDis equal c_FxArea[1]
fix FxAreaCenter FxArea print 8 "${istep} ${FxAreaDis}" screen no file FxAreaCenterDis.data title "Step FxAreaCenterDis"
I got the error message:
ERROR: Variable FxAreaDis: Mismatched compute in variable formula (src/variable.cpp:1596)
But when I add an input “vx” in the code, the program runs well.
compute FxArea FxArea reduce ave x vx
variable FxAreaDis equal c_FxArea[1]
fix FxAreaCenter FxArea print 8 "${istep} ${FxAreaDis}" screen no file FxAreaCenterDis.data title "Step FxAreaCenterDis"
I read the manual about “compute reduce” and I think maybe the question is on this sentence:
If a single input is specified this compute produces a global scalar value. If multiple inputs are specified, this compute produces a global vector of values, the length of which is equal to the number of inputs specified.
However, when I use “dump” command to output “FxAreaDis”, it also reports error. So I got confused.
Could anyone explain the above sentence? Any help will be appreciated! Thanks for reading!