MStruct¶
software/library for MicroStructure analysis by powder diffraction
Installation¶
Introduction¶
MStruct projects provides two main components:
- mstruct program for powder diffraction data refinement
- python module for either interactive or automated powder diffraction analysis
Windows, MacOS and Linux are all supported. However the level of intagration is varying. See the table below for a quick overview.
Windows | MacOS | Linux | |
---|---|---|---|
native binaries | available | - | - |
native source | ask authors | - | available |
Anaconda | available | available | available |
In short:
- Windows binaries are small (few MBs), easy to download and run but you will miss the Python module. Maybe you do not care.
- Anaconda is the most universal. You will get all MStruct features without limitations but you need to have Anaconda enviroment. Anaconda occupies around 2-3 GBs. However you may use it also for something else. You will need to compile MStruct yourself, short instructions are provided, we tested it but some issues are hard to exluclude with any effort (just try it).
- Linux native compilation will give you all features and will not use much space. Compilation process is similar to Anaconda. Use of Anaconda is still adviced mainly in order to protect your system against dirty MStruct features :-)
Installation instructions¶
Windows binaries¶
- Download the latest version of mstruct-win.zip from the Czecho-Slovak Crystallographic Server
- Unzip
- Open
mstruct-win
folder, where you can find- the program
mstruct.exe
and some configuration and example files - subdirectories
x64
andWin32
with the program for 32 or 64 bit Windows
- the program
- Double click
mstruct.exe
if you get the console windows with some text the software is working
You can copy or move mstruct.exe
as you like but remeber to keep libfftw3-3.dll together with
mstruct.exe in the same directory!
Troubleshouting
If an Error Message appears with the double click
- in case libfftw3-3.dll is missing copy/overwright both
mstruct.exe
andlibfftw3-3.dll
with an appropriate pair from one ofx64
andWin32
directories. Do not mix the pairs! - in case MSVCP140.dll is missing you need a set of Microsoft runtime libraries (so called Microsoft Visual C++ 2017 Redistributable). It is not a compiler! You can get a version for your system for free from Microsoft support web. (x86=Win32, x64=Win64)
Obtaining source¶
MStruct is a free open source software. The source code can be obtained from the public MSTRUCT GitHub repo.
# clone it
git clone https://github.com/xray-group/mstruct.git
# or download as zip, manually: top right green button
Compiling with Anaconda¶
Installing Anaconda¶
Anaconda is a popular Python data science platform and scientific software for personal computers with Windows, MacOS or Linux.
The most straighforward way is to get a graphical installer
- no need to sign (web download)
- administrative rights not required for a personal installation
- no need to add to PATH (installation option)
- preferred choice to Register Anaconda as a system Python (installation option), good choice if you do not have any or do not care
Anaconda Navigator in Windows menu:
Anaconda Navigator in Windows menu
Creating Anaconda environment with name=’mst’:
Creating Anaconda environment
Activating Anaconda environment name=’mst’:
Activating Anaconda environment
Installing sw in Conda environment:
Installing sw with Anaconda
Windows with Anaconda¶
For Windows Python3 (x64) is strongly adviced!
# add 'conda-forge' channel
conda config --add channels conda-forge
# install required packages
# not there was (June 2018) a bug in boost-1.67 for Windows
conda install boost=1.66 lapack fftw gsl scons bzip2 git
# git clone or download ZIP
# git clone https://github.com/xray-group/mstruct.git
# wget https://github.com/xray-group/mstruct/archive/r0.15.zip
# swith to project directory
cd mstruct/libmstruct
# set prefix path %P% where your Anaconda environment is installed
# do not forget the name='mst' at the end
set P=C:/..../Anaconda3/envs/mst
# alternatively
set P=conda info --json | grep default_prefix | cut -d '"' -f4
# set environment variables
set CPPPATH=%P%/Library/include;%P%/include
set LIBRARY_PATH=%P%/libs;%P%/Library/lib
# build and install everything
scons -j4 install prefix=%P%/Library modulepath=%P%/Lib/site-packages
Test
# type "mstruct"
mstruct
# you should see text (CTRL+C to exit)
Beginning program ....
job type (0-data refinement,1-grid refinement)
MacOS with Conda¶
# setup environment, e.g. name='mst'
# see instructions using Anaconda Navigator for Windows
# or cmd-line instruction for Linux
# activate environment name='mst'
source activate mst
# install required packages
conda install boost lapack fftw gsl scons bzip2
# resolve the prefix directory P of the active Anaconda environment
P="$(conda info --json | grep default_prefix | cut -d\" -f4)"
# use it to setup environment variables
export CPPPATH=$P/include
export LIBRARY_PATH=$P/lib
export LDFLAGS=-Wl,-rpath,$P/lib
# git clone or download ZIP
# git clone https://github.com/xray-group/mstruct.git
# wget https://github.com/xray-group/mstruct/archive/r0.15.zip
# swith to project directory
cd mstruct/libmstruct
# build library
scons -j4 libmstruct
# build mstruct
scons -j4 mstruct
# (optional) build and install everything
scons -j4 install prefix=$P
Test
# type "mstruct"
mstruct
# you should see text (CTRL+C to exit)
Beginning program ....
job type (0-data refinement,1-grid refinement)
Note unfortunatelly you need to set the LD_LIBRARY_PATH
every time you activate
the environment.
Linux with Conda¶
# (optional block)
# ----------------
# see installed environments
conda info --envs
# setting up an evironment name='mst'
conda create -n mst
# activating evironment name='mst'
source activate mst
# gls, fftw3, lapack, scons are required
conda install -c conda-forge boost=1.72 lapack fftw gsl scons bzip2
# note:
# - check if you like the python version and if it is consitent across the packages
# - prefer builds that are close to your current environment
# get source, git-clone or download and unpack the source
git clone https://github.com/xray-group/mstruct.git
# swith to project directory
cd mstruct/libmstruct
# resolve the prefix directory P of the active Anaconda environment
P="$(conda info --json | grep default_prefix | cut -d\" -f4)"
export CPPPATH=$P/include
export LIBRARY_PATH=$P/lib
export LD_LIBRARY_PATH=$P/lib
# build library
scons -j4 libmstruct
# build mstruct
scons -j4 mstruct
# (optional) build and install everything
scons -j4 install prefix=$P
Test
# type "mstruct"
mstruct
# you should see text (CTRL+C to exit)
Beginning program ....
job type (0-data refinement,1-grid refinement)
P="$(conda info --json | grep default_prefix | cut -d\" -f4)"
export LD_LIBRARY_PATH=$P/lib
Conda tips and tricks¶
tricks from Honza
Linux native compilation¶
# (optional) gls, fftw3, lapack, python and scons are required
sudo apt-get install libgsl-dev fftw3-dev liblapack-dev python-dev scons
# (optional) boost>=1.63 is required, we may want to use a specific one
export B=~/sw/boost_1_67_0
export CPPPATH=$B/include:$CPPPATH/
export LIBRARY_PATH=$B/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=$B/lib:$LD_LIBRARY_PATH
# (optional) prepare user env for installation (define prefix)
export P=~/.local
# (optional) make sure we have place for python modules
mkdir -p $P/lib/python2.7/site-packages
# build library
scons -j4 libmstruct
# build mstruct
scons -j4 mstruct
# (optional) build and install everything
scons -j4 install prefix=$P
# (optional) we may want to activate the installation
export PATH=$P/bin:$PATH
export PYTHONPATH=$P/lib/python2.7/site-packages:$PYTHONATH
export LD_LIBRARY_PATH=$P/lib:$LD_LIBRARY_PATH
Test
# type "mstruct" (if you activated the installation as indicated above)
mstruct
# you should see text (CTRL+C to exit)
Beginning program ....
job type (0-data refinement,1-grid refinement)
Text editors¶
some advices to text editors
Plotting tools¶
links to plotting tools
Course - Struktura 2018¶
Instructions¶
You should have mstruct
binary running on your laptop. It should be pretty straighforward
for Windows, unfortunately for MacOS or Linux you need to compile the source. No stress in
case you fail, we will make it working at the beginning of the course.
Time plan¶
- Mon June 18, 2018, 20:00 - 21:30. Real structure analysis: The basics (Zdenek)
- Nanocrystallie TiO2 powders for catalytic applications: spherical crystallites, crystallite size distribution, isotropic phenomenological microstrain, crystal structure parameters, quantitative phase analysis
- Residual stress in thin TiO2 films: residual stress and refraction correction
- Tue June 19, 2018, 17:10 - 19:40. Challenging samples: Advanced analysis (Milan)
- Ultrathin Pt nanocrystalline films: refraction correction, thin film correction, microstrain, stacking faults
- Copper-Gold nano-spheres: Using individual peak parameters with instrumental correction
- Wed June 20, 2018, 17:30 - 19:30. (optional): Hands on own data (Milan, Zdenek)
- Thu June 20, 2018, 14:00 –. (optional): Individual discussions (Zdenek)
- amorphous content determination
- texture