Precisely Selecting Atoms Using Mathematical Expressions in SAMSON

When modeling molecular systems at the atomic level, selecting specific atoms based on quantitative criteria is often necessary—but rarely straightforward. Whether you need to isolate water molecules, highlight carbon atoms, or extract a structure within a geometric region, doing it manually can be time-consuming and prone to error. Fortunately, SAMSON offers a solution: the Atoms Selector Extension.

This extension allows you to use precise mathematical expressions to select atoms in your active document. If you’re working with molecular crystals, nanoparticle shapes, or want to emphasize certain molecular regions, this tool can save you considerable effort and make your modeling workflow more reproducible.

Why Mathematical Selection Matters

Let’s say you’re analyzing a quartz crystal and want to extract a cylindrical portion for simulation. Manually clicking through thousands of atoms is inefficient and often inaccurate. Instead, you can apply a single-line expression to select just the atoms you need. For example, this expression selects atoms within a cylinder of radius 10 Å centered at (15, 15):

This method is not only fast—it also minimizes errors and makes it easy to reproduce your selection criteria in future projects.

How It Works

Under the hood, the Atoms Selector Extension uses the same variables and logical/mathematical constructs as the Simple Script Extension. This includes variables such as:

  • a.x, a.y, a.z: atom positions
  • a.element, a.symbol: element names and symbols
  • a.chainID, a.residueSequenceNumber: structural hierarchy data

And a wide range of operators and functions such as abs, sin, sqrt, and, or, and more.

Examples You Might Find Useful

Here are a few selection examples that demonstrate the flexibility of this approach:

Selecting All Water Molecules

Selecting Carbon and Hydrogen Atoms

Selecting Atoms in the Positive X-Y Quadrant

Creating a Graphene Tile

Crafting hexagonal or rectangular nano-tiles from a graphene sheet is easily achieved by combining spatial constraints:

You can then use this tile as a repeating unit or apply transformations for more complex shapes using script-based manipulations.

Visual Example: Quartz Crystal Selection

The image below shows the result of selecting a cylindrical shape from a quartz crystal using the expression shown earlier:

Cut cylinder out of quartz crystal

When to Use the Atoms Selector vs. Simple Script

The Atoms Selector is ideal for selection tasks, especially when you’re not modifying properties like coordinates or element types. For more advanced tasks—such as rotating atoms, generating geometric deformations, or scripting procedural filters—consider the Simple Script Extension.

To explore more use cases and see scripted examples, visit the full SAMSON documentation.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.

Comments are closed.