Exemplo n.º 1
0
def test__zmatrix():
    """ test the zmatrix read/write functions
    """
    ref_zma = ((('C', (None, None, None), (None, None, None)),
                ('O', (0, None, None), ('r1', None, None)),
                ('H', (0, 1, None), ('r2', 'a1', None)), ('H', (0, 1, 2),
                                                          ('r3', 'a2', 'd1')),
                ('H', (0, 1, 2), ('r4', 'a3', 'd2')), ('H', (1, 0, 2),
                                                       ('r5', 'a4', 'd3'))), {
                                                           'r1': 2.67535,
                                                           'r2': 2.06501,
                                                           'a1': 1.9116242,
                                                           'r3': 2.06501,
                                                           'a2': 1.9116242,
                                                           'd1': 2.108497362,
                                                           'r4': 2.06458,
                                                           'a3': 1.9020947,
                                                           'd2': 4.195841334,
                                                           'r5': 1.83748,
                                                           'a4': 1.8690905,
                                                           'd3': 5.228936625
                                                       })

    zma_file_name = autofile.name.zmatrix('test')
    zma_file_path = os.path.join(TMP_DIR, zma_file_name)
    zma_str = autofile.write.zmatrix(ref_zma)

    assert not os.path.isfile(zma_file_path)
    autofile.write_file(zma_file_path, zma_str)
    assert os.path.isfile(zma_file_path)

    zma_str = autofile.read_file(zma_file_path)
    zma = autofile.read.zmatrix(zma_str)
    assert automol.zmatrix.almost_equal(ref_zma, zma)
Exemplo n.º 2
0
 def read(self, prefix, args=()):
     """ read the data from a file
     """
     assert self.exists(prefix, args)
     file_path = self.path(prefix, args)
     val_str = autofile.read_file(file_path)
     val = self.reader_(val_str)
     return val
Exemplo n.º 3
0
 def read(self, dir_pth):
     """ read data from this file
     """
     assert self.exists(dir_pth)
     pth = self.path(dir_pth)
     val_str = autofile.read_file(pth)
     val = self.reader_(val_str)
     return val
Exemplo n.º 4
0
 def read(self, args):
     """ read the data from a file
     """
     assert self.exists(args=args)
     file_path = self.path(args)
     file_str = autofile.read_file(file_path)
     file_dat = self.reader_(file_str)
     assert self.checker_(file_dat)
     return file_dat
Exemplo n.º 5
0
def test__energy():
    """ test the energy read/write functions
    """
    ref_ene = -75.00613628303537

    ene_file_name = autofile.name.energy('test')
    ene_file_path = os.path.join(TMP_DIR, ene_file_name)
    ene_str = autofile.write.energy(ref_ene)

    assert not os.path.isfile(ene_file_path)
    autofile.write_file(ene_file_path, ene_str)
    assert os.path.isfile(ene_file_path)

    ene_str = autofile.read_file(ene_file_path)
    ene = autofile.read.energy(ene_str)
    assert numpy.isclose(ref_ene, ene)
Exemplo n.º 6
0
def test__lennard_jones_sigma():
    """ test the sigma read/write functions
    """
    ref_sig = 3.55018590361446

    sig_file_name = autofile.name.lennard_jones_sigma('test')
    sig_file_path = os.path.join(TMP_DIR, sig_file_name)
    sig_str = autofile.write.lennard_jones_sigma(ref_sig)

    assert not os.path.isfile(sig_file_path)
    autofile.write_file(sig_file_path, sig_str)
    assert os.path.isfile(sig_file_path)

    sig_str = autofile.read_file(sig_file_path)
    sig = autofile.read.lennard_jones_sigma(sig_str)
    assert numpy.isclose(ref_sig, sig)
Exemplo n.º 7
0
def test__lennard_jones_epsilon():
    """ test the epsilon read/write functions
    """
    ref_eps = 247.880866746988

    eps_file_name = autofile.name.lennard_jones_epsilon('test')
    eps_file_path = os.path.join(TMP_DIR, eps_file_name)
    eps_str = autofile.write.lennard_jones_epsilon(ref_eps)

    assert not os.path.isfile(eps_file_path)
    autofile.write_file(eps_file_path, eps_str)
    assert os.path.isfile(eps_file_path)

    eps_str = autofile.read_file(eps_file_path)
    eps = autofile.read.lennard_jones_epsilon(eps_str)
    assert numpy.isclose(ref_eps, eps)
Exemplo n.º 8
0
def test__information():
    """ test the information read/write functions
    """
    ref_inf_obj = autoinf.Info(a=['b', 'c', 'd', 'e'],
                               x=autoinf.Info(y=1, z=2))

    inf_file_name = autofile.name.information('test')
    inf_file_path = os.path.join(TMP_DIR, inf_file_name)
    inf_str = autofile.write.information(ref_inf_obj)

    assert not os.path.isfile(inf_file_path)
    autofile.write_file(inf_file_path, inf_str)
    assert os.path.isfile(inf_file_path)

    inf_str = autofile.read_file(inf_file_path)
    inf_obj = autofile.read.information(inf_str)
    assert inf_obj == ref_inf_obj
Exemplo n.º 9
0
def test__geometry():
    """ test the geometry read/write functions
    """
    ref_geo = (('C', (-0.70116587131, 0.0146227007587, -0.016166607003)),
               ('O', (1.7323365056, -0.9538524899, -0.5617192010)),
               ('H', (-0.9827048283, 0.061897979239, 2.02901783816)),
               ('H', (-0.8787925682, 1.91673409124, -0.80019507919)),
               ('H', (-2.12093033745, -1.21447973767, -0.87411360631)),
               ('H', (2.9512589894, 0.17507745634, 0.22317665541)))

    geo_file_name = autofile.name.geometry('test')
    geo_file_path = os.path.join(TMP_DIR, geo_file_name)
    geo_str = autofile.write.geometry(ref_geo)

    assert not os.path.isfile(geo_file_path)
    autofile.write_file(geo_file_path, geo_str)
    assert os.path.isfile(geo_file_path)

    geo_str = autofile.read_file(geo_file_path)
    geo = autofile.read.geometry(geo_str)
    assert automol.geom.almost_equal(ref_geo, geo)
Exemplo n.º 10
0
def test__gradient():
    """ test the gradient read/write functions
    """
    ref_grad = ((-6.687065494e-05, -2.087360475e-05, -2.900518464e-05),
                (2.091815312e-05, -2.162539565e-05, 2.097302071e-05),
                (-9.17712798e-06, -2.97043797e-05, -1.378883952e-05),
                (2.244858355e-05, 6.0265176e-06, 1.00733398e-06),
                (4.676018254e-05, 5.473937899e-05, 1.744549e-05),
                (-1.407913705e-05, 1.143748381e-05, 3.3681804e-06))

    grad_file_name = autofile.name.gradient('test')
    grad_file_path = os.path.join(TMP_DIR, grad_file_name)
    grad_str = autofile.write.gradient(ref_grad)

    assert not os.path.isfile(grad_file_path)
    autofile.write_file(grad_file_path, grad_str)
    assert os.path.isfile(grad_file_path)

    grad_str = autofile.read_file(grad_file_path)
    grad = autofile.read.gradient(grad_str)
    assert numpy.allclose(ref_grad, grad)
Exemplo n.º 11
0
def test__vmatrix():
    """ test the vmatrix read/write functions
    """
    ref_vma = (('C', (None, None, None), (None, None, None)),
               ('O', (0, None, None), ('r1', None, None)),
               ('H', (0, 1, None), ('r2', 'a1', None)), ('H', (0, 1, 2),
                                                         ('r3', 'a2', 'd1')),
               ('H', (0, 1, 2), ('r4', 'a3', 'd2')), ('H', (1, 0, 2),
                                                      ('r5', 'a4', 'd3')))

    vma_file_name = autofile.name.vmatrix('test')
    vma_file_path = os.path.join(TMP_DIR, vma_file_name)
    vma_str = autofile.write.vmatrix(ref_vma)

    assert not os.path.isfile(vma_file_path)
    autofile.write_file(vma_file_path, vma_str)
    assert os.path.isfile(vma_file_path)

    vma_str = autofile.read_file(vma_file_path)
    vma = autofile.read.vmatrix(vma_str)
    assert vma == ref_vma
Exemplo n.º 12
0
def test__hessian():
    """ test the hessian read/write functions
    """
    ref_hess = ((0.70455411073336, -0.08287472697212, 0.0, -0.0798647434566,
                 0.05385932364624, 0.0, -0.62468936727659, 0.02901540332588,
                 0.0), (-0.08287472697212, 0.73374800936533, 0.0,
                        -0.06694564915575, -0.63928635896955, 0.0,
                        0.14982037612785, -0.09446165039567, 0.0),
                (0.0, 0.0, 0.00019470176975, 0.0, 0.0, -9.734161519e-05, 0.0,
                 0.0,
                 -9.736015438e-05), (-0.0798647434566, -0.06694564915575, 0.0,
                                     0.08499297871932, -0.02022391947876, 0.0,
                                     -0.00512823526272, 0.0871695686345, 0.0),
                (0.05385932364624, -0.63928635896955, 0.0, -0.02022391947876,
                 0.65384367318451, 0.0, -0.03363540416748, -0.01455731421496,
                 0.0), (0.0, 0.0, -9.734161519e-05, 0.0, 0.0, 4.370597581e-05,
                        0.0, 0.0, 5.363563938e-05),
                (-0.62468936727659, 0.14982037612785, 0.0, -0.00512823526272,
                 -0.03363540416748, 0.0, 0.6298176025393, -0.11618497196038,
                 0.0), (0.02901540332588, -0.09446165039567, 0.0,
                        0.0871695686345, -0.01455731421496, 0.0,
                        -0.11618497196038, 0.10901896461063,
                        0.0), (0.0, 0.0, -9.736015438e-05, 0.0, 0.0,
                               5.363563938e-05, 0.0, 0.0, 4.3724515e-05))

    hess_file_name = autofile.name.hessian('test')
    hess_file_path = os.path.join(TMP_DIR, hess_file_name)
    hess_str = autofile.write.hessian(ref_hess)

    assert not os.path.isfile(hess_file_path)
    autofile.write_file(hess_file_path, hess_str)
    assert os.path.isfile(hess_file_path)

    hess_str = autofile.read_file(hess_file_path)
    hess = autofile.read.hessian(hess_str)
    assert numpy.allclose(ref_hess, hess)