Create a slab from a bulk material with a cutout of any shape, given as a condition on the coordinates. The default cutout is an etching pattern: two side walls, two parallel channels at the top and a deeper central cavity.
In JupyterLite, the notebook is made/create_cutout_custom_shape.ipynb, entry 1.4.6 "Custom Shape Cutout. Create a slab with a custom shape cutout" of made/Introduction.ipynb.
# Slab parametersMILLER_INDICES=(0,0,1)THICKNESS=6# unit cell layersVACUUM=10.0# AngstromXY_SUPERCELL_MATRIX=[[10,0],[0,10]]# Custom shape parameters in crystal units of the slabLEFT_WALL_POSITION=0.2RIGHT_WALL_POSITION=0.8LEFT_CHANNEL_POSITION=0.25RIGHT_CHANNEL_POSITION=0.75CHANNEL_TOP_Z=0.8CAVITY_TOP_Z=0.5NAME="Custom Shape - Etching Pattern"
LEFT_WALL_POSITION and RIGHT_WALL_POSITION place the walls along x, LEFT_CHANNEL_POSITION and RIGHT_CHANNEL_POSITION the channels along y, and CHANNEL_TOP_Z and CAVITY_TOP_Z their depths along z, all in crystal coordinates of the slab. NAME is the name of the resulting material.
fromtypingimportListfrommat3ra.made.tools.helpersimportCoordinateCondition# Example of a custom coordinate condition. Adapt coordinate conditions to your needs.classCustomCoordinateCondition(CoordinateCondition):""" Defines an etched pattern structure with side walls, channels, and a central cavity. All dimensions are specified as fractions of the total size (0.0 to 1.0). """left_wall_position:float=0.2right_wall_position:float=0.8left_channel_position:float=0.25right_channel_position:float=0.75channel_top_z:float=0.8cavity_top_z:float=0.5defcondition(self,coordinate:List[float])->bool:""" Determines which atoms to filter based on the coordinate. Returns True for positions where atoms should be removed. The structure consists of: 1. Side walls: Two vertical walls running along the y-axis 2. Channels: Two trenches at the top running along the x-axis 3. Cavity: A deeper central region between the channels """x,y,z=coordinate# Define the structural elementsis_in_left_wall=x<=self.left_wall_positionis_in_right_wall=x>=self.right_wall_positionis_in_left_channel=y<=self.left_channel_positionis_in_right_channel=y>=self.right_channel_positionis_in_channel=(z<self.channel_top_zand(is_in_left_channeloris_in_right_channel))is_below_cavity=(z<self.cavity_top_zand# Cavity depthself.left_wall_position<x<self.right_wall_positionand# Between wallsnotis_in_left_channelandnotis_in_right_channel# Between channels)return(is_in_left_walloris_in_right_walloris_in_channeloris_below_cavity)condition=CustomCoordinateCondition(left_wall_position=LEFT_WALL_POSITION,right_wall_position=RIGHT_WALL_POSITION,left_channel_position=LEFT_CHANNEL_POSITION,right_channel_position=RIGHT_CHANNEL_POSITION,channel_top_z=CHANNEL_TOP_Z,cavity_top_z=CAVITY_TOP_Z,).condition
CustomCoordinateCondition.condition defines the pattern from these positions; another pattern is set by editing the method.
Run the notebook with Run > Run All. The notebook shows the result from the top, from the side and at an angle, and passes it back with set_materials, as in Structure Notebooks.