Example #1
0
 def test_odd_file(self):
     scramble = ''
     for s in self.ci.get_string():
         if np.random.rand(1) > .5:
             if s == "\t":
                 scramble += " "
             elif s == " ":
                 scramble += "  "
             elif s == '&':
                 scramble += s
             elif s == '\n':
                 scramble += s
             elif s.isalpha():
                 scramble += s.lower()
             else:
                 scramble += s
         else:
             scramble += s
     # Can you initialize from jumbled input
     # should be case insensitive and ignore
     # excessive white space or tabs
     ci = Cp2kInput.from_string(scramble)
     self.assertEqual(ci['FORCE_EVAL']['DFT']['UKS'], Keyword('UKS', True))
     self.assertEqual([
         k.name.upper()
         for k in ci['FORCE_EVAL']['DFT']['BASIS_SET_FILE_NAME']
     ], ['BASIS_SET_FILE_NAME', 'BASIS_SET_FILE_NAME'])
Example #2
0
 def test_odd_file(self):
     scramble = ""
     for s in self.ci.get_string():
         if np.random.rand(1) > 0.5:
             if s == "\t":
                 scramble += " "
             elif s == " ":
                 scramble += "  "
             elif s == "&":
                 scramble += s
             elif s == "\n":
                 scramble += s
             elif s.isalpha():
                 scramble += s.lower()
             else:
                 scramble += s
         else:
             scramble += s
     # Can you initialize from jumbled input
     # should be case insensitive and ignore
     # excessive white space or tabs
     ci = Cp2kInput.from_string(scramble)
     self.assertEqual(ci["FORCE_EVAL"]["DFT"]["UKS"], Keyword("UKS", True))
     self.assertEqual(
         [
             k.name.upper()
             for k in ci["FORCE_EVAL"]["DFT"]["BASIS_SET_FILE_NAME"]
         ],
         ["BASIS_SET_FILE_NAME", "BASIS_SET_FILE_NAME"],
     )
Example #3
0
 def test_basic_sections(self):
     s = """
     &GLOBAL
         RUN_TYPE ENERGY
         PROJECT_NAME CP2K ! default name
     &END
     """
     ci = Cp2kInput.from_string(s)
     self.assertEqual(ci["GLOBAL"]["RUN_TYPE"], Keyword("RUN_TYPE", "energy"))
     self.assertEqual(ci["GLOBAL"]["PROJECT_NAME"].description, "default name")
     self.assertMSONable(ci)
Example #4
0
 def test_basic_sections(self):
     s = """
     &GLOBAL
         RUN_TYPE ENERGY
         PROJECT_NAME CP2K ! default name
     &END
     """
     ci = Cp2kInput.from_string(s)
     self.assertEqual(ci['GLOBAL']['RUN_TYPE'],
                      Keyword('RUN_TYPE', 'energy'))
     self.assertEqual(ci['GLOBAL']['PROJECT_NAME'].description,
                      'default name')
     self.assertMSONable(ci)
Example #5
0
    def test_mongo(self):
        s = """
        &GLOBAL
            RUN_TYPE ENERGY
            PROJECT_NAME CP2K ! default name
        &END
        """
        s = Cp2kInput.from_string(s)
        s.inc({"GLOBAL": {"TEST": 1}})
        self.assertEqual(s["global"]["test"], Keyword("TEST", 1))

        s.unset({"GLOBAL": "RUN_TYPE"})
        self.assertFalse("RUN_TYPE" in s["global"].keywords)

        s.set({"GLOBAL": {"SUBSEC": {"TEST2": 2}, "SUBSEC2": {"Test2": 1}}})
        self.assertTrue(s.check("global/SUBSEC"))
        self.assertTrue(s.check("global/subsec2"))
Example #6
0
    def test_mongo(self):
        s = """
        &GLOBAL
            RUN_TYPE ENERGY
            PROJECT_NAME CP2K ! default name
        &END
        """
        s = Cp2kInput.from_string(s)
        s.inc({'GLOBAL': {'TEST': 1}})
        self.assertEqual(s['global']['test'], Keyword('TEST', 1))

        s.unset({'GLOBAL': 'RUN_TYPE'})
        self.assertFalse('RUN_TYPE' in s['global'].keywords)

        s.set({'GLOBAL': {'SUBSEC': {'TEST2': 2}, 'SUBSEC2': {'Test2': 1}}})
        self.assertTrue(s.check('global/SUBSEC'))
        self.assertTrue(s.check('global/subsec2'))
Example #7
0
 def setUp(self):
     self.TEST_FILES_DIR = Path.joinpath(self.TEST_FILES_DIR, "cp2k")
     self.ci = Cp2kInput.from_file(
         Path.joinpath(self.TEST_FILES_DIR, "cp2k.inp"))
Example #8
0
 def test_aux_basis(self):
     Si_aux_bases = ["FIT", "cFIT", "pFIT", "cpFIT"]
     for s in Si_aux_bases:
         cis = HybridStaticSet(Si_structure, aux_basis={"Si": s})
         cis = Cp2kInput.from_string(cis.get_string())
Example #9
0
 def test_aux_basis(self):
     Si_aux_bases = ['FIT', 'cFIT', 'pFIT', 'cpFIT']
     for s in Si_aux_bases:
         cis = HybridStaticSet(Si_structure, aux_basis={'Si': s})
         cis = Cp2kInput.from_string(cis.get_string())