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
Importing crystal data
Storing crystal data
Importing data from CIF files
Importing data manually
​
In order to make use of the basic functions in this package, some basic input is required, such as lattice parameters, space group and atom positions. In this tutorial, we will learn how to import the relevant crystallographic information to Mathematica automatically from cif files.
The package must be loaded:
In[1]:=
Needs["StianRamsnes`MaXrd`"]
$CrystalData
contains all crystal data entries
ExportCrystalData
deletes data – currently only to a DISCUS format
ImportCrystalData
imports data form cif files into Mathematica
Functions related to crystal/compound data.
Storing crystal data
In this package, crystal data is by default stored in the file:
MaXrd ▶ Kernel ▶ Data ▶ UserData ▶ CrystalData.m
Under each data entry, or crystal, we find the following relevant information:
◼
Chemical formula
◼
Space group
◼
Lattice parameters
◼
Wavelength (may be omitted)
◼
Atom data (element, occupation factor, fractional coordinates, displacement parameters)
All this information is stored as an
Association
in the Wolfram Language. See The association structure of crystallographic data tutorial if you are unfamiliar with this construct.
When the MaXrd package is loaded, the mentioned file is loaded and the symbol
$CrystalData
is assigned for the association within.
In[2]:=
?
$CrystalData
Out[2]=
Some example crystal data is included in the package, i.e. the file CrystalData.m contains some entries already.
Example entry in
$CrystalData
:
In[3]:=
data=
$CrystalData
["GalliumArsenide"]
Out[3]=
ChemicalFormulaGaAs,FormulaUnits4,SpaceGroupF
4
3m,LatticeParametersa
5.6534
Å
,b
5.6534
Å
,c
5.6534
Å
,α
90
°
,β
90
°
,γ
90
°
,AtomDataElementGa,OccupationFactor1.,FractionalCoordinates{0,0,0},DisplacementParameters0.631,TypeBiso,ElementAs,OccupationFactor1.,FractionalCoordinates
1
4
,
1
4
,
1
4
,DisplacementParameters0.679,TypeBiso,NotesInformation{West}
We can use the
Dataset
function to get a better and dynamic overview:
In[4]:=
Dataset@data
Out[4]=
An overview of all entries:
In[5]:=
MulticolumnKeys@
$CrystalData
,3
Out[5]=
Aluminium
Germanium
Polonium
Austenite
Glycyl-L-alanine
PrussianBlue
CalciumFluoride
Ice
Quartz
Cobalt(II)Fluoride
LanthanumHexaboride
Silicon
Copper
LithiumCobaltate
Silver
CopperTungstenOxide
LithiumManganesePhosphate
Sodalite
Corundum
ManganeseSilicon
SodiumChloride
Diamond
Nickel
Sphalerite
Ferrite
OxalicAcid
Tungsten
GalliumArsenide
Perovskite
Zinc
To see how we may put this data into use, see Performing calculations on crystal data. Alternatively, continue to the next section to learn how to import crystal data to Mathematica.
Importing data manually
Data on crystals is imported to Mathematica through the function called
ImportCrystalData
.
There are two ways to enter the data manually:
◼
Arrange all information in a list/pattern specified by the signature of the
ImportCrystalData
function
◼
Execute
ImportCrystalData
[]
and fill in the information in the dialogue window that appears.
In essence, the second method and automatic method that will be elaborated in the next section, just organise the same information and feeds it into the “main” function.
The labels and expected values should be evident. A worked example using this method is available on the the function's documentation page; no more details will be given here.
Importing data from CIF files
Although «manual» input is an option, the function
ImportCrystalData
is built for automatic import in mind.
The
Crystallography Open Database
can be used to find cif files for testing purposes. We will be using a random cif file from that site in this demonstration; the actual file is found in:
MaXrd ▶ Kernel ▶ Data ▶ ExampleFiles ▶ CIF ▶ COD_2203515.cif
First we need the file path. You can also use the menu in Mathematica: Insert ▶ File Path…
In[1]:=
filepath=FileNameJoin
$MaXrdPath
,"Resources","ExampleFiles","CIF","COD_2203515.cif";
Next we simply use the
ImportCrystalData
function:
In[2]:=
?
ImportCrystalData
Out[2]=
In[3]:=
ImportCrystalData
[filepath]
Out[3]=
ChemicalFormulaCCaFK
O
3
,FormulaUnits1,SpaceGroupP
6
m2,LatticeParametersa
5.10093
Å
,b
5.10093
Å
,c
4.4551
Å
,α
90
°
,β
90
°
,γ
120
°
,AtomData{5}
Data on the crystal is now stored under
"TutorialData"
in
$CrystalData
, since we did not specify a
label
. If we wanted another name, for instance
"My test crystal"
, we would write:
In[4]:=
ImportCrystalData
[filepath,"My test crystal"]
Out[4]=
ChemicalFormulaCCaFK
O
3
,FormulaUnits1,SpaceGroupP
6
m2,LatticeParametersa
5.10093
Å
,b
5.10093
Å
,c
4.4551
Å
,α
90
°
,β
90
°
,γ
120
°
,AtomData{5}
Look up the newly added crystal:
In[5]:=
$CrystalData
["My test crystal"]
Out[5]=
ChemicalFormulaCCaFK
O
3
,FormulaUnits1,SpaceGroupP
6
m2,LatticeParametersa
5.10093
Å
,b
5.10093
Å
,c
4.4551
Å
,α
90
°
,β
90
°
,γ
120
°
,AtomData{ElementK,FractionalCoordinates{0,0,0},DisplacementParameters0.0126,TypeUiso,ElementC,FractionalCoordinates{0.66667,0.33333,0.5},DisplacementParameters0.018,TypeUiso,ElementCa,FractionalCoordinates{0.33333,0.66667,0.5},DisplacementParameters0.01,TypeUiso,ElementO,FractionalCoordinates{0.812,0.188,0.5},DisplacementParameters0.0129,TypeUiso,ElementF,FractionalCoordinates{0.33333,0.66667,0},DisplacementParameters0.0196,TypeUiso}
The
Dataset
function can sometimes give a better overview:
In[6]:=
$CrystalData
["My test crystal"]//Dataset
Out[6]=
Applications of this kind of data is covered in other tutorials. The imported data is stored in the CrystalData.m file and thus kept even after Mathematica shuts down or the kernel is quit. The user may also specify a custom file to store the data in, but more about this can be read in the documentation on
ImportCrystalData
.
​
​
""

© 2025 Wolfram. All rights reserved.

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