當前位置: 首頁>>代碼示例>>Python>>正文


Python NwTask.as_dict方法代碼示例

本文整理匯總了Python中pymatgen.io.nwchem.NwTask.as_dict方法的典型用法代碼示例。如果您正苦於以下問題:Python NwTask.as_dict方法的具體用法?Python NwTask.as_dict怎麽用?Python NwTask.as_dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pymatgen.io.nwchem.NwTask的用法示例。


在下文中一共展示了NwTask.as_dict方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: NwTaskTest

# 需要導入模塊: from pymatgen.io.nwchem import NwTask [as 別名]
# 或者: from pymatgen.io.nwchem.NwTask import as_dict [as 別名]
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)
開發者ID:sonium0,項目名稱:pymatgen,代碼行數:101,代碼來源:test_nwchem.py


注:本文中的pymatgen.io.nwchem.NwTask.as_dict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。