示例#1
0
    def get_irc_calc(self,
                     ts=None,
                     mem="5GB",
                     nprocshared=20,
                     scratch=".",
                     method="m062x",
                     basis="6-311+g(2df,2p)"):
        "A method to create the IRC calculator object"

        if ts is None:
            if self.ts is None:
                return None
            elif not isinstance(self.conformer, TS):
                return None
            else:
                ts = self.conformer

        ts.rmg_molecule.updateMultiplicity()
        label = ts.reaction_label.replace(
            "(", "left").replace(")", "right") + "_irc_" + str(ts.index)

        calc = ASEGaussian(mem=mem,
                           nprocshared=nprocshared,
                           label=label,
                           scratch=scratch,
                           method=method,
                           basis=basis,
                           extra="irc=(calcall)",
                           multiplicity=ts.rmg_molecule.multiplicity)
        calc.atoms = ts.ase_molecule
        del calc.parameters['force']

        return calc
示例#2
0
def test_water():
    from ase.calculators.gaussian import Gaussian
    from ase.atoms import Atoms
    from ase.optimize.lbfgs import LBFGS
    from ase.io import read

    # First test to make sure Gaussian works
    calc = Gaussian(xc='pbe', chk='water.chk', label='water')
    calc.clean()

    water = Atoms('OHH',
                  positions=[(0, 0, 0), (1, 0, 0), (0, 1, 0)],
                  calculator=calc)

    opt = LBFGS(water)
    opt.run(fmax=0.05)

    forces = water.get_forces()
    energy = water.get_potential_energy()
    positions = water.get_positions()

    # Then test the IO routines
    water2 = read('water.log')
    forces2 = water2.get_forces()
    energy2 = water2.get_potential_energy()
    positions2 = water2.get_positions()
    # Compare distances since positions are different in standard orientation.
    dist = water.get_all_distances()
    dist2 = read('water.log', index=-1).get_all_distances()

    assert abs(energy - energy2) < 1e-7
    assert abs(forces - forces2).max() < 1e-9
    assert abs(positions - positions2).max() < 1e-6
    assert abs(dist - dist2).max() < 1e-6
示例#3
0
    def get_overall_calc(self,
                         ts=None,
                         direction="forward",
                         settings=None,
                         scratch=None):
        """
        A method to create a calculator that optimizes the overall geometry of a `TS` object

        Parameters:
        - ts (TS): A `TS` object that you want to perform calculations on
        - direction (str): the forward or reverse direction of the `TS` object
        - settings (dict): a dictionary of settings containing method, basis, mem, nprocshared
        - scratch (str): a directory where you want log files to be written to

        Returns:
        - calc (ASEGaussian): an ASEGaussian calculator with all of the proper setting specified
        """

        if settings is None:
            settings = self.settings
        if scratch is None:
            scratch = self.scratch

        method = settings["method"]
        basis = settings["basis"]
        mem = settings["mem"]
        nprocshared = settings["nprocshared"]

        assert direction.lower() in ["forward", "reverse"]

        assert isinstance(ts, TS), "A TS object was not provided..."

        ts.rmg_molecule.updateMultiplicity()

        label = ts.reaction_label + "_" + direction.lower() + "_" + str(
            ts.index)

        new_scratch = os.path.join(scratch, "ts", ts.reaction_label,
                                   "conformers")

        try:
            os.makedirs(new_scratch)
        except OSError:
            pass

        calc = ASEGaussian(
            mem=mem,
            nprocshared=nprocshared,
            label=label,
            scratch=new_scratch,
            method=method,
            basis=basis,
            extra=
            "opt=(ts,calcfc,noeigentest,maxcycles=900) freq scf=(maxcycle=900) IOP(7/33=1,2/16=3)",
            multiplicity=ts.rmg_molecule.multiplicity)
        calc.atoms = ts.ase_molecule
        del calc.parameters['force']

        return calc
示例#4
0
def write_gaussian(filename, atoms):
    """Writes a basic Gaussian input file"""
# Since Gaussian prints the geometry directly into the input file, we'll just
# the write_input method from the Gaussian calculator, and just use the
# default settings
    calc = Gaussian()
    calc.initialize(atoms)
    calc.write_input(filename, atoms)
示例#5
0
    def get_rotor_calc(self,
                       conformer=None,
                       torsion=None,
                       mem="5GB",
                       nprocshared=20,
                       scratch=".",
                       method="m062x",
                       basis="6-311+g(2df,2p)",
                       steps=36,
                       step_size=10.0):
        """
        A method to create all of the calculators needed to perform hindered rotor calculations given a conformer and a torsion
        """

        assert (torsion and (isinstance(torsion, Torsion))
                ), "To create a rotor calculator, you must provide a Torsion object."

        if not conformer:
            if not self.conformer:
                return None
            conformer = self.conformer

        assert isinstance(
            conformer, Conformer), "A Conformer object was not provided..."

        string = ""
        for bond in conformer.bonds:
            i, j = bond.atom_indices
            string += "B {} {}\n".format(i + 1, j + 1)

        i, j, k, l = torsion.atom_indices
        string += "D {} {} {} {} S {} {}".format(i + 1, j + 1, k + 1, l + 1, steps, float(step_size))

        if isinstance(conformer, TS):
            label = self.label + "_tor_{}_{}".format(j, k)
        elif isinstance(conformer, Conformer):
            label = Chem.rdinchi.InchiToInchiKey(Chem.MolToInchi(
                Chem.MolFromSmiles(conformer.smiles))).strip("-N")
            label += "_tor{}{}".format(j, k)

        label = conformer.smiles + "_tor_{}_{}".format(j, k)
        conformer.rmg_molecule.updateMultiplicity()
        mult = conformer.rmg_molecule.multiplicity

        calc = ASEGaussian(mem=mem,
                           nprocshared=nprocshared,
                           label=label,
                           scratch=scratch,
                           method=method,
                           basis=basis,
                           extra="Opt=(CalcFC,ModRedun)",
                           multiplicity=mult,
                           addsec=[string])

        calc.atoms = conformer.ase_molecule
        del calc.parameters['force']

        return calc
示例#6
0
    def get_center_calc(self):
        """
        A method to create a calculator that optimizes the reaction center of a `TS` object

        Parameters:
        - ts (TS): A `TS` object that you want to perform calculations on
        - direction (str): the forward or reverse direction of the `TS` object
        - settings (dict): a dictionary of settings containing method, basis, mem, nprocshared
        - scratch (str): a directory where you want log files to be written to

        Returns:
        - calc (ASEGaussian): an ASEGaussian calculator with all of the proper setting specified
        """

        assert self.conformer.direction.lower() in ["forward", "reverse"]

        assert isinstance(self.conformer,
                          TS), "A TS object was not provided..."

        indicies = []
        for i, atom in enumerate(self.conformer.rmg_molecule.atoms):
            if not (atom.label != ""):
                indicies.append(i)

        addsec = ""
        for combo in list(itertools.combinations(indicies, 2)):
            a, b = combo
            addsec += "{0} {1} F\n".format(a + 1, b + 1)

        self.conformer.rmg_molecule.updateMultiplicity()

        label = self.conformer.reaction_label + "_" + self.conformer.direction.lower(
        ) + "_center_" + str(self.conformer.index)

        new_scratch = os.path.join(self.directory, "ts",
                                   self.conformer.reaction_label, "conformers")

        try:
            os.makedirs(new_scratch)
        except OSError:
            pass

        ase_gaussian = ASEGaussian(
            mem=self.settings["mem"],
            nprocshared=self.settings["nprocshared"],
            label=label,
            scratch=new_scratch,
            method=self.settings["method"],
            basis=self.settings["basis"],
            extra=
            "Opt=(ts,calcfc,noeigentest,ModRedun,maxcycles=900) scf=(maxcycle=900)",
            multiplicity=self.conformer.rmg_molecule.multiplicity,
            addsec=[addsec[:-1]])
        ase_gaussian.atoms = self.conformer.ase_molecule
        del ase_gaussian.parameters['force']

        return ase_gaussian
示例#7
0
    def get_shell_calc(self):
        """
        A method to create a calculator that optimizes the reaction shell of a `TS` object

        Parameters:
        - ts (TS): A `TS` object that you want to perform calculations on
        - direction (str): the forward or reverse direction of the `TS` object
        - settings (dict): a dictionary of settings containing method, basis, mem, nprocshared
        - directory (str): a directory where you want log files to be written to

        Returns:
        - calc (ASEGaussian): an ASEGaussian calculator with all of the proper setting specified
        """
        assert isinstance(self.conformer,
                          TS), "A TS object was not provided..."
        assert self.conformer.direction.lower() in ["forward", "reverse"]

        self.conformer.rmg_molecule.updateMultiplicity()

        label = self.conformer.reaction_label + "_" + self.conformer.direction.lower(
        ) + "_shell_" + str(self.conformer.index)

        new_scratch = os.path.join(self.directory, "ts",
                                   self.conformer.reaction_label, "conformers")

        try:
            os.makedirs(new_scratch)
        except OSError:
            pass

        ind1 = self.conformer.rmg_molecule.getLabeledAtom("*1").sortingLabel
        ind2 = self.conformer.rmg_molecule.getLabeledAtom("*2").sortingLabel
        ind3 = self.conformer.rmg_molecule.getLabeledAtom("*3").sortingLabel

        combos = ""
        combos += "{0} {1} F\n".format(ind1 + 1, ind2 + 1)
        combos += "{0} {1} F\n".format(ind2 + 1, ind3 + 1)
        combos += "{0} {1} {2} F".format(ind1 + 1, ind2 + 1, ind3 + 1)

        ase_gaussian = ASEGaussian(
            mem=self.settings["mem"],
            nprocshared=self.settings["nprocshared"],
            label=label,
            scratch=new_scratch,
            method=self.settings["method"],
            basis=self.settings["basis"],
            extra=
            "Opt=(ModRedun,Loose,maxcycles=900) Int(Grid=SG1) scf=(maxcycle=900)",
            multiplicity=self.conformer.rmg_molecule.multiplicity,
            addsec=[combos])
        ase_gaussian.atoms = self.conformer.ase_molecule
        del ase_gaussian.parameters['force']

        return ase_gaussian
示例#8
0
    def get_conformer_calc(self):
        """
        A method that creates a calculator for a `Conformer` that will perform a geometry optimization

        Parameters:
        - conformer (Conformer): A `Conformer` object that you want to perform hindered rotor calculations on
        - torsion (Torsion): A `Torsion` object that you want to perform hindered rotor calculations about
        - settings (dict): a dictionary of settings containing method, basis, mem, nprocshared
        - scratch (str): a directory where you want log files to be written to
        - convergence (str): ['verytight','tight','' (default)], specifies the convergence criteria of the geometry optimization

        Returns:
        - calc (ASEGaussian): an ASEGaussian calculator with all of the proper setting specified
        """

        if isinstance(self.conformer, TS):
            logging.info(
                "TS object provided, cannot obtain a species calculator for a TS"
            )
            return None

        assert isinstance(self.conformer,
                          Conformer), "A Conformer object was not provided..."

        self.conformer.rmg_molecule.updateMultiplicity()

        label = "{}_{}".format(self.conformer.smiles, self.conformer.index)

        new_scratch = os.path.join(self.directory, "species",
                                   self.conformer.smiles, "conformers")

        try:
            os.makedirs(new_scratch)
        except OSError:
            pass

        ase_gaussian = ASEGaussian(
            mem=self.settings["mem"],
            nprocshared=self.settings["nprocshared"],
            label=label,
            scratch=new_scratch,
            method=self.settings["method"],
            basis=self.settings["basis"],
            extra=
            "opt=(calcfc,maxcycles=900,{}) freq IOP(7/33=1,2/16=3) scf=(maxcycle=900)"
            .format(self.convergence),
            multiplicity=self.conformer.rmg_molecule.multiplicity)
        ase_gaussian.atoms = self.conformer.ase_molecule
        del ase_gaussian.parameters['force']
        return ase_gaussian
示例#9
0
def gaus(mol, lab, level):

    level = level.split('_')

    Trip = False

    sym = mol.get_chemical_symbols()
    is_O = len(sym) == 1 and sym[0] == 'O'
    is_OO = len(sym) == 2 and sym[0] == 'O' and sym[1] == 'O'

    if is_O or is_OO or Trip == True:
        mol.set_calculator(
            Gaussian(
                label=lab,
                maxiter=60,
                geometry='noautoz noautosym nocenter',
                xc='b3lyp',
                basis='6-31+G',
                task=
                'energy ignore \nset dft:converged true \ntask dft gradient',
                mult=3))
    else:
        atom_num = mol.get_atomic_numbers()
        s = sum(atom_num)
        if s % 2 == 0:
            mol.set_calculator(
                Gaussian(
                    label=lab,
                    maxiter=60,
                    geometry='noautoz noautosym nocenter',
                    xc='b3lyp',
                    basis='6-31+G',
                    task=
                    'energy ignore \nset dft:converged true \ntask dft gradient',
                    mult=1))
        else:
            mol.set_calculator(
                Gaussian(
                    label=lab,
                    maxiter=60,
                    geometry='noautoz noautosym nocenter',
                    xc='b3lyp',
                    basis='6-31+G',
                    mult=2,
                    task=
                    'energy ignore \nset dft:converged true \ntask dft gradient'
                ))
    return mol
示例#10
0
    def reactants_or_products_calc(self,
                                   autotst_mol,
                                   mem="5GB",
                                   nprocshared=20,
                                   scratch=".",
                                   method="m062x",
                                   basis="6-311+g(2df,2p)"):
        "A method that creates a calculator for a reactant or product"

        autotst_mol.rmg_molecule.updateMultiplicity()

        # using this round about way of doing stuff because rmg's `toAugumentedInChIKey` method doesn't work on our cluster

        smiles = autotst_mol.rmg_molecule.toSMILES()
        label = Chem.rdinchi.InchiToInchiKey(
            Chem.MolToInchi(Chem.MolFromSmiles(smiles))).strip("-N")

        calc = Gaussian(
            mem=mem,
            nprocshared=nprocshared,
            label=label,
            scratch=scratch,
            method=method,
            basis=basis,
            extra="opt=(verytight,gdiis,maxcycle=1000) freq IOP(2/16=3)",
            multiplicity=autotst_mol.rmg_molecule.multiplicity)
        del calc.parameters['force']

        return calc
示例#11
0
def test_h2of():
    with open('def2-svp.gbs', 'w') as bfile:
        bfile.write(basis)

    atoms = Atoms('OH2F', positions=[(-1.853788, -0.071113, 0.000000),
                                     (-1.892204, 0.888768, 0.000000),
                                     (-0.888854, -0.232973, 0.000000),
                                     (1.765870, 0.148285, 0.000000)])

    label = 'h2of-anion'
    calc = Gaussian(charge=-1.0,
                    basis='gen',
                    method='B3LYP',
                    basisfile='@def2-svp.gbs/N',
                    label=label,
                    ioplist=['6/80=1', '6/35=4000000'],
                    density='current',
                    addsec=['%s.wfx' % label]
                   )
    # FIXME: the "addsec" argument above is correctly incorporated into the
    # input file, but it doesn't appear to do anything to the calculation.
    # What is it for? What is it suppsoed to do?

    atoms.calc = calc
    atoms.get_potential_energy()
示例#12
0
    def get_center_calc(self, mem="5GB", nprocshared=20, scratch=".", method="m062x", basis="6-311+g(2df,2p)"):
        "A method to create the calculator to perform the reaction center opt"

        indicies = []
        for i, atom in enumerate(self.reaction.ts.rmg_ts.atoms):
            if (atom.label == ""):
                indicies.append(i)

        combos = ""
        for combo in list(itertools.combinations(indicies, 2)):
            a, b = combo
            combos += "{0} {1} F\n".format(a+1, b+1)

        self.reaction.ts.rmg_ts.updateMultiplicity()

        label = self.reaction.label.replace(
            "(", "left").replace(")", "right") + "_center"

        calc = Gaussian(mem=mem,
                        nprocshared=nprocshared,
                        label=label,
                        scratch=scratch,
                        method=method,
                        basis=basis,
                        extra="opt=(ts,calcfc,noeigentest,ModRedun)",
                        multiplicity=self.reaction.ts.rmg_ts.multiplicity,
                        addsec=[combos[:-1]])

        del calc.parameters['force']
        return calc
示例#13
0
    def get_center_calc(self,
                        ts=None,
                        mem="5GB",
                        nprocshared=20,
                        scratch=".",
                        method="m062x",
                        basis="6-311+g(2df,2p)"):
        "A method to create a calculator that optimizes the reaction shell"

        if ts is None:
            if self.ts is None:
                return None
            elif not isinstance(self.conformer, TS):
                return None
            else:
                ts = self.conformer

        assert isinstance(ts, TS), "A TS object was not provided..."

        indicies = []
        for i, atom in enumerate(ts.rmg_molecule.atoms):
            if not (atom.label != ""):
                indicies.append(i)

        combos = ""
        for combo in list(itertools.combinations(indicies, 2)):
            a, b = combo
            combos += "{0} {1} F\n".format(a + 1, b + 1)

        ts.rmg_molecule.updateMultiplicity()

        label = ts.reaction_label.replace(
            "(", "left").replace(")", "right") + "_center_" + str(ts.index)

        calc = ASEGaussian(mem=mem,
                           nprocshared=nprocshared,
                           label=label,
                           scratch=scratch,
                           method=method,
                           basis=basis,
                           extra="Opt=(ModRedun,Loose,maxcycles=900) Int(Grid=SG1)",
                           multiplicity=ts.rmg_molecule.multiplicity,
                           addsec=[combos[:-1]])
        calc.atoms = ts.ase_molecule
        del calc.parameters['force']

        return calc
示例#14
0
    def get_species_calc(self,
                         conformer=None,
                         mem="5GB",
                         nprocshared=20,
                         scratch=".",
                         method="m062x",
                         basis="6-311+g(2df,2p)"):
        "A method that creates a calculator for a reactant or product that will perform a geometry optimization"

        if not conformer:
            if not self.conformer:
                return None
            conformer = self.conformer

        if isinstance(conformer, TS):
            logging.info(
                "TS object provided, cannot obtain a species calculator for a TS")
            return None

        assert isinstance(
            conformer, Conformer), "A Conformer object was not provided..."

        conformer.rmg_molecule.updateMultiplicity()

        # using this round about way of doing stuff because rmg's
        # `toAugumentedInChIKey` method doesn't work on our cluster

        smiles = conformer.rmg_molecule.toSMILES()
        label = Chem.rdinchi.InchiToInchiKey(Chem.MolToInchi(
            Chem.MolFromSmiles(smiles))).strip("-N") + "_{}".format(conformer.index)

        calc = ASEGaussian(
            mem=mem,
            nprocshared=nprocshared,
            label=label,
            scratch=scratch,
            method=method,
            basis=basis,
            extra="opt=(calcfc,verytight,gdiis,maxcycles=900) freq IOP(2/16=3)",
            multiplicity=conformer.rmg_molecule.multiplicity)
        calc.atoms = conformer.ase_molecule
        del calc.parameters['force']

        return calc
示例#15
0
 def get_calculator(self):
     # Explicitly set parameters that must for security reasons not be
     # taken from file:
     calc = Gaussian(atoms=self.atoms,
                     command=None,
                     restart=None,
                     ignore_bad_restart_file=Calculator._deprecated,
                     label='Gaussian',
                     directory='.',
                     **self.parameters)
     return calc
示例#16
0
    def get_irc_calc(self):
        """
        A method to create a calculator that runs an IRC calculation the overall geometry of a `TS` object

        Parameters:
        - ts (TS): A `TS` object that you want to perform calculations on
        - direction (str): the forward or reverse direction of the `TS` object
        - settings (dict): a dictionary of settings containing method, basis, mem, nprocshared
        - scratch (str): a directory where you want log files to be written to

        Returns:
        - calc (ASEGaussian): an ASEGaussian calculator with all of the proper setting specified
        """

        assert isinstance(self.conformer,
                          TS), "A TS object was not provided..."

        self.conformer.rmg_molecule.updateMultiplicity()
        label = self.conformer.reaction_label + "_irc_" + self.conformer.direction + "_" + str(
            self.conformer.index)

        new_scratch = os.path.join(self.directory, "ts",
                                   self.conformer.reaction_label, "irc")
        try:
            os.makedirs(new_scratch)
        except OSError:
            pass

        ase_gaussian = ASEGaussian(
            mem=self.settings["mem"],
            nprocshared=self.settings["nprocshared"],
            label=label,
            scratch=new_scratch,
            method=self.settings["method"],
            basis=self.settings["basis"],
            extra="irc=(calcall)",
            multiplicity=self.conformer.rmg_molecule.multiplicity)
        ase_gaussian.atoms = self.conformer.ase_molecule
        del ase_gaussian.parameters['force']

        return ase_gaussian
示例#17
0
def get_atomization(method, basis):

    energies = {}
    atoms = cheminfo.MULTIPLICITY.keys()

    for atom in atoms:

        multiplicity = cheminfo.MULTIPLICITY[atom]

        label = "_tmp_atom_" + atom

        calculator = GaussianCalculator(method=method,
                                        basis=basis,
                                        multiplicity=multiplicity,
                                        label=label)

        del calculator.parameters['force']

        atomobj = ase.Atoms(atom, calculator=calculator)

        calculator.write_input(atomobj)
        command = calculator.command
        command = command.replace("PREFIX", label)
        run_gaussian(command)

        if "G4" in method:
            pattern = method + " Enthalpy"
            line = read_line(label + ".log", pattern)
            line = line.split()
            value = line[2]
        else:
            line = read_line(label + ".log", "SCF Done:")
            line = line.split()
            value = line[4]

        value = float(value)
        energies[atom] = value

        print(atom, value)

    return energies
示例#18
0
文件: gaussian.py 项目: yfyh2013/ase
def write_gaussian(filename, atoms):
    """Writes a basic Gaussian input file"""
    # Since Gaussian prints the geometry directly into the input file, we'll just
    # the write_input method from the Gaussian calculator, and just use the
    # default settings
    calc = Gaussian()
    calc.initialize(atoms)
    calc.write_input(filename, atoms)
示例#19
0
    def get_overall_calc(self,
                         ts=None,
                         mem="5GB",
                         nprocshared=20,
                         scratch=".",
                         method="m062x",
                         basis="6-311+g(2df,2p)"):
        "A method to create a calculator that optimizes the reaction shell"

        if ts is None:
            if self.ts is None:
                return None
            elif not isinstance(self.conformer, TS):
                return None
            else:
                ts = self.conformer

        assert isinstance(ts, TS), "A TS object was not provided..."

        ts.rmg_molecule.updateMultiplicity()

        label = ts.reaction_label.replace(
            "(", "left").replace(")", "right") + "_" + str(ts.index)

        calc = ASEGaussian(
            mem=mem,
            nprocshared=nprocshared,
            label=label,
            scratch=scratch,
            method=method,
            basis=basis,
            extra="opt=(ts,calcfc,noeigentest,maxcycles=900) freq",
            multiplicity=ts.rmg_molecule.multiplicity)
        calc.atoms = ts.ase_molecule
        del calc.parameters['force']

        return calc
def write_gaussian(ase_object, out_dir, **kwargs):
    """
    Write a Gaussian input file based on an ase object.
    Params :: 
    ase_object: ASE IO Object: ASE file containing molecule used as input for 
        Gaussian input file
    out_dir: str: path of directory to write the Gaussian input file
    **kwargs: dict: additional arguments to modify behaviour of gaussian input

    Returns ::
    None

    """
     # this is used to identify the header line and replace it
    HEADER_FLAG = 'HEADER_FLAG'
    # change directory to destination where input file to be saved
    original_dir = getcwd()
    os.chdir(out_dir)
    gaussian_settings = {'method': HEADER_FLAG,
                            'basis': '6-31g',
                            'Opt': 'Tight',
                            'Freq': 'DiagFull ',
                            'multiplicity': 1,
                            'charge': 0,
                            'mem': '50GB',
                            'nproc': 20  # ***20 for Farber and 36 for Caviness 
                            }
    gaussian_settings.update(kwargs)
    # input file created will be gaussian_input.com
    calc = Gaussian(**gaussian_settings, label='gaussian_input')
    ase_object.set_calculator(calc)  
    calc.write_input(ase_object)
    # change back directories
    os.chdir(original_dir)
    format_root(header_flag=HEADER_FLAG,
                    file_name=os.path.join(out_dir, 'gaussian_input.com'))
示例#21
0
文件: calc.py 项目: eribow/adpy_proj
def calc_set_up():

    methods = set(['LSDA','B3LYP','PBE', 'MPW1PW91', 'HF', 'MP2'])
    basis_sets = set(['STO-3G', '3-21G', '6-31G', '6-31+G*', '6-311G',
                    'cc-pVDZ', 'cc-pVTZ', 'cc-pVQZ', 'aug-cc-pVDZ',
                    'aug-cc-pVTZ', 'aug-cc-pVQZ'])

    calc_dir = input("Name folder in which to place calculations (if it doesn't exist within /calc/ it will be created there): ")
    proj_name = input("Name of calculation/project: ")


    # METHODS
    print("Available methods are:")
    for m in methods:
        print(m)

    method = ''
    while not (method in methods):
        method = input("Select method: ")

        if not (method in methods):
            print("method " + method + " doesn't exist, try gain")


    # BASIS SETS
    print("Available basis sets are:")
    for basis in basis_sets:
        print(basis)

    basis = ''
    while not (basis in basis_sets):
        basis = input("Select basis set: ")

        if not (basis in basis_sets):
            print("Basis set " + basis + " doesn't exist, try gain")


    # Returning ase.calculator object with specified settings
    # TODO - maybe return several calculators depending on what we need later?
    return Gaussian(mem='4GB',
                    nprocshared='8',
                    label='calc/' + calc_dir + "/" + proj_name,
                    xc=method,
                    basis=basis,
                    scf=['tight','novaracc'],
                    integral='noxctest',
                    freq=''
                    ), 'calc/' + calc_dir
示例#22
0
    def get_rotor_calcs(self,
                        autotst_object,
                        mem="5GB",
                        nprocshared=20,
                        scratch=".",
                        method="m062x",
                        basis="6-311+g(2df,2p)"):
        """ A method to create all of the calculators needed to perform hindered rotor calculations"""

        calculators = {}
        for torsion in autotst_object.torsions:
            string = ""
            for bond in autotst_object.bonds:
                i, j = bond.indices
                string += "B {} {}\n".format(i + 1, j + 1)

            i, j, k, l = torsion.indices
            string += "D {} {} {} {} S 36 10.0".format(i + 1, j + 1, k + 1,
                                                       l + 1)

            if isinstance(autotst_object, AutoTST_Reaction):
                label = autotst_object.label + "_tor_{}_{}".format(j, k)
                mult = autotst_object.ts.rmg_ts.multiplicity
            elif isinstance(autotst_object, AutoTST_TS):
                label = autotst_object.label + "_tor_{}_{}".format(j, k)
                mult = autotst_object.rmg_ts.multiplicity
            elif isinstance(autotst_object, AutoTST_Molecule):
                smiles = autotst_object.rmg_molecule.toSMILES()
                label = Chem.rdinchi.InchiToInchiKey(
                    Chem.MolToInchi(Chem.MolFromSmiles(smiles))).strip("-N")
                label += "_tor{}{}".format(j, k)
                mult = autotst_object.rmg_molecule.multiplicity

            calc = Gaussian(mem=mem,
                            nprocshared=nprocshared,
                            label=label,
                            scratch=scratch,
                            method=method,
                            basis=basis,
                            extra="Opt=(CalcFC,ModRedun)",
                            multiplicity=mult,
                            addsec=[string])

            del calc.parameters['force']
            calculators[(j, k)] = calc

        return calculators
示例#23
0
def main():
    arg = sys.argv
    # Basically, the entire CP2K input is passed in explicitly.
    # Disable ASE's input generation by setting everything to None.
    # ASE should only add the CELL and the COORD section.
    calc=Gaussian(method='M062x',
                basis='6-311++G(d,p)',
                nproc = int(arg[3]),
                charge = 0,
                force = 'force',
                chk = '3w.chk',
                label='3w')
    p1 = read(arg[1],index=0,format='xyz')
    #p1.set_cell([[20,0,0],[0,20,0],[0,0,20]],scale_atoms=False,fix=None)
    #p1.set_pbc((True, True, True))
    p1.set_calculator(calc)
    p2 = read(arg[2],index=0,format='xyz')
    #p2.set_cell([[20,0,0],[0,20,0],[0,0,20]],scale_atoms=False,fix=None)
    #p2.set_pbc((True, True, True))
    p2.set_calculator(calc)
#    MaxwellBoltzmannDistribution(slab_from_file, 0.5 * 300 * units.kB, force_temp=True)
#    energy_start = atoms.get_potential_energy() + atoms.get_kinetic_energy()
#    dyn = VelocityVerlet(slab_from_file, 0.5 * units.fs)
    #def print_md():
    #    energy = atoms.get_potential_energy() + atoms.get_kinetic_energy()
    #    print("MD total-energy: %.10feV" %  energy)
    #dyn.attach(print_md, interval=1)
#    dyn.run(20)
    nim = 9  # number of images, including end points
    band = neb.ssneb(p1, p2, numImages = nim, method = 'normal', ss=False)
    if len(arg)>4:
       restart = True
    else:
       restart = False
# to restart, uncomment the following lines which read the previous optimized images into the band
    if restart:
       for i in range(1,nim-1):
           filename = str(i)+'.CON'
           b = read(filename,format='vasp')
           band.path[i].set_positions(b.get_positions())
           band.path[i].set_cell(b.get_cell())

#    opt = neb.qm_ssneb(band, maxmove =0.2, dt=0.05)
    opt = neb.fire_ssneb(band, maxmove =0.2, dtmax = 0.1, dt=0.1)
    opt.minimize(forceConverged=0.1, maxIterations = 1000)
示例#24
0
    def get_irc_calc(self, mem="5GB", nprocshared=20, scratch=".", method="m062x", basis="6-311+g(2df,2p)"):
        "A method to create the IRC calculator object"

        self.reaction.ts.rmg_ts.updateMultiplicity()
        label = self.reaction.label.replace(
            "(", "left").replace(")", "right") + "_irc"

        calc = Gaussian(mem=mem,
                        nprocshared=nprocshared,
                        label=label,
                        scratch=scratch,
                        method=method,
                        basis=basis,
                        extra="irc=(calcall)",
                        multiplicity=self.reaction.ts.rmg_ts.multiplicity)

        del calc.parameters['force']
        return calc
示例#25
0
    def get_overall_calc(self, mem="5GB", nprocshared=20, scratch=".", method="m062x", basis="6-311+g(2df,2p)"):
        "A method to create the calculator to perform the full TS optimization"

        self.reaction.ts.rmg_ts.updateMultiplicity()

        label = self.reaction.label.replace("(", "left").replace(")", "right")

        calc = Gaussian(mem=mem,
                        nprocshared=nprocshared,
                        label=label,
                        scratch=scratch,
                        method=method,
                        basis=basis,
                        extra="opt=(ts,calcfc,noeigentest) freq",
                        multiplicity=self.reaction.ts.rmg_ts.multiplicity)

        del calc.parameters['force']
        return calc
示例#26
0
文件: calc.py 项目: eribow/adpy_proj
def vib(struct, proj_path):
    #struct.calc = Gaussian(label='calc/' + proj_name + '/freq',
    #                        freq='')
    print("\nBeginning calculation of IR frequencies...")

    struct.calc = Gaussian(mem='4GB',
                    nprocshared='8',
                    label=proj_path + '/vib',
                    )
    #struct.get_potential_energy()
    ir = Infrared(struct)
    ir.run()
    ir.write_spectra('ir_spectra.dat')
    spectrum = ir.get_spectrum()
    ir.clean() # to get rid of disturbing .pckl files cluttering the directory
    print("Calculation of vibrational frequencies completed!\nPrinting spectrum...")

    return struct, spectrum
示例#27
0
    def get_shell_calc(self,
                       mem="5GB",
                       nprocshared=20,
                       scratch=".",
                       method="m062x",
                       basis="6-311+g(2df,2p)"):
        "A method to create a calculator that optimizes the reaction shell"

        indicies = []
        for i, atom in enumerate(self.reaction.ts.rmg_ts.atoms):
            if not (atom.label == ""):
                indicies.append(i)

        combos = ""
        for combo in list(itertools.combinations(indicies, 2)):
            a, b = combo
            combos += "{0} {1} F\n".format(a + 1, b + 1)

        self.reaction.ts.rmg_ts.updateMultiplicity()

        label = self.reaction.label.replace("(", "left").replace(
            ")", "right") + "_shell"

        calc = Gaussian(
            mem=mem,
            nprocshared=nprocshared,
            label=label,
            scratch=scratch,
            method=method,
            basis=basis,
            extra="Opt=(ModRedun,Loose,maxcycle=1000) Int(Grid=SG1)",
            multiplicity=self.reaction.ts.rmg_ts.multiplicity,
            addsec=[combos[:-1]])

        del calc.parameters['force']
        return calc
示例#28
0
from ase.test import NotAvailable

from ase.calculators.gaussian import Gaussian

if Gaussian().get_command() is None:
    raise NotAvailable('Gaussian required')

from ase.atoms import Atoms
from ase.optimize.lbfgs import LBFGS

# First test to make sure Gaussian works
calc = Gaussian(method='pbepbe', basis='sto-3g', force='force',
                nproc=1, chk='water.chk', label='water')
calc.clean()

water = Atoms('OHH',
              positions=[(0., 0. ,0. ), (1. ,0. ,0. ), (0. ,1. ,0. )],
              calculator=calc)

opt = LBFGS(water)
opt.run(fmax=0.05)

forces = water.get_forces()
energy = water.get_potential_energy()
positions = water.get_positions()

# Then test the IO routines
from ase.io import read
water2 = read('water/water.log')
forces2 = water2.get_forces()
energy2 = water2.get_potential_energy()
示例#29
0
文件: gausddmc.py 项目: grhawk/ASE
 def write_input(self, atoms, properties=None, systems_changes=None):
     self.gaus_calc = Gaussian(label=self.label)
     self.gaus_calc.parameters.update(self.gausdict)
     self.ddmc_calc = dDMC(label=self.label)
     self.ddmc_calc.parameters.update(self.ddmcdict)
示例#30
0
from math import pi
import numpy as np

import ase
from ase import Atoms
from ase.calculators.gaussian import Gaussian
from ase.optimize import BFGS
from ase.db import connect
from ase.constraints import FixInternals

label = '{label}'
kwargs = {kwargs}

Gaussian.command = '{qc_command} < PREFIX.com > PREFIX.log'
calc = Gaussian(**kwargs)

atom = {atom}
geom = {geom}

mol = Atoms(symbols=atom, positions=geom)
mol.set_calculator(calc)

try:
    e = mol.get_potential_energy(
    )  # use the Gaussian optimizer (task optimize)
    """
    #read the geometry from the output file
    outfile = '{label}.log'
    with open(outfile) as f:
        lines = f.readlines()
示例#31
0
文件: water.py 项目: essil1/ase-laser
from ase.calculators.gaussian import Gaussian
from ase.atoms import Atoms
from ase.optimize.lbfgs import LBFGS

# First test to make sure Gaussian works
calc = Gaussian(method='pbepbe',
                basis='sto-3g',
                force='force',
                nproc=1,
                chk='water.chk',
                label='water')
calc.clean()

water = Atoms('OHH',
              positions=[(0, 0, 0), (1, 0, 0), (0, 1, 0)],
              calculator=calc)

opt = LBFGS(water)
opt.run(fmax=0.05)

forces = water.get_forces()
energy = water.get_potential_energy()
positions = water.get_positions()

# Then test the IO routines
from ase.io import read
water2 = read('water.log')
forces2 = water2.get_forces()
energy2 = water2.get_potential_energy()
positions2 = water2.get_positions()
#compare distances since positions are different in standard orientation
示例#32
0
from ase.test import cli, require
from ase.db import connect
from ase.io.jsonio import read_json
from ase.calculators.gaussian import Gaussian

require('gaussian')
cli("""\
ase-build O | ase-run gaussian -d gaussian_cmdline.json &&
ase-build O2 | ase-run gaussian -d gaussian_cmdline.json""")
c = connect('gaussian_cmdline.json')
dct = read_json('gaussian_cmdline.json')
for name in ['O2', 'O']:
    d = c.get([('name', '=', name)])
    id = d.id
    e1 = d.energy
    e2 = c.get_atoms(id).get_potential_energy()
    e3 = Gaussian.read_atoms(name).get_potential_energy()
    e4 = dct[id]['energy']
    assert e1 == e2 == e3 == e4
    print(e1)
ae = 2 * c.get('name=O').energy - c.get('name=O2').energy
assert abs(ae - 1.060) < 1e-3