-
Notifications
You must be signed in to change notification settings - Fork 7
Unit testing
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.
The testing suite consists of a variety of materials of different properties:
-
copper metal: because copper
-
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.
-
uraninite, UO2: this is an f-electron system
-
zircon, ZrSiO4: this has Si, a tender energy absorber, with a 4d backscatterer
-
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.
-
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
-
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).
For each material, the following tests are made:
-
Does Feff run to completion for the given input file?
-
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? -
For each of the
feffNNNN.dat
files, does Larch import it and construct chi(k) the same as the baseline? -
Are muffin tin and norman radii of the unique potentials the same as in the baseline?
-
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?
-
Is S02 calculated the same as in the baseline calculation?
-
Does a fit to EXAFS data produce identical fitting and statistical results as with the baseline calculation?
-
Are all of those tests passed for non-self-consistent and self-consistent calculations of the potentials?
At all times, all tests must pass.
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"
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.