Skip to content

Create a Nanowire with a Custom Cross-Section Shape

1. Introduction

Create a nanowire with a cross-section of any shape from a bulk material. The wire is cut along the z axis of a slab with the given Miller indices and, optionally, rotated to lie along x.

2. Open the notebook

In JupyterLite, the notebook is made/create_nanowire_custom_shape.ipynb, entry 1.3.2 "Nanowires with custom shape. Create a nanowire with a custom cross-section" of made/Introduction.ipynb.

3. Set the parameters

The notebook takes the first of the input materials.

Cell 1.2 holds the parameters:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from typing import List

# Cross-section shape parameters
CENTER_COORDINATE = [0.5, 0.5, 0.5] # Center of the cylinder in units specified by flag below
MAJOR_RADIUS = 0.25 # Cylinder wire radius in units specified by the flag below
MINOR_RADIUS = 0.1 # Cylinder wire radius in units specified by the flag below
USE_CARTESIAN_COORDINATES = False # Flag to use Cartesian coordinates for the center and radii

# Wire parameters
MILLER_INDICES= (0,0,1)  # Miller indices of the nanowire direction
SUPERCELL_MATRIX = [[9, 0, 0], [0, 9, 0], [0, 0, 30]] # Supercell matrix to cut the cylinder from
VACUUM = 10.0 # Vacuum thickness on the sides in Angstroms
ALIGN_ALONG_X = True

import numpy as np
from mat3ra.made.tools.helpers import CoordinateCondition

# Custom Coordinate Condition for a hollow cylinder shape
class CustomCoordinateCondition(CoordinateCondition):
    center: List[float] = [0.5, 0.5, 0.5]
    major_radius: float = 0.5
    minor_radius: float = 0.2

    def condition(self, coordinate: List[float]) -> bool:
        coord = np.array(coordinate)
        # Calculate the distance from the center in the xy-plane
        xy_distance = np.linalg.norm(coord[:2] - self.center[:2])
        # Calculate the distance from the torus surface
        distance_to_torus = np.sqrt((xy_distance - self.major_radius) ** 2 + (coord[2] - self.center[2]) ** 2)
        return distance_to_torus <= self.minor_radius
condition = CustomCoordinateCondition(center=CENTER_COORDINATE, major_radius=MAJOR_RADIUS, minor_radius=MINOR_RADIUS).condition

CustomCoordinateCondition.condition returns whether the atom at a coordinate is kept. The default keeps the atoms within MINOR_RADIUS of a ring of radius MAJOR_RADIUS around CENTER_COORDINATE; another shape is set by editing the method.

CENTER_COORDINATE, MAJOR_RADIUS and MINOR_RADIUS are in the coordinates that USE_CARTESIAN_COORDINATES selects.

SUPERCELL_MATRIX sets the block the shape is cut from, and ALIGN_ALONG_X = True rotates the wire to lie along x. The overview explains MILLER_INDICES and VACUUM.

4. Run and read the result

Run the notebook with Run > Run All. The notebook shows the nanowire from three directions and passes it back with set_materials, as in Structure Notebooks.

5. Interactive JupyterLite notebook

The interactive JupyterLite notebook for creating a nanowire with a custom cross-section can be accessed below.

The specific example H-Passivated Silicon Nanowire uses this notebook.