0% found this document useful (0 votes)
51 views8 pages

2013jac Gsasii

The newly developed GSAS-II software is a general purpose package for data reduction, structure solution and structure refinement that can be used with both single-crystal and powder diffraction data from both neutron and X-ray sources, including laboratory and synchrotron sources, collected on both twoand one-dimensional detectors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views8 pages

2013jac Gsasii

The newly developed GSAS-II software is a general purpose package for data reduction, structure solution and structure refinement that can be used with both single-crystal and powder diffraction data from both neutron and X-ray sources, including laboratory and synchrotron sources, collected on both twoand one-dimensional detectors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

See discussions, stats, and author profiles for this publication at: [Link]

net/publication/287483981

General structure analysis system - GSAS/EXPGUI

Article · January 1994

CITATIONS READS

2,141 3,027

3 authors, including:

Brian Toby
Argonne National Laboratory
223 PUBLICATIONS 24,191 CITATIONS

SEE PROFILE

All content following this page was uploaded by Brian Toby on 04 May 2021.

The user has requested enhancement of the downloaded file.


electronic reprint
Journal of
Applied
Crystallography
ISSN 0021-8898
Editor: Anke R. Kaysser-Pyzalla

GSAS-II : the genesis of a modern open-source all purpose


crystallography software package

Brian H. Toby and Robert B. Von Dreele

J. Appl. Cryst. (2013). 46, 544–549

Copyright 
c International Union of Crystallography
Author(s) of this paper may load this reprint on their own web site or institutional repository provided that
this cover page is retained. Republication of this article or its storage in electronic databases other than as
specified above is not permitted without prior permission in writing from the IUCr.
For further information see [Link]

Journal of Applied Crystallography covers a wide range of crystallographic topics from


the viewpoints of both techniques and theory. The journal presents papers on the applica-
tion of crystallographic techniques and on the related apparatus and computer software.
For many years, the Journal of Applied Crystallography has been the main vehicle for
the publication of small-angle scattering papers and powder diffraction techniques. The
journal is the primary place where crystallographic computer program information is
published.

Crystallography Journals Online is available from [Link]


J. Appl. Cryst. (2013). 46, 544–549 Toby and Von Dreele · GSAS-II
computer programs
Journal of
Applied
GSAS-II: the genesis of a modern open-source all
Crystallography purpose crystallography software package
ISSN 0021-8898

Brian H. Toby and Robert B. Von Dreele*


Received 15 October 2012
Accepted 4 February 2013
Advanced Photon Source, Argonne National Laboratory, 9700 South Cass Avenue, Argonne, IL 60439-4814,
USA. Correspondence e-mail: vondreele@[Link]

The newly developed GSAS-II software is a general purpose package for data
reduction, structure solution and structure refinement that can be used with
both single-crystal and powder diffraction data from both neutron and X-ray
sources, including laboratory and synchrotron sources, collected on both two-
and one-dimensional detectors. It is intended that GSAS-II will eventually
replace both the GSAS and the EXPGUI packages, as well as many other
utilities. GSAS-II is open source and is written largely in object-oriented Python
but offers speeds comparable to compiled code because of its reliance on the
Python NumPy and SciPy packages for computation. It runs on all common
computer platforms and offers highly integrated graphics, both for a user
interface and for interpretation of parameters. The package can be applied to all
# 2013 International Union of Crystallography stages of crystallographic analysis for constant-wavelength X-ray and neutron
Printed in Singapore – all rights reserved data. Plans for considerable additional development are discussed.

1. Introduction incorporating many aspects of the previous packages’ strengths. This


For the past 60 years crystallographers have depended on computer project was further motivated by the need for a single software
software to perform increasingly sophisticated crystallographic package that encompasses every aspect of the crystallographic
calculations. In the earlier days, it was common to use a program from workflow, particularly for powder diffraction, starting with data
one source to solve a crystal structure, one from a different source for reduction through to the domain of GSAS and similar packages. As
refinement, another for distance–angle and error analysis and so on. GSAS-II has been developed, the advantages of code development in
Over time it has become more common to use crystallographic a graphics-rich environment have become clear. Not only is design of
packages that contain programs for completion of multiple steps in an easy to understand and efficient graphical user interface (GUI) a
the structure determination process. This made the life of the crys- central development task, but the availability of excellent graphics
tallographer easier, in that integration inherent in a package allowed tools allows visualization of results to also be a key initial design goal.
information to flow smoothly through the work process and lessened Finally, it should be noted that the practice of crystallography has
the learning investment needed to master the individual steps. changed in the past few decades: the codes developed a half-century
Beginning in the 1980s, the General Structure and Analysis System ago were written by expert crystallographers for themselves and their
(GSAS) crystallographic package was developed to address all peers. Nowadays, crystallographic analyses are commonly performed
aspects of crystallographic refinement and subsequent structural as one part of a research investigation, often by scientists with
analysis for all types of X-ray and neutron diffraction data, from both considerably less education in crystallography. New tools must thus
constant-wavelength and time-of-flight instrumentation and including adapt, and as such GSAS-II is designed to lower the barriers
both powder and single-crystal studies, possibly in combination experienced by new users.
(Larson & Von Dreele, 2004). GSAS was the first comprehensive
package of its type, and the only one that addresses needs for
structures of all complexity, including proteins. However, GSAS did 2. GSAS-II programming environment
not address pre-refinement tasks, such as indexing powder data or Modern software is written in a variety of programming languages,
structure solution. Newer packages, such as FullProf, TOPAS and including object-oriented languages, such as C++ and Fortran2003,
Jana, have included a wider range of structure determination tools which are compiled and linked into processor- and operating-system-
(Rodrı́guez-Carvajal, 1993; Petricek et al., 2006; Coelho, 2007). dependent executable images; another choice is a virtual-machine
The authors of this article have long been involved with the GSAS (VM) language, most commonly Java, which is compiled into a
package and its companion interface EXPGUI (Toby, 2001). The two machine-independent form; the third choice is scripting languages,
codes are very widely used, with hundreds of new citations each year. such as JavaScript, Perl or Python, which are interpreted at the time
However, it has become clear that it has been increasingly more of execution. Each choice has advantages, in that codes written in
difficult to advance their capabilities, since they are built with older compiled languages usually run fastest, while virtual-machine codes
programming languages and designs that are far less efficient for code tend to be most portable and easy to distribute but will be less
development, code reuse and utilization of contemporary graphical computationally efficient. Scripting languages usually allow for the
capabilities than would be desired (Toby & Von Dreele, 2007). For most rapid code development. Since it is interpreted at the time of
these reasons, it was decided to create a new package, called GSAS-II execution rather than compiled, usually the same code will run on a
and described herein, utilizing a new programming environment and variety of platforms but may be computationally inefficient.

544 doi:10.1107/S0021889813003531 J. Appl. Cryst. (2013). 46, 544–549


electronic reprint
computer programs
However, as will be discussed, with care it is possible to create Python Together they allow Python to offer a sophisticated data structure for
script code that runs as fast as carefully written compiled code where numerical processing and many valuable routines for computation.
speed matters. Most routines operate at speeds comparable to those of highly
Distribution of both VM and script-based programs requires optimized C, C++ or Fortran code, which allows most GSAS-II
installation of additional software that runs the VM or script inter- computations to run very efficiently.
preter. In the case of a scripting language, this interpreter can be a (2) wxPython ([Link] is a Python interface to
fairly massive set of software. However, this interpreter allows for the platform-independent wxWidgets GUI package. It offers a wealth
code to be revised locally, as it is interpreted when the program is of graphical primitives that are implemented with the native ‘look-
started. An example of how this can introduce new capabilities is and-feel’ of the underlying platform. Thus GSAS-II will behave like a
described below when discussing GSAS-II data import support. Windows application on that platform, but will behave more like a
The Python programming language was selected for GSAS-II, as it Mac application on that platform.
is one of the most modern and it has a wealth of available packages (3) matplotlib ([Link] is a two/three-dimen-
that further augment the native features of the language. Further- sional plotting library for scientific graphics. It allows for quite
more, we have found that code written in Python is quite portable sophisticated on-screen and publication-quality graphics. GSAS-II
between Windows, Mac OS X and Linux platforms. In the few rare plots are ‘zoomable’ for examination of details and can be exported
cases where sections of GSAS-II are found to run differently between in common graphical file formats.
platforms, the cause is usually a subtle programming error that, when (4) PyOpenGL ([Link] is a binding of
corrected, addresses the incompatibility. Efficiency of code execution the three-dimensional OpenGL graphics language. It is used in
in Python has not posed much of a challenge either. For the vast GSAS-II for rotatable three-dimensional display of crystal structures
majority of the code in GSAS-II, speed of execution is of little import. and superimposed Fourier maps.
It does not matter if a screen is repainted in 10 or 100 ms after a These packages were selected on the basis of the maturity and
button is pressed, since a user will take seconds to see the change and power offered by each. The requirement for inclusion of these
respond. As will be discussed later, algebraic computations can be additional packages produces a disadvantage in code distribution, as
very quick in Python, but in the few cases where we were unable to one must install both Python and these packages before GSAS-II can
perform computations sufficiently quickly in Python, we have written be used. However, Python and all but one of the selected packages
short Python-wrapped Fortran subroutines that are compiled and are can be installed via a single download for all common computers
called from Python modules. This was also done in the case of the using the ‘EPD Free’ Python package that Enthought Inc. distributes
NRCVAX/GSAS group symmetry analysis code written by Allen at no cost ([Link] Py-
Larson for space group operator derivation, as it was found to be very OpenGL is not included in EPD Free, but the distribution files for
difficult to port to Python. GSAS-II include the installation package for PyOpenGL. When
Python contains a large number of standard packages, but in GSAS-II is first started, if PyOpenGL is not present, it is then
addition there are a very large number of add-on packages, which are installed automatically.
distributed by external groups, that further augment the power of the It should be noted that there are currently two generations of the
computational environment. A small number of these packages are Python language, versions 2.x and 3.x, which differ slightly. GSAS-II
used in the GSAS-II code: uses the 2.x generation syntax, since not all of the required packages
(1) NumPy and SciPy ([Link] While the origins of have yet been adapted for 3.x. When all packages required by GSAS-
these packages are separate, their development is now integrated. II have been shown to work reliably in Python 3.x, and suitable
distributions are available, then it is
expected that an update to 3.x can be
accomplished quickly.

3. GSAS-II GUI design


GSAS-II uses four distinct windows for
operation (Fig. 1). The main window shows
the contents of the current project or
workspace in hierarchical (tree or outline)
format. At the base level of the tree, there
are a number of entries for overall project
settings, plus a base-level entry for struc-
tural phase(s), and another base-level entry
is added for each data set as it is entered.
Each phase is represented by a subentry
under the Phases base-level entry. Note
that there is no limit to the number of
phases or data sets that can be included in a
project and any phase or data set may be
deleted from the project. For each data set’s
base-level entry in the data tree, there are a
Figure 1 number of subentries for background para-
A screen shot of the four GSAS-II windows. The GSAS-II data tree window is in the upper right, the data window
is below it, the plot window showing the crystal structure corresponding to the atom coordinates shown in the data meters, instrumental parameters, sample
window is to the left, and the GSAS-II console window is largely obscured behind the plot window. parameters etc. Associated with the data

J. Appl. Cryst. (2013). 46, 544–549 Toby and Von Dreele  GSAS-II 545
electronic reprint
computer programs
tree window is a menu bar with entries for global operations on the A calibration data set may be read in along with any number of
entire project (e.g. input/output of data, phases and refinement). experimental data sets. Calibration is completed by indicating a
The second window is for display and editing of parameters. The choice for the standard, specifying the X-ray wavelength, and then
content of this window is determined by the item selected in the data selecting five or more points on the first diffraction ring with the
tree window. On Windows and Linux, this window also has a menu mouse. A calibration refinement is then completed in a few seconds.
bar with menu items specific to the type of data contained in the The resulting calibration constants can be copied to all the experi-
window, but on a Macintosh, where the system design allows only one mental data sets in the project in a single step or can be saved for use
menu bar to be displayed, all menus are combined into a single menu in a different project. Once calibration is complete, all images read
that is displayed in the customary way for that platform. into a project can be integrated in a single step.
The third window is used for display of two- and three-dimensional Most area detector data formats that have been encountered from
graphics. Many of the project tree items have an associated graphics devices and software at the APS have used variants of the TIFF
display; each is shown in its own tab on the plot window and one can format, many with incomplete or incorrect headers. Input routines
switch tabs at will to view any of the generated plots. Thus, if a have been constructed to recognize and read these formats, filling in
powder data set is selected, the pattern (or all patterns) is plotted the missing or incorrect data. In addition, GSAS-II will read MAR,
here. Likewise, if the entry for parameter covariance is selected, the ADSC and GE format files. Files can be read from inside zip archives.
covariance matrix is displayed graphically in this window but in a
separate tab from the powder one. Selecting a data set’s instrumental 4.2. Data input
parameters creates a plot of peak widths (as d/d) against 2 or Q, Import of structural parameters, one-dimensional powder diffrac-
etc. Different options for a phase’s atomic parameters allow plotting tion data and single-crystal data sets is performed via a generalized
of the structure in a variety of formats. Selection of texture para- object-oriented layer that is self-configuring on the basis of the data
meters causes plotting of a pole figure or its inverse. In all cases the import routine files that are found when GSAS-II is started. These
plot may be saved in a format (e.g. BMP, TIFF, JPEG etc.) appropriate files are identified by their names. This allows for support of addi-
for inclusion in other documents (e.g. pasted into a Microsoft Word tional formats through inclusion of new Python routines, without any
document). other changes to the code. A data import routine may be as short as
The fourth window is a console window. This shows status and 30 lines of code. Experience with a similar capability in EXPGUI and
error messages from GSAS-II. It is used only for output. All user other code has shown that users with modest programming skills are
input is provided in the data window or in pop-up dialog boxes; the well able to add support via new input routines for previously
user never types any input into the console. However, one can, by unsupported file formats by using the supplied import routines as
using operating-system-specific commands, select and copy text from examples. The base data import class provides the ability to extract
this window and paste it elsewhere (e.g. an open text editor window). and read data files that are inside zip archives, so this capability is
automatically provided for any new formats that may be added.
GSAS-II currently supports the same input file formats as GSAS
4. GSAS-II capabilities
for powder diffraction and single-crystal data and can import struc-
The capabilities of GSAS-II as of this writing are described in the tural data from GSAS experiment (.EXP) files. TOPAS powder data
following paragraphs. A later section describes some anticipated files are also supported. In addition, structures and diffraction data
future additions. can be imported from a CIF, through use of the pyCIFRW library
(Hester, 2006), which is redistributed with GSAS-II.
4.1. Area detector data reduction
Powder diffraction data are being collected increasingly with area 4.3. Peak fitting
detectors. Area detector data sets can be collected in a fraction of a GSAS-II allows fitting of the diffraction peaks in a selected region
second, improve crystallite sampling statistics with grainy samples of a pattern, where peak positions are not constrained by lattice
and reduce (or help quantify) preferred orientation. When data are constants and can be refined independently. Use is made of the
collected with an area detector, one must calibrate the positioning of familiar description of an axial-divergence-broadened (Finger et al.,
the detector so that every pixel on the detector can be mapped to a 1994) pseudo-Voigt (Thompson et al., 1987) powder peak profile
known 2 and azimuthal angle. Measurement of the diffraction function; this is implemented via a modification of the Fortran code
pattern from a standard with known peak positions allows calibra- used in GSAS. The Gaussian and Lorentzian widths for each fitted
tion. From this measurement, the distance from the sample to the peak may be refined individually or can be constrained by profile
detector, the relative position of the beam center, and the tilt angles equations with refined parameters (e.g. U, V, W, X, Y). The latter
between the X-ray beam and the detector normal are determined. mode is usually preferred because it results in better peak positions
Once the calibration constants are known, data can be integrated for highly overlapped peaks for which refinement of individual
around the Bragg rings, using either ranges of azimuthal angles or all profiles would be difficult.
observed pixels subject to optional masking to remove unwanted
features. Software for this process has been available for many years 4.4. Indexing
(e.g. Fit2D; Hammersley, 1998). GSAS-II also performs these Powder pattern indexing is available using a minor variation of the
operations but improves upon this process by treating the projection method of Coelho (2003); it can treat any Laue symmetry and is not
of a Bragg cone rigorously, even when the detector is considerably bound by unit-cell size.
tilted from the normal to the X-ray beam. GSAS-II also simplifies the
calibration and integration process, even when the incident beam is 4.5. Intensity extraction
not projected onto the face of the area detector. Furthermore, the When the unit cell(s) for a powder refinement are assigned, it is
integration result is immediately available within GSAS-II for further possible to perform a Pawley (1981) intensity extraction. This is
processing (e.g. peak picking/fitting, indexing and Rietveld refine- similar to a Rietveld fit, except that reflection structure factors are
ment). treated as refined variables. Highly overlapped reflections are

546 Toby and Von Dreele  GSAS-II J. Appl. Cryst. (2013). 46, 544–549
electronic reprint
computer programs
combined via automatic constraints, partitioning the intensity equally The resulting charge-flip density map has an arbitrarily placed
amongst the contributors; restraints to prevent negative intensities origin with respect to the symmetry elements for the space group. The
may optionally be used. GSAS-II code makes use of the phase angle relationships in the
charge-flip reflection set to determine the origin. Fig. 2 shows the
resulting atomic positions obtained from a charge-flip solution for
4.6. Structure solution sucrose from high-resolution powder diffraction data collected at the
The first structure solution tool to be implemented in GSAS-II is APS 11BM beamline.
the method of charge flipping (Oszlányi & Süto , 2004). This can be
used with either single-crystal structure factors or those extracted 4.7. Fourier maps
from powder data via a GSAS-II Pawley refinement or preliminary Fourier computations via NumPy fast Fourier transform (FFT)
Rietveld refinement based, for example, on a partial model. As a methods may be carried out with observed or computed structure
demonstration of the power of the NumPy package for efficient factors or their differences using the phases from the computed
coding and computation, we offer in Appendix A an annotated code structure factors. Patterson maps may also be computed. The Fourier
snippet that constitute the entire charge-flipping algorithm, as maps can be visualized by superimposing them on the atom structure
implemented in GSAS-II. A preliminary step that is not shown is to for structure completion and final verification. Rather than
expand the array of reflections to cover the entire sphere of reci- computing contours, the map is displayed using points with radius
procal space and zero fill to the limit defined by the desired map proportional to the Fourier density and with a color determined by
resolution (typically 0.5 Å); a random distribution of phases are the density sign. Users select the cutoff for the density representation
assigned to the reflections. via a slider in the appropriate GUI, and users can indicate that
In the charge-flipping algorithm, the user has the option to locations of map features should be added to the atom array as
normalize structure factors against a selected elemental form factor; positions are assigned.
their sum is then computed. The user also selects two charge-flip
controls: one is the conventional lower level of the density below 4.8. Peak-shape model
which the density is flipped in sign, and the other is an upper level GSAS-II employs the same pseudo-Voigt peak shape used for
above which the density is flipped in sign. The latter control provides single peak fits noted above. This is similar to that used in GSAS;
a means of suppressing those spurious charge-flip solutions that however, the Finger–Cox–Jephcoat (Finger et al., 1994) asymmetry
consist of a single very strong density peak (a so-called ‘uranium correction is simplified by assuming that the sample height (2S) is the
atom solution’). The entire calculation is performed in double same as the detector height (2H) and thus only a single parameter is
precision. This code snippet operates in a Python while loop. It is needed. Furthermore, in the GSAS-II formulation, there is a
cycled repeatedly until no further improvement is seen by the user. It complete decoupling of instrument broadening parameters from
should be noted that, while execution of each Python statement adds those of the sample, even though this does lead to some redundancy.
some processing overhead that might not be encountered in a However, if the instrumental parameters are determined initially
compiled language, each computation is performed via a call to the using an appropriate standard, then the refined sample terms directly
highly optimized NumPy module. Thus, since only a small number of represent physically meaningful parameters, such as sample dis-
statements are looped in each charge-flip cycle, the code runs at a placement, strain and crystallite size.
speed comparable to a Fortran or C++ implementation. The brief GSAS-II allows for refinement of two sample displacement para-
length of this code shows that it is also relatively easy to write, in meters in Debye–Scherer geometry, parallel and perpendicular to the
comparison to other languages. The computations are completed at a beam. Strain and crystallite broadening can each be expressed in
rate of 1 s per charge-flip cycle on a reasonably new Intel i5 terms of anisotropic coefficients and three-dimensional surfaces can
quadprocessor laptop running Microsoft Windows 7 with 5  105 be displayed to interpret these coefficients.
structure factors/density points. Typically a solution is found within a
minute (< 100 cycles). 4.9. PDF computation
When data are collected over a sufficiently wide Q range, it is
possible to compute in GSAS-II a pair distribution function (PDF)
from a set of X-ray diffraction data. This computation uses NumPy
FFT methods and has been simplified by combining several common
corrections into a single function with a single ad hoc correction term,
since many of these corrections have approximately the same func-
tional form. The value for this correction term can be varied via a
slider to easily minimize spurious peaks at short distances and
provide a visual sensitivity analysis to confirm that PDF features are
not influenced by these corrections. It is anticipated that there will be
additional improvements for this module.
4.10. Refinement modes
There is no limit to the number of data sets or phases that can be
included in a single GSAS-II project. When a refinement will be
performed using a large project, it is possible to perform a single
Figure 2 refinement, where all parameters are simultaneously best fit to all
A charge-flip structure solution for sucrose from powder diffraction data collected data sets. However, it is also possible to perform a sequential fit,
at 30 keV (0.41326 Å) on APS beamline 11-BM. Diffraction peak intensities to
dmin = 0.978 Å were obtained via a Pawley refinement after peak picking and where the results from the fit to the first data set are used as a starting
indexing by GSAS-II. point for the second data set, and so on.

J. Appl. Cryst. (2013). 46, 544–549 Toby and Von Dreele  GSAS-II 547
electronic reprint
computer programs
4.11. Constraints minimization, while in the case where correlation is negligible, a
GSAS-II offers constrained refinements. Constraints reduce the Gauss–Newton minimization results. The latter is better and faster at
number of refined parameters by creating formal relationships finding minima but fails for highly correlated parameters (Prince,
between parameters in the model. Most commonly, constraints are 2004). When there is complete correlation between variables, or a
applied to atomic coordinates, occupancies or displacement para- variable is found to have no impact on the model, this singularity is
meters, some of which are generated automatically from symmetry addressed by automatically removing variable(s) from the refine-
considerations, but others may be added by the user to force the ment. For this minimizer, the model computation (e.g. structure
model to comply with assumptions posed as part of the analysis (for factors and powder profiles) is separate from the derivative compu-
example, that a site is fully occupied, or that chemically similar atomic tation; this is in contrast to the methods used in older refinement code
environments are well represented by only a single value for Uiso). All (e.g. GSAS) where the function and its derivatives are computed
GSAS-II parameters may be used in constraints and, unlike GSAS, a simultaneously. In practice, we have found this implementation of the
parameter may be used in more than one constraint. Constraints may Levenberg–Marquardt minimizer succeeds on all refinements we
be applied in several ways; parameters may be equated, have attempted, even when correlation is extremely high.
The SciPy leastsq minimizer, using either supplied analytical
p1 ¼ c2 p2 ¼ c3 p3 ¼   ; ð1Þ derivatives or internally computed numerical derivatives, is also
or new composite variables can be created from a series of para- available. In that case an n  m Jacobian (or design) matrix is
meters, constructed, where n is the number of refined parameters and m is the
number of observations. For larger multiple data set problems, m can
v0 ¼ c1 p1 þ c2 p2 þ c3 p3 þ   ; ð2Þ
be greater than 106, which requires more memory than found in most
or one or more linear equations can be input to reduce the number of contemporary computers. This NumPy minimizer is based on the well
degrees of freedom in a model, trusted MINPACK ([Link] lmder and lmdif
routines, which perform well, although the numerical derivative
c0 ¼ c1 p1 þ c2 p2 þ c3 p3 þ    : ð3Þ
version (lmdif) is much slower than the analytical derivative version
In these equations, ci is a constant, pi is a parameter in the model and (lmder).
vi is a new variable that is created for the refinement. Note that, in the
latter two cases, the program creates a full set of n linear equations
for each of the n parameters contained in a set of constraints. It is the 5. Comparison with GSAS
variables created by these equations that will be varied, depending on
the settings for the parameters used in these equations. The GSAS program is used, where possible, to validate code devel-
oped for the new capabilities in GSAS-II. Where models can be
4.12. Restraints
comparably parameterized (for Rietveld and single-crystal structure
refinements), GSAS and GSAS-II give essentially identical results
Restraints can be introduced in GSAS-II on bond lengths, angles, within the limits given by the standard uncertainties for identical
planes, chiral group volumes, torsion angles and paired torsion angles. models. Minor differences in detail arise from the use of single
The latter two are implemented as a restraint on a pseudo-potential precision in Fortran77 throughout GSAS and double precision as
based on allowed values of bond torsion angles found in the literature provided by Python.
as described by Von Dreele (1999, 2005). Restraints on the sum of the
unit-cell contents (e.g. chemical composition) can also be formed.
Restraints are then implemented as additional observations in the 6. Future development
formation of the least-squares Hessian matrix as described below.
At present GSAS-II comprises 35 000 lines of Python code; we
4.13. Quantitative phase analysis envision considerable expansion to introduce new features. Export of
results via CIF and other style formats is anticipated for early
GSAS-II can readily be used for quantitative phase analysis via the development as they are essential for user publication of results from
Rietveld method for mixtures of any number of phases. Each phase in GSAS-II. Fitting to neutron time-of-flight data is currently planned,
a powder pattern is assigned a scale factor based on the unit-cell as well as inclusion of neutron magnetic scattering and support for
contents. Conversion to weight fractions, with assigned standard modulated structures. Monte Carlo simulated annealing of molecular
uncertainties, is provided as a result of the Rietveld refinement. models as an alternative structure solution technique and refinement
of rigid body descriptions for these molecules are currently under
4.14. Refinement minimizers development. The constraints module may be expanded to allow
Refinement is performed using one of three minimizers. Most users generation of parameters from fitting equations for parametric
will use the default, which is a Levenberg–Marquardt least-squares refinements or, better, parametric results may be fitted in a secondary
minimizer that has been developed for GSAS-II. For this minimizer, step to the fitted variables and their covariances.
analytic or numerical derivatives are computed for all parameters in It is our hope that, since GSAS-II is written in an open fashion, the
the model and an n  n Hessian matrix is computed, where n is the code can be used for more sophisticated structural modeling
number of refined parameters. The Hessian is then normalized by the capabilities than are available at present, as may be needed to treat
diagonal elements to avoid the effects of the extreme range of values materials with deviations from long-range ordering, or may be used
frequently encountered in a Rietveld refinement; this normalization to fit other types of data where quantitative simulation is possible
is retained for recovering the inverse and computing the solution. In from atomistic data, for example with other types of physical
the Levenberg–Marquardt algorithm the diagonal of the Hessian measurements. We also hope to explore fitting approaches to
matrix is modified to reduce the impact of correlation iteratively diffraction data where continuum models, as opposed to atomistic
when a fit is found to diverge. In the limit where this modification is ones, are used. The most obvious cases for this are reflectometry and
taken to the extreme, the refinement would occur by steepest-descent small-angle scattering. User modifications are welcome for possible

548 Toby and Von Dreele  GSAS-II J. Appl. Cryst. (2013). 46, 544–549
electronic reprint
computer programs
inclusion in the distributed version of GSAS-II through submission of Notes: (1) This computes the real density; the shift is to accom-
code, but write access to the code repository can be granted to modate the fact that the structure factor array is offset so that the
external collaborators upon request. indices are all zero or positive. CEhkl is a copy of the original
structure factors Ehkl zero filled to the resolution limit. np refers to
the NumPy package and fft to the fast Fourier transform package
7. Distribution and documentation within NumPy. (2) This computes the standard deviation of the
At present, GSAS-II is being enhanced aggressively and we expect density map. (3) This performs the charge flip when the density is less
this to continue for a period of years; changes are made on a some- than the level defined by the user. (4) This performs the charge flip
times daily basis, so it is best for users to run the latest version of the when the density is larger than a level defined by the user and thus
software. For this reason we prefer that users install the software avoids the ‘uranium atom’ problem frequently encountered in
directly using the Subversion protocol from the server at Argonne charge-flipping solutions. (5) This computes structure factors based
National Laboratory used for our development ([Link] on the modified density. The shift is used to offset the results. (6) This
[Link]/pyGSAS), so that they may update to the latest is used to avoid a potential zero divide error in the next step. (7) This
version easily and often. When the Subversion program (svn or is extracts the phase angle from the computed structure factors. (8)
[Link]) is in the program path, a help menu item allows GSAS-II to This applies the phases to the original expanded structure factors. (9)
self-update. However, the need to install Subversion and Python as This counts charge-flip cycles. (10) These last three steps compute the
prerequisites for installing GSAS-II increases the complexity of charge-flip residual using only the observed reflection set; the mask
software installation. This has been somewhat streamlined through removes those added to zero fill the array and sumE is the sum of the
provision of a download script (Mac and Linux) or an installation kit original structure factors.
for Windows, but multiple downloads are still required. When GSAS-
II development is more mature, we hope to further streamline GSAS-
II installation.
Use of the Advanced Photon Source, an Office of Science user
Documentation for GSAS-II is provided through contextual-based
facility operated for the US Department of Energy (DOE) Office of
help entries, tied to each type of GSAS-II window, and via worked-
Science by Argonne National Laboratory, was supported by the US
through tutorial examples. This documentation is included in the
DOE under contract No. DE-AC02-06CH11357. We would like to
software distribution but can also be accessed via the GSAS-II home
thank James Hester for his PyCIFRW package, which greatly
page ([Link] Installation
simplified integration of CIF support, and we thank the APS for its
instructions are provided as wiki pages referenced on the GSAS-II
continuous support of the GSAS-II Subversion server and web site/
home page.
wiki pages.
Users are also encouraged to subscribe to a mailing list (see http://
[Link]/mailman/listinfo/GSAS-II) where announcements
about software updates are posted and where users can post messages
to each other.
References
Coelho, A. A. (2003). J. Appl. Cryst. 36, 86–95.
Coelho, A. (2007). TOPAS. Bruker AXS GmbH, Karlsruhe, Germany.
APPENDIX A Finger, L. W., Cox, D. E. & Jephcoat, A. P. (1994). J. Appl. Cryst. 27, 892–900.
Hammersley, A. P. (1998). Fit2DV10.3 Reference Manual V4.0. Internal Report
Example of Python/NumPy code ESRF98HA01T. ESRF, Grenoble, France.
The following annotated example section of Python/NumPy code Hester, J. R. (2006). J. Appl. Cryst. 39, 621–625.
implements the iterated part of the charge-flipping algorithm in Larson, A. C. & Von Dreele, R. B. (2004). General Structure Analysis System
(GSAS). Los Alamos National Laboratory, New Mexico, USA.
GSAS-II. , A. (2004). Acta Cryst. A60, 134–141.
Oszlányi, G. & Süto
Pawley, G. S. (1981). J. Appl. Cryst. 14, 357–361.
Petricek, V., Dusek, M. & Palatinus, L. (2006). Jana2006. Institute of Physics,
Prague, Czech Republic.
Prince, E. (2004). Mathematical Techniques in Crystallography and Materials
Science. New York: Springer-Verlag.
Rodrı́guez-Carvajal, J. (1993). Physica B, 192, 55–69.
Thompson, P., Cox, D. E. & Hastings, J. B. (1987). J. Appl. Cryst. 20, 79–83.
Toby, B. H. (2001). J. Appl. Cryst. 34, 210–213.
Toby, B. H. & Von Dreele, R. B. (2007). IUCr Commission on Crystallographic
Computing Newsletter, No. 8, pp. 57–73
Von Dreele, R. B. (1999). J. Appl. Cryst. 32, 1084–1089.
Von Dreele, R. B. (2005). Acta Cryst. D61, 22–32.

J. Appl. Cryst. (2013). 46, 544–549 Toby and Von Dreele  GSAS-II 549
View publication stats
electronic reprint

You might also like