From: Axel Kohlmeyer (
Date: Fri Jun 27 2008 - 12:51:26 CDT

On Fri, 27 Jun 2008, dimka wrote:

DK> Hi VMD list, can you please tell me how to select a cylindrical volume?
DK> i've tried something like this but it doesn't work
DK> "within 10 of (x==0 and y==0)"
DK> supposedly this command should select a cylindrical slab in the Z

who said that it should?

DK> direction... but it doesn't.

of course it does not work. don't think that a computer program
does something reasonable, but you'll have to follow the logic.

(x==0 and y==0) would select only particles that have the x-coordinate
and y-coordinate to be exactly 0. that is highly unlikely
and within would select sphere around it anyways. what you need is
something like

sqrt(x*x + y*x) < 10.0

or if you want the cylinder around x=2 and y=-3:

sqrt((x-2)*(x-2) + (y+3)*(y+3)) < 10.0

think about it for a bit and it will become evident. ;-)



Axel Kohlmeyer
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
If you make something idiot-proof, the universe creates a better idiot.