def setUp(self):
     self.pdfcalc = PDFCalculator()
     if not self.nickel:
         type(self).nickel = loadDiffPyStructure('Ni.stru')
     if not self.tio2rutile:
         type(self).tio2rutile = (
                 loadDiffPyStructure('TiO2_rutile-fit.stru'))
     return
Beispiel #2
0
 def setUp(self):
     self.pdfcalc = PDFCalculator()
     if not self.nickel:
         type(self).nickel = loadDiffPyStructure('Ni.stru')
     if not self.tio2rutile:
         type(self).tio2rutile = (
             loadDiffPyStructure('TiO2_rutile-fit.stru'))
     return
 def setUp(self):
     if self.cdse is None:
         type(self).cdse = loadDiffPyStructure('CdSe_cadmoselite.cif')
         for a in self.cdse:  a.Uisoequiv = 0.003
     if self.nickel is None:
         type(self).nickel = loadDiffPyStructure('Ni.cif')
         for a in self.nickel:  a.Uisoequiv = 0.003
     return
Beispiel #4
0
 def setUp(self):
     if self.cdse is None:
         type(self).cdse = loadDiffPyStructure('CdSe_cadmoselite.cif')
         for a in self.cdse:  a.Uisoequiv = 0.003
     if self.nickel is None:
         type(self).nickel = loadDiffPyStructure('Ni.cif')
         for a in self.nickel:  a.Uisoequiv = 0.003
     return
 def setUp(self):
     self.dpdfc = DebyePDFCalculator()
     if not TestDebyePDFCalculator.bucky:
         TestDebyePDFCalculator.bucky = (
                 loadDiffPyStructure('C60bucky.stru'))
     if not TestDebyePDFCalculator.tio2rutile:
         TestDebyePDFCalculator.tio2rutile = (
                 loadDiffPyStructure('TiO2_rutile-fit.stru'))
     return
 def setUp(self):
     self.bdc = BondCalculator()
     if not hasattr(self, 'rutile'):
         type(self).rutile = loadDiffPyStructure('rutile.cif')
     if not hasattr(self, 'nickel'):
         type(self).nickel = loadDiffPyStructure('Ni.stru')
     if not hasattr(self, 'niprim'):
         type(self).niprim = loadDiffPyStructure('Ni_primitive.stru')
     return
 def setUp(self):
     self.olc = OverlapCalculator()
     if not hasattr(self, 'rutile'):
         type(self).rutile = loadDiffPyStructure('rutile.cif')
     if not hasattr(self, 'nickel'):
         type(self).nickel = loadDiffPyStructure('Ni.stru')
     if not hasattr(self, 'niprim'):
         type(self).niprim = loadDiffPyStructure('Ni_primitive.stru')
     return
Beispiel #8
0
 def setUp(self):
     self.dpdfc = DebyePDFCalculator()
     if not TestDebyePDFCalculator.bucky:
         TestDebyePDFCalculator.bucky = (
             loadDiffPyStructure('C60bucky.stru'))
     if not TestDebyePDFCalculator.tio2rutile:
         TestDebyePDFCalculator.tio2rutile = (
             loadDiffPyStructure('TiO2_rutile-fit.stru'))
     return
Beispiel #9
0
 def setUp(self):
     self.pwconst = PeakWidthModel.createByType('constant')
     self.pwconst.width = 2
     if self.tio2stru is None:
         self.tio2stru = loadDiffPyStructure('rutile.cif')
         self.tio2adpt = createStructureAdapter(self.tio2stru)
     return
 def setUp(self):
     self.pwconst = PeakWidthModel.createByType('constant')
     self.pwconst.width = 2
     if self.tio2stru is None:
         self.tio2stru = loadDiffPyStructure('rutile.cif')
         self.tio2adpt = createStructureAdapter(self.tio2stru)
     return
Beispiel #11
0
 def test_fromStructure_CdSe(self):
     """check SFAverage.fromStructure() for CdSe
     """
     cdse = loadDiffPyStructure('CdSe_cadmoselite.cif')
     sfavg = SFAverage.fromStructure(cdse, self.sftx)
     fcd = self.sftx.lookup('Cd')
     fse = self.sftx.lookup('Se')
     self.assertTrue(isinstance(sfavg.f1sum, float))
     self.assertAlmostEqual(0.5 * (fcd + fse), sfavg.f1avg)
     self.assertAlmostEqual(0.5 * (fcd**2 + fse**2), sfavg.f2avg)
     self.assertEqual(4, sfavg.count)
     self.assertEqual(cdse.composition, sfavg.composition)
     qa = numpy.arange(0, 25, 0.1)
     sfavg2 = SFAverage.fromStructure(cdse, self.sftx, qa)
     self.assertTrue(isinstance(sfavg2.f1sum, numpy.ndarray))
     self.assertNotEqual(sfavg2.f1sum[0], sfavg2.f1sum[-1])
     self.assertEqual(sfavg.f1sum, sfavg2.f1sum[0])
     self.assertEqual(sfavg.f2sum, sfavg2.f2sum[0])
     sfavg3 = SFAverage.fromStructure(cdse, self.sftn, qa)
     self.assertEqual(sfavg3.f1sum[0], sfavg3.f1sum[-1])
     sfavg4 = SFAverage.fromStructure(cdse, 'N', qa)
     self.assertTrue(numpy.array_equal(sfavg3.f1sum, sfavg4.f1sum))
     self.assertTrue(numpy.array_equal(sfavg3.f2sum, sfavg4.f2sum))
     sfavg5 = SFAverage.fromStructure(cdse, 'EN', qa)
     self.assertFalse(numpy.array_equal(sfavg3.f1sum, sfavg5.f1sum))
     self.assertRaises(TypeError, SFAverage.fromStructure,
                       'notastructure', self.sftx)
     self.assertRaises(ValueError, SFAverage.fromStructure,
                       cdse, 'invalid')
     return
 def setUp(self):
     self.bvc = BVSCalculator()
     if not hasattr(self, 'rutile'):
         type(self).rutile = loadDiffPyStructure('rutile.cif')
         # rutile.cif does not have charge data, we need to add them here
         iondict = {'Ti' : 'Ti4+',  'O' : 'O2-'}
         for a in self.rutile:  a.element = iondict[a.element]
     return
 def setUp(self):
     self.bvc = BVSCalculator()
     if not hasattr(self, "rutile"):
         type(self).rutile = loadDiffPyStructure("rutile.cif")
         # rutile.cif does not have charge data, we need to add them here
         iondict = {"Ti": "Ti4+", "O": "O2-"}
         for a in self.rutile:
             a.element = iondict[a.element]
     return
Beispiel #14
0
 def setUp(self):
     self.bvc = BVSCalculator()
     if not hasattr(self, 'rutile'):
         type(self).rutile = loadDiffPyStructure('rutile.cif')
         # rutile.cif does not have charge data, we need to add them here
         iondict = {'Ti': 'Ti4+', 'O': 'O2-'}
         for a in self.rutile:
             a.element = iondict[a.element]
     return
 def test_gradients(self):
     """check OverlapCalculator.gradients
     """
     olc = self.olc
     olc.atomradiitable.fromString('Ti:1.6, O:0.66')
     olc(self.rutile)
     self.assertEqual((6, 3), olc.gradients.shape)
     self.assertTrue(numpy.allclose([0, 0, 0], numpy.sum(olc.gradients)))
     g2 = olc.gradients[2]
     self.assertTrue(abs(g2[0]) > 0.1)
     tso0 = olc.totalsquareoverlap
     dx = 1e-8
     rutile2 = loadDiffPyStructure('rutile.cif')
     rutile2[2].xyz_cartn += [dx, 0.0, 0.0]
     olc.eval(rutile2)
     g2nx = (olc.totalsquareoverlap - tso0) / dx
     self.assertAlmostEqual(g2[0], g2nx, 6)
     return
 def test_gradients(self):
     """check OverlapCalculator.gradients
     """
     olc = self.olc
     olc.atomradiitable.fromString('Ti:1.6, O:0.66')
     olc(self.rutile)
     self.assertEqual((6, 3), olc.gradients.shape)
     self.assertTrue(numpy.allclose([0, 0, 0], numpy.sum(olc.gradients)))
     g2 = olc.gradients[2]
     self.assertTrue(abs(g2[0]) > 0.1)
     tso0 = olc.totalsquareoverlap
     dx = 1e-8
     rutile2 = loadDiffPyStructure('rutile.cif')
     rutile2[2].xyz_cartn += [dx, 0.0, 0.0]
     olc.eval(rutile2)
     g2nx = (olc.totalsquareoverlap - tso0) / dx
     self.assertAlmostEqual(g2[0], g2nx, 6)
     return
Beispiel #17
0
 def test_flipDiffTotal(self):
     """check OverlapCalculator.flipDiffTotal
     """
     olc = self.olc
     olc.atomradiitable.fromString('Ti:1.6, O:0.66')
     olc(self.rutile)
     self.assertEqual(0.0, olc.flipDiffTotal(0, 0))
     self.assertEqual(0.0, olc.flipDiffTotal(0, 1))
     self.assertEqual(0.0, olc.flipDiffTotal(2, 5))
     tso0 = olc.totalsquareoverlap
     olc2 = copy.copy(olc)
     rutile2 = loadDiffPyStructure('rutile.cif')
     rutile2[0].element = 'O'
     rutile2[2].element = 'Ti'
     olc2(rutile2)
     fdt02 = olc2.totalsquareoverlap - tso0
     self.assertTrue(fdt02 > 0.01)
     self.assertAlmostEqual(fdt02, olc.flipDiffTotal(0, 2))
     return
 def test_flipDiffTotal(self):
     """check OverlapCalculator.flipDiffTotal
     """
     olc = self.olc
     olc.atomradiitable.fromString('Ti:1.6, O:0.66')
     olc(self.rutile)
     self.assertEqual(0.0, olc.flipDiffTotal(0, 0))
     self.assertEqual(0.0, olc.flipDiffTotal(0, 1))
     self.assertEqual(0.0, olc.flipDiffTotal(2, 5))
     tso0 = olc.totalsquareoverlap
     olc2 = copy.copy(olc)
     rutile2 = loadDiffPyStructure('rutile.cif')
     rutile2[0].element = 'O'
     rutile2[2].element = 'Ti'
     olc2(rutile2)
     fdt02 = olc2.totalsquareoverlap - tso0
     self.assertTrue(fdt02 > 0.01)
     self.assertAlmostEqual(fdt02, olc.flipDiffTotal(0, 2))
     n02 = numpy.array([0, 2], dtype=int)
     self.assertAlmostEqual(fdt02, olc.flipDiffTotal(*n02))
     return
__id__ = '$Id$'

import os
import unittest
import cPickle
import numpy
from diffpy.Structure import Structure
from diffpy.srreal.pdfcalculator import PDFCalculator
from diffpy.srreal.tests.testutils import TestCaseObjCrystOptional
from diffpy.srreal.tests.testutils import loadObjCrystCrystal
from diffpy.srreal.tests.testutils import loadDiffPyStructure, datafile
from diffpy.srreal.structureadapter import *


# useful variables
nickel = loadDiffPyStructure('Ni.stru')
rutile_cif = 'TiO2_rutile-fit.cif'

##############################################################################
class TestRoutines(unittest.TestCase):

    def test_createStructureAdapter(self):
        """check createStructureAdapter() routine.
        """
        adpt = createStructureAdapter(nickel)
        self.assertEqual(4, adpt.countSites())
        self.failUnless(False is adpt.siteAnisotropy(0))
        self.failUnless(StructureAdapter is type(adpt))
        adpt1 = createStructureAdapter(adpt)
        self.failUnless(adpt is adpt1)
        self.assertRaises(TypeError, createStructureAdapter, 77)
 def setUp(self):
     self.nickel = loadDiffPyStructure('Ni.stru')
     return
Beispiel #21
0
import unittest
import cPickle
import numpy
from diffpy.Structure import Structure
from diffpy.srreal.pdfcalculator import PDFCalculator
from diffpy.srreal.tests.testutils import TestCaseObjCrystOptional
from diffpy.srreal.tests.testutils import loadObjCrystCrystal
from diffpy.srreal.tests.testutils import loadDiffPyStructure
from diffpy.srreal.structureadapter import (createStructureAdapter, nometa,
                                            nosymmetry, StructureAdapter,
                                            AtomicStructureAdapter, Atom,
                                            PeriodicStructureAdapter)
import diffpy.srreal.tests.testutils as testutils

# useful variables
nickel = loadDiffPyStructure('Ni.stru')
rutile_cif = 'TiO2_rutile-fit.cif'


##############################################################################
class TestRoutines(unittest.TestCase):
    def test_createStructureAdapter(self):
        """check createStructureAdapter() routine.
        """
        adpt = createStructureAdapter(nickel)
        self.assertEqual(4, adpt.countSites())
        self.failUnless(False is adpt.siteAnisotropy(0))
        self.failUnless(isinstance(adpt, StructureAdapter))
        adpt1 = createStructureAdapter(adpt)
        self.failUnless(adpt is adpt1)
        self.assertRaises(TypeError, createStructureAdapter, 77)
import os
import unittest
import cPickle
import numpy
from diffpy.Structure import Structure
from diffpy.srreal.pdfcalculator import PDFCalculator
from diffpy.srreal.tests.testutils import TestCaseObjCrystOptional
from diffpy.srreal.tests.testutils import loadObjCrystCrystal
from diffpy.srreal.tests.testutils import loadDiffPyStructure, datafile
from diffpy.srreal.structureadapter import *
import diffpy.srreal.tests.testutils as testutils


# useful variables
nickel = loadDiffPyStructure("Ni.stru")
rutile_cif = "TiO2_rutile-fit.cif"

##############################################################################
class TestRoutines(unittest.TestCase):
    def test_createStructureAdapter(self):
        """check createStructureAdapter() routine.
        """
        adpt = createStructureAdapter(nickel)
        self.assertEqual(4, adpt.countSites())
        self.failUnless(False is adpt.siteAnisotropy(0))
        self.failUnless(isinstance(adpt, StructureAdapter))
        adpt1 = createStructureAdapter(adpt)
        self.failUnless(adpt is adpt1)
        self.assertRaises(TypeError, createStructureAdapter, 77)
        self.assertRaises(TypeError, createStructureAdapter, range(8))
Beispiel #23
0
 def setUp(self):
     self.nickel = loadDiffPyStructure('Ni.stru')
     return