class GaussianCSPATest(bettertest.TestCase): """C-squared Population Analysis test""" def setUp(self): self.data, self.logfile = getfile(Gaussian, "basicGaussian03", "dvb_sp.out") self.analysis = CSPA(self.data) self.analysis.logger.setLevel(0) self.analysis.calculate() def testsum(self): """Do the CSPA charges sum up to the total formal charge?""" formalcharge = sum(self.data.atomnos) - self.data.charge totalpopulation = sum(self.analysis.fragcharges) self.assertInside(totalpopulation, formalcharge, 0.001)
class GaussianCSPATest(unittest.TestCase): """C-squared Population Analysis test""" def setUp(self): self.data, self.logfile = getdatafile(Gaussian, "basicGaussian03", ["dvb_un_sp.out"]) self.analysis = CSPA(self.data) self.analysis.logger.setLevel(0) self.analysis.calculate() def testsumcharges(self): """Do the CSPA 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 CSPA 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)