Esempio n. 1
0
    def setUp(self):
        tasks = [
            NwTask.dft_task(mol,
                            operation="optimize",
                            xc="b3lyp",
                            basis_set="6-31++G*"),
            NwTask.dft_task(mol,
                            operation="freq",
                            xc="b3lyp",
                            basis_set="6-31++G*"),
            NwTask.dft_task(mol,
                            operation="energy",
                            xc="b3lyp",
                            basis_set="6-311++G**"),
            NwTask.dft_task(mol,
                            charge=mol.charge + 1,
                            operation="energy",
                            xc="b3lyp",
                            basis_set="6-311++G**"),
            NwTask.dft_task(mol,
                            charge=mol.charge - 1,
                            operation="energy",
                            xc="b3lyp",
                            basis_set="6-311++G**")
        ]

        self.nwi = NwInput(mol,
                           tasks,
                           geometry_options=["units", "angstroms", "noautoz"],
                           memory_options="total 1000 mb")
        self.nwi_symm = NwInput(
            mol,
            tasks,
            geometry_options=["units", "angstroms", "noautoz"],
            symmetry_options=["c1"])
Esempio n. 2
0
    def get_nwinput(self, mol):
        functional = "b3lyp"
        geom_opt_bset = {}
        scf_bset = {}
        for el in mol.composition.elements:
            geom_opt_bset[el.symbol] = "6-31+g*"
            scf_bset[el.symbol] = "6-31++g**" if el.Z <= 18 else "6-31+g*"

        if len(mol) > 1:
            # Insert opt and freq job for molecules with more than one atom.
            tasks = [
                NwTask.dft_task(mol, operation="optimize", xc=functional,
                                basis_set=geom_opt_bset),
                NwTask.dft_task(mol, operation="freq", xc=functional,
                                basis_set=geom_opt_bset)
            ]
        else:
            tasks = []

        tasks.extend([
            NwTask.dft_task(mol, operation="energy", xc=functional,
                            basis_set=scf_bset),
            NwTask.dft_task(mol, charge=mol.charge + 1, operation="energy",
                            xc=functional, basis_set=scf_bset),
            NwTask.dft_task(mol, charge=mol.charge - 1, operation="energy",
                            xc=functional, basis_set=scf_bset)
        ])

        return NwInput(mol, tasks)
Esempio n. 3
0
 def setUp(self):
     self.task = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="dft",
                        theory_directives={"xc": "b3lyp"})
     self.task_cosmo = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="dft",
                              theory_directives={"xc": "b3lyp"},
                              alternate_directives={'cosmo': "cosmo"})
     self.task_esp = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="esp")
Esempio n. 4
0
    def setUp(self):
        tasks = [
            NwTask.dft_task(mol, operation="optimize", xc="b3lyp", basis_set="6-31++G*"),
            NwTask.dft_task(mol, operation="freq", xc="b3lyp", basis_set="6-31++G*"),
            NwTask.dft_task(mol, operation="energy", xc="b3lyp", basis_set="6-311++G**"),
            NwTask.dft_task(mol, charge=mol.charge + 1, operation="energy", xc="b3lyp", basis_set="6-311++G**"),
            NwTask.dft_task(mol, charge=mol.charge - 1, operation="energy", xc="b3lyp", basis_set="6-311++G**"),
        ]

        self.nwi = NwInput(
            mol, tasks, geometry_options=["units", "angstroms", "noautoz"], memory_options="total 1000 mb"
        )
        self.nwi_symm = NwInput(mol, tasks, geometry_options=["units", "angstroms", "noautoz"], symmetry_options=["c1"])
Esempio n. 5
0
    def test_dft_cosmo_task(self):
        task = NwTask.dft_task(
            mol,
            charge=mol.charge,
            operation="energy",
            xc="b3lyp",
            basis_set="6-311++G**",
            alternate_directives={"cosmo": {
                "dielec": 78.0
            }},
        )
        ans = """title "H4C1 dft energy"
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-311++G**"
end
dft
 mult 1
 xc b3lyp
end
cosmo
 dielec 78.0
end
task dft energy"""
        self.assertEqual(str(task), ans)
Esempio n. 6
0
 def setUp(self):
     self.task = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="dft",
                        theory_directives={"xc": "b3lyp"})
     self.task_cosmo = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="dft",
                              theory_directives={"xc": "b3lyp"},
                              alternate_directives={'cosmo': "cosmo"})
     self.task_esp = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="esp")
Esempio n. 7
0
    def test_esp_task(self):
        task = NwTask.esp_task(mol, charge=mol.charge, operation="", basis_set="6-311++G**")
        ans = """title "H4C1 esp "
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-311++G**"
end

task esp """
        self.assertEqual(str(task), ans)
Esempio n. 8
0
    def test_esp_task(self):
        task = NwTask.esp_task(mol, charge=mol.charge, operation="",
                               basis_set="6-311++G**")
        ans = """title "H4C1 esp "
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-311++G**"
end

task esp """
        self.assertEqual(str(task), ans)
Esempio n. 9
0
    def test_dft_task(self):
        task = NwTask.dft_task(mol, charge=1, operation="energy")
        ans = """title "H4C1 dft energy"
charge 1
basis
 C library "6-31g"
 H library "6-31g"
end
dft
 mult 2
 xc b3lyp
end
task dft energy"""
        self.assertEqual(str(task), ans)
Esempio n. 10
0
    def test_dft_task(self):
        task = NwTask.dft_task(mol, charge=1, operation="energy")
        ans = """title "H4C1 dft energy"
charge 1
basis cartesian
 C library "6-31g"
 H library "6-31g"
end
dft
 mult 2
 xc b3lyp
end
task dft energy"""
        self.assertEqual(str(task), ans)
Esempio n. 11
0
    def test_multi_bset(self):
        t = NwTask.from_molecule(
            mol, theory="dft", basis_set={"C": "6-311++G**", "H": "6-31++G**"}, theory_directives={"xc": "b3lyp"}
        )
        ans = """title "H4C1 dft optimize"
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-31++G**"
end
dft
 xc b3lyp
end
task dft optimize"""
        self.assertEqual(str(t), ans)
Esempio n. 12
0
    def test_multi_bset(self):
        t = NwTask.from_molecule(
            mol, theory="dft", basis_set={"C": "6-311++G**",
                                          "H": "6-31++G**"},
            theory_directives={"xc": "b3lyp"})
        ans = """title "H4C1 dft optimize"
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-31++G**"
end
dft
 xc b3lyp
end
task dft optimize"""
        self.assertEqual(str(t), ans)
Esempio n. 13
0
    def test_dft_cosmo_task(self):
        task = NwTask.dft_task(
            mol, charge=mol.charge, operation="energy",
            xc="b3lyp", basis_set="6-311++G**",
            alternate_directives={'cosmo': {"dielec": 78.0}})
        ans = """title "H4C1 dft energy"
charge 0
basis
 C library "6-311++G**"
 H library "6-311++G**"
end
dft
 mult 1
 xc b3lyp
end
cosmo
 dielec 78.0
end
task dft energy"""
        self.assertEqual(str(task), ans)
Esempio n. 14
0
class NwTaskTest(unittest.TestCase):
    def setUp(self):
        self.task = NwTask(
            0,
            1,
            basis_set={"H": "6-31g"},
            theory="dft",
            theory_directives={"xc": "b3lyp"},
        )
        self.task_cosmo = NwTask(
            0,
            1,
            basis_set={"H": "6-31g"},
            theory="dft",
            theory_directives={"xc": "b3lyp"},
            alternate_directives={"cosmo": "cosmo"},
        )
        self.task_esp = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="esp")

    def test_multi_bset(self):
        t = NwTask.from_molecule(
            mol,
            theory="dft",
            basis_set={
                "C": "6-311++G**",
                "H": "6-31++G**"
            },
            theory_directives={"xc": "b3lyp"},
        )
        ans = """title "H4C1 dft optimize"
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-31++G**"
end
dft
 xc b3lyp
end
task dft optimize"""
        self.assertEqual(str(t), ans)

    def test_str_and_from_string(self):
        ans = """title "dft optimize"
charge 0
basis cartesian
 H library "6-31g"
end
dft
 xc b3lyp
end
task dft optimize"""
        self.assertEqual(str(self.task), ans)

    def test_to_from_dict(self):
        d = self.task.as_dict()
        t = NwTask.from_dict(d)
        self.assertIsInstance(t, NwTask)

    def test_init(self):
        self.assertRaises(NwInputError,
                          NwTask,
                          0,
                          1, {"H": "6-31g"},
                          theory="bad")
        self.assertRaises(NwInputError,
                          NwTask,
                          0,
                          1, {"H": "6-31g"},
                          operation="bad")

    def test_dft_task(self):
        task = NwTask.dft_task(mol, charge=1, operation="energy")
        ans = """title "H4C1 dft energy"
charge 1
basis cartesian
 C library "6-31g"
 H library "6-31g"
end
dft
 mult 2
 xc b3lyp
end
task dft energy"""
        self.assertEqual(str(task), ans)

    def test_dft_cosmo_task(self):
        task = NwTask.dft_task(
            mol,
            charge=mol.charge,
            operation="energy",
            xc="b3lyp",
            basis_set="6-311++G**",
            alternate_directives={"cosmo": {
                "dielec": 78.0
            }},
        )
        ans = """title "H4C1 dft energy"
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-311++G**"
end
dft
 mult 1
 xc b3lyp
end
cosmo
 dielec 78.0
end
task dft energy"""
        self.assertEqual(str(task), ans)

    def test_esp_task(self):
        task = NwTask.esp_task(mol,
                               charge=mol.charge,
                               operation="",
                               basis_set="6-311++G**")
        ans = """title "H4C1 esp "
charge 0
basis cartesian
 C library "6-311++G**"
 H library "6-311++G**"
end

task esp """
        self.assertEqual(str(task), ans)
Esempio n. 15
0
 def test_to_from_dict(self):
     d = self.task.as_dict()
     t = NwTask.from_dict(d)
     self.assertIsInstance(t, NwTask)
Esempio n. 16
0
 def test_to_from_dict(self):
     d = self.task.as_dict()
     t = NwTask.from_dict(d)
     self.assertIsInstance(t, NwTask)
Esempio n. 17
0
class NwTaskTest(unittest.TestCase):

    def setUp(self):
        self.task = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="dft",
                           theory_directives={"xc": "b3lyp"})
        self.task_cosmo = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="dft",
                                 theory_directives={"xc": "b3lyp"},
                                 alternate_directives={'cosmo': "cosmo"})
        self.task_esp = NwTask(0, 1, basis_set={"H": "6-31g"}, theory="esp")

    def test_multi_bset(self):
        t = NwTask.from_molecule(
            mol, theory="dft", basis_set={"C": "6-311++G**",
                                          "H": "6-31++G**"},
            theory_directives={"xc": "b3lyp"})
        ans = """title "H4C1 dft optimize"
charge 0
basis
 C library "6-311++G**"
 H library "6-31++G**"
end
dft
 xc b3lyp
end
task dft optimize"""
        self.assertEqual(str(t), ans)

    def test_str_and_from_string(self):

        ans = """title "dft optimize"
charge 0
basis
 H library "6-31g"
end
dft
 xc b3lyp
end
task dft optimize"""
        self.assertEqual(str(self.task), ans)

    def test_to_from_dict(self):
        d = self.task.as_dict()
        t = NwTask.from_dict(d)
        self.assertIsInstance(t, NwTask)

    def test_init(self):
        self.assertRaises(NwInputError, NwTask, 0, 1, {"H": "6-31g"},
                          theory="bad")
        self.assertRaises(NwInputError, NwTask, 0, 1, {"H": "6-31g"},
                          operation="bad")

    def test_dft_task(self):
        task = NwTask.dft_task(mol, charge=1, operation="energy")
        ans = """title "H4C1 dft energy"
charge 1
basis
 C library "6-31g"
 H library "6-31g"
end
dft
 mult 2
 xc b3lyp
end
task dft energy"""
        self.assertEqual(str(task), ans)

    def test_dft_cosmo_task(self):
        task = NwTask.dft_task(
            mol, charge=mol.charge, operation="energy",
            xc="b3lyp", basis_set="6-311++G**",
            alternate_directives={'cosmo': {"dielec": 78.0}})
        ans = """title "H4C1 dft energy"
charge 0
basis
 C library "6-311++G**"
 H library "6-311++G**"
end
dft
 mult 1
 xc b3lyp
end
cosmo
 dielec 78.0
end
task dft energy"""
        self.assertEqual(str(task), ans)

    def test_esp_task(self):
        task = NwTask.esp_task(mol, charge=mol.charge, operation="",
                               basis_set="6-311++G**")
        ans = """title "H4C1 esp "
charge 0
basis
 C library "6-311++G**"
 H library "6-311++G**"
end

task esp """
        self.assertEqual(str(task), ans)
Esempio n. 18
0
#!/usr/bin/env python
# coding: utf-8

from __future__ import division, print_function, unicode_literals, \
    absolute_import

from pymatgen import Molecule
from pymatgen.io.nwchem import NwInput, NwTask

coords = [[0.000000, 0.000000, 0.000000], [0.000000, 0.000000, 1.089000],
          [1.026719, 0.000000, -0.363000], [-0.513360, -0.889165, -0.363000],
          [-0.513360, 0.889165, -0.363000]]
mol = Molecule(["C", "H", "H", "H", "H"], coords)

tasks = [
    NwTask.dft_task(mol,
                    operation="optimize",
                    xc="b3lyp",
                    basis_set="6-31++G*"),
    NwTask.dft_task(mol, operation="freq", xc="b3lyp", basis_set="6-31++G*")
]
nwi = NwInput(mol, tasks)

print(nwi)