Computational XRD: Difference between revisions

From Micro and Nano Mechanics Group
Jump to navigation Jump to search
(Created page with "<P ALIGN="CENTER"> <FONT SIZE="+3" color="darkred"><STRONG> Computational XRD</STRONG></font></P> <DIV> <P ALIGN="CENTER"><STRONG> </STRONG></P> </DIV> ===Making Nanoparticle...")
 
No edit summary
Line 8: Line 8:
===Making Nanoparticles===
===Making Nanoparticles===


Here we give an example of how to generate nanoparticles with different dislocations. A python version of the MD++ code is necessary. The relevant python files are:
Here we give an example of how to generate nanoparticles with different dislocations. One may have to play around a bit with the directories to make sure that the files get opened and written to the correct places. A python version of the MD++ code is necessary. The relevant python files are:


generate_particles.py
generate_particles.py
Line 16: Line 16:
bin/eam generate_particles.py
bin/eam generate_particles.py


'''Flags'''
'''Notable Parameters'''


<pre>
<pre>
Line 35: Line 35:
Now we are ready to run
Now we are ready to run
g++ -o XRD.exe XRD_OpenMP.cpp -lgsl -lgslcblas -lm -fopenmp -std=c++11
g++ -o XRD.exe XRD_OpenMP.cpp -lgsl -lgslcblas -lm -fopenmp -std=c++11
followed simply by ./XRD.exe.
'''Parameters'''

<pre>
flag = 0
Radius = 40
divs = 6 # the number of partial distance calculations to compute.
# this needs to be adjusted to larger values for large runs
# because of memory issues. If not set properly, the code will
# exit with a memory error.
num_bins = 5000 # the number of bins in the histogram per division
N = 1000 # the number of points for the Intensity and Q
</pre>


===Plotting and Interpolating===
===Plotting and Interpolating===

Revision as of 05:11, 15 August 2015

Computational XRD

Making Nanoparticles

Here we give an example of how to generate nanoparticles with different dislocations. One may have to play around a bit with the directories to make sure that the files get opened and written to the correct places. A python version of the MD++ code is necessary. The relevant python files are:

generate_particles.py XRDsetup.py

and these can be run with the command: bin/eam generate_particles.py

Notable Parameters

# flag = 0 is no dislocations
# flag = 1 is only one dislocation
# flag = 2 is multiple randomly generated dislocations
flag = 0 
start = 40    # Radius of the nanoparticle
numDisls = 6  # if flag == 2, the number of dislocations

This generates a series of .cn, .cfg, and a file of atomic positions which will be read by the C++ code to calculate the Intensity.

Intensity Calculation in C++

First, make sure the required libraries are installed. The GSL, C++11, and OpenMP packages are required (the GSL library is for easily making histograms). The required files are the previous file of atomic positions and the attached C++ file:

Now we are ready to run g++ -o XRD.exe XRD_OpenMP.cpp -lgsl -lgslcblas -lm -fopenmp -std=c++11 followed simply by ./XRD.exe. Parameters

flag = 0 
Radius = 40    
divs = 6         # the number of partial distance calculations to compute.
                 # this needs to be adjusted to larger values for large runs
                 # because of memory issues. If not set properly, the code will
                 # exit with a memory error.
num_bins = 5000  # the number of bins in the histogram per division
N = 1000         # the number of points for the Intensity and Q

Plotting and Interpolating

The next step is to read the file of Intensities and Q values into the python script attached. The Intensity and Q values that are either background before the first real Bragg peak or are small values past Q~20 are gotten rid of. The interpolation is only done on the largest 5-10 peaks. The number of peaks that can be reasonably interpolated decreases with increasing number of dislocations as the peaks broaden. There are some important parameters to consider, especially in the interpolation. These are:

Parameters

wavelength = 0.67
Radius = int(sys.argv[1])
flag = int(sys.argv[2])
cutoff = 2e4  # Bragg peaks with maxima below cutoff will be ignored
tol = 0.1     # The Q range around which the program searches for a half-maximum

CUDA Code

The code is obviously parallel. The next step is to re-write the code in CUDA to improve speed.