Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_mbo_un_sp(self):
"""Testing Mayer bond orders for unrestricted single point."""
data, logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_un_sp.log"])
mbo = MBO(data)
mbo.logger.setLevel(logging.ERROR)
mbo.calculate()
e_mbo = numpy.loadtxt(os.path.dirname(os.path.realpath(__file__)) + "/dvb_un_sp.mbo")
bond_orders = mbo.fragresults[0] + mbo.fragresults[1]
self.assertTrue(numpy.all(bond_orders >= e_mbo - 0.30))
self.assertTrue(numpy.all(bond_orders <= e_mbo + 0.30))
def main(log=True):
data1, logfile1 = getdatafile(Gaussian, "CDA", ["BH3CO-sp.log"])
data2, logfile2 = getdatafile(Gaussian, "CDA", ["BH3.log"])
data3, logfile3 = getdatafile(Gaussian, "CDA", ["CO.log"])
fa = CDA(data1)
if not log:
fa.logger.setLevel(logging.ERROR)
fa.calculate([data2, data3])
return fa
def test_programs(self):
"""Does the function catch programs as expected?"""
self.assertEqual(self.guess(["Amsterdam Density Functional"]), cclib.parser.ADF)
self.assertEqual(self.guess(['Dalton - An Electronic Structure Program']), cclib.parser.DALTON)
self.assertEqual(self.guess(['GAMESS']), cclib.parser.GAMESS)
self.assertEqual(self.guess(['G A M E S S - U K']), cclib.parser.GAMESSUK)
self.assertEqual(self.guess(['Gaussian, Inc.']), cclib.parser.Gaussian)
self.assertEqual(self.guess(['Jaguar']), cclib.parser.Jaguar)
self.assertEqual(self.guess(['PROGRAM SYSTEM MOLPRO']), cclib.parser.Molpro)
self.assertEqual(self.guess(['MOPAC2016']), cclib.parser.MOPAC)
self.assertEqual(self.guess(['Northwest Computational Chemistry Package']), cclib.parser.NWChem)
self.assertEqual(self.guess(['O R C A']), cclib.parser.ORCA)
self.assertEqual(self.guess(["PSI3: An Open-Source Ab Initio Electronic Structure Package"]), cclib.parser.Psi3)
self.assertEqual(self.guess(["Psi4: An Open-Source Ab Initio Electronic Structure Package"]), cclib.parser.Psi4)
self.assertEqual(self.guess(['A Quantum Leap Into The Future Of Chemistry']), cclib.parser.QChem)
def test_wavefunction(self):
"""Does the volume occupied by the HOMO integrate to the correct
values?
"""
data_basis, _ = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"])
data_sp, _ = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"])
vol = volume.Volume((-3.0, -6.0, -2.0), (3.0, 6.0, 2.0), (0.25, 0.25, 0.25))
wavefn = volume.wavefunction(data_sp.atomcoords[0],
data_sp.mocoeffs[0][data_sp.homos[0]],
data_basis.gbasis, vol)
integral = wavefn.integrate()
integral_square = wavefn.integrate_square()
self.assertTrue(abs(integral) < 1e-6) # not necessarily true for all wavefns
self.assertTrue(abs(integral_square - 1.00) < 1e-3) # true for all wavefns
print(integral, integral_square)
def setUp(self):
self.data, self.logfile = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"])
def testnoparseGaussian_Gaussian09_coeffs_log(filename):
"""This is a test for a Gaussian file with more than 999 basis functions.
The log file is too big, so we are just including a section. Before
parsing, we set some attributes of the parser so that it all goes smoothly.
"""
parser = Gaussian(os.path.join(__filedir__, filename), loglevel=logging.ERROR)
parser.nmo = 5
parser.nbasis = 1128
data = parser.parse()
assert data.mocoeffs[0].shape == (5, 1128)
assert data.aonames[-1] == "Ga71_19D-2"
assert data.aonames[0] == "Mn1_1S"
def setUp(self):
self.data, self.logfile = getfile(Gaussian, "basicGaussian03", "dvb_sp.out")
self.analysis = MPA(self.data)
self.analysis.logger.setLevel(0)
self.analysis.calculate()
def testsum(self):
def test_wavefunction(self):
"""Does the volume occupied by the HOMO integrate to the correct
values?
"""
data_basis, _ = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"])
data_sp, _ = getdatafile(Gaussian, "basicGaussian09", ["dvb_sp.out"])
vol = volume.Volume((-3.0, -6.0, -2.0), (3.0, 6.0, 2.0), (0.25, 0.25, 0.25))
wavefn = volume.wavefunction(data_sp.atomcoords[0],
data_sp.mocoeffs[0][data_sp.homos[0]],
data_basis.gbasis, vol)
integral = wavefn.integrate()
integral_square = wavefn.integrate_square()
self.assertTrue(abs(integral) < 1e-6) # not necessarily true for all wavefns
self.assertTrue(abs(integral_square - 1.00) < 1e-3) # true for all wavefns
print(integral, integral_square)
def testnoparseGaussian_Gaussian09_coeffs_zip(filename):
"""This is a test for a Gaussian file with more than 999 basis functions.
The log file is too big, so we are just including a section. Before
parsing, we set some attributes of the parser so that it all goes smoothly.
"""
d = Gaussian(filename)
d.logger.setLevel(logging.ERROR)
d.nmo = 5
d.nbasis = 1128
logfile = d.parse()
assert logfile.data.mocoeffs[0].shape == (5, 1128)
assert logfile.data.aonames[-1] == "Ga71_19D-2"
assert logfile.data.aonames[0] == "Mn1_1S"
def gaussian_modes(path):
"""
Read the modes
Create a prody.modes instance
Parameters
----------
path : str
gaussian frequencies output path
Returns
-------
modes : ProDy modes ANM or RTB
"""
gaussian_parser = Gaussian(path).parse()
shape = gaussian_parser.vibdisps.shape
modes_vectors = gaussian_parser.vibdisps.reshape(shape[0], shape[1]*shape[2]).T
modes_frequencies = numpy.abs(gaussian_parser.vibfreqs)
modes = prody.NMA()
modes.setEigens(vectors=modes_vectors, values=modes_frequencies)
return modes