Пример #1
0
class setvarExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.val = 3.0

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when variable is undefined"""
        self.assertRaises(pdffit2.unassignedError, self.P.setvar, self.P.lat(1),
                self.val)

    def test_ValueError(self):
        """raise ValueError when a variable index does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.assertRaises(ValueError, self.P.setvar, self.P.lat(7),
                self.val)
Пример #2
0
class setvarExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.val = 3.0

    def tearDown(self):
        del self.P

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when variable is undefined"""
        self.assertRaises(pdffit2.unassignedError, self.P.setvar, self.P.lat(1),
                self.val)

    def test_ValueError(self):
        """raise ValueError when a variable index does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.assertRaises(ValueError, self.P.setvar, self.P.lat(7),
                self.val)
Пример #3
0
class getparExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()

    def tearDown(self):
        del self.P

    def test_unassignedError1(self):
        """raise pdffit2.unassignedError when parameter does not exist"""
        self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1)

    def test_unassignedError2(self):
        """raise pdffit2.unassignedError when parameter does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.constrain(self.P.lat(1), 2)
        self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1)
Пример #4
0
class getparExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()

    def tearDown(self):
        del self.P

    def test_unassignedError1(self):
        """raise pdffit2.unassignedError when parameter does not exist"""
        self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1)

    def test_unassignedError2(self):
        """raise pdffit2.unassignedError when parameter does not exist"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.constrain(self.P.lat(1), 2)
        self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1)
Пример #5
0
class save_resExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.resfile = "temp.res"

    def tearDown(self):
        del self.P

    def test_IOError(self):
        """raise IOError when residual file cannot be saved"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.read_data(datafile("Ni.dat"), 'X', 30.0, 0.0)
        self.P.constrain(self.P.lat(1), 1)
        self.P.setpar(1, 3.0)
        self.P.pdfrange(1,2.0,10.0)
        self.P.refine_step()
        self.assertRaises(IOError, self.P.save_res,
                "nodir183160/"+self.resfile)

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when structure is undefined"""
        self.assertRaises(pdffit2.unassignedError, self.P.save_res,
        self.resfile)
Пример #6
0
class save_resExceptions(unittest.TestCase):

    def setUp(self):
        self.P = PdfFit()
        self.resfile = "temp.res"

    def tearDown(self):
        del self.P

    def test_IOError(self):
        """raise IOError when residual file cannot be saved"""
        self.P.read_struct(datafile("Ni.stru"))
        self.P.read_data(datafile("Ni.dat"), 'X', 30.0, 0.0)
        self.P.constrain(self.P.lat(1), 1)
        self.P.setpar(1, 3.0)
        self.P.pdfrange(1,2.0,10.0)
        self.P.refine_step()
        self.assertRaises(IOError, self.P.save_res,
                "nodir183160/"+self.resfile)

    def test_unassignedError(self):
        """raise pdffit2.unassignedError when structure is undefined"""
        self.assertRaises(pdffit2.unassignedError, self.P.save_res,
        self.resfile)
Пример #7
0
# Load data ------------------------------------------------------------------

# Load experimental x-ray PDF data
qmax = 30.0  # Q-cutoff used in PDF calculation in 1/A
qdamp = 0.01  # instrument Q-resolution factor, responsible for PDF decay
pf.read_data('Ni-xray.gr', 'X', qmax, qdamp)

# Load nickel structure, must be in PDFFIT or DISCUS format
pf.read_struct('Ni.stru')

# Configure Refinement -------------------------------------------------------

# Refine lattice parameters a, b, c.
# Make them all equal to parameter @1.
pf.constrain(pf.lat(1), "@1")
pf.constrain(pf.lat(2), "@1")
pf.constrain(pf.lat(3), "@1")
# set initial value of parameter @1
pf.setpar(1, pf.lat(1))

# Refine phase scale factor.  Right side can have formulas.
pf.constrain('pscale', '@20 * 2')
pf.setpar(20, pf.getvar(pf.pscale) / 2.0)

# Refine PDF damping due to instrument Q-resolution.
# Left side can be also passed as a reference to PdfFit object
pf.constrain(pf.qdamp, '@21')
pf.setpar(21, 0.03)

# Refine sharpening factor for correlated motion of close atoms.
Пример #8
0
# Load data ------------------------------------------------------------------

# Load experimental x-ray PDF data
qmax = 30.0  # Q-cutoff used in PDF calculation in 1/A
qdamp = 0.01 # instrument Q-resolution factor, responsible for PDF decay
pf.read_data('Ni-xray.gr', 'X', qmax, qdamp)

# Load nickel structure, must be in PDFFIT or DISCUS format
pf.read_struct('Ni.stru')

# Configure Refinement -------------------------------------------------------

# Refine lattice parameters a, b, c.
# Make them all equal to parameter @1.
pf.constrain(pf.lat(1), "@1")
pf.constrain(pf.lat(2), "@1")
pf.constrain(pf.lat(3), "@1")
# set initial value of parameter @1
pf.setpar(1, pf.lat(1))

# Refine phase scale factor.  Right side can have formulas.
pf.constrain('pscale', '@20 * 2')
pf.setpar(20, pf.getvar(pf.pscale) / 2.0)

# Refine PDF damping due to instrument Q-resolution.
# Left side can be also passed as a reference to PdfFit object
pf.constrain(pf.qdamp, '@21')
pf.setpar(21, 0.03)

# Refine sharpening factor for correlated motion of close atoms.