コード例 #1
0
ファイル: test_adf.py プロジェクト: bhourahine/CyGutz
    def test_from_string(self):
        k1 = AdfKey.from_string("CHARGE -1 0")
        self.assertEqual(k1.key, "CHARGE")
        self.assertListEqual(k1.options, [-1, 0])

        k2 = AdfKey.from_string("step rad=0.15 angle=10.0")
        self.assertEqual(k2.key, "step")
        self.assertListEqual(k2.options[0], ['rad', 0.15])
        self.assertListEqual(k2.options[1], ['angle', 10.0])

        k3 = AdfKey.from_string("GEOMETRY\noptim all\niterations 100\nEND\n")
        self.assertEqual(k3.key, "GEOMETRY")
        self.assertEqual(k3.subkeys[0].options[0], "all")
        self.assertEqual(k3.subkeys[1].options[0], 100)

        k4 = AdfKey.from_string("""SCF
            iterations 300
            converge 1.0e-7 1.0e-7
            mixing 0.2
            diis n=100 ok=0.0001 cyc=100 cx=5.0 cxx=10.0
            END""")
        self.assertEqual(k4.key, "SCF")
        self.assertEqual(k4.subkeys[0].key, "iterations")
        self.assertEqual(k4.subkeys[1].key, "converge")
        self.assertEqual(k4.subkeys[1].options[0], 1E-7)
        self.assertEqual(k4.subkeys[2].options[0], 0.2)
コード例 #2
0
ファイル: test_adf.py プロジェクト: ExpHP/pymatgen
    def test_from_string(self):
        k1 = AdfKey.from_string("CHARGE -1 0")
        self.assertEqual(k1.key, "CHARGE")
        self.assertListEqual(k1.options, [-1, 0])

        k2 = AdfKey.from_string("step rad=0.15 angle=10.0")
        self.assertEqual(k2.key, "step")
        self.assertListEqual(k2.options[0], ['rad', 0.15])
        self.assertListEqual(k2.options[1], ['angle', 10.0])

        k3 = AdfKey.from_string("GEOMETRY\noptim all\niterations 100\nEND\n")
        self.assertEqual(k3.key, "GEOMETRY")
        self.assertEqual(k3.subkeys[0].options[0], "all")
        self.assertEqual(k3.subkeys[1].options[0], 100)

        k4 = AdfKey.from_string(
            """SCF
            iterations 300
            converge 1.0e-7 1.0e-7
            mixing 0.2
            diis n=100 ok=0.0001 cyc=100 cx=5.0 cxx=10.0
            END"""
        )
        self.assertEqual(k4.key, "SCF")
        self.assertEqual(k4.subkeys[0].key, "iterations")
        self.assertEqual(k4.subkeys[1].key, "converge")
        self.assertEqual(k4.subkeys[1].options[0], 1E-7)
        self.assertEqual(k4.subkeys[2].options[0], 0.2)
コード例 #3
0
ファイル: test_adf.py プロジェクト: bhourahine/CyGutz
    def test_option_operations(self):
        k1 = AdfKey("Charge", [-1, 0])
        k1.add_option(2)
        self.assertListEqual(k1.options, [-1, 0, 2])
        k1.remove_option(0)
        self.assertListEqual(k1.options, [0, 2])

        k2 = AdfKey.from_string("step rad=0.15 angle=10.0")
        k2.add_option(["length", 0.1])
        self.assertListEqual(k2.options[2], ["length", 0.1])
        k2.remove_option("rad")
        self.assertListEqual(k2.options[0], ["angle", 10.0])
コード例 #4
0
ファイル: test_adf.py プロジェクト: ExpHP/pymatgen
    def test_option_operations(self):
        k1 = AdfKey("Charge", [-1, 0])
        k1.add_option(2)
        self.assertListEqual(k1.options, [-1, 0, 2])
        k1.remove_option(0)
        self.assertListEqual(k1.options, [0, 2])

        k2 = AdfKey.from_string("step rad=0.15 angle=10.0")
        k2.add_option(["length", 0.1])
        self.assertListEqual(k2.options[2], ["length", 0.1])
        k2.remove_option("rad")
        self.assertListEqual(k2.options[0], ["angle", 10.0])
コード例 #5
0
ファイル: test_adf.py プロジェクト: bhourahine/CyGutz
        task = AdfTask()
        o = AdfTask.from_dict(task.as_dict())
        self.assertEqual(task.title, o.title)
        self.assertEqual(task.basis_set, o.basis_set)
        self.assertEqual(task.scf, o.scf)
        self.assertEqual(task.geo, o.geo)
        self.assertEqual(task.operation, o.operation)
        self.assertEqual(task.units, o.units)
        self.assertEqual(str(task), str(o))


rhb18 = {
    "title":
    "RhB18",
    "basis_set":
    AdfKey.from_string("BASIS\ntype TZP\ncore small\nEND"),
    "xc":
    AdfKey.from_string("XC\nHybrid PBE0\nEND"),
    "units":
    AdfKey.from_string("UNITS\nlength angstrom\nEND"),
    "other_directives": [
        AdfKey.from_string("SYMMETRY"),
        AdfKey.from_string("RELATIVISTIC scalar zora"),
        AdfKey.from_string("INTEGRATION 6.0 6.0 6.0"),
        AdfKey.from_string("SAVE TAPE21"),
        AdfKey.from_string("A1FIT 10.0")
    ],
    "geo_subkeys": [
        AdfKey.from_string("optim all"),
        AdfKey.from_string("iterations 300"),
        AdfKey.from_string("step rad=0.15 angle=10.0"),
コード例 #6
0
ファイル: test_adf.py プロジェクト: ExpHP/pymatgen
        self.assertEqual(str(task), energy_task)

    def test_serialization(self):
        task = AdfTask()
        o = AdfTask.from_dict(task.as_dict())
        self.assertEqual(task.title, o.title)
        self.assertEqual(task.basis_set, o.basis_set)
        self.assertEqual(task.scf, o.scf)
        self.assertEqual(task.geo, o.geo)
        self.assertEqual(task.operation, o.operation)
        self.assertEqual(task.units, o.units)
        self.assertEqual(str(task), str(o))


rhb18 = {"title": "RhB18",
         "basis_set": AdfKey.from_string("BASIS\ntype TZP\ncore small\nEND"),
         "xc": AdfKey.from_string("XC\nHybrid PBE0\nEND"),
         "units": AdfKey.from_string("UNITS\nlength angstrom\nEND"),
         "other_directives": [AdfKey.from_string("SYMMETRY"),
                              AdfKey.from_string("RELATIVISTIC scalar zora"),
                              AdfKey.from_string("INTEGRATION 6.0 6.0 6.0"),
                              AdfKey.from_string("SAVE TAPE21"),
                              AdfKey.from_string("A1FIT 10.0")],
         "geo_subkeys": [AdfKey.from_string("optim all"),
                         AdfKey.from_string("iterations 300"),
                         AdfKey.from_string("step rad=0.15 angle=10.0"),
                         AdfKey.from_string("hessupd BFGS")],
         "scf": AdfKey.from_string(
             """SCF
             iterations 300
             converge 1.0e-7 1.0e-7