Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a geometry selection supporting selecting an zone shaped like a box #4323

Open
Cloudac7 opened this issue Oct 25, 2023 · 6 comments · May be fixed by #4324
Open

Add a geometry selection supporting selecting an zone shaped like a box #4323

Cloudac7 opened this issue Oct 25, 2023 · 6 comments · May be fixed by #4324

Comments

@Cloudac7
Copy link

Cloudac7 commented Oct 25, 2023

Is your feature request related to a problem?

I am now working on an system only z axis periodic, and I need to pick the atoms contained within certain distance in only z axis from a selected group. I tried to use cyzone to implement, but it could not include all atoms because of the shape of selection is a circle in xy plane and could not include all atoms in xy. And the prop selection could not read a dynamic updating selction.

Describe the solution you'd like

I would like to add a new geometry selection (named as box, for example), that could satisfy the requirement.
It would create a zone from center of geometry of given selection to x, y, or z direction in a box.
image

Describe alternatives you've considered

#4324

@orbeckst
Copy link
Member

@Cloudac7 could you provide a few usage examples here? PR #4324 outlines the general syntax. I'd be interested to see how one might use it in practice, e.g., corresponding to the different cases in your nice illustrations.

E.g.

To select all atoms in a box with length LX, LY, LZ, centered on center of mass of residue 42:

u.select_atoms("box LX LY LZ (resid 42)"

(That's probably not the correct syntax but you get the idea: description of what you are accomplishing and how a user would use your code.)

@Cloudac7
Copy link
Author

Cloudac7 commented Oct 27, 2023

@Cloudac7 could you provide a few usage examples here? PR #4324 outlines the general syntax. I'd be interested to see how one might use it in practice, e.g., corresponding to the different cases in your nice illustrations.

E.g.

To select all atoms in a box with length LX, LY, LZ, centered on center of mass of residue 42:

u.select_atoms("box LX LY LZ (resid 42)"

(That's probably not the correct syntax but you get the idea: description of what you are accomplishing and how a user would use your code.)

OK. Let me give it a try.

To select all atoms within a defined 3D box region relative to the center of geometry (COG) of a specified residue:

Use the select_atoms() method on a Universe object (u) with the following syntax:

u.select_atoms("box <axes> <max> <min> <selection>")

Where:

  • <axes> specifies which axes to apply the selection on: x, y, z, or any combination like xy, yz, etc.
  • <max> and <min> define the maximum and minimum bounds respectively along each specified axis. Positive values are above/right/front of the COG, negatives are below/left/behind. Should present at the same number of time as the number of axes set.
  • <selection> specifies the selection the box selection relative to.

For example:

To select all atoms between Zmax above and Zmin below the COG of residue 42 along z:

u.select_atoms("box z Zmax Zmin (resid 42)")

To select an 2D box around residue 114 from Xmin to Xmax on x and Ymin to Ymax on y:

u.select_atoms("box xy Xmax Xmin Ymax Ymin (resid 114)")

To select a 3D box around residue 514:

u.select_atoms("box xyz Xmax Xmin Ymax Ymin Zmax Zmin (resid 514)")

@orbeckst
Copy link
Member

orbeckst commented Nov 6, 2023

The selection syntax looks reasonable and fits the pattern established with cyzone:

cyzone externalRadius zMax zMin selection

selects all atoms within a cylindric zone centered in the center of geometry (COG) of a given selection, e.g. cyzone 15 4 -8 protein and resid 42 selects the center of geometry of protein and resid 42, and creates a cylinder of external radius 15 centered on the COG. In z, the cylinder extends from 4 above the COG to 8 below. Positive values for zMin, or negative ones for zMax, are allowed.

I just want to confirm that in your case, Xmax and Xmin are also relative to the center, right?

@Cloudac7
Copy link
Author

Cloudac7 commented Nov 7, 2023

The selection syntax looks reasonable and fits the pattern established with cyzone:

cyzone externalRadius zMax zMin selection
selects all atoms within a cylindric zone centered in the center of geometry (COG) of a given selection, e.g. cyzone 15 4 -8 protein and resid 42 selects the center of geometry of protein and resid 42, and creates a cylinder of external radius 15 centered on the COG. In z, the cylinder extends from 4 above the COG to 8 below. Positive values for zMin, or negative ones for zMax, are allowed.

I just want to confirm that in your case, Xmax and Xmin are also relative to the center, right?

Yes, exactly.

@orbeckst
Copy link
Member

This set of selections would have come in handy for something I had to do: cut out a system from a bigger system https://fhi-aims-club.gitlab.io/tutorials/fhi-aims-mdanalysis/2-periodic-sub-system/

@unchimico
Copy link

I have encountered the same problem discussed in the original post.
I work on MD simulations of electrochemical materials, and I needed to update the boundaries and atoms of an electrolyte region delimited between two electrodes. While it is possible to create the region on a single frame using the "prop" keyword of select_atoms(), the boundaries for this keyword must be hard-coded - i.e. the must be a string, and cannot be passed as variables nor linked to atomic properties.
Eventually, I could bypass this problem by passing the appropriate coordinates to a a string, and creating a new region at each timestep within the main trajectory loop, but that obviously slowed down the calculation and the code writing process, so I would support the creation of a "box" geometry selection which can be dynamically updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants