예제 #1
0
    def setUp(self):
        bfs = BasisFunction('S', [1, 2], [0.5, 0.5])
        bfp = BasisFunction('P', [0.01, 0.2, 1], [0.3, 0.4, 0.3])
        self.h = Basis('H', [bfs, bfp], 'simple')
        bfs = BasisFunction('S', [0.1, 0.4], [0.6, 0.4])
        bfp = BasisFunction('P', [0.1, 0.4, 3], [0.2, 0.3, 0.5])
        self.c = Basis('C', [bfs, bfp], 'simple')

        atoms = OrderedDict([('H', self.h), ('C', self.c)])
        self.basis_set = BasisSet(atoms)
예제 #2
0
    def test_read_basis_set(self):
        """Test reading a basis from a file"""
        tmp_basis_file = 'basis.gbs.tmp1'
        basis_set = BasisSet()
        basis_set['B'] = Basis('B',
                               [BasisFunction('S', [0.2, 0.4], [0.3, 0.7])])
        open(tmp_basis_file, 'w').write(basis_set.print('gamess'))
        self.g.read_basis_set(tmp_basis_file)
        self.assertEqual(basis_set, self.g.basis_set)

        os.remove(tmp_basis_file)
예제 #3
0
    def test_write_input(self):
        """Test writing an input to a basis file"""
        tmp_basis_file = 'basis.gbs.tmp'
        basis_set = BasisSet()
        basis_set['H'] = Basis('H', [BasisFunction('S', [1], [1])])
        basis_set['O'] = Basis(
            'O', [BasisFunction('S', [1], [1]),
                  BasisFunction('S', [2], [1])])
        basis_set['C'] = Basis('C', [
            BasisFunction('S', [1], [1]),
            BasisFunction('SP', [1, 2], [[0.4, 0.6], [0.1, 0.9]])
        ])
        with open(tmp_basis_file, 'w') as f:
            f.write(basis_set.print('gamess'))
        tmp_geom_file = 'geom.xyz.tmp'
        self.formaldehyde_xyz.write(tmp_geom_file)
        tmp_ecp_file = 'ecp.dat.tmp'
        ecp = """\
C-ECP GEN   10  2
    3      ----- d-ul potential     -----
      -10.0000000        1    357.3914469
      -60.2990287        2     64.6477389
      -10.4217834        2     16.0960833
O-ECP NONE"""
        with open(tmp_ecp_file, 'w') as f:
            f.write(ecp)
        tmp_options_file = 'options.dat.tmp'
        options_str = ' $CONTRL\n    SCFTYP=RHF\n $END\n\n $SCF\n    DIRSCF=.TRUE.\n $END\n\n'
        with open(tmp_options_file, 'w') as f:
            f.write(options_str)
        tmp_dat_file = 'dat.tmp'
        vec = ' $VEC\n12 23 31\n33241 32523 11.0\n $END'
        hess = ' $HESS\n32 43 987\n453 443 11.0\n $END'
        data = 'Hey\n' + vec + ' \n random other text\n' + hess + '\n more text\n122\n'
        with open(tmp_dat_file, 'w') as f:
            f.write(data)

        self.g.read(tmp_geom_file, tmp_basis_file, tmp_ecp_file,
                    tmp_options_file, tmp_dat_file)

        tmp_input_file = 'input.inp.tmp'
        self.g.write_input(tmp_input_file)

        os.remove(tmp_geom_file)
        os.remove(tmp_basis_file)
        os.remove(tmp_ecp_file)
        os.remove(tmp_options_file)
        os.remove(tmp_input_file)
        os.remove(tmp_dat_file)
예제 #4
0
 def test_getsetdeleq(self):
     """Test __getitem__, __setitem__, __delitem__, and __eq__"""
     bfs = BasisFunction('S', [0.2, 0.4], [0.3, 0.7])
     b = Basis('B', [bfs])
     self.basis_set['B'] = b
     self.assertEqual(self.c, self.basis_set['C'])
     self.assertEqual(b, self.basis_set['B'])
     del self.basis_set['B']
     self.assertRaises(KeyError, self.basis_set.__getitem__, 'B')
     bfs = BasisFunction('S', [1, 2], [0.5, 0.5])
     bfp = BasisFunction('P', [0.01, 0.2, 1], [0.3, 0.4, 0.3])
     h = Basis('H', [bfs, bfp])
     bfs = BasisFunction('S', [0.1, 0.4], [0.6, 0.4])
     bfp = BasisFunction('P', [0.1, 0.4, 3],
                         [[0.2, 0.3, 0.5], [0.1, 0.3, 0.6]])
     c = Basis('C', [bfs, bfp])
     atoms = OrderedDict([('H', h), ('C', c)])
     atoms = OrderedDict([('H', h)])
     basis_set2 = BasisSet(atoms)
     self.assertEqual(basis_set2, self.basis_set)