For molecular modelers, a common challenge involves efficiently modifying and analyzing atomic properties within large molecular structures. Repetitive tasks like adjusting atom positions, filtering specific atoms, or applying mathematical patterns can be both time-consuming and tedious. What if there were a way to automate such actions, saving both time and effort? Enter the Simple Script Extension in SAMSON, a versatile tool to implement customized atomic modifications through scripting.
What is the Simple Script Extension?
The Simple Script Extension allows users to modify various atomic properties in the active document using mathematical expressions, conditional logic, and scripting. Elements that can be automated include atom positions, visibility, charges, and more. This tool is particularly valuable for tasks like creating structured patterns at the nanoscale, manipulating atomic datasets, or performing complex selections effortlessly.
For example, with just a few lines of code, you can:
- Transform structures into sinusoidal shapes.
- Select specific types of atoms based on their coordinates or physical properties.
- Create nano-scale designs like Batman’s iconic nano-batarang.
Example Use Case: Creating a Sinusoidal Graphene Structure
One practical application is reshaping graphene into a sinusoidal wave. Using the script below, you can set each atom’s z-coordinate as a function of its x-coordinate:
|
1 |
a.z:=sin(a.x * π / 12); |
The result? Your graphene sheet is transformed into a stunning wave-like pattern, as shown below:

A Closer Look at the Script’s Building Blocks
The scripting language is equipped with capabilities familiar to those with programming experience:
- Variables: Use variables like
a.x,a.y, anda.zto represent atomic coordinates. - Operators: Perform operations using standard mathematical symbols (
+,-,*, and more). - Control Structures: Implement
if,if-else, andforloops to execute conditional or iterative operations. - Functions: Utilize pre-defined functions like
sin,abs, andsqrtfor mathematical calculations.
One of the unique benefits of this extension is the ability to combine these elements creatively. For instance, selecting all atoms with positive x and y coordinates is as simple as:
|
1 |
if (a.x > 0 and a.y > 0) n.selectionFlag:=1; else n.selectionFlag:=0; |
Beyond the Basics: Nano-Designs
If you’re feeling ambitious, unleash your creativity by designing complex molecular structures. The extension enables intricate shape modification by employing mathematical expressions. As demonstrated in the documentation, fans of Batman can use the tool to carve nano-batarangs out of graphene sheets:

Why Use the Simple Script Extension?
This extension empowers researchers and professionals to:
- Automate routine molecular tasks, enhancing productivity.
- Experiment with novel nano-designs in a controlled and reproducible manner.
- Learn scripting principles while directly applying them to real-world challenges.
Furthermore, the tool’s versatility ensures that even complex problems like multi-criteria atom selection or property modification are addressed efficiently. The predefined functions and variables make it accessible even for those newer to programming.
Start Exploring
The Simple Script Extension isn’t just about optimizing workflows—it’s about inspiring creativity and innovation in molecular modeling. Whether you’re shaping graphene or selecting specific atoms based on conditions, this extension delivers a practical and powerful solution.
To learn more and view additional examples, visit the complete documentation at this link.
SAMSON and all SAMSON Extensions are free for non-commercial use. Download SAMSON today at SAMSON Connect.
