Molecular modelers and researchers often grapple with the need to customize nanoscale designs. Whether it’s tailoring a specific atomic structure or generating intricate shapes, the task can be daunting without the right tools. This is where SAMSON’s Simple Script Extension can help, offering a way to modify and fine-tune atomic structures using mathematical expressions and scripting.
In this blog post, we’ll explore how to use SAMSON’s Simple Script feature to build custom nanostructures, with a special focus on the versatility it provides for creative molecular modeling. If you are familiar with scripting and mathematical expressions, you’ll discover how to leverage them for complex atom selection and transformations.
What Does Simple Script Offer?
The Simple Script Extension in SAMSON enables users to modify properties of atoms such as their positions, element types, visibility, and more with simple scripts. This scripting feature employs predefined variables, along with standard mathematical operations and logic, giving users the power to:
- Select and filter atoms by specific attributes or spatial coordinates.
- Transform atomic positions using mathematical functions (e.g., sine waves or rotational matrices).
- Modify atomic properties to customize structures efficiently.
By writing concise commands, you can transform datasets with precision or automate processes that are time-consuming to perform manually.
Getting Started with Simple Script
Before diving into scripting, ensure you have added the Simple Script Extension to your SAMSON installation. Once ready, here are some practical capabilities you can unlock:
1. Shape Atomic Structures Mathematically
You can shift all atoms in a determined pattern. For example, adjusting the z-coordinate of atoms to follow a sine wave:
|
1 |
a.z := sin(a.x * π / 12); |
This script allows you to create sinusoidal distortions. Such mathematical shapes are useful for studying the properties of wavy nanostructured materials.

2. Filter Atoms Using Logical Conditions
The scripting feature offers excellent filtering capabilities for atom subsets. For instance, you can select all atoms from specific elements like Carbon(“C”) and Hydrogen(“H”):
|
1 2 |
if (a.element == 'Carbon' or a.symbol == 'H') n.selectionFlag := 1; else n.selectionFlag := 0; |
This ensures only the atoms you’re interested in are considered for further processing or visualization.
3. Construct Iconic Shapes: Create a Nano-Batarang
As a striking application, consider using Simple Script to construct a nano-scale version of Batman’s batarang. This involves selecting atoms and shaping them into the iconic silhouette. Below is an animation of such a script in action:

The ability to script intricate shapes like this is not only a learning exercise but also a method to familiarize yourself with atomic selection and transformations in SAMSON.
Start with Examples and Explore
SAMSON’s documentation includes several ready-to-use script examples for beginners and advanced users. These examples demonstrate essential operations, such as modifying atomic coordinates within specific ranges, reassigning element IDs, and even constructing geometrically complex nanostructures.
To delve much deeper into the powerful features of the Simple Script framework, check the full documentation at Making Nano-Batarangs (and more).
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON at SAMSON-Connect.
