def setUp(self): super(GaussianBickelhauptTest, self).setUp() self.data, self.logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"]) self.analysis = Bickelhaupt(self.data) self.analysis.logger.setLevel(0) self.analysis.calculate()
def test_dvb_sp(self): """Testing Bickelhaupt charges (restricted) against outputs from Multiwfn.""" data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"]) bpa = Bickelhaupt(data) bpa.logger.setLevel(logging.ERROR) bpa.calculate() e_bpa = numpy.loadtxt( os.path.dirname(os.path.realpath(__file__)) + "/dvb_sp.bpa") self.assertTrue(numpy.all(bpa.fragcharges >= e_bpa - 0.05)) self.assertTrue(numpy.all(bpa.fragcharges <= e_bpa + 0.05))
class GaussianBickelhauptTest(unittest.TestCase): """Bickelhaupt Population Analysis test""" def setUp(self): super(GaussianBickelhauptTest, self).setUp() self.data, self.logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"]) self.analysis = Bickelhaupt(self.data) self.analysis.logger.setLevel(0) self.analysis.calculate() def testsumcharges(self): """Do the Bickelhaupt charges sum up to the total formal charge?""" formalcharge = sum(self.data.atomnos) - self.data.charge totalpopulation = sum(self.analysis.fragcharges) self.assertAlmostEqual(totalpopulation, formalcharge, delta=1.0e-3) def testsumspins(self): """Do the Bickelhaupt spins sum up to the total formal spin?""" formalspin = self.data.homos[0] - self.data.homos[1] totalspin = sum(self.analysis.fragspins) self.assertAlmostEqual(totalspin, formalspin, delta=1.0e-3) def test_dvb_sp(self): """Testing Bickelhaupt charges (restricted) against outputs from Multiwfn.""" data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"]) bpa = Bickelhaupt(data) bpa.logger.setLevel(logging.ERROR) bpa.calculate() e_bpa = numpy.loadtxt( os.path.dirname(os.path.realpath(__file__)) + "/dvb_sp.bpa") self.assertTrue(numpy.all(bpa.fragcharges >= e_bpa - 0.05)) self.assertTrue(numpy.all(bpa.fragcharges <= e_bpa + 0.05)) def test_dvb_un_sp(self): """Testing Bickelhaupt charges (unrestricted) against outputs from Multiwfn.""" data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"]) bpa = Bickelhaupt(data) bpa.logger.setLevel(logging.ERROR) bpa.calculate() e_bpaalpha = numpy.loadtxt( os.path.dirname(os.path.realpath(__file__)) + "/dvb_un_sp.bpa") e_bpaspin = numpy.loadtxt( os.path.dirname(os.path.realpath(__file__)) + "/dvb_un_sp.bpaspin") self.assertTrue(numpy.all(bpa.fragcharges >= e_bpaalpha - 0.05)) self.assertTrue(numpy.all(bpa.fragcharges <= e_bpaalpha + 0.05)) self.assertTrue(numpy.all(bpa.fragspins >= e_bpaspin - 0.05)) self.assertTrue(numpy.all(bpa.fragspins <= e_bpaspin + 0.05))