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
Basic computations
Unit cell volume
Distance between two points (bond distances)
Conversion from crystal to Cartesian coordinates
​
In introductory classes in crystallography and material science we find topics such as crystal lattice and -systems, unit cell and Miller indices. In this tutorial we will familiarise ourselves with functionalities of this package by working with these basic topics. See the box below for an overview of relevant functions.
The package must be loaded:
In[1]:=
<<MaXrd`
BraggAngle
calculates the Bragg angle for a given wavelength and reflection
CrystalDensity
calculates the theoretical density of a crystal
GetCrystalMetric
returns the metric
G
of a crystal
InterplanarSpacing
calculates
d
hkl
of a given crystal and reflection
GetLatticeParameters
returns the lattice parameters of a crystal
Relevant functions for basic crystallographic computations.
Unit cell volume
The unit cell volume can be found by taking the square-root of the determinant of the metric matrix.
First we find the metric matrix with
CrystalMetric
:
In[2]:=
G=
GetCrystalMetric
["Silicon"];
The unit cell volume of silicon is found by taking the square-root of the determinant (units:
3
Å
):
In[3]:=
Sqrt@Det@G
Out[3]=
160.181
Another formula for the volume is given by
V=abc
1-
2
cos
α-
2
cos
β-
2
cos
γ+2cosαcosβcosγ
. Let us use this to find the volume of the corundum unit cell.
We need the lattice parameters of corundum. One way to do this is by using the
GetLatticeParameters
function:
In[4]:=
lattice=Thread{a,b,c,α,β,γ}
GetLatticeParameters
["Corundum","Units"True]
Out[4]=
a
4.76094
Å
,b
4.76094
Å
,c
12.9662
Å
,α
90
°
,β
90
°
,γ
120
°

Substituting values into the volume formula:
In[5]:=
V=abc
1-
2
Cos[α]
-
2
Cos[β]
-
2
Cos[γ]
+2Cos[α]Cos[β]Cos[γ]
/.lattice
Out[5]=
254.524
3
Å
Conversion from crystal to Cartesian coordinates
Data on crystals are stored in
$CrystalData
. Let us look at corundum (
Al
2
O
3
) in this example.
The two atoms,
Al
and
O
, have fractional coordinates:
In[6]:=
coords=
$CrystalData
"Corundum","AtomData",All,"FractionalCoordinates"
Out[6]=
{0.,0.,0.352105},0.30626,0.30626,
1
4

We want to use the standard orthogonal unit vectors instead of the crystallographic vectors. In introductory books we may find the following transformation matrix:
In[7]:=
P=
$TransformationMatrices
["CrystallographicToCartesian"];P//MatrixForm
Out[7]//MatrixForm=
a
bCos[γ]
cCos[β]
0
bSin[γ]
c(Cos[α]-Cos[β]Cos[γ])Csc[γ]
0
0
c
1-
2
Cos[β]
-
2
(Cos[α]-Cos[β]Cos[γ])
2
Csc[γ]
Next we want to insert the lattice parameters for this particular crystal.
In[8]:=
lattice=Thread{a,b,c,α,β,γ}
GetLatticeParameters
["Corundum","Units"True]
Out[8]=
a
4.76094
Å
,b
4.76094
Å
,c
12.9662
Å
,α
90
°
,β
90
°
,γ
120
°

Then we overwrite the matrix
P
with these values:
In[9]:=
P=QuantityMagnitude[P/.lattice];​​P//MatrixForm
Out[10]//MatrixForm=
4.76094
-2.38047
0.
0
4.12309
0.
0
0
12.9662
The new coordinates for the
Al
atom:
In[11]:=
P.coords〚1〛
Out[11]=
{0.,0.,4.56546}
The new coordinates for the
O
atom:
In[12]:=
P.coords〚2〛
Out[12]=
{0.729043,1.26274,3.24155}
Alternatively, we can perform the computations as follows:
In[13]:=
P.#&/@coords
Out[13]=
{{0.,0.,4.56546},{0.729043,1.26274,3.24155}}
Distance between two points (bond distances)
In the previous section we found the Cartesian coordinates of two atoms:
In[14]:=
xyzAlCart={0,0,4.56546};​​xyzOCart={0.729043,1.26274,3.24155};
Since we are now using an orthonormal basis, the distance between them is found with the Pythagorean theorem:
In[16]:=
dist=Sqrt@Total[
2
(xyzAlCart-xyzOCart)
]
Out[16]=
1.96946
alternatively by using:
In[17]:=
dist=EuclideanDistance[xyzAlCart,xyzOCart]
Out[17]=
1.96946
A more direct approach is to use the metric matrix directly:
The metric matrix:
In[18]:=
G=
GetCrystalMetric
["Corundum"]
Out[18]=
{{22.6665,-11.3333,0.},{-11.3333,22.6665,0.},{0.,0.,168.122}}
The coordinates (in the crystal system):
In[19]:=
{xyzAl,xyzO}=
$CrystalData
"Corundum","AtomData",All,"FractionalCoordinates"
Out[19]=
{0.,0.,0.352105},0.30626,0.30626,
1
4

The distance between them:
In[20]:=
dist=
d.G.d
/.dxyzAl-xyzO
Out[20]=
1.96946
​
​
""

© 2025 Wolfram. All rights reserved.

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