예제 #1
0
 def test_cutCylinderCoords(self):
     f = collect('unitTests/sampleCoords.xyz')
     index, atomType, cylinder = f.cutCylinder(3, 4, radius=5.0, dim=False)
     answer = np.array([[0.0, 0.0, 0.0], [0.75, 0.75, 0.0],
                        [-0.75, 0.75, 0.0], [0.0, 0.0, -5.0],
                        [0.0, 0.0, 5.0]])
     np.testing.assert_array_almost_equal(cylinder, answer)
예제 #2
0
    def __det_calc_type(self):
        '''
        In an input file, determine the calc type based on what was in the
        input block.  If an output file, do this based on what was found in 
        the file, but cross-check against input block.
        This is done for cross-package  support. Return as a set.
        '''

        # If no input block was read in, try to find one in an input file
        if not self.key:
            from os.path import splitext
            from chemPackage import collect, CollectionError
            from textwrap import dedent
            for ext in ('.run', '.inp'):
                inp = splitext(self.filename)[0] + ext
                try:
                    inp = collect(inp)
                except IOError:
                    pass
                else:
                    break
            else:
                from textwrap import dedent
                raise CollectionError(
                    dedent('''\
                The chem package requires the output file to have a copy of
                the input block or have the input file be in the same directory
                as the output file. The input block is used to determine the
                calculation type and check for errors.
                '''))
            # Copy the input file's input block into this one
            self.key = inp.key
            self.subkey = inp.subkey

        # Determine calculation type
        if 'EXCITEDGO' in self.key:
            self.calctype.add('EXCITED STATE')
        if 'EXCITATION' in self.key:
            self.calctype.add('EXCITATIONS')
        if 'RAMAN' in self.subkey:
            self.calctype.add('RAMAN')
        if 'VROA' in self.subkey:
            self.calctype.add('VROA')
            self.calctype.add('OPTICAL ROTATION')
            self.calctype.add('POLARIZABILITY')
        if 'AORESPONSE' in self.key or 'RESPONSE' in self.key:
            if 'OPTICAL ROTATION' in self.subkey:
                self.calctype.add('OPTICAL ROTATION')
            else:
                self.calctype.add('POLARIZABILITY')
            if 'HYPERPOL' in self.subkey or 'TWONPLUSONE' in self.subkey or 'BETA' in self.subkey:
                #if 'HYPERPOL' in self.subkey or 'BETA' in self.subkey:
                self.calctype.add('HYPERPOLARIZABILITY')
            if 'GAMMA' in self.subkey:
                self.calctype.add('SECOND HYPERPOLARIZABILITY')
            if 'LIFETIME' in self.subkey or 'DYNAHYP' in self.subkey:
                self.calctype.add('FD')
            else:
                self.calctype.add('STATIC')
        if 'FREQUENCIES' in self.subkey:
            self.calctype.add('FREQUENCIES')
        if 'GEOMETRY' in self.key:
            it = 'ITERATIONS'
            x = [x for x in self.key['GEOMETRY'][1] if it in x.upper()]
            if 'EXCITED STATE' in self.calctype:
                try:
                    i = int(x[0].split()[1])
                except IndexError:
                    self.calctype.add('GEOMETRY')
                else:
                    if i > 1: self.calctype.add('GEOMETRY')
            elif 'FREQUENCIES' not in self.subkey:
                self.calctype.add('GEOMETRY')
            elif 'ANALYTICALFREQ' in self.key:
                self.calctype.add('GEOMETRY')
        if 'DIMQM' in self.key:
            self.calctype.add('DIM')
        if 'FRAGMENTS' in self.key:
            if self.key['FRAGMENTS'][1][0].split()[1][0:3] != 't21':
                self.calctype.add('FRAGMENT ANALYSIS')
        if 'UNRESTRICTED' in self.key:
            self.calctype.add('UNRESTRICTED')
        if 'FDE' in self.key:
            self.calctype.add('FDE')
        if 'SUBEXCI' in self.key:
            self.calctype.add('FDE')
            self.calctype.add('SUBEXCI')
        if 'SUBRESPONSE' in self.key:
            self.calctype.add('FDE')
            self.calctype.add('SUBRESPONSE')
        if 'SOLVATION' in self.key:
            self.calctype.add('COSMO')

        # All ADF is DFT calculations
        self.calctype.add('DFT')
예제 #3
0
 def setUp(self):
     self.test = collect('unitTests/nh3Geom.out')
     self.test2 = collect('unitTests/nh3Freq.out')
     self.test3 = collect('unitTests/nh3Pol.out')
     self.test4 = collect('unitTests/nh3Pol2.out')
     self.test5 = collect('unitTests/DIM_spe.out')
예제 #4
0
 def setUp(self):
     self.test = collect('unitTests/nh3Geom.out')
예제 #5
0
 def test_cutCylinderAtomType(self):
     f = collect('unitTests/sampleCoords.xyz')
     index, atomType, cylinder = f.cutCylinder(3, 4, radius=5.0, dim=False)
     answer = np.array(['H', 'O', 'O', 'Ag', 'Ag'])
     np.testing.assert_array_equal(atomType, answer)
예제 #6
0
 def test_cutCylinderIndex(self):
     f = collect('unitTests/sampleCoords.xyz')
     index, atomType, cylinder = f.cutCylinder(3, 4, radius=5.0, dim=False)
     answer = np.array([0, 1, 2, 3, 4])
     np.testing.assert_array_almost_equal(index, answer)
예제 #7
0
 def setUp(self):
     self.test = collect('unitTests/h2o_freq.out')
예제 #8
0
 def setUp(self):
     self.test = collect('unitTests/raman-benzene.out')
예제 #9
0
 def setUp(self):
     self.test = collect('unitTests/nh3Freq.out')
예제 #10
0
 def setUp(self):
     self.test = collect('unitTests/nh3Pol2.out')
     self.testDamp = collect('unitTests/nh3Pol.out')
예제 #11
0
def collect_values(args):
    '''Collect the pertinent information from file, and verify it.'''
    from chemPackage import collect
    from numpy import array, reshape

    # Check that when the excited states are listed with the excite option,
    # that we also list a directory for collecting data from. 
    if (args.excite and not args.dirs) or (args.dirs and not args.excite):
        sys.exit('Need either both or neither of --excite and --dirs')
    # Verify that we have the correct number of directories to collect
    # data from.
    if args.excite:
        if len(args.excite) != len(args.dirs) and  len(args.dirs) > 1:
            sys.exit('# of --excite and --dirs must be equal')
        # If --dirs is 1, then fill to match excite
        if len(args.dirs) == 1 and len(args.excite) > 1:
            for i in range(1, len(args.excite), 1):
                args.dirs.append(args.dirs[0])
        # If --excited is 1, then fill to match excite
        if len(args.excited) == 1 and len(args.excite) > 1:
            for i in range(1, len(args.excite), 1):
                args.excited.append(args.excited[0])
            
    # Collect the ground state geometry and normal modes, and make
    # sure it is of the correct type
    modes = collect(args.modes)
    assert 'FREQUENCIES' in modes.calctype, (
       'The MODES file {0} has no frequencies info.'.format(modes.filename))

    # Collect all the excited state information, and make
    # sure it is of the correct type
    es = []
    for i, f in enumerate(args.excited):
        if args.excite:
            # Collect the equilibrium excitation
            es.append(collect(f))
            # Determine the sign of the transition dipole moment and two-photon
            # transition moment at the equilibrium geometry
            sign_tdm, sign_stpm = transmom_sign(es[i], args)
            # Collect the numerical deltas from the given directories and the
            # given excitations.
            temp = modes.copy()
            temp.collect_raman_derivatives(dir=args.dirs[i],
                                           excitation=args.excite[i],
                                           gdipder=args.IR,
                                           tdipder=args.dtdip,
                                           tdipref=sign_tdm)
            #if args.dstpm:
            #
            # Place the delta and excited state number information into that dataset
            es[i].include(temp)
            es[i].es = args.excite[i]
            assert 'DELTAS' in es[i].calctype, (
                    'The EXCITED directory {0} did not yield deltas'.format(
                                                   args.dirs[i]))
        else:
            es.append(collect(f))
            assert 'EXCITED STATE' in es[i].calctype, (
                               'The EXCITED file {0} has no es info.'.format(f))

    # Make the number of normal modes match the number of numerical deltas
    if args.excite:
        # If the number of deltas is not the same for all, exit
        if len(set([x.nmodes for x in es])) != 1:
            sys.exit('Each set of numerical deltas must be of the same length')
        else:
            modes.nmodes        = es[0].nmodes
            modes.IR            = es[0].IR.copy()
            modes.normal_modes  = es[0].normal_modes.copy()
            modes.v_frequencies = es[0].v_frequencies.copy()

    # Determine if we will use the excited state gradient or optimized
    # geometry method.  Base this on the first file given, and only if
    # not chosen explicitly on the command line.
    if not args.esgrad:
        args.esgrad = True if 'GEOMETRY' not in es[0].calctype else False
   
    return modes, es