Skip to content

njszym/AdaptiveXRD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adaptive XRD

A package designed to integrate automated phase identification with in-line guidance of XRD measurements.

The corresponding manuscript can be found at npj Computational Materials. All simulated and experimental data used for testing can be found in Figshare.

Installation

First, go to XRD-AutoAnalyzer and follow the instructions for installation.

Then, clone the current repository:

git clone https://github.com/njszym/AdaptiveXRD.git

Navigate to the cloned directory and execute:

pip install . --user

Training new models

Convolutional neural networks are trained using artifical XRD spectra generated from a given set of reference phases. This follows the methodology discussed in XRD-AutoAnalyzer.

For adaptive XRD, multiple models are trained on distinct ranges of 2θ. Such models can be created as follows:

python construct_models.py --min_angle=10.0 --start_max=60.0 --final_max=140.0 --interval=10.0

Where start_max represents the upper bound on the first range of 2θ that will be sampled by the diffractometer. In cases where additional measurements are suggested, the scan range will be expanded by the amount specified (interval). This process continues until final_max is reached. Keep in mind that the maximum angle specified should be compatible with the diffractometer being used. For most instruments, 140 degrees is an upper limit.

By specifying these values during during training, several models will be created to represent each possible range of 2θ. For example:

  • Model 1: trained on 2θ = [min_angle, start_max]
  • Model 2: trained on 2θ = [min_angle, start_max + interval]
  • Model 3: trained on 2θ = [min_angle, start_max + 2×interval]
  • And so on...Until final_max is reached.

All trained models will be placed inside a folder called Models. Their maximum angles will be specified in the filenames (e.g., Model_80.h5).

Performing measurements and analysis

Trained neural network models can be used to guide XRD scans and perform phase identification on the resulting patterns. This can be accomplished with the scan_and_ID script. For example:

python scan_and_ID.py --min_angle=10.0 --start_max=60.0 --final_max=140.0 --interval=10.0 --instrument='Aeris' --target_conf=80.0 --cam_cutoff=25.0 --min_window=5.0

The first few variables should match the values used during training. These dictate how the 2θ scan range will be expanded during the XRD measurements.

The instrument variable specifies which diffractometer will be used. This is important as each instrument must be interfaced with in a unique way. Further details on this are given in the next section.

The later variables control resampling of 2θ within each range.

target_conf represents the desired prediction confidence for each phase identified by XRD-AutoAnalyzer. In cases where the prediction confidence falls below this value, additional measurements will be performed.

cam_cutoff controls how much 2θ is scanned during each resampling iteration. A lower cutoff will lead to more resampling (and therefore a longer measurement time), whereas a higher cutoff leads to less resampling (shorter scan time). A cutoff of 25% generally leads to a good balance between speed and accuracy.

min_window defines the smallest range of 2θ that will be resampled. Generally, windows less than 5 degrees are inefficient as some time is required to set up the measurement, and such a small range will yield limited information.

Once the measurements and analysis are complete, an output will appear:

Predicted phases: (phase_1 + phase_2 + ...)
Confidence: (probabilities associated with the phases above)

And the measured spectrum can bound found in the Spectra folder.

To perfrom further analysis of this spectrum post hoc, XRD-AutoAnalyzer can be used.

Choice of diffractometer

As mentioned in the previous section, the diffractometer should be specified at runtime using the --instrument flag. This will tell adaptiveXRD how to interface with the diffractometer (see adaptXRD/oracle/__init__.py).

Currently, this package supports three instrument types, described below.

Aeris

Specifying --instrument="Aeris" enables an interface with a Panalytical Aeris diffractometer.

Communication is performed via TCP commands over an ethernet connection. Details regarding the Aeris communication system can be found in adaptXRD/AerisAI. The IP address and results directory should be changed to reflect the user's setup.

Bruker

Specifying --instrument="Bruker" enables an interface with a Bruker D8 Advance diffractometer.

Communication is performed through a file handoff system, where input files with scan parameters are placed in a folder that is constantly monitored by the Bruker LabLims software. Experiment files (.bsml) and scan scripts (.cs) should be created by the user beforehand. The location of the job file should also be set before running any measurements on a new system. All information can be specified in the adaptXRD/oracle/__init__.py file.

Post Hoc

Specifying --instrument="Post Hoc" enables interpolation of low- and high-precision spectra that are created beforehand. This is mostly used for testing purposes, as it represents a simulation of experimental sampling.

When using this flag, patterns with low and high resolution should be placed in folders named Low and High respectively.

Each filename should also be specified at runtime by using the --existing_file=FILENAME flag. As with other methods, the resulting spectrum will be placed in the Spectra folder.

Additional diffractometers

AdaptiveXRD can be readily applied to new instrumentation, so long as an interface is accessible. In such cases, the adaptXRD/oracle/__init__.py should be modified accordingly.

Customized scan times

The resolution, and therefore the speed, of the XRD scans can be set by the following arguments:

python scan_and_ID.py --initial_step=0.02 --initial_time=0.01 --final_step=0.01 --final_time=0.2

The values given above are the default values, which generally lead to measurements that take around 3-5 minutes per sample. For shorter or longer measurements, alternative values can be specified. A description of each parameter is given below.

initial_step is the sampling interval (in degrees) to be used during the initial, low-resolution scan.

initial_time is the time that will be spent scanning each step (in seconds) during the initial, low-resolution scan.

final_step is the sampling interval (in degrees) to be used during adaptive (high-resolution) resampling.

final_time is the time that will be spent scanning each step (in seconds) during adaptive (high-resolution) resampling.

Running a simulated example

After the installation has been completed, the user may run an example on simulated XRD data using pre-trained models in the Li-Ti-P-O chemical space. To do this, naviate to the Example folder and run the following command:

python scan_and_ID.py --min_angle=10.0 --start_max=60.0 --final_max=80.0 --interval=10.0 --instrument='Post Hoc' --existing_file='ZrO2_14+Li2ZrO3_15+LiOH_129' --plot --raw_spec

If the package was installed properly, this should yield the following predictions and plot:

Predicted phases: ['LiOH_129', 'ZrO2_14', 'Li2ZrO3_15']
Confidence: [99.0, 98.5, 98.0]

sample

This shows an accurate prediction on a three-phase mixture, which is enabled by the resampling of peaks in the range of 18-32 degrees.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages