Skip to content
Bruce Ravel edited this page Jan 6, 2015 · 2 revisions

The feff85exafs unit testing framework

The unit testing framework lives in the tests/ directory. This location may change in the future.

The framework is implemented as a Larch plugin called f85ut.py and is intended to be run using the nose unit testing tool.

The concept of the testing framework is to compare the results of Feff calculations using the code in its current state with the results of baseline calculations run using the code in the state it was in when it was given to us by The Feff Project.

Materials:

The testing suite consists of a variety of materials of different properties:

  1. copper metal: because copper

  2. nickel oxide, NiO: this is a simple, cubic, metal oxide. It represents a problem slightly more complicated than copper metal. It also is easy to get a decent fit out to the sixth coordination shell.

  3. uraninite, UO2: this is an f-electron system

  4. zircon, ZrSiO4: this has Si, a tender energy absorber, with a 4d backscatterer

  5. bromoadamantane: this is a small molecule which can be fit with a fairly simple model of four paths, but for which the 6 nearby hydrogen scatterers play a big role in the fit.

  6. ferrocene macrocycle: this is a iron organometallic with Fe in between two 5 member carbon rings, so it has 10 C neighbors at a range of distances from 2.026 A to 2.099 A

  7. lanthanum cuprate: this is an orthorhombic crystal with the copper atom in an octahedral configuration. The oxygen atoms along the z axis are much farther away than the ones in the plane. This, then, is a test that involves Feff's polarization and ellipticity calculations. There is one folder for calculating with the incident light parallel to the z axis (polarization only) and one for light perpendicular to the z axis (polarization and ellipticity).

Tests

For each material, the following tests are made:

  1. Does Feff run to completion for the given input file?

  2. For each of the feffNNNN.dat files from the calculation, are each of the columns the same (with some small numerical variation) as when calculated in the baseline?

  3. For each of the feffNNNN.dat files, does Larch import it and construct chi(k) the same as the baseline?

  4. Are muffin tin and norman radii of the unique potentials the same as in the baseline?

  5. Are various parameters of the potential model -- edge, gam_ch, kf, mu, rs_int, and vint (see this page from the Larch document) -- the same in the baseline calculation?

  6. Is S02 calculated the same as in the baseline calculation?

  7. Does a fit to EXAFS data produce identical fitting and statistical results as with the baseline calculation?

  8. Are all of those tests passed for non-self-consistent and self-consistent calculations of the potentials?

At all times, all tests must pass.

Using the testing framework

First copy the file f85ut.py to your personal Larch plugin folder, $HOME/.larch/modules on Unix or Mac OSX or $USER\\larch\\modules on Windows.

To run the full test suite, run this command from the top directory:

~> nosetests --verbosity=3

This will run the full suite of tests, which currently number over 1400 and cover all the materials and tests discussed above.

By default (and because its a lot faster), the tests are run without self-consistent potentials. To use self-consistency in the tests, set the FEFF_TEST_SCF environment variable to True. With bash, zsh, etc:

~> export FEFF_TEST_SCF=True

With csh, tcsh, etc:

~> setenv FEFF_TEST_SCF "True"

Running tests by hand:

The individual tests run by the full testing can be run by hand. To do so, fire up larch:

~> larch
  Larch 0.9.24 (28-Oct-2014) M. Newville, T. Trainor
  using python 2.7.6, numpy 1.8.2, wx-enabled, wx version 2.8.12.1

Once larch is running, load the unit testing plugin and create a unit testing object:

larch> add_plugin('f85ut')
True
larch> a=ut('Copper')

The unit testing object points at one of subfolders beneath t/materials/. Creating the object, loads files from that folder and prepares the object to perform tests on that material.

Once you have a testing object (a in this example), you can run any of the individual tests. See the README file in the tests/ folder for a complete listing of available tests. When run interactively, many of the tests have a visual component in the form of plots of the columns of feffNNNN.dat for the test run compared to the baseline.

Clone this wiki locally