Cell Link

Define here which nodes will be considered in the link operation.


GAMGI supports two methods to define the boundary between inside (linked) and outside (unlinked) cell regions: Object and Node.

With the Object method, the link is considered as long as the object is inside the cell volume (even if the node is outside). This is the usual method to build crystals.

With the Node method, the link is considered as long as the node is inside the cell volume (even if the object is outside). This method is useful for example to build liquids and nanostructures.

For all cell representations, a small tolerance (by default 1.0E-4) is added around the cell volume, to make sure that objects or nodes exactly in the borders are included.


When the cell volume is Primitive, Wigner, Rhombus or Sphere, the occupation rules are applied along the primitive vectors.

When the volume is Conventional, users can choose to apply the occupation rules to P nodes (the vertices of the cells) or, when they exist, to I nodes (in the center of the cells), to A, B, C nodes (in the center of the faces normal to vectors a, b, c, respectively), or to R nodes (the nodes inside rombohedral cells, with an obverse orientation), by pressing the buttons labeled P, I, A, B, C, R.

When Cell->Link starts, all nodes are available, though not selected. When a Cell is selected, the available nodes are selected by default and nonexistent nodes are automatically disabled.


GAMGI uses a small language based in patterns of occupation to define which nodes should be linked (occupied). These pattern rules are formed by combining the characters * (meaning ocuppied nodes) and _ (meaning empty nodes), plus the digits 0-9 (meaning node positions). These rules are applied separately to each of the selected node subsets. By default all nodes are accupied, so the initial pattern is (*, *, *).

The most common examples of occupation rules are simple to understand: (*, *, *) means apply to all nodes, (1, 2, 3) means apply to node (1, 2, 3) only, (*_, *_, *_) means apply to alternated nodes only, with the starting node (0, 0, 0) occupied, (*, 2, *) means apply only to the nodes where the second coordinate is 2, (*5, *, *) means apply to all nodes where the first coordinate is 5 or smaller, (*, *, _3*) means apply to all nodes where the third coordinate is 4 or larger.

When digits are not included, the sequences of * and _ characters are handled as patterns of occupation that are repeated until all nodes are scanned. Therefore, the pattern (*_, *, *) is equivalent to (*_*_, *, *) but different from (*_*, *, *).

Nodes are scanned and marked three times, first along the a direction, with the first pattern, then along the b direction, with the second pattern and finally along the c direction, with the third pattern.

When the first pattern is applied, the nodes in the first plane (along direction a) are marked with the pattern first character, but when the second and third patterns are applied, the nodes in the first planes (along directions b, c) are preserved (to keep the information introduced with the previous patterns) and the patterns are scanned not from the first character but from the character that is equal to the character of the nodes in the first planes. Therefore, the pattern (*_, *_, *_) is equivalent to (*_, _*, _*) (node (0, 0, 0) is occupied) but different from (_*, *_, *_) (node (0, 0, 0) is empty).

When digits are included, they are handled as node coordinates and fix limits to the range of application of the various patterns. They can appear in the beginning, meaning that nodes with a smaller coordinate are empty, in the middle, meaning that the previous pattern should be repeated only until that node inclusive, or in the end, meaning that all nodes with a larger coordinate are empty.

For example: (*, *_5**_10, *) means repeat sequence one occupied-one empty along the second direction until the second coordinate becomes 5 inclusive, then repeat sequence two occupied-one empty until the second coordinate becomes 10 inclusive, all the remaing nodes are empty; (*, *, _5*_10*) means all nodes are empty along the third direction until the third coordinate is 5 inclusive, then apply the sequence one occupied- one empty until the third coordinate becomes 10 inclusive, all the remaining nodes are occupied.

When only digits appear, nodes with that coordinate are occupied, all the others, before and after, are empty. We note that (*, *, 8) is equivalent to (*, *, 8_) (nodes are empty except when the third coordinate is 8) but (8, *, *) (nodes are empty except when the first coordinate is 8) is different from (_8, *, *) (all nodes are empty).

When marking the nodes, the sequence * (or ** or ***, etc.), meaning these nodes seem to be occupied, can be overrun by patterns applied in the other directions, which in turn can be overrun by the sequence _ (or __ or ___, etc.), meaning these nodes must be empty, or by starting/ending digits, meaning nodes before/after must be empty, this way establishing a hierarchy for the priority of the various patterns.

For example, the sequence (*, *_, *10_) means, first, all nodes seem to be occupied in the first direction, second, alternated nodes in the second direction are empty, (overriding the first sequence), third, nodes until 10 stay as they are (because * has lower priority than the pattern applied in the second direction) and nodes after 10 are definitely empty (overriding the second sequence).

The rules explained so far are valid for nodes with positive coordinates along Cell directions a, b, c. To obtain the occupancy patterns for nodes with negative coordinates, just reflect around zero (by a mirror operation) the results obtained for positive nodes. Therefore the rule (1, 1, 1) actually links the eight nodes (-1,-1,-1), (-1,-1,+1), (-1,+1,-1), (-1,+1,+1), (+1,-1,-1), (+1,-1,+1), (+1,+1,-1) and (+1,+1,+1).

When the cell volume is a Sphere, by default the origin is at the center, so nodes are marked in one octant and symmetrically replicated to the other octants. For example, for a cubic lattice inside a sphere of radius 5, to occupy only a central cube around the center, a pattern as (*2_, *2_, *2_) can be used, and to occupy all the other nodes (leaving the cube in the center completely empty), the pattern (___***, ___***, ___***) will work. In this second case, a pattern as (_2*, _2*, _2*) will not work, because the low priority * sequence is overrun by the high priority _ sequence, when applied in the other directions.

When the selected Cutoff mode is Objects, nodes outside the cell volume can contribute to the contents of the cell volume. This happens for all centered lattices with Conventional volumes, plus Rhombus and Sphere cell volumes. Therefore, the occupancy patterns must be applied to the larger cell volumes that contain all the contributing nodes (not just those that are visible inside the cell). Some of these additional nodes have negative coordinates, so they are replicated from the corresponding positive nodes. This occurs for Conventional centered cells, for I, A, B, C nodes, plus Rhombus volumes.

Changing the Cell origin, to take profit of the replication rule, extends enormously the power of occupancy patterns. For example, a cubic primitive lattice with 8 x 6 x 4 conventional cells has positive nodes only. Moving the Cell origin to the volume center, to node (4, 3, 2), seven out of the eight octants have now nodes with negative coordinates. Applying successively the rules (____*), (___****) and (__***), the cell volume remains empty everywhere except at the six lateral faces, where all nodes are occupied.

These techniques can be used to build arbitrarily complex, multi-layered, nanostructures.