User Tools

Site Tools


examples:gs_loop_ppv

GrainSpotter loop for NaCoF3 post-perovskite

Below is an example of a GrainSpotter loop for NaCoF3 post-perovskite. You can run it by typing

gsLoop.sh > gsLoop.log

The output of the loop will be saved in gsLoop.log, with multiple outputs, one for each indexing.

Main idea

The loop can run nLoops indexings (typically 3). Indexing are run in parallel. If you ask for 20 copies of indexings, they will run simultaneously. Make sure you do not overrun the capabilities of your computer otherwise it will become very slow!

For each, the loop runs

  • 20 iterations of 10000 GrainSpotter orientation searches with the following threshold
  • minNPeaks = 25
  • minCompleteness = 0.5
  • Δ = 0.05°
  • Δη = 1.2°
  • Δω = 1.2°
  • maximum deviation nσ = 2
  • 20 iterations of 10000 GrainSpotter orientation searches with
  • minNPeaks = 25
  • minCompleteness = 0.5
  • Δ = 0.07°
  • Δη = 2°
  • Δω = 2°
  • maximum deviation nσ = 2
  • 20 iterations of 10000 GrainSpotter orientation searches with
  • minNPeaks = 15
  • minCompleteness = 0.3
  • Δ = 0.05°
  • Δη = 1.2°
  • Δω = 1.2°
  • maximum deviation nσ = 2
  • 20 iterations of 10000 GrainSpotter orientation searches with
  • minNPeaks = 15
  • minCompleteness = 0.3
  • Δ = 0.07°
  • Δη = 2°
  • Δω = 2°
  • maximum deviation nσ = 2

At the end of the loop, all results for the corresponding loop number are saved in a folder called Indexing-$loop, where $loop is the loop number. Merged grains are in a file called merge-grains.log and their Euler angles in merge-grains-euler.txt.

Getting some idea on indexing capabilities

There is now a dedicated TIMEleSS tool to evaluate your indexing performance.

The loop

You wanted it?! Here is the source code for the loop above

gsLoop.sh
#!/bin/bash
 
# Starting GVE file
startGVE=../HTC_04_02_3D_03_merge.gve
# Starting GVE file
crystalSymmetryCode=3
# Number of indexings
nLoops=3
# Threshold for considering 2 grains are the same (in degrees)
matchgrainThreshold=1
# Step in omega, in degrees
omegastep=0.25
# 2 theta range
min2theta=4.0
max2theta=17.0
# Wavelength
wave=0.3738
 
# Update parameters above as well as in 
#    - create_GS_init
#    - fine details in indexing_loop
 
# Location of executables
GrainSpotter=/usr/local/bin/GrainSpotter.0.90
clearGVE=/usr/bin/timelessClearGVEGrains
mergeGrains=/usr/bin/timelessGrainSpotterMerge
extractEuler=/usr/bin/timelessExtractEulerAngles
indexingStatistics=/usr/bin/timelessGSIndexingStatistics
 
# Global parameter. Used to pass list of files between functions
#grainlist=""
 
#-----------------------------------------------------------------------------------------------
#
# Call to create GrainSpotter input
# 3 parameters
# - first: name of GrainSpotter output file
# - second: name gve file
# - third: name of grain output file
# - forth : min_measurments
# - fifth : min_completeness
# - sixth : sigma_tth
# - seventh : sigma_eta
# - eighth : sigma_omega
#
#-----------------------------------------------------------------------------------------------
create_GS_init () {
cat > $1 <<- EOM
spacegroup 63					! spacegroup [space group nr]
etarange 0 360					! etarange [min max]
! dsrange 0.0 2.0				! dsrange [min max], reciprocal d-spacing range, multiple ranges can be specified
tthrange $min2theta $max2theta	! tthrange [min max], multiple ranges can be specified
domega $omegastep				! domega [stepsize] in omega, degrees
omegarange -29.0 30.0 			! omegarange [min max] degrees, multiple ranges can be specified
filespecs $2 $3					! [gvecsfile grainsfile]
cuts $4 $5 1.0 					! cuts [min_measuments min_completeness min_uniqueness]
eulerstep 3                		! eulerstep [stepsize] : angle step size in Euler space
uncertainties $6 $7 $8    		! uncertainties [sigma_tth sigma_eta sigma_omega] in degrees
nsigmas 2               		! nsigmas [Nsig] : maximal deviation in sigmas
!Nhkls_in_indexing 31        	! Nhkls_in_indexing [Nfamilies] : use first Nfamilies in indexing
random $9               		! random sampling of orientation space trying 10000 sample points
minfracg 0.99					! stop search when minfracg (0..1) of the gvectors have been assigned to grains
! positionfit 					! fit the position of the grain
! genhkl						! generate list of hkl's based on space group and cell parameters in gve file
EOM
}
 
#-----------------------------------------------------------------------------------------------
#
# Actual indexing loop
# Runs tens of GrainSpotter iterations with decreasing tolerances
# Runs in the current folder
#
#-----------------------------------------------------------------------------------------------
 
indexing_loop () {
local grainlist="" # Declaring this variable as local to be able to run multiple indexings in parallel
 
echo "#"
echo "#"
echo "# Running first GS iteration. Starting from $startGVE, GS parameters in index-0.ini, grains saved in grains0.log"
echo "#"
echo "#"
create_GS_init index-0.ini ../$startGVE grains-0.log 25 0.5 0.05 1.2 1.2 10000
$GrainSpotter index-0.ini
echo "#"
echo "#"
echo "# Done with iteration 0. New list of GVE will be peaks_after_step-0.gve"
echo "#"
echo "#"
$clearGVE grains-0.log ../$startGVE peaks_after_step-0.gve 
grainlist="grains-0.log"
 
for i in {1..20}
do
	j="$((i - 1))"
	echo "#"
	echo "#"
	echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
	echo "#"
	echo "#"
	# Use from previous step and create grains$i.log
	create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 25 0.5 0.05 1.2 1.2 10000
	$GrainSpotter index-$i.ini 
	echo "#"
	echo "#"
	echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
	echo "#"
	echo "#"
	$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
	grainlist="$grainlist grains-$i.log"
	rm peaks_after_step-$j.gve
done
 
for i in {21..40}
do
	j="$((i - 1))"
	echo "#"
	echo "#"
	echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
	echo "#"
	echo "#"
	# Use from previous step and create grains$i.log
	create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 25 0.5 0.07 2.0 2.0 10000
	$GrainSpotter index-$i.ini 
	echo "#"
	echo "#"
	echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
	echo "#"
	echo "#"
	$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
	grainlist="$grainlist grains-$i.log"
	rm peaks_after_step-$j.gve
done
 
for i in {41..60}
do
	j="$((i - 1))"
	echo "#"
	echo "#"
	echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
	echo "#"
	echo "#"
	# Use from previous step and create grains$i.log
	create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 15 0.3 0.05 1.2 1.2 10000
	$GrainSpotter index-$i.ini 
	echo "#"
	echo "#"
	echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
	echo "#"
	echo "#"
	$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
	grainlist="$grainlist grains-$i.log"
	rm peaks_after_step-$j.gve
done
 
 
for i in {61..80}
do
	j="$((i - 1))"
	echo "#"
	echo "#"
	echo "# Running GS iteration $i. Starting from peaks_after_step-$j.gve, GS parameters in index$i.ini, grains saved in grains-$i.log"
	echo "#"
	echo "#"
	# Use from previous step and create grains$i.log
	create_GS_init index-$i.ini peaks_after_step-$j.gve grains-$i.log 15 0.3 0.07 2.0 2.0 10000
	$GrainSpotter index-$i.ini 
	echo "#"
	echo "#"
	echo "# Done with iteration $i. New list of GVE will be peaks_after_step-$i.gve"
	echo "#"
	echo "#"
	$clearGVE grains-$i.log peaks_after_step-$j.gve peaks_after_step-$i.gve
	grainlist="$grainlist grains-$i.log"
	rm peaks_after_step-$j.gve
done
 
rm peaks_after_step-80.gve
$mergeGrains -c $crystalSymmetryCode -m $matchgrainThreshold -o merge $grainlist
$extractEuler -o merge-grains-euler.txt merge-grains.log
$indexingStatistics -i index-80.ini -l merge-grains.log -g ../$startGVE -w $wave 
 
}
 
#-----------------------------------------------------------------------------------------------
#
# Indexing loop, runs tens of GrainSpotter iterations with decreasing tolerances
# Runs in the current folder
#
#-----------------------------------------------------------------------------------------------
 
for (( loop=1; loop<=$nLoops; loop++ ))
do
	echo "#----------------------------------------------------------------------------------------"
	echo "#"
	echo "# Full indexing loop number $loop"
	echo "# Data saved in folder: Indexing-$loop"
	echo "#"
	echo "#----------------------------------------------------------------------------------------"
	echo ""
	folder="Indexing-$loop"
	\rm -rf $folder
	mkdir $folder
	cd $folder
	indexing_loop > "../indexing-$loop.log" &
	cd ..
 
	echo ""
	echo ""
	echo "#"
	echo "# Done starting the indexing loop number $loop"
	echo "# Data saved in folder: Indexing-$loop"
	echo "# Log file is indexing-$loop.log"
	echo "#"
	echo "#----------------------------------------------------------------------------------------"
	echo ""
	echo ""
done
 
exit
examples/gs_loop_ppv.txt · Last modified: 2023/12/09 22:30 by smerkel