A Faster Way to Select Atoms with Mathematical Logic

When working with complex molecular systems, one common challenge molecular modelers face is selecting specific atoms according to criteria that go beyond basic clicking or visual inspection. Whether it’s isolating atoms with a certain charge, picking out surface atoms, or highlighting elements within a geometric region, doing this manually can be tedious and error-prone.

Fortunately, the Atoms Selector Extension in SAMSON offers a streamlined, programmable approach to atom selection using mathematical expressions. If you’ve ever wished for a way to filter atoms with the logic of a script but without having to write full code, this tool hits the sweet spot.

Why Use Mathematical Expressions for Selection?

Let’s say you want to select all atoms within a sphere of radius 10 Å centered at a known point. Rather than visually estimating which atoms fall within that range, you can write a concise expression like:

This drastically reduces manual labor and improves accuracy. It’s especially useful for large or symmetric structures like crystals or nanosheets where selecting by hand is impractical.

How It Works

The Atoms Selector Extension lets you input logical expressions that combine atom properties using mathematical and logical constructs. Variables like a.x, a.y, a.z, a.elementID, and a.symbol can be used directly. Comparisons (==, <, >, etc.), boolean operators (and, or), and mathematical functions (abs, sin, exp, etc.) are all supported—as well as more complex control structures if needed.

Here’s how it looks in action:

Cut cylinder out of quartz crystal

In this example, a cylinder-shaped selection is created simply by defining a condition that marks all atoms within a radius of 10 Å from a central axis. The selected atoms can then be visualized, manipulated, or exported just like any other selected region.

When to Use It

  • Surface selection: Highlight atoms on the surface of a nanostructure using coordinate thresholds.
  • Charge filtering: Select ions by formal or partial charge using expressions like a.formalCharge == -1.
  • Elemental separation: Isolate Hydrogen and Carbon atoms using element names or symbols.
  • Geometric rules: Select atoms inside spheres, cylinders or slices using simple equations.

Tips for Better Selection

  • Use parentheses to clarify complex logical expressions.
  • Preview your selection visually in stages for better control.
  • Remember that expressions are case-insensitive.
  • If you want to select everything, use the special keyword all.

If you’re already familiar with the Simple Script Extension in SAMSON, you’ll feel right at home—Atoms Selector uses the same variables and logic, but focuses only on selection, without modifying properties.

Learn more in the full documentation, including other tools like the Simple Script Extension for atom modification.

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

Comments are closed.