Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

MaXrd

Guides

  • MaXrd – Mathematica X-ray diffraction package

Tech Notes

  • Applying crystal data
  • Basic computations
  • Computations on reflections
  • Formulas in crystallography
  • Importing crystal data
  • Quick guide to conditions
  • References
  • Symmetry calculations
  • The association structure of crystallographic data
  • Using the rotation options

Symbols

  • AttenuationCoefficient
  • BraggAngle
  • ConstructDomains
  • CrystalDensity
  • CrystalFormulaUnits
  • CrystalPlot
  • DarwinWidth
  • DistortStructure
  • DomainPlot
  • EmbedStructure
  • ExpandCrystal
  • ExportCrystalData
  • ExtinctionLength
  • FindPixelClusters
  • GetAtomCoordinates
  • GetAtomicScatteringFactors
  • GetCrystalMetric
  • GetElements
  • GetLatticeParameters
  • GetLaueClass
  • GetScatteringCrossSections
  • GetSymmetryData
  • GetSymmetryOperations
  • ImportCrystalData
  • InputCheck
  • InterplanarSpacing
  • MergeDomains
  • MergeSymmetryEquivalentReflections
  • MillerNotationToList
  • MillerNotationToString
  • ReciprocalImageCheck
  • ReciprocalSpaceSimulation
  • ReflectionList
  • RelatedFunctionsGraph
  • ResetCrystalData
  • ResizeStructure
  • SimulateDiffractionPattern
  • StructureFactor
  • StructureFactorTable
  • SymmetryEquivalentPositions
  • SymmetryEquivalentReflections
  • SymmetryEquivalentReflectionsQ
  • SynthesiseStructure
  • SystematicAbsentQ
  • ToStandardSetting
  • TransformAtomicDisplacementParameters
  • UnitCellTransformation
  • $CrystalData
  • $GroupSymbolRedirect
  • $LaueClasses
  • $MaXrdPath
  • $MaXrdVersion
  • $PeriodicTable
  • $PointGroups
  • $SpaceGroups
  • $TransformationMatrices
Computations on reflections
Generating lists of reflections
Working with formatted strings
Formatting the reflections
​
In this tutorial, we will see how to make use of the package when working with reflections on the form
{h,k,l}
, symbolising Miller indices
hkl
.
The package must be loaded:
In[1]:=
<<MaXrd`
MergeSymmetryEquivalent
delete duplicate reflections by symmetry equivalence
ReflectionList
generates lists of reflections
SystematicAbsentQ
checks whether a reflection is extinct
ToStandardSetting
gives the «standard representative» reflection
Useful functions concerning
hkl
reflections and systematic absence (extinct- or forbidden reflections).
MillerNotationToList
converts formatted string
hkl
to list
{h,k,l}
MillerNotationToString
converts list
{h,k,l}
to formatted string
hkl
Functions for formatting and clearing formatting of reflections.
Generating lists of reflections
In this demonstration we wish to generate an appropriate list of reflections for sodium chloride.
Reflections are characterised by their Miller indices,
hkl
, which are represented by lists of three elements in Mathematica,
{h,k,l}
.
Let us start by making a generic list of reflections; every possible whole number combinations, up to index
2
(except the
000
reflection):
In[2]:=
hkl=
ReflectionList
[2]
Out[2]=
{{0,0,1},{0,1,0},{1,0,0},{0,0,-1},{0,-1,0},{-1,0,0},{0,0,2},{0,1,1},{0,2,0},{1,0,1},{1,1,0},{2,0,0},{0,0,-2},{0,1,-1},{1,0,-1},{0,-2,0},{0,-1,1},{1,-1,0},{0,-1,-1},{-2,0,0},{-1,0,1},{-1,1,0},{-1,0,-1},{-1,-1,0},{0,1,2},{0,2,1},{1,0,2},{1,1,1},{1,2,0},{2,0,1},{2,1,0},{0,1,-2},{0,2,-1},{1,0,-2},{1,1,-1},{2,0,-1},{0,-2,1},{0,-1,2},{1,-2,0},{1,-1,1},{2,-1,0},{0,-2,-1},{0,-1,-2},{1,-1,-1},{-2,0,1},{-2,1,0},{-1,0,2},{-1,1,1},{-1,2,0},{-2,0,-1},{-1,0,-2},{-1,1,-1},{-2,-1,0},{-1,-2,0},{-1,-1,1},{-1,-1,-1},{0,2,2},{1,1,2},{1,2,1},{2,0,2},{2,1,1},{2,2,0},{0,2,-2},{1,1,-2},{1,2,-1},{2,0,-2},{2,1,-1},{0,-2,2},{1,-2,1},{1,-1,2},{2,-2,0},{2,-1,1},{0,-2,-2},{1,-2,-1},{1,-1,-2},{2,-1,-1},{-2,0,2},{-2,1,1},{-2,2,0},{-1,1,2},{-1,2,1},{-2,0,-2},{-2,1,-1},{-1,1,-2},{-1,2,-1},{-2,-2,0},{-2,-1,1},{-1,-2,1},{-1,-1,2},{-2,-1,-1},{-1,-2,-1},{-1,-1,-2},{1,2,2},{2,1,2},{2,2,1},{1,2,-2},{2,1,-2},{2,2,-1},{1,-2,2},{2,-2,1},{2,-1,2},{1,-2,-2},{2,-2,-1},{2,-1,-2},{-2,1,2},{-2,2,1},{-1,2,2},{-2,1,-2},{-2,2,-1},{-1,2,-2},{-2,-2,1},{-2,-1,2},{-1,-2,2},{-2,-2,-1},{-2,-1,-2},{-1,-2,-2},{2,2,2},{2,2,-2},{2,-2,2},{2,-2,-2},{-2,2,2},{-2,2,-2},{-2,-2,2},{-2,-2,-2}}
In[3]:=
$CrystalData
["SodiumChloride","SpaceGroup"]
Out[3]=
Fm
3
m
In[4]:=
extinct=
SystematicAbsentQ
["Fm
3
m",hkl]
Out[4]=
{True,True,True,True,True,True,False,True,False,True,True,False,False,True,True,False,True,True,True,False,True,True,True,True,True,True,True,False,True,True,True,True,True,True,False,True,True,True,True,False,True,True,True,False,True,True,True,False,True,True,True,False,True,True,False,False,False,True,True,False,True,False,False,True,True,False,True,False,True,True,False,True,False,True,True,True,False,True,False,True,True,False,True,True,True,False,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,False,False,False,False,False,False,False,False}
In[5]:=
hkl=Pick[hkl,extinct,False]
Out[5]=
{{0,0,2},{0,2,0},{2,0,0},{0,0,-2},{0,-2,0},{-2,0,0},{1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},{-1,1,1},{-1,1,-1},{-1,-1,1},{-1,-1,-1},{0,2,2},{2,0,2},{2,2,0},{0,2,-2},{2,0,-2},{0,-2,2},{2,-2,0},{0,-2,-2},{-2,0,2},{-2,2,0},{-2,0,-2},{-2,-2,0},{2,2,2},{2,2,-2},{2,-2,2},{2,-2,-2},{-2,2,2},{-2,2,-2},{-2,-2,2},{-2,-2,-2}}
In[6]:=
MergeSymmetryEquivalentReflections
["Fm
3
m",hkl]
Out[6]=
{{0,0,2},{1,1,1},{0,2,2},{2,2,2}}
Two comments before we proceed further: We chose to remove the extinct reflections before we merged the symmetry equivalents, but this could have been done in the opposite order. The other thing is that we could also had used the name of the crystal directly instead of its space group. In the next lines we do this, and see that we end up with the same four reflections
002
,
111
,
022
and
222
:
In[7]:=
hkl=
ReflectionList
[2];​​hkl=
MergeSymmetryEquivalentReflections
["SodiumChloride",hkl]
Out[8]=
{{0,0,1},{0,0,2},{0,1,1},{0,1,2},{1,1,1},{0,2,2},{1,1,2},{1,2,2},{2,2,2}}
In[9]:=
extinct=
SystematicAbsentQ
["SodiumChloride",hkl]
Out[9]=
{True,False,True,True,False,False,True,True,False}
In[10]:=
Pick[hkl,extinct,False]
Out[10]=
{{0,0,2},{1,1,1},{0,2,2},{2,2,2}}
Another thing to consider is the Bragg angles of the reflections. The wavelength will limit how far out in reciprocal space we will see reflections. For example:
Given the wavelength
λ=1.54Å
(
Cu
K
α1
), we see that the reflection
335
is OK, but the higher indices of the
557
reflection yields an undefined angle:
In[11]:=
BraggAngle
["SodiumChloride",1.54,{{3,3,5},{5,5,7}}]
Out[11]=
{
63.541
°
,Undefined}
Thus, we also need to run our reflections through this check. Since we only generated reflections with a maximum index
2
, we won't have this problem with the four reflections we got. This begs another question: Which maximum index is appropriate for our crystal, given a certain wavelength? Luckily, the function
ReflectionList
does this and above steps automatically.
Generating reflections for sodium chloride, given the wavelength
λ=1.54Å
:
In[12]:=
ReflectionList
["SodiumChloride",1.54]
Out[12]=
{{0,0,2},{1,1,1},{0,0,4},{0,2,2},{1,1,3},{0,2,4},{2,2,2},{1,1,5},{1,3,3},{0,4,4},{2,2,4},{1,3,5},{3,3,3},{2,4,4}}
You may have notices a progress bar during the computations. If we have a crystal with low symmetry or a very small wavelength, the process could take a little while.
A crystal with low symmetry (space group #14):
In[13]:=
ReflectionList
["OxalicAcid",1.54]//Shallow
Out[13]//Shallow=
{{0,0,2},{0,1,1},{0,2,0},{1,0,1},{1,1,0},{2,0,0},{-1,0,1},{0,1,2},{0,2,1},{1,1,1},127}
Relatively short wavelength (could take a little time):
In[14]:=
ReflectionList
["SodiumChloride",0.25]//Shallow
Out[14]//Shallow=
{{0,0,2},{1,1,1},{0,0,4},{0,2,2},{1,1,3},{0,0,6},{0,2,4},{2,2,2},{1,1,5},{1,3,3},1039}
Formatting the reflections
Once we have generated reflections, we may wish to present them in for instance a table.
Twelve random reflections with maximum index
7
:
In[15]:=
hkl=RandomChoice
ReflectionList
[5],12
Out[15]=
{{3,0,0},{-5,1,-2},{2,4,-5},{2,-1,0},{4,0,5},{3,1,-4},{2,2,3},{4,5,1},{-3,-4,-5},{-3,-1,2},{5,5,2},{-1,3,0}}
We can make formatted versions of the reflections (normal crystallographic notation) with
ToMiller
. Here the function is mapped over each reflection:
In[16]:=
miller=
MillerNotationToString
/@hkl
Out[16]=
{(300),(​
5
1
2
​),(24
5
​),(2
1
0),(405),(31
4
​),(223),(451),(​
3
4
5
​),(​
3
1
2),(552),(​
1
30)}
Let us make a table over the reflections and their corresponding Bragg angles (note: we do not care about extinct reflections at the moment):
In[17]:=
angle=
BraggAngle
["SodiumChloride",1.54,hkl]
Out[17]=
{
24.1781
°
,
48.3982
°
,
66.3248
°
,
17.7749
°
,
60.9487
°
,
44.1183
°
,
34.257
°
,
62.2247
°
,
74.8788
°
,
30.7191
°
,Undefined,
25.5774
°
}
Let us gather the data into one list, and also sort the data by increasing Bragg angle (while pushing the
Undefined
to the bottom):
In[18]:=
data=Transpose[{miller,hkl,angle}];​​data=SortBy[data,{!QuantityQ@#〚3〛,Abs@#〚3〛}&];​​​​Grid[​​Prepend[data,{"(hkl)","{h,k,l}","
θ
B
"}],Dividers{{False,True},{False,True}}]
Out[20]=
(hkl)
{h,k,l}
θ
B
(2
1
0)
{2,-1,0}
17.7749
°
(300)
{3,0,0}
24.1781
°
(​
1
30)
{-1,3,0}
25.5774
°
(​
3
1
2)
{-3,-1,2}
30.7191
°
(223)
{2,2,3}
34.257
°
(31
4
​)
{3,1,-4}
44.1183
°
(​
5
1
2
​)
{-5,1,-2}
48.3982
°
(405)
{4,0,5}
60.9487
°
(451)
{4,5,1}
62.2247
°
(24
5
​)
{2,4,-5}
66.3248
°
(​
3
4
5
​)
{-3,-4,-5}
74.8788
°
(552)
{5,5,2}
Undefined
If we want to clear the formatting of the Miller indices, we use
FromMiller
:
In[21]:=
MillerNotationToList
/@miller
Out[21]=
{{3,0,0},{-5,1,-2},{2,4,-5},{2,-1,0},{4,0,5},{3,1,-4},{2,2,3},{4,5,1},{-3,-4,-5},{-3,-1,2},{5,5,2},{-1,3,0}}
Working with formatted strings
Subscripts are made with the key combination +hyphen-minus and overbars are made by highlighting the digit character and pressing +7 followed by and underscore.

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com