COLVARS package: converting a length 1 vector colvar to scalar

Dear LAMMPS users,

I am trying to run metadynamics to calculate the PMF that a single particle experiences in space along the z direction. I attempted to do this using the following code, however run into problems with setting lowerBoundary and upperBoundary because the z position of my particle is being returned as a vector of length 1, instead of a scalar. Is there anything I can do to convert the output of the colvar into a scalar?

I am using the 12 Dec 2018 version of LAMMPS.

colvarsRestartFrequency 100

colvar {
name pos
outputValue on
lowerBoundary -70.
upperBoundary 70.
cartesian {
useX off
useY off
atoms { atomNumbers 3155 }
}
}

metadynamics {
colvars pos
hillWeight 0.01
hillWidth 2.0
}

Thank you,

Tiantian

Hello Tiantian, it would be much simpler to use a distanceZ function with a dummy atom as reference group (e.g. the origin).
http://colvars.github.io/colvars-refman-lammps/colvars-refman-lammps.html#sec:cvc_distanceZ

For the general case of a more complex variable that you want to reduce to a scalar, customFunction should do the trick:
http://colvars.github.io/colvars-refman-lammps/colvars-refman-lammps.html#sec:colvar_custom_function