The program that is being used to visualize a crystal structure is MATLAB. The code that MATLAB uses to do this is contained in the file, 'BravaisLattice.m', written by this author. After reading the code, MATLAB creates the PUC (Primitive Unit Cell) of the crystal structure by drawing spheres at the points of all the atoms in the PUC. It then translates the PUC in the x-axis, then the y-axis, and finally translates everything to the z-axis to create a full 3-D crystal lattice. MATLAB takes the coordinates of an input file, which is specified in line 3 of 'BravaisLattice.m', to perform the above algorithm. There are three examples of input files that are provided in this webpage to assist the user in creating a crystal structure with MATLAB.
1) Download the file 'BravaisLattice.m' into your computer 2) Open MATLAB and open 'BravaisLattice.m' in the MATLAB Editor 3) Create a text file using notepad or any other program that allows you to save in the '.txt' format. 4) There are three sample input files in this webpage, named 'diamond.txt', 'NaCl.txt' and 'fcc.txt that can be used. You can modify line 3 of the code to tell the program to open either of these two files and finally hit the 'F5' key on your keyboard, or equivalently select the 'run' task from the 'debug' menu in MATLAB Editor. 5) As mentioned, you should modify line 3 of the code, which contains the name of the text file that you want to open, to accommodate for your own text file, i.e., if you want to open 'Trial.txt', line 3 of the code should read: "fid = fopen('Trial.txt','r')"
Structure of the Input File This program enables users to visualize a crystal lattice with an underlying cubic lattice structure. The input file should contain all the necessary coordinates and atomic number information of the Primitive Unit Cell (PUC) of the crystal that you want to visualize. The input file, which is a text file that can be created in a program such as 'Notepad', has the following format: (Note that everything must come in the right order, with the numbers below corresponding to the ordering of the input file. 1. (1 entry) length of lattice in Cartesian coordinates for each direction (x,y,z), in addition to that of the PUC. For example, (1,1,1) corresponds to a cell that has length (1,1,1) + PUC length. In the text file, you will enter 1 1 1 2. (1 entry) total number of atoms in the PUC. This is excluding atoms that make up the underlying cubic lattice, described by the vectors in number 3 below. Each atom within the PUC corresponds to a count of 1, there is no sharing between PUC's, except for the atoms in the corners, which are not counted here. In the text file, you will enter, say for a cell with 10 atoms, 10 0 0 Note that the extra zeros are there to simply ensure the symmetry of the text file, i.e., it should have 3 columns with the desired rows. This is because MATLAB reads the text file as a 3 x N matrix. 3. (3 entries) underlying basis vectors. For a cubic basis, you will enter, 1 0 0 0 1 0 0 0 1 4. (1 entry for each atom) additional coordinates for each atom in the PUC. A total of 3 vectors for each atom, i.e., (0.5,0.5,0.5) corresponds to one atom located in the center of the PUC. For example, in an fcc structure, there are 6 atoms contained in the PUC (1 on the center on each face of the cube), excluding sharing and the atoms constituting the basis, therefore, you will enter, 1.5 1.5 1 1 1.5 1.5 1.5 1 1.5