def testShapedConstruction(self): """ Testing the construction of the class with parameters. """ feff_parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, effective_path_distance=self.__effective_path_distance, amplitude_reduction_factor=self.__amplitude_reduction_factor) self.assertIsInstance(feff_parameters, FEFFPhotonMatterInteractorParameters) # Check attributes self.assertEqual( feff_parameters._FEFFPhotonMatterInteractorParameters__atoms, self.__atoms) self.assertEqual( feff_parameters._FEFFPhotonMatterInteractorParameters__potentials, self.__potentials) self.assertEqual( feff_parameters._FEFFPhotonMatterInteractorParameters__edge, self.__edge) self.assertEqual( feff_parameters. _FEFFPhotonMatterInteractorParameters__amplitude_reduction_factor, self.__amplitude_reduction_factor) self.assertEqual( feff_parameters. _FEFFPhotonMatterInteractorParameters__effective_path_distance, self.__effective_path_distance)
def testSetters(self): """ Test that setting parameters works correctly. """ # Construct the object. feff_parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, effective_path_distance=self.__effective_path_distance, amplitude_reduction_factor=self.__amplitude_reduction_factor) # Set new parameters. feff_parameters.atoms = self.__atoms[:10] feff_parameters.potentials = None feff_parameters.edge = 'L2' feff_parameters.amplitude_reduction_factor = 0.1 feff_parameters.effective_path_distance = 5.0 # Check attributes self.assertEqual( feff_parameters._FEFFPhotonMatterInteractorParameters__atoms, self.__atoms[:10]) self.assertEqual( feff_parameters._FEFFPhotonMatterInteractorParameters__potentials, None) self.assertEqual( feff_parameters._FEFFPhotonMatterInteractorParameters__edge, 'L2') self.assertEqual( feff_parameters. _FEFFPhotonMatterInteractorParameters__amplitude_reduction_factor, 0.1) self.assertEqual( feff_parameters. _FEFFPhotonMatterInteractorParameters__effective_path_distance, 5.0)
def testFinalization(self): """ That that the finalization flag is set correctly. """ feff_parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, effective_path_distance=self.__effective_path_distance, amplitude_reduction_factor=self.__amplitude_reduction_factor) # Is finalized after construction. self.assertTrue(feff_parameters.finalized) # Change a parameter feff_parameters.edge = 'L1' self.assertFalse(feff_parameters.finalized) # Finalize. feff_parameters.finalize() self.assertTrue(feff_parameters.finalized)
def testFinalize(self): # Setup parameters. feff_parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, effective_path_distance=5.5, amplitude_reduction_factor=1.0, ) # Get potential list. potential_list = feff_parameters._FEFFPhotonMatterInteractorParameters__potential_list self.assertEqual(potential_list, [[0, 29, 'Cu'], [1, 29, 'Cu']])
def testQueries(self): """ Test that all queries return the correct value. """ feff_parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, effective_path_distance=self.__effective_path_distance, amplitude_reduction_factor=self.__amplitude_reduction_factor) # Check queries. self.assertEqual(feff_parameters.atoms, self.__atoms) self.assertEqual(feff_parameters.potentials, self.__potentials) self.assertEqual(feff_parameters.edge, self.__edge) self.assertEqual(feff_parameters.amplitude_reduction_factor, self.__amplitude_reduction_factor) self.assertEqual(feff_parameters.effective_path_distance, self.__effective_path_distance)
def testSerialize(self): """ Check that the serialize() method produces a valid feff.inp file.""" # Setup parameters. feff_parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, effective_path_distance=5.5, amplitude_reduction_factor=1.0, ) # Setup a stream to write to. stream = StringIO.StringIO() feff_parameters._serialize(stream=stream) # Compare to reference. reference_inp = """EDGE K S02 1.000000 CONTROL 1 1 1 1 1 1 PRINT 0 0 0 0 0 0 RPATH 5.500000 EXAFS POTENTIALS 0 29 Cu 1 29 Cu ATOMS 0.00000 0.00000 0.00000 0 0.00000 1.80500 -1.80500 1 -1.80500 -1.80500 0.00000 1 1.80500 0.00000 -1.80500 1 0.00000 -1.80500 1.80500 1 1.80500 1.80500 0.00000 1 0.00000 -1.80500 -1.80500 1 -1.80500 1.80500 0.00000 1 0.00000 1.80500 1.80500 1 -1.80500 0.00000 -1.80500 1 -1.80500 0.00000 1.80500 1 1.80500 0.00000 1.80500 1 1.80500 -1.80500 0.00000 1 0.00000 -3.61000 0.00000 1 0.00000 0.00000 -3.61000 1 0.00000 0.00000 3.61000 1 -3.61000 0.00000 0.00000 1 3.61000 0.00000 0.00000 1 0.00000 3.61000 0.00000 1 -1.80500 3.61000 1.80500 1 1.80500 3.61000 1.80500 1 -1.80500 -3.61000 -1.80500 1 -1.80500 3.61000 -1.80500 1 1.80500 3.61000 -1.80500 1 -1.80500 -3.61000 1.80500 1 -3.61000 1.80500 -1.80500 1 1.80500 -3.61000 1.80500 1 3.61000 1.80500 -1.80500 1 -3.61000 1.80500 1.80500 1 -3.61000 -1.80500 -1.80500 1 3.61000 -1.80500 1.80500 1 1.80500 -3.61000 -1.80500 1 -3.61000 -1.80500 1.80500 1 3.61000 1.80500 1.80500 1 -1.80500 -1.80500 3.61000 1 -1.80500 -1.80500 -3.61000 1 1.80500 1.80500 -3.61000 1 1.80500 -1.80500 -3.61000 1 1.80500 -1.80500 3.61000 1 -1.80500 1.80500 -3.61000 1 -1.80500 1.80500 3.61000 1 1.80500 1.80500 3.61000 1 3.61000 -1.80500 -1.80500 1 3.61000 -3.61000 0.00000 1 3.61000 0.00000 -3.61000 1 3.61000 0.00000 3.61000 1 -3.61000 3.61000 0.00000 1 0.00000 3.61000 3.61000 1 -3.61000 0.00000 3.61000 1 -3.61000 -3.61000 0.00000 1 0.00000 -3.61000 3.61000 1 -3.61000 0.00000 -3.61000 1 3.61000 3.61000 0.00000 1 0.00000 -3.61000 -3.61000 1 0.00000 3.61000 -3.61000 1 0.00000 -5.41500 1.80500 1 1.80500 -5.41500 0.00000 1 0.00000 -5.41500 -1.80500 1 -1.80500 0.00000 5.41500 1 -5.41500 0.00000 -1.80500 1 5.41500 -1.80500 0.00000 1 -1.80500 5.41500 0.00000 1 5.41500 0.00000 -1.80500 1 -5.41500 -1.80500 0.00000 1 1.80500 5.41500 0.00000 1 5.41500 1.80500 0.00000 1 0.00000 5.41500 -1.80500 1 0.00000 -1.80500 -5.41500 1 0.00000 5.41500 1.80500 1 1.80500 0.00000 5.41500 1 0.00000 1.80500 5.41500 1 5.41500 0.00000 1.80500 1 1.80500 0.00000 -5.41500 1 0.00000 1.80500 -5.41500 1 0.00000 -1.80500 5.41500 1 -5.41500 0.00000 1.80500 1 -5.41500 1.80500 0.00000 1 -1.80500 0.00000 -5.41500 1 -1.80500 -5.41500 0.00000 1 END""" comp = stream.getvalue() self.assertEqual(comp, reference_inp)
def setUp(self): """ Setting up a test. """ self.__files_to_remove = [] self.__dirs_to_remove = [] self.__atoms = ( [[0.00000, 0.00000, 0.00000], 'Cu', 0], [[0.00000, 1.80500, -1.80500], 'Cu', 1], [[-1.80500, -1.80500, 0.00000], 'Cu', 1], [[1.80500, 0.00000, -1.80500], 'Cu', 1], [[0.00000, -1.80500, 1.80500], 'Cu', 1], [[1.80500, 1.80500, 0.00000], 'Cu', 1], [[0.00000, -1.80500, -1.80500], 'Cu', 1], [[-1.80500, 1.80500, 0.00000], 'Cu', 1], [[0.00000, 1.80500, 1.80500], 'Cu', 1], [[-1.80500, 0.00000, -1.80500], 'Cu', 1], [[-1.80500, 0.00000, 1.80500], 'Cu', 1], [[1.80500, 0.00000, 1.80500], 'Cu', 1], [[1.80500, -1.80500, 0.00000], 'Cu', 1], [[0.00000, -3.61000, 0.00000], 'Cu', 1], [[0.00000, 0.00000, -3.61000], 'Cu', 1], [[0.00000, 0.00000, 3.61000], 'Cu', 1], [[-3.61000, 0.00000, 0.00000], 'Cu', 1], [[3.61000, 0.00000, 0.00000], 'Cu', 1], [[0.00000, 3.61000, 0.00000], 'Cu', 1], [[-1.80500, 3.61000, 1.80500], 'Cu', 1], [[1.80500, 3.61000, 1.80500], 'Cu', 1], [[-1.80500, -3.61000, -1.80500], 'Cu', 1], [[-1.80500, 3.61000, -1.80500], 'Cu', 1], [[1.80500, 3.61000, -1.80500], 'Cu', 1], [[-1.80500, -3.61000, 1.80500], 'Cu', 1], [[-3.61000, 1.80500, -1.80500], 'Cu', 1], [[1.80500, -3.61000, 1.80500], 'Cu', 1], [[3.61000, 1.80500, -1.80500], 'Cu', 1], [[-3.61000, 1.80500, 1.80500], 'Cu', 1], [[-3.61000, -1.80500, -1.80500], 'Cu', 1], [[3.61000, -1.80500, 1.80500], 'Cu', 1], [[1.80500, -3.61000, -1.80500], 'Cu', 1], [[-3.61000, -1.80500, 1.80500], 'Cu', 1], [[3.61000, 1.80500, 1.80500], 'Cu', 1], [[-1.80500, -1.80500, 3.61000], 'Cu', 1], [[-1.80500, -1.80500, -3.61000], 'Cu', 1], [[1.80500, 1.80500, -3.61000], 'Cu', 1], [[1.80500, -1.80500, -3.61000], 'Cu', 1], [[1.80500, -1.80500, 3.61000], 'Cu', 1], [[-1.80500, 1.80500, -3.61000], 'Cu', 1], [[-1.80500, 1.80500, 3.61000], 'Cu', 1], [[1.80500, 1.80500, 3.61000], 'Cu', 1], [[3.61000, -1.80500, -1.80500], 'Cu', 1], [[3.61000, -3.61000, 0.00000], 'Cu', 1], [[3.61000, 0.00000, -3.61000], 'Cu', 1], [[3.61000, 0.00000, 3.61000], 'Cu', 1], [[-3.61000, 3.61000, 0.00000], 'Cu', 1], [[0.00000, 3.61000, 3.61000], 'Cu', 1], [[-3.61000, 0.00000, 3.61000], 'Cu', 1], [[-3.61000, -3.61000, 0.00000], 'Cu', 1], [[0.00000, -3.61000, 3.61000], 'Cu', 1], [[-3.61000, 0.00000, -3.61000], 'Cu', 1], [[3.61000, 3.61000, 0.00000], 'Cu', 1], [[0.00000, -3.61000, -3.61000], 'Cu', 1], [[0.00000, 3.61000, -3.61000], 'Cu', 1], [[0.00000, -5.41500, 1.80500], 'Cu', 1], [[1.80500, -5.41500, 0.00000], 'Cu', 1], [[0.00000, -5.41500, -1.80500], 'Cu', 1], [[-1.80500, 0.00000, 5.41500], 'Cu', 1], [[-5.41500, 0.00000, -1.80500], 'Cu', 1], [[5.41500, -1.80500, 0.00000], 'Cu', 1], [[-1.80500, 5.41500, 0.00000], 'Cu', 1], [[5.41500, 0.00000, -1.80500], 'Cu', 1], [[-5.41500, -1.80500, 0.00000], 'Cu', 1], [[1.80500, 5.41500, 0.00000], 'Cu', 1], [[5.41500, 1.80500, 0.00000], 'Cu', 1], [[0.00000, 5.41500, -1.80500], 'Cu', 1], [[0.00000, -1.80500, -5.41500], 'Cu', 1], [[0.00000, 5.41500, 1.80500], 'Cu', 1], [[1.80500, 0.00000, 5.41500], 'Cu', 1], [[0.00000, 1.80500, 5.41500], 'Cu', 1], [[5.41500, 0.00000, 1.80500], 'Cu', 1], [[1.80500, 0.00000, -5.41500], 'Cu', 1], [[0.00000, 1.80500, -5.41500], 'Cu', 1], [[0.00000, -1.80500, 5.41500], 'Cu', 1], [[-5.41500, 0.00000, 1.80500], 'Cu', 1], [[-5.41500, 1.80500, 0.00000], 'Cu', 1], [[-1.80500, 0.00000, -5.41500], 'Cu', 1], [[-1.80500, -5.41500, 0.00000], 'Cu', 1], ) self.__potentials = None self.__edge = 'K' self.__amplitude_reduction_factor = 0.9 self.__effective_path_distance = 5.5 self.__parameters = FEFFPhotonMatterInteractorParameters( atoms=self.__atoms, potentials=self.__potentials, edge=self.__edge, amplitude_reduction_factor=self.__amplitude_reduction_factor, effective_path_distance=self.__effective_path_distance, )