An engineering student is examining the x-ray diffraction pattern of aluminum samples. She has come to you to write a program that can calculate the lattice parameter of aluminum given the raw peak data from the diffractometer for each of her samples. The lattice parameter equation is:
where: a = lattice parameter, nm
diffractometer wavelength, 0.154056 nm
angle of diffraction, degrees
h, k, and l = indices of planes causing diffraction, positive integers
You are given the data for one sample in a file named AluminumIn.txt. The first line of the file contains a single, positive integer n that indicates the number of peaks included in the file. This number will never be greater than 50. The rest of the file contains n lines of data arranged in four columns as 2θ, h, k, and l. An example of a possible data file is shown below:
3
38.52 1 1 1
112.03 3 3 1
82.47 2 2 2
Write a complete program consisting of a Main Program and Subprogram (you choose which type, but there should be only one) that fulfills the following requirements:
• The diffraction data is read from the file into a 2D array in the Main Program.
• The subprogram calculates the lattice parameter, a, in Å (Angstroms, 1 Å = 10-10 m) for each set of 2θ, h, k, and l and stores the answers as a 1D array (note that the lattice parameter equation uses θ and the data is given as 2θ in degrees).
• The subprogram calculates the mean of all lattice parameters.
• The Main Program handles all output. Output should consist of a data file containing a table listing all 2 θ, h, k, l, and a with the average lattice parameter (e.g. 4.53 Angstroms) indicated below the table. The output file should be well formatted with all values properly labeled.