Exemplo n.º 1
0
    def qc_conf(self, species, geom, index=-1, ring=0):
        """ 
        Creates a geometry optimization input for the conformational search and runs it.
        qc: 'gauss' or 'nwchem'
        wellorts: 0 for wells and 1 for saddle points
        index: >=0 for sampling, each job will get numbered with index
        """
        if index == -1:
            job = 'conf/' + str(species.chemid) + '_well'
        else:
            r = ''
            if ring: r = 'r'
            if species.wellorts:
                job = 'conf/' + species.name + '_' + r + str(index).zfill(
                    self.zf)
            else:
                job = 'conf/' + str(
                    species.chemid) + '_' + r + str(index).zfill(self.zf)

        if species.wellorts:
            kwargs = self.get_qc_arguments(job,
                                           species.mult,
                                           species.charge,
                                           ts=1,
                                           step=1,
                                           max_step=1)
        else:
            kwargs = self.get_qc_arguments(job, species.mult, species.charge)
            if self.qc == 'gauss':
                kwargs['opt'] = 'CalcFC, Tight'

        del kwargs['chk']

        atom = copy.deepcopy(species.atom)

        dummy = geometry.is_linear(geom, species.bond)
        if len(dummy) > 0:  # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom, ['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]

        template_file = pkg_resources.resource_filename(
            'tpl', 'ase_{qc}_opt_well.py.tpl'.format(qc=self.qc))
        template = open(template_file, 'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command)

        f_out = open('{}.py'.format(job), 'w')
        f_out.write(template)
        f_out.close()

        self.submit_qc(job)

        return 0
Exemplo n.º 2
0
    def qc_ring_conf(self, species, geom, fix, change, conf_nr, scan_nr):
        """ 
        Creates a constrained geometry optimization input for the
        conformational search of cyclic structures and runs it.
        Make use of the ASE optimizer PCOBFGS

        qc: 'gauss' or 'nwchem'
        scan: list of dihedrals to be scanned and their values
        wellorts: 0 for wells and 1 for saddle points
        conf_nr: number of the conformer in the conformer search
        scan_nr: number of the scan for this conformer
        """
        if species.wellorts:
            job = 'conf/' + species.name + '_r' + str(conf_nr).zfill(
                self.zf) + '_' + str(scan_nr).zfill(self.zf)
        else:
            job = 'conf/' + str(species.chemid) + '_r' + str(conf_nr).zfill(
                self.zf) + '_' + str(scan_nr).zfill(self.zf)

        kwargs = self.get_qc_arguments(job,
                                       species.mult,
                                       species.charge,
                                       ts=species.wellorts,
                                       step=1,
                                       max_step=1,
                                       hir=1)

        del kwargs['opt']
        del kwargs['chk']
        kwargs['method'] = 'am1'
        kwargs['basis'] = ''

        atom = copy.deepcopy(species.atom)

        dummy = geometry.is_linear(geom, species.bond)
        if len(dummy) > 0:  # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom, ['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]

        template_file = pkg_resources.resource_filename(
            'tpl', 'ase_{qc}_ring_conf.py.tpl'.format(qc=self.qc))
        template = open(template_file, 'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   fix=fix,
                                   change=change,
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command)

        f_out = open('{}.py'.format(job), 'w')
        f_out.write(template)
        f_out.close()

        self.submit_qc(job)
        return 0
Exemplo n.º 3
0
    def qc_hir(self, species, geom, rot_index, ang_index, fix, rigid):
        """
        Creates a constrained geometry optimization input and runs it.
        wellorts: 0 for wells and 1 for saddle points
        rot_index: index of the rotor in the molecule
        ang_index: index for the current size of the angle
        fix: four atoms of the dihedral that is currently fixed
        """
        if species.wellorts:
            job = 'hir/' + species.name + '_hir_' + str(rot_index) + '_' + str(
                ang_index).zfill(2)
        else:
            job = 'hir/' + str(species.chemid) + '_hir_' + str(
                rot_index) + '_' + str(ang_index).zfill(2)

        kwargs = self.get_qc_arguments(job,
                                       species.mult,
                                       species.charge,
                                       ts=species.wellorts,
                                       step=1,
                                       max_step=1,
                                       high_level=1,
                                       hir=1,
                                       rigid=rigid)
        kwargs['fix'] = fix
        del kwargs['chk']

        atom = copy.deepcopy(species.atom)

        dummy = geometry.is_linear(geom, species.bond)
        if len(dummy) > 0:  # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom, ['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]

        template_file = pkg_resources.resource_filename(
            'tpl', 'ase_{qc}_hir.tpl.py'.format(qc=self.qc))
        template = open(template_file, 'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job), 'w')
        f_out.write(template)
        f_out.close()

        self.submit_qc(job)

        return 0
Exemplo n.º 4
0
    def qc_conf(self,species, geom, index=-1, ring = 0):
        """ 
        Creates a geometry optimization input for the conformational search and runs it.
        qc: 'gauss' or 'nwchem'
        wellorts: 0 for wells and 1 for saddle points
        index: >=0 for sampling, each job will get numbered with index
        """
        if index == -1:
            job = 'conf/' + str(species.chemid) + '_well'
        else:
            r = ''
            if ring: r = 'r'
            if species.wellorts:
                job = 'conf/' + species.name + '_' + r + str(index).zfill(self.zf)
            else:
                job = 'conf/' + str(species.chemid) + '_' + r + str(index).zfill(self.zf)
        
        if species.wellorts:
            kwargs = self.get_qc_arguments(job,species.mult,species.charge, ts = 1, step = 1, max_step = 1)
        else:
            kwargs = self.get_qc_arguments(job,species.mult,species.charge)
            if self.qc == 'gauss':
                kwargs['opt'] = 'CalcFC, Tight'
        
        del kwargs['chk']
        
        atom = copy.deepcopy(species.atom)
        
        dummy = geometry.is_linear(geom,species.bond)
        if len(dummy) > 0: # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom,['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]
        
        template_file = pkg_resources.resource_filename('tpl', 'ase_{qc}_opt_well.py.tpl'.format(qc = self.qc))
        template = open(template_file,'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs, 
                                   atom=list(atom), 
                                   geom=list([list(gi) for gi in geom]),
                                   ppn = self.ppn,
                                   dummy = dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job),'w')
        f_out.write(template)
        f_out.close()
        
        self.submit_qc(job)

        return 0
Exemplo n.º 5
0
    def qc_ring_conf(self,species, geom, fix, change, conf_nr, scan_nr):
        """ 
        Creates a constrained geometry optimization input for the
        conformational search of cyclic structures and runs it.
        Make use of the ASE optimizer PCOBFGS

        qc: 'gauss' or 'nwchem'
        scan: list of dihedrals to be scanned and their values
        wellorts: 0 for wells and 1 for saddle points
        conf_nr: number of the conformer in the conformer search
        scan_nr: number of the scan for this conformer
        """
        if species.wellorts:
            job = 'conf/' + species.name + '_r' + str(conf_nr).zfill(self.zf) + '_' + str(scan_nr).zfill(self.zf)
        else:
            job = 'conf/' + str(species.chemid) + '_r' + str(conf_nr).zfill(self.zf) + '_' + str(scan_nr).zfill(self.zf)
        
        kwargs = self.get_qc_arguments(job,species.mult,species.charge, ts=species.wellorts, step=1, max_step=1, hir=1)
        
        del kwargs['opt']
        del kwargs['chk']
        kwargs['method'] = 'am1'
        kwargs['basis'] = ''
        
        atom = copy.deepcopy(species.atom)
        
        dummy = geometry.is_linear(geom,species.bond)
        if len(dummy) > 0: # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom,['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]
    
        template_file = pkg_resources.resource_filename('tpl', 'ase_{qc}_ring_conf.py.tpl'.format(qc = self.qc))
        template = open(template_file,'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   fix=fix,
                                   change=change,
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job),'w')
        f_out.write(template)
        f_out.close()
        
        self.submit_qc(job)
        return 0
Exemplo n.º 6
0
    def qc_freq(self, species, geom, high_level=0):
        """
        Creates a frequency input and runs it.
        """

        job = str(species.chemid) + '_fr'
        if high_level:
            job = str(species.chemid) + '_fr_high'

        kwargs = self.get_qc_arguments(job,
                                       species.mult,
                                       species.charge,
                                       high_level=high_level)
        if self.qc == 'gauss':
            kwargs['freq'] = 'freq'
            kwargs['ioplist'] = ['7/33=1']
        elif self.qc == 'nwchem':
            kwargs['task'] = 'frequencies'

        atom = copy.deepcopy(species.atom)

        dummy = geometry.is_linear(geom, species.bond)
        if len(dummy) > 0:  # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom, ['X'])
                geom = np.concatenate((geom, [d]), axis=0)
            # switch on the symmetry of gaussian
            if 'NoSymm' in kwargs:
                del kwargs['NoSymm']
        dummy = [d.tolist() for d in dummy]

        template_file = pkg_resources.resource_filename(
            'tpl', 'ase_{qc}_freq_well.tpl.py'.format(qc=self.qc))
        template = open(template_file, 'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job), 'w')
        f_out.write(template)
        f_out.close()

        self.submit_qc(job)

        return 0
Exemplo n.º 7
0
    def qc_opt(self, species, geom, high_level=0, mp2=0):
        """ 
        Creates a geometry optimization input and runs it. 
        """

        job = str(species.chemid) + '_well'
        if high_level:
            job = str(species.chemid) + '_well_high'
        if mp2:
            job = str(species.chemid) + '_well_mp2'

        kwargs = self.get_qc_arguments(job,
                                       species.mult,
                                       species.charge,
                                       high_level=high_level)
        if self.qc == 'gauss':
            kwargs['opt'] = 'CalcFC, Tight'
        if mp2:
            kwargs['method'] = 'mp2'

        atom = copy.deepcopy(species.atom)

        dummy = geometry.is_linear(geom, species.bond)
        if len(dummy) > 0:  # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom, ['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]

        template_file = pkg_resources.resource_filename(
            'tpl', 'ase_{qc}_opt_well.py.tpl'.format(qc=self.qc))
        template = open(template_file, 'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command)

        f_out = open('{}.py'.format(job), 'w')
        f_out.write(template)
        f_out.close()

        self.submit_qc(job)

        return 0
Exemplo n.º 8
0
    def qc_freq(self, species, geom, high_level = 0):
        """ 
        Creates a frequency input and runs it. 
        """

        job = str(species.chemid) + '_fr'
        if high_level:
            job = str(species.chemid) + '_fr_high'

        kwargs = self.get_qc_arguments(job, species.mult, species.charge, high_level = high_level)
        if self.qc == 'gauss':
            kwargs['freq'] = 'freq'
            kwargs['ioplist'] = ['7/33=1']
        elif self.qc == 'nwchem':
            kwargs['task'] = 'frequencies'
        
        atom = copy.deepcopy(species.atom)
        
        dummy = geometry.is_linear(geom,species.bond)
        if len(dummy) > 0: # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom,['X'])
                geom = np.concatenate((geom, [d]), axis=0)
            #switch on the symmetry of gaussian
            if 'NoSymm' in kwargs:
                del kwargs['NoSymm']
        dummy = [d.tolist() for d in dummy]
        
        template_file = pkg_resources.resource_filename('tpl', 'ase_{qc}_freq_well.py.tpl'.format(qc = self.qc))
        template = open(template_file,'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs, 
                                   atom=list(atom), 
                                   geom=list([list(gi) for gi in geom]), 
                                   ppn=self.ppn, 
                                   dummy=dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job),'w')
        f_out.write(template)
        f_out.close()
        
        self.submit_qc(job)
        
        return 0
Exemplo n.º 9
0
 def testLinear(self):
     """
     Test the method to see if a geometry is linear
     """
     np.random.seed(1)
     a = np.random.uniform(size=3)
     b = np.random.uniform(size=3)
     d1 = np.random.rand()
     d2 = np.random.rand()
     c = a + b / np.linalg.norm(b) * d1
     d = a + b / np.linalg.norm(b) * d2
     geom = [a, c, d]
     bond = [[0, 1, 0], [1, 0, 1], [0, 0, 1]]
     dummy = geometry.is_linear(geom, bond)
     exp = 1
     cal = len(dummy)
     warn = 'Linear molecule not well perceived.'
     self.assertEqual(exp, cal, msg=warn)
Exemplo n.º 10
0
    def qc_opt(self, species, geom, high_level = 0, mp2 = 0):
        """ 
        Creates a geometry optimization input and runs it. 
        """
        
        job = str(species.chemid) + '_well'
        if high_level:
            job = str(species.chemid) + '_well_high'
        if mp2:
            job = str(species.chemid) + '_well_mp2'
        
        kwargs = self.get_qc_arguments(job, species.mult, species.charge, high_level = high_level)
        if self.qc == 'gauss':
            kwargs['opt'] = 'CalcFC, Tight'
        if mp2:
            kwargs['method'] = 'mp2'
        
        atom = copy.deepcopy(species.atom)
        
        dummy = geometry.is_linear(geom,species.bond)
        if len(dummy) > 0: # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom,['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]
        
        template_file = pkg_resources.resource_filename('tpl', 'ase_{qc}_opt_well.py.tpl'.format(qc = self.qc))
        template = open(template_file,'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs, 
                                   atom=list(atom), 
                                   geom=list([list(gi) for gi in geom]),
                                   ppn=self.ppn,
                                   dummy = dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job),'w')
        f_out.write(template)
        f_out.close()
        
        self.submit_qc(job)

        return 0
Exemplo n.º 11
0
    def qc_hir(self,species, geom, rot_index, ang_index,fix):
        """ 
        Creates a constrained geometry optimization input and runs it. 
        wellorts: 0 for wells and 1 for saddle points
        rot_index: index of the rotor in the molecule
        ang_index: index for the current size of the angle
        fix: four atoms of the dihedral that is currently fixed
        """
        if species.wellorts:
            job = 'hir/' + species.name + '_hir_' + str(rot_index) + '_' + str(ang_index).zfill(2)
        else:
            job = 'hir/' + str(species.chemid) + '_hir_' + str(rot_index) + '_' + str(ang_index).zfill(2)

        kwargs = self.get_qc_arguments(job,species.mult,species.charge, ts = species.wellorts, step = 1, max_step = 1, high_level = 1, hir = 1)
        kwargs['fix'] = fix
        del kwargs['chk']
        
        atom = copy.deepcopy(species.atom)
        
        dummy = geometry.is_linear(geom,species.bond)
        if len(dummy) > 0: # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom,['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]
        
        template_file = pkg_resources.resource_filename('tpl', 'ase_{qc}_hir.py.tpl'.format(qc = self.qc))
        template = open(template_file,'r').read()
        template = template.format(label=job, 
                                   kwargs=kwargs, 
                                   atom=list(atom), 
                                   geom=list([list(gi) for gi in geom]), 
                                   ppn=self.ppn, 
                                   dummy=dummy, 
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job),'w')
        f_out.write(template)
        f_out.close()
        
        self.submit_qc(job)

        return 0
Exemplo n.º 12
0
    def qc_opt(self, species, geom, high_level=0, mp2=0, bls=0):
        """
        Creates a geometry optimization input and runs it.
        """
        job = str(species.chemid) + '_well'
        if high_level:
            job = str(species.chemid) + '_well_high'
        if mp2:
            job = str(species.chemid) + '_well_mp2'
        if bls:
            job = str(species.chemid) + '_well_bls'

        # TODO: Code exceptions into their own function/py script that opt can call.
        # TODO: Fix symmetry numbers for calcs as well if needed
        # O2
        if species.chemid == "320320000000000000001":
            mult = 3
        # CH2
        elif species.chemid == "140260020000000000001":
            mult = 3
        else:
            mult = species.mult

        kwargs = self.get_qc_arguments(job,
                                       mult,
                                       species.charge,
                                       high_level=high_level)

        if self.qc == 'gauss':
            kwargs['opt'] = 'CalcFC, Tight'
        if mp2:
            kwargs['method'] = self.scan_method
            kwargs['basis'] = self.scan_basis
        if high_level:
            if self.opt:
                kwargs['opt'] = 'CalcFC, {}'.format(self.opt)
        # the integral is set in the get_qc_arguments parts, bad design

        atom = copy.deepcopy(species.atom)
        dummy = geometry.is_linear(geom, species.bond)
        if len(dummy) > 0:  # add a dummy atom for each close to linear angle
            for d in dummy:
                atom = np.append(atom, ['X'])
                geom = np.concatenate((geom, [d]), axis=0)
        dummy = [d.tolist() for d in dummy]

        template_file = pkg_resources.resource_filename(
            'tpl', 'ase_{qc}_opt_well.tpl.py'.format(qc=self.qc))
        template = open(template_file, 'r').read()
        template = template.format(label=job,
                                   kwargs=kwargs,
                                   atom=list(atom),
                                   geom=list([list(gi) for gi in geom]),
                                   ppn=self.ppn,
                                   dummy=dummy,
                                   qc_command=self.qc_command,
                                   working_dir=os.getcwd())

        f_out = open('{}.py'.format(job), 'w')
        f_out.write(template)
        f_out.close()

        self.submit_qc(job)
        return 0